aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/misc
diff options
context:
space:
mode:
authorAnatolij Gustschin <agust@denx.de>2011-07-25 20:13:29 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2011-07-25 23:57:16 -0400
commit469dded1839105cfbfc265376e23e24dbc48d2a7 (patch)
treec020b0896fc26b49d42a8ebe919df7546aa7fceb /drivers/misc
parent06b4501e88ad10f02849a3f9d7408ed6ae15a53f (diff)
misc/eeprom: add eeprom access driver for digsy_mtc board
Both displays on digsy_mtc board obtain their configuration from microwire EEPROMs which are connected to the SoC over GPIO lines. We need an easy way to access the EEPROMs to write the needed display configuration or to read out the currently programmed configuration. The generic eeprom_93xx46 SPI driver added by previous patch allows EEPROM access over sysfs. Using the simple driver added by this patch we provide used GPIO interface and access control description on the board for generic eeprom_93xx46 driver and spi_gpio driver. Signed-off-by: Anatolij Gustschin <agust@denx.de> Cc: Jonathan Cameron <jic23@cam.ac.uk> Cc: Grant Likely <grant.likely@secretlab.ca> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/misc')
-rw-r--r--drivers/misc/eeprom/Kconfig12
-rw-r--r--drivers/misc/eeprom/Makefile1
-rw-r--r--drivers/misc/eeprom/digsy_mtc_eeprom.c85
3 files changed, 98 insertions, 0 deletions
diff --git a/drivers/misc/eeprom/Kconfig b/drivers/misc/eeprom/Kconfig
index 620de283b40b..26cf12ca7f50 100644
--- a/drivers/misc/eeprom/Kconfig
+++ b/drivers/misc/eeprom/Kconfig
@@ -83,4 +83,16 @@ config EEPROM_93XX46
83 83
84 If unsure, say N. 84 If unsure, say N.
85 85
86config EEPROM_DIGSY_MTC_CFG
87 bool "DigsyMTC display configuration EEPROMs device"
88 depends on PPC_MPC5200_GPIO && GPIOLIB && SPI_GPIO
89 help
90 This option enables access to display configuration EEPROMs
91 on digsy_mtc board. You have to additionally select Microwire
92 EEPROM 93XX46 driver. sysfs entries will be created for that
93 EEPROM allowing to read/write the configuration data or to
94 erase the whole EEPROM.
95
96 If unsure, say N.
97
86endmenu 98endmenu
diff --git a/drivers/misc/eeprom/Makefile b/drivers/misc/eeprom/Makefile
index ec55aad24cfb..fc1e81d29267 100644
--- a/drivers/misc/eeprom/Makefile
+++ b/drivers/misc/eeprom/Makefile
@@ -4,3 +4,4 @@ obj-$(CONFIG_EEPROM_LEGACY) += eeprom.o
4obj-$(CONFIG_EEPROM_MAX6875) += max6875.o 4obj-$(CONFIG_EEPROM_MAX6875) += max6875.o
5obj-$(CONFIG_EEPROM_93CX6) += eeprom_93cx6.o 5obj-$(CONFIG_EEPROM_93CX6) += eeprom_93cx6.o
6obj-$(CONFIG_EEPROM_93XX46) += eeprom_93xx46.o 6obj-$(CONFIG_EEPROM_93XX46) += eeprom_93xx46.o
7obj-$(CONFIG_EEPROM_DIGSY_MTC_CFG) += digsy_mtc_eeprom.o
diff --git a/drivers/misc/eeprom/digsy_mtc_eeprom.c b/drivers/misc/eeprom/digsy_mtc_eeprom.c
new file mode 100644
index 000000000000..66d9e1baeae5
--- /dev/null
+++ b/drivers/misc/eeprom/digsy_mtc_eeprom.c
@@ -0,0 +1,85 @@
1/*
2 * EEPROMs access control driver for display configuration EEPROMs
3 * on DigsyMTC board.
4 *
5 * (C) 2011 DENX Software Engineering, Anatolij Gustschin <agust@denx.de>
6 *
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.
10 */
11
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>
18
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
25
26static void digsy_mtc_op_prepare(void *p)
27{
28 /* enable */
29 gpio_set_value(GPIO_EEPROM_OE, 0);
30}
31
32static void digsy_mtc_op_finish(void *p)
33{
34 /* disable */
35 gpio_set_value(GPIO_EEPROM_OE, 1);
36}
37
38struct eeprom_93xx46_platform_data digsy_mtc_eeprom_data = {
39 .flags = EE_ADDR8,
40 .prepare = digsy_mtc_op_prepare,
41 .finish = digsy_mtc_op_finish,
42};
43
44static struct spi_gpio_platform_data eeprom_spi_gpio_data = {
45 .sck = GPIO_EEPROM_CLK,
46 .mosi = GPIO_EEPROM_DI,
47 .miso = GPIO_EEPROM_DO,
48 .num_chipselect = 1,
49};
50
51static struct platform_device digsy_mtc_eeprom = {
52 .name = "spi_gpio",
53 .id = EE_SPI_BUS_NUM,
54 .dev = {
55 .platform_data = &eeprom_spi_gpio_data,
56 },
57};
58
59static struct spi_board_info digsy_mtc_eeprom_info[] __initdata = {
60 {
61 .modalias = "93xx46",
62 .max_speed_hz = 1000000,
63 .bus_num = EE_SPI_BUS_NUM,
64 .chip_select = 0,
65 .mode = SPI_MODE_0,
66 .controller_data = (void *)GPIO_EEPROM_CS,
67 .platform_data = &digsy_mtc_eeprom_data,
68 },
69};
70
71static int __init digsy_mtc_eeprom_devices_init(void)
72{
73 int ret;
74
75 ret = gpio_request_one(GPIO_EEPROM_OE, GPIOF_OUT_INIT_HIGH,
76 "93xx46 EEPROMs OE");
77 if (ret) {
78 pr_err("can't request gpio %d\n", GPIO_EEPROM_OE);
79 return ret;
80 }
81 spi_register_board_info(digsy_mtc_eeprom_info,
82 ARRAY_SIZE(digsy_mtc_eeprom_info));
83 return platform_device_register(&digsy_mtc_eeprom);
84}
85device_initcall(digsy_mtc_eeprom_devices_init);