diff options
Diffstat (limited to 'recipes-kernel/linux/linux-3.0/beagle/0008-OMAP2-add-cpu-id-register-to-MAC-address-helper.patch')
-rw-r--r-- | recipes-kernel/linux/linux-3.0/beagle/0008-OMAP2-add-cpu-id-register-to-MAC-address-helper.patch | 89 |
1 files changed, 89 insertions, 0 deletions
diff --git a/recipes-kernel/linux/linux-3.0/beagle/0008-OMAP2-add-cpu-id-register-to-MAC-address-helper.patch b/recipes-kernel/linux/linux-3.0/beagle/0008-OMAP2-add-cpu-id-register-to-MAC-address-helper.patch new file mode 100644 index 00000000..121f2742 --- /dev/null +++ b/recipes-kernel/linux/linux-3.0/beagle/0008-OMAP2-add-cpu-id-register-to-MAC-address-helper.patch | |||
@@ -0,0 +1,89 @@ | |||
1 | From 93b4f0bb46f9b9075bf830f2597816c3adeb01b7 Mon Sep 17 00:00:00 2001 | ||
2 | From: Andy Green <andy@warmcat.com> | ||
3 | Date: Thu, 24 Mar 2011 21:27:29 +0000 | ||
4 | Subject: [PATCH 08/10] OMAP2+: add cpu id register to MAC address helper | ||
5 | |||
6 | Introduce a generic helper function that can set a MAC address using | ||
7 | data from the OMAP unique CPU ID register. | ||
8 | |||
9 | For comparison purposes this produces a MAC address of | ||
10 | |||
11 | 2e:40:70:f0:12:06 | ||
12 | |||
13 | for the ethernet device on my Panda. | ||
14 | |||
15 | Note that this patch requires the fix patch for CPU ID register | ||
16 | indexes previously posted to linux-omap, otherwise the CPU ID is | ||
17 | misread on Panda by the existing function to do it. This patch | ||
18 | is already on linux-omap. | ||
19 | |||
20 | "OMAP2+:Common CPU DIE ID reading code reads wrong registers for OMAP4430" | ||
21 | http://git.kernel.org/?p=linux/kernel/git/tmlind/linux-omap-2.6.git;a=commit;h=b235e007831dbf57710e59cd4a120e2f374eecb9 | ||
22 | |||
23 | Signed-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 | |||
29 | diff --git a/arch/arm/mach-omap2/id.c b/arch/arm/mach-omap2/id.c | ||
30 | index 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 | +} | ||
76 | diff --git a/arch/arm/mach-omap2/include/mach/id.h b/arch/arm/mach-omap2/include/mach/id.h | ||
77 | index 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 | -- | ||
88 | 1.6.6.1 | ||
89 | |||