Consolidated fsg3 support into a single patch, identical to the one in the nlsu2-linux kernel repository

SVN-Revision: 10151
owl
Rod Whitby 2008-01-09 02:36:02 +00:00
parent 74ba9f2bc8
commit dfdbdac2e5
3 changed files with 130 additions and 431 deletions

View File

@ -1,45 +0,0 @@
Index: linux-2.6.23.12/arch/arm/mach-ixp4xx/fsg-setup.c
===================================================================
--- linux-2.6.23.12.orig/arch/arm/mach-ixp4xx/fsg-setup.c 2008-01-05 13:53:26.000000000 +1030
+++ linux-2.6.23.12/arch/arm/mach-ixp4xx/fsg-setup.c 2008-01-05 13:56:28.000000000 +1030
@@ -94,6 +94,31 @@
.resource = fsg_uart_resources,
};
+ /* Built-in 10/100 Ethernet MAC interfaces */
+ static struct eth_plat_info fsg_plat_eth[] = {
+ {
+ .phy = 5,
+ .rxq = 3,
+ .txreadyq = 20,
+ }, {
+ .phy = 4,
+ .rxq = 4,
+ .txreadyq = 21,
+ }
+ };
+
+ static struct platform_device fsg_eth[] = {
+ {
+ .name = "ixp4xx_eth",
+ .id = IXP4XX_ETH_NPEB,
+ .dev.platform_data = fsg_plat_eth,
+ }, {
+ .name = "ixp4xx_eth",
+ .id = IXP4XX_ETH_NPEC,
+ .dev.platform_data = fsg_plat_eth + 1,
+ }
+ };
+
static struct platform_device fsg_leds = {
.name = "fsg-led",
.id = -1,
@@ -102,6 +127,8 @@
static struct platform_device *fsg_devices[] __initdata = {
&fsg_i2c_controller,
&fsg_flash,
+ &fsg_eth[0],
+ &fsg_eth[1],
&fsg_leds,
};

View File

@ -1,68 +0,0 @@
Index: linux-2.6.23.12/arch/arm/mach-ixp4xx/fsg-setup.c
===================================================================
--- linux-2.6.23.12.orig/arch/arm/mach-ixp4xx/fsg-setup.c 2008-01-05 13:56:28.000000000 +1030
+++ linux-2.6.23.12/arch/arm/mach-ixp4xx/fsg-setup.c 2008-01-05 13:56:43.000000000 +1030
@@ -21,6 +21,7 @@
#include <asm/mach-types.h>
#include <asm/mach/arch.h>
#include <asm/mach/flash.h>
+#include <asm/io.h>
static struct flash_platform_data fsg_flash_data = {
.map_name = "cfi_probe",
@@ -140,6 +141,9 @@
static void __init fsg_init(void)
{
+ uint8_t __iomem *f;
+ int i;
+
ixp4xx_sys_init();
fsg_flash_resource.start = IXP4XX_EXP_BUS_BASE(0);
@@ -161,6 +165,45 @@
(void)platform_device_register(&fsg_uart);
platform_add_devices(fsg_devices, ARRAY_SIZE(fsg_devices));
+
+
+ /*
+ * Map in a portion of the flash and read the MAC addresses.
+ * Since it is stored in BE in the flash itself, we need to
+ * byteswap it if we're in LE mode.
+ */
+ if ((f = ioremap(IXP4XX_EXP_BUS_BASE(0), 0x400000))) {
+#ifdef __ARMEB__
+ for (i = 0; i < 6; i++) {
+ fsg_plat_eth[0].hwaddr[i] = readb(f + 0x3C0422 + i);
+ fsg_plat_eth[1].hwaddr[i] = readb(f + 0x3C043B + i);
+ }
+#else
+ fsg_plat_eth[0].hwaddr[0] = readb(f + 0x3C0422 + 3);
+ fsg_plat_eth[0].hwaddr[1] = readb(f + 0x3C0422 + 2);
+ fsg_plat_eth[0].hwaddr[2] = readb(f + 0x3C0422 + 1);
+ fsg_plat_eth[0].hwaddr[3] = readb(f + 0x3C0422 + 0);
+ fsg_plat_eth[0].hwaddr[4] = readb(f + 0x3C0422 + 7);
+ fsg_plat_eth[0].hwaddr[5] = readb(f + 0x3C0422 + 6);
+
+ fsg_plat_eth[1].hwaddr[0] = readb(f + 0x3C0422 + 3);
+ fsg_plat_eth[1].hwaddr[1] = readb(f + 0x3C0422 + 2);
+ fsg_plat_eth[1].hwaddr[2] = readb(f + 0x3C0422 + 1);
+ fsg_plat_eth[1].hwaddr[3] = readb(f + 0x3C0422 + 0);
+ fsg_plat_eth[1].hwaddr[4] = readb(f + 0x3C0422 + 7);
+ fsg_plat_eth[1].hwaddr[5] = readb(f + 0x3C0422 + 6);
+#endif
+ iounmap(f);
+ }
+ printk(KERN_INFO "FSG: Using MAC address %.2x:%.2x:%.2x:%.2x:%.2x:%.2x for port 0\n",
+ fsg_plat_eth[0].hwaddr[0], fsg_plat_eth[0].hwaddr[1],
+ fsg_plat_eth[0].hwaddr[2], fsg_plat_eth[0].hwaddr[3],
+ fsg_plat_eth[0].hwaddr[4], fsg_plat_eth[0].hwaddr[5]);
+ printk(KERN_INFO "FSG: Using MAC address %.2x:%.2x:%.2x:%.2x:%.2x:%.2x for port 1\n",
+ fsg_plat_eth[1].hwaddr[0], fsg_plat_eth[1].hwaddr[1],
+ fsg_plat_eth[1].hwaddr[2], fsg_plat_eth[1].hwaddr[3],
+ fsg_plat_eth[1].hwaddr[4], fsg_plat_eth[1].hwaddr[5]);
+
}
MACHINE_START(FSG, "Freecom FSG-3")

View File

@ -1,7 +1,7 @@
Index: linux-2.6.23.12/arch/arm/mach-ixp4xx/fsg-pci.c
Index: linux-2.6.23.12-armeb/arch/arm/mach-ixp4xx/fsg-pci.c
===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
+++ linux-2.6.23.12/arch/arm/mach-ixp4xx/fsg-pci.c 2008-01-05 13:32:23.000000000 +1030
+++ linux-2.6.23.12-armeb/arch/arm/mach-ixp4xx/fsg-pci.c 2008-01-09 12:49:07.000000000 +1030
@@ -0,0 +1,71 @@
+/*
+ * arch/arch/mach-ixp4xx/fsg-pci.c
@ -74,11 +74,11 @@ Index: linux-2.6.23.12/arch/arm/mach-ixp4xx/fsg-pci.c
+}
+
+subsys_initcall(fsg_pci_init);
Index: linux-2.6.23.12/arch/arm/mach-ixp4xx/fsg-setup.c
Index: linux-2.6.23.12-armeb/arch/arm/mach-ixp4xx/fsg-setup.c
===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
+++ linux-2.6.23.12/arch/arm/mach-ixp4xx/fsg-setup.c 2008-01-05 14:07:41.000000000 +1030
@@ -0,0 +1,148 @@
+++ linux-2.6.23.12-armeb/arch/arm/mach-ixp4xx/fsg-setup.c 2008-01-09 12:49:07.000000000 +1030
@@ -0,0 +1,220 @@
+/*
+ * arch/arm/mach-ixp4xx/fsg-setup.c
+ *
@ -96,12 +96,13 @@ Index: linux-2.6.23.12/arch/arm/mach-ixp4xx/fsg-setup.c
+#include <linux/serial.h>
+#include <linux/serial_8250.h>
+#include <linux/leds.h>
+#include <linux/mtd/mtd.h>
+#include <linux/reboot.h>
+#include <linux/i2c-gpio.h>
+
+#include <asm/mach-types.h>
+#include <asm/mach/arch.h>
+#include <asm/mach/flash.h>
+#include <asm/io.h>
+
+static struct flash_platform_data fsg_flash_data = {
+ .map_name = "cfi_probe",
@ -120,16 +121,17 @@ Index: linux-2.6.23.12/arch/arm/mach-ixp4xx/fsg-setup.c
+ .resource = &fsg_flash_resource,
+};
+
+static struct ixp4xx_i2c_pins fsg_i2c_gpio_pins = {
+static struct i2c_gpio_platform_data fsg_i2c_gpio_data = {
+ .sda_pin = FSG_SDA_PIN,
+ .scl_pin = FSG_SCL_PIN,
+};
+
+static struct platform_device fsg_i2c_controller = {
+ .name = "IXP4XX-I2C",
+ .id = 0,
+ .dev.platform_data = &fsg_i2c_gpio_pins,
+ .num_resources = 0,
+static struct platform_device fsg_i2c_gpio = {
+ .name = "i2c-gpio",
+ .id = 0,
+ .dev = {
+ .platform_data = &fsg_i2c_gpio_data,
+ },
+};
+
+static struct resource fsg_uart_resources[] = {
@ -180,10 +182,37 @@ Index: linux-2.6.23.12/arch/arm/mach-ixp4xx/fsg-setup.c
+ .id = -1,
+};
+
+/* Built-in 10/100 Ethernet MAC interfaces */
+static struct eth_plat_info fsg_plat_eth[] = {
+ {
+ .phy = 5,
+ .rxq = 3,
+ .txreadyq = 20,
+ }, {
+ .phy = 4,
+ .rxq = 4,
+ .txreadyq = 21,
+ }
+};
+
+static struct platform_device fsg_eth[] = {
+ {
+ .name = "ixp4xx_eth",
+ .id = IXP4XX_ETH_NPEB,
+ .dev.platform_data = fsg_plat_eth,
+ }, {
+ .name = "ixp4xx_eth",
+ .id = IXP4XX_ETH_NPEC,
+ .dev.platform_data = fsg_plat_eth + 1,
+ }
+};
+
+static struct platform_device *fsg_devices[] __initdata = {
+ &fsg_i2c_controller,
+ &fsg_i2c_gpio,
+ &fsg_flash,
+ &fsg_leds,
+ &fsg_eth[0],
+ &fsg_eth[1],
+};
+
+static void fsg_power_off(void)
@ -194,16 +223,19 @@ Index: linux-2.6.23.12/arch/arm/mach-ixp4xx/fsg-setup.c
+
+static void __init fsg_init(void)
+{
+ uint8_t __iomem *f;
+ int i;
+
+ ixp4xx_sys_init();
+
+ pm_power_off = fsg_power_off;
+
+ fsg_flash_resource.start = IXP4XX_EXP_BUS_BASE(0);
+ fsg_flash_resource.end =
+ IXP4XX_EXP_BUS_BASE(0) + ixp4xx_exp_bus_size - 1;
+
+ pm_power_off = fsg_power_off;
+
+ *IXP4XX_EXP_CS0 |= IXP4XX_FLASH_WRITABLE;
+ *IXP4XX_EXP_CS1 = *IXP4XX_EXP_CS0;
+ *IXP4XX_EXP_CS0 |= IXP4XX_FLASH_WRITABLE;
+ *IXP4XX_EXP_CS1 = *IXP4XX_EXP_CS0;
+
+ /* Configure CS2 for operation, 8bit and writable */
+ *IXP4XX_EXP_CS2 = 0xbfff0002;
@ -215,9 +247,49 @@ Index: linux-2.6.23.12/arch/arm/mach-ixp4xx/fsg-setup.c
+ (void)platform_device_register(&fsg_uart);
+
+ platform_add_devices(fsg_devices, ARRAY_SIZE(fsg_devices));
+
+
+ /*
+ * Map in a portion of the flash and read the MAC addresses.
+ * Since it is stored in BE in the flash itself, we need to
+ * byteswap it if we're in LE mode.
+ */
+ if ((f = ioremap(IXP4XX_EXP_BUS_BASE(0), 0x400000))) {
+#ifdef __ARMEB__
+ for (i = 0; i < 6; i++) {
+ fsg_plat_eth[0].hwaddr[i] = readb(f + 0x3C0422 + i);
+ fsg_plat_eth[1].hwaddr[i] = readb(f + 0x3C043B + i);
+ }
+#else
+ fsg_plat_eth[0].hwaddr[0] = readb(f + 0x3C0422 + 3);
+ fsg_plat_eth[0].hwaddr[1] = readb(f + 0x3C0422 + 2);
+ fsg_plat_eth[0].hwaddr[2] = readb(f + 0x3C0422 + 1);
+ fsg_plat_eth[0].hwaddr[3] = readb(f + 0x3C0422 + 0);
+ fsg_plat_eth[0].hwaddr[4] = readb(f + 0x3C0422 + 7);
+ fsg_plat_eth[0].hwaddr[5] = readb(f + 0x3C0422 + 6);
+
+ fsg_plat_eth[1].hwaddr[0] = readb(f + 0x3C0422 + 3);
+ fsg_plat_eth[1].hwaddr[1] = readb(f + 0x3C0422 + 2);
+ fsg_plat_eth[1].hwaddr[2] = readb(f + 0x3C0422 + 1);
+ fsg_plat_eth[1].hwaddr[3] = readb(f + 0x3C0422 + 0);
+ fsg_plat_eth[1].hwaddr[4] = readb(f + 0x3C0422 + 7);
+ fsg_plat_eth[1].hwaddr[5] = readb(f + 0x3C0422 + 6);
+#endif
+ iounmap(f);
+ }
+ printk(KERN_INFO "FSG: Using MAC address %.2x:%.2x:%.2x:%.2x:%.2x:%.2x for port 0\n",
+ fsg_plat_eth[0].hwaddr[0], fsg_plat_eth[0].hwaddr[1],
+ fsg_plat_eth[0].hwaddr[2], fsg_plat_eth[0].hwaddr[3],
+ fsg_plat_eth[0].hwaddr[4], fsg_plat_eth[0].hwaddr[5]);
+ printk(KERN_INFO "FSG: Using MAC address %.2x:%.2x:%.2x:%.2x:%.2x:%.2x for port 1\n",
+ fsg_plat_eth[1].hwaddr[0], fsg_plat_eth[1].hwaddr[1],
+ fsg_plat_eth[1].hwaddr[2], fsg_plat_eth[1].hwaddr[3],
+ fsg_plat_eth[1].hwaddr[4], fsg_plat_eth[1].hwaddr[5]);
+
+}
+
+MACHINE_START(FSG, "Freecom FSG-3")
+ /* Maintainer: www.nslu2-linux.org */
+ .phys_io = IXP4XX_PERIPHERAL_BASE_PHYS,
+ .io_pg_offst = ((IXP4XX_PERIPHERAL_BASE_VIRT) >> 18) & 0xfffc,
+ .map_io = ixp4xx_map_io,
@ -227,10 +299,10 @@ Index: linux-2.6.23.12/arch/arm/mach-ixp4xx/fsg-setup.c
+ .init_machine = fsg_init,
+MACHINE_END
+
Index: linux-2.6.23.12/arch/arm/mach-ixp4xx/Kconfig
Index: linux-2.6.23.12-armeb/arch/arm/mach-ixp4xx/Kconfig
===================================================================
--- linux-2.6.23.12.orig/arch/arm/mach-ixp4xx/Kconfig 2008-01-05 13:29:20.000000000 +1030
+++ linux-2.6.23.12/arch/arm/mach-ixp4xx/Kconfig 2008-01-05 14:07:40.000000000 +1030
--- linux-2.6.23.12-armeb.orig/arch/arm/mach-ixp4xx/Kconfig 2008-01-09 12:49:04.000000000 +1030
+++ linux-2.6.23.12-armeb/arch/arm/mach-ixp4xx/Kconfig 2008-01-09 12:49:07.000000000 +1030
@@ -125,6 +125,15 @@
depends on ARCH_IXDP425 || MACH_IXDP465 || MACH_KIXRP435
default y
@ -247,10 +319,10 @@ Index: linux-2.6.23.12/arch/arm/mach-ixp4xx/Kconfig
#
# Certain registers and IRQs are only enabled if supporting IXP465 CPUs
#
Index: linux-2.6.23.12/arch/arm/mach-ixp4xx/Makefile
Index: linux-2.6.23.12-armeb/arch/arm/mach-ixp4xx/Makefile
===================================================================
--- linux-2.6.23.12.orig/arch/arm/mach-ixp4xx/Makefile 2008-01-05 13:29:20.000000000 +1030
+++ linux-2.6.23.12/arch/arm/mach-ixp4xx/Makefile 2008-01-05 14:07:40.000000000 +1030
--- linux-2.6.23.12-armeb.orig/arch/arm/mach-ixp4xx/Makefile 2008-01-09 12:49:04.000000000 +1030
+++ linux-2.6.23.12-armeb/arch/arm/mach-ixp4xx/Makefile 2008-01-09 12:49:07.000000000 +1030
@@ -15,6 +15,7 @@
obj-pci-$(CONFIG_MACH_DSMG600) += dsmg600-pci.o
obj-pci-$(CONFIG_MACH_GATEWAY7001) += gateway7001-pci.o
@ -259,18 +331,19 @@ Index: linux-2.6.23.12/arch/arm/mach-ixp4xx/Makefile
obj-y += common.o
@@ -28,5 +29,6 @@
@@ -28,6 +29,7 @@
obj-$(CONFIG_MACH_DSMG600) += dsmg600-setup.o dsmg600-power.o
obj-$(CONFIG_MACH_GATEWAY7001) += gateway7001-setup.o
obj-$(CONFIG_MACH_WG302V2) += wg302v2-setup.o
+obj-$(CONFIG_MACH_FSG) += fsg-setup.o fsg-power.o
obj-$(CONFIG_PCI) += $(obj-pci-$(CONFIG_PCI)) common-pci.o
Index: linux-2.6.23.12/include/asm-arm/arch-ixp4xx/fsg.h
obj-$(CONFIG_IXP4XX_QMGR) += ixp4xx_qmgr.o
Index: linux-2.6.23.12-armeb/include/asm-arm/arch-ixp4xx/fsg.h
===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
+++ linux-2.6.23.12/include/asm-arm/arch-ixp4xx/fsg.h 2008-01-05 14:08:23.000000000 +1030
@@ -0,0 +1,58 @@
+++ linux-2.6.23.12-armeb/include/asm-arm/arch-ixp4xx/fsg.h 2008-01-09 12:49:07.000000000 +1030
@@ -0,0 +1,74 @@
+/*
+ * include/asm-arm/arch-ixp4xx/fsg.h
+ *
@ -323,16 +396,32 @@ Index: linux-2.6.23.12/include/asm-arm/arch-ixp4xx/fsg.h
+
+/* LEDs */
+
+#define FSG_LED_WLAN_BIT 0
+#define FSG_LED_WAN_BIT 1
+#define FSG_LED_SATA_BIT 2
+#define FSG_LED_USB_BIT 4
+#define FSG_LED_RING_BIT 5
+#define FSG_LED_SYNC_BIT 7
Index: linux-2.6.23.12/include/asm-arm/arch-ixp4xx/hardware.h
+#define FSG_LED_RING_GPIO 0
+#define FSG_LED_SYNC_GPIO 1
+#define FSG_LED_USB_GPIO 2
+#define FSG_LED_SATA_GPIO 3
+#define FSG_LED_WAN_GPIO 4
+#define FSG_LED_WLAN_GPIO 5
+
+/* %%% REMOVE %%%
+#define FSG_PCI_SLOT0_PIN 6
+#define FSG_PCI_SLOT1_PIN 7
+
+#define FSG_PCI_SLOT0_DEVID 14
+#define FSG_PCI_SLOT1_DEVID 15
+
+#define FSG_IDE_BASE_PHYS IXP4XX_EXP_BUS_BASE(3)
+#define FSG_IDE_BASE_VIRT 0xFFFE1000
+#define FSG_IDE_REGION_SIZE 0x1000
+
+#define FSG_IDE_DATA_PORT 0xFFFE10E0
+#define FSG_IDE_CTRL_PORT 0xFFFE10FC
+#define FSG_IDE_ERROR_PORT 0xFFFE10E2
+*/
Index: linux-2.6.23.12-armeb/include/asm-arm/arch-ixp4xx/hardware.h
===================================================================
--- linux-2.6.23.12.orig/include/asm-arm/arch-ixp4xx/hardware.h 2008-01-05 13:29:20.000000000 +1030
+++ linux-2.6.23.12/include/asm-arm/arch-ixp4xx/hardware.h 2008-01-05 14:07:39.000000000 +1030
--- linux-2.6.23.12-armeb.orig/include/asm-arm/arch-ixp4xx/hardware.h 2008-01-09 12:49:04.000000000 +1030
+++ linux-2.6.23.12-armeb/include/asm-arm/arch-ixp4xx/hardware.h 2008-01-09 12:49:07.000000000 +1030
@@ -45,5 +45,6 @@
#include "nslu2.h"
#include "nas100d.h"
@ -340,10 +429,10 @@ Index: linux-2.6.23.12/include/asm-arm/arch-ixp4xx/hardware.h
+#include "fsg.h"
#endif /* _ASM_ARCH_HARDWARE_H */
Index: linux-2.6.23.12/include/asm-arm/arch-ixp4xx/irqs.h
Index: linux-2.6.23.12-armeb/include/asm-arm/arch-ixp4xx/irqs.h
===================================================================
--- linux-2.6.23.12.orig/include/asm-arm/arch-ixp4xx/irqs.h 2008-01-05 13:29:20.000000000 +1030
+++ linux-2.6.23.12/include/asm-arm/arch-ixp4xx/irqs.h 2008-01-05 13:29:24.000000000 +1030
--- linux-2.6.23.12-armeb.orig/include/asm-arm/arch-ixp4xx/irqs.h 2008-01-09 12:49:04.000000000 +1030
+++ linux-2.6.23.12-armeb/include/asm-arm/arch-ixp4xx/irqs.h 2008-01-09 12:49:07.000000000 +1030
@@ -128,4 +128,17 @@
#define IRQ_DSMG600_PCI_INTE IRQ_IXP4XX_GPIO7
#define IRQ_DSMG600_PCI_INTF IRQ_IXP4XX_GPIO6
@ -362,10 +451,10 @@ Index: linux-2.6.23.12/include/asm-arm/arch-ixp4xx/irqs.h
+*/
+
#endif
Index: linux-2.6.23.12/arch/arm/mach-ixp4xx/fsg-power.c
Index: linux-2.6.23.12-armeb/arch/arm/mach-ixp4xx/fsg-power.c
===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
+++ linux-2.6.23.12/arch/arm/mach-ixp4xx/fsg-power.c 2008-01-05 13:32:27.000000000 +1030
+++ linux-2.6.23.12-armeb/arch/arm/mach-ixp4xx/fsg-power.c 2008-01-09 12:49:07.000000000 +1030
@@ -0,0 +1,87 @@
+/*
+ * arch/arm/mach-ixp4xx/fsg-power.c
@ -454,280 +543,3 @@ Index: linux-2.6.23.12/arch/arm/mach-ixp4xx/fsg-power.c
+MODULE_AUTHOR("Rod Whitby <rod@whitby.id.au>");
+MODULE_DESCRIPTION("FSG Power/Reset driver");
+MODULE_LICENSE("GPL");
Index: linux-2.6.23.12/drivers/leds/Kconfig
===================================================================
--- linux-2.6.23.12.orig/drivers/leds/Kconfig 2008-01-05 13:31:05.000000000 +1030
+++ linux-2.6.23.12/drivers/leds/Kconfig 2008-01-05 13:33:48.000000000 +1030
@@ -48,6 +48,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.23.12/drivers/leds/Makefile
===================================================================
--- linux-2.6.23.12.orig/drivers/leds/Makefile 2008-01-05 13:31:04.000000000 +1030
+++ linux-2.6.23.12/drivers/leds/Makefile 2008-01-05 13:33:21.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.23.12/drivers/leds/leds-fsg.c
===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
+++ linux-2.6.23.12/drivers/leds/leds-fsg.c 2008-01-05 13:31:52.000000000 +1030
@@ -0,0 +1,243 @@
+/*
+ * LED Driver for the Freecom FSG-3
+ *
+ * Copyright (c) 2008 Rod Whitby <rod@whitby.id.au>
+ *
+ * Author: Rod Whitby <rod@whitby.id.au>
+ *
+ * Based on leds-spitz.c
+ * Copyright 2005-2006 Openedhand Ltd.
+ * Author: Richard Purdie <rpurdie@openedhand.com>
+ *
+ * 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 <linux/kernel.h>
+#include <linux/init.h>
+#include <linux/platform_device.h>
+#include <linux/leds.h>
+#include <asm/arch/hardware.h>
+#include <asm/io.h>
+
+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 <rod@whitby.id.au>");
+MODULE_DESCRIPTION("Freecom FSG-3 LED driver");
+MODULE_LICENSE("GPL");