987abdfc71994baf82c1a53ebfdba9fc8fd7290c
[openwrt.git] / target / linux / ixp4xx / patches / 996-fsg3_support.patch
1 Index: linux-2.6.21.7/arch/arm/mach-ixp4xx/fsg-pci.c
2 ===================================================================
3 --- /dev/null
4 +++ linux-2.6.21.7/arch/arm/mach-ixp4xx/fsg-pci.c
5 @@ -0,0 +1,71 @@
6 +/*
7 + * arch/arch/mach-ixp4xx/fsg-pci.c
8 + *
9 + * FSG board-level PCI initialization
10 + *
11 + * Author: Rod Whitby <rod@whitby.id.au>
12 + * Maintainer: http://www.nslu2-linux.org/
13 + *
14 + * based on ixdp425-pci.c:
15 + * Copyright (C) 2002 Intel Corporation.
16 + * Copyright (C) 2003-2004 MontaVista Software, Inc.
17 + *
18 + * This program is free software; you can redistribute it and/or modify
19 + * it under the terms of the GNU General Public License version 2 as
20 + * published by the Free Software Foundation.
21 + *
22 + */
23 +
24 +#include <linux/pci.h>
25 +#include <linux/init.h>
26 +#include <linux/irq.h>
27 +
28 +#include <asm/mach/pci.h>
29 +#include <asm/mach-types.h>
30 +
31 +void __init fsg_pci_preinit(void)
32 +{
33 + set_irq_type(IRQ_FSG_PCI_INTA, IRQT_LOW);
34 + set_irq_type(IRQ_FSG_PCI_INTB, IRQT_LOW);
35 + set_irq_type(IRQ_FSG_PCI_INTC, IRQT_LOW);
36 +
37 + ixp4xx_pci_preinit();
38 +}
39 +
40 +static int __init fsg_map_irq(struct pci_dev *dev, u8 slot, u8 pin)
41 +{
42 + static int pci_irq_table[FSG_PCI_IRQ_LINES] = {
43 + IRQ_FSG_PCI_INTC,
44 + IRQ_FSG_PCI_INTB,
45 + IRQ_FSG_PCI_INTA,
46 + };
47 +
48 + int irq = -1;
49 + slot = slot - 11;
50 +
51 + if (slot >= 1 && slot <= FSG_PCI_MAX_DEV &&
52 + pin >= 1 && pin <= FSG_PCI_IRQ_LINES) {
53 + irq = pci_irq_table[(slot - 1)];
54 + }
55 + printk("%s: Mapped slot %d pin %d to IRQ %d\n", __FUNCTION__,slot, pin, irq);
56 +
57 + return irq;
58 +}
59 +
60 +struct hw_pci fsg_pci __initdata = {
61 + .nr_controllers = 1,
62 + .preinit = fsg_pci_preinit,
63 + .swizzle = pci_std_swizzle,
64 + .setup = ixp4xx_setup,
65 + .scan = ixp4xx_scan_bus,
66 + .map_irq = fsg_map_irq,
67 +};
68 +
69 +int __init fsg_pci_init(void)
70 +{
71 + if (machine_is_fsg())
72 + pci_common_init(&fsg_pci);
73 + return 0;
74 +}
75 +
76 +subsys_initcall(fsg_pci_init);
77 Index: linux-2.6.21.7/arch/arm/mach-ixp4xx/fsg-setup.c
78 ===================================================================
79 --- /dev/null
80 +++ linux-2.6.21.7/arch/arm/mach-ixp4xx/fsg-setup.c
81 @@ -0,0 +1,223 @@
82 +/*
83 + * arch/arm/mach-ixp4xx/fsg-setup.c
84 + *
85 + * FSG board-setup
86 + *
87 + * based ixdp425-setup.c:
88 + * Copyright (C) 2003-2004 MontaVista Software, Inc.
89 + *
90 + * Author: Rod Whitby <rod@whitby.id.au>
91 + * Maintainers: http://www.nslu2-linux.org/
92 + *
93 + */
94 +
95 +#include <linux/kernel.h>
96 +#include <linux/serial.h>
97 +#include <linux/serial_8250.h>
98 +#include <linux/leds.h>
99 +#include <linux/mtd/mtd.h>
100 +
101 +#include <asm/mach-types.h>
102 +#include <asm/mach/arch.h>
103 +#include <asm/mach/flash.h>
104 +
105 +static struct flash_platform_data fsg_flash_data = {
106 + .map_name = "cfi_probe",
107 + .width = 2,
108 +};
109 +
110 +static struct resource fsg_flash_resource = {
111 + .flags = IORESOURCE_MEM,
112 +};
113 +
114 +static struct platform_device fsg_flash = {
115 + .name = "IXP4XX-Flash",
116 + .id = 0,
117 + .dev.platform_data = &fsg_flash_data,
118 + .num_resources = 1,
119 + .resource = &fsg_flash_resource,
120 +};
121 +
122 +static struct ixp4xx_i2c_pins fsg_i2c_gpio_pins = {
123 + .sda_pin = FSG_SDA_PIN,
124 + .scl_pin = FSG_SCL_PIN,
125 +};
126 +
127 +static struct platform_device fsg_i2c_controller = {
128 + .name = "IXP4XX-I2C",
129 + .id = 0,
130 + .dev.platform_data = &fsg_i2c_gpio_pins,
131 + .num_resources = 0,
132 +};
133 +
134 +static struct resource fsg_uart_resources[] = {
135 + {
136 + .start = IXP4XX_UART1_BASE_PHYS,
137 + .end = IXP4XX_UART1_BASE_PHYS + 0x0fff,
138 + .flags = IORESOURCE_MEM,
139 + },
140 + {
141 + .start = IXP4XX_UART2_BASE_PHYS,
142 + .end = IXP4XX_UART2_BASE_PHYS + 0x0fff,
143 + .flags = IORESOURCE_MEM,
144 + }
145 +};
146 +
147 +static struct plat_serial8250_port fsg_uart_data[] = {
148 + {
149 + .mapbase = IXP4XX_UART1_BASE_PHYS,
150 + .membase = (char *)IXP4XX_UART1_BASE_VIRT + REG_OFFSET,
151 + .irq = IRQ_IXP4XX_UART1,
152 + .flags = UPF_BOOT_AUTOCONF | UPF_SKIP_TEST,
153 + .iotype = UPIO_MEM,
154 + .regshift = 2,
155 + .uartclk = IXP4XX_UART_XTAL,
156 + },
157 + {
158 + .mapbase = IXP4XX_UART2_BASE_PHYS,
159 + .membase = (char *)IXP4XX_UART2_BASE_VIRT + REG_OFFSET,
160 + .irq = IRQ_IXP4XX_UART2,
161 + .flags = UPF_BOOT_AUTOCONF | UPF_SKIP_TEST,
162 + .iotype = UPIO_MEM,
163 + .regshift = 2,
164 + .uartclk = IXP4XX_UART_XTAL,
165 + },
166 + { }
167 +};
168 +
169 +static struct platform_device fsg_uart = {
170 + .name = "serial8250",
171 + .id = PLAT8250_DEV_PLATFORM,
172 + .dev.platform_data = fsg_uart_data,
173 + .num_resources = ARRAY_SIZE(fsg_uart_resources),
174 + .resource = fsg_uart_resources,
175 +};
176 +
177 +/* Built-in 10/100 Ethernet MAC interfaces */
178 +static struct resource res_mac0 = {
179 + .start = IXP4XX_EthB_BASE_PHYS,
180 + .end = IXP4XX_EthB_BASE_PHYS + 0x1ff,
181 + .flags = IORESOURCE_MEM,
182 +};
183 +
184 +static struct resource res_mac1 = {
185 + .start = IXP4XX_EthC_BASE_PHYS,
186 + .end = IXP4XX_EthC_BASE_PHYS + 0x1ff,
187 + .flags = IORESOURCE_MEM,
188 +};
189 +
190 +static struct mac_plat_info plat_mac0 = {
191 + .npe_id = 1,
192 + .phy_id = 5,
193 + .eth_id = 0,
194 + .rxq_id = 27,
195 + .txq_id = 24,
196 + .rxdoneq_id = 4,
197 +};
198 +
199 +static struct mac_plat_info plat_mac1 = {
200 + .npe_id = 2,
201 + .phy_id = 4,
202 + .eth_id = 1,
203 + .rxq_id = 28,
204 + .txq_id = 25,
205 + .rxdoneq_id = 5,
206 +};
207 +
208 +static struct platform_device mac0 = {
209 + .name = "ixp4xx_mac",
210 + .id = 0,
211 + .dev.platform_data = &plat_mac0,
212 + .num_resources = 1,
213 + .resource = &res_mac0,
214 +};
215 +
216 +static struct platform_device mac1 = {
217 + .name = "ixp4xx_mac",
218 + .id = 1,
219 + .dev.platform_data = &plat_mac1,
220 + .num_resources = 1,
221 + .resource = &res_mac1,
222 +};
223 +
224 +struct npe_ucode_platform_data fsg_npe_ucode_data = {
225 + .mtd_partition = "microcode",
226 +};
227 +
228 +static struct platform_device fsg_npe_ucode = {
229 + .name = "ixp4xx_npe_ucode",
230 + .id = 0,
231 + .dev.platform_data = &fsg_npe_ucode_data,
232 +};
233 +
234 +static struct platform_device *fsg_devices[] __initdata = {
235 + &fsg_i2c_controller,
236 + &fsg_flash,
237 + &mac0,
238 + &mac1,
239 + &fsg_npe_ucode,
240 +};
241 +
242 +static void fsg_flash_add(struct mtd_info *mtd)
243 +{
244 + if (strcmp(mtd->name, "RedBoot config") == 0) {
245 + size_t retlen;
246 + u_char mac[6];
247 +
248 + if (mtd->read(mtd, 0x0422, 6, &retlen, mac) == 0 && retlen == 6) {
249 + printk(KERN_INFO "eth0 mac: %.2x:%.2x:%.2x:%.2x:%.2x:%.2x\n",
250 + mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);
251 + memcpy(plat_mac0.hwaddr, mac, 6);
252 + mac[5]++;
253 + printk(KERN_INFO "eth1 mac: %.2x:%.2x:%.2x:%.2x:%.2x:%.2x\n",
254 + mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);
255 + memcpy(plat_mac1.hwaddr, mac, 6);
256 + } else {
257 + printk(KERN_ERR "fsg mac: read failed\n");
258 + }
259 + }
260 +}
261 +
262 +static void fsg_flash_remove(struct mtd_info *mtd) {
263 +}
264 +
265 +static struct mtd_notifier fsg_flash_notifier = {
266 + .add = fsg_flash_add,
267 + .remove = fsg_flash_remove,
268 +};
269 +
270 +static void __init fsg_init(void)
271 +{
272 + ixp4xx_sys_init();
273 +
274 + fsg_flash_resource.start = IXP4XX_EXP_BUS_BASE(0);
275 + fsg_flash_resource.end =
276 + IXP4XX_EXP_BUS_BASE(0) + ixp4xx_exp_bus_size - 1;
277 +
278 + *IXP4XX_EXP_CS0 |= IXP4XX_FLASH_WRITABLE;
279 + *IXP4XX_EXP_CS1 = *IXP4XX_EXP_CS0;
280 +
281 + /* Configure CS2 for operation, 8bit and writable */
282 + *IXP4XX_EXP_CS2 = 0xbfff0002;
283 +
284 + /* This is only useful on a modified machine, but it is valuable
285 + * to have it first in order to see debug messages, and so that
286 + * it does *not* get removed if platform_add_devices fails!
287 + */
288 + (void)platform_device_register(&fsg_uart);
289 +
290 + platform_add_devices(fsg_devices, ARRAY_SIZE(fsg_devices));
291 +
292 + register_mtd_user(&fsg_flash_notifier);
293 +}
294 +
295 +MACHINE_START(FSG, "Freecom FSG-3")
296 + .phys_io = IXP4XX_PERIPHERAL_BASE_PHYS,
297 + .io_pg_offst = ((IXP4XX_PERIPHERAL_BASE_VIRT) >> 18) & 0xfffc,
298 + .map_io = ixp4xx_map_io,
299 + .init_irq = ixp4xx_init_irq,
300 + .timer = &ixp4xx_timer,
301 + .boot_params = 0x0100,
302 + .init_machine = fsg_init,
303 +MACHINE_END
304 +
305 Index: linux-2.6.21.7/include/asm-arm/arch-ixp4xx/fsg.h
306 ===================================================================
307 --- /dev/null
308 +++ linux-2.6.21.7/include/asm-arm/arch-ixp4xx/fsg.h
309 @@ -0,0 +1,58 @@
310 +/*
311 + * include/asm-arm/arch-ixp4xx/fsg.h
312 + *
313 + * Freecom FSG-3 platform specific definitions
314 + *
315 + * Author: Rod Whitby <rod@whitby.id.au>
316 + * Author: Tomasz Chmielewski <mangoo@wpkg.org>
317 + * Maintainers: http://www.nslu2-linux.org
318 + *
319 + * Based on coyote.h by
320 + * Copyright 2004 (c) MontaVista, Software, Inc.
321 + *
322 + * This file is licensed under the terms of the GNU General Public
323 + * License version 2. This program is licensed "as is" without any
324 + * warranty of any kind, whether express or implied.
325 + */
326 +
327 +#ifndef __ASM_ARCH_HARDWARE_H__
328 +#error "Do not include this directly, instead #include <asm/hardware.h>"
329 +#endif
330 +
331 +#define FSG_SDA_PIN 12
332 +#define FSG_SCL_PIN 13
333 +
334 +/*
335 + * FSG PCI IRQs
336 + */
337 +#define FSG_PCI_MAX_DEV 3
338 +#define FSG_PCI_IRQ_LINES 3
339 +
340 +
341 +/* PCI controller GPIO to IRQ pin mappings */
342 +#define FSG_PCI_INTA_PIN 6
343 +#define FSG_PCI_INTB_PIN 7
344 +#define FSG_PCI_INTC_PIN 5
345 +
346 +/* Buttons */
347 +
348 +#define FSG_SB_GPIO 4
349 +#define FSG_RB_GPIO 9
350 +#define FSG_UB_GPIO 10
351 +
352 +#define FSG_SB_IRQ IRQ_IXP4XX_GPIO4
353 +#define FSG_RB_IRQ IRQ_IXP4XX_GPIO9
354 +#define FSG_UB_IRQ IRQ_IXP4XX_GPIO10
355 +
356 +#define FSG_SB_BM (1L << FSG_SB_GPIO)
357 +#define FSG_RB_BM (1L << FSG_RB_GPIO)
358 +#define FSG_UB_BM (1L << FSG_UB_GPIO)
359 +
360 +/* LEDs */
361 +
362 +#define FSG_LED_RING_BIT 0
363 +#define FSG_LED_SYNC_BIT 1
364 +#define FSG_LED_USB_BIT 2
365 +#define FSG_LED_SATA_BIT 3
366 +#define FSG_LED_WAN_BIT 4
367 +#define FSG_LED_WLAN_BIT 5
368 Index: linux-2.6.21.7/include/asm-arm/arch-ixp4xx/hardware.h
369 ===================================================================
370 --- linux-2.6.21.7.orig/include/asm-arm/arch-ixp4xx/hardware.h
371 +++ linux-2.6.21.7/include/asm-arm/arch-ixp4xx/hardware.h
372 @@ -48,5 +48,6 @@ extern unsigned int processor_id;
373 #include "nslu2.h"
374 #include "nas100d.h"
375 #include "dsmg600.h"
376 +#include "fsg.h"
377
378 #endif /* _ASM_ARCH_HARDWARE_H */
379 Index: linux-2.6.21.7/include/asm-arm/arch-ixp4xx/irqs.h
380 ===================================================================
381 --- linux-2.6.21.7.orig/include/asm-arm/arch-ixp4xx/irqs.h
382 +++ linux-2.6.21.7/include/asm-arm/arch-ixp4xx/irqs.h
383 @@ -128,4 +128,11 @@
384 #define IRQ_DSMG600_PCI_INTE IRQ_IXP4XX_GPIO7
385 #define IRQ_DSMG600_PCI_INTF IRQ_IXP4XX_GPIO6
386
387 +/*
388 + * Freecom FSG-3 board IRQs
389 + */
390 +#define IRQ_FSG_PCI_INTA IRQ_IXP4XX_GPIO6
391 +#define IRQ_FSG_PCI_INTB IRQ_IXP4XX_GPIO7
392 +#define IRQ_FSG_PCI_INTC IRQ_IXP4XX_GPIO5
393 +
394 #endif
395 Index: linux-2.6.21.7/arch/arm/mach-ixp4xx/Makefile
396 ===================================================================
397 --- linux-2.6.21.7.orig/arch/arm/mach-ixp4xx/Makefile
398 +++ linux-2.6.21.7/arch/arm/mach-ixp4xx/Makefile
399 @@ -13,6 +13,7 @@ obj-pci-$(CONFIG_MACH_GTWX5715) += gtwx
400 obj-pci-$(CONFIG_MACH_NSLU2) += nslu2-pci.o
401 obj-pci-$(CONFIG_MACH_NAS100D) += nas100d-pci.o
402 obj-pci-$(CONFIG_MACH_DSMG600) += dsmg600-pci.o
403 +obj-pci-$(CONFIG_MACH_FSG) += fsg-pci.o
404 obj-pci-$(CONFIG_MACH_GATEWAY7001) += gateway7001-pci.o
405 obj-pci-$(CONFIG_MACH_WG302V2) += wg302v2-pci.o
406 obj-pci-$(CONFIG_MACH_PRONGHORNMETRO) += pronghornmetro-pci.o
407 @@ -29,6 +30,7 @@ obj-$(CONFIG_MACH_GTWX5715) += gtwx5715-
408 obj-$(CONFIG_MACH_NSLU2) += nslu2-setup.o nslu2-power.o
409 obj-$(CONFIG_MACH_NAS100D) += nas100d-setup.o nas100d-power.o
410 obj-$(CONFIG_MACH_DSMG600) += dsmg600-setup.o dsmg600-power.o
411 +obj-$(CONFIG_MACH_FSG) += fsg-setup.o
412 obj-$(CONFIG_MACH_GATEWAY7001) += gateway7001-setup.o
413 obj-$(CONFIG_MACH_WG302V2) += wg302v2-setup.o
414 obj-$(CONFIG_MACH_PRONGHORNMETRO) += pronghornmetro-setup.o
415 Index: linux-2.6.21.7/arch/arm/mach-ixp4xx/Kconfig
416 ===================================================================
417 --- linux-2.6.21.7.orig/arch/arm/mach-ixp4xx/Kconfig
418 +++ linux-2.6.21.7/arch/arm/mach-ixp4xx/Kconfig
419 @@ -138,6 +138,14 @@ config MACH_DSMG600
420 DSM-G600 RevA device. For more information on this platform,
421 see http://www.nslu2-linux.org/wiki/DSMG600/HomePage
422
423 +config MACH_FSG
424 + bool
425 + prompt "Freecom FSG-3"
426 + help
427 + Say 'Y' here if you want your kernel to support Freecom's
428 + FSG-3 device. For more information on this
429 + platform see http://www.openfsg.com/
430 +
431 #
432 # Avila and IXDP share the same source for now. Will change in future
433 #
This page took 0.052413 seconds and 3 git commands to generate.