Skip to content

Commit

Permalink
Merge tag 'at24-5.1-updates-for-wolfram' of git://git.kernel.org/pub/…
Browse files Browse the repository at this point in the history
…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
  • Loading branch information
Wolfram Sang committed Feb 14, 2019
2 parents d8434c3 + 950bcbb commit bceb26b
Show file tree
Hide file tree
Showing 13 changed files with 130 additions and 250 deletions.
3 changes: 3 additions & 0 deletions Documentation/devicetree/bindings/eeprom/at24.txt
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,14 @@ Optional properties:

- address-width: number of address bits (one of 8, 16).

- num-addresses: total number of i2c slave addresses this device takes

Example:

eeprom@52 {
compatible = "atmel,24c32";
reg = <0x52>;
pagesize = <32>;
wp-gpios = <&gpio1 3 0>;
num-addresses = <8>;
};
1 change: 0 additions & 1 deletion MAINTAINERS
Original file line number Diff line number Diff line change
Expand Up @@ -2503,7 +2503,6 @@ T: git git://git.kernel.org/pub/scm/linux/kernel/git/brgl/linux.git
S: Maintained
F: Documentation/devicetree/bindings/eeprom/at24.txt
F: drivers/misc/eeprom/at24.c
F: include/linux/platform_data/at24.h

ATA OVER ETHERNET (AOE) DRIVER
M: "Ed L. Cashin" <ed.cashin@acm.org>
Expand Down
13 changes: 5 additions & 8 deletions arch/arm/mach-davinci/board-da830-evm.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
#include <linux/platform_device.h>
#include <linux/i2c.h>
#include <linux/platform_data/pcf857x.h>
#include <linux/platform_data/at24.h>
#include <linux/property.h>
#include <linux/mtd/mtd.h>
#include <linux/mtd/partitions.h>
#include <linux/spi/spi.h>
Expand Down Expand Up @@ -457,12 +457,9 @@ static struct nvmem_cell_lookup da830_evm_nvmem_cell_lookup = {
.con_id = "mac-address",
};

static struct at24_platform_data da830_evm_i2c_eeprom_info = {
.byte_len = SZ_256K / 8,
.page_size = 64,
.flags = AT24_FLAG_ADDR16,
.setup = davinci_get_mac_addr,
.context = (void *)0x7f00,
static const struct property_entry da830_evm_i2c_eeprom_properties[] = {
PROPERTY_ENTRY_U32("pagesize", 64),
{ }
};

static int __init da830_evm_ui_expander_setup(struct i2c_client *client,
Expand Down Expand Up @@ -496,7 +493,7 @@ static struct pcf857x_platform_data __initdata da830_evm_ui_expander_info = {
static struct i2c_board_info __initdata da830_evm_i2c_devices[] = {
{
I2C_BOARD_INFO("24c256", 0x50),
.platform_data = &da830_evm_i2c_eeprom_info,
.properties = da830_evm_i2c_eeprom_properties,
},
{
I2C_BOARD_INFO("tlv320aic3x", 0x18),
Expand Down
28 changes: 0 additions & 28 deletions arch/arm/mach-davinci/board-da850-evm.c
Original file line number Diff line number Diff line change
Expand Up @@ -150,32 +150,6 @@ static struct spi_board_info da850evm_spi_info[] = {
},
};

#ifdef CONFIG_MTD
static void da850_evm_m25p80_notify_add(struct mtd_info *mtd)
{
char *mac_addr = davinci_soc_info.emac_pdata->mac_addr;
size_t retlen;

if (!strcmp(mtd->name, "MAC-Address")) {
mtd_read(mtd, 0, ETH_ALEN, &retlen, mac_addr);
if (retlen == ETH_ALEN)
pr_info("Read MAC addr from SPI Flash: %pM\n",
mac_addr);
}
}

static struct mtd_notifier da850evm_spi_notifier = {
.add = da850_evm_m25p80_notify_add,
};

static void da850_evm_setup_mac_addr(void)
{
register_mtd_user(&da850evm_spi_notifier);
}
#else
static void da850_evm_setup_mac_addr(void) { }
#endif

static struct mtd_partition da850_evm_norflash_partition[] = {
{
.name = "bootloaders + env",
Expand Down Expand Up @@ -1494,8 +1468,6 @@ static __init void da850_evm_init(void)
if (ret)
pr_warn("%s: SATA registration failed: %d\n", __func__, ret);

da850_evm_setup_mac_addr();

ret = da8xx_register_rproc();
if (ret)
pr_warn("%s: dsp/rproc registration failed: %d\n",
Expand Down
13 changes: 5 additions & 8 deletions arch/arm/mach-davinci/board-dm365-evm.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
#include <linux/i2c.h>
#include <linux/io.h>
#include <linux/clk.h>
#include <linux/platform_data/at24.h>
#include <linux/property.h>
#include <linux/leds.h>
#include <linux/mtd/mtd.h>
#include <linux/mtd/partitions.h>
Expand Down Expand Up @@ -225,18 +225,15 @@ static struct nvmem_cell_lookup davinci_nvmem_cell_lookup = {
.con_id = "mac-address",
};

static struct at24_platform_data eeprom_info = {
.byte_len = (256*1024) / 8,
.page_size = 64,
.flags = AT24_FLAG_ADDR16,
.setup = davinci_get_mac_addr,
.context = (void *)0x7f00,
static const struct property_entry eeprom_properties[] = {
PROPERTY_ENTRY_U32("pagesize", 64),
{ }
};

static struct i2c_board_info i2c_info[] = {
{
I2C_BOARD_INFO("24c256", 0x50),
.platform_data = &eeprom_info,
.properties = eeprom_properties,
},
{
I2C_BOARD_INFO("tlv320aic3x", 0x18),
Expand Down
13 changes: 5 additions & 8 deletions arch/arm/mach-davinci/board-dm644x-evm.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
#include <linux/gpio/machine.h>
#include <linux/i2c.h>
#include <linux/platform_data/pcf857x.h>
#include <linux/platform_data/at24.h>
#include <linux/platform_data/gpio-davinci.h>
#include <linux/property.h>
#include <linux/mtd/mtd.h>
#include <linux/mtd/rawnand.h>
#include <linux/mtd/partitions.h>
Expand Down Expand Up @@ -532,12 +532,9 @@ static struct nvmem_cell_lookup dm644evm_nvmem_cell_lookup = {
.con_id = "mac-address",
};

static struct at24_platform_data eeprom_info = {
.byte_len = (256*1024) / 8,
.page_size = 64,
.flags = AT24_FLAG_ADDR16,
.setup = davinci_get_mac_addr,
.context = (void *)0x7f00,
static const struct property_entry eeprom_properties[] = {
PROPERTY_ENTRY_U32("pagesize", 64),
{ }
};

/*
Expand Down Expand Up @@ -647,7 +644,7 @@ static struct i2c_board_info __initdata i2c_info[] = {
},
{
I2C_BOARD_INFO("24c256", 0x50),
.platform_data = &eeprom_info,
.properties = eeprom_properties,
},
{
I2C_BOARD_INFO("tlv320aic33", 0x1b),
Expand Down
13 changes: 5 additions & 8 deletions arch/arm/mach-davinci/board-dm646x-evm.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
#include <linux/gpio.h>
#include <linux/platform_device.h>
#include <linux/i2c.h>
#include <linux/platform_data/at24.h>
#include <linux/property.h>
#include <linux/platform_data/pcf857x.h>
#include <linux/platform_data/ti-aemif.h>

Expand Down Expand Up @@ -364,12 +364,9 @@ static struct nvmem_cell_lookup dm646x_evm_nvmem_cell_lookup = {
.con_id = "mac-address",
};

static struct at24_platform_data eeprom_info = {
.byte_len = (256*1024) / 8,
.page_size = 64,
.flags = AT24_FLAG_ADDR16,
.setup = davinci_get_mac_addr,
.context = (void *)0x7f00,
static const struct property_entry eeprom_properties[] = {
PROPERTY_ENTRY_U32("pagesize", 64),
{ }
};
#endif

Expand Down Expand Up @@ -440,7 +437,7 @@ static void evm_init_cpld(void)
static struct i2c_board_info __initdata i2c_info[] = {
{
I2C_BOARD_INFO("24c256", 0x50),
.platform_data = &eeprom_info,
.properties = eeprom_properties,
},
{
I2C_BOARD_INFO("pcf8574a", 0x38),
Expand Down
38 changes: 21 additions & 17 deletions arch/arm/mach-davinci/board-mityomapl138.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,13 @@
#include <linux/init.h>
#include <linux/console.h>
#include <linux/platform_device.h>
#include <linux/property.h>
#include <linux/mtd/partitions.h>
#include <linux/notifier.h>
#include <linux/nvmem-consumer.h>
#include <linux/nvmem-provider.h>
#include <linux/regulator/machine.h>
#include <linux/i2c.h>
#include <linux/platform_data/at24.h>
#include <linux/etherdevice.h>
#include <linux/spi/spi.h>
#include <linux/spi/flash.h>
Expand Down Expand Up @@ -117,11 +119,15 @@ static void mityomapl138_cpufreq_init(const char *partnum)
static void mityomapl138_cpufreq_init(const char *partnum) { }
#endif

static void read_factory_config(struct nvmem_device *nvmem, void *context)
static int read_factory_config(struct notifier_block *nb,
unsigned long event, void *data)
{
int ret;
const char *partnum = NULL;
struct davinci_soc_info *soc_info = &davinci_soc_info;
struct nvmem_device *nvmem = data;

if (strcmp(nvmem_dev_name(nvmem), "1-00500") != 0)
return NOTIFY_DONE;

if (!IS_BUILTIN(CONFIG_NVMEM)) {
pr_warn("Factory Config not available without CONFIG_NVMEM\n");
Expand All @@ -147,21 +153,20 @@ static void read_factory_config(struct nvmem_device *nvmem, void *context)
goto bad_config;
}

pr_info("Found MAC = %pM\n", factory_config.mac);
if (is_valid_ether_addr(factory_config.mac))
memcpy(soc_info->emac_pdata->mac_addr,
factory_config.mac, ETH_ALEN);
else
pr_warn("Invalid MAC found in factory config block\n");

partnum = factory_config.partnum;
pr_info("Part Number = %s\n", partnum);

bad_config:
/* default maximum speed is valid for all platforms */
mityomapl138_cpufreq_init(partnum);

return NOTIFY_STOP;
}

static struct notifier_block mityomapl138_nvmem_notifier = {
.notifier_call = read_factory_config,
};

/*
* We don't define a cell for factory config as it will be accessed from the
* board file using the nvmem notifier chain.
Expand All @@ -187,12 +192,10 @@ static struct nvmem_cell_lookup mityomapl138_nvmem_cell_lookup = {
.con_id = "mac-address",
};

static struct at24_platform_data mityomapl138_fd_chip = {
.byte_len = 256,
.page_size = 8,
.flags = AT24_FLAG_READONLY | AT24_FLAG_IRUGO,
.setup = read_factory_config,
.context = NULL,
static const struct property_entry mityomapl138_fd_chip_properties[] = {
PROPERTY_ENTRY_U32("pagesize", 8),
PROPERTY_ENTRY_BOOL("read-only"),
{ }
};

static struct davinci_i2c_platform_data mityomap_i2c_0_pdata = {
Expand Down Expand Up @@ -321,7 +324,7 @@ static struct i2c_board_info __initdata mityomap_tps65023_info[] = {
},
{
I2C_BOARD_INFO("24c02", 0x50),
.platform_data = &mityomapl138_fd_chip,
.properties = mityomapl138_fd_chip_properties,
},
};

Expand Down Expand Up @@ -569,6 +572,7 @@ static void __init mityomapl138_init(void)

davinci_serial_init(da8xx_serial_device);

nvmem_register_notifier(&mityomapl138_nvmem_notifier);
nvmem_add_cell_table(&mityomapl138_nvmem_cell_table);
nvmem_add_cell_lookups(&mityomapl138_nvmem_cell_lookup, 1);

Expand Down
13 changes: 6 additions & 7 deletions arch/arm/mach-davinci/board-sffsdr.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
#include <linux/init.h>
#include <linux/platform_device.h>
#include <linux/i2c.h>
#include <linux/platform_data/at24.h>
#include <linux/property.h>
#include <linux/mtd/mtd.h>
#include <linux/mtd/rawnand.h>
#include <linux/mtd/partitions.h>
Expand Down Expand Up @@ -92,16 +92,15 @@ static struct platform_device davinci_sffsdr_nandflash_device = {
.resource = davinci_sffsdr_nandflash_resource,
};

static struct at24_platform_data eeprom_info = {
.byte_len = (64*1024) / 8,
.page_size = 32,
.flags = AT24_FLAG_ADDR16,
static const struct property_entry eeprom_properties[] = {
PROPERTY_ENTRY_U32("pagesize", 32),
{ }
};

static struct i2c_board_info __initdata i2c_info[] = {
{
I2C_BOARD_INFO("24lc64", 0x50),
.platform_data = &eeprom_info,
I2C_BOARD_INFO("24c64", 0x50),
.properties = eeprom_properties,
},
/* Other I2C devices:
* MSP430, addr 0x23 (not used)
Expand Down
15 changes: 0 additions & 15 deletions arch/arm/mach-davinci/common.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,21 +26,6 @@ EXPORT_SYMBOL(davinci_soc_info);
void __iomem *davinci_intc_base;
int davinci_intc_type;

void davinci_get_mac_addr(struct nvmem_device *nvmem, void *context)
{
char *mac_addr = davinci_soc_info.emac_pdata->mac_addr;
off_t offset = (off_t)context;

if (!IS_BUILTIN(CONFIG_NVMEM)) {
pr_warn("Cannot read MAC addr from EEPROM without CONFIG_NVMEM\n");
return;
}

/* Read MAC addr from EEPROM */
if (nvmem_device_read(nvmem, offset, ETH_ALEN, mac_addr) == ETH_ALEN)
pr_info("Read MAC addr from EEPROM: %pM\n", mac_addr);
}

static int __init davinci_init_id(struct davinci_soc_info *soc_info)
{
int i;
Expand Down
Loading

0 comments on commit bceb26b

Please sign in to comment.