From 92faf43b9c669236d5ae34e02d4d2c795d39a65b Mon Sep 17 00:00:00 2001 From: Robert Beckett Date: Fri, 31 Jan 2020 15:07:59 +0200 Subject: [PATCH] board: ge: bx50v3: Enable DM PWM for backlight Add backlight and panel devicetree definitions Use UCLASS_PANEL to enable backlight via display enable handler Remove old explicit gpio code for handling backlight Use cls command to initiate display in HW agnostic manner Enable DM regulator and pwm Signed-off-by: Robert Beckett --- board/ge/bx50v3/bx50v3.c | 81 ++++++++----------------------------- configs/ge_bx50v3_defconfig | 3 ++ include/configs/ge_bx50v3.h | 2 +- 3 files changed, 20 insertions(+), 66 deletions(-) diff --git a/board/ge/bx50v3/bx50v3.c b/board/ge/bx50v3/bx50v3.c index 4a75c7b279..a29fc42d5a 100644 --- a/board/ge/bx50v3/bx50v3.c +++ b/board/ge/bx50v3/bx50v3.c @@ -37,6 +37,7 @@ #include "../common/vpd_reader.h" #include "../../../drivers/net/e1000.h" #include +#include DECLARE_GLOBAL_DATA_PTR; @@ -124,16 +125,20 @@ int board_phy_config(struct phy_device *phydev) } #if defined(CONFIG_VIDEO_IPUV3) -static iomux_v3_cfg_t const backlight_pads[] = { - /* Power for LVDS Display */ - MX6_PAD_EIM_D22__GPIO3_IO22 | MUX_PAD_CTRL(NO_PAD_CTRL), -#define LVDS_POWER_GP IMX_GPIO_NR(3, 22) - /* Backlight enable for LVDS display */ - MX6_PAD_GPIO_0__GPIO1_IO00 | MUX_PAD_CTRL(NO_PAD_CTRL), -#define LVDS_BACKLIGHT_GP IMX_GPIO_NR(1, 0) - /* backlight PWM brightness control */ - MX6_PAD_SD1_DAT3__PWM1_OUT | MUX_PAD_CTRL(NO_PAD_CTRL), -}; +static void do_enable_backlight(struct display_info_t const *dev) +{ + struct udevice *panel; + int ret; + + ret = uclass_get_device(UCLASS_PANEL, 0, &panel); + if (ret) { + printf("Could not find panel: %d\n", ret); + return; + } + + panel_set_backlight(panel, 100); + panel_enable_backlight(panel); +} static void do_enable_hdmi(struct display_info_t const *dev) { @@ -155,7 +160,7 @@ struct display_info_t const displays[] = {{ .addr = -1, .pixfmt = IPU_PIX_FMT_RGB24, .detect = detect_lcd, - .enable = NULL, + .enable = do_enable_backlight, .mode = { .name = "G121X1-L03", .refresh = 60, @@ -314,12 +319,6 @@ static void setup_display_bx50v3(void) IOMUXC_GPR3_LVDS0_MUX_CTL_MASK, (IOMUXC_GPR3_MUX_SRC_IPU1_DI0 << IOMUXC_GPR3_LVDS0_MUX_CTL_OFFSET)); - - /* backlights off until needed */ - imx_iomux_v3_setup_multiple_pads(backlight_pads, - ARRAY_SIZE(backlight_pads)); - gpio_request(LVDS_POWER_GP, "lvds_power"); - gpio_direction_input(LVDS_POWER_GP); } #endif /* CONFIG_VIDEO_IPUV3 */ @@ -476,9 +475,6 @@ int board_init(void) setup_display_b850v3(); else setup_display_bx50v3(); - - gpio_request(LVDS_BACKLIGHT_GP, "lvds_backlight"); - gpio_direction_input(LVDS_BACKLIGHT_GP); #endif /* address of boot parameters */ @@ -590,51 +586,6 @@ int ft_board_setup(void *blob, bd_t *bd) } #endif -static int do_backlight_enable(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) -{ -#if CONFIG_IS_ENABLED(DM_VIDEO) - int ret; - struct udevice *dev; - -#ifdef CONFIG_VIDEO_IPUV3 - if (!is_b850v3()) { - gpio_direction_output(LVDS_POWER_GP, 1); - - /* We need at least 200ms between power on and backlight on - * as per specifications from CHI MEI - */ - mdelay(250); - - /* enable backlight PWM 1 */ - pwm_init(0, 0, 0); - - /* duty cycle 5000000ns, period: 5000000ns */ - pwm_config(0, 5000000, 5000000); - - /* Backlight Power */ - gpio_direction_output(LVDS_BACKLIGHT_GP, 1); - - pwm_enable(0); - } -#endif - - /* Probe, to find a video device to be used to show a message on - * the vidconsole. - */ - ret = uclass_get_device(UCLASS_VIDEO, 0, &dev); - if (ret) - return ret; -#endif - - return 0; -} - -U_BOOT_CMD( - bx50_backlight_enable, 1, 1, do_backlight_enable, - "enable Bx50 backlight", - "" -); - int board_fit_config_name_match(const char *name) { if (!vpd.is_read) diff --git a/configs/ge_bx50v3_defconfig b/configs/ge_bx50v3_defconfig index b19861c89c..49df9f6261 100644 --- a/configs/ge_bx50v3_defconfig +++ b/configs/ge_bx50v3_defconfig @@ -31,6 +31,7 @@ CONFIG_CMD_PCI=y # CONFIG_CMD_NFS is not set CONFIG_CMD_BOOTCOUNT=y CONFIG_CMD_CACHE=y +CONFIG_CMD_CLS=y CONFIG_CMD_EXT2=y CONFIG_CMD_EXT4=y CONFIG_CMD_EXT4_WRITE=y @@ -74,9 +75,11 @@ CONFIG_DM_PCI=y CONFIG_PINCTRL=y CONFIG_PINCTRL_IMX6=y CONFIG_PWM_IMX=y +CONFIG_DM_PWM=y CONFIG_DM_PMIC=y CONFIG_DM_PMIC_DA9063=y CONFIG_DM_REGULATOR=y +CONFIG_DM_REGULATOR_FIXED=y CONFIG_DM_REGULATOR_DA9063=y CONFIG_DM_RTC=y CONFIG_RTC_RX8010SJ=y diff --git a/include/configs/ge_bx50v3.h b/include/configs/ge_bx50v3.h index b9227fc2fe..46a3c38294 100644 --- a/include/configs/ge_bx50v3.h +++ b/include/configs/ge_bx50v3.h @@ -105,7 +105,7 @@ "setexpr partnum 3 - ${partnum}\0" \ "failbootcmd=" \ "echo reached failbootcmd; " \ - "bx50_backlight_enable; " \ + "cls; " \ "setcurs 5 4; " \ "lcdputs \"Monitor failed to start. " \ "Try again, or contact GE Service for support.\"; " \ -- 2.25.1