From fe176ce302a5ebe1a8291709c507677a9d17a10e Mon Sep 17 00:00:00 2001 From: houdz1 Date: Fri, 9 Jul 2021 14:22:43 +0800 Subject: [PATCH] msm/dsi: add support HBM with GPIO_DCS For cypfq, we will set the backlight to max with dcs command. And pull up hbm_en gpio to set the max current to 25mA. Change-Id: I07885a122a9efc73e3f1191fa2465c0721ab9ec1 Signed-off-by: houdz1 Reviewed-on: https://gerrit.mot.com/2007805 SME-Granted: SME Approvals Granted SLTApproved: Slta Waiver Tested-by: Jira Key Reviewed-by: Huosheng Liao Submit-Approved: Jira Key --- msm/dsi/dsi_panel.c | 58 ++++++++++++++++++++++++++++++++++++++++----- msm/dsi/dsi_panel.h | 2 ++ 2 files changed, 54 insertions(+), 6 deletions(-) diff --git a/msm/dsi/dsi_panel.c b/msm/dsi/dsi_panel.c index 6f4a4aa9925e..27123a911a10 100644 --- a/msm/dsi/dsi_panel.c +++ b/msm/dsi/dsi_panel.c @@ -237,11 +237,24 @@ static int dsi_panel_gpio_request(struct dsi_panel *panel) rc); panel->avdd_enable_gpio = -1; rc = 0; + goto error_release_avdd_enable; } } + if (gpio_is_valid(panel->hbm_en_gpio)) { + rc = gpio_request(panel->hbm_en_gpio, "hbm_en_gpio"); + if (rc) { + DSI_WARN("request for hbm_en_gpio failed, rc=%d\n", + rc); + panel->hbm_en_gpio = -1; + rc = 0; + } + } goto error; +error_release_avdd_enable: + if (gpio_is_valid(panel->avdd_enable_gpio)) + gpio_free(panel->avdd_enable_gpio); error_release_avee_enable: if (gpio_is_valid(panel->avee_enable_gpio)) gpio_free(panel->avee_enable_gpio); @@ -281,6 +294,9 @@ static int dsi_panel_gpio_release(struct dsi_panel *panel) if (gpio_is_valid(panel->panel_test_gpio)) gpio_free(panel->panel_test_gpio); + if (gpio_is_valid(panel->hbm_en_gpio)) + gpio_free(panel->hbm_en_gpio); + return rc; } @@ -1011,13 +1027,36 @@ static int dsi_panel_set_hbm(struct dsi_panel *panel, pr_info("Set HBM to (%d)\n", param_info->value); - rc = dsi_panel_send_param_cmd(panel, param_info); - if (rc < 0) { - DSI_ERR("%s: failed to send param cmds. ret=%d\n", __func__, rc); + if (panel->hbm_type == HBM_TYPE_LCD_DCS_GPIO) { + if (gpio_is_valid(panel->hbm_en_gpio)) { + struct panel_param *panel_param = &dsi_panel_param[0][PARAM_HBM_ID]; + + panel_param->value = param_info->value; if (param_info->value) { + gpio_direction_output(panel->hbm_en_gpio, 1); + pr_info("Set HBM to (%d) with GPIO%d\n", param_info->value, panel->hbm_en_gpio); + } + else { + gpio_direction_output(panel->hbm_en_gpio, 0); + pr_info("Set HBM to (%d) with GPIO%d\n", param_info->value, panel->hbm_en_gpio); + } + + rc = dsi_panel_set_backlight(panel, HBM_BRIGHTNESS(param_info->value)); + if (rc) + DSI_ERR("Set HBM: unable to set backlight\n"); + + } else { + DSI_ERR("%s: invalid params\n", __func__); + rc = -EINVAL; + } } else { - rc = dsi_panel_set_backlight(panel, HBM_BRIGHTNESS(param_info->value)); - if (rc) - DSI_ERR("unable to set backlight\n"); + rc = dsi_panel_send_param_cmd(panel, param_info); + if (rc < 0) { + DSI_ERR("%s: failed to send param cmds. ret=%d\n", __func__, rc); + } else { + rc = dsi_panel_set_backlight(panel, HBM_BRIGHTNESS(param_info->value)); + if (rc) + DSI_ERR("unable to set backlight\n"); + } } return rc; @@ -2776,6 +2815,13 @@ static int dsi_panel_parse_gpios(struct dsi_panel *panel) DSI_DEBUG("%s:%d qcom,add-enable-gpio not specified\n", __func__, __LINE__); + panel->hbm_en_gpio = utils->get_named_gpio(utils->data, + "qcom,platform-hbm-en-gpio", + 0); + if (!gpio_is_valid(panel->hbm_en_gpio)) + DSI_DEBUG("%s:%d HBM enable gpio not specified\n", __func__, + __LINE__); + error: return rc; } diff --git a/msm/dsi/dsi_panel.h b/msm/dsi/dsi_panel.h index bdeadbcec94e..2c582bacdfd1 100644 --- a/msm/dsi/dsi_panel.h +++ b/msm/dsi/dsi_panel.h @@ -375,6 +375,8 @@ struct dsi_panel { int avee_enable_gpio; int avdd_enable_gpio; + + int hbm_en_gpio; }; bool dsi_display_all_displays_dead(void);