diff options
author | Wolfram Sang <wsa@the-dreams.de> | 2019-02-14 12:03:21 -0500 |
---|---|---|
committer | Wolfram Sang <wsa@the-dreams.de> | 2019-02-14 12:03:21 -0500 |
commit | bceb26bffebf4c8f167787eb87b6a858d991e48e (patch) | |
tree | 15c226de65a290bf897e9915b54a6bc920ae979a | |
parent | d8434c31378d5f2009741fa171bd1143c77a6e4a (diff) | |
parent | 950bcbbe31548636d24e49b3abaf3780204f7fe8 (diff) |
Merge tag 'at24-5.1-updates-for-wolfram' of git://git.kernel.org/pub/scm/linux/kernel/git/brgl/linux into i2c/for-5.1
at24 updates for v5.1
- finally remove legacy platform data as all users have been switched
to using device properties and nvmem notifier chain
- add support for the 'num-addresses' property
-rw-r--r-- | Documentation/devicetree/bindings/eeprom/at24.txt | 3 | ||||
-rw-r--r-- | MAINTAINERS | 1 | ||||
-rw-r--r-- | arch/arm/mach-davinci/board-da830-evm.c | 13 | ||||
-rw-r--r-- | arch/arm/mach-davinci/board-da850-evm.c | 28 | ||||
-rw-r--r-- | arch/arm/mach-davinci/board-dm365-evm.c | 13 | ||||
-rw-r--r-- | arch/arm/mach-davinci/board-dm644x-evm.c | 13 | ||||
-rw-r--r-- | arch/arm/mach-davinci/board-dm646x-evm.c | 13 | ||||
-rw-r--r-- | arch/arm/mach-davinci/board-mityomapl138.c | 38 | ||||
-rw-r--r-- | arch/arm/mach-davinci/board-sffsdr.c | 13 | ||||
-rw-r--r-- | arch/arm/mach-davinci/common.c | 15 | ||||
-rw-r--r-- | drivers/misc/eeprom/at24.c | 169 | ||||
-rw-r--r-- | include/linux/davinci_emac.h | 1 | ||||
-rw-r--r-- | include/linux/platform_data/at24.h | 60 |
13 files changed, 130 insertions, 250 deletions
diff --git a/Documentation/devicetree/bindings/eeprom/at24.txt b/Documentation/devicetree/bindings/eeprom/at24.txt index f9a7c984274c..0e456bbc1213 100644 --- a/Documentation/devicetree/bindings/eeprom/at24.txt +++ b/Documentation/devicetree/bindings/eeprom/at24.txt | |||
@@ -75,6 +75,8 @@ Optional properties: | |||
75 | 75 | ||
76 | - address-width: number of address bits (one of 8, 16). | 76 | - address-width: number of address bits (one of 8, 16). |
77 | 77 | ||
78 | - num-addresses: total number of i2c slave addresses this device takes | ||
79 | |||
78 | Example: | 80 | Example: |
79 | 81 | ||
80 | eeprom@52 { | 82 | eeprom@52 { |
@@ -82,4 +84,5 @@ eeprom@52 { | |||
82 | reg = <0x52>; | 84 | reg = <0x52>; |
83 | pagesize = <32>; | 85 | pagesize = <32>; |
84 | wp-gpios = <&gpio1 3 0>; | 86 | wp-gpios = <&gpio1 3 0>; |
87 | num-addresses = <8>; | ||
85 | }; | 88 | }; |
diff --git a/MAINTAINERS b/MAINTAINERS index 9919840d54cd..d901919dd475 100644 --- a/MAINTAINERS +++ b/MAINTAINERS | |||
@@ -2503,7 +2503,6 @@ T: git git://git.kernel.org/pub/scm/linux/kernel/git/brgl/linux.git | |||
2503 | S: Maintained | 2503 | S: Maintained |
2504 | F: Documentation/devicetree/bindings/eeprom/at24.txt | 2504 | F: Documentation/devicetree/bindings/eeprom/at24.txt |
2505 | F: drivers/misc/eeprom/at24.c | 2505 | F: drivers/misc/eeprom/at24.c |
2506 | F: include/linux/platform_data/at24.h | ||
2507 | 2506 | ||
2508 | ATA OVER ETHERNET (AOE) DRIVER | 2507 | ATA OVER ETHERNET (AOE) DRIVER |
2509 | M: "Ed L. Cashin" <ed.cashin@acm.org> | 2508 | M: "Ed L. Cashin" <ed.cashin@acm.org> |
diff --git a/arch/arm/mach-davinci/board-da830-evm.c b/arch/arm/mach-davinci/board-da830-evm.c index c4da635ee4ce..669b4ca3b9c2 100644 --- a/arch/arm/mach-davinci/board-da830-evm.c +++ b/arch/arm/mach-davinci/board-da830-evm.c | |||
@@ -18,7 +18,7 @@ | |||
18 | #include <linux/platform_device.h> | 18 | #include <linux/platform_device.h> |
19 | #include <linux/i2c.h> | 19 | #include <linux/i2c.h> |
20 | #include <linux/platform_data/pcf857x.h> | 20 | #include <linux/platform_data/pcf857x.h> |
21 | #include <linux/platform_data/at24.h> | 21 | #include <linux/property.h> |
22 | #include <linux/mtd/mtd.h> | 22 | #include <linux/mtd/mtd.h> |
23 | #include <linux/mtd/partitions.h> | 23 | #include <linux/mtd/partitions.h> |
24 | #include <linux/spi/spi.h> | 24 | #include <linux/spi/spi.h> |
@@ -457,12 +457,9 @@ static struct nvmem_cell_lookup da830_evm_nvmem_cell_lookup = { | |||
457 | .con_id = "mac-address", | 457 | .con_id = "mac-address", |
458 | }; | 458 | }; |
459 | 459 | ||
460 | static struct at24_platform_data da830_evm_i2c_eeprom_info = { | 460 | static const struct property_entry da830_evm_i2c_eeprom_properties[] = { |
461 | .byte_len = SZ_256K / 8, | 461 | PROPERTY_ENTRY_U32("pagesize", 64), |
462 | .page_size = 64, | 462 | { } |
463 | .flags = AT24_FLAG_ADDR16, | ||
464 | .setup = davinci_get_mac_addr, | ||
465 | .context = (void *)0x7f00, | ||
466 | }; | 463 | }; |
467 | 464 | ||
468 | static int __init da830_evm_ui_expander_setup(struct i2c_client *client, | 465 | static int __init da830_evm_ui_expander_setup(struct i2c_client *client, |
@@ -496,7 +493,7 @@ static struct pcf857x_platform_data __initdata da830_evm_ui_expander_info = { | |||
496 | static struct i2c_board_info __initdata da830_evm_i2c_devices[] = { | 493 | static struct i2c_board_info __initdata da830_evm_i2c_devices[] = { |
497 | { | 494 | { |
498 | I2C_BOARD_INFO("24c256", 0x50), | 495 | I2C_BOARD_INFO("24c256", 0x50), |
499 | .platform_data = &da830_evm_i2c_eeprom_info, | 496 | .properties = da830_evm_i2c_eeprom_properties, |
500 | }, | 497 | }, |
501 | { | 498 | { |
502 | I2C_BOARD_INFO("tlv320aic3x", 0x18), | 499 | I2C_BOARD_INFO("tlv320aic3x", 0x18), |
diff --git a/arch/arm/mach-davinci/board-da850-evm.c b/arch/arm/mach-davinci/board-da850-evm.c index 44bca048dfd0..3490ed382716 100644 --- a/arch/arm/mach-davinci/board-da850-evm.c +++ b/arch/arm/mach-davinci/board-da850-evm.c | |||
@@ -150,32 +150,6 @@ static struct spi_board_info da850evm_spi_info[] = { | |||
150 | }, | 150 | }, |
151 | }; | 151 | }; |
152 | 152 | ||
153 | #ifdef CONFIG_MTD | ||
154 | static void da850_evm_m25p80_notify_add(struct mtd_info *mtd) | ||
155 | { | ||
156 | char *mac_addr = davinci_soc_info.emac_pdata->mac_addr; | ||
157 | size_t retlen; | ||
158 | |||
159 | if (!strcmp(mtd->name, "MAC-Address")) { | ||
160 | mtd_read(mtd, 0, ETH_ALEN, &retlen, mac_addr); | ||
161 | if (retlen == ETH_ALEN) | ||
162 | pr_info("Read MAC addr from SPI Flash: %pM\n", | ||
163 | mac_addr); | ||
164 | } | ||
165 | } | ||
166 | |||
167 | static struct mtd_notifier da850evm_spi_notifier = { | ||
168 | .add = da850_evm_m25p80_notify_add, | ||
169 | }; | ||
170 | |||
171 | static void da850_evm_setup_mac_addr(void) | ||
172 | { | ||
173 | register_mtd_user(&da850evm_spi_notifier); | ||
174 | } | ||
175 | #else | ||
176 | static void da850_evm_setup_mac_addr(void) { } | ||
177 | #endif | ||
178 | |||
179 | static struct mtd_partition da850_evm_norflash_partition[] = { | 153 | static struct mtd_partition da850_evm_norflash_partition[] = { |
180 | { | 154 | { |
181 | .name = "bootloaders + env", | 155 | .name = "bootloaders + env", |
@@ -1494,8 +1468,6 @@ static __init void da850_evm_init(void) | |||
1494 | if (ret) | 1468 | if (ret) |
1495 | pr_warn("%s: SATA registration failed: %d\n", __func__, ret); | 1469 | pr_warn("%s: SATA registration failed: %d\n", __func__, ret); |
1496 | 1470 | ||
1497 | da850_evm_setup_mac_addr(); | ||
1498 | |||
1499 | ret = da8xx_register_rproc(); | 1471 | ret = da8xx_register_rproc(); |
1500 | if (ret) | 1472 | if (ret) |
1501 | pr_warn("%s: dsp/rproc registration failed: %d\n", | 1473 | pr_warn("%s: dsp/rproc registration failed: %d\n", |
diff --git a/arch/arm/mach-davinci/board-dm365-evm.c b/arch/arm/mach-davinci/board-dm365-evm.c index e3b0b701e395..f21dc8d3b28c 100644 --- a/arch/arm/mach-davinci/board-dm365-evm.c +++ b/arch/arm/mach-davinci/board-dm365-evm.c | |||
@@ -18,7 +18,7 @@ | |||
18 | #include <linux/i2c.h> | 18 | #include <linux/i2c.h> |
19 | #include <linux/io.h> | 19 | #include <linux/io.h> |
20 | #include <linux/clk.h> | 20 | #include <linux/clk.h> |
21 | #include <linux/platform_data/at24.h> | 21 | #include <linux/property.h> |
22 | #include <linux/leds.h> | 22 | #include <linux/leds.h> |
23 | #include <linux/mtd/mtd.h> | 23 | #include <linux/mtd/mtd.h> |
24 | #include <linux/mtd/partitions.h> | 24 | #include <linux/mtd/partitions.h> |
@@ -225,18 +225,15 @@ static struct nvmem_cell_lookup davinci_nvmem_cell_lookup = { | |||
225 | .con_id = "mac-address", | 225 | .con_id = "mac-address", |
226 | }; | 226 | }; |
227 | 227 | ||
228 | static struct at24_platform_data eeprom_info = { | 228 | static const struct property_entry eeprom_properties[] = { |
229 | .byte_len = (256*1024) / 8, | 229 | PROPERTY_ENTRY_U32("pagesize", 64), |
230 | .page_size = 64, | 230 | { } |
231 | .flags = AT24_FLAG_ADDR16, | ||
232 | .setup = davinci_get_mac_addr, | ||
233 | .context = (void *)0x7f00, | ||
234 | }; | 231 | }; |
235 | 232 | ||
236 | static struct i2c_board_info i2c_info[] = { | 233 | static struct i2c_board_info i2c_info[] = { |
237 | { | 234 | { |
238 | I2C_BOARD_INFO("24c256", 0x50), | 235 | I2C_BOARD_INFO("24c256", 0x50), |
239 | .platform_data = &eeprom_info, | 236 | .properties = eeprom_properties, |
240 | }, | 237 | }, |
241 | { | 238 | { |
242 | I2C_BOARD_INFO("tlv320aic3x", 0x18), | 239 | I2C_BOARD_INFO("tlv320aic3x", 0x18), |
diff --git a/arch/arm/mach-davinci/board-dm644x-evm.c b/arch/arm/mach-davinci/board-dm644x-evm.c index b80c4ee76217..ecd30643c2c4 100644 --- a/arch/arm/mach-davinci/board-dm644x-evm.c +++ b/arch/arm/mach-davinci/board-dm644x-evm.c | |||
@@ -16,8 +16,8 @@ | |||
16 | #include <linux/gpio/machine.h> | 16 | #include <linux/gpio/machine.h> |
17 | #include <linux/i2c.h> | 17 | #include <linux/i2c.h> |
18 | #include <linux/platform_data/pcf857x.h> | 18 | #include <linux/platform_data/pcf857x.h> |
19 | #include <linux/platform_data/at24.h> | ||
20 | #include <linux/platform_data/gpio-davinci.h> | 19 | #include <linux/platform_data/gpio-davinci.h> |
20 | #include <linux/property.h> | ||
21 | #include <linux/mtd/mtd.h> | 21 | #include <linux/mtd/mtd.h> |
22 | #include <linux/mtd/rawnand.h> | 22 | #include <linux/mtd/rawnand.h> |
23 | #include <linux/mtd/partitions.h> | 23 | #include <linux/mtd/partitions.h> |
@@ -532,12 +532,9 @@ static struct nvmem_cell_lookup dm644evm_nvmem_cell_lookup = { | |||
532 | .con_id = "mac-address", | 532 | .con_id = "mac-address", |
533 | }; | 533 | }; |
534 | 534 | ||
535 | static struct at24_platform_data eeprom_info = { | 535 | static const struct property_entry eeprom_properties[] = { |
536 | .byte_len = (256*1024) / 8, | 536 | PROPERTY_ENTRY_U32("pagesize", 64), |
537 | .page_size = 64, | 537 | { } |
538 | .flags = AT24_FLAG_ADDR16, | ||
539 | .setup = davinci_get_mac_addr, | ||
540 | .context = (void *)0x7f00, | ||
541 | }; | 538 | }; |
542 | 539 | ||
543 | /* | 540 | /* |
@@ -647,7 +644,7 @@ static struct i2c_board_info __initdata i2c_info[] = { | |||
647 | }, | 644 | }, |
648 | { | 645 | { |
649 | I2C_BOARD_INFO("24c256", 0x50), | 646 | I2C_BOARD_INFO("24c256", 0x50), |
650 | .platform_data = &eeprom_info, | 647 | .properties = eeprom_properties, |
651 | }, | 648 | }, |
652 | { | 649 | { |
653 | I2C_BOARD_INFO("tlv320aic33", 0x1b), | 650 | I2C_BOARD_INFO("tlv320aic33", 0x1b), |
diff --git a/arch/arm/mach-davinci/board-dm646x-evm.c b/arch/arm/mach-davinci/board-dm646x-evm.c index 8d5be6dd2019..02b57face113 100644 --- a/arch/arm/mach-davinci/board-dm646x-evm.c +++ b/arch/arm/mach-davinci/board-dm646x-evm.c | |||
@@ -22,7 +22,7 @@ | |||
22 | #include <linux/gpio.h> | 22 | #include <linux/gpio.h> |
23 | #include <linux/platform_device.h> | 23 | #include <linux/platform_device.h> |
24 | #include <linux/i2c.h> | 24 | #include <linux/i2c.h> |
25 | #include <linux/platform_data/at24.h> | 25 | #include <linux/property.h> |
26 | #include <linux/platform_data/pcf857x.h> | 26 | #include <linux/platform_data/pcf857x.h> |
27 | #include <linux/platform_data/ti-aemif.h> | 27 | #include <linux/platform_data/ti-aemif.h> |
28 | 28 | ||
@@ -364,12 +364,9 @@ static struct nvmem_cell_lookup dm646x_evm_nvmem_cell_lookup = { | |||
364 | .con_id = "mac-address", | 364 | .con_id = "mac-address", |
365 | }; | 365 | }; |
366 | 366 | ||
367 | static struct at24_platform_data eeprom_info = { | 367 | static const struct property_entry eeprom_properties[] = { |
368 | .byte_len = (256*1024) / 8, | 368 | PROPERTY_ENTRY_U32("pagesize", 64), |
369 | .page_size = 64, | 369 | { } |
370 | .flags = AT24_FLAG_ADDR16, | ||
371 | .setup = davinci_get_mac_addr, | ||
372 | .context = (void *)0x7f00, | ||
373 | }; | 370 | }; |
374 | #endif | 371 | #endif |
375 | 372 | ||
@@ -440,7 +437,7 @@ static void evm_init_cpld(void) | |||
440 | static struct i2c_board_info __initdata i2c_info[] = { | 437 | static struct i2c_board_info __initdata i2c_info[] = { |
441 | { | 438 | { |
442 | I2C_BOARD_INFO("24c256", 0x50), | 439 | I2C_BOARD_INFO("24c256", 0x50), |
443 | .platform_data = &eeprom_info, | 440 | .properties = eeprom_properties, |
444 | }, | 441 | }, |
445 | { | 442 | { |
446 | I2C_BOARD_INFO("pcf8574a", 0x38), | 443 | I2C_BOARD_INFO("pcf8574a", 0x38), |
diff --git a/arch/arm/mach-davinci/board-mityomapl138.c b/arch/arm/mach-davinci/board-mityomapl138.c index 8df16e81b69e..a381b26328d8 100644 --- a/arch/arm/mach-davinci/board-mityomapl138.c +++ b/arch/arm/mach-davinci/board-mityomapl138.c | |||
@@ -14,11 +14,13 @@ | |||
14 | #include <linux/init.h> | 14 | #include <linux/init.h> |
15 | #include <linux/console.h> | 15 | #include <linux/console.h> |
16 | #include <linux/platform_device.h> | 16 | #include <linux/platform_device.h> |
17 | #include <linux/property.h> | ||
17 | #include <linux/mtd/partitions.h> | 18 | #include <linux/mtd/partitions.h> |
19 | #include <linux/notifier.h> | ||
20 | #include <linux/nvmem-consumer.h> | ||
18 | #include <linux/nvmem-provider.h> | 21 | #include <linux/nvmem-provider.h> |
19 | #include <linux/regulator/machine.h> | 22 | #include <linux/regulator/machine.h> |
20 | #include <linux/i2c.h> | 23 | #include <linux/i2c.h> |
21 | #include <linux/platform_data/at24.h> | ||
22 | #include <linux/etherdevice.h> | 24 | #include <linux/etherdevice.h> |
23 | #include <linux/spi/spi.h> | 25 | #include <linux/spi/spi.h> |
24 | #include <linux/spi/flash.h> | 26 | #include <linux/spi/flash.h> |
@@ -117,11 +119,15 @@ static void mityomapl138_cpufreq_init(const char *partnum) | |||
117 | static void mityomapl138_cpufreq_init(const char *partnum) { } | 119 | static void mityomapl138_cpufreq_init(const char *partnum) { } |
118 | #endif | 120 | #endif |
119 | 121 | ||
120 | static void read_factory_config(struct nvmem_device *nvmem, void *context) | 122 | static int read_factory_config(struct notifier_block *nb, |
123 | unsigned long event, void *data) | ||
121 | { | 124 | { |
122 | int ret; | 125 | int ret; |
123 | const char *partnum = NULL; | 126 | const char *partnum = NULL; |
124 | struct davinci_soc_info *soc_info = &davinci_soc_info; | 127 | struct nvmem_device *nvmem = data; |
128 | |||
129 | if (strcmp(nvmem_dev_name(nvmem), "1-00500") != 0) | ||
130 | return NOTIFY_DONE; | ||
125 | 131 | ||
126 | if (!IS_BUILTIN(CONFIG_NVMEM)) { | 132 | if (!IS_BUILTIN(CONFIG_NVMEM)) { |
127 | pr_warn("Factory Config not available without CONFIG_NVMEM\n"); | 133 | pr_warn("Factory Config not available without CONFIG_NVMEM\n"); |
@@ -147,21 +153,20 @@ static void read_factory_config(struct nvmem_device *nvmem, void *context) | |||
147 | goto bad_config; | 153 | goto bad_config; |
148 | } | 154 | } |
149 | 155 | ||
150 | pr_info("Found MAC = %pM\n", factory_config.mac); | ||
151 | if (is_valid_ether_addr(factory_config.mac)) | ||
152 | memcpy(soc_info->emac_pdata->mac_addr, | ||
153 | factory_config.mac, ETH_ALEN); | ||
154 | else | ||
155 | pr_warn("Invalid MAC found in factory config block\n"); | ||
156 | |||
157 | partnum = factory_config.partnum; | 156 | partnum = factory_config.partnum; |
158 | pr_info("Part Number = %s\n", partnum); | 157 | pr_info("Part Number = %s\n", partnum); |
159 | 158 | ||
160 | bad_config: | 159 | bad_config: |
161 | /* default maximum speed is valid for all platforms */ | 160 | /* default maximum speed is valid for all platforms */ |
162 | mityomapl138_cpufreq_init(partnum); | 161 | mityomapl138_cpufreq_init(partnum); |
162 | |||
163 | return NOTIFY_STOP; | ||
163 | } | 164 | } |
164 | 165 | ||
166 | static struct notifier_block mityomapl138_nvmem_notifier = { | ||
167 | .notifier_call = read_factory_config, | ||
168 | }; | ||
169 | |||
165 | /* | 170 | /* |
166 | * We don't define a cell for factory config as it will be accessed from the | 171 | * We don't define a cell for factory config as it will be accessed from the |
167 | * board file using the nvmem notifier chain. | 172 | * board file using the nvmem notifier chain. |
@@ -187,12 +192,10 @@ static struct nvmem_cell_lookup mityomapl138_nvmem_cell_lookup = { | |||
187 | .con_id = "mac-address", | 192 | .con_id = "mac-address", |
188 | }; | 193 | }; |
189 | 194 | ||
190 | static struct at24_platform_data mityomapl138_fd_chip = { | 195 | static const struct property_entry mityomapl138_fd_chip_properties[] = { |
191 | .byte_len = 256, | 196 | PROPERTY_ENTRY_U32("pagesize", 8), |
192 | .page_size = 8, | 197 | PROPERTY_ENTRY_BOOL("read-only"), |
193 | .flags = AT24_FLAG_READONLY | AT24_FLAG_IRUGO, | 198 | { } |
194 | .setup = read_factory_config, | ||
195 | .context = NULL, | ||
196 | }; | 199 | }; |
197 | 200 | ||
198 | static struct davinci_i2c_platform_data mityomap_i2c_0_pdata = { | 201 | static struct davinci_i2c_platform_data mityomap_i2c_0_pdata = { |
@@ -321,7 +324,7 @@ static struct i2c_board_info __initdata mityomap_tps65023_info[] = { | |||
321 | }, | 324 | }, |
322 | { | 325 | { |
323 | I2C_BOARD_INFO("24c02", 0x50), | 326 | I2C_BOARD_INFO("24c02", 0x50), |
324 | .platform_data = &mityomapl138_fd_chip, | 327 | .properties = mityomapl138_fd_chip_properties, |
325 | }, | 328 | }, |
326 | }; | 329 | }; |
327 | 330 | ||
@@ -569,6 +572,7 @@ static void __init mityomapl138_init(void) | |||
569 | 572 | ||
570 | davinci_serial_init(da8xx_serial_device); | 573 | davinci_serial_init(da8xx_serial_device); |
571 | 574 | ||
575 | nvmem_register_notifier(&mityomapl138_nvmem_notifier); | ||
572 | nvmem_add_cell_table(&mityomapl138_nvmem_cell_table); | 576 | nvmem_add_cell_table(&mityomapl138_nvmem_cell_table); |
573 | nvmem_add_cell_lookups(&mityomapl138_nvmem_cell_lookup, 1); | 577 | nvmem_add_cell_lookups(&mityomapl138_nvmem_cell_lookup, 1); |
574 | 578 | ||
diff --git a/arch/arm/mach-davinci/board-sffsdr.c b/arch/arm/mach-davinci/board-sffsdr.c index 792bb84d5011..ff14de1396c8 100644 --- a/arch/arm/mach-davinci/board-sffsdr.c +++ b/arch/arm/mach-davinci/board-sffsdr.c | |||
@@ -26,7 +26,7 @@ | |||
26 | #include <linux/init.h> | 26 | #include <linux/init.h> |
27 | #include <linux/platform_device.h> | 27 | #include <linux/platform_device.h> |
28 | #include <linux/i2c.h> | 28 | #include <linux/i2c.h> |
29 | #include <linux/platform_data/at24.h> | 29 | #include <linux/property.h> |
30 | #include <linux/mtd/mtd.h> | 30 | #include <linux/mtd/mtd.h> |
31 | #include <linux/mtd/rawnand.h> | 31 | #include <linux/mtd/rawnand.h> |
32 | #include <linux/mtd/partitions.h> | 32 | #include <linux/mtd/partitions.h> |
@@ -92,16 +92,15 @@ static struct platform_device davinci_sffsdr_nandflash_device = { | |||
92 | .resource = davinci_sffsdr_nandflash_resource, | 92 | .resource = davinci_sffsdr_nandflash_resource, |
93 | }; | 93 | }; |
94 | 94 | ||
95 | static struct at24_platform_data eeprom_info = { | 95 | static const struct property_entry eeprom_properties[] = { |
96 | .byte_len = (64*1024) / 8, | 96 | PROPERTY_ENTRY_U32("pagesize", 32), |
97 | .page_size = 32, | 97 | { } |
98 | .flags = AT24_FLAG_ADDR16, | ||
99 | }; | 98 | }; |
100 | 99 | ||
101 | static struct i2c_board_info __initdata i2c_info[] = { | 100 | static struct i2c_board_info __initdata i2c_info[] = { |
102 | { | 101 | { |
103 | I2C_BOARD_INFO("24lc64", 0x50), | 102 | I2C_BOARD_INFO("24c64", 0x50), |
104 | .platform_data = &eeprom_info, | 103 | .properties = eeprom_properties, |
105 | }, | 104 | }, |
106 | /* Other I2C devices: | 105 | /* Other I2C devices: |
107 | * MSP430, addr 0x23 (not used) | 106 | * MSP430, addr 0x23 (not used) |
diff --git a/arch/arm/mach-davinci/common.c b/arch/arm/mach-davinci/common.c index e1d0f0d841ff..0c638fe15dcb 100644 --- a/arch/arm/mach-davinci/common.c +++ b/arch/arm/mach-davinci/common.c | |||
@@ -26,21 +26,6 @@ EXPORT_SYMBOL(davinci_soc_info); | |||
26 | void __iomem *davinci_intc_base; | 26 | void __iomem *davinci_intc_base; |
27 | int davinci_intc_type; | 27 | int davinci_intc_type; |
28 | 28 | ||
29 | void davinci_get_mac_addr(struct nvmem_device *nvmem, void *context) | ||
30 | { | ||
31 | char *mac_addr = davinci_soc_info.emac_pdata->mac_addr; | ||
32 | off_t offset = (off_t)context; | ||
33 | |||
34 | if (!IS_BUILTIN(CONFIG_NVMEM)) { | ||
35 | pr_warn("Cannot read MAC addr from EEPROM without CONFIG_NVMEM\n"); | ||
36 | return; | ||
37 | } | ||
38 | |||
39 | /* Read MAC addr from EEPROM */ | ||
40 | if (nvmem_device_read(nvmem, offset, ETH_ALEN, mac_addr) == ETH_ALEN) | ||
41 | pr_info("Read MAC addr from EEPROM: %pM\n", mac_addr); | ||
42 | } | ||
43 | |||
44 | static int __init davinci_init_id(struct davinci_soc_info *soc_info) | 29 | static int __init davinci_init_id(struct davinci_soc_info *soc_info) |
45 | { | 30 | { |
46 | int i; | 31 | int i; |
diff --git a/drivers/misc/eeprom/at24.c b/drivers/misc/eeprom/at24.c index ddfcf4ade7bf..63aa541c9608 100644 --- a/drivers/misc/eeprom/at24.c +++ b/drivers/misc/eeprom/at24.c | |||
@@ -22,10 +22,24 @@ | |||
22 | #include <linux/i2c.h> | 22 | #include <linux/i2c.h> |
23 | #include <linux/nvmem-provider.h> | 23 | #include <linux/nvmem-provider.h> |
24 | #include <linux/regmap.h> | 24 | #include <linux/regmap.h> |
25 | #include <linux/platform_data/at24.h> | ||
26 | #include <linux/pm_runtime.h> | 25 | #include <linux/pm_runtime.h> |
27 | #include <linux/gpio/consumer.h> | 26 | #include <linux/gpio/consumer.h> |
28 | 27 | ||
28 | /* Address pointer is 16 bit. */ | ||
29 | #define AT24_FLAG_ADDR16 BIT(7) | ||
30 | /* sysfs-entry will be read-only. */ | ||
31 | #define AT24_FLAG_READONLY BIT(6) | ||
32 | /* sysfs-entry will be world-readable. */ | ||
33 | #define AT24_FLAG_IRUGO BIT(5) | ||
34 | /* Take always 8 addresses (24c00). */ | ||
35 | #define AT24_FLAG_TAKE8ADDR BIT(4) | ||
36 | /* Factory-programmed serial number. */ | ||
37 | #define AT24_FLAG_SERIAL BIT(3) | ||
38 | /* Factory-programmed mac address. */ | ||
39 | #define AT24_FLAG_MAC BIT(2) | ||
40 | /* Does not auto-rollover reads to the next slave address. */ | ||
41 | #define AT24_FLAG_NO_RDROL BIT(1) | ||
42 | |||
29 | /* | 43 | /* |
30 | * I2C EEPROMs from most vendors are inexpensive and mostly interchangeable. | 44 | * I2C EEPROMs from most vendors are inexpensive and mostly interchangeable. |
31 | * Differences between different vendor product lines (like Atmel AT24C or | 45 | * Differences between different vendor product lines (like Atmel AT24C or |
@@ -107,10 +121,6 @@ module_param_named(write_timeout, at24_write_timeout, uint, 0); | |||
107 | MODULE_PARM_DESC(at24_write_timeout, "Time (in ms) to try writes (default 25)"); | 121 | MODULE_PARM_DESC(at24_write_timeout, "Time (in ms) to try writes (default 25)"); |
108 | 122 | ||
109 | struct at24_chip_data { | 123 | struct at24_chip_data { |
110 | /* | ||
111 | * these fields mirror their equivalents in | ||
112 | * struct at24_platform_data | ||
113 | */ | ||
114 | u32 byte_len; | 124 | u32 byte_len; |
115 | u8 flags; | 125 | u8 flags; |
116 | }; | 126 | }; |
@@ -471,63 +481,11 @@ static int at24_write(void *priv, unsigned int off, void *val, size_t count) | |||
471 | return 0; | 481 | return 0; |
472 | } | 482 | } |
473 | 483 | ||
474 | static void at24_properties_to_pdata(struct device *dev, | 484 | static const struct at24_chip_data *at24_get_chip_data(struct device *dev) |
475 | struct at24_platform_data *chip) | ||
476 | { | ||
477 | int err; | ||
478 | u32 val; | ||
479 | |||
480 | if (device_property_present(dev, "read-only")) | ||
481 | chip->flags |= AT24_FLAG_READONLY; | ||
482 | if (device_property_present(dev, "no-read-rollover")) | ||
483 | chip->flags |= AT24_FLAG_NO_RDROL; | ||
484 | |||
485 | err = device_property_read_u32(dev, "address-width", &val); | ||
486 | if (!err) { | ||
487 | switch (val) { | ||
488 | case 8: | ||
489 | if (chip->flags & AT24_FLAG_ADDR16) | ||
490 | dev_warn(dev, "Override address width to be 8, while default is 16\n"); | ||
491 | chip->flags &= ~AT24_FLAG_ADDR16; | ||
492 | break; | ||
493 | case 16: | ||
494 | chip->flags |= AT24_FLAG_ADDR16; | ||
495 | break; | ||
496 | default: | ||
497 | dev_warn(dev, "Bad \"address-width\" property: %u\n", | ||
498 | val); | ||
499 | } | ||
500 | } | ||
501 | |||
502 | err = device_property_read_u32(dev, "size", &val); | ||
503 | if (!err) | ||
504 | chip->byte_len = val; | ||
505 | |||
506 | err = device_property_read_u32(dev, "pagesize", &val); | ||
507 | if (!err) { | ||
508 | chip->page_size = val; | ||
509 | } else { | ||
510 | /* | ||
511 | * This is slow, but we can't know all eeproms, so we better | ||
512 | * play safe. Specifying custom eeprom-types via platform_data | ||
513 | * is recommended anyhow. | ||
514 | */ | ||
515 | chip->page_size = 1; | ||
516 | } | ||
517 | } | ||
518 | |||
519 | static int at24_get_pdata(struct device *dev, struct at24_platform_data *pdata) | ||
520 | { | 485 | { |
521 | struct device_node *of_node = dev->of_node; | 486 | struct device_node *of_node = dev->of_node; |
522 | const struct at24_chip_data *cdata; | 487 | const struct at24_chip_data *cdata; |
523 | const struct i2c_device_id *id; | 488 | const struct i2c_device_id *id; |
524 | struct at24_platform_data *pd; | ||
525 | |||
526 | pd = dev_get_platdata(dev); | ||
527 | if (pd) { | ||
528 | memcpy(pdata, pd, sizeof(*pdata)); | ||
529 | return 0; | ||
530 | } | ||
531 | 489 | ||
532 | id = i2c_match_id(at24_ids, to_i2c_client(dev)); | 490 | id = i2c_match_id(at24_ids, to_i2c_client(dev)); |
533 | 491 | ||
@@ -544,13 +502,9 @@ static int at24_get_pdata(struct device *dev, struct at24_platform_data *pdata) | |||
544 | cdata = acpi_device_get_match_data(dev); | 502 | cdata = acpi_device_get_match_data(dev); |
545 | 503 | ||
546 | if (!cdata) | 504 | if (!cdata) |
547 | return -ENODEV; | 505 | return ERR_PTR(-ENODEV); |
548 | 506 | ||
549 | pdata->byte_len = cdata->byte_len; | 507 | return cdata; |
550 | pdata->flags = cdata->flags; | ||
551 | at24_properties_to_pdata(dev, pdata); | ||
552 | |||
553 | return 0; | ||
554 | } | 508 | } |
555 | 509 | ||
556 | static void at24_remove_dummy_clients(struct at24_data *at24) | 510 | static void at24_remove_dummy_clients(struct at24_data *at24) |
@@ -619,7 +573,8 @@ static int at24_probe(struct i2c_client *client) | |||
619 | { | 573 | { |
620 | struct regmap_config regmap_config = { }; | 574 | struct regmap_config regmap_config = { }; |
621 | struct nvmem_config nvmem_config = { }; | 575 | struct nvmem_config nvmem_config = { }; |
622 | struct at24_platform_data pdata = { }; | 576 | u32 byte_len, page_size, flags, addrw; |
577 | const struct at24_chip_data *cdata; | ||
623 | struct device *dev = &client->dev; | 578 | struct device *dev = &client->dev; |
624 | bool i2c_fn_i2c, i2c_fn_block; | 579 | bool i2c_fn_i2c, i2c_fn_block; |
625 | unsigned int i, num_addresses; | 580 | unsigned int i, num_addresses; |
@@ -634,35 +589,75 @@ static int at24_probe(struct i2c_client *client) | |||
634 | i2c_fn_block = i2c_check_functionality(client->adapter, | 589 | i2c_fn_block = i2c_check_functionality(client->adapter, |
635 | I2C_FUNC_SMBUS_WRITE_I2C_BLOCK); | 590 | I2C_FUNC_SMBUS_WRITE_I2C_BLOCK); |
636 | 591 | ||
637 | err = at24_get_pdata(dev, &pdata); | 592 | cdata = at24_get_chip_data(dev); |
593 | if (IS_ERR(cdata)) | ||
594 | return PTR_ERR(cdata); | ||
595 | |||
596 | err = device_property_read_u32(dev, "pagesize", &page_size); | ||
597 | if (err) | ||
598 | /* | ||
599 | * This is slow, but we can't know all eeproms, so we better | ||
600 | * play safe. Specifying custom eeprom-types via platform_data | ||
601 | * is recommended anyhow. | ||
602 | */ | ||
603 | page_size = 1; | ||
604 | |||
605 | flags = cdata->flags; | ||
606 | if (device_property_present(dev, "read-only")) | ||
607 | flags |= AT24_FLAG_READONLY; | ||
608 | if (device_property_present(dev, "no-read-rollover")) | ||
609 | flags |= AT24_FLAG_NO_RDROL; | ||
610 | |||
611 | err = device_property_read_u32(dev, "address-width", &addrw); | ||
612 | if (!err) { | ||
613 | switch (addrw) { | ||
614 | case 8: | ||
615 | if (flags & AT24_FLAG_ADDR16) | ||
616 | dev_warn(dev, | ||
617 | "Override address width to be 8, while default is 16\n"); | ||
618 | flags &= ~AT24_FLAG_ADDR16; | ||
619 | break; | ||
620 | case 16: | ||
621 | flags |= AT24_FLAG_ADDR16; | ||
622 | break; | ||
623 | default: | ||
624 | dev_warn(dev, "Bad \"address-width\" property: %u\n", | ||
625 | addrw); | ||
626 | } | ||
627 | } | ||
628 | |||
629 | err = device_property_read_u32(dev, "size", &byte_len); | ||
638 | if (err) | 630 | if (err) |
639 | return err; | 631 | byte_len = cdata->byte_len; |
640 | 632 | ||
641 | if (!i2c_fn_i2c && !i2c_fn_block) | 633 | if (!i2c_fn_i2c && !i2c_fn_block) |
642 | pdata.page_size = 1; | 634 | page_size = 1; |
643 | 635 | ||
644 | if (!pdata.page_size) { | 636 | if (!page_size) { |
645 | dev_err(dev, "page_size must not be 0!\n"); | 637 | dev_err(dev, "page_size must not be 0!\n"); |
646 | return -EINVAL; | 638 | return -EINVAL; |
647 | } | 639 | } |
648 | 640 | ||
649 | if (!is_power_of_2(pdata.page_size)) | 641 | if (!is_power_of_2(page_size)) |
650 | dev_warn(dev, "page_size looks suspicious (no power of 2)!\n"); | 642 | dev_warn(dev, "page_size looks suspicious (no power of 2)!\n"); |
651 | 643 | ||
652 | if (pdata.flags & AT24_FLAG_TAKE8ADDR) | 644 | err = device_property_read_u32(dev, "num-addresses", &num_addresses); |
653 | num_addresses = 8; | 645 | if (err) { |
654 | else | 646 | if (flags & AT24_FLAG_TAKE8ADDR) |
655 | num_addresses = DIV_ROUND_UP(pdata.byte_len, | 647 | num_addresses = 8; |
656 | (pdata.flags & AT24_FLAG_ADDR16) ? 65536 : 256); | 648 | else |
649 | num_addresses = DIV_ROUND_UP(byte_len, | ||
650 | (flags & AT24_FLAG_ADDR16) ? 65536 : 256); | ||
651 | } | ||
657 | 652 | ||
658 | if ((pdata.flags & AT24_FLAG_SERIAL) && (pdata.flags & AT24_FLAG_MAC)) { | 653 | if ((flags & AT24_FLAG_SERIAL) && (flags & AT24_FLAG_MAC)) { |
659 | dev_err(dev, | 654 | dev_err(dev, |
660 | "invalid device data - cannot have both AT24_FLAG_SERIAL & AT24_FLAG_MAC."); | 655 | "invalid device data - cannot have both AT24_FLAG_SERIAL & AT24_FLAG_MAC."); |
661 | return -EINVAL; | 656 | return -EINVAL; |
662 | } | 657 | } |
663 | 658 | ||
664 | regmap_config.val_bits = 8; | 659 | regmap_config.val_bits = 8; |
665 | regmap_config.reg_bits = (pdata.flags & AT24_FLAG_ADDR16) ? 16 : 8; | 660 | regmap_config.reg_bits = (flags & AT24_FLAG_ADDR16) ? 16 : 8; |
666 | regmap_config.disable_locking = true; | 661 | regmap_config.disable_locking = true; |
667 | 662 | ||
668 | regmap = devm_regmap_init_i2c(client, ®map_config); | 663 | regmap = devm_regmap_init_i2c(client, ®map_config); |
@@ -675,11 +670,11 @@ static int at24_probe(struct i2c_client *client) | |||
675 | return -ENOMEM; | 670 | return -ENOMEM; |
676 | 671 | ||
677 | mutex_init(&at24->lock); | 672 | mutex_init(&at24->lock); |
678 | at24->byte_len = pdata.byte_len; | 673 | at24->byte_len = byte_len; |
679 | at24->page_size = pdata.page_size; | 674 | at24->page_size = page_size; |
680 | at24->flags = pdata.flags; | 675 | at24->flags = flags; |
681 | at24->num_addresses = num_addresses; | 676 | at24->num_addresses = num_addresses; |
682 | at24->offset_adj = at24_get_offset_adj(pdata.flags, pdata.byte_len); | 677 | at24->offset_adj = at24_get_offset_adj(flags, byte_len); |
683 | at24->client[0].client = client; | 678 | at24->client[0].client = client; |
684 | at24->client[0].regmap = regmap; | 679 | at24->client[0].regmap = regmap; |
685 | 680 | ||
@@ -687,10 +682,10 @@ static int at24_probe(struct i2c_client *client) | |||
687 | if (IS_ERR(at24->wp_gpio)) | 682 | if (IS_ERR(at24->wp_gpio)) |
688 | return PTR_ERR(at24->wp_gpio); | 683 | return PTR_ERR(at24->wp_gpio); |
689 | 684 | ||
690 | writable = !(pdata.flags & AT24_FLAG_READONLY); | 685 | writable = !(flags & AT24_FLAG_READONLY); |
691 | if (writable) { | 686 | if (writable) { |
692 | at24->write_max = min_t(unsigned int, | 687 | at24->write_max = min_t(unsigned int, |
693 | pdata.page_size, at24_io_limit); | 688 | page_size, at24_io_limit); |
694 | if (!i2c_fn_i2c && at24->write_max > I2C_SMBUS_BLOCK_MAX) | 689 | if (!i2c_fn_i2c && at24->write_max > I2C_SMBUS_BLOCK_MAX) |
695 | at24->write_max = I2C_SMBUS_BLOCK_MAX; | 690 | at24->write_max = I2C_SMBUS_BLOCK_MAX; |
696 | } | 691 | } |
@@ -733,7 +728,7 @@ static int at24_probe(struct i2c_client *client) | |||
733 | nvmem_config.priv = at24; | 728 | nvmem_config.priv = at24; |
734 | nvmem_config.stride = 1; | 729 | nvmem_config.stride = 1; |
735 | nvmem_config.word_size = 1; | 730 | nvmem_config.word_size = 1; |
736 | nvmem_config.size = pdata.byte_len; | 731 | nvmem_config.size = byte_len; |
737 | 732 | ||
738 | at24->nvmem = devm_nvmem_register(dev, &nvmem_config); | 733 | at24->nvmem = devm_nvmem_register(dev, &nvmem_config); |
739 | if (IS_ERR(at24->nvmem)) { | 734 | if (IS_ERR(at24->nvmem)) { |
@@ -742,13 +737,9 @@ static int at24_probe(struct i2c_client *client) | |||
742 | } | 737 | } |
743 | 738 | ||
744 | dev_info(dev, "%u byte %s EEPROM, %s, %u bytes/write\n", | 739 | dev_info(dev, "%u byte %s EEPROM, %s, %u bytes/write\n", |
745 | pdata.byte_len, client->name, | 740 | byte_len, client->name, |
746 | writable ? "writable" : "read-only", at24->write_max); | 741 | writable ? "writable" : "read-only", at24->write_max); |
747 | 742 | ||
748 | /* export data to kernel code */ | ||
749 | if (pdata.setup) | ||
750 | pdata.setup(at24->nvmem, pdata.context); | ||
751 | |||
752 | return 0; | 743 | return 0; |
753 | 744 | ||
754 | err_clients: | 745 | err_clients: |
diff --git a/include/linux/davinci_emac.h b/include/linux/davinci_emac.h index 05b97144d342..28e6cf1356da 100644 --- a/include/linux/davinci_emac.h +++ b/include/linux/davinci_emac.h | |||
@@ -46,5 +46,4 @@ enum { | |||
46 | EMAC_VERSION_2, /* DM646x */ | 46 | EMAC_VERSION_2, /* DM646x */ |
47 | }; | 47 | }; |
48 | 48 | ||
49 | void davinci_get_mac_addr(struct nvmem_device *nvmem, void *context); | ||
50 | #endif | 49 | #endif |
diff --git a/include/linux/platform_data/at24.h b/include/linux/platform_data/at24.h deleted file mode 100644 index 63507ff464ee..000000000000 --- a/include/linux/platform_data/at24.h +++ /dev/null | |||
@@ -1,60 +0,0 @@ | |||
1 | /* | ||
2 | * at24.h - platform_data for the at24 (generic eeprom) driver | ||
3 | * (C) Copyright 2008 by Pengutronix | ||
4 | * (C) Copyright 2012 by Wolfram Sang | ||
5 | * same license as the driver | ||
6 | */ | ||
7 | |||
8 | #ifndef _LINUX_AT24_H | ||
9 | #define _LINUX_AT24_H | ||
10 | |||
11 | #include <linux/types.h> | ||
12 | #include <linux/nvmem-consumer.h> | ||
13 | #include <linux/bitops.h> | ||
14 | |||
15 | /** | ||
16 | * struct at24_platform_data - data to set up at24 (generic eeprom) driver | ||
17 | * @byte_len: size of eeprom in byte | ||
18 | * @page_size: number of byte which can be written in one go | ||
19 | * @flags: tunable options, check AT24_FLAG_* defines | ||
20 | * @setup: an optional callback invoked after eeprom is probed; enables kernel | ||
21 | code to access eeprom via nvmem, see example | ||
22 | * @context: optional parameter passed to setup() | ||
23 | * | ||
24 | * If you set up a custom eeprom type, please double-check the parameters. | ||
25 | * Especially page_size needs extra care, as you risk data loss if your value | ||
26 | * is bigger than what the chip actually supports! | ||
27 | * | ||
28 | * An example in pseudo code for a setup() callback: | ||
29 | * | ||
30 | * void get_mac_addr(struct nvmem_device *nvmem, void *context) | ||
31 | * { | ||
32 | * u8 *mac_addr = ethernet_pdata->mac_addr; | ||
33 | * off_t offset = context; | ||
34 | * | ||
35 | * // Read MAC addr from EEPROM | ||
36 | * if (nvmem_device_read(nvmem, offset, ETH_ALEN, mac_addr) == ETH_ALEN) | ||
37 | * pr_info("Read MAC addr from EEPROM: %pM\n", mac_addr); | ||
38 | * } | ||
39 | * | ||
40 | * This function pointer and context can now be set up in at24_platform_data. | ||
41 | */ | ||
42 | |||
43 | struct at24_platform_data { | ||
44 | u32 byte_len; /* size (sum of all addr) */ | ||
45 | u16 page_size; /* for writes */ | ||
46 | u8 flags; | ||
47 | #define AT24_FLAG_ADDR16 BIT(7) /* address pointer is 16 bit */ | ||
48 | #define AT24_FLAG_READONLY BIT(6) /* sysfs-entry will be read-only */ | ||
49 | #define AT24_FLAG_IRUGO BIT(5) /* sysfs-entry will be world-readable */ | ||
50 | #define AT24_FLAG_TAKE8ADDR BIT(4) /* take always 8 addresses (24c00) */ | ||
51 | #define AT24_FLAG_SERIAL BIT(3) /* factory-programmed serial number */ | ||
52 | #define AT24_FLAG_MAC BIT(2) /* factory-programmed mac address */ | ||
53 | #define AT24_FLAG_NO_RDROL BIT(1) /* does not auto-rollover reads to */ | ||
54 | /* the next slave address */ | ||
55 | |||
56 | void (*setup)(struct nvmem_device *nvmem, void *context); | ||
57 | void *context; | ||
58 | }; | ||
59 | |||
60 | #endif /* _LINUX_AT24_H */ | ||