aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm/mach-pxa/mainstone.c
diff options
context:
space:
mode:
authorRussell King <rmk@dyn-67.arm.linux.org.uk>2007-11-08 06:22:48 -0500
committerRussell King <rmk+kernel@arm.linux.org.uk>2008-01-26 10:07:50 -0500
commit3777f7748a5d10222a55ce88f753a19b16c17032 (patch)
tree3336b45d3c2bdb74a9e6defdd545b56cfb88faba /arch/arm/mach-pxa/mainstone.c
parent03f5b2cee6cabd0400b9f89956c373a0b5d3802a (diff)
[ARM] pxa: mainstone: update backlight to use the backlight infrastructure
Linux has framebuffer backlight support infrastructure which should be used to expose backlight attributes. Mainstone should use it. Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Diffstat (limited to 'arch/arm/mach-pxa/mainstone.c')
-rw-r--r--arch/arm/mach-pxa/mainstone.c60
1 files changed, 50 insertions, 10 deletions
diff --git a/arch/arm/mach-pxa/mainstone.c b/arch/arm/mach-pxa/mainstone.c
index 41d8c6cea62b..a5db00c38f1f 100644
--- a/arch/arm/mach-pxa/mainstone.c
+++ b/arch/arm/mach-pxa/mainstone.c
@@ -23,6 +23,7 @@
23#include <linux/ioport.h> 23#include <linux/ioport.h>
24#include <linux/mtd/mtd.h> 24#include <linux/mtd/mtd.h>
25#include <linux/mtd/partitions.h> 25#include <linux/mtd/partitions.h>
26#include <linux/backlight.h>
26 27
27#include <asm/types.h> 28#include <asm/types.h>
28#include <asm/setup.h> 29#include <asm/setup.h>
@@ -263,21 +264,60 @@ static struct platform_device mst_flash_device[2] = {
263 }, 264 },
264}; 265};
265 266
266static void mainstone_backlight_power(int on) 267#ifdef CONFIG_BACKLIGHT_CLASS_DEVICE
268static int mainstone_backlight_update_status(struct backlight_device *bl)
267{ 269{
268 if (on) { 270 int brightness = bl->props.brightness;
271
272 if (bl->props.power != FB_BLANK_UNBLANK ||
273 bl->props.fb_blank != FB_BLANK_UNBLANK)
274 brightness = 0;
275
276 if (brightness != 0) {
269 pxa_gpio_mode(GPIO16_PWM0_MD); 277 pxa_gpio_mode(GPIO16_PWM0_MD);
270 pxa_set_cken(CKEN_PWM0, 1); 278 pxa_set_cken(CKEN_PWM0, 1);
271 PWM_CTRL0 = 0; 279 }
272 PWM_PWDUTY0 = 0x3ff; 280 PWM_CTRL0 = 0;
273 PWM_PERVAL0 = 0x3ff; 281 PWM_PWDUTY0 = brightness;
274 } else { 282 PWM_PERVAL0 = bl->props.max_brightness;
275 PWM_CTRL0 = 0; 283 if (brightness == 0)
276 PWM_PWDUTY0 = 0x0;
277 PWM_PERVAL0 = 0x3FF;
278 pxa_set_cken(CKEN_PWM0, 0); 284 pxa_set_cken(CKEN_PWM0, 0);
285 return 0; /* pointless return value */
286}
287
288static int mainstone_backlight_get_brightness(struct backlight_device *bl)
289{
290 return PWM_PWDUTY0;
291}
292
293static /*const*/ struct backlight_ops mainstone_backlight_ops = {
294 .update_status = mainstone_backlight_update_status,
295 .get_brightness = mainstone_backlight_get_brightness,
296};
297
298static void __init mainstone_backlight_register(void)
299{
300 struct backlight_device *bl;
301
302 bl = backlight_device_register("mainstone-bl", &pxa_device_fb.dev,
303 NULL, &mainstone_backlight_ops);
304 if (IS_ERR(bl)) {
305 printk(KERN_ERR "mainstone: unable to register backlight: %ld\n",
306 PTR_ERR(bl));
307 return;
279 } 308 }
309
310 /*
311 * broken design - register-then-setup interfaces are
312 * utterly broken by definition.
313 */
314 bl->props.max_brightness = 1023;
315 bl->props.brightness = 1023;
316 backlight_update_status(bl);
280} 317}
318#else
319#define mainstone_backlight_register() do { } while (0)
320#endif
281 321
282static struct pxafb_mode_info toshiba_ltm04c380k_mode = { 322static struct pxafb_mode_info toshiba_ltm04c380k_mode = {
283 .pixclock = 50000, 323 .pixclock = 50000,
@@ -311,7 +351,6 @@ static struct pxafb_mach_info mainstone_pxafb_info = {
311 .num_modes = 1, 351 .num_modes = 1,
312 .lccr0 = LCCR0_Act, 352 .lccr0 = LCCR0_Act,
313 .lccr3 = LCCR3_PCP, 353 .lccr3 = LCCR3_PCP,
314 .pxafb_backlight_power = mainstone_backlight_power,
315}; 354};
316 355
317static int mainstone_mci_init(struct device *dev, irq_handler_t mstone_detect_int, void *data) 356static int mainstone_mci_init(struct device *dev, irq_handler_t mstone_detect_int, void *data)
@@ -473,6 +512,7 @@ static void __init mainstone_init(void)
473 mainstone_pxafb_info.modes = &toshiba_ltm035a776c_mode; 512 mainstone_pxafb_info.modes = &toshiba_ltm035a776c_mode;
474 513
475 set_pxa_fb_info(&mainstone_pxafb_info); 514 set_pxa_fb_info(&mainstone_pxafb_info);
515 mainstone_backlight_register();
476 516
477 pxa_set_mci_info(&mainstone_mci_platform_data); 517 pxa_set_mci_info(&mainstone_mci_platform_data);
478 pxa_set_ficp_info(&mainstone_ficp_platform_data); 518 pxa_set_ficp_info(&mainstone_ficp_platform_data);