Updated rtc patches from my git repo ready for upstream
[nslu2-linux/kernel.git] / patches / 2.6.25 / ixp4xx-nslu2-nas100d-ethernet-support.patch
blob426581ca39bce98e57a797fc5db77a22d28796fb
1 From 31f59b98f850870515f73d05517b2fa00d9e46fd Mon Sep 17 00:00:00 2001
2 From: Rod Whitby <rod@whitby.id.au>
3 Date: Sun, 27 Jan 2008 09:06:51 +1030
4 Subject: [PATCH] ixp4xx: Ethernet support for the nslu2 and nas100d boards
6 Enables the new ixp4xx qmgr and npe drivers in ixp4xx_defconfig.
8 Sets up the corresponding platform data for the nslu2 and nas100d
9 boards, and reads the ethernet MAC address from the internal flash.
11 Tested on both little-endian and bit-endian platforms.
13 Signed-off-by: Rod Whitby <rod@whitby.id.au>
14 Signed-off-by: Michael Westerhof <mwester@dls.net>
15 Tested-by: Tom King <tom@websb.net>
16 ---
17 arch/arm/configs/ixp4xx_defconfig | 8 ++++-
18 arch/arm/mach-ixp4xx/nas100d-setup.c | 49 +++++++++++++++++++++++++++++++++
19 arch/arm/mach-ixp4xx/nslu2-setup.c | 50 ++++++++++++++++++++++++++++++++++
20 3 files changed, 105 insertions(+), 2 deletions(-)
22 diff --git a/arch/arm/configs/ixp4xx_defconfig b/arch/arm/configs/ixp4xx_defconfig
23 index 2d5ae33..45192ef 100644
24 --- a/arch/arm/configs/ixp4xx_defconfig
25 +++ b/arch/arm/configs/ixp4xx_defconfig
26 @@ -1,7 +1,7 @@
28 # Automatically generated make config: don't edit
29 -# Linux kernel version: 2.6.24-rc8
30 -# Wed Jan 23 17:26:16 2008
31 +# Linux kernel version: 2.6.24
32 +# Sun Jan 27 07:33:38 2008
34 CONFIG_ARM=y
35 CONFIG_SYS_SUPPORTS_APM_EMULATION=y
36 @@ -174,6 +174,8 @@ CONFIG_MACH_GTWX5715=y
38 CONFIG_DMABOUNCE=y
39 # CONFIG_IXP4XX_INDIRECT_PCI is not set
40 +CONFIG_IXP4XX_QMGR=y
41 +CONFIG_IXP4XX_NPE=y
44 # Boot options
45 @@ -832,6 +834,7 @@ CONFIG_DUMMY=y
46 # CONFIG_PHYLIB is not set
47 CONFIG_NET_ETHERNET=y
48 CONFIG_MII=y
49 +CONFIG_IXP4XX_ETH=y
50 # CONFIG_AX88796 is not set
51 # CONFIG_HAPPYMEAL is not set
52 # CONFIG_SUNGEM is not set
53 @@ -925,6 +928,7 @@ CONFIG_HDLC_X25=m
54 # CONFIG_PC300TOO is not set
55 # CONFIG_FARSYNC is not set
56 # CONFIG_DSCC4 is not set
57 +# CONFIG_IXP4XX_HSS is not set
58 CONFIG_DLCI=m
59 CONFIG_DLCI_MAX=8
60 CONFIG_WAN_ROUTER_DRIVERS=m
61 diff --git a/arch/arm/mach-ixp4xx/nas100d-setup.c b/arch/arm/mach-ixp4xx/nas100d-setup.c
62 index ea334f3..36421b3 100644
63 --- a/arch/arm/mach-ixp4xx/nas100d-setup.c
64 +++ b/arch/arm/mach-ixp4xx/nas100d-setup.c
65 @@ -20,6 +20,7 @@
66 #include <asm/mach-types.h>
67 #include <asm/mach/arch.h>
68 #include <asm/mach/flash.h>
69 +#include <asm/io.h>
71 static struct flash_platform_data nas100d_flash_data = {
72 .map_name = "cfi_probe",
73 @@ -123,12 +124,30 @@ static struct platform_device nas100d_uart = {
74 .resource = nas100d_uart_resources,
77 +/* Built-in 10/100 Ethernet MAC interfaces */
78 +static struct eth_plat_info nas100d_plat_eth[] = {
79 + {
80 + .phy = 0,
81 + .rxq = 3,
82 + .txreadyq = 20,
83 + }
84 +};
86 +static struct platform_device nas100d_eth[] = {
87 + {
88 + .name = "ixp4xx_eth",
89 + .id = IXP4XX_ETH_NPEB,
90 + .dev.platform_data = nas100d_plat_eth,
91 + }
92 +};
94 static struct platform_device *nas100d_devices[] __initdata = {
95 &nas100d_i2c_controller,
96 &nas100d_flash,
97 #ifdef CONFIG_LEDS_IXP4XX
98 &nas100d_leds,
99 #endif
100 + &nas100d_eth[0],
103 static void nas100d_power_off(void)
104 @@ -144,6 +163,9 @@ static void nas100d_power_off(void)
106 static void __init nas100d_init(void)
108 + uint8_t __iomem *f;
109 + int i;
111 ixp4xx_sys_init();
113 /* gpio 14 and 15 are _not_ clocks */
114 @@ -163,6 +185,33 @@ static void __init nas100d_init(void)
115 (void)platform_device_register(&nas100d_uart);
117 platform_add_devices(nas100d_devices, ARRAY_SIZE(nas100d_devices));
119 + /*
120 + * Map in a portion of the flash and read the MAC address.
121 + * Since it is stored in BE in the flash itself, we need to
122 + * byteswap it if we're in LE mode.
123 + */
124 + f = ioremap(IXP4XX_EXP_BUS_BASE(0), 0x1000000);
125 + if (f) {
126 +#ifdef __ARMEB__
127 + for (i = 0; i < 6; i++)
128 + nas100d_plat_eth[0].hwaddr[i] = readb(f + 0xFC0FD8 + i);
129 +#else
130 + nas100d_plat_eth[0].hwaddr[0] = readb(f + 0xFC0FD8 + 3);
131 + nas100d_plat_eth[0].hwaddr[1] = readb(f + 0xFC0FD8 + 2);
132 + nas100d_plat_eth[0].hwaddr[2] = readb(f + 0xFC0FD8 + 1);
133 + nas100d_plat_eth[0].hwaddr[3] = readb(f + 0xFC0FD8 + 0);
134 + nas100d_plat_eth[0].hwaddr[4] = readb(f + 0xFC0FD8 + 7);
135 + nas100d_plat_eth[0].hwaddr[5] = readb(f + 0xFC0FD8 + 6);
136 +#endif
137 + iounmap(f);
139 + printk(KERN_INFO "NAS100D: Using MAC address "
140 + "%.2x:%.2x:%.2x:%.2x:%.2x:%.2x for port 0\n",
141 + nas100d_plat_eth[0].hwaddr[0], nas100d_plat_eth[0].hwaddr[1],
142 + nas100d_plat_eth[0].hwaddr[2], nas100d_plat_eth[0].hwaddr[3],
143 + nas100d_plat_eth[0].hwaddr[4], nas100d_plat_eth[0].hwaddr[5]);
147 MACHINE_START(NAS100D, "Iomega NAS 100d")
148 diff --git a/arch/arm/mach-ixp4xx/nslu2-setup.c b/arch/arm/mach-ixp4xx/nslu2-setup.c
149 index 9bf8ccb..b10e094 100644
150 --- a/arch/arm/mach-ixp4xx/nslu2-setup.c
151 +++ b/arch/arm/mach-ixp4xx/nslu2-setup.c
152 @@ -23,6 +23,7 @@
153 #include <asm/mach/arch.h>
154 #include <asm/mach/flash.h>
155 #include <asm/mach/time.h>
156 +#include <asm/io.h>
158 static struct flash_platform_data nslu2_flash_data = {
159 .map_name = "cfi_probe",
160 @@ -138,6 +139,23 @@ static struct platform_device nslu2_uart = {
161 .resource = nslu2_uart_resources,
164 +/* Built-in 10/100 Ethernet MAC interfaces */
165 +static struct eth_plat_info nslu2_plat_eth[] = {
167 + .phy = 1,
168 + .rxq = 3,
169 + .txreadyq = 20,
173 +static struct platform_device nslu2_eth[] = {
175 + .name = "ixp4xx_eth",
176 + .id = IXP4XX_ETH_NPEB,
177 + .dev.platform_data = nslu2_plat_eth,
181 static struct platform_device *nslu2_devices[] __initdata = {
182 &nslu2_i2c_controller,
183 &nslu2_flash,
184 @@ -145,6 +163,7 @@ static struct platform_device *nslu2_devices[] __initdata = {
185 #ifdef CONFIG_LEDS_IXP4XX
186 &nslu2_leds,
187 #endif
188 + &nslu2_eth[0],
191 static void nslu2_power_off(void)
192 @@ -173,6 +192,9 @@ static struct sys_timer nslu2_timer = {
194 static void __init nslu2_init(void)
196 + uint8_t __iomem *f;
197 + int i;
199 ixp4xx_sys_init();
201 nslu2_flash_resource.start = IXP4XX_EXP_BUS_BASE(0);
202 @@ -189,6 +211,34 @@ static void __init nslu2_init(void)
203 (void)platform_device_register(&nslu2_uart);
205 platform_add_devices(nslu2_devices, ARRAY_SIZE(nslu2_devices));
208 + /*
209 + * Map in a portion of the flash and read the MAC address.
210 + * Since it is stored in BE in the flash itself, we need to
211 + * byteswap it if we're in LE mode.
212 + */
213 + f = ioremap(IXP4XX_EXP_BUS_BASE(0), 0x40000);
214 + if (f) {
215 +#ifdef __ARMEB__
216 + for (i = 0; i < 6; i++)
217 + nslu2_plat_eth[0].hwaddr[i] = readb(f + 0x3FFB0 + i);
218 +#else
219 + nslu2_plat_eth[0].hwaddr[0] = readb(f + 0x3FFB0 + 3);
220 + nslu2_plat_eth[0].hwaddr[1] = readb(f + 0x3FFB0 + 2);
221 + nslu2_plat_eth[0].hwaddr[2] = readb(f + 0x3FFB0 + 1);
222 + nslu2_plat_eth[0].hwaddr[3] = readb(f + 0x3FFB0 + 0);
223 + nslu2_plat_eth[0].hwaddr[4] = readb(f + 0x3FFB0 + 7);
224 + nslu2_plat_eth[0].hwaddr[5] = readb(f + 0x3FFB0 + 6);
225 +#endif
226 + iounmap(f);
228 + printk(KERN_INFO "NSLU2: Using MAC address "
229 + "%.2x:%.2x:%.2x:%.2x:%.2x:%.2x for port 0\n",
230 + nslu2_plat_eth[0].hwaddr[0], nslu2_plat_eth[0].hwaddr[1],
231 + nslu2_plat_eth[0].hwaddr[2], nslu2_plat_eth[0].hwaddr[3],
232 + nslu2_plat_eth[0].hwaddr[4], nslu2_plat_eth[0].hwaddr[5]);
236 MACHINE_START(NSLU2, "Linksys NSLU2")
238 1.5.2.5