[ixp4xx] fix a compiler warning in the Sidewinder board specific code
[openwrt.git] / target / linux / ixp4xx / patches-2.6.24 / 030-ixp4xx_fsg_board_support.patch
1 Index: linux-2.6.24/arch/arm/mach-ixp4xx/Kconfig
2 ===================================================================
3 --- linux-2.6.24.orig/arch/arm/mach-ixp4xx/Kconfig 2008-03-20 21:07:50.000000000 +1030
4 +++ linux-2.6.24/arch/arm/mach-ixp4xx/Kconfig 2008-03-20 21:09:12.000000000 +1030
5 @@ -125,6 +125,15 @@
6 depends on ARCH_IXDP425 || MACH_IXDP465 || MACH_KIXRP435
7 default y
8
9 +config MACH_FSG
10 + bool
11 + prompt "Freecom FSG-3"
12 + select PCI
13 + help
14 + Say 'Y' here if you want your kernel to support Freecom's
15 + FSG-3 device. For more information on this platform,
16 + see http://www.nslu2-linux.org/wiki/FSG3/HomePage
17 +
18 #
19 # Certain registers and IRQs are only enabled if supporting IXP465 CPUs
20 #
21 Index: linux-2.6.24/arch/arm/mach-ixp4xx/Makefile
22 ===================================================================
23 --- linux-2.6.24.orig/arch/arm/mach-ixp4xx/Makefile 2008-03-20 21:07:50.000000000 +1030
24 +++ linux-2.6.24/arch/arm/mach-ixp4xx/Makefile 2008-03-20 21:09:12.000000000 +1030
25 @@ -15,6 +15,7 @@
26 obj-pci-$(CONFIG_MACH_DSMG600) += dsmg600-pci.o
27 obj-pci-$(CONFIG_MACH_GATEWAY7001) += gateway7001-pci.o
28 obj-pci-$(CONFIG_MACH_WG302V2) += wg302v2-pci.o
29 +obj-pci-$(CONFIG_MACH_FSG) += fsg-pci.o
30
31 obj-y += common.o
32
33 @@ -28,5 +29,6 @@
34 obj-$(CONFIG_MACH_DSMG600) += dsmg600-setup.o dsmg600-power.o
35 obj-$(CONFIG_MACH_GATEWAY7001) += gateway7001-setup.o
36 obj-$(CONFIG_MACH_WG302V2) += wg302v2-setup.o
37 +obj-$(CONFIG_MACH_FSG) += fsg-setup.o
38
39 obj-$(CONFIG_PCI) += $(obj-pci-$(CONFIG_PCI)) common-pci.o
40 Index: linux-2.6.24/arch/arm/mach-ixp4xx/fsg-pci.c
41 ===================================================================
42 --- /dev/null 1970-01-01 00:00:00.000000000 +0000
43 +++ linux-2.6.24/arch/arm/mach-ixp4xx/fsg-pci.c 2008-03-20 21:09:12.000000000 +1030
44 @@ -0,0 +1,71 @@
45 +/*
46 + * arch/arch/mach-ixp4xx/fsg-pci.c
47 + *
48 + * FSG board-level PCI initialization
49 + *
50 + * Author: Rod Whitby <rod@whitby.id.au>
51 + * Maintainer: http://www.nslu2-linux.org/
52 + *
53 + * based on ixdp425-pci.c:
54 + * Copyright (C) 2002 Intel Corporation.
55 + * Copyright (C) 2003-2004 MontaVista Software, Inc.
56 + *
57 + * This program is free software; you can redistribute it and/or modify
58 + * it under the terms of the GNU General Public License version 2 as
59 + * published by the Free Software Foundation.
60 + *
61 + */
62 +
63 +#include <linux/pci.h>
64 +#include <linux/init.h>
65 +#include <linux/irq.h>
66 +
67 +#include <asm/mach/pci.h>
68 +#include <asm/mach-types.h>
69 +
70 +void __init fsg_pci_preinit(void)
71 +{
72 + set_irq_type(IRQ_FSG_PCI_INTA, IRQT_LOW);
73 + set_irq_type(IRQ_FSG_PCI_INTB, IRQT_LOW);
74 + set_irq_type(IRQ_FSG_PCI_INTC, IRQT_LOW);
75 +
76 + ixp4xx_pci_preinit();
77 +}
78 +
79 +static int __init fsg_map_irq(struct pci_dev *dev, u8 slot, u8 pin)
80 +{
81 + static int pci_irq_table[FSG_PCI_IRQ_LINES] = {
82 + IRQ_FSG_PCI_INTC,
83 + IRQ_FSG_PCI_INTB,
84 + IRQ_FSG_PCI_INTA,
85 + };
86 +
87 + int irq = -1;
88 + slot = slot - 11;
89 +
90 + if (slot >= 1 && slot <= FSG_PCI_MAX_DEV &&
91 + pin >= 1 && pin <= FSG_PCI_IRQ_LINES)
92 + irq = pci_irq_table[(slot - 1)];
93 + printk(KERN_INFO "%s: Mapped slot %d pin %d to IRQ %d\n",
94 + __func__, slot, pin, irq);
95 +
96 + return irq;
97 +}
98 +
99 +struct hw_pci fsg_pci __initdata = {
100 + .nr_controllers = 1,
101 + .preinit = fsg_pci_preinit,
102 + .swizzle = pci_std_swizzle,
103 + .setup = ixp4xx_setup,
104 + .scan = ixp4xx_scan_bus,
105 + .map_irq = fsg_map_irq,
106 +};
107 +
108 +int __init fsg_pci_init(void)
109 +{
110 + if (machine_is_fsg())
111 + pci_common_init(&fsg_pci);
112 + return 0;
113 +}
114 +
115 +subsys_initcall(fsg_pci_init);
116 Index: linux-2.6.24/arch/arm/mach-ixp4xx/fsg-setup.c
117 ===================================================================
118 --- /dev/null 1970-01-01 00:00:00.000000000 +0000
119 +++ linux-2.6.24/arch/arm/mach-ixp4xx/fsg-setup.c 2008-03-20 21:09:12.000000000 +1030
120 @@ -0,0 +1,275 @@
121 +/*
122 + * arch/arm/mach-ixp4xx/fsg-setup.c
123 + *
124 + * FSG board-setup
125 + *
126 + * Copyright (C) 2008 Rod Whitby <rod@whitby.id.au>
127 + *
128 + * based on ixdp425-setup.c:
129 + * Copyright (C) 2003-2004 MontaVista Software, Inc.
130 + * based on nslu2-power.c
131 + * Copyright (C) 2005 Tower Technologies
132 + *
133 + * Author: Rod Whitby <rod@whitby.id.au>
134 + * Maintainers: http://www.nslu2-linux.org/
135 + *
136 + */
137 +
138 +#include <linux/if_ether.h>
139 +#include <linux/irq.h>
140 +#include <linux/serial.h>
141 +#include <linux/serial_8250.h>
142 +#include <linux/leds.h>
143 +#include <linux/reboot.h>
144 +#include <linux/i2c.h>
145 +#include <linux/i2c-gpio.h>
146 +
147 +#include <asm/mach-types.h>
148 +#include <asm/mach/arch.h>
149 +#include <asm/mach/flash.h>
150 +#include <asm/io.h>
151 +#include <asm/gpio.h>
152 +
153 +static struct flash_platform_data fsg_flash_data = {
154 + .map_name = "cfi_probe",
155 + .width = 2,
156 +};
157 +
158 +static struct resource fsg_flash_resource = {
159 + .flags = IORESOURCE_MEM,
160 +};
161 +
162 +static struct platform_device fsg_flash = {
163 + .name = "IXP4XX-Flash",
164 + .id = 0,
165 + .dev.platform_data = &fsg_flash_data,
166 + .num_resources = 1,
167 + .resource = &fsg_flash_resource,
168 +};
169 +
170 +static struct i2c_gpio_platform_data fsg_i2c_gpio_data = {
171 + .sda_pin = FSG_SDA_PIN,
172 + .scl_pin = FSG_SCL_PIN,
173 +};
174 +
175 +static struct platform_device fsg_i2c_gpio = {
176 + .name = "i2c-gpio",
177 + .id = 0,
178 + .dev = {
179 + .platform_data = &fsg_i2c_gpio_data,
180 + },
181 +};
182 +
183 +static struct i2c_board_info __initdata fsg_i2c_board_info [] = {
184 + {
185 + I2C_BOARD_INFO("rtc-isl1208", 0x6f),
186 + },
187 +};
188 +
189 +static struct resource fsg_uart_resources[] = {
190 + {
191 + .start = IXP4XX_UART1_BASE_PHYS,
192 + .end = IXP4XX_UART1_BASE_PHYS + 0x0fff,
193 + .flags = IORESOURCE_MEM,
194 + },
195 + {
196 + .start = IXP4XX_UART2_BASE_PHYS,
197 + .end = IXP4XX_UART2_BASE_PHYS + 0x0fff,
198 + .flags = IORESOURCE_MEM,
199 + }
200 +};
201 +
202 +static struct plat_serial8250_port fsg_uart_data[] = {
203 + {
204 + .mapbase = IXP4XX_UART1_BASE_PHYS,
205 + .membase = (char *)IXP4XX_UART1_BASE_VIRT + REG_OFFSET,
206 + .irq = IRQ_IXP4XX_UART1,
207 + .flags = UPF_BOOT_AUTOCONF | UPF_SKIP_TEST,
208 + .iotype = UPIO_MEM,
209 + .regshift = 2,
210 + .uartclk = IXP4XX_UART_XTAL,
211 + },
212 + {
213 + .mapbase = IXP4XX_UART2_BASE_PHYS,
214 + .membase = (char *)IXP4XX_UART2_BASE_VIRT + REG_OFFSET,
215 + .irq = IRQ_IXP4XX_UART2,
216 + .flags = UPF_BOOT_AUTOCONF | UPF_SKIP_TEST,
217 + .iotype = UPIO_MEM,
218 + .regshift = 2,
219 + .uartclk = IXP4XX_UART_XTAL,
220 + },
221 + { }
222 +};
223 +
224 +static struct platform_device fsg_uart = {
225 + .name = "serial8250",
226 + .id = PLAT8250_DEV_PLATFORM,
227 + .dev.platform_data = fsg_uart_data,
228 + .num_resources = ARRAY_SIZE(fsg_uart_resources),
229 + .resource = fsg_uart_resources,
230 +};
231 +
232 +static struct platform_device fsg_leds = {
233 + .name = "fsg-led",
234 + .id = -1,
235 +};
236 +
237 +/* Built-in 10/100 Ethernet MAC interfaces */
238 +static struct eth_plat_info fsg_plat_eth[] = {
239 + {
240 + .phy = 5,
241 + .rxq = 3,
242 + .txreadyq = 20,
243 + }, {
244 + .phy = 4,
245 + .rxq = 4,
246 + .txreadyq = 21,
247 + }
248 +};
249 +
250 +static struct platform_device fsg_eth[] = {
251 + {
252 + .name = "ixp4xx_eth",
253 + .id = IXP4XX_ETH_NPEB,
254 + .dev.platform_data = fsg_plat_eth,
255 + }, {
256 + .name = "ixp4xx_eth",
257 + .id = IXP4XX_ETH_NPEC,
258 + .dev.platform_data = fsg_plat_eth + 1,
259 + }
260 +};
261 +
262 +static struct platform_device *fsg_devices[] __initdata = {
263 + &fsg_i2c_gpio,
264 + &fsg_flash,
265 + &fsg_leds,
266 + &fsg_eth[0],
267 + &fsg_eth[1],
268 +};
269 +
270 +static void fsg_power_off(void)
271 +{
272 + printk(KERN_INFO "Restarting system.\n");
273 + machine_restart(NULL);
274 +}
275 +
276 +static irqreturn_t fsg_power_handler(int irq, void *dev_id)
277 +{
278 + /* Signal init to do the ctrlaltdel action, this will bypass init if
279 + * it hasn't started and do a kernel_restart.
280 + */
281 + ctrl_alt_del();
282 +
283 + return IRQ_HANDLED;
284 +}
285 +
286 +static irqreturn_t fsg_reset_handler(int irq, void *dev_id)
287 +{
288 + /* This is the paper-clip reset, it shuts the machine down directly.
289 + */
290 + machine_power_off();
291 +
292 + return IRQ_HANDLED;
293 +}
294 +
295 +static void __init fsg_init(void)
296 +{
297 + DECLARE_MAC_BUF(mac_buf);
298 + uint8_t __iomem *f;
299 + int i;
300 +
301 + ixp4xx_sys_init();
302 +
303 + fsg_flash_resource.start = IXP4XX_EXP_BUS_BASE(0);
304 + fsg_flash_resource.end =
305 + IXP4XX_EXP_BUS_BASE(0) + ixp4xx_exp_bus_size - 1;
306 +
307 + *IXP4XX_EXP_CS0 |= IXP4XX_FLASH_WRITABLE;
308 + *IXP4XX_EXP_CS1 = *IXP4XX_EXP_CS0;
309 +
310 + /* Configure CS2 for operation, 8bit and writable */
311 + *IXP4XX_EXP_CS2 = 0xbfff0002;
312 +
313 + i2c_register_board_info(0, fsg_i2c_board_info,
314 + ARRAY_SIZE(fsg_i2c_board_info));
315 +
316 + /* This is only useful on a modified machine, but it is valuable
317 + * to have it first in order to see debug messages, and so that
318 + * it does *not* get removed if platform_add_devices fails!
319 + */
320 + (void)platform_device_register(&fsg_uart);
321 +
322 + platform_add_devices(fsg_devices, ARRAY_SIZE(fsg_devices));
323 +
324 + pm_power_off = fsg_power_off;
325 +
326 + set_irq_type(gpio_to_irq(FSG_RB_GPIO), IRQT_LOW);
327 + if (request_irq(gpio_to_irq(FSG_RB_GPIO), &fsg_reset_handler,
328 + IRQF_DISABLED, "FSG reset button", NULL) < 0) {
329 +
330 + printk(KERN_DEBUG "Reset Button IRQ %d not available\n",
331 + gpio_to_irq(FSG_RB_GPIO));
332 + }
333 +
334 + set_irq_type(gpio_to_irq(FSG_SB_GPIO), IRQT_LOW);
335 + if (request_irq(gpio_to_irq(FSG_SB_GPIO), &fsg_power_handler,
336 + IRQF_DISABLED, "FSG power button", NULL) < 0) {
337 +
338 + printk(KERN_DEBUG "Power Button IRQ %d not available\n",
339 + gpio_to_irq(FSG_SB_GPIO));
340 + }
341 +
342 + /*
343 + * Map in a portion of the flash and read the MAC addresses.
344 + * Since it is stored in BE in the flash itself, we need to
345 + * byteswap it if we're in LE mode.
346 + */
347 + f = ioremap(IXP4XX_EXP_BUS_BASE(0), 0x400000);
348 + if (f) {
349 +#ifdef __ARMEB__
350 + for (i = 0; i < 6; i++) {
351 + fsg_plat_eth[0].hwaddr[i] = readb(f + 0x3C0422 + i);
352 + fsg_plat_eth[1].hwaddr[i] = readb(f + 0x3C043B + i);
353 + }
354 +#else
355 +
356 + /*
357 + Endian-swapped reads from unaligned addresses are
358 + required to extract the two MACs from the big-endian
359 + Redboot config area in flash.
360 + */
361 +
362 + fsg_plat_eth[0].hwaddr[0] = readb(f + 0x3C0421);
363 + fsg_plat_eth[0].hwaddr[1] = readb(f + 0x3C0420);
364 + fsg_plat_eth[0].hwaddr[2] = readb(f + 0x3C0427);
365 + fsg_plat_eth[0].hwaddr[3] = readb(f + 0x3C0426);
366 + fsg_plat_eth[0].hwaddr[4] = readb(f + 0x3C0425);
367 + fsg_plat_eth[0].hwaddr[5] = readb(f + 0x3C0424);
368 +
369 + fsg_plat_eth[1].hwaddr[0] = readb(f + 0x3C0439);
370 + fsg_plat_eth[1].hwaddr[1] = readb(f + 0x3C043F);
371 + fsg_plat_eth[1].hwaddr[2] = readb(f + 0x3C043E);
372 + fsg_plat_eth[1].hwaddr[3] = readb(f + 0x3C043D);
373 + fsg_plat_eth[1].hwaddr[4] = readb(f + 0x3C043C);
374 + fsg_plat_eth[1].hwaddr[5] = readb(f + 0x3C0443);
375 +#endif
376 + iounmap(f);
377 + }
378 + printk(KERN_INFO "FSG: Using MAC address %s for port 0\n",
379 + print_mac(mac_buf, fsg_plat_eth[0].hwaddr));
380 + printk(KERN_INFO "FSG: Using MAC address %s for port 1\n",
381 + print_mac(mac_buf, fsg_plat_eth[1].hwaddr));
382 +
383 +}
384 +
385 +MACHINE_START(FSG, "Freecom FSG-3")
386 + /* Maintainer: www.nslu2-linux.org */
387 + .phys_io = IXP4XX_PERIPHERAL_BASE_PHYS,
388 + .io_pg_offst = ((IXP4XX_PERIPHERAL_BASE_VIRT) >> 18) & 0xfffc,
389 + .map_io = ixp4xx_map_io,
390 + .init_irq = ixp4xx_init_irq,
391 + .timer = &ixp4xx_timer,
392 + .boot_params = 0x0100,
393 + .init_machine = fsg_init,
394 +MACHINE_END
395 +
396 Index: linux-2.6.24/include/asm-arm/arch-ixp4xx/fsg.h
397 ===================================================================
398 --- /dev/null 1970-01-01 00:00:00.000000000 +0000
399 +++ linux-2.6.24/include/asm-arm/arch-ixp4xx/fsg.h 2008-03-20 21:09:12.000000000 +1030
400 @@ -0,0 +1,50 @@
401 +/*
402 + * include/asm-arm/arch-ixp4xx/fsg.h
403 + *
404 + * Freecom FSG-3 platform specific definitions
405 + *
406 + * Author: Rod Whitby <rod@whitby.id.au>
407 + * Author: Tomasz Chmielewski <mangoo@wpkg.org>
408 + * Maintainers: http://www.nslu2-linux.org
409 + *
410 + * Based on coyote.h by
411 + * Copyright 2004 (c) MontaVista, Software, Inc.
412 + *
413 + * This file is licensed under the terms of the GNU General Public
414 + * License version 2. This program is licensed "as is" without any
415 + * warranty of any kind, whether express or implied.
416 + */
417 +
418 +#ifndef __ASM_ARCH_HARDWARE_H__
419 +#error "Do not include this directly, instead #include <asm/hardware.h>"
420 +#endif
421 +
422 +#define FSG_SDA_PIN 12
423 +#define FSG_SCL_PIN 13
424 +
425 +/*
426 + * FSG PCI IRQs
427 + */
428 +#define FSG_PCI_MAX_DEV 3
429 +#define FSG_PCI_IRQ_LINES 3
430 +
431 +
432 +/* PCI controller GPIO to IRQ pin mappings */
433 +#define FSG_PCI_INTA_PIN 6
434 +#define FSG_PCI_INTB_PIN 7
435 +#define FSG_PCI_INTC_PIN 5
436 +
437 +/* Buttons */
438 +
439 +#define FSG_SB_GPIO 4 /* sync button */
440 +#define FSG_RB_GPIO 9 /* reset button */
441 +#define FSG_UB_GPIO 10 /* usb button */
442 +
443 +/* LEDs */
444 +
445 +#define FSG_LED_WLAN_BIT 0
446 +#define FSG_LED_WAN_BIT 1
447 +#define FSG_LED_SATA_BIT 2
448 +#define FSG_LED_USB_BIT 4
449 +#define FSG_LED_RING_BIT 5
450 +#define FSG_LED_SYNC_BIT 7
451 Index: linux-2.6.24/include/asm-arm/arch-ixp4xx/hardware.h
452 ===================================================================
453 --- linux-2.6.24.orig/include/asm-arm/arch-ixp4xx/hardware.h 2008-03-20 21:07:50.000000000 +1030
454 +++ linux-2.6.24/include/asm-arm/arch-ixp4xx/hardware.h 2008-03-20 21:09:12.000000000 +1030
455 @@ -45,5 +45,6 @@
456 #include "nslu2.h"
457 #include "nas100d.h"
458 #include "dsmg600.h"
459 +#include "fsg.h"
460
461 #endif /* _ASM_ARCH_HARDWARE_H */
462 Index: linux-2.6.24/include/asm-arm/arch-ixp4xx/irqs.h
463 ===================================================================
464 --- linux-2.6.24.orig/include/asm-arm/arch-ixp4xx/irqs.h 2008-03-20 21:07:50.000000000 +1030
465 +++ linux-2.6.24/include/asm-arm/arch-ixp4xx/irqs.h 2008-03-20 21:09:12.000000000 +1030
466 @@ -128,4 +128,11 @@
467 #define IRQ_DSMG600_PCI_INTE IRQ_IXP4XX_GPIO7
468 #define IRQ_DSMG600_PCI_INTF IRQ_IXP4XX_GPIO6
469
470 +/*
471 + * Freecom FSG-3 Board IRQs
472 + */
473 +#define IRQ_FSG_PCI_INTA IRQ_IXP4XX_GPIO6
474 +#define IRQ_FSG_PCI_INTB IRQ_IXP4XX_GPIO7
475 +#define IRQ_FSG_PCI_INTC IRQ_IXP4XX_GPIO5
476 +
477 #endif
478 Index: linux-2.6.24/drivers/leds/Kconfig
479 ===================================================================
480 --- linux-2.6.24.orig/drivers/leds/Kconfig 2008-03-20 21:07:50.000000000 +1030
481 +++ linux-2.6.24/drivers/leds/Kconfig 2008-03-20 21:09:12.000000000 +1030
482 @@ -48,6 +48,12 @@
483 particular board must have LEDs and they must be connected
484 to the GPIO lines. If unsure, say Y.
485
486 +config LEDS_FSG
487 + tristate "LED Support for the Freecom FSG-3"
488 + depends on LEDS_CLASS && MACH_FSG
489 + help
490 + This option enables support for the LEDs on the Freecom FSG-3.
491 +
492 config LEDS_TOSA
493 tristate "LED Support for the Sharp SL-6000 series"
494 depends on LEDS_CLASS && PXA_SHARPSL
495 Index: linux-2.6.24/drivers/leds/Makefile
496 ===================================================================
497 --- linux-2.6.24.orig/drivers/leds/Makefile 2008-03-20 21:07:50.000000000 +1030
498 +++ linux-2.6.24/drivers/leds/Makefile 2008-03-20 21:09:56.000000000 +1030
499 @@ -20,6 +20,7 @@
500 obj-$(CONFIG_LEDS_COBALT_RAQ) += leds-cobalt-raq.o
501 obj-$(CONFIG_LEDS_GPIO) += leds-gpio.o
502 obj-$(CONFIG_LEDS_CM_X270) += leds-cm-x270.o
503 +obj-$(CONFIG_LEDS_FSG) += leds-fsg.o
504
505 # LED Triggers
506 obj-$(CONFIG_LEDS_TRIGGER_TIMER) += ledtrig-timer.o
507 Index: linux-2.6.24/drivers/leds/leds-fsg.c
508 ===================================================================
509 --- /dev/null 1970-01-01 00:00:00.000000000 +0000
510 +++ linux-2.6.24/drivers/leds/leds-fsg.c 2008-03-20 21:09:12.000000000 +1030
511 @@ -0,0 +1,261 @@
512 +/*
513 + * LED Driver for the Freecom FSG-3
514 + *
515 + * Copyright (c) 2008 Rod Whitby <rod@whitby.id.au>
516 + *
517 + * Author: Rod Whitby <rod@whitby.id.au>
518 + *
519 + * Based on leds-spitz.c
520 + * Copyright 2005-2006 Openedhand Ltd.
521 + * Author: Richard Purdie <rpurdie@openedhand.com>
522 + *
523 + * This program is free software; you can redistribute it and/or modify
524 + * it under the terms of the GNU General Public License version 2 as
525 + * published by the Free Software Foundation.
526 + *
527 + */
528 +
529 +#include <linux/kernel.h>
530 +#include <linux/init.h>
531 +#include <linux/platform_device.h>
532 +#include <linux/leds.h>
533 +#include <asm/arch/hardware.h>
534 +#include <asm/io.h>
535 +
536 +static short __iomem *latch_address;
537 +static unsigned short latch_value;
538 +
539 +
540 +static void fsg_led_wlan_set(struct led_classdev *led_cdev,
541 + enum led_brightness value)
542 +{
543 + if (value) {
544 + latch_value &= ~(1 << FSG_LED_WLAN_BIT);
545 + *latch_address = latch_value;
546 + } else {
547 + latch_value |= (1 << FSG_LED_WLAN_BIT);
548 + *latch_address = latch_value;
549 + }
550 +}
551 +
552 +static void fsg_led_wan_set(struct led_classdev *led_cdev,
553 + enum led_brightness value)
554 +{
555 + if (value) {
556 + latch_value &= ~(1 << FSG_LED_WAN_BIT);
557 + *latch_address = latch_value;
558 + } else {
559 + latch_value |= (1 << FSG_LED_WAN_BIT);
560 + *latch_address = latch_value;
561 + }
562 +}
563 +
564 +static void fsg_led_sata_set(struct led_classdev *led_cdev,
565 + enum led_brightness value)
566 +{
567 + if (value) {
568 + latch_value &= ~(1 << FSG_LED_SATA_BIT);
569 + *latch_address = latch_value;
570 + } else {
571 + latch_value |= (1 << FSG_LED_SATA_BIT);
572 + *latch_address = latch_value;
573 + }
574 +}
575 +
576 +static void fsg_led_usb_set(struct led_classdev *led_cdev,
577 + enum led_brightness value)
578 +{
579 + if (value) {
580 + latch_value &= ~(1 << FSG_LED_USB_BIT);
581 + *latch_address = latch_value;
582 + } else {
583 + latch_value |= (1 << FSG_LED_USB_BIT);
584 + *latch_address = latch_value;
585 + }
586 +}
587 +
588 +static void fsg_led_sync_set(struct led_classdev *led_cdev,
589 + enum led_brightness value)
590 +{
591 + if (value) {
592 + latch_value &= ~(1 << FSG_LED_SYNC_BIT);
593 + *latch_address = latch_value;
594 + } else {
595 + latch_value |= (1 << FSG_LED_SYNC_BIT);
596 + *latch_address = latch_value;
597 + }
598 +}
599 +
600 +static void fsg_led_ring_set(struct led_classdev *led_cdev,
601 + enum led_brightness value)
602 +{
603 + if (value) {
604 + latch_value &= ~(1 << FSG_LED_RING_BIT);
605 + *latch_address = latch_value;
606 + } else {
607 + latch_value |= (1 << FSG_LED_RING_BIT);
608 + *latch_address = latch_value;
609 + }
610 +}
611 +
612 +
613 +
614 +static struct led_classdev fsg_wlan_led = {
615 + .name = "fsg:blue:wlan",
616 + .brightness_set = fsg_led_wlan_set,
617 +};
618 +
619 +static struct led_classdev fsg_wan_led = {
620 + .name = "fsg:blue:wan",
621 + .brightness_set = fsg_led_wan_set,
622 +};
623 +
624 +static struct led_classdev fsg_sata_led = {
625 + .name = "fsg:blue:sata",
626 + .brightness_set = fsg_led_sata_set,
627 +};
628 +
629 +static struct led_classdev fsg_usb_led = {
630 + .name = "fsg:blue:usb",
631 + .brightness_set = fsg_led_usb_set,
632 +};
633 +
634 +static struct led_classdev fsg_sync_led = {
635 + .name = "fsg:blue:sync",
636 + .brightness_set = fsg_led_sync_set,
637 +};
638 +
639 +static struct led_classdev fsg_ring_led = {
640 + .name = "fsg:blue:ring",
641 + .brightness_set = fsg_led_ring_set,
642 +};
643 +
644 +
645 +
646 +#ifdef CONFIG_PM
647 +static int fsg_led_suspend(struct platform_device *dev, pm_message_t state)
648 +{
649 + led_classdev_suspend(&fsg_wlan_led);
650 + led_classdev_suspend(&fsg_wan_led);
651 + led_classdev_suspend(&fsg_sata_led);
652 + led_classdev_suspend(&fsg_usb_led);
653 + led_classdev_suspend(&fsg_sync_led);
654 + led_classdev_suspend(&fsg_ring_led);
655 + return 0;
656 +}
657 +
658 +static int fsg_led_resume(struct platform_device *dev)
659 +{
660 + led_classdev_resume(&fsg_wlan_led);
661 + led_classdev_resume(&fsg_wan_led);
662 + led_classdev_resume(&fsg_sata_led);
663 + led_classdev_resume(&fsg_usb_led);
664 + led_classdev_resume(&fsg_sync_led);
665 + led_classdev_resume(&fsg_ring_led);
666 + return 0;
667 +}
668 +#endif
669 +
670 +
671 +static int fsg_led_probe(struct platform_device *pdev)
672 +{
673 + int ret;
674 +
675 + ret = led_classdev_register(&pdev->dev, &fsg_wlan_led);
676 + if (ret < 0)
677 + goto failwlan;
678 +
679 + ret = led_classdev_register(&pdev->dev, &fsg_wan_led);
680 + if (ret < 0)
681 + goto failwan;
682 +
683 + ret = led_classdev_register(&pdev->dev, &fsg_sata_led);
684 + if (ret < 0)
685 + goto failsata;
686 +
687 + ret = led_classdev_register(&pdev->dev, &fsg_usb_led);
688 + if (ret < 0)
689 + goto failusb;
690 +
691 + ret = led_classdev_register(&pdev->dev, &fsg_sync_led);
692 + if (ret < 0)
693 + goto failsync;
694 +
695 + ret = led_classdev_register(&pdev->dev, &fsg_ring_led);
696 + if (ret < 0)
697 + goto failring;
698 +
699 + /* Map the LED chip select address space */
700 + latch_address = (unsigned short *) ioremap(IXP4XX_EXP_BUS_BASE(2), 512);
701 + if (!latch_address) {
702 + ret = -ENOMEM;
703 + goto failremap;
704 + }
705 +
706 + latch_value = 0xffff;
707 + *latch_address = latch_value;
708 +
709 + return ret;
710 +
711 + failremap:
712 + led_classdev_unregister(&fsg_ring_led);
713 + failring:
714 + led_classdev_unregister(&fsg_sync_led);
715 + failsync:
716 + led_classdev_unregister(&fsg_usb_led);
717 + failusb:
718 + led_classdev_unregister(&fsg_sata_led);
719 + failsata:
720 + led_classdev_unregister(&fsg_wan_led);
721 + failwan:
722 + led_classdev_unregister(&fsg_wlan_led);
723 + failwlan:
724 +
725 + return ret;
726 +}
727 +
728 +static int fsg_led_remove(struct platform_device *pdev)
729 +{
730 + iounmap(latch_address);
731 +
732 + led_classdev_unregister(&fsg_wlan_led);
733 + led_classdev_unregister(&fsg_wan_led);
734 + led_classdev_unregister(&fsg_sata_led);
735 + led_classdev_unregister(&fsg_usb_led);
736 + led_classdev_unregister(&fsg_sync_led);
737 + led_classdev_unregister(&fsg_ring_led);
738 +
739 + return 0;
740 +}
741 +
742 +
743 +static struct platform_driver fsg_led_driver = {
744 + .probe = fsg_led_probe,
745 + .remove = fsg_led_remove,
746 +#ifdef CONFIG_PM
747 + .suspend = fsg_led_suspend,
748 + .resume = fsg_led_resume,
749 +#endif
750 + .driver = {
751 + .name = "fsg-led",
752 + },
753 +};
754 +
755 +
756 +static int __init fsg_led_init(void)
757 +{
758 + return platform_driver_register(&fsg_led_driver);
759 +}
760 +
761 +static void __exit fsg_led_exit(void)
762 +{
763 + platform_driver_unregister(&fsg_led_driver);
764 +}
765 +
766 +
767 +module_init(fsg_led_init);
768 +module_exit(fsg_led_exit);
769 +
770 +MODULE_AUTHOR("Rod Whitby <rod@whitby.id.au>");
771 +MODULE_DESCRIPTION("Freecom FSG-3 LED driver");
772 +MODULE_LICENSE("GPL");
This page took 0.075834 seconds and 5 git commands to generate.