diff options
author | Mark A. Greer <mgreer@mvista.com> | 2009-04-15 12:41:27 -0700 |
---|---|---|
committer | Kevin Hilman <khilman@deeprootsystems.com> | 2009-05-28 15:17:47 -0700 |
commit | b14dc0f9942a9c318c6c49f29511d88b3642e2d0 (patch) | |
tree | ef9a9f0502c62a059de7ef7bb4949d5f51f8c8d1 /arch/arm/mach-davinci | |
parent | c97909fcf1611645f0fe235b332e39623588d84c (diff) | |
download | blackbird-op-linux-b14dc0f9942a9c318c6c49f29511d88b3642e2d0.tar.gz blackbird-op-linux-b14dc0f9942a9c318c6c49f29511d88b3642e2d0.zip |
davinci: Factor out emac mac address handling
Factor out the code to extract that mac address from
i2c eeprom.
Signed-off-by: Mark A. Greer <mgreer@mvista.com>
Signed-off-by: Kevin Hilman <khilman@deeprootsystems.com>
Diffstat (limited to 'arch/arm/mach-davinci')
-rw-r--r-- | arch/arm/mach-davinci/board-dm644x-evm.c | 21 | ||||
-rw-r--r-- | arch/arm/mach-davinci/board-dm646x-evm.c | 20 | ||||
-rw-r--r-- | arch/arm/mach-davinci/common.c | 12 | ||||
-rw-r--r-- | arch/arm/mach-davinci/devices.c | 26 | ||||
-rw-r--r-- | arch/arm/mach-davinci/include/mach/emac.h | 6 |
5 files changed, 20 insertions, 65 deletions
diff --git a/arch/arm/mach-davinci/board-dm644x-evm.c b/arch/arm/mach-davinci/board-dm644x-evm.c index 987d27fcacb0..d9d40450bdc5 100644 --- a/arch/arm/mach-davinci/board-dm644x-evm.c +++ b/arch/arm/mach-davinci/board-dm644x-evm.c @@ -44,6 +44,7 @@ #include <mach/psc.h> #include <mach/nand.h> #include <mach/mmc.h> +#include <mach/emac.h> #include <mach/common.h> #define DM644X_EVM_PHY_MASK (0x2) @@ -437,28 +438,13 @@ static struct pcf857x_platform_data pcf_data_u35 = { * - 0x0039, 1 byte NTSC vs PAL (bit 0x80 == PAL) * - ... newer boards may have more */ -static struct memory_accessor *at24_mem_acc; - -static void at24_setup(struct memory_accessor *mem_acc, void *context) -{ - char mac_addr[ETH_ALEN]; - struct davinci_soc_info *soc_info = &davinci_soc_info; - - at24_mem_acc = mem_acc; - - /* Read MAC addr from EEPROM */ - if (at24_mem_acc->read(at24_mem_acc, mac_addr, 0x7f00, ETH_ALEN) == - ETH_ALEN) { - printk(KERN_INFO "Read MAC addr from EEPROM: %pM\n", mac_addr); - memcpy(soc_info->emac_pdata->mac_addr, mac_addr, ETH_ALEN); - } -} static struct at24_platform_data eeprom_info = { .byte_len = (256*1024) / 8, .page_size = 64, .flags = AT24_FLAG_ADDR16, - .setup = at24_setup, + .setup = davinci_get_mac_addr, + .context = (void *)0x7f00, }; /* @@ -684,7 +670,6 @@ static __init void davinci_evm_init(void) soc_info->emac_pdata->phy_mask = DM644X_EVM_PHY_MASK; soc_info->emac_pdata->mdio_max_freq = DM644X_EVM_MDIO_FREQUENCY; - dm644x_init_emac(soc_info->emac_pdata); /* Register the fixup for PHY on DaVinci */ phy_register_fixup_for_uid(LXT971_PHY_ID, LXT971_PHY_MASK, diff --git a/arch/arm/mach-davinci/board-dm646x-evm.c b/arch/arm/mach-davinci/board-dm646x-evm.c index 44e2ab665af5..e17de6352624 100644 --- a/arch/arm/mach-davinci/board-dm646x-evm.c +++ b/arch/arm/mach-davinci/board-dm646x-evm.c @@ -198,28 +198,13 @@ static struct pcf857x_platform_data pcf_data = { * - 0x7f00, 6 bytes Ethernet Address * - ... newer boards may have more */ -static struct memory_accessor *at24_mem_acc; - -static void at24_setup(struct memory_accessor *mem_acc, void *context) -{ - char mac_addr[ETH_ALEN]; - struct davinci_soc_info *soc_info = &davinci_soc_info; - - at24_mem_acc = mem_acc; - - /* Read MAC addr from EEPROM */ - if (at24_mem_acc->read(at24_mem_acc, mac_addr, 0x7f00, ETH_ALEN) == - ETH_ALEN) { - pr_info("Read MAC addr from EEPROM: %pM\n", mac_addr); - memcpy(soc_info->emac_pdata->mac_addr, mac_addr, ETH_ALEN); - } -} static struct at24_platform_data eeprom_info = { .byte_len = (256*1024) / 8, .page_size = 64, .flags = AT24_FLAG_ADDR16, - .setup = at24_setup, + .setup = davinci_get_mac_addr, + .context = (void *)0x7f00, }; static struct i2c_board_info __initdata i2c_info[] = { @@ -258,7 +243,6 @@ static __init void evm_init(void) soc_info->emac_pdata->phy_mask = DM646X_EVM_PHY_MASK; soc_info->emac_pdata->mdio_max_freq = DM646X_EVM_MDIO_FREQUENCY; - dm646x_init_emac(soc_info->emac_pdata); } static __init void davinci_dm646x_evm_irq_init(void) diff --git a/arch/arm/mach-davinci/common.c b/arch/arm/mach-davinci/common.c index d72d517d090c..169ec73f8d76 100644 --- a/arch/arm/mach-davinci/common.c +++ b/arch/arm/mach-davinci/common.c @@ -10,12 +10,14 @@ */ #include <linux/module.h> #include <linux/io.h> +#include <linux/etherdevice.h> #include <asm/tlb.h> #include <asm/mach/map.h> #include <mach/common.h> #include <mach/cputype.h> +#include <mach/emac.h> #include "clock.h" @@ -24,6 +26,16 @@ EXPORT_SYMBOL(davinci_soc_info); void __iomem *davinci_intc_base; +void davinci_get_mac_addr(struct memory_accessor *mem_acc, void *context) +{ + char *mac_addr = davinci_soc_info.emac_pdata->mac_addr; + off_t offset = (off_t)context; + + /* Read MAC addr from EEPROM */ + if (mem_acc->read(mem_acc, mac_addr, offset, ETH_ALEN) == ETH_ALEN) + pr_info("Read MAC addr from EEPROM: %pM\n", mac_addr); +} + static struct davinci_id * __init davinci_get_id(u32 jtag_id) { int i; diff --git a/arch/arm/mach-davinci/devices.c b/arch/arm/mach-davinci/devices.c index c0195cd3a2cd..c85091c25d11 100644 --- a/arch/arm/mach-davinci/devices.c +++ b/arch/arm/mach-davinci/devices.c @@ -254,32 +254,6 @@ struct davinci_timer_instance davinci_timer_instance[2] = { /*-------------------------------------------------------------------------*/ -#if defined(CONFIG_TI_DAVINCI_EMAC) || defined(CONFIG_TI_DAVINCI_EMAC_MODULE) - -void davinci_init_emac(struct emac_platform_data *pdata) -{ - DECLARE_MAC_BUF(buf); - - /* if valid MAC exists, don't re-register */ - if (is_valid_ether_addr(pdata->mac_addr)) - return; - else { - /* Use random MAC if none passed */ - random_ether_addr(pdata->mac_addr); - - printk(KERN_WARNING "%s: using random MAC addr: %s\n", - __func__, print_mac(buf, pdata->mac_addr)); - } -} - -#else - -void davinci_init_emac(struct emac_platform_data *unused) {} - -#endif - -/*-------------------------------------------------------------------------*/ - static int __init davinci_init_devices(void) { /* please keep these calls, and their implementations above, diff --git a/arch/arm/mach-davinci/include/mach/emac.h b/arch/arm/mach-davinci/include/mach/emac.h index 549fcced2175..beff4fb7c845 100644 --- a/arch/arm/mach-davinci/include/mach/emac.h +++ b/arch/arm/mach-davinci/include/mach/emac.h @@ -12,6 +12,7 @@ #define _MACH_DAVINCI_EMAC_H #include <linux/if_ether.h> +#include <linux/memory.h> struct emac_platform_data { char mac_addr[ETH_ALEN]; @@ -30,7 +31,6 @@ enum { EMAC_VERSION_1, /* DM644x */ EMAC_VERSION_2, /* DM646x */ }; -void davinci_init_emac(struct emac_platform_data *pdata); -#endif - +void davinci_get_mac_addr(struct memory_accessor *mem_acc, void *context); +#endif |