]> git.kernelconcepts.de Git - karo-tx-uboot.git/commitdiff
karo: tx: get LCD backlight polarity from DT
authorLothar Waßmann <LW@KARO-electronics.de>
Mon, 27 Jan 2014 12:41:19 +0000 (13:41 +0100)
committerLothar Waßmann <LW@KARO-electronics.de>
Tue, 18 Feb 2014 10:58:12 +0000 (11:58 +0100)
board/karo/common/fdt.c
board/karo/common/karo.h
board/karo/tx28/tx28.c
board/karo/tx48/tx48.c
board/karo/tx51/tx51.c
board/karo/tx53/tx53.c
board/karo/tx6/tx6qdl.c

index 979804d45c055a22236d37411de27a294182143b..a6d1951fd1b5f3ab95d308e1b9144c9945b73b52 100644 (file)
@@ -819,3 +819,28 @@ u8 karo_fdt_get_lvds_channels(const void *blob)
        }
        return lvds_chan_mask;
 }
+
+int karo_fdt_get_backlight_polarity(const void *blob)
+{
+       int off = fdt_path_offset(blob, "/backlight");
+       const struct fdt_property *prop;
+       int len;
+
+       if (off < 0) {
+               printf("/backlight node not found in DT\n");
+               return off;
+       }
+
+       prop = fdt_get_property(blob, off, "pwms", &len);
+       if (!prop)
+               printf("'pwms' property not found\n");
+       else
+               debug("'pwms' property has len %d\n", len);
+
+       len /= sizeof(u32);
+       if (prop && len > 3) {
+               const u32 *data = (const u32 *)prop->data;
+               return fdt32_to_cpu(data[3]) == 0;
+       }
+       return 0;
+}
index a28890c743b1b52cde15a0e759930c5693f707b8..fb6d165ec7f8959724da450c8fcb93a18479fcfe 100644 (file)
@@ -34,6 +34,7 @@ int karo_fdt_create_fb_mode(void *blob, const char *name,
 int karo_fdt_get_lcd_bus_width(const void *blob, int default_width);
 int karo_fdt_get_lvds_mapping(const void *blob, int default_mapping);
 u8 karo_fdt_get_lvds_channels(const void *blob);
+int karo_fdt_get_backlight_polarity(const void *blob);
 #else
 static inline void karo_fdt_remove_node(void *blob, const char *node)
 {
@@ -87,6 +88,10 @@ u8 karo_fdt_get_lvds_channels(const void *blob)
 {
        return 0;
 }
+static inline int karo_fdt_get_backlight_polarity(const void *blob)
+{
+       return getenv_yesno("backlight_polarity");
+}
 #endif
 
 static inline const char *karo_get_vmode(const char *video_mode)
index b902fa0c7c0256106728b6351baa99c0fdd336c3..d0045164f200536eaefa80cb46d4e1abd5219671 100644 (file)
@@ -486,6 +486,12 @@ static struct fb_videomode tx28_fb_modes[] = {
 };
 
 static int lcd_enabled = 1;
+static int lcd_bl_polarity;
+
+static int lcd_backlight_polarity(void)
+{
+       return lcd_bl_polarity;
+}
 
 void lcd_enable(void)
 {
@@ -503,7 +509,8 @@ void lcd_enable(void)
                udelay(100);
                gpio_set_value(TX28_LCD_RST_GPIO, 1);
                udelay(300000);
-               gpio_set_value(TX28_LCD_BACKLIGHT_GPIO, 0);
+               gpio_set_value(TX28_LCD_BACKLIGHT_GPIO,
+                       lcd_backlight_polarity());
        }
 }
 
@@ -515,7 +522,8 @@ void lcd_panel_disable(void)
 {
        if (lcd_enabled) {
                debug("Switching LCD off\n");
-               gpio_set_value(TX28_LCD_BACKLIGHT_GPIO, 1);
+               gpio_set_value(TX28_LCD_BACKLIGHT_GPIO,
+                       !lcd_backlight_polarity());
                gpio_set_value(TX28_LCD_RST_GPIO, 0);
                gpio_set_value(TX28_LCD_PWR_GPIO, 0);
        }
@@ -595,6 +603,7 @@ void lcd_ctrl_init(void *lcdbase)
        }
 
        karo_fdt_move_fdt();
+       lcd_bl_polarity = karo_fdt_get_backlight_polarity(working_fdt);
 
        if (video_mode == NULL) {
                debug("Disabling LCD\n");
index 5fcfbd1e18387b17aaf6f65a1fd5d6cd2b67a6d9..e59aa162898bcc92d7d4283227cf211f4436f400 100644 (file)
@@ -534,6 +534,12 @@ short console_col;
 short console_row;
 
 static int lcd_enabled = 1;
+static int lcd_bl_polarity;
+
+static int lcd_backlight_polarity(void)
+{
+       return lcd_bl_polarity;
+}
 
 void lcd_initcolregs(void)
 {
@@ -560,7 +566,8 @@ void lcd_enable(void)
                udelay(100);
                gpio_set_value(TX48_LCD_RST_GPIO, 1);
                udelay(300000);
-               gpio_set_value(TX48_LCD_BACKLIGHT_GPIO, 0);
+               gpio_set_value(TX48_LCD_BACKLIGHT_GPIO,
+                       lcd_backlight_polarity());
        }
 }
 
@@ -595,7 +602,8 @@ void lcd_panel_disable(void)
 {
        if (lcd_enabled) {
                debug("Switching LCD off\n");
-               gpio_set_value(TX48_LCD_BACKLIGHT_GPIO, 1);
+               gpio_set_value(TX48_LCD_BACKLIGHT_GPIO,
+                       !lcd_backlight_polarity());
                gpio_set_value(TX48_LCD_PWR_GPIO, 0);
                gpio_set_value(TX48_LCD_RST_GPIO, 0);
        }
@@ -625,6 +633,7 @@ void lcd_ctrl_init(void *lcdbase)
        }
 
        karo_fdt_move_fdt();
+       lcd_bl_polarity = karo_fdt_get_backlight_polarity(working_fdt);
 
        if (video_mode == NULL) {
                debug("Disabling LCD\n");
index bf289badc585f50da629f23e982f179d05d76131..b04a844ff857d4c32e865179b0eefd39cb74ba6d 100644 (file)
@@ -677,6 +677,12 @@ static struct fb_videomode tx51_fb_modes[] = {
 };
 
 static int lcd_enabled = 1;
+static int lcd_bl_polarity;
+
+static int lcd_backlight_polarity(void)
+{
+       return lcd_bl_polarity;
+}
 
 void lcd_enable(void)
 {
@@ -695,7 +701,8 @@ void lcd_enable(void)
                udelay(100);
                gpio_set_value(TX51_LCD_RST_GPIO, 1);
                udelay(300000);
-               gpio_set_value(TX51_LCD_BACKLIGHT_GPIO, 0);
+               gpio_set_value(TX51_LCD_BACKLIGHT_GPIO,
+                       lcd_backlight_polarity());
        }
 }
 
@@ -711,7 +718,8 @@ void lcd_panel_disable(void)
 {
        if (lcd_enabled) {
                debug("Switching LCD off\n");
-               gpio_set_value(TX51_LCD_BACKLIGHT_GPIO, 1);
+               gpio_set_value(TX51_LCD_BACKLIGHT_GPIO,
+                       !lcd_backlight_polarity());
                gpio_set_value(TX51_LCD_RST_GPIO, 0);
                gpio_set_value(TX51_LCD_PWR_GPIO, 0);
        }
@@ -786,6 +794,7 @@ void lcd_ctrl_init(void *lcdbase)
        }
 
        karo_fdt_move_fdt();
+       lcd_bl_polarity = karo_fdt_get_backlight_polarity(working_fdt);
 
        vm = getenv("video_mode");
        if (vm == NULL) {
index ccce6dc74fff9cdaaccd16d31f24766b1d7ea175..59b0a5ba490d7d86a0e0e941e7ed3ce604368ce0 100644 (file)
@@ -770,6 +770,12 @@ static struct fb_videomode tx53_fb_modes[] = {
 };
 
 static int lcd_enabled = 1;
+static int lcd_bl_polarity;
+
+static int lcd_backlight_polarity(void)
+{
+       return lcd_bl_polarity;
+}
 
 void lcd_enable(void)
 {
@@ -788,7 +794,8 @@ void lcd_enable(void)
                udelay(100);
                gpio_set_value(TX53_LCD_RST_GPIO, 1);
                udelay(300000);
-               gpio_set_value(TX53_LCD_BACKLIGHT_GPIO, is_lvds());
+               gpio_set_value(TX53_LCD_BACKLIGHT_GPIO,
+                       lcd_backlight_polarity());
        }
 }
 
@@ -804,7 +811,8 @@ void lcd_panel_disable(void)
 {
        if (lcd_enabled) {
                debug("Switching LCD off\n");
-               gpio_set_value(TX53_LCD_BACKLIGHT_GPIO, !is_lvds());
+               gpio_set_value(TX53_LCD_BACKLIGHT_GPIO,
+                       !lcd_backlight_polarity());
                gpio_set_value(TX53_LCD_RST_GPIO, 0);
                gpio_set_value(TX53_LCD_PWR_GPIO, 0);
        }
@@ -898,6 +906,7 @@ void lcd_ctrl_init(void *lcdbase)
        }
 
        karo_fdt_move_fdt();
+       lcd_bl_polarity = karo_fdt_get_backlight_polarity(working_fdt);
 
        if (video_mode == NULL) {
                debug("Disabling LCD\n");
index 6f3cd10348599e5bf63c45d149bd28457e5c73c9..0ec84b618f2d68139d26c7763c2650791eddb6a7 100644 (file)
@@ -864,6 +864,12 @@ static struct fb_videomode tx6_fb_modes[] = {
 };
 
 static int lcd_enabled = 1;
+static int lcd_bl_polarity;
+
+static int lcd_backlight_polarity(void)
+{
+       return lcd_bl_polarity;
+}
 
 void lcd_enable(void)
 {
@@ -882,7 +888,8 @@ void lcd_enable(void)
                udelay(100);
                gpio_set_value(TX6_LCD_RST_GPIO, 1);
                udelay(300000);
-               gpio_set_value(TX6_LCD_BACKLIGHT_GPIO, is_lvds());
+               gpio_set_value(TX6_LCD_BACKLIGHT_GPIO,
+                       lcd_backlight_polarity());
        }
 }
 
@@ -898,7 +905,8 @@ void lcd_panel_disable(void)
 {
        if (lcd_enabled) {
                debug("Switching LCD off\n");
-               gpio_set_value(TX6_LCD_BACKLIGHT_GPIO, !is_lvds());
+               gpio_set_value(TX6_LCD_BACKLIGHT_GPIO,
+                       !lcd_backlight_polarity());
                gpio_set_value(TX6_LCD_RST_GPIO, 0);
                gpio_set_value(TX6_LCD_PWR_GPIO, 0);
        }
@@ -976,6 +984,7 @@ void lcd_ctrl_init(void *lcdbase)
        }
 
        karo_fdt_move_fdt();
+       lcd_bl_polarity = karo_fdt_get_backlight_polarity(working_fdt);
 
        if (video_mode == NULL) {
                debug("Disabling LCD\n");