* [U-Boot] [PATCH 0/3] OMAP3: support fake USB Ethernet MAC address for OMAP3 BeagleBoard-XM
@ 2014-03-28 16:00 Nishanth Menon
2014-03-28 16:00 ` [U-Boot] [PATCH 1/3] OMAP: common: consolidate fake USB ethernet MAC address creation Nishanth Menon
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: Nishanth Menon @ 2014-03-28 16:00 UTC (permalink / raw)
To: u-boot
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(-)
--
1.7.9.5
^ permalink raw reply [flat|nested] 5+ messages in thread
* [U-Boot] [PATCH 1/3] OMAP: common: consolidate fake USB ethernet MAC address creation
2014-03-28 16:00 [U-Boot] [PATCH 0/3] OMAP3: support fake USB Ethernet MAC address for OMAP3 BeagleBoard-XM Nishanth Menon
@ 2014-03-28 16:00 ` Nishanth Menon
2014-03-28 16:00 ` [U-Boot] [PATCH 2/3] omap3/sys_info: provide interface to read die id Nishanth Menon
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: Nishanth Menon @ 2014-03-28 16:00 UTC (permalink / raw)
To: u-boot
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.
Signed-off-by: Nishanth Menon <nm@ti.com>
---
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(-)
diff --git a/arch/arm/cpu/armv7/omap-common/utils.c b/arch/arm/cpu/armv7/omap-common/utils.c
index aabf2bd..1696c2d 100644
--- a/arch/arm/cpu/armv7/omap-common/utils.c
+++ b/arch/arm/cpu/armv7/omap-common/utils.c
@@ -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);
+ }
+}
diff --git a/arch/arm/include/asm/omap_common.h b/arch/arm/include/asm/omap_common.h
index 04925bc..729723a 100644
--- a/arch/arm/include/asm/omap_common.h
+++ b/arch/arm/include/asm/omap_common.h
@@ -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
diff --git a/board/ti/omap5_uevm/evm.c b/board/ti/omap5_uevm/evm.c
index 3eaa5ac..4666b38 100644
--- a/board/ti/omap5_uevm/evm.c
+++ b/board/ti/omap5_uevm/evm.c
@@ -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;
}
diff --git a/board/ti/panda/panda.c b/board/ti/panda/panda.c
index 5ab6db9..82f30d5 100644
--- a/board/ti/panda/panda.c
+++ b/board/ti/panda/panda.c
@@ -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;
}
--
1.7.9.5
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [U-Boot] [PATCH 2/3] omap3/sys_info: provide interface to read die id
2014-03-28 16:00 [U-Boot] [PATCH 0/3] OMAP3: support fake USB Ethernet MAC address for OMAP3 BeagleBoard-XM Nishanth Menon
2014-03-28 16:00 ` [U-Boot] [PATCH 1/3] OMAP: common: consolidate fake USB ethernet MAC address creation Nishanth Menon
@ 2014-03-28 16:00 ` Nishanth Menon
2014-03-28 16:00 ` [U-Boot] [PATCH 3/3] OMAP3: beagle-xm: generate fake USB ethernet MAC address from dieid Nishanth Menon
2014-04-18 13:21 ` [U-Boot] [PATCH 0/3] OMAP3: support fake USB Ethernet MAC address for OMAP3 BeagleBoard-XM Tom Rini
3 siblings, 0 replies; 5+ messages in thread
From: Nishanth Menon @ 2014-03-28 16:00 UTC (permalink / raw)
To: u-boot
introduce get_die_id() function which allows generation of
information such as fake MAC address from the processor ID code.
Signed-off-by: Nishanth Menon <nm@ti.com>
---
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(-)
diff --git a/arch/arm/cpu/armv7/omap3/sys_info.c b/arch/arm/cpu/armv7/omap3/sys_info.c
index 258786b..bef5f05 100644
--- a/arch/arm/cpu/armv7/omap3/sys_info.c
+++ b/arch/arm/cpu/armv7/omap3/sys_info.c
@@ -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;
diff --git a/arch/arm/include/asm/arch-omap3/sys_proto.h b/arch/arm/include/asm/arch-omap3/sys_proto.h
index 44fa66f..1f62941 100644
--- a/arch/arm/include/asm/arch-omap3/sys_proto.h
+++ b/arch/arm/include/asm/arch-omap3/sys_proto.h
@@ -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);
--
1.7.9.5
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [U-Boot] [PATCH 3/3] OMAP3: beagle-xm: generate fake USB ethernet MAC address from dieid
2014-03-28 16:00 [U-Boot] [PATCH 0/3] OMAP3: support fake USB Ethernet MAC address for OMAP3 BeagleBoard-XM Nishanth Menon
2014-03-28 16:00 ` [U-Boot] [PATCH 1/3] OMAP: common: consolidate fake USB ethernet MAC address creation Nishanth Menon
2014-03-28 16:00 ` [U-Boot] [PATCH 2/3] omap3/sys_info: provide interface to read die id Nishanth Menon
@ 2014-03-28 16:00 ` Nishanth Menon
2014-04-18 13:21 ` [U-Boot] [PATCH 0/3] OMAP3: support fake USB Ethernet MAC address for OMAP3 BeagleBoard-XM Tom Rini
3 siblings, 0 replies; 5+ messages in thread
From: Nishanth Menon @ 2014-03-28 16:00 UTC (permalink / raw)
To: u-boot
Similar 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.
Signed-off-by: Nishanth Menon <nm@ti.com>
---
arch/arm/include/asm/arch-omap3/sys_proto.h | 1 +
board/ti/beagle/beagle.c | 11 +++++++++++
2 files changed, 12 insertions(+)
diff --git a/arch/arm/include/asm/arch-omap3/sys_proto.h b/arch/arm/include/asm/arch-omap3/sys_proto.h
index 1f62941..ce6b22b 100644
--- a/arch/arm/include/asm/arch-omap3/sys_proto.h
+++ b/arch/arm/include/asm/arch-omap3/sys_proto.h
@@ -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;
diff --git a/board/ti/beagle/beagle.c b/board/ti/beagle/beagle.c
index 9669a32..0674afd 100644
--- a/board/ti/beagle/beagle.c
+++ b/board/ti/beagle/beagle.c
@@ -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;
}
--
1.7.9.5
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [U-Boot] [PATCH 0/3] OMAP3: support fake USB Ethernet MAC address for OMAP3 BeagleBoard-XM
2014-03-28 16:00 [U-Boot] [PATCH 0/3] OMAP3: support fake USB Ethernet MAC address for OMAP3 BeagleBoard-XM Nishanth Menon
` (2 preceding siblings ...)
2014-03-28 16:00 ` [U-Boot] [PATCH 3/3] OMAP3: beagle-xm: generate fake USB ethernet MAC address from dieid Nishanth Menon
@ 2014-04-18 13:21 ` Tom Rini
3 siblings, 0 replies; 5+ messages in thread
From: Tom Rini @ 2014-04-18 13:21 UTC (permalink / raw)
To: u-boot
On Fri, Mar 28, 2014 at 11:00:03AM -0500, Nishanth Menon wrote:
>
> 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
Applied to u-boot-ti/master, thanks!
--
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>
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2014-04-18 13:21 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-03-28 16:00 [U-Boot] [PATCH 0/3] OMAP3: support fake USB Ethernet MAC address for OMAP3 BeagleBoard-XM Nishanth Menon
2014-03-28 16:00 ` [U-Boot] [PATCH 1/3] OMAP: common: consolidate fake USB ethernet MAC address creation Nishanth Menon
2014-03-28 16:00 ` [U-Boot] [PATCH 2/3] omap3/sys_info: provide interface to read die id Nishanth Menon
2014-03-28 16:00 ` [U-Boot] [PATCH 3/3] OMAP3: beagle-xm: generate fake USB ethernet MAC address from dieid Nishanth Menon
2014-04-18 13:21 ` [U-Boot] [PATCH 0/3] OMAP3: support fake USB Ethernet MAC address for OMAP3 BeagleBoard-XM Tom Rini
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox