summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--recipes-kernel/linux/linux-3.0/beagle/0007-OMAP2-add-cpu-id-register-to-MAC-address-helper.patch89
-rw-r--r--recipes-kernel/linux/linux-3.0/beagle/0008-HACK-OMAP2-BeagleBoard-Fix-up-random-or-missing-MAC-.patch156
-rw-r--r--recipes-kernel/linux/linux_3.0.bb4
3 files changed, 248 insertions, 1 deletions
diff --git a/recipes-kernel/linux/linux-3.0/beagle/0007-OMAP2-add-cpu-id-register-to-MAC-address-helper.patch b/recipes-kernel/linux/linux-3.0/beagle/0007-OMAP2-add-cpu-id-register-to-MAC-address-helper.patch
new file mode 100644
index 00000000..74e16bbd
--- /dev/null
+++ b/recipes-kernel/linux/linux-3.0/beagle/0007-OMAP2-add-cpu-id-register-to-MAC-address-helper.patch
@@ -0,0 +1,89 @@
1From ab46a513a2600654c6c02805be2b88b5203bae82 Mon Sep 17 00:00:00 2001
2From: Andy Green <andy@warmcat.com>
3Date: Thu, 24 Mar 2011 21:27:29 +0000
4Subject: [PATCH 7/8] OMAP2+: add cpu id register to MAC address helper
5
6Introduce a generic helper function that can set a MAC address using
7data from the OMAP unique CPU ID register.
8
9For comparison purposes this produces a MAC address of
10
11 2e:40:70:f0:12:06
12
13for the ethernet device on my Panda.
14
15Note that this patch requires the fix patch for CPU ID register
16indexes previously posted to linux-omap, otherwise the CPU ID is
17misread on Panda by the existing function to do it. This patch
18is already on linux-omap.
19
20"OMAP2+:Common CPU DIE ID reading code reads wrong registers for OMAP4430"
21http://git.kernel.org/?p=linux/kernel/git/tmlind/linux-omap-2.6.git;a=commit;h=b235e007831dbf57710e59cd4a120e2f374eecb9
22
23Signed-off-by: Andy Green <andy.green@linaro.org>
24---
25 arch/arm/mach-omap2/id.c | 39 +++++++++++++++++++++++++++++++++
26 arch/arm/mach-omap2/include/mach/id.h | 1 +
27 2 files changed, 40 insertions(+), 0 deletions(-)
28
29diff --git a/arch/arm/mach-omap2/id.c b/arch/arm/mach-omap2/id.c
30index b6ed78a..de993f1 100644
31--- a/arch/arm/mach-omap2/id.c
32+++ b/arch/arm/mach-omap2/id.c
33@@ -567,3 +567,42 @@ void __init omap2_set_globals_tap(struct omap_globals *omap2_globals)
34 else
35 tap_prod_id = 0x0208;
36 }
37+
38+/*
39+ * this uses the unique per-cpu info from the cpu fuses set at factory to
40+ * generate a 6-byte MAC address. Two bits in the generated code are used
41+ * to elaborate the generated address into four, so it can be used on multiple
42+ * network interfaces.
43+ */
44+
45+void omap2_die_id_to_ethernet_mac(u8 *mac, int subtype)
46+{
47+ struct omap_die_id odi;
48+ u32 tap = read_tap_reg(OMAP_TAP_IDCODE);
49+
50+ omap_get_die_id(&odi);
51+
52+ mac[0] = odi.id_2;
53+ mac[1] = odi.id_2 >> 8;
54+ mac[2] = odi.id_1;
55+ mac[3] = odi.id_1 >> 8;
56+ mac[4] = odi.id_1 >> 16;
57+ mac[5] = odi.id_1 >> 24;
58+
59+ /* XOR other chip-specific data with ID */
60+
61+ tap ^= odi.id_3;
62+
63+ mac[0] ^= tap;
64+ mac[1] ^= tap >> 8;
65+ mac[2] ^= tap >> 16;
66+ mac[3] ^= tap >> 24;
67+
68+ /* allow four MACs from this same basic data */
69+
70+ mac[1] = (mac[1] & ~0xc0) | ((subtype & 3) << 6);
71+
72+ /* mark it as not multicast and outside official 80211 MAC namespace */
73+
74+ mac[0] = (mac[0] & ~1) | 2;
75+}
76diff --git a/arch/arm/mach-omap2/include/mach/id.h b/arch/arm/mach-omap2/include/mach/id.h
77index 02ed3aa..373313a 100644
78--- a/arch/arm/mach-omap2/include/mach/id.h
79+++ b/arch/arm/mach-omap2/include/mach/id.h
80@@ -18,5 +18,6 @@ struct omap_die_id {
81 };
82
83 void omap_get_die_id(struct omap_die_id *odi);
84+void omap2_die_id_to_ethernet_mac(u8 *mac, int subtype);
85
86 #endif
87--
881.7.4.1
89
diff --git a/recipes-kernel/linux/linux-3.0/beagle/0008-HACK-OMAP2-BeagleBoard-Fix-up-random-or-missing-MAC-.patch b/recipes-kernel/linux/linux-3.0/beagle/0008-HACK-OMAP2-BeagleBoard-Fix-up-random-or-missing-MAC-.patch
new file mode 100644
index 00000000..210c38c1
--- /dev/null
+++ b/recipes-kernel/linux/linux-3.0/beagle/0008-HACK-OMAP2-BeagleBoard-Fix-up-random-or-missing-MAC-.patch
@@ -0,0 +1,156 @@
1From 67f39ef3d73d377b13dbf34bd5170d94f00cc2c2 Mon Sep 17 00:00:00 2001
2From: Jason Kridner <jdk@ti.com>
3Date: Thu, 15 Sep 2011 18:23:02 -0400
4Subject: [PATCH 8/8] HACK: OMAP2+: BeagleBoard: Fix up random or missing MAC addresses for eth0 and wlan0
5
6This was borrowed from the Panda implementation at http://patches.linaro.org/777/
7
8This patch registers a network device notifier callback to set the mac
9addresses for the onboard network assets of the BeagleBoard correctly, despite the
10drivers involved have used a random or all-zeros MAC address.
11
12The technique was suggested by Alan Cox on lkml.
13
14It works by device path so it corrects the MAC addresses even if the
15drivers are in modules loaded in an order that changes their interface
16name from usual (eg, the onboard module might be "wlan1" if there is a
17USB wireless stick plugged in and its module is inserted first.)
18
19Cc: Andy Green <andy@warmcat.com>
20---
21 arch/arm/mach-omap2/board-omap3beagle.c | 90 +++++++++++++++++++++++++++++++
22 1 files changed, 90 insertions(+), 0 deletions(-)
23
24diff --git a/arch/arm/mach-omap2/board-omap3beagle.c b/arch/arm/mach-omap2/board-omap3beagle.c
25index 5e1d9f9..9712099 100644
26--- a/arch/arm/mach-omap2/board-omap3beagle.c
27+++ b/arch/arm/mach-omap2/board-omap3beagle.c
28@@ -33,6 +33,8 @@
29
30 #include <linux/regulator/machine.h>
31 #include <linux/i2c/twl.h>
32+#include <linux/netdevice.h>
33+#include <linux/if_ether.h>
34
35 #include <mach/hardware.h>
36 #include <asm/mach-types.h>
37@@ -42,6 +44,7 @@
38
39 #include <plat/board.h>
40 #include <plat/common.h>
41+#include <mach/id.h>
42 #include <video/omapdss.h>
43 #include <video/omap-panel-generic-dpi.h>
44 #include <plat/gpmc.h>
45@@ -91,6 +94,90 @@ static struct {
46 .usr_button_gpio = 4,
47 };
48
49+/*
50+ * This device path represents the onboard USB <-> Ethernet bridge
51+ * on the BeagleBoard-xM which needs a random or all-zeros
52+ * mac address replaced with a per-cpu stable generated one
53+ */
54+
55+static const char * const xm_fixup_mac_device_paths[] = {
56+ "usb1/1-2/1-2.1/1-2.1:1.0",
57+};
58+
59+static int beagle_device_path_need_mac(struct device *dev)
60+{
61+ const char **try = (const char **) xm_fixup_mac_device_paths;
62+ const char *path;
63+ int count = ARRAY_SIZE(xm_fixup_mac_device_paths);
64+ const char *p;
65+ int len;
66+ struct device *devn;
67+
68+ while (count--) {
69+
70+ p = *try + strlen(*try);
71+ devn = dev;
72+
73+ while (devn) {
74+
75+ path = dev_name(devn);
76+ len = strlen(path);
77+
78+ if ((p - *try) < len) {
79+ devn = NULL;
80+ continue;
81+ }
82+
83+ p -= len;
84+
85+ if (strncmp(path, p, len)) {
86+ devn = NULL;
87+ continue;
88+ }
89+
90+ devn = devn->parent;
91+ if (p == *try)
92+ return count;
93+
94+ if (devn != NULL && (p - *try) < 2)
95+ devn = NULL;
96+
97+ p--;
98+ if (devn != NULL && *p != '/')
99+ devn = NULL;
100+ }
101+
102+ try++;
103+ }
104+
105+ return -ENOENT;
106+}
107+
108+static int omap_beagle_netdev_event(struct notifier_block *this,
109+ unsigned long event, void *ptr)
110+{
111+ struct net_device *dev = ptr;
112+ struct sockaddr sa;
113+ int n;
114+
115+ if (event != NETDEV_REGISTER)
116+ return NOTIFY_DONE;
117+
118+ n = beagle_device_path_need_mac(dev->dev.parent);
119+ if (n >= 0) {
120+ sa.sa_family = dev->type;
121+ omap2_die_id_to_ethernet_mac(sa.sa_data, n);
122+ dev->netdev_ops->ndo_set_mac_address(dev, &sa);
123+ }
124+
125+ return NOTIFY_DONE;
126+}
127+
128+static struct notifier_block omap_beagle_netdev_notifier = {
129+ .notifier_call = omap_beagle_netdev_event,
130+ .priority = 1,
131+};
132+
133 static struct gpio omap3_beagle_rev_gpios[] __initdata = {
134 { 171, GPIOF_IN, "rev_id_0" },
135 { 172, GPIOF_IN, "rev_id_1" },
136@@ -146,14 +233,17 @@ static void __init omap3_beagle_init_rev(void)
137 printk(KERN_INFO "OMAP3 Beagle Rev: xM Ax/Bx\n");
138 omap3_beagle_version = OMAP3BEAGLE_BOARD_XM;
139 beagle_config.usb_pwr_level = GPIOF_OUT_INIT_HIGH;
140+ register_netdevice_notifier(&omap_beagle_netdev_notifier);
141 break;
142 case 2:
143 printk(KERN_INFO "OMAP3 Beagle Rev: xM C\n");
144 omap3_beagle_version = OMAP3BEAGLE_BOARD_XMC;
145+ register_netdevice_notifier(&omap_beagle_netdev_notifier);
146 break;
147 default:
148 printk(KERN_INFO "OMAP3 Beagle Rev: unknown %hd\n", beagle_rev);
149 omap3_beagle_version = OMAP3BEAGLE_BOARD_UNKN;
150+ register_netdevice_notifier(&omap_beagle_netdev_notifier);
151 }
152 }
153
154--
1551.7.4.1
156
diff --git a/recipes-kernel/linux/linux_3.0.bb b/recipes-kernel/linux/linux_3.0.bb
index 40e7ea5e..f42af2f0 100644
--- a/recipes-kernel/linux/linux_3.0.bb
+++ b/recipes-kernel/linux/linux_3.0.bb
@@ -10,7 +10,7 @@ PV = "3.0.4"
10SRCREV_pn-${PN} = "04aa37b5f943920017ad094e776cd5514b1a9246" 10SRCREV_pn-${PN} = "04aa37b5f943920017ad094e776cd5514b1a9246"
11 11
12# The main PR is now using MACHINE_KERNEL_PR, for omap3 see conf/machine/include/omap3.inc 12# The main PR is now using MACHINE_KERNEL_PR, for omap3 see conf/machine/include/omap3.inc
13MACHINE_KERNEL_PR_append = "c" 13MACHINE_KERNEL_PR_append = "d"
14 14
15FILESPATH =. "${FILE_DIRNAME}/linux-3.0:${FILE_DIRNAME}/linux-3.0/${MACHINE}:" 15FILESPATH =. "${FILE_DIRNAME}/linux-3.0:${FILE_DIRNAME}/linux-3.0/${MACHINE}:"
16 16
@@ -190,6 +190,8 @@ SRC_URI += "git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-3.0.y.git
190 file://beagle/0004-OMAP3-beagle-HACK-add-in-1GHz-OPP.patch \ 190 file://beagle/0004-OMAP3-beagle-HACK-add-in-1GHz-OPP.patch \
191 file://beagle/0005-omap3-Add-basic-support-for-720MHz-part.patch \ 191 file://beagle/0005-omap3-Add-basic-support-for-720MHz-part.patch \
192 file://beagle/0006-omap-mmc-Adjust-dto-to-eliminate-timeout-errors.patch \ 192 file://beagle/0006-omap-mmc-Adjust-dto-to-eliminate-timeout-errors.patch \
193 file://beagle/0007-OMAP2-add-cpu-id-register-to-MAC-address-helper.patch \
194 file://beagle/0008-HACK-OMAP2-BeagleBoard-Fix-up-random-or-missing-MAC-.patch \
193 file://madc/0001-Enabling-Hwmon-driver-for-twl4030-madc.patch \ 195 file://madc/0001-Enabling-Hwmon-driver-for-twl4030-madc.patch \
194 file://madc/0002-mfd-twl-core-enable-madc-clock.patch \ 196 file://madc/0002-mfd-twl-core-enable-madc-clock.patch \
195 \ 197 \