2 * EEPROMs access control driver for display configuration EEPROMs
5 * (C) 2011 DENX Software Engineering, Anatolij Gustschin <agust@denx.de>
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation.
11 * FIXME: this driver is used on a device-tree probed platform: it
12 * should be defined as a bit-banged SPI device and probed from the device
13 * tree and not like this with static grabbing of a few numbered GPIO
16 * Add proper SPI and EEPROM in arch/powerpc/boot/dts/digsy_mtc.dts
17 * and delete this driver.
20 #include <linux/gpio.h>
21 #include <linux/gpio/machine.h>
22 #include <linux/init.h>
23 #include <linux/platform_device.h>
24 #include <linux/spi/spi.h>
25 #include <linux/spi/spi_gpio.h>
26 #include <linux/eeprom_93xx46.h>
28 #define GPIO_EEPROM_CLK 216
29 #define GPIO_EEPROM_CS 210
30 #define GPIO_EEPROM_DI 217
31 #define GPIO_EEPROM_DO 249
32 #define GPIO_EEPROM_OE 255
33 #define EE_SPI_BUS_NUM 1
35 static void digsy_mtc_op_prepare(void *p
)
38 gpio_set_value(GPIO_EEPROM_OE
, 0);
41 static void digsy_mtc_op_finish(void *p
)
44 gpio_set_value(GPIO_EEPROM_OE
, 1);
47 struct eeprom_93xx46_platform_data digsy_mtc_eeprom_data
= {
49 .prepare
= digsy_mtc_op_prepare
,
50 .finish
= digsy_mtc_op_finish
,
53 static struct spi_gpio_platform_data eeprom_spi_gpio_data
= {
57 static struct platform_device digsy_mtc_eeprom
= {
61 .platform_data
= &eeprom_spi_gpio_data
,
65 static struct gpiod_lookup_table eeprom_spi_gpiod_table
= {
68 GPIO_LOOKUP("gpio@b00", GPIO_EEPROM_CLK
,
69 "sck", GPIO_ACTIVE_HIGH
),
70 GPIO_LOOKUP("gpio@b00", GPIO_EEPROM_DI
,
71 "mosi", GPIO_ACTIVE_HIGH
),
72 GPIO_LOOKUP("gpio@b00", GPIO_EEPROM_DO
,
73 "miso", GPIO_ACTIVE_HIGH
),
74 GPIO_LOOKUP("gpio@b00", GPIO_EEPROM_CS
,
75 "cs", GPIO_ACTIVE_HIGH
),
80 static struct spi_board_info digsy_mtc_eeprom_info
[] __initdata
= {
83 .max_speed_hz
= 1000000,
84 .bus_num
= EE_SPI_BUS_NUM
,
87 .platform_data
= &digsy_mtc_eeprom_data
,
91 static int __init
digsy_mtc_eeprom_devices_init(void)
95 ret
= gpio_request_one(GPIO_EEPROM_OE
, GPIOF_OUT_INIT_HIGH
,
98 pr_err("can't request gpio %d\n", GPIO_EEPROM_OE
);
101 gpiod_add_lookup_table(&eeprom_spi_gpiod_table
);
102 spi_register_board_info(digsy_mtc_eeprom_info
,
103 ARRAY_SIZE(digsy_mtc_eeprom_info
));
104 return platform_device_register(&digsy_mtc_eeprom
);
106 device_initcall(digsy_mtc_eeprom_devices_init
);