Fixes the MAC address handling on avila NPE on startup
[openwrt.git] / target / linux / ixp4xx / patches-2.6.23 / 013-fsg3_support.patch
1 diff -uprN linux-2.6.23.orig/arch/arm/mach-ixp4xx/fsg-pci.c linux-2.6.23/arch/arm/mach-ixp4xx/fsg-pci.c
2 --- linux-2.6.23.orig/arch/arm/mach-ixp4xx/fsg-pci.c    1969-12-31 18:00:00.000000000 -0600
3 +++ linux-2.6.23/arch/arm/mach-ixp4xx/fsg-pci.c 2007-10-11 00:55:34.000000000 -0500
4 @@ -0,0 +1,71 @@
5 +/*
6 + * arch/arch/mach-ixp4xx/fsg-pci.c
7 + *
8 + * FSG board-level PCI initialization
9 + *
10 + * Author: Rod Whitby <rod@whitby.id.au>
11 + * Maintainer: http://www.nslu2-linux.org/
12 + *
13 + * based on ixdp425-pci.c:
14 + *     Copyright (C) 2002 Intel Corporation.
15 + *     Copyright (C) 2003-2004 MontaVista Software, Inc.
16 + *
17 + * This program is free software; you can redistribute it and/or modify
18 + * it under the terms of the GNU General Public License version 2 as
19 + * published by the Free Software Foundation.
20 + *
21 + */
22 +
23 +#include <linux/pci.h>
24 +#include <linux/init.h>
25 +#include <linux/irq.h>
26 +
27 +#include <asm/mach/pci.h>
28 +#include <asm/mach-types.h>
29 +
30 +void __init fsg_pci_preinit(void)
31 +{
32 +       set_irq_type(IRQ_FSG_PCI_INTA, IRQT_LOW);
33 +       set_irq_type(IRQ_FSG_PCI_INTB, IRQT_LOW);
34 +       set_irq_type(IRQ_FSG_PCI_INTC, IRQT_LOW);
35 +
36 +       ixp4xx_pci_preinit();
37 +}
38 +
39 +static int __init fsg_map_irq(struct pci_dev *dev, u8 slot, u8 pin)
40 +{
41 +       static int pci_irq_table[FSG_PCI_IRQ_LINES] = {
42 +               IRQ_FSG_PCI_INTC,
43 +               IRQ_FSG_PCI_INTB,
44 +               IRQ_FSG_PCI_INTA,
45 +       };
46 +
47 +       int irq = -1;
48 +       slot = slot - 11;
49 +
50 +       if (slot >= 1 && slot <= FSG_PCI_MAX_DEV &&
51 +               pin >= 1 && pin <= FSG_PCI_IRQ_LINES) {
52 +                       irq = pci_irq_table[(slot - 1)];
53 +       }
54 +        printk("%s: Mapped slot %d pin %d to IRQ %d\n", __FUNCTION__,slot, pin, irq);
55 +
56 +        return irq;
57 +}
58 +
59 +struct hw_pci fsg_pci __initdata = {
60 +       .nr_controllers = 1,
61 +       .preinit =        fsg_pci_preinit,
62 +       .swizzle =        pci_std_swizzle,
63 +       .setup =          ixp4xx_setup,
64 +       .scan =           ixp4xx_scan_bus,
65 +       .map_irq =        fsg_map_irq,
66 +};
67 +
68 +int __init fsg_pci_init(void)
69 +{
70 +       if (machine_is_fsg())
71 +               pci_common_init(&fsg_pci);
72 +       return 0;
73 +}
74 +
75 +subsys_initcall(fsg_pci_init);
76 diff -uprN linux-2.6.23.orig/arch/arm/mach-ixp4xx/fsg-setup.c linux-2.6.23/arch/arm/mach-ixp4xx/fsg-setup.c
77 --- linux-2.6.23.orig/arch/arm/mach-ixp4xx/fsg-setup.c  1969-12-31 18:00:00.000000000 -0600
78 +++ linux-2.6.23/arch/arm/mach-ixp4xx/fsg-setup.c       2007-10-11 00:55:34.000000000 -0500
79 @@ -0,0 +1,186 @@
80 +/*
81 + * arch/arm/mach-ixp4xx/fsg-setup.c
82 + *
83 + * FSG board-setup
84 + *
85 + * based ixdp425-setup.c:
86 + *      Copyright (C) 2003-2004 MontaVista Software, Inc.
87 + *
88 + * Author: Rod Whitby <rod@whitby.id.au>
89 + * Maintainers: http://www.nslu2-linux.org/
90 + *
91 + */
92 +
93 +#include <linux/kernel.h>
94 +#include <linux/serial.h>
95 +#include <linux/serial_8250.h>
96 +#include <linux/leds.h>
97 +#include <linux/i2c-gpio.h>
98 +
99 +#include <asm/mach-types.h>
100 +#include <asm/mach/arch.h>
101 +#include <asm/mach/flash.h>
102 +
103 +static struct flash_platform_data fsg_flash_data = {
104 +       .map_name               = "cfi_probe",
105 +       .width                  = 2,
106 +};
107 +
108 +static struct resource fsg_flash_resource = {
109 +       .flags                  = IORESOURCE_MEM,
110 +};
111 +
112 +static struct platform_device fsg_flash = {
113 +       .name                   = "IXP4XX-Flash",
114 +       .id                     = 0,
115 +       .dev.platform_data      = &fsg_flash_data,
116 +       .num_resources          = 1,
117 +       .resource               = &fsg_flash_resource,
118 +};
119 +
120 +static struct i2c_gpio_platform_data fsg_i2c_gpio_data = {
121 +       .sda_pin                = FSG_SDA_PIN,
122 +       .scl_pin                = FSG_SCL_PIN,
123 +};
124 +
125 +static struct platform_device fsg_i2c_gpio = {
126 +       .name                   = "i2c-gpio",
127 +       .id                     = 0,
128 +       .dev     = {
129 +               .platform_data  = &fsg_i2c_gpio_data,
130 +       },
131 +};
132 +
133 +#ifdef CONFIG_LEDS_CLASS
134 +static struct resource fsg_led_resources[] = {
135 +       {
136 +               .name           = "ring",
137 +               .start          = FSG_LED_RING_GPIO,
138 +               .end            = FSG_LED_RING_GPIO,
139 +               .flags          = IXP4XX_GPIO_HIGH,
140 +       },
141 +       {
142 +               .name           = "sync",
143 +               .start          = FSG_LED_SYNC_GPIO,
144 +               .end            = FSG_LED_SYNC_GPIO,
145 +               .flags          = IXP4XX_GPIO_HIGH,
146 +       },
147 +       {
148 +               .name           = "usb",
149 +               .start          = FSG_LED_USB_GPIO,
150 +               .end            = FSG_LED_USB_GPIO,
151 +               .flags          = IXP4XX_GPIO_HIGH,
152 +       },
153 +       {
154 +               .name           = "sata",
155 +               .start          = FSG_LED_SATA_GPIO,
156 +               .end            = FSG_LED_SATA_GPIO,
157 +               .flags          = IXP4XX_GPIO_HIGH,
158 +       },
159 +       {
160 +               .name           = "wan",
161 +               .start          = FSG_LED_WAN_GPIO,
162 +               .end            = FSG_LED_WAN_GPIO,
163 +               .flags          = IXP4XX_GPIO_HIGH,
164 +       },
165 +       {
166 +               .name           = "wlan",
167 +               .start          = FSG_LED_WLAN_GPIO,
168 +               .end            = FSG_LED_WLAN_GPIO,
169 +               .flags          = IXP4XX_GPIO_HIGH,
170 +       },
171 +};
172 +
173 +static struct platform_device fsg_leds = {
174 +        .name                   = "IXP4XX-GPIO-LED",
175 +        .id                     = -1,
176 +        .num_resources          = ARRAY_SIZE(fsg_led_resources),
177 +        .resource               = fsg_led_resources,
178 +};
179 +#endif
180 +
181 +static struct resource fsg_uart_resources[] = {
182 +       {
183 +               .start          = IXP4XX_UART1_BASE_PHYS,
184 +               .end            = IXP4XX_UART1_BASE_PHYS + 0x0fff,
185 +               .flags          = IORESOURCE_MEM,
186 +       },
187 +       {
188 +               .start          = IXP4XX_UART2_BASE_PHYS,
189 +               .end            = IXP4XX_UART2_BASE_PHYS + 0x0fff,
190 +               .flags          = IORESOURCE_MEM,
191 +       }
192 +};
193 +
194 +static struct plat_serial8250_port fsg_uart_data[] = {
195 +       {
196 +               .mapbase        = IXP4XX_UART1_BASE_PHYS,
197 +               .membase        = (char *)IXP4XX_UART1_BASE_VIRT + REG_OFFSET,
198 +               .irq            = IRQ_IXP4XX_UART1,
199 +               .flags          = UPF_BOOT_AUTOCONF | UPF_SKIP_TEST,
200 +               .iotype         = UPIO_MEM,
201 +               .regshift       = 2,
202 +               .uartclk        = IXP4XX_UART_XTAL,
203 +       },
204 +       {
205 +               .mapbase        = IXP4XX_UART2_BASE_PHYS,
206 +               .membase        = (char *)IXP4XX_UART2_BASE_VIRT + REG_OFFSET,
207 +               .irq            = IRQ_IXP4XX_UART2,
208 +               .flags          = UPF_BOOT_AUTOCONF | UPF_SKIP_TEST,
209 +               .iotype         = UPIO_MEM,
210 +               .regshift       = 2,
211 +               .uartclk        = IXP4XX_UART_XTAL,
212 +       },
213 +       { }
214 +};
215 +
216 +static struct platform_device fsg_uart = {
217 +       .name                   = "serial8250",
218 +       .id                     = PLAT8250_DEV_PLATFORM,
219 +       .dev.platform_data      = fsg_uart_data,
220 +       .num_resources          = ARRAY_SIZE(fsg_uart_resources),
221 +       .resource               = fsg_uart_resources,
222 +};
223 +
224 +static struct platform_device *fsg_devices[] __initdata = {
225 +       &fsg_i2c_gpio,
226 +       &fsg_flash,
227 +#ifdef CONFIG_LEDS_IXP4XX
228 +       &fsg_leds,
229 +#endif
230 +};
231 +
232 +static void __init fsg_init(void)
233 +{
234 +       ixp4xx_sys_init();
235 +
236 +       fsg_flash_resource.start = IXP4XX_EXP_BUS_BASE(0);
237 +       fsg_flash_resource.end =
238 +               IXP4XX_EXP_BUS_BASE(0) + ixp4xx_exp_bus_size - 1;
239 +
240 +        *IXP4XX_EXP_CS0 |= IXP4XX_FLASH_WRITABLE;
241 +        *IXP4XX_EXP_CS1 = *IXP4XX_EXP_CS0;
242 +
243 +       /* Configure CS2 for operation, 8bit and writable */
244 +       *IXP4XX_EXP_CS2 = 0xbfff0002;
245 +
246 +       /* This is only useful on a modified machine, but it is valuable
247 +        * to have it first in order to see debug messages, and so that
248 +        * it does *not* get removed if platform_add_devices fails!
249 +        */
250 +       (void)platform_device_register(&fsg_uart);
251 +
252 +       platform_add_devices(fsg_devices, ARRAY_SIZE(fsg_devices));
253 +}
254 +
255 +MACHINE_START(FSG, "Freecom FSG-3")
256 +       /* Maintainer: www.nslu2-linux.org */
257 +       .phys_io        = IXP4XX_PERIPHERAL_BASE_PHYS,
258 +       .io_pg_offst    = ((IXP4XX_PERIPHERAL_BASE_VIRT) >> 18) & 0xfffc,
259 +       .map_io         = ixp4xx_map_io,
260 +       .init_irq       = ixp4xx_init_irq,
261 +       .timer          = &ixp4xx_timer,
262 +       .boot_params    = 0x0100,
263 +       .init_machine   = fsg_init,
264 +MACHINE_END
265 +
266 diff -uprN linux-2.6.23.orig/arch/arm/mach-ixp4xx/Kconfig linux-2.6.23/arch/arm/mach-ixp4xx/Kconfig
267 --- linux-2.6.23.orig/arch/arm/mach-ixp4xx/Kconfig      2007-10-09 15:31:38.000000000 -0500
268 +++ linux-2.6.23/arch/arm/mach-ixp4xx/Kconfig   2007-10-11 00:55:34.000000000 -0500
269 @@ -125,6 +125,15 @@ config     ARCH_IXDP4XX
270         depends on ARCH_IXDP425 || MACH_IXDP465 || MACH_KIXRP435
271         default y
272  
273 +config MACH_FSG
274 +       bool
275 +       prompt "Freecom FSG-3"
276 +       select PCI
277 +       help
278 +         Say 'Y' here if you want your kernel to support Freecom's
279 +         FSG-3 device. For more information on this platform
280 +         see http://www.nslu2-linux.org/wiki/FSG3/HomePage
281 +
282  #
283  # Certain registers and IRQs are only enabled if supporting IXP465 CPUs
284  #
285 diff -uprN linux-2.6.23.orig/arch/arm/mach-ixp4xx/Makefile linux-2.6.23/arch/arm/mach-ixp4xx/Makefile
286 --- linux-2.6.23.orig/arch/arm/mach-ixp4xx/Makefile     2007-10-09 15:31:38.000000000 -0500
287 +++ linux-2.6.23/arch/arm/mach-ixp4xx/Makefile  2007-10-11 00:55:34.000000000 -0500
288 @@ -15,6 +15,7 @@ obj-pci-$(CONFIG_MACH_NAS100D)                += nas10
289  obj-pci-$(CONFIG_MACH_DSMG600)         += dsmg600-pci.o
290  obj-pci-$(CONFIG_MACH_GATEWAY7001)     += gateway7001-pci.o
291  obj-pci-$(CONFIG_MACH_WG302V2)         += wg302v2-pci.o
292 +obj-pci-$(CONFIG_MACH_FSG)             += fsg-pci.o
293  
294  obj-y  += common.o
295  
296 @@ -28,5 +29,6 @@ obj-$(CONFIG_MACH_NAS100D)    += nas100d-se
297  obj-$(CONFIG_MACH_DSMG600)      += dsmg600-setup.o dsmg600-power.o
298  obj-$(CONFIG_MACH_GATEWAY7001) += gateway7001-setup.o
299  obj-$(CONFIG_MACH_WG302V2)     += wg302v2-setup.o
300 +obj-$(CONFIG_MACH_FSG)         += fsg-setup.o
301  
302  obj-$(CONFIG_PCI)              += $(obj-pci-$(CONFIG_PCI)) common-pci.o
303 diff -uprN linux-2.6.23.orig/include/asm-arm/arch-ixp4xx/fsg.h linux-2.6.23/include/asm-arm/arch-ixp4xx/fsg.h
304 --- linux-2.6.23.orig/include/asm-arm/arch-ixp4xx/fsg.h 1969-12-31 18:00:00.000000000 -0600
305 +++ linux-2.6.23/include/asm-arm/arch-ixp4xx/fsg.h      2007-10-11 00:55:34.000000000 -0500
306 @@ -0,0 +1,74 @@
307 +/*
308 + * include/asm-arm/arch-ixp4xx/fsg.h
309 + *
310 + * Freecom FSG-3 platform specific definitions
311 + *
312 + * Author: Rod Whitby <rod@whitby.id.au>
313 + * Author: Tomasz Chmielewski <mangoo@wpkg.org>
314 + * Maintainers: http://www.nslu2-linux.org
315 + *
316 + * Based on coyote.h by
317 + * Copyright 2004 (c) MontaVista, Software, Inc.
318 + *
319 + * This file is licensed under  the terms of the GNU General Public
320 + * License version 2. This program is licensed "as is" without any
321 + * warranty of any kind, whether express or implied.
322 + */
323 +
324 +#ifndef __ASM_ARCH_HARDWARE_H__
325 +#error "Do not include this directly, instead #include <asm/hardware.h>"
326 +#endif
327 +
328 +#define FSG_SDA_PIN            12
329 +#define FSG_SCL_PIN            13
330 +
331 +/*
332 + * FSG PCI IRQs
333 + */
334 +#define FSG_PCI_MAX_DEV                3
335 +#define FSG_PCI_IRQ_LINES      3
336 +
337 +
338 +/* PCI controller GPIO to IRQ pin mappings */
339 +#define FSG_PCI_INTA_PIN       6
340 +#define FSG_PCI_INTB_PIN       7
341 +#define FSG_PCI_INTC_PIN       5
342 +
343 +/* Buttons */
344 +
345 +#define FSG_SB_GPIO            4
346 +#define FSG_RB_GPIO            9
347 +#define FSG_UB_GPIO            10
348 +
349 +#define FSG_SB_IRQ             IRQ_IXP4XX_GPIO4
350 +#define FSG_RB_IRQ             IRQ_IXP4XX_GPIO9
351 +#define FSG_UB_IRQ             IRQ_IXP4XX_GPIO10
352 +
353 +#define FSG_SB_BM              (1L << FSG_SB_GPIO)
354 +#define FSG_RB_BM              (1L << FSG_RB_GPIO)
355 +#define FSG_UB_BM              (1L << FSG_UB_GPIO)
356 +
357 +/* LEDs */
358 +
359 +#define FSG_LED_RING_GPIO      0
360 +#define FSG_LED_SYNC_GPIO      1
361 +#define FSG_LED_USB_GPIO       2
362 +#define FSG_LED_SATA_GPIO      3
363 +#define FSG_LED_WAN_GPIO       4
364 +#define FSG_LED_WLAN_GPIO      5
365 +
366 +/* %%% REMOVE %%%
367 +#define FSG_PCI_SLOT0_PIN      6
368 +#define FSG_PCI_SLOT1_PIN      7
369 +
370 +#define        FSG_PCI_SLOT0_DEVID     14
371 +#define        FSG_PCI_SLOT1_DEVID     15
372 +
373 +#define        FSG_IDE_BASE_PHYS       IXP4XX_EXP_BUS_BASE(3)
374 +#define        FSG_IDE_BASE_VIRT       0xFFFE1000
375 +#define        FSG_IDE_REGION_SIZE     0x1000
376 +
377 +#define        FSG_IDE_DATA_PORT       0xFFFE10E0
378 +#define        FSG_IDE_CTRL_PORT       0xFFFE10FC
379 +#define        FSG_IDE_ERROR_PORT      0xFFFE10E2
380 +*/
381 diff -uprN linux-2.6.23.orig/include/asm-arm/arch-ixp4xx/hardware.h linux-2.6.23/include/asm-arm/arch-ixp4xx/hardware.h
382 --- linux-2.6.23.orig/include/asm-arm/arch-ixp4xx/hardware.h    2007-10-09 15:31:38.000000000 -0500
383 +++ linux-2.6.23/include/asm-arm/arch-ixp4xx/hardware.h 2007-10-11 00:55:34.000000000 -0500
384 @@ -45,5 +45,6 @@
385  #include "nslu2.h"
386  #include "nas100d.h"
387  #include "dsmg600.h"
388 +#include "fsg.h"
389  
390  #endif  /* _ASM_ARCH_HARDWARE_H */
391 diff -uprN linux-2.6.23.orig/include/asm-arm/arch-ixp4xx/irqs.h linux-2.6.23/include/asm-arm/arch-ixp4xx/irqs.h
392 --- linux-2.6.23.orig/include/asm-arm/arch-ixp4xx/irqs.h        2007-10-09 15:31:38.000000000 -0500
393 +++ linux-2.6.23/include/asm-arm/arch-ixp4xx/irqs.h     2007-10-11 00:55:34.000000000 -0500
394 @@ -128,4 +128,17 @@
395  #define        IRQ_DSMG600_PCI_INTE    IRQ_IXP4XX_GPIO7
396  #define        IRQ_DSMG600_PCI_INTF    IRQ_IXP4XX_GPIO6
397  
398 +/*
399 + * Freecom FSG-3 Board IRQs
400 + */
401 +#define        IRQ_FSG_PCI_INTA        IRQ_IXP4XX_GPIO6
402 +#define        IRQ_FSG_PCI_INTB        IRQ_IXP4XX_GPIO7
403 +#define        IRQ_FSG_PCI_INTC        IRQ_IXP4XX_GPIO5
404 +
405 +/* %%% REMOVE %%%
406 +#define        IRQ_FSG_PCI_SLOT0       IRQ_IXP4XX_GPIO6
407 +#define        IRQ_FSG_PCI_SLOT1       IRQ_IXP4XX_GPIO7
408 +#define        IRQ_FSG_IDE             IRQ_IXP4XX_GPIO5
409 +*/
410 +
411  #endif