]> pilppa.com Git - linux-2.6-omap-h63xx.git/commitdiff
This patch adds backlight control for omap3evm
authorArun C <arunedarath@mistralsolutions.com>
Tue, 1 Jul 2008 11:24:55 +0000 (16:54 +0530)
committerTony Lindgren <tony@atomide.com>
Thu, 3 Jul 2008 10:28:15 +0000 (13:28 +0300)
TWL4030 LEDdriver A(LEDA) is used here to control the LCD backlight

Signed-off-by: Arun C <arunedarath@mistralsolutions.com>
Signed-off-by: Tony Lindgren <tony@atomide.com>
drivers/video/omap/lcd_omap3evm.c

index 5d2ed04150c69a55979873c0aa4e2b72c81d1f15..f5a1477036bc5e6d6a3ad9e6cc907fa3430e87e0 100644 (file)
 #define ENABLE_VPLL2_DEDICATED 0x05
 #define ENABLE_VPLL2_DEV_GRP   0xE0
 
+#define TWL_LED_LEDEN          0x00
+#define TWL_PWMA_PWMAON                0x00
+#define TWL_PWMA_PWMAOFF       0x01
+
+static unsigned int bklight_level;
+
 static int omap3evm_panel_init(struct lcd_panel *panel,
                                struct omapfb_device *fbdev)
 {
@@ -60,10 +66,10 @@ static int omap3evm_panel_init(struct lcd_panel *panel,
        omap_set_gpio_direction(LCD_PANEL_RESB, 0);
        omap_set_gpio_direction(LCD_PANEL_QVGA, 0);
 
-       twl4030_i2c_write_u8(TWL4030_MODULE_PWMA, 0x7F, 0);
-       twl4030_i2c_write_u8(TWL4030_MODULE_PWMA, 0x7F, 1);
-       twl4030_i2c_write_u8(TWL4030_MODULE_PWMB, 0x7F, 0);
-       twl4030_i2c_write_u8(TWL4030_MODULE_PWMB, 0x7F, 1);
+       twl4030_i2c_write_u8(TWL4030_MODULE_LED, 0x11, TWL_LED_LEDEN);
+       twl4030_i2c_write_u8(TWL4030_MODULE_PWMA, 0x01, TWL_PWMA_PWMAON);
+       twl4030_i2c_write_u8(TWL4030_MODULE_PWMA, 0x02, TWL_PWMA_PWMAOFF);
+       bklight_level = 100;
 
        omap_set_gpio_dataout(LCD_PANEL_RESB, 1);
        omap_set_gpio_dataout(LCD_PANEL_INI, 1);
@@ -94,6 +100,28 @@ static unsigned long omap3evm_panel_get_caps(struct lcd_panel *panel)
        return 0;
 }
 
+static int omap3evm_bklight_setlevel(struct lcd_panel *panel,
+                                               unsigned int level)
+{
+       u8 c;
+       if ((level >= 0) && (level <= 100)) {
+               c = (125 * (100 - level)) / 100 + 2;
+               twl4030_i2c_write_u8(TWL4030_MODULE_PWMA, c, TWL_PWMA_PWMAOFF);
+               bklight_level = level;
+       }
+       return 0;
+}
+
+static unsigned int omap3evm_bklight_getlevel(struct lcd_panel *panel)
+{
+       return bklight_level;
+}
+
+static unsigned int omap3evm_bklight_getmaxlevel(struct lcd_panel *panel)
+{
+       return 100;
+}
+
 struct lcd_panel omap3evm_panel = {
        .name           = "omap3evm",
        .config         = OMAP_LCDC_PANEL_TFT | OMAP_LCDC_INV_VSYNC |
@@ -117,6 +145,9 @@ struct lcd_panel omap3evm_panel = {
        .enable         = omap3evm_panel_enable,
        .disable        = omap3evm_panel_disable,
        .get_caps       = omap3evm_panel_get_caps,
+       .set_bklight_level      = omap3evm_bklight_setlevel,
+       .get_bklight_level      = omap3evm_bklight_getlevel,
+       .get_bklight_max        = omap3evm_bklight_getmaxlevel,
 };
 
 static int omap3evm_panel_probe(struct platform_device *pdev)