diff options
author | Rajashekhara, Sudhakar <sudhakar.raj@ti.com> | 2011-07-12 06:28:53 -0400 |
---|---|---|
committer | Sekhar Nori <nsekhar@ti.com> | 2011-09-07 04:53:01 -0400 |
commit | 810198bc9c109489dfadc57131c5183ce6ad2d7d (patch) | |
tree | 739a24d54f14aaac66998e83a1307989ea849036 /arch | |
parent | ddf28352b80c86754a6424e3a61e8bdf9213b3c7 (diff) |
ARM: davinci: da850 EVM: read mac address from SPI flash
DA850/OMAP-L138 EMAC driver uses random mac address instead of
a fixed one because the mac address is not stuffed into EMAC
platform data.
This patch provides a function which reads the mac address
stored in SPI flash (registered as MTD device) and populates the
EMAC platform data. The function which reads the mac address is
registered as a callback which gets called upon addition of MTD
device.
NOTE: In case the MAC address stored in SPI flash is erased, follow
the instructions at [1] to restore it.
[1] http://processors.wiki.ti.com/index.php/GSG:_OMAP-L138_DVEVM_Additional_Procedures#Restoring_MAC_address_on_SPI_Flash
Modifications in v2:
Guarded registering the mtd_notifier only when MTD is enabled.
Earlier this was handled using mtd_has_partitions() call, but
this has been removed in Linux v3.0.
Modifications in v3:
a. Guarded da850_evm_m25p80_notify_add() function and
da850evm_spi_notifier structure with CONFIG_MTD macros.
b. Renamed da850_evm_register_mtd_user() function to
da850_evm_setup_mac_addr() and removed the struct mtd_notifier
argument to this function.
c. Passed the da850evm_spi_notifier structure to register_mtd_user()
function.
Modifications in v4:
Moved the da850_evm_setup_mac_addr() function within the first
CONFIG_MTD ifdef construct.
Signed-off-by: Rajashekhara, Sudhakar <sudhakar.raj@ti.com>
Signed-off-by: Sekhar Nori <nsekhar@ti.com>
Cc: stable@kernel.org
Diffstat (limited to 'arch')
-rw-r--r-- | arch/arm/mach-davinci/board-da850-evm.c | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/arch/arm/mach-davinci/board-da850-evm.c b/arch/arm/mach-davinci/board-da850-evm.c index bd5394537c88..008d51407cd7 100644 --- a/arch/arm/mach-davinci/board-da850-evm.c +++ b/arch/arm/mach-davinci/board-da850-evm.c | |||
@@ -115,6 +115,32 @@ static struct spi_board_info da850evm_spi_info[] = { | |||
115 | }, | 115 | }, |
116 | }; | 116 | }; |
117 | 117 | ||
118 | #ifdef CONFIG_MTD | ||
119 | static void da850_evm_m25p80_notify_add(struct mtd_info *mtd) | ||
120 | { | ||
121 | char *mac_addr = davinci_soc_info.emac_pdata->mac_addr; | ||
122 | size_t retlen; | ||
123 | |||
124 | if (!strcmp(mtd->name, "MAC-Address")) { | ||
125 | mtd->read(mtd, 0, ETH_ALEN, &retlen, mac_addr); | ||
126 | if (retlen == ETH_ALEN) | ||
127 | pr_info("Read MAC addr from SPI Flash: %pM\n", | ||
128 | mac_addr); | ||
129 | } | ||
130 | } | ||
131 | |||
132 | static struct mtd_notifier da850evm_spi_notifier = { | ||
133 | .add = da850_evm_m25p80_notify_add, | ||
134 | }; | ||
135 | |||
136 | static void da850_evm_setup_mac_addr(void) | ||
137 | { | ||
138 | register_mtd_user(&da850evm_spi_notifier); | ||
139 | } | ||
140 | #else | ||
141 | static void da850_evm_setup_mac_addr(void) { } | ||
142 | #endif | ||
143 | |||
118 | static struct mtd_partition da850_evm_norflash_partition[] = { | 144 | static struct mtd_partition da850_evm_norflash_partition[] = { |
119 | { | 145 | { |
120 | .name = "bootloaders + env", | 146 | .name = "bootloaders + env", |
@@ -1244,6 +1270,8 @@ static __init void da850_evm_init(void) | |||
1244 | if (ret) | 1270 | if (ret) |
1245 | pr_warning("da850_evm_init: sata registration failed: %d\n", | 1271 | pr_warning("da850_evm_init: sata registration failed: %d\n", |
1246 | ret); | 1272 | ret); |
1273 | |||
1274 | da850_evm_setup_mac_addr(); | ||
1247 | } | 1275 | } |
1248 | 1276 | ||
1249 | #ifdef CONFIG_SERIAL_8250_CONSOLE | 1277 | #ifdef CONFIG_SERIAL_8250_CONSOLE |