Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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

+130 -250
+3
Documentation/devicetree/bindings/eeprom/at24.txt
··· 75 75 76 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 80 Example: 79 81 80 82 eeprom@52 { ··· 84 82 reg = <0x52>; 85 83 pagesize = <32>; 86 84 wp-gpios = <&gpio1 3 0>; 85 + num-addresses = <8>; 87 86 };
-1
MAINTAINERS
··· 2503 2503 S: Maintained 2504 2504 F: Documentation/devicetree/bindings/eeprom/at24.txt 2505 2505 F: drivers/misc/eeprom/at24.c 2506 - F: include/linux/platform_data/at24.h 2507 2506 2508 2507 ATA OVER ETHERNET (AOE) DRIVER 2509 2508 M: "Ed L. Cashin" <ed.cashin@acm.org>
+5 -8
arch/arm/mach-davinci/board-da830-evm.c
··· 18 18 #include <linux/platform_device.h> 19 19 #include <linux/i2c.h> 20 20 #include <linux/platform_data/pcf857x.h> 21 - #include <linux/platform_data/at24.h> 21 + #include <linux/property.h> 22 22 #include <linux/mtd/mtd.h> 23 23 #include <linux/mtd/partitions.h> 24 24 #include <linux/spi/spi.h> ··· 457 457 .con_id = "mac-address", 458 458 }; 459 459 460 - static struct at24_platform_data da830_evm_i2c_eeprom_info = { 461 - .byte_len = SZ_256K / 8, 462 - .page_size = 64, 463 - .flags = AT24_FLAG_ADDR16, 464 - .setup = davinci_get_mac_addr, 465 - .context = (void *)0x7f00, 460 + static const struct property_entry da830_evm_i2c_eeprom_properties[] = { 461 + PROPERTY_ENTRY_U32("pagesize", 64), 462 + { } 466 463 }; 467 464 468 465 static int __init da830_evm_ui_expander_setup(struct i2c_client *client, ··· 493 496 static struct i2c_board_info __initdata da830_evm_i2c_devices[] = { 494 497 { 495 498 I2C_BOARD_INFO("24c256", 0x50), 496 - .platform_data = &da830_evm_i2c_eeprom_info, 499 + .properties = da830_evm_i2c_eeprom_properties, 497 500 }, 498 501 { 499 502 I2C_BOARD_INFO("tlv320aic3x", 0x18),
-28
arch/arm/mach-davinci/board-da850-evm.c
··· 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 153 static struct mtd_partition da850_evm_norflash_partition[] = { 180 154 { 181 155 .name = "bootloaders + env", ··· 1467 1493 ret = da850_register_sata(DA850EVM_SATA_REFCLKPN_RATE); 1468 1494 if (ret) 1469 1495 pr_warn("%s: SATA registration failed: %d\n", __func__, ret); 1470 - 1471 - da850_evm_setup_mac_addr(); 1472 1496 1473 1497 ret = da8xx_register_rproc(); 1474 1498 if (ret)
+5 -8
arch/arm/mach-davinci/board-dm365-evm.c
··· 18 18 #include <linux/i2c.h> 19 19 #include <linux/io.h> 20 20 #include <linux/clk.h> 21 - #include <linux/platform_data/at24.h> 21 + #include <linux/property.h> 22 22 #include <linux/leds.h> 23 23 #include <linux/mtd/mtd.h> 24 24 #include <linux/mtd/partitions.h> ··· 225 225 .con_id = "mac-address", 226 226 }; 227 227 228 - static struct at24_platform_data eeprom_info = { 229 - .byte_len = (256*1024) / 8, 230 - .page_size = 64, 231 - .flags = AT24_FLAG_ADDR16, 232 - .setup = davinci_get_mac_addr, 233 - .context = (void *)0x7f00, 228 + static const struct property_entry eeprom_properties[] = { 229 + PROPERTY_ENTRY_U32("pagesize", 64), 230 + { } 234 231 }; 235 232 236 233 static struct i2c_board_info i2c_info[] = { 237 234 { 238 235 I2C_BOARD_INFO("24c256", 0x50), 239 - .platform_data = &eeprom_info, 236 + .properties = eeprom_properties, 240 237 }, 241 238 { 242 239 I2C_BOARD_INFO("tlv320aic3x", 0x18),
+5 -8
arch/arm/mach-davinci/board-dm644x-evm.c
··· 16 16 #include <linux/gpio/machine.h> 17 17 #include <linux/i2c.h> 18 18 #include <linux/platform_data/pcf857x.h> 19 - #include <linux/platform_data/at24.h> 20 19 #include <linux/platform_data/gpio-davinci.h> 20 + #include <linux/property.h> 21 21 #include <linux/mtd/mtd.h> 22 22 #include <linux/mtd/rawnand.h> 23 23 #include <linux/mtd/partitions.h> ··· 532 532 .con_id = "mac-address", 533 533 }; 534 534 535 - static struct at24_platform_data eeprom_info = { 536 - .byte_len = (256*1024) / 8, 537 - .page_size = 64, 538 - .flags = AT24_FLAG_ADDR16, 539 - .setup = davinci_get_mac_addr, 540 - .context = (void *)0x7f00, 535 + static const struct property_entry eeprom_properties[] = { 536 + PROPERTY_ENTRY_U32("pagesize", 64), 537 + { } 541 538 }; 542 539 543 540 /* ··· 644 647 }, 645 648 { 646 649 I2C_BOARD_INFO("24c256", 0x50), 647 - .platform_data = &eeprom_info, 650 + .properties = eeprom_properties, 648 651 }, 649 652 { 650 653 I2C_BOARD_INFO("tlv320aic33", 0x1b),
+5 -8
arch/arm/mach-davinci/board-dm646x-evm.c
··· 22 22 #include <linux/gpio.h> 23 23 #include <linux/platform_device.h> 24 24 #include <linux/i2c.h> 25 - #include <linux/platform_data/at24.h> 25 + #include <linux/property.h> 26 26 #include <linux/platform_data/pcf857x.h> 27 27 #include <linux/platform_data/ti-aemif.h> 28 28 ··· 364 364 .con_id = "mac-address", 365 365 }; 366 366 367 - static struct at24_platform_data eeprom_info = { 368 - .byte_len = (256*1024) / 8, 369 - .page_size = 64, 370 - .flags = AT24_FLAG_ADDR16, 371 - .setup = davinci_get_mac_addr, 372 - .context = (void *)0x7f00, 367 + static const struct property_entry eeprom_properties[] = { 368 + PROPERTY_ENTRY_U32("pagesize", 64), 369 + { } 373 370 }; 374 371 #endif 375 372 ··· 437 440 static struct i2c_board_info __initdata i2c_info[] = { 438 441 { 439 442 I2C_BOARD_INFO("24c256", 0x50), 440 - .platform_data = &eeprom_info, 443 + .properties = eeprom_properties, 441 444 }, 442 445 { 443 446 I2C_BOARD_INFO("pcf8574a", 0x38),
+21 -17
arch/arm/mach-davinci/board-mityomapl138.c
··· 14 14 #include <linux/init.h> 15 15 #include <linux/console.h> 16 16 #include <linux/platform_device.h> 17 + #include <linux/property.h> 17 18 #include <linux/mtd/partitions.h> 19 + #include <linux/notifier.h> 20 + #include <linux/nvmem-consumer.h> 18 21 #include <linux/nvmem-provider.h> 19 22 #include <linux/regulator/machine.h> 20 23 #include <linux/i2c.h> 21 - #include <linux/platform_data/at24.h> 22 24 #include <linux/etherdevice.h> 23 25 #include <linux/spi/spi.h> 24 26 #include <linux/spi/flash.h> ··· 119 117 static void mityomapl138_cpufreq_init(const char *partnum) { } 120 118 #endif 121 119 122 - static void read_factory_config(struct nvmem_device *nvmem, void *context) 120 + static int read_factory_config(struct notifier_block *nb, 121 + unsigned long event, void *data) 123 122 { 124 123 int ret; 125 124 const char *partnum = NULL; 126 - struct davinci_soc_info *soc_info = &davinci_soc_info; 125 + struct nvmem_device *nvmem = data; 126 + 127 + if (strcmp(nvmem_dev_name(nvmem), "1-00500") != 0) 128 + return NOTIFY_DONE; 127 129 128 130 if (!IS_BUILTIN(CONFIG_NVMEM)) { 129 131 pr_warn("Factory Config not available without CONFIG_NVMEM\n"); ··· 153 147 goto bad_config; 154 148 } 155 149 156 - pr_info("Found MAC = %pM\n", factory_config.mac); 157 - if (is_valid_ether_addr(factory_config.mac)) 158 - memcpy(soc_info->emac_pdata->mac_addr, 159 - factory_config.mac, ETH_ALEN); 160 - else 161 - pr_warn("Invalid MAC found in factory config block\n"); 162 - 163 150 partnum = factory_config.partnum; 164 151 pr_info("Part Number = %s\n", partnum); 165 152 166 153 bad_config: 167 154 /* default maximum speed is valid for all platforms */ 168 155 mityomapl138_cpufreq_init(partnum); 156 + 157 + return NOTIFY_STOP; 169 158 } 159 + 160 + static struct notifier_block mityomapl138_nvmem_notifier = { 161 + .notifier_call = read_factory_config, 162 + }; 170 163 171 164 /* 172 165 * We don't define a cell for factory config as it will be accessed from the ··· 192 187 .con_id = "mac-address", 193 188 }; 194 189 195 - static struct at24_platform_data mityomapl138_fd_chip = { 196 - .byte_len = 256, 197 - .page_size = 8, 198 - .flags = AT24_FLAG_READONLY | AT24_FLAG_IRUGO, 199 - .setup = read_factory_config, 200 - .context = NULL, 190 + static const struct property_entry mityomapl138_fd_chip_properties[] = { 191 + PROPERTY_ENTRY_U32("pagesize", 8), 192 + PROPERTY_ENTRY_BOOL("read-only"), 193 + { } 201 194 }; 202 195 203 196 static struct davinci_i2c_platform_data mityomap_i2c_0_pdata = { ··· 324 321 }, 325 322 { 326 323 I2C_BOARD_INFO("24c02", 0x50), 327 - .platform_data = &mityomapl138_fd_chip, 324 + .properties = mityomapl138_fd_chip_properties, 328 325 }, 329 326 }; 330 327 ··· 572 569 573 570 davinci_serial_init(da8xx_serial_device); 574 571 572 + nvmem_register_notifier(&mityomapl138_nvmem_notifier); 575 573 nvmem_add_cell_table(&mityomapl138_nvmem_cell_table); 576 574 nvmem_add_cell_lookups(&mityomapl138_nvmem_cell_lookup, 1); 577 575
+6 -7
arch/arm/mach-davinci/board-sffsdr.c
··· 26 26 #include <linux/init.h> 27 27 #include <linux/platform_device.h> 28 28 #include <linux/i2c.h> 29 - #include <linux/platform_data/at24.h> 29 + #include <linux/property.h> 30 30 #include <linux/mtd/mtd.h> 31 31 #include <linux/mtd/rawnand.h> 32 32 #include <linux/mtd/partitions.h> ··· 92 92 .resource = davinci_sffsdr_nandflash_resource, 93 93 }; 94 94 95 - static struct at24_platform_data eeprom_info = { 96 - .byte_len = (64*1024) / 8, 97 - .page_size = 32, 98 - .flags = AT24_FLAG_ADDR16, 95 + static const struct property_entry eeprom_properties[] = { 96 + PROPERTY_ENTRY_U32("pagesize", 32), 97 + { } 99 98 }; 100 99 101 100 static struct i2c_board_info __initdata i2c_info[] = { 102 101 { 103 - I2C_BOARD_INFO("24lc64", 0x50), 104 - .platform_data = &eeprom_info, 102 + I2C_BOARD_INFO("24c64", 0x50), 103 + .properties = eeprom_properties, 105 104 }, 106 105 /* Other I2C devices: 107 106 * MSP430, addr 0x23 (not used)
-15
arch/arm/mach-davinci/common.c
··· 26 26 void __iomem *davinci_intc_base; 27 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 29 static int __init davinci_init_id(struct davinci_soc_info *soc_info) 45 30 { 46 31 int i;
+80 -89
drivers/misc/eeprom/at24.c
··· 22 22 #include <linux/i2c.h> 23 23 #include <linux/nvmem-provider.h> 24 24 #include <linux/regmap.h> 25 - #include <linux/platform_data/at24.h> 26 25 #include <linux/pm_runtime.h> 27 26 #include <linux/gpio/consumer.h> 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) 28 42 29 43 /* 30 44 * I2C EEPROMs from most vendors are inexpensive and mostly interchangeable. ··· 121 107 MODULE_PARM_DESC(at24_write_timeout, "Time (in ms) to try writes (default 25)"); 122 108 123 109 struct at24_chip_data { 124 - /* 125 - * these fields mirror their equivalents in 126 - * struct at24_platform_data 127 - */ 128 110 u32 byte_len; 129 111 u8 flags; 130 112 }; ··· 481 471 return 0; 482 472 } 483 473 484 - static void at24_properties_to_pdata(struct device *dev, 485 - struct at24_platform_data *chip) 486 - { 487 - int err; 488 - u32 val; 489 - 490 - if (device_property_present(dev, "read-only")) 491 - chip->flags |= AT24_FLAG_READONLY; 492 - if (device_property_present(dev, "no-read-rollover")) 493 - chip->flags |= AT24_FLAG_NO_RDROL; 494 - 495 - err = device_property_read_u32(dev, "address-width", &val); 496 - if (!err) { 497 - switch (val) { 498 - case 8: 499 - if (chip->flags & AT24_FLAG_ADDR16) 500 - dev_warn(dev, "Override address width to be 8, while default is 16\n"); 501 - chip->flags &= ~AT24_FLAG_ADDR16; 502 - break; 503 - case 16: 504 - chip->flags |= AT24_FLAG_ADDR16; 505 - break; 506 - default: 507 - dev_warn(dev, "Bad \"address-width\" property: %u\n", 508 - val); 509 - } 510 - } 511 - 512 - err = device_property_read_u32(dev, "size", &val); 513 - if (!err) 514 - chip->byte_len = val; 515 - 516 - err = device_property_read_u32(dev, "pagesize", &val); 517 - if (!err) { 518 - chip->page_size = val; 519 - } else { 520 - /* 521 - * This is slow, but we can't know all eeproms, so we better 522 - * play safe. Specifying custom eeprom-types via platform_data 523 - * is recommended anyhow. 524 - */ 525 - chip->page_size = 1; 526 - } 527 - } 528 - 529 - static int at24_get_pdata(struct device *dev, struct at24_platform_data *pdata) 474 + static const struct at24_chip_data *at24_get_chip_data(struct device *dev) 530 475 { 531 476 struct device_node *of_node = dev->of_node; 532 477 const struct at24_chip_data *cdata; 533 478 const struct i2c_device_id *id; 534 - struct at24_platform_data *pd; 535 - 536 - pd = dev_get_platdata(dev); 537 - if (pd) { 538 - memcpy(pdata, pd, sizeof(*pdata)); 539 - return 0; 540 - } 541 479 542 480 id = i2c_match_id(at24_ids, to_i2c_client(dev)); 543 481 ··· 502 544 cdata = acpi_device_get_match_data(dev); 503 545 504 546 if (!cdata) 505 - return -ENODEV; 547 + return ERR_PTR(-ENODEV); 506 548 507 - pdata->byte_len = cdata->byte_len; 508 - pdata->flags = cdata->flags; 509 - at24_properties_to_pdata(dev, pdata); 510 - 511 - return 0; 549 + return cdata; 512 550 } 513 551 514 552 static void at24_remove_dummy_clients(struct at24_data *at24) ··· 573 619 { 574 620 struct regmap_config regmap_config = { }; 575 621 struct nvmem_config nvmem_config = { }; 576 - struct at24_platform_data pdata = { }; 622 + u32 byte_len, page_size, flags, addrw; 623 + const struct at24_chip_data *cdata; 577 624 struct device *dev = &client->dev; 578 625 bool i2c_fn_i2c, i2c_fn_block; 579 626 unsigned int i, num_addresses; ··· 589 634 i2c_fn_block = i2c_check_functionality(client->adapter, 590 635 I2C_FUNC_SMBUS_WRITE_I2C_BLOCK); 591 636 592 - err = at24_get_pdata(dev, &pdata); 637 + cdata = at24_get_chip_data(dev); 638 + if (IS_ERR(cdata)) 639 + return PTR_ERR(cdata); 640 + 641 + err = device_property_read_u32(dev, "pagesize", &page_size); 593 642 if (err) 594 - return err; 643 + /* 644 + * This is slow, but we can't know all eeproms, so we better 645 + * play safe. Specifying custom eeprom-types via platform_data 646 + * is recommended anyhow. 647 + */ 648 + page_size = 1; 649 + 650 + flags = cdata->flags; 651 + if (device_property_present(dev, "read-only")) 652 + flags |= AT24_FLAG_READONLY; 653 + if (device_property_present(dev, "no-read-rollover")) 654 + flags |= AT24_FLAG_NO_RDROL; 655 + 656 + err = device_property_read_u32(dev, "address-width", &addrw); 657 + if (!err) { 658 + switch (addrw) { 659 + case 8: 660 + if (flags & AT24_FLAG_ADDR16) 661 + dev_warn(dev, 662 + "Override address width to be 8, while default is 16\n"); 663 + flags &= ~AT24_FLAG_ADDR16; 664 + break; 665 + case 16: 666 + flags |= AT24_FLAG_ADDR16; 667 + break; 668 + default: 669 + dev_warn(dev, "Bad \"address-width\" property: %u\n", 670 + addrw); 671 + } 672 + } 673 + 674 + err = device_property_read_u32(dev, "size", &byte_len); 675 + if (err) 676 + byte_len = cdata->byte_len; 595 677 596 678 if (!i2c_fn_i2c && !i2c_fn_block) 597 - pdata.page_size = 1; 679 + page_size = 1; 598 680 599 - if (!pdata.page_size) { 681 + if (!page_size) { 600 682 dev_err(dev, "page_size must not be 0!\n"); 601 683 return -EINVAL; 602 684 } 603 685 604 - if (!is_power_of_2(pdata.page_size)) 686 + if (!is_power_of_2(page_size)) 605 687 dev_warn(dev, "page_size looks suspicious (no power of 2)!\n"); 606 688 607 - if (pdata.flags & AT24_FLAG_TAKE8ADDR) 608 - num_addresses = 8; 609 - else 610 - num_addresses = DIV_ROUND_UP(pdata.byte_len, 611 - (pdata.flags & AT24_FLAG_ADDR16) ? 65536 : 256); 689 + err = device_property_read_u32(dev, "num-addresses", &num_addresses); 690 + if (err) { 691 + if (flags & AT24_FLAG_TAKE8ADDR) 692 + num_addresses = 8; 693 + else 694 + num_addresses = DIV_ROUND_UP(byte_len, 695 + (flags & AT24_FLAG_ADDR16) ? 65536 : 256); 696 + } 612 697 613 - if ((pdata.flags & AT24_FLAG_SERIAL) && (pdata.flags & AT24_FLAG_MAC)) { 698 + if ((flags & AT24_FLAG_SERIAL) && (flags & AT24_FLAG_MAC)) { 614 699 dev_err(dev, 615 700 "invalid device data - cannot have both AT24_FLAG_SERIAL & AT24_FLAG_MAC."); 616 701 return -EINVAL; 617 702 } 618 703 619 704 regmap_config.val_bits = 8; 620 - regmap_config.reg_bits = (pdata.flags & AT24_FLAG_ADDR16) ? 16 : 8; 705 + regmap_config.reg_bits = (flags & AT24_FLAG_ADDR16) ? 16 : 8; 621 706 regmap_config.disable_locking = true; 622 707 623 708 regmap = devm_regmap_init_i2c(client, &regmap_config); ··· 670 675 return -ENOMEM; 671 676 672 677 mutex_init(&at24->lock); 673 - at24->byte_len = pdata.byte_len; 674 - at24->page_size = pdata.page_size; 675 - at24->flags = pdata.flags; 678 + at24->byte_len = byte_len; 679 + at24->page_size = page_size; 680 + at24->flags = flags; 676 681 at24->num_addresses = num_addresses; 677 - at24->offset_adj = at24_get_offset_adj(pdata.flags, pdata.byte_len); 682 + at24->offset_adj = at24_get_offset_adj(flags, byte_len); 678 683 at24->client[0].client = client; 679 684 at24->client[0].regmap = regmap; 680 685 ··· 682 687 if (IS_ERR(at24->wp_gpio)) 683 688 return PTR_ERR(at24->wp_gpio); 684 689 685 - writable = !(pdata.flags & AT24_FLAG_READONLY); 690 + writable = !(flags & AT24_FLAG_READONLY); 686 691 if (writable) { 687 692 at24->write_max = min_t(unsigned int, 688 - pdata.page_size, at24_io_limit); 693 + page_size, at24_io_limit); 689 694 if (!i2c_fn_i2c && at24->write_max > I2C_SMBUS_BLOCK_MAX) 690 695 at24->write_max = I2C_SMBUS_BLOCK_MAX; 691 696 } ··· 728 733 nvmem_config.priv = at24; 729 734 nvmem_config.stride = 1; 730 735 nvmem_config.word_size = 1; 731 - nvmem_config.size = pdata.byte_len; 736 + nvmem_config.size = byte_len; 732 737 733 738 at24->nvmem = devm_nvmem_register(dev, &nvmem_config); 734 739 if (IS_ERR(at24->nvmem)) { ··· 737 742 } 738 743 739 744 dev_info(dev, "%u byte %s EEPROM, %s, %u bytes/write\n", 740 - pdata.byte_len, client->name, 745 + byte_len, client->name, 741 746 writable ? "writable" : "read-only", at24->write_max); 742 - 743 - /* export data to kernel code */ 744 - if (pdata.setup) 745 - pdata.setup(at24->nvmem, pdata.context); 746 747 747 748 return 0; 748 749
-1
include/linux/davinci_emac.h
··· 46 46 EMAC_VERSION_2, /* DM646x */ 47 47 }; 48 48 49 - void davinci_get_mac_addr(struct nvmem_device *nvmem, void *context); 50 49 #endif
-60
include/linux/platform_data/at24.h
··· 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 */