aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm/mach-pxa/magician.c
diff options
context:
space:
mode:
Diffstat (limited to 'arch/arm/mach-pxa/magician.c')
-rw-r--r--arch/arm/mach-pxa/magician.c68
1 files changed, 44 insertions, 24 deletions
diff --git a/arch/arm/mach-pxa/magician.c b/arch/arm/mach-pxa/magician.c
index b94cae48314..01b2fa79021 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>
@@ -40,6 +41,7 @@
40#include <asm/arch/irda.h> 41#include <asm/arch/irda.h>
41#include <asm/arch/ohci.h> 42#include <asm/arch/ohci.h>
42 43
44#include "devices.h"
43#include "generic.h" 45#include "generic.h"
44 46
45static unsigned long magician_pin_config[] = { 47static unsigned long magician_pin_config[] = {
@@ -349,40 +351,58 @@ static struct pxafb_mach_info samsung_info = {
349 * Backlight 351 * Backlight
350 */ 352 */
351 353
352static void magician_set_bl_intensity(int intensity) 354static int magician_backlight_init(struct device *dev)
353{ 355{
354 if (intensity) { 356 int ret;
355 PWM_CTRL0 = 1; 357
356 PWM_PERVAL0 = 0xc8; 358 ret = gpio_request(EGPIO_MAGICIAN_BL_POWER, "BL_POWER");
357 if (intensity > 0xc7) { 359 if (ret)
358 PWM_PWDUTY0 = intensity - 0x48; 360 goto err;
359 gpio_set_value(EGPIO_MAGICIAN_BL_POWER2, 1); 361 ret = gpio_request(EGPIO_MAGICIAN_BL_POWER2, "BL_POWER2");
360 } else { 362 if (ret)
361 PWM_PWDUTY0 = intensity; 363 goto err2;
362 gpio_set_value(EGPIO_MAGICIAN_BL_POWER2, 0); 364 return 0;
363 } 365
364 gpio_set_value(EGPIO_MAGICIAN_BL_POWER, 1); 366err2:
365 pxa_set_cken(CKEN_PWM0, 1); 367 gpio_free(EGPIO_MAGICIAN_BL_POWER);
368err:
369 return ret;
370}
371
372static int magician_backlight_notify(int brightness)
373{
374 gpio_set_value(EGPIO_MAGICIAN_BL_POWER, brightness);
375 if (brightness >= 200) {
376 gpio_set_value(EGPIO_MAGICIAN_BL_POWER2, 1);
377 return brightness - 72;
366 } else { 378 } else {
367 /* PWM_PWDUTY0 = intensity; */ 379 gpio_set_value(EGPIO_MAGICIAN_BL_POWER2, 0);
368 gpio_set_value(EGPIO_MAGICIAN_BL_POWER, 0); 380 return brightness;
369 pxa_set_cken(CKEN_PWM0, 0);
370 } 381 }
371} 382}
372 383
373static struct generic_bl_info backlight_info = { 384static void magician_backlight_exit(struct device *dev)
374 .default_intensity = 0x64, 385{
375 .limit_mask = 0x0b, 386 gpio_free(EGPIO_MAGICIAN_BL_POWER);
376 .max_intensity = 0xc7+0x48, 387 gpio_free(EGPIO_MAGICIAN_BL_POWER2);
377 .set_bl_intensity = magician_set_bl_intensity, 388}
389
390static struct platform_pwm_backlight_data backlight_data = {
391 .pwm_id = 0,
392 .max_brightness = 272,
393 .dft_brightness = 100,
394 .pwm_period_ns = 30923,
395 .init = magician_backlight_init,
396 .notify = magician_backlight_notify,
397 .exit = magician_backlight_exit,
378}; 398};
379 399
380static struct platform_device backlight = { 400static struct platform_device backlight = {
381 .name = "generic-bl", 401 .name = "pwm-backlight",
382 .dev = { 402 .dev = {
383 .platform_data = &backlight_info, 403 .parent = &pxa27x_device_pwm0.dev,
404 .platform_data = &backlight_data,
384 }, 405 },
385 .id = -1,
386}; 406};
387 407
388/* 408/*