Index: linux-2.6.21.7-armeb/drivers/leds/Kconfig =================================================================== --- linux-2.6.21.7-armeb.orig/drivers/leds/Kconfig 2008-01-05 09:05:31.000000000 +1030 +++ linux-2.6.21.7-armeb/drivers/leds/Kconfig 2008-01-05 09:06:47.000000000 +1030 @@ -49,6 +49,12 @@ particular board must have LEDs and they must be connected to the GPIO lines. If unsure, say Y. +config LEDS_FSG + tristate "LED Support for the Freecom FSG-3" + depends on LEDS_CLASS && MACH_FSG + help + This option enables support for the LEDs on the Freecom FSG-3. + config LEDS_TOSA tristate "LED Support for the Sharp SL-6000 series" depends on LEDS_CLASS && PXA_SHARPSL Index: linux-2.6.21.7-armeb/drivers/leds/Makefile =================================================================== --- linux-2.6.21.7-armeb.orig/drivers/leds/Makefile 2008-01-05 09:05:31.000000000 +1030 +++ linux-2.6.21.7-armeb/drivers/leds/Makefile 2008-01-05 09:06:47.000000000 +1030 @@ -9,6 +9,7 @@ obj-$(CONFIG_LEDS_LOCOMO) += leds-locomo.o obj-$(CONFIG_LEDS_SPITZ) += leds-spitz.o obj-$(CONFIG_LEDS_IXP4XX) += leds-ixp4xx-gpio.o +obj-$(CONFIG_LEDS_FSG) += leds-fsg.o obj-$(CONFIG_LEDS_TOSA) += leds-tosa.o obj-$(CONFIG_LEDS_S3C24XX) += leds-s3c24xx.o obj-$(CONFIG_LEDS_AMS_DELTA) += leds-ams-delta.o Index: linux-2.6.21.7-armeb/drivers/leds/leds-fsg.c =================================================================== --- /dev/null 1970-01-01 00:00:00.000000000 +0000 +++ linux-2.6.21.7-armeb/drivers/leds/leds-fsg.c 2008-01-05 10:04:05.000000000 +1030 @@ -0,0 +1,243 @@ +/* + * LED Driver for the Freecom FSG-3 + * + * Copyright (c) 2008 Rod Whitby + * + * Author: Rod Whitby + * + * Based on leds-spitz.c + * Copyright 2005-2006 Openedhand Ltd. + * Author: Richard Purdie + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + */ + +#include +#include +#include +#include +#include +#include + +static short __iomem *latch_address; +static unsigned short latch_value; + + +static void fsg_led_wlan_set(struct led_classdev *led_cdev, enum led_brightness value) +{ + if (value) { + latch_value &= ~(1 << FSG_LED_WLAN_BIT); + *latch_address = latch_value; + } + else { + latch_value |= (1 << FSG_LED_WLAN_BIT); + *latch_address = latch_value; + } +} + +static void fsg_led_wan_set(struct led_classdev *led_cdev, enum led_brightness value) +{ + if (value) { + latch_value &= ~(1 << FSG_LED_WAN_BIT); + *latch_address = latch_value; + } + else { + latch_value |= (1 << FSG_LED_WAN_BIT); + *latch_address = latch_value; + } +} + +static void fsg_led_sata_set(struct led_classdev *led_cdev, enum led_brightness value) +{ + if (value) { + latch_value &= ~(1 << FSG_LED_SATA_BIT); + *latch_address = latch_value; + } + else { + latch_value |= (1 << FSG_LED_SATA_BIT); + *latch_address = latch_value; + } +} + +static void fsg_led_usb_set(struct led_classdev *led_cdev, enum led_brightness value) +{ + if (value) { + latch_value &= ~(1 << FSG_LED_USB_BIT); + *latch_address = latch_value; + } + else { + latch_value |= (1 << FSG_LED_USB_BIT); + *latch_address = latch_value; + } +} + +static void fsg_led_sync_set(struct led_classdev *led_cdev, enum led_brightness value) +{ + if (value) { + latch_value &= ~(1 << FSG_LED_SYNC_BIT); + *latch_address = latch_value; + } + else { + latch_value |= (1 << FSG_LED_SYNC_BIT); + *latch_address = latch_value; + } +} + +static void fsg_led_ring_set(struct led_classdev *led_cdev, enum led_brightness value) +{ + if (value) { + latch_value &= ~(1 << FSG_LED_RING_BIT); + *latch_address = latch_value; + } + else { + latch_value |= (1 << FSG_LED_RING_BIT); + *latch_address = latch_value; + } +} + + + +static struct led_classdev fsg_wlan_led = { + .name = "fsg:wlan", + .brightness_set = fsg_led_wlan_set, +}; + +static struct led_classdev fsg_wan_led = { + .name = "fsg:wan", + .brightness_set = fsg_led_wan_set, +}; + +static struct led_classdev fsg_sata_led = { + .name = "fsg:sata", + .brightness_set = fsg_led_sata_set, +}; + +static struct led_classdev fsg_usb_led = { + .name = "fsg:usb", + .brightness_set = fsg_led_usb_set, +}; + +static struct led_classdev fsg_sync_led = { + .name = "fsg:sync", + .brightness_set = fsg_led_sync_set, +}; + +static struct led_classdev fsg_ring_led = { + .name = "fsg:ring", + .brightness_set = fsg_led_ring_set, +}; + + + +#ifdef CONFIG_PM +static int fsg_led_suspend(struct platform_device *dev, pm_message_t state) +{ + led_classdev_suspend(&fsg_wlan_led); + led_classdev_suspend(&fsg_wan_led); + led_classdev_suspend(&fsg_sata_led); + led_classdev_suspend(&fsg_usb_led); + led_classdev_suspend(&fsg_sync_led); + led_classdev_suspend(&fsg_ring_led); + return 0; +} + +static int fsg_led_resume(struct platform_device *dev) +{ + led_classdev_resume(&fsg_wlan_led); + led_classdev_resume(&fsg_wan_led); + led_classdev_resume(&fsg_sata_led); + led_classdev_resume(&fsg_usb_led); + led_classdev_resume(&fsg_sync_led); + led_classdev_resume(&fsg_ring_led); + return 0; +} +#endif + + +static int fsg_led_probe(struct platform_device *pdev) +{ + int ret; + + /* FIXME: Need to work out how to handle failure below */ + + ret = led_classdev_register(&pdev->dev, &fsg_wlan_led); + if (ret < 0) + return ret; + + ret = led_classdev_register(&pdev->dev, &fsg_wan_led); + if (ret < 0) + return ret; + + ret = led_classdev_register(&pdev->dev, &fsg_sata_led); + if (ret < 0) + return ret; + + ret = led_classdev_register(&pdev->dev, &fsg_usb_led); + if (ret < 0) + return ret; + + ret = led_classdev_register(&pdev->dev, &fsg_sync_led); + if (ret < 0) + return ret; + + ret = led_classdev_register(&pdev->dev, &fsg_ring_led); + if (ret < 0) + return ret; + + return ret; +} + +static int fsg_led_remove(struct platform_device *pdev) +{ + led_classdev_unregister(&fsg_wlan_led); + led_classdev_unregister(&fsg_wan_led); + led_classdev_unregister(&fsg_sata_led); + led_classdev_unregister(&fsg_usb_led); + led_classdev_unregister(&fsg_sync_led); + led_classdev_unregister(&fsg_ring_led); + + return 0; +} + + +static struct platform_driver fsg_led_driver = { + .probe = fsg_led_probe, + .remove = fsg_led_remove, +#ifdef CONFIG_PM + .suspend = fsg_led_suspend, + .resume = fsg_led_resume, +#endif + .driver = { + .name = "fsg-led", + }, +}; + + +static int __init fsg_led_init(void) +{ + /* Map the LED chip select address space */ + latch_address = (unsigned short *) ioremap(IXP4XX_EXP_BUS_BASE(2), 512); + if (!latch_address) + return -ENOMEM; + latch_value = 0xffff; + *latch_address = latch_value; + /* FIXME: We leak memory if the next line fails */ + return platform_driver_register(&fsg_led_driver); +} + +static void __exit fsg_led_exit(void) +{ + platform_driver_unregister(&fsg_led_driver); + iounmap(latch_address); +} + + +module_init(fsg_led_init); +module_exit(fsg_led_exit); + +MODULE_AUTHOR("Rod Whitby "); +MODULE_DESCRIPTION("Freecom FSG-3 LED driver"); +MODULE_LICENSE("GPL"); Index: linux-2.6.21.7-armeb/arch/arm/mach-ixp4xx/fsg-setup.c =================================================================== --- linux-2.6.21.7-armeb.orig/arch/arm/mach-ixp4xx/fsg-setup.c 2008-01-05 09:06:46.000000000 +1030 +++ linux-2.6.21.7-armeb/arch/arm/mach-ixp4xx/fsg-setup.c 2008-01-05 09:06:47.000000000 +1030 @@ -151,12 +151,18 @@ .dev.platform_data = &fsg_npe_ucode_data, }; +static struct platform_device fsg_leds = { + .name = "fsg-led", + .id = -1, +}; + static struct platform_device *fsg_devices[] __initdata = { &fsg_i2c_controller, &fsg_flash, &mac0, &mac1, &fsg_npe_ucode, + &fsg_leds, }; static void fsg_flash_add(struct mtd_info *mtd)