1 // SPDX-License-Identifier: GPL-2.0-only
3 * EEPROMs access control driver for display configuration EEPROMs
8 * FIXME: this driver is used on a device-tree probed platform: it
9 * should be defined as a bit-banged SPI device and probed from the device
10 * tree and not like this with static grabbing of a few numbered GPIO
13 * Add proper SPI and EEPROM in arch/powerpc/boot/dts/digsy_mtc.dts
14 * and delete this driver.
17 #include <linux/gpio/machine.h>
18 #include <linux/init.h>
19 #include <linux/platform_device.h>
20 #include <linux/property.h>
21 #include <linux/spi/spi.h>
22 #include <linux/spi/spi_gpio.h>
24 #define GPIO_EEPROM_CLK 216
25 #define GPIO_EEPROM_CS 210
26 #define GPIO_EEPROM_DI 217
27 #define GPIO_EEPROM_DO 249
28 #define GPIO_EEPROM_OE 255
29 #define EE_SPI_BUS_NUM 1
31 static const struct property_entry digsy_mtc_spi_properties[] = {
32 PROPERTY_ENTRY_U32("data-size", 8),
36 static const struct software_node digsy_mtc_spi_node = {
37 .properties = digsy_mtc_spi_properties,
40 static struct spi_gpio_platform_data eeprom_spi_gpio_data = {
44 static struct platform_device digsy_mtc_eeprom = {
48 .platform_data = &eeprom_spi_gpio_data,
52 static struct gpiod_lookup_table eeprom_spi_gpiod_table = {
55 GPIO_LOOKUP("gpio@b00", GPIO_EEPROM_CLK,
56 "sck", GPIO_ACTIVE_HIGH),
57 GPIO_LOOKUP("gpio@b00", GPIO_EEPROM_DI,
58 "mosi", GPIO_ACTIVE_HIGH),
59 GPIO_LOOKUP("gpio@b00", GPIO_EEPROM_DO,
60 "miso", GPIO_ACTIVE_HIGH),
61 GPIO_LOOKUP("gpio@b00", GPIO_EEPROM_CS,
62 "cs", GPIO_ACTIVE_HIGH),
63 GPIO_LOOKUP("gpio@b00", GPIO_EEPROM_OE,
64 "select", GPIO_ACTIVE_LOW),
69 static struct spi_board_info digsy_mtc_eeprom_info[] __initdata = {
71 .modalias = "eeprom-93xx46",
72 .max_speed_hz = 1000000,
73 .bus_num = EE_SPI_BUS_NUM,
79 static int __init digsy_mtc_eeprom_devices_init(void)
83 gpiod_add_lookup_table(&eeprom_spi_gpiod_table);
84 spi_register_board_info(digsy_mtc_eeprom_info,
85 ARRAY_SIZE(digsy_mtc_eeprom_info));
87 ret = device_add_software_node(&digsy_mtc_eeprom.dev, &digsy_mtc_spi_node);
91 ret = platform_device_register(&digsy_mtc_eeprom);
93 device_remove_software_node(&digsy_mtc_eeprom.dev);
97 device_initcall(digsy_mtc_eeprom_devices_init);