OSDN Git Service

ARM: davinci: mityomapl138: use cell nvmem lookup for mac address
authorBartosz Golaszewski <bgolaszewski@baylibre.com>
Tue, 13 Nov 2018 14:01:15 +0000 (15:01 +0100)
committerSekhar Nori <nsekhar@ti.com>
Thu, 6 Dec 2018 10:49:50 +0000 (16:19 +0530)
We now support nvmem lookups and cell definitions for machine code.
Add relevant data structures for the mac-address stored in at24 EEPROM.

Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Signed-off-by: Sekhar Nori <nsekhar@ti.com>
arch/arm/mach-davinci/board-mityomapl138.c

index 2933e0c..8df16e8 100644 (file)
@@ -15,6 +15,7 @@
 #include <linux/console.h>
 #include <linux/platform_device.h>
 #include <linux/mtd/partitions.h>
+#include <linux/nvmem-provider.h>
 #include <linux/regulator/machine.h>
 #include <linux/i2c.h>
 #include <linux/platform_data/at24.h>
@@ -161,6 +162,31 @@ bad_config:
        mityomapl138_cpufreq_init(partnum);
 }
 
+/*
+ * We don't define a cell for factory config as it will be accessed from the
+ * board file using the nvmem notifier chain.
+ */
+static struct nvmem_cell_info mityomapl138_nvmem_cells[] = {
+       {
+               .name           = "macaddr",
+               .offset         = 0x64,
+               .bytes          = ETH_ALEN,
+       }
+};
+
+static struct nvmem_cell_table mityomapl138_nvmem_cell_table = {
+       .nvmem_name     = "1-00500",
+       .cells          = mityomapl138_nvmem_cells,
+       .ncells         = ARRAY_SIZE(mityomapl138_nvmem_cells),
+};
+
+static struct nvmem_cell_lookup mityomapl138_nvmem_cell_lookup = {
+       .nvmem_name     = "1-00500",
+       .cell_name      = "macaddr",
+       .dev_id         = "davinci_emac.1",
+       .con_id         = "mac-address",
+};
+
 static struct at24_platform_data mityomapl138_fd_chip = {
        .byte_len       = 256,
        .page_size      = 8,
@@ -543,6 +569,9 @@ static void __init mityomapl138_init(void)
 
        davinci_serial_init(da8xx_serial_device);
 
+       nvmem_add_cell_table(&mityomapl138_nvmem_cell_table);
+       nvmem_add_cell_lookups(&mityomapl138_nvmem_cell_lookup, 1);
+
        ret = da8xx_register_i2c(0, &mityomap_i2c_0_pdata);
        if (ret)
                pr_warn("i2c0 registration failed: %d\n", ret);