[ixp4xx] move the latch-led driver into a separated patch
[openwrt.git] / target / linux / ixp4xx / patches-2.6.25 / 301-avila_led.patch
1 Index: linux-2.6.25.4/arch/arm/mach-ixp4xx/avila-setup.c
2 ===================================================================
3 --- linux-2.6.25.4.orig/arch/arm/mach-ixp4xx/avila-setup.c
4 +++ linux-2.6.25.4/arch/arm/mach-ixp4xx/avila-setup.c
5 @@ -26,6 +26,7 @@
6  # include <linux/eeprom.h>
7  #endif
8  
9 +#include <linux/leds.h>
10  #include <linux/i2c-gpio.h>
11  
12  #include <asm/types.h>
13 @@ -172,6 +173,72 @@ static struct platform_device avila_npec
14         .dev.platform_data      = &avila_npec_data,
15  };
16  
17 +static struct gpio_led avila_gpio_leds[] = {
18 +       {
19 +               .name           = "user",  /* green led */
20 +               .gpio           = AVILA_GW23XX_LED_USER_GPIO,
21 +               .active_low     = 1,
22 +       }
23 +};
24 +
25 +static struct gpio_led_platform_data avila_gpio_leds_data = {
26 +       .num_leds               = 1,
27 +       .leds                   = avila_gpio_leds,
28 +};
29 +
30 +static struct platform_device avila_gpio_leds_device = {
31 +       .name                   = "leds-gpio",
32 +       .id                     = -1,
33 +       .dev.platform_data      = &avila_gpio_leds_data,
34 +};
35 +
36 +static struct latch_led avila_latch_leds[] = {
37 +       {
38 +               .name   = "led0",  /* green led */
39 +               .bit    = 0,
40 +       },
41 +       {
42 +               .name   = "led1",  /* green led */
43 +               .bit    = 1,
44 +       },
45 +       {
46 +               .name   = "led2",  /* green led */
47 +               .bit    = 2,
48 +       },
49 +       {
50 +               .name   = "led3",  /* green led */
51 +               .bit    = 3,
52 +       },
53 +       {
54 +               .name   = "led4",  /* green led */
55 +               .bit    = 4,
56 +       },
57 +       {
58 +               .name   = "led5",  /* green led */
59 +               .bit    = 5,
60 +       },
61 +       {
62 +               .name   = "led6",  /* green led */
63 +               .bit    = 6,
64 +       },
65 +       {
66 +               .name   = "led7",  /* green led */
67 +               .bit    = 7,
68 +       }
69 +};
70 +
71 +static struct latch_led_platform_data avila_latch_leds_data = {
72 +       .num_leds   = 8,
73 +       .leds       = avila_latch_leds,
74 +       .mem        = 0x51000000,
75 +};
76 +
77 +static struct platform_device avila_latch_leds_device = {
78 +       .name     = "leds-latch",
79 +       .id     = -1,
80 +       .dev.platform_data  = &avila_latch_leds_data,
81 +};
82 +
83  static struct platform_device *avila_devices[] __initdata = {
84         &avila_i2c_gpio,
85         &avila_flash,
86 @@ -182,6 +249,8 @@ static void __init avila_gw23xx_setup(vo
87  {
88         platform_device_register(&avila_npeb_device);
89         platform_device_register(&avila_npec_device);
90 +
91 +       platform_device_register(&avila_gpio_leds_device);
92  }
93  
94  #ifdef CONFIG_SENSORS_EEPROM
95 @@ -189,6 +258,8 @@ static void __init avila_gw2342_setup(vo
96  {
97         platform_device_register(&avila_npeb_device);
98         platform_device_register(&avila_npec_device);
99 +
100 +       platform_device_register(&avila_gpio_leds_device);
101  }
102  
103  static void __init avila_gw2345_setup(void)
104 @@ -199,22 +270,30 @@ static void __init avila_gw2345_setup(vo
105  
106         avila_npec_data.phy = 5; /* port 5 of the KS8995 switch */
107         platform_device_register(&avila_npec_device);
108 +
109 +       platform_device_register(&avila_gpio_leds_device);
110  }
111  
112  static void __init avila_gw2347_setup(void)
113  {
114         platform_device_register(&avila_npeb_device);
115 +
116 +       avila_gpio_leds[0].gpio = AVILA_GW23X7_LED_USER_GPIO;
117 +       platform_device_register(&avila_gpio_leds_device);
118  }
119  
120  static void __init avila_gw2348_setup(void)
121  {
122         platform_device_register(&avila_npeb_device);
123         platform_device_register(&avila_npec_device);
124 +
125 +       platform_device_register(&avila_gpio_leds_device);
126  }
127  
128  static void __init avila_gw2353_setup(void)
129  {
130         platform_device_register(&avila_npeb_device);
131 +       platform_device_register(&avila_gpio_leds_device);
132  }
133  
134  static void __init avila_gw2355_setup(void)
135 @@ -225,11 +304,29 @@ static void __init avila_gw2355_setup(vo
136  
137         avila_npec_data.phy = 16;
138         platform_device_register(&avila_npec_device);
139 +
140 +       platform_device_register(&avila_gpio_leds_device);
141 +
142 +       *IXP4XX_EXP_CS4 |= 0xbfff3c03;
143 +       avila_latch_leds[0].name = "RXD";
144 +       avila_latch_leds[1].name = "TXD";
145 +       avila_latch_leds[2].name = "POL";
146 +       avila_latch_leds[3].name = "LNK";
147 +       avila_latch_leds[4].name = "ERR";
148 +       avila_latch_leds_data.num_leds = 5;
149 +       avila_latch_leds_data.mem = 0x54000000;
150 +       platform_device_register(&avila_latch_leds_device);
151  }
152  
153  static void __init avila_gw2357_setup(void)
154  {
155         platform_device_register(&avila_npeb_device);
156 +
157 +       avila_gpio_leds[0].gpio = AVILA_GW23X7_LED_USER_GPIO;
158 +       platform_device_register(&avila_gpio_leds_device);
159 +
160 +       *IXP4XX_EXP_CS1 |= 0xbfff3c03;
161 +       platform_device_register(&avila_latch_leds_device);
162  }
163  
164  static struct avila_board_info avila_boards[] __initdata = {
165 Index: linux-2.6.25.4/include/asm-arm/arch-ixp4xx/avila.h
166 ===================================================================
167 --- linux-2.6.25.4.orig/include/asm-arm/arch-ixp4xx/avila.h
168 +++ linux-2.6.25.4/include/asm-arm/arch-ixp4xx/avila.h
169 @@ -36,4 +36,6 @@
170  #define AVILA_PCI_INTC_PIN     9
171  #define AVILA_PCI_INTD_PIN     8
172  
173 -
174 +/* User LEDs */
175 +#define AVILA_GW23XX_LED_USER_GPIO     3
176 +#define AVILA_GW23X7_LED_USER_GPIO     4