diff -pNaur -X b/Documentation/dontdiff a/arch/arm/mach-omap1/board-palmte.c b/arch/arm/mach-omap1/board-palmte.c --- a/arch/arm/mach-omap1/board-palmte.c 2006-07-16 04:55:47.000000000 +0200 +++ b/arch/arm/mach-omap1/board-palmte.c 2006-07-16 04:58:48.000000000 +0200 @@ -85,9 +85,22 @@ static struct platform_device palmte_lcd .id = -1, }; +static struct omap_backlight_config palmte_backlight_config = { + .default_intensity = 0xa0, +}; + +static struct platform_device palmte_backlight_device = { + .name = "omap-bl", + .id = -1, + .dev = { + .platform_data = &palmte_backlight_config, + }, +}; + static struct platform_device *devices[] __initdata = { &palmte_kp_device, &palmte_lcd_device, + &palmte_backlight_device, }; static struct omap_usb_config palmte_usb_config __initdata = { diff -pNaur -X b/Documentation/dontdiff a/drivers/video/backlight/Kconfig b/drivers/video/backlight/Kconfig --- a/drivers/video/backlight/Kconfig 2006-03-22 18:44:53.000000000 +0100 +++ b/drivers/video/backlight/Kconfig 2006-07-16 05:02:18.000000000 +0200 @@ -58,3 +58,11 @@ config BACKLIGHT_HP680 If you have a HP Jornada 680, say y to enable the backlight driver. +config BACKLIGHT_OMAP + tristate "OMAP LCD Backlight" + depends on BACKLIGHT_DEVICE && (ARCH_OMAP1 || ARCH_OMAP2) + default y + help + This driver controls the LCD backlight level and power + for the PWL module of OMAP processors. Say Y if you want + to use power saving. diff -pNaur -X b/Documentation/dontdiff a/drivers/video/backlight/Makefile b/drivers/video/backlight/Makefile --- a/drivers/video/backlight/Makefile 2006-03-22 18:44:53.000000000 +0100 +++ b/drivers/video/backlight/Makefile 2006-07-16 05:02:24.000000000 +0200 @@ -4,4 +4,5 @@ obj-$(CONFIG_LCD_CLASS_DEVICE) += lc obj-$(CONFIG_BACKLIGHT_CLASS_DEVICE) += backlight.o obj-$(CONFIG_BACKLIGHT_CORGI) += corgi_bl.o obj-$(CONFIG_BACKLIGHT_HP680) += hp680_bl.o +obj-$(CONFIG_BACKLIGHT_OMAP) += omap_bl.o obj-$(CONFIG_SHARP_LOCOMO) += locomolcd.o diff -pNaur -X b/Documentation/dontdiff a/drivers/video/backlight/omap_bl.c b/drivers/video/backlight/omap_bl.c --- a/drivers/video/backlight/omap_bl.c 1970-01-01 01:00:00.000000000 +0100 +++ b/drivers/video/backlight/omap_bl.c 2006-07-16 05:02:34.000000000 +0200 @@ -0,0 +1,219 @@ +/* + * drivers/video/backlight/omap_bl.c + * + * Backlight driver for OMAP based boards. + * + * Copyright (c) 2006 Andrzej Zaborowski + * + * This package is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This package is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this package; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +#define OMAPBL_MAX_INTENSITY 0xff + +struct omap_backlight { + int powermode; + int current_intensity; + + spinlock_t lock; + + struct device *dev; + struct omap_backlight_config *pdata; +}; + +static void inline omapbl_send_intensity(int intensity) +{ + omap_writeb(intensity, OMAP_PWL_ENABLE); +} + +static void inline omapbl_send_enable(int enable) +{ + omap_writeb(enable, OMAP_PWL_CLK_ENABLE); +} + +static void omapbl_blank(struct omap_backlight *bl, int mode) +{ + if (bl->pdata->set_power) + bl->pdata->set_power(bl->dev, mode); + + switch (mode) { + case FB_BLANK_NORMAL: + case FB_BLANK_VSYNC_SUSPEND: + case FB_BLANK_HSYNC_SUSPEND: + case FB_BLANK_POWERDOWN: + omapbl_send_intensity(0); + omapbl_send_enable(0); + break; + + case FB_BLANK_UNBLANK: + omapbl_send_intensity(bl->current_intensity); + omapbl_send_enable(1); + break; + } +} + +#ifdef CONFIG_PM +static int omapbl_suspend(struct platform_device *pdev, pm_message_t state) +{ + struct backlight_device *dev = platform_get_drvdata(pdev); + struct omap_backlight *bl = class_get_devdata(&dev->class_dev); + + omapbl_blank(bl, FB_BLANK_POWERDOWN); + return 0; +} + +static int omapbl_resume(struct platform_device *pdev) +{ + struct backlight_device *dev = platform_get_drvdata(pdev); + struct omap_backlight *bl = class_get_devdata(&dev->class_dev); + + omapbl_blank(bl, bl->powermode); + return 0; +} +#else +#define omapbl_suspend NULL +#define omapbl_resume NULL +#endif + +static int omapbl_set_power(struct backlight_device *dev, int state) +{ + struct omap_backlight *bl = class_get_devdata(&dev->class_dev); + + omapbl_blank(bl, state); + bl->powermode = state; + + return 0; +} + +static int omapbl_get_power(struct backlight_device *dev) +{ + struct omap_backlight *bl = class_get_devdata(&dev->class_dev); + return bl->powermode; +} + +static int omapbl_set_intensity(struct backlight_device *dev, int intensity) +{ + struct omap_backlight *bl = class_get_devdata(&dev->class_dev); + + if (intensity > OMAPBL_MAX_INTENSITY || intensity < 0) + return -EPERM; /* Leave current_intensity untouched */ + + if (bl->powermode == FB_BLANK_UNBLANK) + omapbl_send_intensity(intensity); + bl->current_intensity = intensity; + + return 0; +} + +static int omapbl_get_intensity(struct backlight_device *dev) +{ + struct omap_backlight *bl = class_get_devdata(&dev->class_dev); + return bl->current_intensity; +} + +static struct backlight_properties omapbl_data = { + .owner = THIS_MODULE, + .get_power = omapbl_get_power, + .set_power = omapbl_set_power, + .max_brightness = OMAPBL_MAX_INTENSITY, + .get_brightness = omapbl_get_intensity, + .set_brightness = omapbl_set_intensity, +}; + +static int omapbl_probe(struct platform_device *pdev) +{ + struct backlight_device *dev; + struct omap_backlight *bl; + struct omap_backlight_config *pdata = pdev->dev.platform_data; + + omapbl_data.check_fb = pdata->check_fb; + + bl = kzalloc(sizeof(struct omap_backlight), GFP_KERNEL); + if (unlikely(!bl)) + return -ENOMEM; + + dev = backlight_device_register("omap-bl", bl, &omapbl_data); + if (IS_ERR(dev)) { + kfree(bl); + return PTR_ERR(dev); + } + + bl->powermode = FB_BLANK_POWERDOWN; + bl->current_intensity = 0; + bl->lock = SPIN_LOCK_UNLOCKED; + + bl->pdata = pdata; + bl->dev = &pdev->dev; + + platform_set_drvdata(pdev, dev); + + omap_cfg_reg(PWL); /* Conflicts with UART3 */ + + omapbl_set_power(dev, FB_BLANK_UNBLANK); + omapbl_set_intensity(dev, pdata->default_intensity); + + printk(KERN_INFO "OMAP LCD backlight initialised\n"); + + return 0; +} + +static int omapbl_remove(struct platform_device *pdev) +{ + struct backlight_device *dev = platform_get_drvdata(pdev); + struct omap_backlight *bl = class_get_devdata(&dev->class_dev); + + backlight_device_unregister(dev); + kfree(bl); + + return 0; +} + +static struct platform_driver omapbl_driver = { + .probe = omapbl_probe, + .remove = omapbl_remove, + .suspend = omapbl_suspend, + .resume = omapbl_resume, + .driver = { + .name = "omap-bl", + }, +}; + +static int __init omapbl_init(void) +{ + return platform_driver_register(&omapbl_driver); +} + +static void __exit omapbl_exit(void) +{ + platform_driver_unregister(&omapbl_driver); +} + +module_init(omapbl_init); +module_exit(omapbl_exit); + +MODULE_AUTHOR("Andrzej Zaborowski "); +MODULE_DESCRIPTION("OMAP LCD Backlight driver"); +MODULE_LICENSE("GPL"); diff -pNaur -X b/Documentation/dontdiff a/drivers/video/omap/lcd_osk.c b/drivers/video/omap/lcd_osk.c --- a/drivers/video/omap/lcd_osk.c 2006-03-22 18:44:53.000000000 +0100 +++ b/drivers/video/omap/lcd_osk.c 2006-07-16 05:03:33.000000000 +0200 @@ -54,10 +54,10 @@ static int osk_panel_enable(void) omap_cfg_reg(PWL); /* Enable PWL unit */ - omap_writeb(0x01, OMAP16XX_PWL_CLK_ENABLE); + omap_writeb(0x01, OMAP_PWL_CLK_ENABLE); /* Set PWL level */ - omap_writeb(0xFF, OMAP16XX_PWL_ENABLE); + omap_writeb(0xFF, OMAP_PWL_ENABLE); /* configure GPIO2 as output */ omap_set_gpio_direction(2, 0); @@ -74,10 +74,10 @@ static void osk_panel_disable(void) DBGENTER(1); /* Set PWL level to zero */ - omap_writeb(0x00, OMAP16XX_PWL_ENABLE); + omap_writeb(0x00, OMAP_PWL_ENABLE); /* Disable PWL unit */ - omap_writeb(0x00, OMAP16XX_PWL_CLK_ENABLE); + omap_writeb(0x00, OMAP_PWL_CLK_ENABLE); /* set GPIO2 low */ omap_set_gpio_dataout(2, 0); diff -pNaur -X b/Documentation/dontdiff a/include/asm-arm/arch-omap/board.h b/include/asm-arm/arch-omap/board.h --- a/include/asm-arm/arch-omap/board.h 2006-03-22 18:45:00.000000000 +0100 +++ b/include/asm-arm/arch-omap/board.h 2006-07-16 05:04:32.000000000 +0200 @@ -95,6 +95,14 @@ struct omap_lcd_config { char ctrl_name[16]; }; +struct device; +struct fb_info; +struct omap_backlight_config { + int default_intensity; + int (*set_power)(struct device *dev, int state); + int (*check_fb)(struct fb_info *fb); +}; + struct omap_fbmem_config { u32 fb_sram_start; u32 fb_sram_size; diff -pNaur -X b/Documentation/dontdiff a/include/asm-arm/arch-omap/hardware.h b/include/asm-arm/arch-omap/hardware.h --- a/include/asm-arm/arch-omap/hardware.h 2006-07-16 04:20:06.000000000 +0200 +++ b/include/asm-arm/arch-omap/hardware.h 2006-07-16 05:05:03.000000000 +0200 @@ -268,6 +268,15 @@ #define OMAP_LPG2_PMR (OMAP_LPG2_BASE + 0x04) /* + * ---------------------------------------------------------------------------- + * Pulse-Width Light + * ---------------------------------------------------------------------------- + */ +#define OMAP_PWL_BASE 0xfffb5800 +#define OMAP_PWL_ENABLE (OMAP_PWL_BASE + 0x00) +#define OMAP_PWL_CLK_ENABLE (OMAP_PWL_BASE + 0x04) + +/* * --------------------------------------------------------------------------- * Processor specific defines * --------------------------------------------------------------------------- diff -pNaur -X b/Documentation/dontdiff a/include/asm-arm/arch-omap/omap16xx.h b/include/asm-arm/arch-omap/omap16xx.h --- a/include/asm-arm/arch-omap/omap16xx.h 2006-03-22 18:45:00.000000000 +0100 +++ b/include/asm-arm/arch-omap/omap16xx.h 2006-07-16 05:05:11.000000000 +0200 @@ -159,15 +159,6 @@ #define UART3_MVR (OMAP_UART3_BASE + 0x50) /* - * ---------------------------------------------------------------------------- - * Pulse-Width Light - * ---------------------------------------------------------------------------- - */ -#define OMAP16XX_PWL_BASE (0xfffb5800) -#define OMAP16XX_PWL_ENABLE (OMAP16XX_PWL_BASE + 0x00) -#define OMAP16XX_PWL_CLK_ENABLE (OMAP16XX_PWL_BASE + 0x04) - -/* * --------------------------------------------------------------------------- * Watchdog timer * ---------------------------------------------------------------------------