diff options
author | Simon Guinot <sguinot@lacie.com> | 2010-10-07 10:38:50 -0400 |
---|---|---|
committer | Nicolas Pitre <nico@fluxnic.net> | 2010-10-07 14:13:23 -0400 |
commit | af9a2d006611124eb1de9d7fee160b25b252ad98 (patch) | |
tree | 3c27cc5fb9c6458e50785fe1ddef9bcd9d0a60cf /arch/arm/mach-kirkwood | |
parent | 2446783250fc12ba9bc39771e04988692742ed90 (diff) |
[ARM] Kirkwood: add LED support for netxbig_v2 boards
Signed-off-by: Simon Guinot <sguinot@lacie.com>
Signed-off-by: Nicolas Pitre <nico@fluxnic.net>
Diffstat (limited to 'arch/arm/mach-kirkwood')
-rw-r--r-- | arch/arm/mach-kirkwood/netxbig_v2-setup.c | 158 |
1 files changed, 133 insertions, 25 deletions
diff --git a/arch/arm/mach-kirkwood/netxbig_v2-setup.c b/arch/arm/mach-kirkwood/netxbig_v2-setup.c index aec528d6081f..d970e1eee37d 100644 --- a/arch/arm/mach-kirkwood/netxbig_v2-setup.c +++ b/arch/arm/mach-kirkwood/netxbig_v2-setup.c | |||
@@ -32,6 +32,7 @@ | |||
32 | #include <asm/mach-types.h> | 32 | #include <asm/mach-types.h> |
33 | #include <asm/mach/arch.h> | 33 | #include <asm/mach/arch.h> |
34 | #include <mach/kirkwood.h> | 34 | #include <mach/kirkwood.h> |
35 | #include <mach/leds-netxbig.h> | ||
35 | #include "common.h" | 36 | #include "common.h" |
36 | #include "mpp.h" | 37 | #include "mpp.h" |
37 | #include "lacie_v2-common.h" | 38 | #include "lacie_v2-common.h" |
@@ -104,7 +105,7 @@ static struct platform_device netxbig_v2_gpio_buttons = { | |||
104 | }; | 105 | }; |
105 | 106 | ||
106 | /***************************************************************************** | 107 | /***************************************************************************** |
107 | * GPIO LEDs | 108 | * GPIO extension LEDs |
108 | ****************************************************************************/ | 109 | ****************************************************************************/ |
109 | 110 | ||
110 | /* | 111 | /* |
@@ -114,19 +115,32 @@ static struct platform_device netxbig_v2_gpio_buttons = { | |||
114 | * - address register : bit [0-2] -> GPIO [47-49] | 115 | * - address register : bit [0-2] -> GPIO [47-49] |
115 | * - data register : bit [0-2] -> GPIO [44-46] | 116 | * - data register : bit [0-2] -> GPIO [44-46] |
116 | * - enable register : GPIO 29 | 117 | * - enable register : GPIO 29 |
117 | * | 118 | */ |
119 | |||
120 | static int netxbig_v2_gpio_ext_addr[] = { 47, 48, 49 }; | ||
121 | static int netxbig_v2_gpio_ext_data[] = { 44, 45, 46 }; | ||
122 | |||
123 | static struct netxbig_gpio_ext netxbig_v2_gpio_ext = { | ||
124 | .addr = netxbig_v2_gpio_ext_addr, | ||
125 | .num_addr = ARRAY_SIZE(netxbig_v2_gpio_ext_addr), | ||
126 | .data = netxbig_v2_gpio_ext_data, | ||
127 | .num_data = ARRAY_SIZE(netxbig_v2_gpio_ext_data), | ||
128 | .enable = 29, | ||
129 | }; | ||
130 | |||
131 | /* | ||
118 | * Address register selection: | 132 | * Address register selection: |
119 | * | 133 | * |
120 | * addr | register | 134 | * addr | register |
121 | * ---------------------------- | 135 | * ---------------------------- |
122 | * 0 | front LED | 136 | * 0 | front LED |
123 | * 1 | front LED brightness | 137 | * 1 | front LED brightness |
124 | * 2 | HDD LED brightness | 138 | * 2 | SATA LED brightness |
125 | * 3 | HDD1 LED | 139 | * 3 | SATA0 LED |
126 | * 4 | HDD2 LED | 140 | * 4 | SATA1 LED |
127 | * 5 | HDD3 LED | 141 | * 5 | SATA2 LED |
128 | * 6 | HDD4 LED | 142 | * 6 | SATA3 LED |
129 | * 7 | HDD5 LED | 143 | * 7 | SATA4 LED |
130 | * | 144 | * |
131 | * Data register configuration: | 145 | * Data register configuration: |
132 | * | 146 | * |
@@ -147,18 +161,109 @@ static struct platform_device netxbig_v2_gpio_buttons = { | |||
147 | * 6 | blink blue on=1 sec and red on=1 sec | 161 | * 6 | blink blue on=1 sec and red on=1 sec |
148 | * 7 | blink blue on=0.5 sec and blue off=2.5 sec | 162 | * 7 | blink blue on=0.5 sec and blue off=2.5 sec |
149 | * | 163 | * |
150 | * data | HDD LED mode | 164 | * data | SATA LED mode |
151 | * ------------------------------------------------- | 165 | * ------------------------------------------------- |
152 | * 0 | fix blue on | 166 | * 0 | fix off |
153 | * 1 | SATA activity blink | 167 | * 1 | SATA activity blink |
154 | * 2 | fix red on | 168 | * 2 | fix red on |
155 | * 3 | blink blue on=1 sec and blue off=1 sec | 169 | * 3 | blink blue on=1 sec and blue off=1 sec |
156 | * 4 | blink red on=1 sec and red off=1 sec | 170 | * 4 | blink red on=1 sec and red off=1 sec |
157 | * 5 | blink blue on=2.5 sec and red on=0.5 sec | 171 | * 5 | blink blue on=2.5 sec and red on=0.5 sec |
158 | * 6 | blink blue on=1 sec and red on=1 sec | 172 | * 6 | blink blue on=1 sec and red on=1 sec |
159 | * 7 | blink blue on=0.5 sec and blue off=2.5 sec | 173 | * 7 | fix blue on |
160 | */ | 174 | */ |
161 | 175 | ||
176 | static int netxbig_v2_red_mled[NETXBIG_LED_MODE_NUM] = { | ||
177 | [NETXBIG_LED_OFF] = 0, | ||
178 | [NETXBIG_LED_ON] = 2, | ||
179 | [NETXBIG_LED_SATA] = NETXBIG_LED_INVALID_MODE, | ||
180 | [NETXBIG_LED_TIMER1] = 4, | ||
181 | [NETXBIG_LED_TIMER2] = NETXBIG_LED_INVALID_MODE, | ||
182 | }; | ||
183 | |||
184 | static int netxbig_v2_blue_pwr_mled[NETXBIG_LED_MODE_NUM] = { | ||
185 | [NETXBIG_LED_OFF] = 0, | ||
186 | [NETXBIG_LED_ON] = 1, | ||
187 | [NETXBIG_LED_SATA] = NETXBIG_LED_INVALID_MODE, | ||
188 | [NETXBIG_LED_TIMER1] = 3, | ||
189 | [NETXBIG_LED_TIMER2] = 7, | ||
190 | }; | ||
191 | |||
192 | static int netxbig_v2_blue_sata_mled[NETXBIG_LED_MODE_NUM] = { | ||
193 | [NETXBIG_LED_OFF] = 0, | ||
194 | [NETXBIG_LED_ON] = 7, | ||
195 | [NETXBIG_LED_SATA] = 1, | ||
196 | [NETXBIG_LED_TIMER1] = 3, | ||
197 | [NETXBIG_LED_TIMER2] = NETXBIG_LED_INVALID_MODE, | ||
198 | }; | ||
199 | |||
200 | static struct netxbig_led_timer netxbig_v2_led_timer[] = { | ||
201 | [0] = { | ||
202 | .delay_on = 500, | ||
203 | .delay_off = 500, | ||
204 | .mode = NETXBIG_LED_TIMER1, | ||
205 | }, | ||
206 | [1] = { | ||
207 | .delay_on = 500, | ||
208 | .delay_off = 1000, | ||
209 | .mode = NETXBIG_LED_TIMER2, | ||
210 | }, | ||
211 | }; | ||
212 | |||
213 | #define NETXBIG_LED(_name, maddr, mval, baddr) \ | ||
214 | { .name = _name, \ | ||
215 | .mode_addr = maddr, \ | ||
216 | .mode_val = mval, \ | ||
217 | .bright_addr = baddr } | ||
218 | |||
219 | static struct netxbig_led net2big_v2_leds_ctrl[] = { | ||
220 | NETXBIG_LED("net2big-v2:blue:power", 0, netxbig_v2_blue_pwr_mled, 1), | ||
221 | NETXBIG_LED("net2big-v2:red:power", 0, netxbig_v2_red_mled, 1), | ||
222 | NETXBIG_LED("net2big-v2:blue:sata0", 3, netxbig_v2_blue_sata_mled, 2), | ||
223 | NETXBIG_LED("net2big-v2:red:sata0", 3, netxbig_v2_red_mled, 2), | ||
224 | NETXBIG_LED("net2big-v2:blue:sata1", 4, netxbig_v2_blue_sata_mled, 2), | ||
225 | NETXBIG_LED("net2big-v2:red:sata1", 4, netxbig_v2_red_mled, 2), | ||
226 | }; | ||
227 | |||
228 | static struct netxbig_led_platform_data net2big_v2_leds_data = { | ||
229 | .gpio_ext = &netxbig_v2_gpio_ext, | ||
230 | .timer = netxbig_v2_led_timer, | ||
231 | .num_timer = ARRAY_SIZE(netxbig_v2_led_timer), | ||
232 | .leds = net2big_v2_leds_ctrl, | ||
233 | .num_leds = ARRAY_SIZE(net2big_v2_leds_ctrl), | ||
234 | }; | ||
235 | |||
236 | static struct netxbig_led net5big_v2_leds_ctrl[] = { | ||
237 | NETXBIG_LED("net5big-v2:blue:power", 0, netxbig_v2_blue_pwr_mled, 1), | ||
238 | NETXBIG_LED("net5big-v2:red:power", 0, netxbig_v2_red_mled, 1), | ||
239 | NETXBIG_LED("net5big-v2:blue:sata0", 3, netxbig_v2_blue_sata_mled, 2), | ||
240 | NETXBIG_LED("net5big-v2:red:sata0", 3, netxbig_v2_red_mled, 2), | ||
241 | NETXBIG_LED("net5big-v2:blue:sata1", 4, netxbig_v2_blue_sata_mled, 2), | ||
242 | NETXBIG_LED("net5big-v2:red:sata1", 4, netxbig_v2_red_mled, 2), | ||
243 | NETXBIG_LED("net5big-v2:blue:sata2", 5, netxbig_v2_blue_sata_mled, 2), | ||
244 | NETXBIG_LED("net5big-v2:red:sata2", 5, netxbig_v2_red_mled, 2), | ||
245 | NETXBIG_LED("net5big-v2:blue:sata3", 6, netxbig_v2_blue_sata_mled, 2), | ||
246 | NETXBIG_LED("net5big-v2:red:sata3", 6, netxbig_v2_red_mled, 2), | ||
247 | NETXBIG_LED("net5big-v2:blue:sata4", 7, netxbig_v2_blue_sata_mled, 2), | ||
248 | NETXBIG_LED("net5big-v2:red:sata5", 7, netxbig_v2_red_mled, 2), | ||
249 | }; | ||
250 | |||
251 | static struct netxbig_led_platform_data net5big_v2_leds_data = { | ||
252 | .gpio_ext = &netxbig_v2_gpio_ext, | ||
253 | .timer = netxbig_v2_led_timer, | ||
254 | .num_timer = ARRAY_SIZE(netxbig_v2_led_timer), | ||
255 | .leds = net5big_v2_leds_ctrl, | ||
256 | .num_leds = ARRAY_SIZE(net5big_v2_leds_ctrl), | ||
257 | }; | ||
258 | |||
259 | static struct platform_device netxbig_v2_leds = { | ||
260 | .name = "leds-netxbig", | ||
261 | .id = -1, | ||
262 | .dev = { | ||
263 | .platform_data = &net2big_v2_leds_data, | ||
264 | }, | ||
265 | }; | ||
266 | |||
162 | /***************************************************************************** | 267 | /***************************************************************************** |
163 | * General Setup | 268 | * General Setup |
164 | ****************************************************************************/ | 269 | ****************************************************************************/ |
@@ -184,18 +289,18 @@ static unsigned int net2big_v2_mpp_config[] __initdata = { | |||
184 | MPP24_GPIO, /* USB mode select */ | 289 | MPP24_GPIO, /* USB mode select */ |
185 | MPP26_GPIO, /* USB device vbus */ | 290 | MPP26_GPIO, /* USB device vbus */ |
186 | MPP28_GPIO, /* USB enable host vbus */ | 291 | MPP28_GPIO, /* USB enable host vbus */ |
187 | MPP29_GPIO, /* CPLD extension ALE */ | 292 | MPP29_GPIO, /* GPIO extension ALE */ |
188 | MPP34_GPIO, /* Rear Push button */ | 293 | MPP34_GPIO, /* Rear Push button */ |
189 | MPP35_GPIO, /* Inhibit switch power-off */ | 294 | MPP35_GPIO, /* Inhibit switch power-off */ |
190 | MPP36_GPIO, /* SATA HDD1 presence */ | 295 | MPP36_GPIO, /* SATA HDD1 presence */ |
191 | MPP37_GPIO, /* SATA HDD2 presence */ | 296 | MPP37_GPIO, /* SATA HDD2 presence */ |
192 | MPP40_GPIO, /* eSATA presence */ | 297 | MPP40_GPIO, /* eSATA presence */ |
193 | MPP44_GPIO, /* CPLD extension (data 0) */ | 298 | MPP44_GPIO, /* GPIO extension (data 0) */ |
194 | MPP45_GPIO, /* CPLD extension (data 1) */ | 299 | MPP45_GPIO, /* GPIO extension (data 1) */ |
195 | MPP46_GPIO, /* CPLD extension (data 2) */ | 300 | MPP46_GPIO, /* GPIO extension (data 2) */ |
196 | MPP47_GPIO, /* CPLD extension (addr 0) */ | 301 | MPP47_GPIO, /* GPIO extension (addr 0) */ |
197 | MPP48_GPIO, /* CPLD extension (addr 1) */ | 302 | MPP48_GPIO, /* GPIO extension (addr 1) */ |
198 | MPP49_GPIO, /* CPLD extension (addr 2) */ | 303 | MPP49_GPIO, /* GPIO extension (addr 2) */ |
199 | 0 | 304 | 0 |
200 | }; | 305 | }; |
201 | 306 | ||
@@ -224,7 +329,7 @@ static unsigned int net5big_v2_mpp_config[] __initdata = { | |||
224 | MPP26_GE1_RXD2, | 329 | MPP26_GE1_RXD2, |
225 | MPP27_GE1_RXD3, | 330 | MPP27_GE1_RXD3, |
226 | MPP28_GPIO, /* USB enable host vbus */ | 331 | MPP28_GPIO, /* USB enable host vbus */ |
227 | MPP29_GPIO, /* CPLD extension ALE */ | 332 | MPP29_GPIO, /* GPIO extension ALE */ |
228 | MPP30_GE1_RXCTL, | 333 | MPP30_GE1_RXCTL, |
229 | MPP31_GE1_RXCLK, | 334 | MPP31_GE1_RXCLK, |
230 | MPP32_GE1_TCLKOUT, | 335 | MPP32_GE1_TCLKOUT, |
@@ -239,12 +344,12 @@ static unsigned int net5big_v2_mpp_config[] __initdata = { | |||
239 | MPP41_GPIO, /* SATA HDD3 power */ | 344 | MPP41_GPIO, /* SATA HDD3 power */ |
240 | MPP42_GPIO, /* SATA HDD4 power */ | 345 | MPP42_GPIO, /* SATA HDD4 power */ |
241 | MPP43_GPIO, /* SATA HDD5 power */ | 346 | MPP43_GPIO, /* SATA HDD5 power */ |
242 | MPP44_GPIO, /* CPLD extension (data 0) */ | 347 | MPP44_GPIO, /* GPIO extension (data 0) */ |
243 | MPP45_GPIO, /* CPLD extension (data 1) */ | 348 | MPP45_GPIO, /* GPIO extension (data 1) */ |
244 | MPP46_GPIO, /* CPLD extension (data 2) */ | 349 | MPP46_GPIO, /* GPIO extension (data 2) */ |
245 | MPP47_GPIO, /* CPLD extension (addr 0) */ | 350 | MPP47_GPIO, /* GPIO extension (addr 0) */ |
246 | MPP48_GPIO, /* CPLD extension (addr 1) */ | 351 | MPP48_GPIO, /* GPIO extension (addr 1) */ |
247 | MPP49_GPIO, /* CPLD extension (addr 2) */ | 352 | MPP49_GPIO, /* GPIO extension (addr 2) */ |
248 | 0 | 353 | 0 |
249 | }; | 354 | }; |
250 | 355 | ||
@@ -280,6 +385,9 @@ static void __init netxbig_v2_init(void) | |||
280 | lacie_v2_register_flash(); | 385 | lacie_v2_register_flash(); |
281 | lacie_v2_register_i2c_devices(); | 386 | lacie_v2_register_i2c_devices(); |
282 | 387 | ||
388 | if (machine_is_net5big_v2()) | ||
389 | netxbig_v2_leds.dev.platform_data = &net5big_v2_leds_data; | ||
390 | platform_device_register(&netxbig_v2_leds); | ||
283 | platform_device_register(&netxbig_v2_gpio_buttons); | 391 | platform_device_register(&netxbig_v2_gpio_buttons); |
284 | 392 | ||
285 | if (gpio_request(NETXBIG_V2_GPIO_POWER_OFF, "power-off") == 0 && | 393 | if (gpio_request(NETXBIG_V2_GPIO_POWER_OFF, "power-off") == 0 && |