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.
12 #include <linux/gpio.h>
13 #include <linux/init.h>
14 #include <linux/platform_device.h>
15 #include <linux/spi/spi.h>
16 #include <linux/spi/spi_gpio.h>
17 #include <linux/eeprom_93xx46.h>
19 #define GPIO_EEPROM_CLK 216
20 #define GPIO_EEPROM_CS 210
21 #define GPIO_EEPROM_DI 217
22 #define GPIO_EEPROM_DO 249
23 #define GPIO_EEPROM_OE 255
24 #define EE_SPI_BUS_NUM 1
26 static void digsy_mtc_op_prepare(void *p
)
29 gpio_set_value(GPIO_EEPROM_OE
, 0);
32 static void digsy_mtc_op_finish(void *p
)
35 gpio_set_value(GPIO_EEPROM_OE
, 1);
38 struct eeprom_93xx46_platform_data digsy_mtc_eeprom_data
= {
40 .prepare
= digsy_mtc_op_prepare
,
41 .finish
= digsy_mtc_op_finish
,
44 static struct spi_gpio_platform_data eeprom_spi_gpio_data
= {
45 .sck
= GPIO_EEPROM_CLK
,
46 .mosi
= GPIO_EEPROM_DI
,
47 .miso
= GPIO_EEPROM_DO
,
51 static struct platform_device digsy_mtc_eeprom
= {
55 .platform_data
= &eeprom_spi_gpio_data
,
59 static struct spi_board_info digsy_mtc_eeprom_info
[] __initdata
= {
62 .max_speed_hz
= 1000000,
63 .bus_num
= EE_SPI_BUS_NUM
,
66 .controller_data
= (void *)GPIO_EEPROM_CS
,
67 .platform_data
= &digsy_mtc_eeprom_data
,
71 static int __init
digsy_mtc_eeprom_devices_init(void)
75 ret
= gpio_request_one(GPIO_EEPROM_OE
, GPIOF_OUT_INIT_HIGH
,
78 pr_err("can't request gpio %d\n", GPIO_EEPROM_OE
);
81 spi_register_board_info(digsy_mtc_eeprom_info
,
82 ARRAY_SIZE(digsy_mtc_eeprom_info
));
83 return platform_device_register(&digsy_mtc_eeprom
);
85 device_initcall(digsy_mtc_eeprom_devices_init
);