Commit 90733530 authored by Bartosz Golaszewski's avatar Bartosz Golaszewski

Merge branch 'v5.1/eeprom-for-bartosz' of...

Merge branch 'v5.1/eeprom-for-bartosz' of git://git.kernel.org/pub/scm/linux/kernel/git/nsekhar/linux-davinci into at24/for-next
parents d1393711 e430685f
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
#include <linux/platform_device.h> #include <linux/platform_device.h>
#include <linux/i2c.h> #include <linux/i2c.h>
#include <linux/platform_data/pcf857x.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/mtd.h>
#include <linux/mtd/partitions.h> #include <linux/mtd/partitions.h>
#include <linux/spi/spi.h> #include <linux/spi/spi.h>
...@@ -457,12 +457,9 @@ static struct nvmem_cell_lookup da830_evm_nvmem_cell_lookup = { ...@@ -457,12 +457,9 @@ static struct nvmem_cell_lookup da830_evm_nvmem_cell_lookup = {
.con_id = "mac-address", .con_id = "mac-address",
}; };
static struct at24_platform_data da830_evm_i2c_eeprom_info = { static const struct property_entry da830_evm_i2c_eeprom_properties[] = {
.byte_len = SZ_256K / 8, PROPERTY_ENTRY_U32("pagesize", 64),
.page_size = 64, { }
.flags = AT24_FLAG_ADDR16,
.setup = davinci_get_mac_addr,
.context = (void *)0x7f00,
}; };
static int __init da830_evm_ui_expander_setup(struct i2c_client *client, 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,7 +493,7 @@ static struct pcf857x_platform_data __initdata da830_evm_ui_expander_info = {
static struct i2c_board_info __initdata da830_evm_i2c_devices[] = { static struct i2c_board_info __initdata da830_evm_i2c_devices[] = {
{ {
I2C_BOARD_INFO("24c256", 0x50), I2C_BOARD_INFO("24c256", 0x50),
.platform_data = &da830_evm_i2c_eeprom_info, .properties = da830_evm_i2c_eeprom_properties,
}, },
{ {
I2C_BOARD_INFO("tlv320aic3x", 0x18), I2C_BOARD_INFO("tlv320aic3x", 0x18),
......
...@@ -150,32 +150,6 @@ static struct spi_board_info da850evm_spi_info[] = { ...@@ -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[] = { static struct mtd_partition da850_evm_norflash_partition[] = {
{ {
.name = "bootloaders + env", .name = "bootloaders + env",
...@@ -1494,8 +1468,6 @@ static __init void da850_evm_init(void) ...@@ -1494,8 +1468,6 @@ static __init void da850_evm_init(void)
if (ret) if (ret)
pr_warn("%s: SATA registration failed: %d\n", __func__, ret); pr_warn("%s: SATA registration failed: %d\n", __func__, ret);
da850_evm_setup_mac_addr();
ret = da8xx_register_rproc(); ret = da8xx_register_rproc();
if (ret) if (ret)
pr_warn("%s: dsp/rproc registration failed: %d\n", pr_warn("%s: dsp/rproc registration failed: %d\n",
......
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
#include <linux/i2c.h> #include <linux/i2c.h>
#include <linux/io.h> #include <linux/io.h>
#include <linux/clk.h> #include <linux/clk.h>
#include <linux/platform_data/at24.h> #include <linux/property.h>
#include <linux/leds.h> #include <linux/leds.h>
#include <linux/mtd/mtd.h> #include <linux/mtd/mtd.h>
#include <linux/mtd/partitions.h> #include <linux/mtd/partitions.h>
...@@ -225,18 +225,15 @@ static struct nvmem_cell_lookup davinci_nvmem_cell_lookup = { ...@@ -225,18 +225,15 @@ static struct nvmem_cell_lookup davinci_nvmem_cell_lookup = {
.con_id = "mac-address", .con_id = "mac-address",
}; };
static struct at24_platform_data eeprom_info = { static const struct property_entry eeprom_properties[] = {
.byte_len = (256*1024) / 8, PROPERTY_ENTRY_U32("pagesize", 64),
.page_size = 64, { }
.flags = AT24_FLAG_ADDR16,
.setup = davinci_get_mac_addr,
.context = (void *)0x7f00,
}; };
static struct i2c_board_info i2c_info[] = { static struct i2c_board_info i2c_info[] = {
{ {
I2C_BOARD_INFO("24c256", 0x50), I2C_BOARD_INFO("24c256", 0x50),
.platform_data = &eeprom_info, .properties = eeprom_properties,
}, },
{ {
I2C_BOARD_INFO("tlv320aic3x", 0x18), I2C_BOARD_INFO("tlv320aic3x", 0x18),
......
...@@ -16,8 +16,8 @@ ...@@ -16,8 +16,8 @@
#include <linux/gpio/machine.h> #include <linux/gpio/machine.h>
#include <linux/i2c.h> #include <linux/i2c.h>
#include <linux/platform_data/pcf857x.h> #include <linux/platform_data/pcf857x.h>
#include <linux/platform_data/at24.h>
#include <linux/platform_data/gpio-davinci.h> #include <linux/platform_data/gpio-davinci.h>
#include <linux/property.h>
#include <linux/mtd/mtd.h> #include <linux/mtd/mtd.h>
#include <linux/mtd/rawnand.h> #include <linux/mtd/rawnand.h>
#include <linux/mtd/partitions.h> #include <linux/mtd/partitions.h>
...@@ -532,12 +532,9 @@ static struct nvmem_cell_lookup dm644evm_nvmem_cell_lookup = { ...@@ -532,12 +532,9 @@ static struct nvmem_cell_lookup dm644evm_nvmem_cell_lookup = {
.con_id = "mac-address", .con_id = "mac-address",
}; };
static struct at24_platform_data eeprom_info = { static const struct property_entry eeprom_properties[] = {
.byte_len = (256*1024) / 8, PROPERTY_ENTRY_U32("pagesize", 64),
.page_size = 64, { }
.flags = AT24_FLAG_ADDR16,
.setup = davinci_get_mac_addr,
.context = (void *)0x7f00,
}; };
/* /*
...@@ -647,7 +644,7 @@ static struct i2c_board_info __initdata i2c_info[] = { ...@@ -647,7 +644,7 @@ static struct i2c_board_info __initdata i2c_info[] = {
}, },
{ {
I2C_BOARD_INFO("24c256", 0x50), I2C_BOARD_INFO("24c256", 0x50),
.platform_data = &eeprom_info, .properties = eeprom_properties,
}, },
{ {
I2C_BOARD_INFO("tlv320aic33", 0x1b), I2C_BOARD_INFO("tlv320aic33", 0x1b),
......
...@@ -22,7 +22,7 @@ ...@@ -22,7 +22,7 @@
#include <linux/gpio.h> #include <linux/gpio.h>
#include <linux/platform_device.h> #include <linux/platform_device.h>
#include <linux/i2c.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/pcf857x.h>
#include <linux/platform_data/ti-aemif.h> #include <linux/platform_data/ti-aemif.h>
...@@ -364,12 +364,9 @@ static struct nvmem_cell_lookup dm646x_evm_nvmem_cell_lookup = { ...@@ -364,12 +364,9 @@ static struct nvmem_cell_lookup dm646x_evm_nvmem_cell_lookup = {
.con_id = "mac-address", .con_id = "mac-address",
}; };
static struct at24_platform_data eeprom_info = { static const struct property_entry eeprom_properties[] = {
.byte_len = (256*1024) / 8, PROPERTY_ENTRY_U32("pagesize", 64),
.page_size = 64, { }
.flags = AT24_FLAG_ADDR16,
.setup = davinci_get_mac_addr,
.context = (void *)0x7f00,
}; };
#endif #endif
...@@ -440,7 +437,7 @@ static void evm_init_cpld(void) ...@@ -440,7 +437,7 @@ static void evm_init_cpld(void)
static struct i2c_board_info __initdata i2c_info[] = { static struct i2c_board_info __initdata i2c_info[] = {
{ {
I2C_BOARD_INFO("24c256", 0x50), I2C_BOARD_INFO("24c256", 0x50),
.platform_data = &eeprom_info, .properties = eeprom_properties,
}, },
{ {
I2C_BOARD_INFO("pcf8574a", 0x38), I2C_BOARD_INFO("pcf8574a", 0x38),
......
...@@ -14,11 +14,13 @@ ...@@ -14,11 +14,13 @@
#include <linux/init.h> #include <linux/init.h>
#include <linux/console.h> #include <linux/console.h>
#include <linux/platform_device.h> #include <linux/platform_device.h>
#include <linux/property.h>
#include <linux/mtd/partitions.h> #include <linux/mtd/partitions.h>
#include <linux/notifier.h>
#include <linux/nvmem-consumer.h>
#include <linux/nvmem-provider.h> #include <linux/nvmem-provider.h>
#include <linux/regulator/machine.h> #include <linux/regulator/machine.h>
#include <linux/i2c.h> #include <linux/i2c.h>
#include <linux/platform_data/at24.h>
#include <linux/etherdevice.h> #include <linux/etherdevice.h>
#include <linux/spi/spi.h> #include <linux/spi/spi.h>
#include <linux/spi/flash.h> #include <linux/spi/flash.h>
...@@ -117,11 +119,15 @@ static void mityomapl138_cpufreq_init(const char *partnum) ...@@ -117,11 +119,15 @@ static void mityomapl138_cpufreq_init(const char *partnum)
static void mityomapl138_cpufreq_init(const char *partnum) { } static void mityomapl138_cpufreq_init(const char *partnum) { }
#endif #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; int ret;
const char *partnum = NULL; 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)) { if (!IS_BUILTIN(CONFIG_NVMEM)) {
pr_warn("Factory Config not available without CONFIG_NVMEM\n"); 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,21 +153,20 @@ static void read_factory_config(struct nvmem_device *nvmem, void *context)
goto bad_config; 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; partnum = factory_config.partnum;
pr_info("Part Number = %s\n", partnum); pr_info("Part Number = %s\n", partnum);
bad_config: bad_config:
/* default maximum speed is valid for all platforms */ /* default maximum speed is valid for all platforms */
mityomapl138_cpufreq_init(partnum); 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 * We don't define a cell for factory config as it will be accessed from the
* board file using the nvmem notifier chain. * board file using the nvmem notifier chain.
...@@ -187,12 +192,10 @@ static struct nvmem_cell_lookup mityomapl138_nvmem_cell_lookup = { ...@@ -187,12 +192,10 @@ static struct nvmem_cell_lookup mityomapl138_nvmem_cell_lookup = {
.con_id = "mac-address", .con_id = "mac-address",
}; };
static struct at24_platform_data mityomapl138_fd_chip = { static const struct property_entry mityomapl138_fd_chip_properties[] = {
.byte_len = 256, PROPERTY_ENTRY_U32("pagesize", 8),
.page_size = 8, PROPERTY_ENTRY_BOOL("read-only"),
.flags = AT24_FLAG_READONLY | AT24_FLAG_IRUGO, { }
.setup = read_factory_config,
.context = NULL,
}; };
static struct davinci_i2c_platform_data mityomap_i2c_0_pdata = { static struct davinci_i2c_platform_data mityomap_i2c_0_pdata = {
...@@ -321,7 +324,7 @@ static struct i2c_board_info __initdata mityomap_tps65023_info[] = { ...@@ -321,7 +324,7 @@ static struct i2c_board_info __initdata mityomap_tps65023_info[] = {
}, },
{ {
I2C_BOARD_INFO("24c02", 0x50), I2C_BOARD_INFO("24c02", 0x50),
.platform_data = &mityomapl138_fd_chip, .properties = mityomapl138_fd_chip_properties,
}, },
}; };
...@@ -569,6 +572,7 @@ static void __init mityomapl138_init(void) ...@@ -569,6 +572,7 @@ static void __init mityomapl138_init(void)
davinci_serial_init(da8xx_serial_device); davinci_serial_init(da8xx_serial_device);
nvmem_register_notifier(&mityomapl138_nvmem_notifier);
nvmem_add_cell_table(&mityomapl138_nvmem_cell_table); nvmem_add_cell_table(&mityomapl138_nvmem_cell_table);
nvmem_add_cell_lookups(&mityomapl138_nvmem_cell_lookup, 1); nvmem_add_cell_lookups(&mityomapl138_nvmem_cell_lookup, 1);
......
...@@ -26,7 +26,7 @@ ...@@ -26,7 +26,7 @@
#include <linux/init.h> #include <linux/init.h>
#include <linux/platform_device.h> #include <linux/platform_device.h>
#include <linux/i2c.h> #include <linux/i2c.h>
#include <linux/platform_data/at24.h> #include <linux/property.h>
#include <linux/mtd/mtd.h> #include <linux/mtd/mtd.h>
#include <linux/mtd/rawnand.h> #include <linux/mtd/rawnand.h>
#include <linux/mtd/partitions.h> #include <linux/mtd/partitions.h>
...@@ -92,16 +92,15 @@ static struct platform_device davinci_sffsdr_nandflash_device = { ...@@ -92,16 +92,15 @@ static struct platform_device davinci_sffsdr_nandflash_device = {
.resource = davinci_sffsdr_nandflash_resource, .resource = davinci_sffsdr_nandflash_resource,
}; };
static struct at24_platform_data eeprom_info = { static const struct property_entry eeprom_properties[] = {
.byte_len = (64*1024) / 8, PROPERTY_ENTRY_U32("pagesize", 32),
.page_size = 32, { }
.flags = AT24_FLAG_ADDR16,
}; };
static struct i2c_board_info __initdata i2c_info[] = { static struct i2c_board_info __initdata i2c_info[] = {
{ {
I2C_BOARD_INFO("24lc64", 0x50), I2C_BOARD_INFO("24c64", 0x50),
.platform_data = &eeprom_info, .properties = eeprom_properties,
}, },
/* Other I2C devices: /* Other I2C devices:
* MSP430, addr 0x23 (not used) * MSP430, addr 0x23 (not used)
......
...@@ -26,21 +26,6 @@ EXPORT_SYMBOL(davinci_soc_info); ...@@ -26,21 +26,6 @@ EXPORT_SYMBOL(davinci_soc_info);
void __iomem *davinci_intc_base; void __iomem *davinci_intc_base;
int davinci_intc_type; 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) static int __init davinci_init_id(struct davinci_soc_info *soc_info)
{ {
int i; int i;
......
...@@ -46,5 +46,4 @@ enum { ...@@ -46,5 +46,4 @@ enum {
EMAC_VERSION_2, /* DM646x */ EMAC_VERSION_2, /* DM646x */
}; };
void davinci_get_mac_addr(struct nvmem_device *nvmem, void *context);
#endif #endif
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment