mirror of
https://git.yoctoproject.org/meta-ti
synced 2026-01-12 01:20:20 +00:00
linux-3.0: fix BeagleBoard-xM eth mac using die id
Signed-off-by: Jason Kridner <jdk@ti.com> Cc: Joel A Fernandes <agnel.joel@gmail.com> Cc: Koen Kooi <koen@dominion.thruhere.net>
This commit is contained in:
@@ -0,0 +1,89 @@
|
||||
From ab46a513a2600654c6c02805be2b88b5203bae82 Mon Sep 17 00:00:00 2001
|
||||
From: Andy Green <andy@warmcat.com>
|
||||
Date: Thu, 24 Mar 2011 21:27:29 +0000
|
||||
Subject: [PATCH 7/8] OMAP2+: add cpu id register to MAC address helper
|
||||
|
||||
Introduce a generic helper function that can set a MAC address using
|
||||
data from the OMAP unique CPU ID register.
|
||||
|
||||
For comparison purposes this produces a MAC address of
|
||||
|
||||
2e:40:70:f0:12:06
|
||||
|
||||
for the ethernet device on my Panda.
|
||||
|
||||
Note that this patch requires the fix patch for CPU ID register
|
||||
indexes previously posted to linux-omap, otherwise the CPU ID is
|
||||
misread on Panda by the existing function to do it. This patch
|
||||
is already on linux-omap.
|
||||
|
||||
"OMAP2+:Common CPU DIE ID reading code reads wrong registers for OMAP4430"
|
||||
http://git.kernel.org/?p=linux/kernel/git/tmlind/linux-omap-2.6.git;a=commit;h=b235e007831dbf57710e59cd4a120e2f374eecb9
|
||||
|
||||
Signed-off-by: Andy Green <andy.green@linaro.org>
|
||||
---
|
||||
arch/arm/mach-omap2/id.c | 39 +++++++++++++++++++++++++++++++++
|
||||
arch/arm/mach-omap2/include/mach/id.h | 1 +
|
||||
2 files changed, 40 insertions(+), 0 deletions(-)
|
||||
|
||||
diff --git a/arch/arm/mach-omap2/id.c b/arch/arm/mach-omap2/id.c
|
||||
index b6ed78a..de993f1 100644
|
||||
--- a/arch/arm/mach-omap2/id.c
|
||||
+++ b/arch/arm/mach-omap2/id.c
|
||||
@@ -567,3 +567,42 @@ void __init omap2_set_globals_tap(struct omap_globals *omap2_globals)
|
||||
else
|
||||
tap_prod_id = 0x0208;
|
||||
}
|
||||
+
|
||||
+/*
|
||||
+ * this uses the unique per-cpu info from the cpu fuses set at factory to
|
||||
+ * generate a 6-byte MAC address. Two bits in the generated code are used
|
||||
+ * to elaborate the generated address into four, so it can be used on multiple
|
||||
+ * network interfaces.
|
||||
+ */
|
||||
+
|
||||
+void omap2_die_id_to_ethernet_mac(u8 *mac, int subtype)
|
||||
+{
|
||||
+ struct omap_die_id odi;
|
||||
+ u32 tap = read_tap_reg(OMAP_TAP_IDCODE);
|
||||
+
|
||||
+ omap_get_die_id(&odi);
|
||||
+
|
||||
+ mac[0] = odi.id_2;
|
||||
+ mac[1] = odi.id_2 >> 8;
|
||||
+ mac[2] = odi.id_1;
|
||||
+ mac[3] = odi.id_1 >> 8;
|
||||
+ mac[4] = odi.id_1 >> 16;
|
||||
+ mac[5] = odi.id_1 >> 24;
|
||||
+
|
||||
+ /* XOR other chip-specific data with ID */
|
||||
+
|
||||
+ tap ^= odi.id_3;
|
||||
+
|
||||
+ mac[0] ^= tap;
|
||||
+ mac[1] ^= tap >> 8;
|
||||
+ mac[2] ^= tap >> 16;
|
||||
+ mac[3] ^= tap >> 24;
|
||||
+
|
||||
+ /* allow four MACs from this same basic data */
|
||||
+
|
||||
+ mac[1] = (mac[1] & ~0xc0) | ((subtype & 3) << 6);
|
||||
+
|
||||
+ /* mark it as not multicast and outside official 80211 MAC namespace */
|
||||
+
|
||||
+ mac[0] = (mac[0] & ~1) | 2;
|
||||
+}
|
||||
diff --git a/arch/arm/mach-omap2/include/mach/id.h b/arch/arm/mach-omap2/include/mach/id.h
|
||||
index 02ed3aa..373313a 100644
|
||||
--- a/arch/arm/mach-omap2/include/mach/id.h
|
||||
+++ b/arch/arm/mach-omap2/include/mach/id.h
|
||||
@@ -18,5 +18,6 @@ struct omap_die_id {
|
||||
};
|
||||
|
||||
void omap_get_die_id(struct omap_die_id *odi);
|
||||
+void omap2_die_id_to_ethernet_mac(u8 *mac, int subtype);
|
||||
|
||||
#endif
|
||||
--
|
||||
1.7.4.1
|
||||
|
||||
@@ -0,0 +1,156 @@
|
||||
From 67f39ef3d73d377b13dbf34bd5170d94f00cc2c2 Mon Sep 17 00:00:00 2001
|
||||
From: Jason Kridner <jdk@ti.com>
|
||||
Date: Thu, 15 Sep 2011 18:23:02 -0400
|
||||
Subject: [PATCH 8/8] HACK: OMAP2+: BeagleBoard: Fix up random or missing MAC addresses for eth0 and wlan0
|
||||
|
||||
This was borrowed from the Panda implementation at http://patches.linaro.org/777/
|
||||
|
||||
This patch registers a network device notifier callback to set the mac
|
||||
addresses for the onboard network assets of the BeagleBoard correctly, despite the
|
||||
drivers involved have used a random or all-zeros MAC address.
|
||||
|
||||
The technique was suggested by Alan Cox on lkml.
|
||||
|
||||
It works by device path so it corrects the MAC addresses even if the
|
||||
drivers are in modules loaded in an order that changes their interface
|
||||
name from usual (eg, the onboard module might be "wlan1" if there is a
|
||||
USB wireless stick plugged in and its module is inserted first.)
|
||||
|
||||
Cc: Andy Green <andy@warmcat.com>
|
||||
---
|
||||
arch/arm/mach-omap2/board-omap3beagle.c | 90 +++++++++++++++++++++++++++++++
|
||||
1 files changed, 90 insertions(+), 0 deletions(-)
|
||||
|
||||
diff --git a/arch/arm/mach-omap2/board-omap3beagle.c b/arch/arm/mach-omap2/board-omap3beagle.c
|
||||
index 5e1d9f9..9712099 100644
|
||||
--- a/arch/arm/mach-omap2/board-omap3beagle.c
|
||||
+++ b/arch/arm/mach-omap2/board-omap3beagle.c
|
||||
@@ -33,6 +33,8 @@
|
||||
|
||||
#include <linux/regulator/machine.h>
|
||||
#include <linux/i2c/twl.h>
|
||||
+#include <linux/netdevice.h>
|
||||
+#include <linux/if_ether.h>
|
||||
|
||||
#include <mach/hardware.h>
|
||||
#include <asm/mach-types.h>
|
||||
@@ -42,6 +44,7 @@
|
||||
|
||||
#include <plat/board.h>
|
||||
#include <plat/common.h>
|
||||
+#include <mach/id.h>
|
||||
#include <video/omapdss.h>
|
||||
#include <video/omap-panel-generic-dpi.h>
|
||||
#include <plat/gpmc.h>
|
||||
@@ -91,6 +94,90 @@ static struct {
|
||||
.usr_button_gpio = 4,
|
||||
};
|
||||
|
||||
+/*
|
||||
+ * This device path represents the onboard USB <-> Ethernet bridge
|
||||
+ * on the BeagleBoard-xM which needs a random or all-zeros
|
||||
+ * mac address replaced with a per-cpu stable generated one
|
||||
+ */
|
||||
+
|
||||
+static const char * const xm_fixup_mac_device_paths[] = {
|
||||
+ "usb1/1-2/1-2.1/1-2.1:1.0",
|
||||
+};
|
||||
+
|
||||
+static int beagle_device_path_need_mac(struct device *dev)
|
||||
+{
|
||||
+ const char **try = (const char **) xm_fixup_mac_device_paths;
|
||||
+ const char *path;
|
||||
+ int count = ARRAY_SIZE(xm_fixup_mac_device_paths);
|
||||
+ const char *p;
|
||||
+ int len;
|
||||
+ struct device *devn;
|
||||
+
|
||||
+ while (count--) {
|
||||
+
|
||||
+ p = *try + strlen(*try);
|
||||
+ devn = dev;
|
||||
+
|
||||
+ while (devn) {
|
||||
+
|
||||
+ path = dev_name(devn);
|
||||
+ len = strlen(path);
|
||||
+
|
||||
+ if ((p - *try) < len) {
|
||||
+ devn = NULL;
|
||||
+ continue;
|
||||
+ }
|
||||
+
|
||||
+ p -= len;
|
||||
+
|
||||
+ if (strncmp(path, p, len)) {
|
||||
+ devn = NULL;
|
||||
+ continue;
|
||||
+ }
|
||||
+
|
||||
+ devn = devn->parent;
|
||||
+ if (p == *try)
|
||||
+ return count;
|
||||
+
|
||||
+ if (devn != NULL && (p - *try) < 2)
|
||||
+ devn = NULL;
|
||||
+
|
||||
+ p--;
|
||||
+ if (devn != NULL && *p != '/')
|
||||
+ devn = NULL;
|
||||
+ }
|
||||
+
|
||||
+ try++;
|
||||
+ }
|
||||
+
|
||||
+ return -ENOENT;
|
||||
+}
|
||||
+
|
||||
+static int omap_beagle_netdev_event(struct notifier_block *this,
|
||||
+ unsigned long event, void *ptr)
|
||||
+{
|
||||
+ struct net_device *dev = ptr;
|
||||
+ struct sockaddr sa;
|
||||
+ int n;
|
||||
+
|
||||
+ if (event != NETDEV_REGISTER)
|
||||
+ return NOTIFY_DONE;
|
||||
+
|
||||
+ n = beagle_device_path_need_mac(dev->dev.parent);
|
||||
+ if (n >= 0) {
|
||||
+ sa.sa_family = dev->type;
|
||||
+ omap2_die_id_to_ethernet_mac(sa.sa_data, n);
|
||||
+ dev->netdev_ops->ndo_set_mac_address(dev, &sa);
|
||||
+ }
|
||||
+
|
||||
+ return NOTIFY_DONE;
|
||||
+}
|
||||
+
|
||||
+static struct notifier_block omap_beagle_netdev_notifier = {
|
||||
+ .notifier_call = omap_beagle_netdev_event,
|
||||
+ .priority = 1,
|
||||
+};
|
||||
+
|
||||
static struct gpio omap3_beagle_rev_gpios[] __initdata = {
|
||||
{ 171, GPIOF_IN, "rev_id_0" },
|
||||
{ 172, GPIOF_IN, "rev_id_1" },
|
||||
@@ -146,14 +233,17 @@ static void __init omap3_beagle_init_rev(void)
|
||||
printk(KERN_INFO "OMAP3 Beagle Rev: xM Ax/Bx\n");
|
||||
omap3_beagle_version = OMAP3BEAGLE_BOARD_XM;
|
||||
beagle_config.usb_pwr_level = GPIOF_OUT_INIT_HIGH;
|
||||
+ register_netdevice_notifier(&omap_beagle_netdev_notifier);
|
||||
break;
|
||||
case 2:
|
||||
printk(KERN_INFO "OMAP3 Beagle Rev: xM C\n");
|
||||
omap3_beagle_version = OMAP3BEAGLE_BOARD_XMC;
|
||||
+ register_netdevice_notifier(&omap_beagle_netdev_notifier);
|
||||
break;
|
||||
default:
|
||||
printk(KERN_INFO "OMAP3 Beagle Rev: unknown %hd\n", beagle_rev);
|
||||
omap3_beagle_version = OMAP3BEAGLE_BOARD_UNKN;
|
||||
+ register_netdevice_notifier(&omap_beagle_netdev_notifier);
|
||||
}
|
||||
}
|
||||
|
||||
--
|
||||
1.7.4.1
|
||||
|
||||
@@ -10,7 +10,7 @@ PV = "3.0.4"
|
||||
SRCREV_pn-${PN} = "04aa37b5f943920017ad094e776cd5514b1a9246"
|
||||
|
||||
# The main PR is now using MACHINE_KERNEL_PR, for omap3 see conf/machine/include/omap3.inc
|
||||
MACHINE_KERNEL_PR_append = "c"
|
||||
MACHINE_KERNEL_PR_append = "d"
|
||||
|
||||
FILESPATH =. "${FILE_DIRNAME}/linux-3.0:${FILE_DIRNAME}/linux-3.0/${MACHINE}:"
|
||||
|
||||
@@ -190,6 +190,8 @@ SRC_URI += "git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-3.0.y.git
|
||||
file://beagle/0004-OMAP3-beagle-HACK-add-in-1GHz-OPP.patch \
|
||||
file://beagle/0005-omap3-Add-basic-support-for-720MHz-part.patch \
|
||||
file://beagle/0006-omap-mmc-Adjust-dto-to-eliminate-timeout-errors.patch \
|
||||
file://beagle/0007-OMAP2-add-cpu-id-register-to-MAC-address-helper.patch \
|
||||
file://beagle/0008-HACK-OMAP2-BeagleBoard-Fix-up-random-or-missing-MAC-.patch \
|
||||
file://madc/0001-Enabling-Hwmon-driver-for-twl4030-madc.patch \
|
||||
file://madc/0002-mfd-twl-core-enable-madc-clock.patch \
|
||||
\
|
||||
|
||||
Reference in New Issue
Block a user