From 77d648442fc147b79339ca9cac7048db61a1a457 Mon Sep 17 00:00:00 2001 From: Jeykumar Sankaran Date: Tue, 27 Apr 2021 16:44:18 -0700 Subject: [PATCH] disp: msm: dsi: implement ESD trigger for trusted vm DSI driver stubs out GPIO parsing in trusted vm. Add support for ESD trigger in trusted vm by explicitly parsing the reset gpio and setting the value. Change-Id: I8c04e4b27b234eb236ec51df633c06738f2a5c96 Signed-off-by: Jeykumar Sankaran --- msm/dsi/dsi_display.c | 5 ++- msm/dsi/dsi_panel.c | 87 +++++++++++++++++++++++++------------------ msm/dsi/dsi_panel.h | 3 +- 3 files changed, 54 insertions(+), 41 deletions(-) diff --git a/msm/dsi/dsi_display.c b/msm/dsi/dsi_display.c index a9e0d3cac4..155111f5b7 100644 --- a/msm/dsi/dsi_display.c +++ b/msm/dsi/dsi_display.c @@ -1660,9 +1660,10 @@ static ssize_t debugfs_esd_trigger_check(struct file *file, } if (display->esd_trigger) { + struct dsi_panel *panel = display->panel; + DSI_INFO("ESD attack triggered by user\n"); - rc = dsi_panel_trigger_esd_attack(display->panel, - display->trusted_vm_env); + rc = panel->panel_ops.trigger_esd_attack(panel); if (rc) { DSI_ERR("Failed to trigger ESD attack\n"); goto error; diff --git a/msm/dsi/dsi_panel.c b/msm/dsi/dsi_panel.c index 4948fee514..7b6ba80fc2 100644 --- a/msm/dsi/dsi_panel.c +++ b/msm/dsi/dsi_panel.c @@ -193,47 +193,14 @@ static int dsi_panel_gpio_release(struct dsi_panel *panel) return rc; } -int dsi_panel_trigger_esd_attack(struct dsi_panel *panel, bool trusted_vm_env) +static int dsi_panel_trigger_esd_attack_sub(int reset_gpio) { - if (!panel) { - DSI_ERR("Invalid panel param\n"); + if (!gpio_is_valid(reset_gpio)) { + DSI_INFO("failed to pull down the reset gpio\n"); return -EINVAL; } - /* toggle reset-gpio by writing directly to register in trusted-vm */ - if (trusted_vm_env) { - struct dsi_tlmm_gpio *gpio = NULL; - void __iomem *io; - u32 offset = 0x4; - int i; - - for (i = 0; i < panel->tlmm_gpio_count; i++) - if (!strcmp(panel->tlmm_gpio[i].name, "reset-gpio")) - gpio = &panel->tlmm_gpio[i]; - - if (!gpio) { - DSI_ERR("reset gpio not found\n"); - return -EINVAL; - } - - io = ioremap(gpio->addr, gpio->size); - writel_relaxed(0, io + offset); - iounmap(io); - - } else { - struct dsi_panel_reset_config *r_config = &panel->reset_config; - - if (!r_config) { - DSI_ERR("Invalid panel reset configuration\n"); - return -EINVAL; - } - - if (!gpio_is_valid(r_config->reset_gpio)) { - DSI_ERR("failed to pull down gpio\n"); - return -EINVAL; - } - gpio_set_value(r_config->reset_gpio, 0); - } + gpio_set_value(reset_gpio, 0); SDE_EVT32(SDE_EVTLOG_FUNC_CASE1); DSI_INFO("GPIO pulled low to simulate ESD\n"); @@ -241,6 +208,50 @@ int dsi_panel_trigger_esd_attack(struct dsi_panel *panel, bool trusted_vm_env) return 0; } +static int dsi_panel_vm_trigger_esd_attack(struct dsi_panel *panel) +{ + struct dsi_parser_utils *utils = &panel->utils; + int reset_gpio; + int rc = 0; + + reset_gpio = utils->get_named_gpio(utils->data, + "qcom,platform-reset-gpio", 0); + if (!gpio_is_valid(reset_gpio)) { + DSI_ERR("[%s] reset gpio not provided\n", panel->name); + return -EINVAL; + } + + rc = gpio_request(reset_gpio, "reset_gpio"); + if (rc) { + DSI_ERR("request for reset_gpio failed, rc=%d\n", rc); + return rc; + } + + rc = dsi_panel_trigger_esd_attack_sub(reset_gpio); + + gpio_free(reset_gpio); + + return rc; +} + +static int dsi_panel_trigger_esd_attack(struct dsi_panel *panel) +{ + struct dsi_panel_reset_config *r_config; + + if (!panel) { + DSI_ERR("Invalid panel param\n"); + return -EINVAL; + } + + r_config = &panel->reset_config; + if (!r_config) { + DSI_ERR("Invalid panel reset configuration\n"); + return -EINVAL; + } + + return dsi_panel_trigger_esd_attack_sub(r_config->reset_gpio); +} + static int dsi_panel_reset(struct dsi_panel *panel) { int rc = 0; @@ -3485,6 +3496,7 @@ static void dsi_panel_setup_vm_ops(struct dsi_panel *panel, bool trusted_vm_env) panel->panel_ops.bl_unregister = dsi_panel_vm_stub; panel->panel_ops.parse_gpios = dsi_panel_vm_stub; panel->panel_ops.parse_power_cfg = dsi_panel_vm_stub; + panel->panel_ops.trigger_esd_attack = dsi_panel_vm_trigger_esd_attack; } else { panel->panel_ops.pinctrl_init = dsi_panel_pinctrl_init; panel->panel_ops.gpio_request = dsi_panel_gpio_request; @@ -3494,6 +3506,7 @@ static void dsi_panel_setup_vm_ops(struct dsi_panel *panel, bool trusted_vm_env) panel->panel_ops.bl_unregister = dsi_panel_bl_unregister; panel->panel_ops.parse_gpios = dsi_panel_parse_gpios; panel->panel_ops.parse_power_cfg = dsi_panel_parse_power_cfg; + panel->panel_ops.trigger_esd_attack = dsi_panel_trigger_esd_attack; } } diff --git a/msm/dsi/dsi_panel.h b/msm/dsi/dsi_panel.h index a9cd767a01..918e406568 100644 --- a/msm/dsi/dsi_panel.h +++ b/msm/dsi/dsi_panel.h @@ -209,6 +209,7 @@ struct dsi_panel_ops { int (*bl_unregister)(struct dsi_panel *panel); int (*parse_gpios)(struct dsi_panel *panel); int (*parse_power_cfg)(struct dsi_panel *panel); + int (*trigger_esd_attack)(struct dsi_panel *panel); }; struct dsi_panel { @@ -310,8 +311,6 @@ struct dsi_panel *dsi_panel_get(struct device *parent, int topology_override, bool trusted_vm_env); -int dsi_panel_trigger_esd_attack(struct dsi_panel *panel, bool trusted_vm_env); - void dsi_panel_put(struct dsi_panel *panel); int dsi_panel_drv_init(struct dsi_panel *panel, struct mipi_dsi_host *host);