rename patch
[openwrt.git] / target / linux / ixp4xx / patches-2.6.24 / 031-nslu2_nas100d_ethernet_support.patch
1 From af66bd3b3324d51f0c43b7672b7a0563db425377 Mon Sep 17 00:00:00 2001
2 From: Rod Whitby <rod@whitby.id.au>
3 Date: Tue, 29 Jan 2008 10:03:19 +1030
4 Subject: ixp4xx: Ethernet support for the nslu2 and nas100d boards
5
6 Enables the new ixp4xx qmgr and npe drivers in ixp4xx_defconfig.
7
8 Sets up the corresponding platform data for the nslu2 and nas100d
9 boards, and reads the ethernet MAC address from the internal flash.
10
11 Tested on both little-endian and big-endian kernels.
12
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 PATCH FOLLOWS
18 KernelVersion: v2.6.24-1916-g3832564
19
20 Index: linux-2.6.24.7/arch/arm/configs/ixp4xx_defconfig
21 ===================================================================
22 --- linux-2.6.24.7.orig/arch/arm/configs/ixp4xx_defconfig
23 +++ linux-2.6.24.7/arch/arm/configs/ixp4xx_defconfig
24 @@ -1,7 +1,7 @@
25  #
26  # Automatically generated make config: don't edit
27 -# Linux kernel version: 2.6.24-rc8
28 -# Wed Jan 23 17:26:16 2008
29 +# Linux kernel version: 2.6.24
30 +# Sun Jan 27 07:33:38 2008
31  #
32  CONFIG_ARM=y
33  CONFIG_SYS_SUPPORTS_APM_EMULATION=y
34 @@ -174,6 +174,8 @@ CONFIG_MACH_GTWX5715=y
35  #
36  CONFIG_DMABOUNCE=y
37  # CONFIG_IXP4XX_INDIRECT_PCI is not set
38 +CONFIG_IXP4XX_QMGR=y
39 +CONFIG_IXP4XX_NPE=y
40  
41  #
42  # Boot options
43 @@ -832,6 +834,7 @@ CONFIG_DUMMY=y
44  # CONFIG_PHYLIB is not set
45  CONFIG_NET_ETHERNET=y
46  CONFIG_MII=y
47 +CONFIG_IXP4XX_ETH=y
48  # CONFIG_AX88796 is not set
49  # CONFIG_HAPPYMEAL is not set
50  # CONFIG_SUNGEM is not set
51 @@ -925,6 +928,7 @@ CONFIG_HDLC_X25=m
52  # CONFIG_PC300TOO is not set
53  # CONFIG_FARSYNC is not set
54  # CONFIG_DSCC4 is not set
55 +# CONFIG_IXP4XX_HSS is not set
56  CONFIG_DLCI=m
57  CONFIG_DLCI_MAX=8
58  CONFIG_WAN_ROUTER_DRIVERS=m
59 Index: linux-2.6.24.7/arch/arm/mach-ixp4xx/nas100d-setup.c
60 ===================================================================
61 --- linux-2.6.24.7.orig/arch/arm/mach-ixp4xx/nas100d-setup.c
62 +++ linux-2.6.24.7/arch/arm/mach-ixp4xx/nas100d-setup.c
63 @@ -12,6 +12,7 @@
64   *
65   */
66  
67 +#include <linux/if_ether.h>
68  #include <linux/kernel.h>
69  #include <linux/serial.h>
70  #include <linux/serial_8250.h>
71 @@ -22,6 +23,7 @@
72  #include <asm/mach-types.h>
73  #include <asm/mach/arch.h>
74  #include <asm/mach/flash.h>
75 +#include <asm/io.h>
76  
77  static struct flash_platform_data nas100d_flash_data = {
78         .map_name               = "cfi_probe",
79 @@ -131,10 +133,28 @@ static struct platform_device nas100d_ua
80         .resource               = nas100d_uart_resources,
81  };
82  
83 +/* Built-in 10/100 Ethernet MAC interfaces */
84 +static struct eth_plat_info nas100d_plat_eth[] = {
85 +       {
86 +               .phy            = 0,
87 +               .rxq            = 3,
88 +               .txreadyq       = 20,
89 +       }
90 +};
91 +
92 +static struct platform_device nas100d_eth[] = {
93 +       {
94 +               .name                   = "ixp4xx_eth",
95 +               .id                     = IXP4XX_ETH_NPEB,
96 +               .dev.platform_data      = nas100d_plat_eth,
97 +       }
98 +};
99 +
100  static struct platform_device *nas100d_devices[] __initdata = {
101         &nas100d_i2c_gpio,
102         &nas100d_flash,
103         &nas100d_leds,
104 +       &nas100d_eth[0],
105  };
106  
107  static void nas100d_power_off(void)
108 @@ -150,6 +170,10 @@ static void nas100d_power_off(void)
109  
110  static void __init nas100d_init(void)
111  {
112 +       DECLARE_MAC_BUF(mac_buf);
113 +       uint8_t __iomem *f;
114 +       int i;
115 +
116         ixp4xx_sys_init();
117  
118         /* gpio 14 and 15 are _not_ clocks */
119 @@ -172,6 +196,25 @@ static void __init nas100d_init(void)
120         (void)platform_device_register(&nas100d_uart);
121  
122         platform_add_devices(nas100d_devices, ARRAY_SIZE(nas100d_devices));
123 +
124 +       /*
125 +        * Map in a portion of the flash and read the MAC address.
126 +        * Since it is stored in BE in the flash itself, we need to
127 +        * byteswap it if we're in LE mode.
128 +        */
129 +       f = ioremap(IXP4XX_EXP_BUS_BASE(0), 0x1000000);
130 +       if (f) {
131 +               for (i = 0; i < 6; i++)
132 +#ifdef __ARMEB__
133 +                       nas100d_plat_eth[0].hwaddr[i] = readb(f + 0xFC0FD8 + i);
134 +#else
135 +                       nas100d_plat_eth[0].hwaddr[i] = readb(f + 0xFC0FD8 + (i^3));
136 +#endif
137 +               iounmap(f);
138 +       }
139 +       printk(KERN_INFO "NAS100D: Using MAC address %s for port 0\n",
140 +              print_mac(mac_buf, nas100d_plat_eth[0].hwaddr));
141 +
142  }
143  
144  MACHINE_START(NAS100D, "Iomega NAS 100d")
145 Index: linux-2.6.24.7/arch/arm/mach-ixp4xx/nslu2-setup.c
146 ===================================================================
147 --- linux-2.6.24.7.orig/arch/arm/mach-ixp4xx/nslu2-setup.c
148 +++ linux-2.6.24.7/arch/arm/mach-ixp4xx/nslu2-setup.c
149 @@ -14,6 +14,7 @@
150   * Changed to conform to new style __init ixdp425 kas11 10/22/04
151   */
152  
153 +#include <linux/if_ether.h>
154  #include <linux/kernel.h>
155  #include <linux/serial.h>
156  #include <linux/serial_8250.h>
157 @@ -25,6 +26,7 @@
158  #include <asm/mach/arch.h>
159  #include <asm/mach/flash.h>
160  #include <asm/mach/time.h>
161 +#include <asm/io.h>
162  
163  static struct flash_platform_data nslu2_flash_data = {
164         .map_name               = "cfi_probe",
165 @@ -143,11 +145,29 @@ static struct platform_device nslu2_uart
166         .resource               = nslu2_uart_resources,
167  };
168  
169 +/* Built-in 10/100 Ethernet MAC interfaces */
170 +static struct eth_plat_info nslu2_plat_eth[] = {
171 +       {
172 +               .phy            = 1,
173 +               .rxq            = 3,
174 +               .txreadyq       = 20,
175 +       }
176 +};
177 +
178 +static struct platform_device nslu2_eth[] = {
179 +       {
180 +               .name                   = "ixp4xx_eth",
181 +               .id                     = IXP4XX_ETH_NPEB,
182 +               .dev.platform_data      = nslu2_plat_eth,
183 +       }
184 +};
185 +
186  static struct platform_device *nslu2_devices[] __initdata = {
187         &nslu2_i2c_gpio,
188         &nslu2_flash,
189         &nslu2_beeper,
190         &nslu2_leds,
191 +       &nslu2_eth[0],
192  };
193  
194  static void nslu2_power_off(void)
195 @@ -176,6 +196,10 @@ static struct sys_timer nslu2_timer = {
196  
197  static void __init nslu2_init(void)
198  {
199 +       DECLARE_MAC_BUF(mac_buf);
200 +       uint8_t __iomem *f;
201 +       int i;
202 +
203         ixp4xx_sys_init();
204  
205         nslu2_flash_resource.start = IXP4XX_EXP_BUS_BASE(0);
206 @@ -195,6 +219,26 @@ static void __init nslu2_init(void)
207         (void)platform_device_register(&nslu2_uart);
208  
209         platform_add_devices(nslu2_devices, ARRAY_SIZE(nslu2_devices));
210 +
211 +
212 +       /*
213 +        * Map in a portion of the flash and read the MAC address.
214 +        * Since it is stored in BE in the flash itself, we need to
215 +        * byteswap it if we're in LE mode.
216 +        */
217 +       f = ioremap(IXP4XX_EXP_BUS_BASE(0), 0x40000);
218 +       if (f) {
219 +               for (i = 0; i < 6; i++)
220 +#ifdef __ARMEB__
221 +                       nslu2_plat_eth[0].hwaddr[i] = readb(f + 0x3FFB0 + i);
222 +#else
223 +                       nslu2_plat_eth[0].hwaddr[i] = readb(f + 0x3FFB0 + (i^3));
224 +#endif
225 +               iounmap(f);
226 +       }
227 +       printk(KERN_INFO "NSLU2: Using MAC address %s for port 0\n",
228 +              print_mac(mac_buf, nslu2_plat_eth[0].hwaddr));
229 +
230  }
231  
232  MACHINE_START(NSLU2, "Linksys NSLU2")