diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2011-03-22 13:06:54 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2011-03-22 13:06:54 -0400 |
commit | e77277dfe28baed73b6fd7c66c3fb44580a3dac1 (patch) | |
tree | 0c40be7a4ca9140d86122ed9057fe1573ea91b2d /arch | |
parent | 75ea6358bc7d97630a8edc2b89c930de118cf7eb (diff) | |
parent | 9edb240696bacd53f4331119d2dfd13d4cd4852f (diff) |
Merge branch 'next-samsung' of git://git.fluff.org/bjdooks/linux
* 'next-samsung' of git://git.fluff.org/bjdooks/linux:
ARM: H1940/RX1950: Change default LED triggers
ARM: S3C2442: RX1950: Add support for LED blinking
ARM: S3C2442: RX1950: Retain LEDs state in suspend
ARM: S3C2410: H1940: Fix lcd_power_set function
ARM: S3C2410: H1940: Add battery support
ARM: S3C2410: H1940: Use leds-gpio driver for LEDs managing
ARM: S3C2410: H1940: Make h1940-bluetooth.c compile again
ARM: S3C2410: H1940: Add keys device
Diffstat (limited to 'arch')
-rw-r--r-- | arch/arm/mach-s3c2410/h1940-bluetooth.c | 11 | ||||
-rw-r--r-- | arch/arm/mach-s3c2410/include/mach/h1940.h | 3 | ||||
-rw-r--r-- | arch/arm/mach-s3c2410/mach-h1940.c | 303 | ||||
-rw-r--r-- | arch/arm/mach-s3c2440/mach-rx1950.c | 74 |
4 files changed, 366 insertions, 25 deletions
diff --git a/arch/arm/mach-s3c2410/h1940-bluetooth.c b/arch/arm/mach-s3c2410/h1940-bluetooth.c index 6b86a722a7db..2c126bbca08d 100644 --- a/arch/arm/mach-s3c2410/h1940-bluetooth.c +++ b/arch/arm/mach-s3c2410/h1940-bluetooth.c | |||
@@ -18,12 +18,14 @@ | |||
18 | #include <linux/leds.h> | 18 | #include <linux/leds.h> |
19 | #include <linux/gpio.h> | 19 | #include <linux/gpio.h> |
20 | #include <linux/rfkill.h> | 20 | #include <linux/rfkill.h> |
21 | #include <linux/leds.h> | ||
21 | 22 | ||
22 | #include <mach/regs-gpio.h> | 23 | #include <mach/regs-gpio.h> |
23 | #include <mach/hardware.h> | 24 | #include <mach/hardware.h> |
24 | #include <mach/h1940-latch.h> | 25 | #include <mach/h1940-latch.h> |
26 | #include <mach/h1940.h> | ||
25 | 27 | ||
26 | #define DRV_NAME "h1940-bt" | 28 | #define DRV_NAME "h1940-bt" |
27 | 29 | ||
28 | /* Bluetooth control */ | 30 | /* Bluetooth control */ |
29 | static void h1940bt_enable(int on) | 31 | static void h1940bt_enable(int on) |
@@ -37,6 +39,8 @@ static void h1940bt_enable(int on) | |||
37 | gpio_set_value(S3C2410_GPH(1), 1); | 39 | gpio_set_value(S3C2410_GPH(1), 1); |
38 | mdelay(10); | 40 | mdelay(10); |
39 | gpio_set_value(S3C2410_GPH(1), 0); | 41 | gpio_set_value(S3C2410_GPH(1), 0); |
42 | |||
43 | h1940_led_blink_set(-EINVAL, GPIO_LED_BLINK, NULL, NULL); | ||
40 | } | 44 | } |
41 | else { | 45 | else { |
42 | gpio_set_value(S3C2410_GPH(1), 1); | 46 | gpio_set_value(S3C2410_GPH(1), 1); |
@@ -44,6 +48,8 @@ static void h1940bt_enable(int on) | |||
44 | gpio_set_value(S3C2410_GPH(1), 0); | 48 | gpio_set_value(S3C2410_GPH(1), 0); |
45 | mdelay(10); | 49 | mdelay(10); |
46 | gpio_set_value(H1940_LATCH_BLUETOOTH_POWER, 0); | 50 | gpio_set_value(H1940_LATCH_BLUETOOTH_POWER, 0); |
51 | |||
52 | h1940_led_blink_set(-EINVAL, GPIO_LED_NO_BLINK_LOW, NULL, NULL); | ||
47 | } | 53 | } |
48 | } | 54 | } |
49 | 55 | ||
@@ -85,7 +91,6 @@ static int __devinit h1940bt_probe(struct platform_device *pdev) | |||
85 | s3c_gpio_cfgpin(S3C2410_GPH(3), S3C2410_GPH3_RXD0); | 91 | s3c_gpio_cfgpin(S3C2410_GPH(3), S3C2410_GPH3_RXD0); |
86 | s3c_gpio_setpull(S3C2410_GPH(3), S3C_GPIO_PULL_NONE); | 92 | s3c_gpio_setpull(S3C2410_GPH(3), S3C_GPIO_PULL_NONE); |
87 | 93 | ||
88 | |||
89 | rfk = rfkill_alloc(DRV_NAME, &pdev->dev, RFKILL_TYPE_BLUETOOTH, | 94 | rfk = rfkill_alloc(DRV_NAME, &pdev->dev, RFKILL_TYPE_BLUETOOTH, |
90 | &h1940bt_rfkill_ops, NULL); | 95 | &h1940bt_rfkill_ops, NULL); |
91 | if (!rfk) { | 96 | if (!rfk) { |
@@ -93,8 +98,6 @@ static int __devinit h1940bt_probe(struct platform_device *pdev) | |||
93 | goto err_rfk_alloc; | 98 | goto err_rfk_alloc; |
94 | } | 99 | } |
95 | 100 | ||
96 | rfkill_set_led_trigger_name(rfk, "h1940-bluetooth"); | ||
97 | |||
98 | ret = rfkill_register(rfk); | 101 | ret = rfkill_register(rfk); |
99 | if (ret) | 102 | if (ret) |
100 | goto err_rfkill; | 103 | goto err_rfkill; |
diff --git a/arch/arm/mach-s3c2410/include/mach/h1940.h b/arch/arm/mach-s3c2410/include/mach/h1940.h index 4559784129c0..2aa683c8d3d6 100644 --- a/arch/arm/mach-s3c2410/include/mach/h1940.h +++ b/arch/arm/mach-s3c2410/include/mach/h1940.h | |||
@@ -17,5 +17,8 @@ | |||
17 | #define H1940_SUSPEND_CHECK (0x30080000) | 17 | #define H1940_SUSPEND_CHECK (0x30080000) |
18 | 18 | ||
19 | extern void h1940_pm_return(void); | 19 | extern void h1940_pm_return(void); |
20 | extern int h1940_led_blink_set(unsigned gpio, int state, | ||
21 | unsigned long *delay_on, unsigned long *delay_off); | ||
22 | |||
20 | 23 | ||
21 | #endif /* __ASM_ARCH_H1940_H */ | 24 | #endif /* __ASM_ARCH_H1940_H */ |
diff --git a/arch/arm/mach-s3c2410/mach-h1940.c b/arch/arm/mach-s3c2410/mach-h1940.c index 1e93f176c1de..2a2fa0620133 100644 --- a/arch/arm/mach-s3c2410/mach-h1940.c +++ b/arch/arm/mach-s3c2410/mach-h1940.c | |||
@@ -23,8 +23,15 @@ | |||
23 | #include <linux/platform_device.h> | 23 | #include <linux/platform_device.h> |
24 | #include <linux/io.h> | 24 | #include <linux/io.h> |
25 | #include <linux/gpio.h> | 25 | #include <linux/gpio.h> |
26 | #include <linux/input.h> | ||
27 | #include <linux/gpio_keys.h> | ||
26 | #include <linux/pwm_backlight.h> | 28 | #include <linux/pwm_backlight.h> |
27 | #include <linux/i2c.h> | 29 | #include <linux/i2c.h> |
30 | #include <linux/leds.h> | ||
31 | #include <linux/pda_power.h> | ||
32 | #include <linux/s3c_adc_battery.h> | ||
33 | #include <linux/delay.h> | ||
34 | |||
28 | #include <video/platform_lcd.h> | 35 | #include <video/platform_lcd.h> |
29 | 36 | ||
30 | #include <linux/mmc/host.h> | 37 | #include <linux/mmc/host.h> |
@@ -203,20 +210,239 @@ static struct s3c2410fb_mach_info h1940_fb_info __initdata = { | |||
203 | .num_displays = 1, | 210 | .num_displays = 1, |
204 | .default_display = 0, | 211 | .default_display = 0, |
205 | 212 | ||
206 | .lpcsel= 0x02, | 213 | .lpcsel = 0x02, |
207 | .gpccon= 0xaa940659, | 214 | .gpccon = 0xaa940659, |
208 | .gpccon_mask= 0xffffffff, | 215 | .gpccon_mask = 0xffffc0f0, |
209 | .gpcup= 0x0000ffff, | 216 | .gpcup = 0x0000ffff, |
210 | .gpcup_mask= 0xffffffff, | 217 | .gpcup_mask = 0xffffffff, |
211 | .gpdcon= 0xaa84aaa0, | 218 | .gpdcon = 0xaa84aaa0, |
212 | .gpdcon_mask= 0xffffffff, | 219 | .gpdcon_mask = 0xffffffff, |
213 | .gpdup= 0x0000faff, | 220 | .gpdup = 0x0000faff, |
214 | .gpdup_mask= 0xffffffff, | 221 | .gpdup_mask = 0xffffffff, |
215 | }; | 222 | }; |
216 | 223 | ||
217 | static struct platform_device h1940_device_leds = { | 224 | static int power_supply_init(struct device *dev) |
218 | .name = "h1940-leds", | 225 | { |
226 | return gpio_request(S3C2410_GPF(2), "cable plugged"); | ||
227 | } | ||
228 | |||
229 | static int h1940_is_ac_online(void) | ||
230 | { | ||
231 | return !gpio_get_value(S3C2410_GPF(2)); | ||
232 | } | ||
233 | |||
234 | static void power_supply_exit(struct device *dev) | ||
235 | { | ||
236 | gpio_free(S3C2410_GPF(2)); | ||
237 | } | ||
238 | |||
239 | static char *h1940_supplicants[] = { | ||
240 | "main-battery", | ||
241 | "backup-battery", | ||
242 | }; | ||
243 | |||
244 | static struct pda_power_pdata power_supply_info = { | ||
245 | .init = power_supply_init, | ||
246 | .is_ac_online = h1940_is_ac_online, | ||
247 | .exit = power_supply_exit, | ||
248 | .supplied_to = h1940_supplicants, | ||
249 | .num_supplicants = ARRAY_SIZE(h1940_supplicants), | ||
250 | }; | ||
251 | |||
252 | static struct resource power_supply_resources[] = { | ||
253 | [0] = { | ||
254 | .name = "ac", | ||
255 | .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_LOWEDGE | | ||
256 | IORESOURCE_IRQ_HIGHEDGE, | ||
257 | .start = IRQ_EINT2, | ||
258 | .end = IRQ_EINT2, | ||
259 | }, | ||
260 | }; | ||
261 | |||
262 | static struct platform_device power_supply = { | ||
263 | .name = "pda-power", | ||
264 | .id = -1, | ||
265 | .dev = { | ||
266 | .platform_data = | ||
267 | &power_supply_info, | ||
268 | }, | ||
269 | .resource = power_supply_resources, | ||
270 | .num_resources = ARRAY_SIZE(power_supply_resources), | ||
271 | }; | ||
272 | |||
273 | static const struct s3c_adc_bat_thresh bat_lut_noac[] = { | ||
274 | { .volt = 4070, .cur = 162, .level = 100}, | ||
275 | { .volt = 4040, .cur = 165, .level = 95}, | ||
276 | { .volt = 4016, .cur = 164, .level = 90}, | ||
277 | { .volt = 3996, .cur = 166, .level = 85}, | ||
278 | { .volt = 3971, .cur = 168, .level = 80}, | ||
279 | { .volt = 3951, .cur = 168, .level = 75}, | ||
280 | { .volt = 3931, .cur = 170, .level = 70}, | ||
281 | { .volt = 3903, .cur = 172, .level = 65}, | ||
282 | { .volt = 3886, .cur = 172, .level = 60}, | ||
283 | { .volt = 3858, .cur = 176, .level = 55}, | ||
284 | { .volt = 3842, .cur = 176, .level = 50}, | ||
285 | { .volt = 3818, .cur = 176, .level = 45}, | ||
286 | { .volt = 3789, .cur = 180, .level = 40}, | ||
287 | { .volt = 3769, .cur = 180, .level = 35}, | ||
288 | { .volt = 3749, .cur = 184, .level = 30}, | ||
289 | { .volt = 3732, .cur = 184, .level = 25}, | ||
290 | { .volt = 3716, .cur = 184, .level = 20}, | ||
291 | { .volt = 3708, .cur = 184, .level = 15}, | ||
292 | { .volt = 3716, .cur = 96, .level = 10}, | ||
293 | { .volt = 3700, .cur = 96, .level = 5}, | ||
294 | { .volt = 3684, .cur = 96, .level = 0}, | ||
295 | }; | ||
296 | |||
297 | static const struct s3c_adc_bat_thresh bat_lut_acin[] = { | ||
298 | { .volt = 4130, .cur = 0, .level = 100}, | ||
299 | { .volt = 3982, .cur = 0, .level = 50}, | ||
300 | { .volt = 3854, .cur = 0, .level = 10}, | ||
301 | { .volt = 3841, .cur = 0, .level = 0}, | ||
302 | }; | ||
303 | |||
304 | int h1940_bat_init(void) | ||
305 | { | ||
306 | int ret; | ||
307 | |||
308 | ret = gpio_request(H1940_LATCH_SM803_ENABLE, "h1940-charger-enable"); | ||
309 | if (ret) | ||
310 | return ret; | ||
311 | gpio_direction_output(H1940_LATCH_SM803_ENABLE, 0); | ||
312 | |||
313 | return 0; | ||
314 | |||
315 | } | ||
316 | |||
317 | void h1940_bat_exit(void) | ||
318 | { | ||
319 | gpio_free(H1940_LATCH_SM803_ENABLE); | ||
320 | } | ||
321 | |||
322 | void h1940_enable_charger(void) | ||
323 | { | ||
324 | gpio_set_value(H1940_LATCH_SM803_ENABLE, 1); | ||
325 | } | ||
326 | |||
327 | void h1940_disable_charger(void) | ||
328 | { | ||
329 | gpio_set_value(H1940_LATCH_SM803_ENABLE, 0); | ||
330 | } | ||
331 | |||
332 | static struct s3c_adc_bat_pdata h1940_bat_cfg = { | ||
333 | .init = h1940_bat_init, | ||
334 | .exit = h1940_bat_exit, | ||
335 | .enable_charger = h1940_enable_charger, | ||
336 | .disable_charger = h1940_disable_charger, | ||
337 | .gpio_charge_finished = S3C2410_GPF(3), | ||
338 | .gpio_inverted = 1, | ||
339 | .lut_noac = bat_lut_noac, | ||
340 | .lut_noac_cnt = ARRAY_SIZE(bat_lut_noac), | ||
341 | .lut_acin = bat_lut_acin, | ||
342 | .lut_acin_cnt = ARRAY_SIZE(bat_lut_acin), | ||
343 | .volt_channel = 0, | ||
344 | .current_channel = 1, | ||
345 | .volt_mult = 4056, | ||
346 | .current_mult = 1893, | ||
347 | .internal_impedance = 200, | ||
348 | .backup_volt_channel = 3, | ||
349 | /* TODO Check backup volt multiplier */ | ||
350 | .backup_volt_mult = 4056, | ||
351 | .backup_volt_min = 0, | ||
352 | .backup_volt_max = 4149288 | ||
353 | }; | ||
354 | |||
355 | static struct platform_device h1940_battery = { | ||
356 | .name = "s3c-adc-battery", | ||
219 | .id = -1, | 357 | .id = -1, |
358 | .dev = { | ||
359 | .parent = &s3c_device_adc.dev, | ||
360 | .platform_data = &h1940_bat_cfg, | ||
361 | }, | ||
362 | }; | ||
363 | |||
364 | DEFINE_SPINLOCK(h1940_blink_spin); | ||
365 | |||
366 | int h1940_led_blink_set(unsigned gpio, int state, | ||
367 | unsigned long *delay_on, unsigned long *delay_off) | ||
368 | { | ||
369 | int blink_gpio, check_gpio1, check_gpio2; | ||
370 | |||
371 | switch (gpio) { | ||
372 | case H1940_LATCH_LED_GREEN: | ||
373 | blink_gpio = S3C2410_GPA(7); | ||
374 | check_gpio1 = S3C2410_GPA(1); | ||
375 | check_gpio2 = S3C2410_GPA(3); | ||
376 | break; | ||
377 | case H1940_LATCH_LED_RED: | ||
378 | blink_gpio = S3C2410_GPA(1); | ||
379 | check_gpio1 = S3C2410_GPA(7); | ||
380 | check_gpio2 = S3C2410_GPA(3); | ||
381 | break; | ||
382 | default: | ||
383 | blink_gpio = S3C2410_GPA(3); | ||
384 | check_gpio1 = S3C2410_GPA(1); | ||
385 | check_gpio1 = S3C2410_GPA(7); | ||
386 | break; | ||
387 | } | ||
388 | |||
389 | if (delay_on && delay_off && !*delay_on && !*delay_off) | ||
390 | *delay_on = *delay_off = 500; | ||
391 | |||
392 | spin_lock(&h1940_blink_spin); | ||
393 | |||
394 | switch (state) { | ||
395 | case GPIO_LED_NO_BLINK_LOW: | ||
396 | case GPIO_LED_NO_BLINK_HIGH: | ||
397 | if (!gpio_get_value(check_gpio1) && | ||
398 | !gpio_get_value(check_gpio2)) | ||
399 | gpio_set_value(H1940_LATCH_LED_FLASH, 0); | ||
400 | gpio_set_value(blink_gpio, 0); | ||
401 | if (gpio_is_valid(gpio)) | ||
402 | gpio_set_value(gpio, state); | ||
403 | break; | ||
404 | case GPIO_LED_BLINK: | ||
405 | if (gpio_is_valid(gpio)) | ||
406 | gpio_set_value(gpio, 0); | ||
407 | gpio_set_value(H1940_LATCH_LED_FLASH, 1); | ||
408 | gpio_set_value(blink_gpio, 1); | ||
409 | break; | ||
410 | } | ||
411 | |||
412 | spin_unlock(&h1940_blink_spin); | ||
413 | |||
414 | return 0; | ||
415 | } | ||
416 | EXPORT_SYMBOL(h1940_led_blink_set); | ||
417 | |||
418 | static struct gpio_led h1940_leds_desc[] = { | ||
419 | { | ||
420 | .name = "Green", | ||
421 | .default_trigger = "main-battery-full", | ||
422 | .gpio = H1940_LATCH_LED_GREEN, | ||
423 | .retain_state_suspended = 1, | ||
424 | }, | ||
425 | { | ||
426 | .name = "Red", | ||
427 | .default_trigger | ||
428 | = "main-battery-charging-blink-full-solid", | ||
429 | .gpio = H1940_LATCH_LED_RED, | ||
430 | .retain_state_suspended = 1, | ||
431 | }, | ||
432 | }; | ||
433 | |||
434 | static struct gpio_led_platform_data h1940_leds_pdata = { | ||
435 | .num_leds = ARRAY_SIZE(h1940_leds_desc), | ||
436 | .leds = h1940_leds_desc, | ||
437 | .gpio_blink_set = h1940_led_blink_set, | ||
438 | }; | ||
439 | |||
440 | static struct platform_device h1940_device_leds = { | ||
441 | .name = "leds-gpio", | ||
442 | .id = -1, | ||
443 | .dev = { | ||
444 | .platform_data = &h1940_leds_pdata, | ||
445 | }, | ||
220 | }; | 446 | }; |
221 | 447 | ||
222 | static struct platform_device h1940_device_bluetooth = { | 448 | static struct platform_device h1940_device_bluetooth = { |
@@ -302,14 +528,14 @@ static struct platform_device h1940_backlight = { | |||
302 | static void h1940_lcd_power_set(struct plat_lcd_data *pd, | 528 | static void h1940_lcd_power_set(struct plat_lcd_data *pd, |
303 | unsigned int power) | 529 | unsigned int power) |
304 | { | 530 | { |
305 | int value; | 531 | int value, retries = 100; |
306 | 532 | ||
307 | if (!power) { | 533 | if (!power) { |
308 | gpio_set_value(S3C2410_GPC(0), 0); | 534 | gpio_set_value(S3C2410_GPC(0), 0); |
309 | /* wait for 3ac */ | 535 | /* wait for 3ac */ |
310 | do { | 536 | do { |
311 | value = gpio_get_value(S3C2410_GPC(6)); | 537 | value = gpio_get_value(S3C2410_GPC(6)); |
312 | } while (value); | 538 | } while (value && retries--); |
313 | 539 | ||
314 | gpio_set_value(H1940_LATCH_LCD_P2, 0); | 540 | gpio_set_value(H1940_LATCH_LCD_P2, 0); |
315 | gpio_set_value(H1940_LATCH_LCD_P3, 0); | 541 | gpio_set_value(H1940_LATCH_LCD_P3, 0); |
@@ -327,6 +553,9 @@ static void h1940_lcd_power_set(struct plat_lcd_data *pd, | |||
327 | gpio_set_value(H1940_LATCH_LCD_P0, 1); | 553 | gpio_set_value(H1940_LATCH_LCD_P0, 1); |
328 | gpio_set_value(H1940_LATCH_LCD_P1, 1); | 554 | gpio_set_value(H1940_LATCH_LCD_P1, 1); |
329 | 555 | ||
556 | gpio_direction_input(S3C2410_GPC(1)); | ||
557 | gpio_direction_input(S3C2410_GPC(4)); | ||
558 | mdelay(10); | ||
330 | s3c_gpio_cfgpin(S3C2410_GPC(1), S3C_GPIO_SFN(2)); | 559 | s3c_gpio_cfgpin(S3C2410_GPC(1), S3C_GPIO_SFN(2)); |
331 | s3c_gpio_cfgpin(S3C2410_GPC(4), S3C_GPIO_SFN(2)); | 560 | s3c_gpio_cfgpin(S3C2410_GPC(4), S3C_GPIO_SFN(2)); |
332 | 561 | ||
@@ -362,7 +591,44 @@ static struct i2c_board_info h1940_i2c_devices[] = { | |||
362 | }, | 591 | }, |
363 | }; | 592 | }; |
364 | 593 | ||
594 | #define DECLARE_BUTTON(p, k, n, w) \ | ||
595 | { \ | ||
596 | .gpio = p, \ | ||
597 | .code = k, \ | ||
598 | .desc = n, \ | ||
599 | .wakeup = w, \ | ||
600 | .active_low = 1, \ | ||
601 | } | ||
602 | |||
603 | static struct gpio_keys_button h1940_buttons[] = { | ||
604 | DECLARE_BUTTON(S3C2410_GPF(0), KEY_POWER, "Power", 1), | ||
605 | DECLARE_BUTTON(S3C2410_GPF(6), KEY_ENTER, "Select", 1), | ||
606 | DECLARE_BUTTON(S3C2410_GPF(7), KEY_RECORD, "Record", 0), | ||
607 | DECLARE_BUTTON(S3C2410_GPG(0), KEY_F11, "Calendar", 0), | ||
608 | DECLARE_BUTTON(S3C2410_GPG(2), KEY_F12, "Contacts", 0), | ||
609 | DECLARE_BUTTON(S3C2410_GPG(3), KEY_MAIL, "Mail", 0), | ||
610 | DECLARE_BUTTON(S3C2410_GPG(6), KEY_LEFT, "Left_arrow", 0), | ||
611 | DECLARE_BUTTON(S3C2410_GPG(7), KEY_HOMEPAGE, "Home", 0), | ||
612 | DECLARE_BUTTON(S3C2410_GPG(8), KEY_RIGHT, "Right_arrow", 0), | ||
613 | DECLARE_BUTTON(S3C2410_GPG(9), KEY_UP, "Up_arrow", 0), | ||
614 | DECLARE_BUTTON(S3C2410_GPG(10), KEY_DOWN, "Down_arrow", 0), | ||
615 | }; | ||
616 | |||
617 | static struct gpio_keys_platform_data h1940_buttons_data = { | ||
618 | .buttons = h1940_buttons, | ||
619 | .nbuttons = ARRAY_SIZE(h1940_buttons), | ||
620 | }; | ||
621 | |||
622 | static struct platform_device h1940_dev_buttons = { | ||
623 | .name = "gpio-keys", | ||
624 | .id = -1, | ||
625 | .dev = { | ||
626 | .platform_data = &h1940_buttons_data, | ||
627 | } | ||
628 | }; | ||
629 | |||
365 | static struct platform_device *h1940_devices[] __initdata = { | 630 | static struct platform_device *h1940_devices[] __initdata = { |
631 | &h1940_dev_buttons, | ||
366 | &s3c_device_ohci, | 632 | &s3c_device_ohci, |
367 | &s3c_device_lcd, | 633 | &s3c_device_lcd, |
368 | &s3c_device_wdt, | 634 | &s3c_device_wdt, |
@@ -379,6 +645,8 @@ static struct platform_device *h1940_devices[] __initdata = { | |||
379 | &h1940_lcd_powerdev, | 645 | &h1940_lcd_powerdev, |
380 | &s3c_device_adc, | 646 | &s3c_device_adc, |
381 | &s3c_device_ts, | 647 | &s3c_device_ts, |
648 | &power_supply, | ||
649 | &h1940_battery, | ||
382 | }; | 650 | }; |
383 | 651 | ||
384 | static void __init h1940_map_io(void) | 652 | static void __init h1940_map_io(void) |
@@ -461,6 +729,15 @@ static void __init h1940_init(void) | |||
461 | 729 | ||
462 | platform_add_devices(h1940_devices, ARRAY_SIZE(h1940_devices)); | 730 | platform_add_devices(h1940_devices, ARRAY_SIZE(h1940_devices)); |
463 | 731 | ||
732 | gpio_request(S3C2410_GPA(1), "Red LED blink"); | ||
733 | gpio_request(S3C2410_GPA(3), "Blue LED blink"); | ||
734 | gpio_request(S3C2410_GPA(7), "Green LED blink"); | ||
735 | gpio_request(H1940_LATCH_LED_FLASH, "LED blink"); | ||
736 | gpio_direction_output(S3C2410_GPA(1), 0); | ||
737 | gpio_direction_output(S3C2410_GPA(3), 0); | ||
738 | gpio_direction_output(S3C2410_GPA(7), 0); | ||
739 | gpio_direction_output(H1940_LATCH_LED_FLASH, 0); | ||
740 | |||
464 | i2c_register_board_info(0, h1940_i2c_devices, | 741 | i2c_register_board_info(0, h1940_i2c_devices, |
465 | ARRAY_SIZE(h1940_i2c_devices)); | 742 | ARRAY_SIZE(h1940_i2c_devices)); |
466 | } | 743 | } |
diff --git a/arch/arm/mach-s3c2440/mach-rx1950.c b/arch/arm/mach-s3c2440/mach-rx1950.c index 86bbc233b31c..27ea95096fe1 100644 --- a/arch/arm/mach-s3c2440/mach-rx1950.c +++ b/arch/arm/mach-s3c2440/mach-rx1950.c | |||
@@ -263,27 +263,78 @@ void rx1950_disable_charger(void) | |||
263 | gpio_direction_output(S3C2410_GPJ(3), 0); | 263 | gpio_direction_output(S3C2410_GPJ(3), 0); |
264 | } | 264 | } |
265 | 265 | ||
266 | DEFINE_SPINLOCK(rx1950_blink_spin); | ||
267 | |||
268 | static int rx1950_led_blink_set(unsigned gpio, int state, | ||
269 | unsigned long *delay_on, unsigned long *delay_off) | ||
270 | { | ||
271 | int blink_gpio, check_gpio; | ||
272 | |||
273 | switch (gpio) { | ||
274 | case S3C2410_GPA(6): | ||
275 | blink_gpio = S3C2410_GPA(4); | ||
276 | check_gpio = S3C2410_GPA(3); | ||
277 | break; | ||
278 | case S3C2410_GPA(7): | ||
279 | blink_gpio = S3C2410_GPA(3); | ||
280 | check_gpio = S3C2410_GPA(4); | ||
281 | break; | ||
282 | default: | ||
283 | return -EINVAL; | ||
284 | break; | ||
285 | } | ||
286 | |||
287 | if (delay_on && delay_off && !*delay_on && !*delay_off) | ||
288 | *delay_on = *delay_off = 500; | ||
289 | |||
290 | spin_lock(&rx1950_blink_spin); | ||
291 | |||
292 | switch (state) { | ||
293 | case GPIO_LED_NO_BLINK_LOW: | ||
294 | case GPIO_LED_NO_BLINK_HIGH: | ||
295 | if (!gpio_get_value(check_gpio)) | ||
296 | gpio_set_value(S3C2410_GPJ(6), 0); | ||
297 | gpio_set_value(blink_gpio, 0); | ||
298 | gpio_set_value(gpio, state); | ||
299 | break; | ||
300 | case GPIO_LED_BLINK: | ||
301 | gpio_set_value(gpio, 0); | ||
302 | gpio_set_value(S3C2410_GPJ(6), 1); | ||
303 | gpio_set_value(blink_gpio, 1); | ||
304 | break; | ||
305 | } | ||
306 | |||
307 | spin_unlock(&rx1950_blink_spin); | ||
308 | |||
309 | return 0; | ||
310 | } | ||
311 | |||
266 | static struct gpio_led rx1950_leds_desc[] = { | 312 | static struct gpio_led rx1950_leds_desc[] = { |
267 | { | 313 | { |
268 | .name = "Green", | 314 | .name = "Green", |
269 | .default_trigger = "main-battery-charging-or-full", | 315 | .default_trigger = "main-battery-full", |
270 | .gpio = S3C2410_GPA(6), | 316 | .gpio = S3C2410_GPA(6), |
317 | .retain_state_suspended = 1, | ||
271 | }, | 318 | }, |
272 | { | 319 | { |
273 | .name = "Red", | 320 | .name = "Red", |
274 | .default_trigger = "main-battery-full", | 321 | .default_trigger |
275 | .gpio = S3C2410_GPA(7), | 322 | = "main-battery-charging-blink-full-solid", |
323 | .gpio = S3C2410_GPA(7), | ||
324 | .retain_state_suspended = 1, | ||
276 | }, | 325 | }, |
277 | { | 326 | { |
278 | .name = "Blue", | 327 | .name = "Blue", |
279 | .default_trigger = "rx1950-acx-mem", | 328 | .default_trigger = "rx1950-acx-mem", |
280 | .gpio = S3C2410_GPA(11), | 329 | .gpio = S3C2410_GPA(11), |
330 | .retain_state_suspended = 1, | ||
281 | }, | 331 | }, |
282 | }; | 332 | }; |
283 | 333 | ||
284 | static struct gpio_led_platform_data rx1950_leds_pdata = { | 334 | static struct gpio_led_platform_data rx1950_leds_pdata = { |
285 | .num_leds = ARRAY_SIZE(rx1950_leds_desc), | 335 | .num_leds = ARRAY_SIZE(rx1950_leds_desc), |
286 | .leds = rx1950_leds_desc, | 336 | .leds = rx1950_leds_desc, |
337 | .gpio_blink_set = rx1950_led_blink_set, | ||
287 | }; | 338 | }; |
288 | 339 | ||
289 | static struct platform_device rx1950_leds = { | 340 | static struct platform_device rx1950_leds = { |
@@ -752,6 +803,13 @@ static void __init rx1950_init_machine(void) | |||
752 | 803 | ||
753 | WARN_ON(gpio_request(S3C2410_GPB(1), "LCD power")); | 804 | WARN_ON(gpio_request(S3C2410_GPB(1), "LCD power")); |
754 | 805 | ||
806 | WARN_ON(gpio_request(S3C2410_GPA(3), "Red blink")); | ||
807 | WARN_ON(gpio_request(S3C2410_GPA(4), "Green blink")); | ||
808 | WARN_ON(gpio_request(S3C2410_GPJ(6), "LED blink")); | ||
809 | gpio_direction_output(S3C2410_GPA(3), 0); | ||
810 | gpio_direction_output(S3C2410_GPA(4), 0); | ||
811 | gpio_direction_output(S3C2410_GPJ(6), 0); | ||
812 | |||
755 | platform_add_devices(rx1950_devices, ARRAY_SIZE(rx1950_devices)); | 813 | platform_add_devices(rx1950_devices, ARRAY_SIZE(rx1950_devices)); |
756 | 814 | ||
757 | i2c_register_board_info(0, rx1950_i2c_devices, | 815 | i2c_register_board_info(0, rx1950_i2c_devices, |