diff options
author | Philipp Zabel <philipp.zabel@gmail.com> | 2008-05-22 09:20:01 -0400 |
---|---|---|
committer | Russell King <rmk+kernel@arm.linux.org.uk> | 2008-07-03 08:25:08 -0400 |
commit | 85847a360ff5012ed7932bb5bb63566ad584e02f (patch) | |
tree | f230dbfc1b488cb558786ef77847f602b8eeb6a8 /arch | |
parent | 43bda1a6d218744382547a2f8be3240d1c3a151b (diff) |
[ARM] 5045/1: magician: use the pwm_bl driver for the LCD backlight
magician has a GPIO that modifies the brightness level additionally to
the PWM duty value. This patch makes use of the pwm_bl notify callback
to present userspace with a single brightness scale.
This gets rid of the pxa_set_cken calls and direct PWM register access.
Signed-off-by: Philipp Zabel <philipp.zabel@gmail.com>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Diffstat (limited to 'arch')
-rw-r--r-- | arch/arm/mach-pxa/magician.c | 68 |
1 files changed, 44 insertions, 24 deletions
diff --git a/arch/arm/mach-pxa/magician.c b/arch/arm/mach-pxa/magician.c index badba064dc04..300caeb21371 100644 --- a/arch/arm/mach-pxa/magician.c +++ b/arch/arm/mach-pxa/magician.c | |||
@@ -25,6 +25,7 @@ | |||
25 | #include <linux/mtd/map.h> | 25 | #include <linux/mtd/map.h> |
26 | #include <linux/mtd/physmap.h> | 26 | #include <linux/mtd/physmap.h> |
27 | #include <linux/pda_power.h> | 27 | #include <linux/pda_power.h> |
28 | #include <linux/pwm_backlight.h> | ||
28 | 29 | ||
29 | #include <asm/gpio.h> | 30 | #include <asm/gpio.h> |
30 | #include <asm/hardware.h> | 31 | #include <asm/hardware.h> |
@@ -39,6 +40,7 @@ | |||
39 | #include <asm/arch/irda.h> | 40 | #include <asm/arch/irda.h> |
40 | #include <asm/arch/ohci.h> | 41 | #include <asm/arch/ohci.h> |
41 | 42 | ||
43 | #include "devices.h" | ||
42 | #include "generic.h" | 44 | #include "generic.h" |
43 | 45 | ||
44 | static unsigned long magician_pin_config[] = { | 46 | static unsigned long magician_pin_config[] = { |
@@ -348,40 +350,58 @@ static struct pxafb_mach_info samsung_info = { | |||
348 | * Backlight | 350 | * Backlight |
349 | */ | 351 | */ |
350 | 352 | ||
351 | static void magician_set_bl_intensity(int intensity) | 353 | static int magician_backlight_init(struct device *dev) |
352 | { | 354 | { |
353 | if (intensity) { | 355 | int ret; |
354 | PWM_CTRL0 = 1; | 356 | |
355 | PWM_PERVAL0 = 0xc8; | 357 | ret = gpio_request(EGPIO_MAGICIAN_BL_POWER, "BL_POWER"); |
356 | if (intensity > 0xc7) { | 358 | if (ret) |
357 | PWM_PWDUTY0 = intensity - 0x48; | 359 | goto err; |
358 | gpio_set_value(EGPIO_MAGICIAN_BL_POWER2, 1); | 360 | ret = gpio_request(EGPIO_MAGICIAN_BL_POWER2, "BL_POWER2"); |
359 | } else { | 361 | if (ret) |
360 | PWM_PWDUTY0 = intensity; | 362 | goto err2; |
361 | gpio_set_value(EGPIO_MAGICIAN_BL_POWER2, 0); | 363 | return 0; |
362 | } | 364 | |
363 | gpio_set_value(EGPIO_MAGICIAN_BL_POWER, 1); | 365 | err2: |
364 | pxa_set_cken(CKEN_PWM0, 1); | 366 | gpio_free(EGPIO_MAGICIAN_BL_POWER); |
367 | err: | ||
368 | return ret; | ||
369 | } | ||
370 | |||
371 | static int magician_backlight_notify(int brightness) | ||
372 | { | ||
373 | gpio_set_value(EGPIO_MAGICIAN_BL_POWER, brightness); | ||
374 | if (brightness >= 200) { | ||
375 | gpio_set_value(EGPIO_MAGICIAN_BL_POWER2, 1); | ||
376 | return brightness - 72; | ||
365 | } else { | 377 | } else { |
366 | /* PWM_PWDUTY0 = intensity; */ | 378 | gpio_set_value(EGPIO_MAGICIAN_BL_POWER2, 0); |
367 | gpio_set_value(EGPIO_MAGICIAN_BL_POWER, 0); | 379 | return brightness; |
368 | pxa_set_cken(CKEN_PWM0, 0); | ||
369 | } | 380 | } |
370 | } | 381 | } |
371 | 382 | ||
372 | static struct generic_bl_info backlight_info = { | 383 | static void magician_backlight_exit(struct device *dev) |
373 | .default_intensity = 0x64, | 384 | { |
374 | .limit_mask = 0x0b, | 385 | gpio_free(EGPIO_MAGICIAN_BL_POWER); |
375 | .max_intensity = 0xc7+0x48, | 386 | gpio_free(EGPIO_MAGICIAN_BL_POWER2); |
376 | .set_bl_intensity = magician_set_bl_intensity, | 387 | } |
388 | |||
389 | static struct platform_pwm_backlight_data backlight_data = { | ||
390 | .pwm_id = 0, | ||
391 | .max_brightness = 272, | ||
392 | .dft_brightness = 100, | ||
393 | .pwm_period_ns = 30923, | ||
394 | .init = magician_backlight_init, | ||
395 | .notify = magician_backlight_notify, | ||
396 | .exit = magician_backlight_exit, | ||
377 | }; | 397 | }; |
378 | 398 | ||
379 | static struct platform_device backlight = { | 399 | static struct platform_device backlight = { |
380 | .name = "generic-bl", | 400 | .name = "pwm-backlight", |
381 | .dev = { | 401 | .dev = { |
382 | .platform_data = &backlight_info, | 402 | .parent = &pxa27x_device_pwm0.dev, |
403 | .platform_data = &backlight_data, | ||
383 | }, | 404 | }, |
384 | .id = -1, | ||
385 | }; | 405 | }; |
386 | 406 | ||
387 | /* | 407 | /* |