Skip to contentSkip to conversation

drm/stm: dsi: check hardware version

PATCH In review Yannick Fertré 3 participants 3 messages May 10, 2019 – May 24, 2019

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drm/stm: dsi: check hardware version

Check version of DSI hardware IP. Only versions 1.30 & 1.31 are supported.

---
 drivers/gpu/drm/stm/dw_mipi_dsi-stm.c | 24 +++++++++++++++++++++++-
 1 file changed, 23 insertions(+), 1 deletion(-)
drivers/gpu/drm/stm/dw_mipi_dsi-stm.c +23 -1
index 22bd095..29105e9 100644
@@ -227,7 +227,6 @@ dw_mipi_dsi_get_lane_mbps(void *priv_data, const struct drm_display_mode *mode,
 	u32 val;
 
 	/* Update lane capabilities according to hw version */
-	dsi->hw_version = dsi_read(dsi, DSI_VERSION) & VERSION;
 	dsi->lane_min_kbps = LANE_MIN_KBPS;
 	dsi->lane_max_kbps = LANE_MAX_KBPS;
 	if (dsi->hw_version == HWVER_131) {
@@ -306,6 +305,7 @@ static int dw_mipi_dsi_stm_probe(struct platform_device *pdev)
 {
 	struct device *dev = &pdev->dev;
 	struct dw_mipi_dsi_stm *dsi;
+	struct clk *pclk;
 	struct resource *res;
 	int ret;
 
@@ -347,6 +347,28 @@ static int dw_mipi_dsi_stm_probe(struct platform_device *pdev)
 		goto err_clk_get;
 	}
 
+	pclk = devm_clk_get(dev, "pclk");
+	if (IS_ERR(pclk)) {
+		ret = PTR_ERR(pclk);
+		DRM_ERROR("Unable to get peripheral clock: %d\n", ret);
+		goto err_dsi_probe;
+	}
+
+	ret = clk_prepare_enable(pclk);
+	if (ret) {
+		DRM_ERROR("%s: Failed to enable peripheral clk\n", __func__);
+		goto err_dsi_probe;
+	}
+
+	dsi->hw_version = dsi_read(dsi, DSI_VERSION) & VERSION;
+	clk_disable_unprepare(pclk);
+
+	if (dsi->hw_version != HWVER_130 && dsi->hw_version != HWVER_131) {
+		ret = -ENODEV;
+		DRM_ERROR("bad dsi hardware version\n");
+		goto err_dsi_probe;
+	}
+
 	dw_mipi_dsi_stm_plat_data.base = dsi->base;
 	dw_mipi_dsi_stm_plat_data.priv_data = dsi;
 
Signature · 6 lines
2.7.4

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Acked-by on v1 1/1
#1 lore raw

Dear Yannick,
Thank you for your patch,

Dear Benjamin,
If you are fine with this patch, please push it *after* the patch named "drm/stm: dsi: add support of an optional regulator" (if I well understood those two patches)

Thank you
Philippe :-)

Quoted 48 lines · Yannick Fertré

Check version of DSI hardware IP. Only versions 1.30 & 1.31 are supported.

---
  drivers/gpu/drm/stm/dw_mipi_dsi-stm.c | 24 +++++++++++++++++++++++-
  1 file changed, 23 insertions(+), 1 deletion(-)
drivers/gpu/drm/stm/dw_mipi_dsi-stm.c +16 -1
index 22bd095..29105e9 100644
@@ -227,7 +227,6 @@ dw_mipi_dsi_get_lane_mbps(void *priv_data, const struct drm_display_mode *mode,
  	u32 val;
 
  	/* Update lane capabilities according to hw version */
-	dsi->hw_version = dsi_read(dsi, DSI_VERSION) & VERSION;
  	dsi->lane_min_kbps = LANE_MIN_KBPS;
  	dsi->lane_max_kbps = LANE_MAX_KBPS;
  	if (dsi->hw_version == HWVER_131) {
@@ -306,6 +305,7 @@ static int dw_mipi_dsi_stm_probe(struct platform_device *pdev)
  {
  	struct device *dev = &pdev->dev;
  	struct dw_mipi_dsi_stm *dsi;
+	struct clk *pclk;
  	struct resource *res;
  	int ret;
 
@@ -347,6 +347,28 @@ static int dw_mipi_dsi_stm_probe(struct platform_device *pdev)
  		goto err_clk_get;
  	}
 
+	pclk = devm_clk_get(dev, "pclk");
+	if (IS_ERR(pclk)) {
+		ret = PTR_ERR(pclk);
+		DRM_ERROR("Unable to get peripheral clock: %d\n", ret);
+		goto err_dsi_probe;
+	}
+
+	ret = clk_prepare_enable(pclk);
+	if (ret) {
+		DRM_ERROR("%s: Failed to enable peripheral clk\n", __func__);
+		goto err_dsi_probe;
+	}
+
+	dsi->hw_version = dsi_read(dsi, DSI_VERSION) & VERSION;
+	clk_disable_unprepare(pclk);

drivers/gpu/drm/stm/dw_mipi_dsi-stm.c static int dw_mipi_dsi_stm_probe(struct platform_device *pdev) · line 374

Quoted 10 lines
drivers/gpu/drm/stm/dw_mipi_dsi-stm.c +7 -0
+
+	if (dsi->hw_version != HWVER_130 && dsi->hw_version != HWVER_131) {
+		ret = -ENODEV;
+		DRM_ERROR("bad dsi hardware version\n");
+		goto err_dsi_probe;
+	}
+
  	dw_mipi_dsi_stm_plat_data.base = dsi->base;
  	dw_mipi_dsi_stm_plat_data.priv_data = dsi;
 

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

#2 lore raw
Quoted 7 lines · Philippe CORNU

Dear Yannick,
Thank you for your patch,

Quoted 7 lines

Dear Benjamin,
If you are fine with this patch, please push it *after* the patch named "drm/stm: dsi: add support of an optional regulator" (if I well understood those two patches)

Thank you
Philippe :-)

Applied on drm-misc-next,

Benjamin

Quoted 65 lines · Yannick Fertré
Quoted 48 lines

Check version of DSI hardware IP. Only versions 1.30 & 1.31 are supported.

---
  drivers/gpu/drm/stm/dw_mipi_dsi-stm.c | 24 +++++++++++++++++++++++-
  1 file changed, 23 insertions(+), 1 deletion(-)
drivers/gpu/drm/stm/dw_mipi_dsi-stm.c +16 -1
index 22bd095..29105e9 100644
@@ -227,7 +227,6 @@ dw_mipi_dsi_get_lane_mbps(void *priv_data, const struct drm_display_mode *mode,
      u32 val;
 
      /* Update lane capabilities according to hw version */
-     dsi->hw_version = dsi_read(dsi, DSI_VERSION) & VERSION;
      dsi->lane_min_kbps = LANE_MIN_KBPS;
      dsi->lane_max_kbps = LANE_MAX_KBPS;
      if (dsi->hw_version == HWVER_131) {
@@ -306,6 +305,7 @@ static int dw_mipi_dsi_stm_probe(struct platform_device *pdev)
  {
      struct device *dev = &pdev->dev;
      struct dw_mipi_dsi_stm *dsi;
+     struct clk *pclk;
      struct resource *res;
      int ret;
 
@@ -347,6 +347,28 @@ static int dw_mipi_dsi_stm_probe(struct platform_device *pdev)
              goto err_clk_get;
      }
 
+     pclk = devm_clk_get(dev, "pclk");
+     if (IS_ERR(pclk)) {
+             ret = PTR_ERR(pclk);
+             DRM_ERROR("Unable to get peripheral clock: %d\n", ret);
+             goto err_dsi_probe;
+     }
+
+     ret = clk_prepare_enable(pclk);
+     if (ret) {
+             DRM_ERROR("%s: Failed to enable peripheral clk\n", __func__);
+             goto err_dsi_probe;
+     }
+
+     dsi->hw_version = dsi_read(dsi, DSI_VERSION) & VERSION;
+     clk_disable_unprepare(pclk);

drivers/gpu/drm/stm/dw_mipi_dsi-stm.c static int dw_mipi_dsi_stm_probe(struct platform_device *pdev) · line 374

Quoted 10 lines
drivers/gpu/drm/stm/dw_mipi_dsi-stm.c +7 -0
+
+     if (dsi->hw_version != HWVER_130 && dsi->hw_version != HWVER_131) {
+             ret = -ENODEV;
+             DRM_ERROR("bad dsi hardware version\n");
+             goto err_dsi_probe;
+     }
+
      dw_mipi_dsi_stm_plat_data.base = dsi->base;
      dw_mipi_dsi_stm_plat_data.priv_data = dsi;
 

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel