]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
am335x, guardian: Enable backlight
authorGireesh Hiremath <Gireesh.Hiremath@in.bosch.com>
Fri, 11 Jun 2021 16:13:44 +0000 (16:13 +0000)
committerLokesh Vutla <lokeshvutla@ti.com>
Thu, 15 Jul 2021 12:26:03 +0000 (17:56 +0530)
Enable backlight, set brightness value and dimming frequency

Signed-off-by: Gireesh Hiremath <Gireesh.Hiremath@in.bosch.com>
Signed-off-by: Lokesh Vutla <lokeshvutla@ti.com>
Link: https://lore.kernel.org/r/20210611161350.2141-13-Gireesh.Hiremath@in.bosch.com
board/bosch/guardian/board.c
include/configs/am335x_guardian.h

index f14ceaa1f92a1bca2f3726569a42353bc4df0234..4388ef70d2571333d833fc4258fb49221c27b3c5 100644 (file)
@@ -225,12 +225,38 @@ err:
        env_set("swi_status", "err");
 }
 
+void lcdbacklight_en(void)
+{
+       unsigned long brightness = env_get_ulong("backlight_brightness", 10, 50);
+
+       if (brightness > 99 || brightness == 0)
+               brightness = 99;
+
+       /*
+        * Brightness range:
+        * WLEDCTRL2 DUTY[6:0]
+        *
+        * 000 0000b = 1%
+        * 000 0001b = 2%
+        * ...
+        * 110 0010b = 99%
+        * 110 0011b = 100%
+        *
+        */
+
+       tps65217_reg_write(TPS65217_PROT_LEVEL_NONE, TPS65217_WLEDCTRL2,
+                          brightness, 0xFF);
+       tps65217_reg_write(TPS65217_PROT_LEVEL_NONE, TPS65217_WLEDCTRL1,
+                          brightness != 0 ? 0x0A : 0x02, 0xFF);
+}
+
 int board_late_init(void)
 {
 #ifdef CONFIG_LED_GPIO
        led_default_state();
 #endif
        set_bootmode_env();
+       lcdbacklight_en();
        return 0;
 }
 #endif /* CONFIG_BOARD_LATE_INIT */
index c76f9b26fb2c9316e4272431dbe853c2c09afe49..73248292f2640779f86a7c8d8e341c35258271bc 100644 (file)
@@ -59,6 +59,7 @@
        BOOTENV \
        GUARDIAN_DEFAULT_PROD_ENV \
        "autoload=no\0" \
+       "backlight_brightness=50\0" \
        "bootubivol=rootfs\0" \
        "distro_bootcmd=" \
                "setenv rootflags \"bulk_read,chk_data_crc\"; " \