]> git.kernelconcepts.de Git - karo-tx-uboot.git/commitdiff
Merge branch 'backlight-polarity' into uboot-merge
authorLothar Waßmann <LW@KARO-electronics.de>
Wed, 5 Mar 2014 14:34:37 +0000 (15:34 +0100)
committerLothar Waßmann <LW@KARO-electronics.de>
Wed, 5 Mar 2014 14:34:37 +0000 (15:34 +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 0ea4e194e300b5bd9d46817d84bae4e88a3a756a..d666c454d854aeb6e56c60b875609ebcda712911 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 @@ static inline 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 9fc36f74243abd9368143c690b36dada31720464..40f5598039bc7a69c4a4fd4c97c26bf2873fb0de 100644 (file)
@@ -674,6 +674,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)
 {
@@ -692,7 +698,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());
        }
 }
 
@@ -708,7 +715,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);
        }
@@ -783,6 +791,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 363df2ed773e773ad320af4fbed2a8c2b067255a..74928e61d83ff15b86c9adfa0120dfaad7173bad 100644 (file)
@@ -767,6 +767,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)
 {
@@ -785,7 +791,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());
        }
 }
 
@@ -801,7 +808,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);
        }
@@ -895,6 +903,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 6324486d065c79f15b666f6c481fd99951c11548..08dd9dd2a549cc81ddd431120283551591a19d06 100644 (file)
@@ -861,6 +861,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)
 {
@@ -879,7 +885,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());
        }
 }
 
@@ -895,7 +902,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);
        }
@@ -973,6 +981,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");