Fixed the RTC driver board info
[nslu2-linux/kernel.git] / patches / 2.6.25 / ixp4xx-fsg-board-support.patch
blob66ba405bee5ed7951e984748e797948c1b772bcc
1 From 0b64383e483b2d554df96084070dc72b028d1c3a 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..6ca0dfa
190 --- /dev/null
191 +++ b/arch/arm/mach-ixp4xx/fsg-setup.c
192 @@ -0,0 +1,275 @@
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/irq.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.h>
217 +#include <linux/i2c-gpio.h>
219 +#include <asm/mach-types.h>
220 +#include <asm/mach/arch.h>
221 +#include <asm/mach/flash.h>
222 +#include <asm/io.h>
223 +#include <asm/gpio.h>
225 +static struct flash_platform_data fsg_flash_data = {
226 + .map_name = "cfi_probe",
227 + .width = 2,
230 +static struct resource fsg_flash_resource = {
231 + .flags = IORESOURCE_MEM,
234 +static struct platform_device fsg_flash = {
235 + .name = "IXP4XX-Flash",
236 + .id = 0,
237 + .dev.platform_data = &fsg_flash_data,
238 + .num_resources = 1,
239 + .resource = &fsg_flash_resource,
242 +static struct i2c_gpio_platform_data fsg_i2c_gpio_data = {
243 + .sda_pin = FSG_SDA_PIN,
244 + .scl_pin = FSG_SCL_PIN,
247 +static struct platform_device fsg_i2c_gpio = {
248 + .name = "i2c-gpio",
249 + .id = 0,
250 + .dev = {
251 + .platform_data = &fsg_i2c_gpio_data,
252 + },
255 +static struct i2c_board_info __initdata fsg_i2c_board_info [] = {
257 + I2C_BOARD_INFO("rtc-isl1208", 0x6f),
258 + },
261 +static struct resource fsg_uart_resources[] = {
263 + .start = IXP4XX_UART1_BASE_PHYS,
264 + .end = IXP4XX_UART1_BASE_PHYS + 0x0fff,
265 + .flags = IORESOURCE_MEM,
266 + },
268 + .start = IXP4XX_UART2_BASE_PHYS,
269 + .end = IXP4XX_UART2_BASE_PHYS + 0x0fff,
270 + .flags = IORESOURCE_MEM,
274 +static struct plat_serial8250_port fsg_uart_data[] = {
276 + .mapbase = IXP4XX_UART1_BASE_PHYS,
277 + .membase = (char *)IXP4XX_UART1_BASE_VIRT + REG_OFFSET,
278 + .irq = IRQ_IXP4XX_UART1,
279 + .flags = UPF_BOOT_AUTOCONF | UPF_SKIP_TEST,
280 + .iotype = UPIO_MEM,
281 + .regshift = 2,
282 + .uartclk = IXP4XX_UART_XTAL,
283 + },
285 + .mapbase = IXP4XX_UART2_BASE_PHYS,
286 + .membase = (char *)IXP4XX_UART2_BASE_VIRT + REG_OFFSET,
287 + .irq = IRQ_IXP4XX_UART2,
288 + .flags = UPF_BOOT_AUTOCONF | UPF_SKIP_TEST,
289 + .iotype = UPIO_MEM,
290 + .regshift = 2,
291 + .uartclk = IXP4XX_UART_XTAL,
292 + },
293 + { }
296 +static struct platform_device fsg_uart = {
297 + .name = "serial8250",
298 + .id = PLAT8250_DEV_PLATFORM,
299 + .dev.platform_data = fsg_uart_data,
300 + .num_resources = ARRAY_SIZE(fsg_uart_resources),
301 + .resource = fsg_uart_resources,
304 +static struct platform_device fsg_leds = {
305 + .name = "fsg-led",
306 + .id = -1,
309 +/* Built-in 10/100 Ethernet MAC interfaces */
310 +static struct eth_plat_info fsg_plat_eth[] = {
312 + .phy = 5,
313 + .rxq = 3,
314 + .txreadyq = 20,
315 + }, {
316 + .phy = 4,
317 + .rxq = 4,
318 + .txreadyq = 21,
322 +static struct platform_device fsg_eth[] = {
324 + .name = "ixp4xx_eth",
325 + .id = IXP4XX_ETH_NPEB,
326 + .dev.platform_data = fsg_plat_eth,
327 + }, {
328 + .name = "ixp4xx_eth",
329 + .id = IXP4XX_ETH_NPEC,
330 + .dev.platform_data = fsg_plat_eth + 1,
334 +static struct platform_device *fsg_devices[] __initdata = {
335 + &fsg_i2c_gpio,
336 + &fsg_flash,
337 + &fsg_leds,
338 + &fsg_eth[0],
339 + &fsg_eth[1],
342 +static void fsg_power_off(void)
344 + printk(KERN_INFO "Restarting system.\n");
345 + machine_restart(NULL);
348 +static irqreturn_t fsg_power_handler(int irq, void *dev_id)
350 + /* Signal init to do the ctrlaltdel action, this will bypass init if
351 + * it hasn't started and do a kernel_restart.
352 + */
353 + ctrl_alt_del();
355 + return IRQ_HANDLED;
358 +static irqreturn_t fsg_reset_handler(int irq, void *dev_id)
360 + /* This is the paper-clip reset, it shuts the machine down directly.
361 + */
362 + machine_power_off();
364 + return IRQ_HANDLED;
367 +static void __init fsg_init(void)
369 + DECLARE_MAC_BUF(mac_buf);
370 + uint8_t __iomem *f;
371 + int i;
373 + ixp4xx_sys_init();
375 + fsg_flash_resource.start = IXP4XX_EXP_BUS_BASE(0);
376 + fsg_flash_resource.end =
377 + IXP4XX_EXP_BUS_BASE(0) + ixp4xx_exp_bus_size - 1;
379 + *IXP4XX_EXP_CS0 |= IXP4XX_FLASH_WRITABLE;
380 + *IXP4XX_EXP_CS1 = *IXP4XX_EXP_CS0;
382 + /* Configure CS2 for operation, 8bit and writable */
383 + *IXP4XX_EXP_CS2 = 0xbfff0002;
385 + i2c_register_board_info(0, fsg_i2c_board_info,
386 + ARRAY_SIZE(fsg_i2c_board_info));
388 + /* This is only useful on a modified machine, but it is valuable
389 + * to have it first in order to see debug messages, and so that
390 + * it does *not* get removed if platform_add_devices fails!
391 + */
392 + (void)platform_device_register(&fsg_uart);
394 + platform_add_devices(fsg_devices, ARRAY_SIZE(fsg_devices));
396 + pm_power_off = fsg_power_off;
398 + set_irq_type(gpio_to_irq(FSG_RB_GPIO), IRQT_LOW);
399 + if (request_irq(gpio_to_irq(FSG_RB_GPIO), &fsg_reset_handler,
400 + IRQF_DISABLED, "FSG reset button", NULL) < 0) {
402 + printk(KERN_DEBUG "Reset Button IRQ %d not available\n",
403 + gpio_to_irq(FSG_RB_GPIO));
406 + set_irq_type(gpio_to_irq(FSG_SB_GPIO), IRQT_LOW);
407 + if (request_irq(gpio_to_irq(FSG_SB_GPIO), &fsg_power_handler,
408 + IRQF_DISABLED, "FSG power button", NULL) < 0) {
410 + printk(KERN_DEBUG "Power Button IRQ %d not available\n",
411 + gpio_to_irq(FSG_SB_GPIO));
414 + /*
415 + * Map in a portion of the flash and read the MAC addresses.
416 + * Since it is stored in BE in the flash itself, we need to
417 + * byteswap it if we're in LE mode.
418 + */
419 + f = ioremap(IXP4XX_EXP_BUS_BASE(0), 0x400000);
420 + if (f) {
421 +#ifdef __ARMEB__
422 + for (i = 0; i < 6; i++) {
423 + fsg_plat_eth[0].hwaddr[i] = readb(f + 0x3C0422 + i);
424 + fsg_plat_eth[1].hwaddr[i] = readb(f + 0x3C043B + i);
426 +#else
428 + /*
429 + Endian-swapped reads from unaligned addresses are
430 + required to extract the two MACs from the big-endian
431 + Redboot config area in flash.
432 + */
434 + fsg_plat_eth[0].hwaddr[0] = readb(f + 0x3C0421);
435 + fsg_plat_eth[0].hwaddr[1] = readb(f + 0x3C0420);
436 + fsg_plat_eth[0].hwaddr[2] = readb(f + 0x3C0427);
437 + fsg_plat_eth[0].hwaddr[3] = readb(f + 0x3C0426);
438 + fsg_plat_eth[0].hwaddr[4] = readb(f + 0x3C0425);
439 + fsg_plat_eth[0].hwaddr[5] = readb(f + 0x3C0424);
441 + fsg_plat_eth[1].hwaddr[0] = readb(f + 0x3C0439);
442 + fsg_plat_eth[1].hwaddr[1] = readb(f + 0x3C043F);
443 + fsg_plat_eth[1].hwaddr[2] = readb(f + 0x3C043E);
444 + fsg_plat_eth[1].hwaddr[3] = readb(f + 0x3C043D);
445 + fsg_plat_eth[1].hwaddr[4] = readb(f + 0x3C043C);
446 + fsg_plat_eth[1].hwaddr[5] = readb(f + 0x3C0443);
447 +#endif
448 + iounmap(f);
450 + printk(KERN_INFO "FSG: Using MAC address %s for port 0\n",
451 + print_mac(mac_buf, fsg_plat_eth[0].hwaddr));
452 + printk(KERN_INFO "FSG: Using MAC address %s for port 1\n",
453 + print_mac(mac_buf, fsg_plat_eth[1].hwaddr));
457 +MACHINE_START(FSG, "Freecom FSG-3")
458 + /* Maintainer: www.nslu2-linux.org */
459 + .phys_io = IXP4XX_PERIPHERAL_BASE_PHYS,
460 + .io_pg_offst = ((IXP4XX_PERIPHERAL_BASE_VIRT) >> 18) & 0xfffc,
461 + .map_io = ixp4xx_map_io,
462 + .init_irq = ixp4xx_init_irq,
463 + .timer = &ixp4xx_timer,
464 + .boot_params = 0x0100,
465 + .init_machine = fsg_init,
466 +MACHINE_END
468 diff --git a/include/asm-arm/arch-ixp4xx/fsg.h b/include/asm-arm/arch-ixp4xx/fsg.h
469 new file mode 100644
470 index 0000000..c0100cc
471 --- /dev/null
472 +++ b/include/asm-arm/arch-ixp4xx/fsg.h
473 @@ -0,0 +1,50 @@
475 + * include/asm-arm/arch-ixp4xx/fsg.h
477 + * Freecom FSG-3 platform specific definitions
479 + * Author: Rod Whitby <rod@whitby.id.au>
480 + * Author: Tomasz Chmielewski <mangoo@wpkg.org>
481 + * Maintainers: http://www.nslu2-linux.org
483 + * Based on coyote.h by
484 + * Copyright 2004 (c) MontaVista, Software, Inc.
486 + * This file is licensed under the terms of the GNU General Public
487 + * License version 2. This program is licensed "as is" without any
488 + * warranty of any kind, whether express or implied.
489 + */
491 +#ifndef __ASM_ARCH_HARDWARE_H__
492 +#error "Do not include this directly, instead #include <asm/hardware.h>"
493 +#endif
495 +#define FSG_SDA_PIN 12
496 +#define FSG_SCL_PIN 13
499 + * FSG PCI IRQs
500 + */
501 +#define FSG_PCI_MAX_DEV 3
502 +#define FSG_PCI_IRQ_LINES 3
505 +/* PCI controller GPIO to IRQ pin mappings */
506 +#define FSG_PCI_INTA_PIN 6
507 +#define FSG_PCI_INTB_PIN 7
508 +#define FSG_PCI_INTC_PIN 5
510 +/* Buttons */
512 +#define FSG_SB_GPIO 4 /* sync button */
513 +#define FSG_RB_GPIO 9 /* reset button */
514 +#define FSG_UB_GPIO 10 /* usb button */
516 +/* LEDs */
518 +#define FSG_LED_WLAN_BIT 0
519 +#define FSG_LED_WAN_BIT 1
520 +#define FSG_LED_SATA_BIT 2
521 +#define FSG_LED_USB_BIT 4
522 +#define FSG_LED_RING_BIT 5
523 +#define FSG_LED_SYNC_BIT 7
524 diff --git a/include/asm-arm/arch-ixp4xx/hardware.h b/include/asm-arm/arch-ixp4xx/hardware.h
525 index 73e8dc3..fa723a6 100644
526 --- a/include/asm-arm/arch-ixp4xx/hardware.h
527 +++ b/include/asm-arm/arch-ixp4xx/hardware.h
528 @@ -45,5 +45,6 @@
529 #include "nslu2.h"
530 #include "nas100d.h"
531 #include "dsmg600.h"
532 +#include "fsg.h"
534 #endif /* _ASM_ARCH_HARDWARE_H */
535 diff --git a/include/asm-arm/arch-ixp4xx/irqs.h b/include/asm-arm/arch-ixp4xx/irqs.h
536 index 1180160..674af4a 100644
537 --- a/include/asm-arm/arch-ixp4xx/irqs.h
538 +++ b/include/asm-arm/arch-ixp4xx/irqs.h
539 @@ -128,4 +128,11 @@
540 #define IRQ_DSMG600_PCI_INTE IRQ_IXP4XX_GPIO7
541 #define IRQ_DSMG600_PCI_INTF IRQ_IXP4XX_GPIO6
544 + * Freecom FSG-3 Board IRQs
545 + */
546 +#define IRQ_FSG_PCI_INTA IRQ_IXP4XX_GPIO6
547 +#define IRQ_FSG_PCI_INTB IRQ_IXP4XX_GPIO7
548 +#define IRQ_FSG_PCI_INTC IRQ_IXP4XX_GPIO5
550 #endif
552 1.5.2.5