Fixed the LE mac addresses
[nslu2-linux/kernel.git] / patches / 2.6.24 / ixp4xx-fsg-board-support.patch
blob3971c6a21dde1d90456e9f3d90187a8c36903aee
1 From 1bcd974638f69159d2040c95c8c6adb01abad9e4 Mon Sep 17 00:00:00 2001
2 From: Rod Whitby <rod@whitby.id.au>
3 Date: Tue, 29 Jan 2008 23:12:44 +1030
4 Subject: ixp4xx: Add support for the Freecom FSG-3 board
6 The Freecom-FSG3 is a small network-attached-storage device with the
7 following feature set:
9 * Intel IXP422
10 * 4MB Flash (ixp4xx flash driver)
11 * 64MB RAM
12 * 4 USB 2.0 host ports (ehci and ohci drivers)
13 * 1 WAN (eth1) and 3 LAN (eth0) ethernet ports
14 * Supported by the open source ixp4xx ethernet driver
15 * Via VT6421 disk controller (libata and sata-via drivers)
16 * Internal hard disk
17 * External SATA port (not yet supported)
18 * ISL1208 RTC chip
19 * Winbond 83782 temp sensor and fan controller
20 * MiniPCI slot
22 The ixp4xx_defconfig is also updated to support this device.
24 This has been tested on both big-endian and little-endian kernels.
26 Signed-off-by: Rod Whitby <rod@whitby.id.au>
28 PATCH FOLLOWS
29 KernelVersion: 2.6.24-git9 (+ patches already applied on ixp branch)
31 diff --git a/arch/arm/configs/ixp4xx_defconfig b/arch/arm/configs/ixp4xx_defconfig
32 index efa0485..11a1b3e 100644
33 --- a/arch/arm/configs/ixp4xx_defconfig
34 +++ b/arch/arm/configs/ixp4xx_defconfig
35 @@ -165,6 +165,7 @@ CONFIG_ARCH_PRPMC1100=y
36 CONFIG_MACH_NAS100D=y
37 CONFIG_MACH_DSMG600=y
38 CONFIG_ARCH_IXDP4XX=y
39 +CONFIG_MACH_FSG=y
40 CONFIG_CPU_IXP46X=y
41 CONFIG_CPU_IXP43X=y
42 CONFIG_MACH_GTWX5715=y
43 @@ -770,7 +771,7 @@ CONFIG_ATA=y
44 # CONFIG_SATA_SIL24 is not set
45 # CONFIG_SATA_SIS is not set
46 # CONFIG_SATA_ULI is not set
47 -# CONFIG_SATA_VIA is not set
48 +CONFIG_SATA_VIA=y
49 # CONFIG_SATA_VITESSE is not set
50 # CONFIG_SATA_INIC162X is not set
51 # CONFIG_PATA_ALI is not set
52 @@ -1143,7 +1144,7 @@ CONFIG_HWMON=y
53 # CONFIG_SENSORS_VIA686A is not set
54 # CONFIG_SENSORS_VT1211 is not set
55 # CONFIG_SENSORS_VT8231 is not set
56 -# CONFIG_SENSORS_W83781D is not set
57 +CONFIG_SENSORS_W83781D=y
58 # CONFIG_SENSORS_W83791D is not set
59 # CONFIG_SENSORS_W83792D is not set
60 # CONFIG_SENSORS_W83793 is not set
61 @@ -1367,7 +1368,7 @@ CONFIG_RTC_INTF_DEV=y
62 # CONFIG_RTC_DRV_DS1672 is not set
63 # CONFIG_RTC_DRV_MAX6900 is not set
64 # CONFIG_RTC_DRV_RS5C372 is not set
65 -# CONFIG_RTC_DRV_ISL1208 is not set
66 +CONFIG_RTC_DRV_ISL1208=y
67 CONFIG_RTC_DRV_X1205=y
68 CONFIG_RTC_DRV_PCF8563=y
69 # CONFIG_RTC_DRV_PCF8583 is not set
70 diff --git a/arch/arm/mach-ixp4xx/Kconfig b/arch/arm/mach-ixp4xx/Kconfig
71 index e774447..db8b5fe 100644
72 --- a/arch/arm/mach-ixp4xx/Kconfig
73 +++ b/arch/arm/mach-ixp4xx/Kconfig
74 @@ -125,6 +125,15 @@ config ARCH_IXDP4XX
75 depends on ARCH_IXDP425 || MACH_IXDP465 || MACH_KIXRP435
76 default y
78 +config MACH_FSG
79 + bool
80 + prompt "Freecom FSG-3"
81 + select PCI
82 + help
83 + Say 'Y' here if you want your kernel to support Freecom's
84 + FSG-3 device. For more information on this platform,
85 + see http://www.nslu2-linux.org/wiki/FSG3/HomePage
88 # Certain registers and IRQs are only enabled if supporting IXP465 CPUs
90 diff --git a/arch/arm/mach-ixp4xx/Makefile b/arch/arm/mach-ixp4xx/Makefile
91 index 4bb97e1..e620ff3 100644
92 --- a/arch/arm/mach-ixp4xx/Makefile
93 +++ b/arch/arm/mach-ixp4xx/Makefile
94 @@ -15,6 +15,7 @@ obj-pci-$(CONFIG_MACH_NAS100D) += nas100d-pci.o
95 obj-pci-$(CONFIG_MACH_DSMG600) += dsmg600-pci.o
96 obj-pci-$(CONFIG_MACH_GATEWAY7001) += gateway7001-pci.o
97 obj-pci-$(CONFIG_MACH_WG302V2) += wg302v2-pci.o
98 +obj-pci-$(CONFIG_MACH_FSG) += fsg-pci.o
100 obj-y += common.o
102 @@ -28,6 +29,7 @@ obj-$(CONFIG_MACH_NAS100D) += nas100d-setup.o nas100d-power.o
103 obj-$(CONFIG_MACH_DSMG600) += dsmg600-setup.o dsmg600-power.o
104 obj-$(CONFIG_MACH_GATEWAY7001) += gateway7001-setup.o
105 obj-$(CONFIG_MACH_WG302V2) += wg302v2-setup.o
106 +obj-$(CONFIG_MACH_FSG) += fsg-setup.o
108 obj-$(CONFIG_PCI) += $(obj-pci-$(CONFIG_PCI)) common-pci.o
109 obj-$(CONFIG_IXP4XX_QMGR) += ixp4xx_qmgr.o
110 diff --git a/arch/arm/mach-ixp4xx/fsg-pci.c b/arch/arm/mach-ixp4xx/fsg-pci.c
111 new file mode 100644
112 index 0000000..19a8b73
113 --- /dev/null
114 +++ b/arch/arm/mach-ixp4xx/fsg-pci.c
115 @@ -0,0 +1,71 @@
117 + * arch/arch/mach-ixp4xx/fsg-pci.c
119 + * FSG board-level PCI initialization
121 + * Author: Rod Whitby <rod@whitby.id.au>
122 + * Maintainer: http://www.nslu2-linux.org/
124 + * based on ixdp425-pci.c:
125 + * Copyright (C) 2002 Intel Corporation.
126 + * Copyright (C) 2003-2004 MontaVista Software, Inc.
128 + * This program is free software; you can redistribute it and/or modify
129 + * it under the terms of the GNU General Public License version 2 as
130 + * published by the Free Software Foundation.
132 + */
134 +#include <linux/pci.h>
135 +#include <linux/init.h>
136 +#include <linux/irq.h>
138 +#include <asm/mach/pci.h>
139 +#include <asm/mach-types.h>
141 +void __init fsg_pci_preinit(void)
143 + set_irq_type(IRQ_FSG_PCI_INTA, IRQT_LOW);
144 + set_irq_type(IRQ_FSG_PCI_INTB, IRQT_LOW);
145 + set_irq_type(IRQ_FSG_PCI_INTC, IRQT_LOW);
147 + ixp4xx_pci_preinit();
150 +static int __init fsg_map_irq(struct pci_dev *dev, u8 slot, u8 pin)
152 + static int pci_irq_table[FSG_PCI_IRQ_LINES] = {
153 + IRQ_FSG_PCI_INTC,
154 + IRQ_FSG_PCI_INTB,
155 + IRQ_FSG_PCI_INTA,
156 + };
158 + int irq = -1;
159 + slot = slot - 11;
161 + if (slot >= 1 && slot <= FSG_PCI_MAX_DEV &&
162 + pin >= 1 && pin <= FSG_PCI_IRQ_LINES)
163 + irq = pci_irq_table[(slot - 1)];
164 + printk(KERN_INFO "%s: Mapped slot %d pin %d to IRQ %d\n",
165 + __FUNCTION__, slot, pin, irq);
167 + return irq;
170 +struct hw_pci fsg_pci __initdata = {
171 + .nr_controllers = 1,
172 + .preinit = fsg_pci_preinit,
173 + .swizzle = pci_std_swizzle,
174 + .setup = ixp4xx_setup,
175 + .scan = ixp4xx_scan_bus,
176 + .map_irq = fsg_map_irq,
179 +int __init fsg_pci_init(void)
181 + if (machine_is_fsg())
182 + pci_common_init(&fsg_pci);
183 + return 0;
186 +subsys_initcall(fsg_pci_init);
187 diff --git a/arch/arm/mach-ixp4xx/fsg-setup.c b/arch/arm/mach-ixp4xx/fsg-setup.c
188 new file mode 100644
189 index 0000000..411f617
190 --- /dev/null
191 +++ b/arch/arm/mach-ixp4xx/fsg-setup.c
192 @@ -0,0 +1,274 @@
194 + * arch/arm/mach-ixp4xx/fsg-setup.c
196 + * FSG board-setup
198 + * Copyright (C) 2008 Rod Whitby <rod@whitby.id.au>
200 + * based on ixdp425-setup.c:
201 + * Copyright (C) 2003-2004 MontaVista Software, Inc.
202 + * based on nslu2-power.c
203 + * Copyright (C) 2005 Tower Technologies
205 + * Author: Rod Whitby <rod@whitby.id.au>
206 + * Maintainers: http://www.nslu2-linux.org/
208 + */
210 +#include <linux/if_ether.h>
211 +#include <linux/kernel.h>
212 +#include <linux/serial.h>
213 +#include <linux/serial_8250.h>
214 +#include <linux/leds.h>
215 +#include <linux/reboot.h>
216 +#include <linux/i2c-gpio.h>
218 +#include <linux/module.h>
219 +#include <linux/reboot.h>
220 +#include <linux/interrupt.h>
221 +#include <linux/irq.h>
222 +#include <linux/jiffies.h>
223 +#include <linux/timer.h>
225 +#include <asm/gpio.h>
226 +#include <asm/mach-types.h>
228 +#include <asm/mach-types.h>
229 +#include <asm/mach/arch.h>
230 +#include <asm/mach/flash.h>
231 +#include <asm/io.h>
233 +static struct flash_platform_data fsg_flash_data = {
234 + .map_name = "cfi_probe",
235 + .width = 2,
238 +static struct resource fsg_flash_resource = {
239 + .flags = IORESOURCE_MEM,
242 +static struct platform_device fsg_flash = {
243 + .name = "IXP4XX-Flash",
244 + .id = 0,
245 + .dev.platform_data = &fsg_flash_data,
246 + .num_resources = 1,
247 + .resource = &fsg_flash_resource,
250 +static struct i2c_gpio_platform_data fsg_i2c_gpio_data = {
251 + .sda_pin = FSG_SDA_PIN,
252 + .scl_pin = FSG_SCL_PIN,
255 +static struct platform_device fsg_i2c_gpio = {
256 + .name = "i2c-gpio",
257 + .id = 0,
258 + .dev = {
259 + .platform_data = &fsg_i2c_gpio_data,
260 + },
263 +static struct resource fsg_uart_resources[] = {
265 + .start = IXP4XX_UART1_BASE_PHYS,
266 + .end = IXP4XX_UART1_BASE_PHYS + 0x0fff,
267 + .flags = IORESOURCE_MEM,
268 + },
270 + .start = IXP4XX_UART2_BASE_PHYS,
271 + .end = IXP4XX_UART2_BASE_PHYS + 0x0fff,
272 + .flags = IORESOURCE_MEM,
276 +static struct plat_serial8250_port fsg_uart_data[] = {
278 + .mapbase = IXP4XX_UART1_BASE_PHYS,
279 + .membase = (char *)IXP4XX_UART1_BASE_VIRT + REG_OFFSET,
280 + .irq = IRQ_IXP4XX_UART1,
281 + .flags = UPF_BOOT_AUTOCONF | UPF_SKIP_TEST,
282 + .iotype = UPIO_MEM,
283 + .regshift = 2,
284 + .uartclk = IXP4XX_UART_XTAL,
285 + },
287 + .mapbase = IXP4XX_UART2_BASE_PHYS,
288 + .membase = (char *)IXP4XX_UART2_BASE_VIRT + REG_OFFSET,
289 + .irq = IRQ_IXP4XX_UART2,
290 + .flags = UPF_BOOT_AUTOCONF | UPF_SKIP_TEST,
291 + .iotype = UPIO_MEM,
292 + .regshift = 2,
293 + .uartclk = IXP4XX_UART_XTAL,
294 + },
295 + { }
298 +static struct platform_device fsg_uart = {
299 + .name = "serial8250",
300 + .id = PLAT8250_DEV_PLATFORM,
301 + .dev.platform_data = fsg_uart_data,
302 + .num_resources = ARRAY_SIZE(fsg_uart_resources),
303 + .resource = fsg_uart_resources,
306 +static struct platform_device fsg_leds = {
307 + .name = "fsg-led",
308 + .id = -1,
311 +/* Built-in 10/100 Ethernet MAC interfaces */
312 +static struct eth_plat_info fsg_plat_eth[] = {
314 + .phy = 5,
315 + .rxq = 3,
316 + .txreadyq = 20,
317 + }, {
318 + .phy = 4,
319 + .rxq = 4,
320 + .txreadyq = 21,
324 +static struct platform_device fsg_eth[] = {
326 + .name = "ixp4xx_eth",
327 + .id = IXP4XX_ETH_NPEB,
328 + .dev.platform_data = fsg_plat_eth,
329 + }, {
330 + .name = "ixp4xx_eth",
331 + .id = IXP4XX_ETH_NPEC,
332 + .dev.platform_data = fsg_plat_eth + 1,
336 +static struct platform_device *fsg_devices[] __initdata = {
337 + &fsg_i2c_gpio,
338 + &fsg_flash,
339 + &fsg_leds,
340 + &fsg_eth[0],
341 + &fsg_eth[1],
344 +static void fsg_power_off(void)
346 + printk(KERN_INFO "Restarting system.\n");
347 + machine_restart(NULL);
350 +static irqreturn_t fsg_power_handler(int irq, void *dev_id)
352 + /* Signal init to do the ctrlaltdel action, this will bypass init if
353 + * it hasn't started and do a kernel_restart.
354 + */
355 + ctrl_alt_del();
357 + return IRQ_HANDLED;
360 +static irqreturn_t fsg_reset_handler(int irq, void *dev_id)
362 + /* This is the paper-clip reset, it shuts the machine down directly.
363 + */
364 + machine_power_off();
366 + return IRQ_HANDLED;
369 +static void __init fsg_init(void)
371 + DECLARE_MAC_BUF(mac_buf);
372 + uint8_t __iomem *f;
373 + int i;
375 + ixp4xx_sys_init();
377 + fsg_flash_resource.start = IXP4XX_EXP_BUS_BASE(0);
378 + fsg_flash_resource.end =
379 + IXP4XX_EXP_BUS_BASE(0) + ixp4xx_exp_bus_size - 1;
381 + *IXP4XX_EXP_CS0 |= IXP4XX_FLASH_WRITABLE;
382 + *IXP4XX_EXP_CS1 = *IXP4XX_EXP_CS0;
384 + /* Configure CS2 for operation, 8bit and writable */
385 + *IXP4XX_EXP_CS2 = 0xbfff0002;
387 + /* This is only useful on a modified machine, but it is valuable
388 + * to have it first in order to see debug messages, and so that
389 + * it does *not* get removed if platform_add_devices fails!
390 + */
391 + (void)platform_device_register(&fsg_uart);
393 + platform_add_devices(fsg_devices, ARRAY_SIZE(fsg_devices));
395 + pm_power_off = fsg_power_off;
397 + set_irq_type(gpio_to_irq(FSG_RB_GPIO), IRQT_LOW);
398 + if (request_irq(gpio_to_irq(FSG_RB_GPIO), &fsg_reset_handler,
399 + IRQF_DISABLED, "FSG reset button", NULL) < 0) {
401 + printk(KERN_DEBUG "Reset Button IRQ %d not available\n",
402 + gpio_to_irq(FSG_RB_GPIO));
405 + set_irq_type(gpio_to_irq(FSG_SB_GPIO), IRQT_LOW);
406 + if (request_irq(gpio_to_irq(FSG_SB_GPIO), &fsg_power_handler,
407 + IRQF_DISABLED, "FSG power button", NULL) < 0) {
409 + printk(KERN_DEBUG "Power Button IRQ %d not available\n",
410 + gpio_to_irq(FSG_SB_GPIO));
413 + /*
414 + * Map in a portion of the flash and read the MAC addresses.
415 + * Since it is stored in BE in the flash itself, we need to
416 + * byteswap it if we're in LE mode.
417 + */
418 + f = ioremap(IXP4XX_EXP_BUS_BASE(0), 0x400000);
419 + if (f) {
420 +#ifdef __ARMEB__
421 + for (i = 0; i < 6; i++) {
422 + fsg_plat_eth[0].hwaddr[i] = readb(f + 0x3C0422 + i);
423 + fsg_plat_eth[1].hwaddr[i] = readb(f + 0x3C043B + i);
425 +#else
427 + /*
428 + Endian-swapped reads from unaligned addresses are
429 + required to extract the two MACs from the big-endian
430 + Redboot config area in flash.
431 + */
433 + fsg_plat_eth[0].hwaddr[0] = readb(f + 0x3C0421);
434 + fsg_plat_eth[0].hwaddr[1] = readb(f + 0x3C0420);
435 + fsg_plat_eth[0].hwaddr[2] = readb(f + 0x3C0427);
436 + fsg_plat_eth[0].hwaddr[3] = readb(f + 0x3C0426);
437 + fsg_plat_eth[0].hwaddr[4] = readb(f + 0x3C0425);
438 + fsg_plat_eth[0].hwaddr[5] = readb(f + 0x3C0424);
440 + fsg_plat_eth[1].hwaddr[0] = readb(f + 0x3C0439);
441 + fsg_plat_eth[1].hwaddr[1] = readb(f + 0x3C043F);
442 + fsg_plat_eth[1].hwaddr[2] = readb(f + 0x3C043E);
443 + fsg_plat_eth[1].hwaddr[3] = readb(f + 0x3C043D);
444 + fsg_plat_eth[1].hwaddr[4] = readb(f + 0x3C043C);
445 + fsg_plat_eth[1].hwaddr[5] = readb(f + 0x3C0443);
446 +#endif
447 + iounmap(f);
449 + printk(KERN_INFO "FSG: Using MAC address %s for port 0\n",
450 + print_mac(mac_buf, fsg_plat_eth[0].hwaddr));
451 + printk(KERN_INFO "FSG: Using MAC address %s for port 1\n",
452 + print_mac(mac_buf, fsg_plat_eth[1].hwaddr));
456 +MACHINE_START(FSG, "Freecom FSG-3")
457 + /* Maintainer: www.nslu2-linux.org */
458 + .phys_io = IXP4XX_PERIPHERAL_BASE_PHYS,
459 + .io_pg_offst = ((IXP4XX_PERIPHERAL_BASE_VIRT) >> 18) & 0xfffc,
460 + .map_io = ixp4xx_map_io,
461 + .init_irq = ixp4xx_init_irq,
462 + .timer = &ixp4xx_timer,
463 + .boot_params = 0x0100,
464 + .init_machine = fsg_init,
465 +MACHINE_END
467 diff --git a/include/asm-arm/arch-ixp4xx/fsg.h b/include/asm-arm/arch-ixp4xx/fsg.h
468 new file mode 100644
469 index 0000000..c0100cc
470 --- /dev/null
471 +++ b/include/asm-arm/arch-ixp4xx/fsg.h
472 @@ -0,0 +1,50 @@
474 + * include/asm-arm/arch-ixp4xx/fsg.h
476 + * Freecom FSG-3 platform specific definitions
478 + * Author: Rod Whitby <rod@whitby.id.au>
479 + * Author: Tomasz Chmielewski <mangoo@wpkg.org>
480 + * Maintainers: http://www.nslu2-linux.org
482 + * Based on coyote.h by
483 + * Copyright 2004 (c) MontaVista, Software, Inc.
485 + * This file is licensed under the terms of the GNU General Public
486 + * License version 2. This program is licensed "as is" without any
487 + * warranty of any kind, whether express or implied.
488 + */
490 +#ifndef __ASM_ARCH_HARDWARE_H__
491 +#error "Do not include this directly, instead #include <asm/hardware.h>"
492 +#endif
494 +#define FSG_SDA_PIN 12
495 +#define FSG_SCL_PIN 13
498 + * FSG PCI IRQs
499 + */
500 +#define FSG_PCI_MAX_DEV 3
501 +#define FSG_PCI_IRQ_LINES 3
504 +/* PCI controller GPIO to IRQ pin mappings */
505 +#define FSG_PCI_INTA_PIN 6
506 +#define FSG_PCI_INTB_PIN 7
507 +#define FSG_PCI_INTC_PIN 5
509 +/* Buttons */
511 +#define FSG_SB_GPIO 4 /* sync button */
512 +#define FSG_RB_GPIO 9 /* reset button */
513 +#define FSG_UB_GPIO 10 /* usb button */
515 +/* LEDs */
517 +#define FSG_LED_WLAN_BIT 0
518 +#define FSG_LED_WAN_BIT 1
519 +#define FSG_LED_SATA_BIT 2
520 +#define FSG_LED_USB_BIT 4
521 +#define FSG_LED_RING_BIT 5
522 +#define FSG_LED_SYNC_BIT 7
523 diff --git a/include/asm-arm/arch-ixp4xx/hardware.h b/include/asm-arm/arch-ixp4xx/hardware.h
524 index 73e8dc3..fa723a6 100644
525 --- a/include/asm-arm/arch-ixp4xx/hardware.h
526 +++ b/include/asm-arm/arch-ixp4xx/hardware.h
527 @@ -45,5 +45,6 @@
528 #include "nslu2.h"
529 #include "nas100d.h"
530 #include "dsmg600.h"
531 +#include "fsg.h"
533 #endif /* _ASM_ARCH_HARDWARE_H */
534 diff --git a/include/asm-arm/arch-ixp4xx/irqs.h b/include/asm-arm/arch-ixp4xx/irqs.h
535 index 1180160..674af4a 100644
536 --- a/include/asm-arm/arch-ixp4xx/irqs.h
537 +++ b/include/asm-arm/arch-ixp4xx/irqs.h
538 @@ -128,4 +128,11 @@
539 #define IRQ_DSMG600_PCI_INTE IRQ_IXP4XX_GPIO7
540 #define IRQ_DSMG600_PCI_INTF IRQ_IXP4XX_GPIO6
543 + * Freecom FSG-3 Board IRQs
544 + */
545 +#define IRQ_FSG_PCI_INTA IRQ_IXP4XX_GPIO6
546 +#define IRQ_FSG_PCI_INTB IRQ_IXP4XX_GPIO7
547 +#define IRQ_FSG_PCI_INTC IRQ_IXP4XX_GPIO5
549 #endif
551 1.5.2.5