OMAP3: support fake USB Ethernet MAC address for OMAP3 BeagleBoard-XM
cover OMAP3: support fake USB Ethernet MAC address for OMAP3 BeagleBoard-XM
BeagleBoard-XM unfortunately is plagued by lack of proper MAC address in USB resulting in custom uEnv.txt and risk of MAC address conflict in the network.
NOTE:
a) if user wants to manually set/override the mac address, then they can change the environment variable prior to 'usb start'
b) If a new board file would like to create it's own version of this, the weak function can be overriden as well.
c) There does not yet seem a need to create a generic fake ethernet MAC address logic, hence, not done pending such a need.
Nishanth Menon (3):
OMAP: common: consolidate fake USB ethernet MAC address creation omap3/sys_info: provide interface to read die id
OMAP3: beagle-xm: generate fake USB ethernet MAC address from dieid
arch/arm/cpu/armv7/omap-common/utils.c | 22 ++++++++++++++++++++++ arch/arm/cpu/armv7/omap3/sys_info.c | 19 ++++++++++++++----- arch/arm/include/asm/arch-omap3/sys_proto.h | 2 ++ arch/arm/include/asm/omap_common.h | 2 ++ board/ti/beagle/beagle.c | 11 +++++++++++ board/ti/omap5_uevm/evm.c | 25 ++++++++----------------- board/ti/panda/panda.c | 21 ++++++--------------- 7 files changed, 65 insertions(+), 37 deletions(-)
Signature · 1 line
1.7.9.5
PATCH 1/3 OMAP: common: consolidate fake USB ethernet MAC address creation
TI platforms such as OMAP5uevm, PandaBoard, use equivalent logic to generate fake USB MAC address from device unique DIE ID.
Consolidate this to a generic location such that other TI platforms such as BeagleBoard-XM can also use the same.
NOTE: at this point in time, I dont yet see a need for a generic dummy ethernet MAC address creation function, but if there is a need in the future, this can be further abstracted out.
---
arch/arm/cpu/armv7/omap-common/utils.c | 21 +++++++++++++++++++++ arch/arm/include/asm/omap_common.h | 2 ++ board/ti/omap5_uevm/evm.c | 25 ++++++++----------------- board/ti/panda/panda.c | 21 ++++++--------------- 4 files changed, 37 insertions(+), 32 deletions(-)
arch/arm/cpu/armv7/omap-common/utils.c +21 -0
@@ -5,6 +5,7 @@* SPDX-License-Identifier: GPL-2.0+ */ #include <common.h> +#include <asm/arch/sys_proto.h> static void do_cancel_out (u32 *num,u32 *den,u32 factor) {while (1 ) {
@@ -39,3 +40,23 @@ void cancel_out(u32 *num, u32 *den, u32 den_limit) *den = (*den +1 ) /2 ; } } + +void __weak usb_fake_mac_from_die_id (u32 *id) +{ +uint8_t device_mac[6 ]; + +if (!getenv ("usbethaddr" )) { +/* +* create a fake MAC address from the processor ID code. +* first byte is 0x02 to signify locally administered. +*/ + device_mac[0 ] =0x02 ; + device_mac[1 ] = id[3 ] &0xff ; + device_mac[2 ] = id[2 ] &0xff ; + device_mac[3 ] = id[1 ] &0xff ; + device_mac[4 ] = id[0 ] &0xff ; + device_mac[5 ] = (id[0 ] >>8 ) &0xff ; + +eth_setenv_enetaddr ("usbethaddr" , device_mac); + } +}
arch/arm/include/asm/omap_common.h +2 -0
@@ -574,6 +574,8 @@ void abb_setup(u32 fuse, u32 ldovbb, u32 setup, u32 control, u32 txdone, u32 txdone_mask, u32 opp);s8 abb_setup_ldovbb (u32 fuse,u32 ldovbb); +void usb_fake_mac_from_die_id (u32 *id); +/* HW Init Context */ #define OMAP_INIT_CONTEXT_SPL 0#define OMAP_INIT_CONTEXT_UBOOT_FROM_NOR 1
board/ti/omap5_uevm/evm.c +8 -17
@@ -119,28 +119,19 @@ static void enable_host_clocks(void)int misc_init_r (void ) {int reg; -uint8_t device_mac[6 ]; +u32 id[4 ];#ifdef CONFIG_PALMAS_POWER palmas_init_settings ();#endif -if (!getenv ("usbethaddr" )) { - reg =DIE_ID_REG_BASE +DIE_ID_REG_OFFSET ; - -/* -* create a fake MAC address from the processor ID code. -* first byte is 0x02 to signify locally administered. -*/ - device_mac[0 ] =0x02 ; - device_mac[1 ] =readl (reg +0x10 ) &0xff ; - device_mac[2 ] =readl (reg +0xC ) &0xff ; - device_mac[3 ] =readl (reg +0x8 ) &0xff ; - device_mac[4 ] =readl (reg) &0xff ; - device_mac[5 ] = (readl (reg) >>8 ) &0xff ; - -eth_setenv_enetaddr ("usbethaddr" , device_mac); - } + reg =DIE_ID_REG_BASE +DIE_ID_REG_OFFSET ; + + id[0 ] =readl (reg); + id[1 ] =readl (reg +0x8 ); + id[2 ] =readl (reg +0xC ); + id[3 ] =readl (reg +0x10 ); +usb_fake_mac_from_die_id (id);return 0 ; }
board/ti/panda/panda.c +6 -15
@@ -193,7 +193,7 @@ int misc_init_r(void) {int phy_type;u32 auxclk, altclksrc; -uint8_t device_mac[6 ]; +u32 id[4 ];/* EHCI is not supported on ES1.0 */ if (omap_revision () ==OMAP4430_ES1_0 )
@@ -247,20 +247,11 @@ int misc_init_r(void)writel (altclksrc, &scrm->altclksrc); -if (!getenv ("usbethaddr" )) { -/* -* create a fake MAC address from the processor ID code. -* first byte is 0x02 to signify locally administered. -*/ - device_mac[0 ] =0x02 ; - device_mac[1 ] =readl (STD_FUSE_DIE_ID_3 ) &0xff ; - device_mac[2 ] =readl (STD_FUSE_DIE_ID_2 ) &0xff ; - device_mac[3 ] =readl (STD_FUSE_DIE_ID_1 ) &0xff ; - device_mac[4 ] =readl (STD_FUSE_DIE_ID_0 ) &0xff ; - device_mac[5 ] = (readl (STD_FUSE_DIE_ID_0 ) >>8 ) &0xff ; - -eth_setenv_enetaddr ("usbethaddr" , device_mac); - } + id[0 ] =readl (STD_FUSE_DIE_ID_0 ); + id[1 ] =readl (STD_FUSE_DIE_ID_1 ); + id[2 ] =readl (STD_FUSE_DIE_ID_2 ); + id[3 ] =readl (STD_FUSE_DIE_ID_3 ); +usb_fake_mac_from_die_id (id);return 0 ; }
Signature · 1 line
1.7.9.5
PATCH 2/3 omap3/sys_info: provide interface to read die id
In reply to Nishanth Menonintroduce get_die_id() function which allows generation of information such as fake MAC address from the processor ID code.
---
arch/arm/cpu/armv7/omap3/sys_info.c | 19 ++++++++++++++----- arch/arm/include/asm/arch-omap3/sys_proto.h | 1 + 2 files changed, 15 insertions(+), 5 deletions(-)
arch/arm/cpu/armv7/omap3/sys_info.c +14 -5
@@ -41,11 +41,23 @@ static char *rev_s_37xx[CPU_37XX_MAX_REV] = {#endif /* CONFIG_DISPLAY_CPUINFO */ /***************************************************************** +* get_dieid(u32 *id) - read die ID +*****************************************************************/ +void get_dieid (u32 *id) +{ +struct ctrl_id *id_base = (struct ctrl_id *)OMAP34XX_ID_L4_IO_BASE ; + + id[3 ] =readl (&id_base->die_id_0); + id[2 ] =readl (&id_base->die_id_1); + id[1 ] =readl (&id_base->die_id_2); + id[0 ] =readl (&id_base->die_id_3); +} + +/***************************************************************** * dieid_num_r(void) - read and set die ID *****************************************************************/ void dieid_num_r (void ) { -struct ctrl_id *id_base = (struct ctrl_id *)OMAP34XX_ID_L4_IO_BASE ;char *uid_s, die_id[34 ];u32 id[4 ];
@@ -54,10 +66,7 @@ void dieid_num_r(void) uid_s =getenv ("dieid#" );if (uid_s ==NULL ) { - id[3 ] =readl (&id_base->die_id_0); - id[2 ] =readl (&id_base->die_id_1); - id[1 ] =readl (&id_base->die_id_2); - id[0 ] =readl (&id_base->die_id_3); +get_dieid (id);sprintf (die_id,"%08x%08x%08x%08x" , id[0 ], id[1 ], id[2 ], id[3 ]);setenv ("dieid#" , die_id); uid_s = die_id;
arch/arm/include/asm/arch-omap3/sys_proto.h +1 -0
@@ -69,6 +69,7 @@ void make_cs1_contiguous(void);void omap_nand_switch_ecc (uint32_t ,uint32_t );void power_init_r (void );void dieid_num_r (void ); +void get_dieid (u32 *id);void do_omap3_emu_romcode_call (u32 service_id,u32 parameters);void omap3_gp_romcode_call (u32 service_id,u32 parameter);u32 warm_reset (void );
Signature · 1 line
1.7.9.5
PATCH 3/3 OMAP3: beagle-xm: generate fake USB ethernet MAC address from dieid
In reply to Nishanth MenonSimilar to OMAP5uEVM, PandaBoard, BeagleBoard-XM has a USB based ethernet without MAC address embedded. So fake a MAC address following the similar strategy used on OMAP5 and PandaBoard family.
---
arch/arm/include/asm/arch-omap3/sys_proto.h | 1 + board/ti/beagle/beagle.c | 11 +++++++++++ 2 files changed, 12 insertions(+)
arch/arm/include/asm/arch-omap3/sys_proto.h +1 -0
@@ -8,6 +8,7 @@ #ifndef _SYS_PROTO_H_ #define _SYS_PROTO_H_ #include <linux/mtd/omap_gpmc.h> +#include <asm/omap_common.h> typedef struct { u32 mtype;
board/ti/beagle/beagle.c +11 -0
@@ -316,6 +316,7 @@ int misc_init_r(void)struct gpio *gpio5_base = (struct gpio *)OMAP34XX_GPIO5_BASE ;struct gpio *gpio6_base = (struct gpio *)OMAP34XX_GPIO6_BASE ;struct control_prog_io *prog_io_base = (struct control_prog_io *)OMAP34XX_CTRL_BASE ; +bool generate_fake_mac = false;/* Enable i2c2 pullup resisters */ writel (~(PRG_I2C2_PULLUPRESX ), &prog_io_base->io1);
@@ -349,6 +350,7 @@ int misc_init_r(void)TWL4030_PM_RECEIVER_VAUX2_VSEL_18 ,TWL4030_PM_RECEIVER_VAUX2_DEV_GRP , TWL4030_PM_RECEIVER_DEV_GRP_P1); + generate_fake_mac = true;break ;case REVISION_XM_C :printf ("Beagle xM Rev C\n" );
@@ -359,6 +361,7 @@ int misc_init_r(void)TWL4030_PM_RECEIVER_VAUX2_VSEL_18 ,TWL4030_PM_RECEIVER_VAUX2_DEV_GRP , TWL4030_PM_RECEIVER_DEV_GRP_P1); + generate_fake_mac = true;break ;default :printf ("Beagle unknown 0x%02x\n" ,get_board_revision ());
@@ -368,6 +371,7 @@ int misc_init_r(void)TWL4030_PM_RECEIVER_VAUX2_VSEL_18 ,TWL4030_PM_RECEIVER_VAUX2_DEV_GRP , TWL4030_PM_RECEIVER_DEV_GRP_P1); + generate_fake_mac = true; }switch (get_expansion_id ()) {
@@ -486,6 +490,13 @@ int misc_init_r(void)musb_register (&musb_plat, &musb_board_data, (void *)MUSB_BASE );#endif +if (generate_fake_mac) { +u32 id[4 ]; + +get_dieid (id); +usb_fake_mac_from_die_id (id); + } +return 0 ; }
Signature · 1 line
1.7.9.5
cover OMAP3: support fake USB Ethernet MAC address for OMAP3 BeagleBoard-XM
In reply to Nishanth MenonQuoted 12 lines · Nishanth Menon
BeagleBoard-XM unfortunately is plagued by lack of proper MAC address in USB resulting in custom uEnv.txt and risk of MAC address conflict in the network.
NOTE:
a) if user wants to manually set/override the mac address, then they can change the environment variable prior to 'usb start'
b) If a new board file would like to create it's own version of this, the weak function can be overriden as well.
c) There does not yet seem a need to create a generic fake ethernet MAC address logic, hence, not done pending such a need.
Quoted 4 lines
Nishanth Menon (3):
OMAP: common: consolidate fake USB ethernet MAC address creation omap3/sys_info: provide interface to read die id
OMAP3: beagle-xm: generate fake USB ethernet MAC address from dieid
Applied to u-boot-ti/master, thanks!
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 836 bytes Desc: Digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20140418/a3ba3d6d/attachment.pgp>