浏览代码

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 <[email protected]>
Jeykumar Sankaran 4 年之前
父节点
当前提交
77d648442f
共有 3 个文件被更改,包括 50 次插入37 次删除
  1. 3 2
      msm/dsi/dsi_display.c
  2. 46 33
      msm/dsi/dsi_panel.c
  3. 1 2
      msm/dsi/dsi_panel.h

+ 3 - 2
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;

+ 46 - 33
msm/dsi/dsi_panel.c

@@ -193,52 +193,63 @@ 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;
+	gpio_set_value(reset_gpio, 0);
 
-		for (i = 0; i < panel->tlmm_gpio_count; i++)
-			if (!strcmp(panel->tlmm_gpio[i].name, "reset-gpio"))
-				gpio = &panel->tlmm_gpio[i];
+	SDE_EVT32(SDE_EVTLOG_FUNC_CASE1);
+	DSI_INFO("GPIO pulled low to simulate ESD\n");
 
-		if (!gpio) {
-			DSI_ERR("reset gpio not found\n");
-			return -EINVAL;
-		}
+	return 0;
+}
 
-		io = ioremap(gpio->addr, gpio->size);
-		writel_relaxed(0, io + offset);
-		iounmap(io);
+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;
 
-	} else {
-		struct dsi_panel_reset_config *r_config = &panel->reset_config;
+	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;
+	}
 
-		if (!r_config) {
-			DSI_ERR("Invalid panel reset configuration\n");
-			return -EINVAL;
-		}
+	rc = gpio_request(reset_gpio, "reset_gpio");
+	if (rc) {
+		DSI_ERR("request for reset_gpio failed, rc=%d\n", rc);
+		return rc;
+	}
 
-		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);
+	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;
 	}
 
-	SDE_EVT32(SDE_EVTLOG_FUNC_CASE1);
-	DSI_INFO("GPIO pulled low to simulate ESD\n");
+	r_config = &panel->reset_config;
+	if (!r_config) {
+		DSI_ERR("Invalid panel reset configuration\n");
+		return -EINVAL;
+	}
 
-	return 0;
+	return dsi_panel_trigger_esd_attack_sub(r_config->reset_gpio);
 }
 
 static int dsi_panel_reset(struct dsi_panel *panel)
@@ -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;
 	}
 }
 

+ 1 - 2
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);