Skip to contentSkip to conversation

drm/exynos: defer hdmi probe when fail to get regulators

PATCH Superseded Rahul Sharma 2 participants 3 messages Jun 18, 2014 – Jun 19, 2014

Subsystems (3)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drm/exynos: defer hdmi probe when fail to get regulators

HDMI probe proceeds with dummy regulators when the regulators are not provided in DT node or regulator provider has not get probed or failed to register the regulators.

This patch modify hdmi driver to defer the probe in case the regulators are not available.

---
Based on exynos-drm-fixes branch in Inki dae's tree.

 drivers/gpu/drm/exynos/exynos_hdmi.c |   69 ++++++++++++++++++++++++----------
 1 file changed, 50 insertions(+), 19 deletions(-)
drivers/gpu/drm/exynos/exynos_hdmi.c +50 -19
index aa259b0..3f24c49 100644
@@ -83,7 +83,7 @@ struct hdmi_resources {
 	struct clk			*sclk_pixel;
 	struct clk			*sclk_hdmiphy;
 	struct clk			*mout_hdmi;
-	struct regulator_bulk_data	*regul_bulk;
+	struct regulator		**regulators;
 	int				regul_count;
 };
 
@@ -2022,6 +2022,36 @@ static void hdmi_commit(struct exynos_drm_display *display)
 	hdmi_conf_apply(hdata);
 }
 
+int hdmi_regulator_enable(struct hdmi_context *hdata)
+{
+	struct hdmi_resources *res = &hdata->res;
+	int i, ret;
+
+	for (i = 0; i < res->regul_count; ++i) {
+		ret = regulator_enable(res->regulators[i]);
+		if (ret < 0) {
+			DRM_ERROR("fail to enable regulators.\n");
+			return ret;
+		}
+	}
+	return 0;
+}
+
+int hdmi_regulator_disable(struct hdmi_context *hdata)
+{
+	struct hdmi_resources *res = &hdata->res;
+	int i, ret;
+
+	for (i = 0; i < res->regul_count; ++i) {
+		ret = regulator_disable(res->regulators[i]);
+		if (ret < 0) {
+			DRM_ERROR("fail to disable regulators.\n");
+			return ret;
+		}
+	}
+	return 0;
+}
+
 static void hdmi_poweron(struct exynos_drm_display *display)
 {
 	struct hdmi_context *hdata = display->ctx;
@@ -2039,8 +2069,8 @@ static void hdmi_poweron(struct exynos_drm_display *display)
 
 	pm_runtime_get_sync(hdata->dev);
 
-	if (regulator_bulk_enable(res->regul_count, res->regul_bulk))
-		DRM_DEBUG_KMS("failed to enable regulator bulk\n");
+	if (hdmi_regulator_enable(hdata))
+		DRM_DEBUG_KMS("failed to enable regulators\n");
 
 	/* set pmu hdmiphy control bit to enable hdmiphy */
 	regmap_update_bits(hdata->pmureg, PMU_HDMI_PHY_CONTROL,
@@ -2077,7 +2107,8 @@ static void hdmi_poweroff(struct exynos_drm_display *display)
 	regmap_update_bits(hdata->pmureg, PMU_HDMI_PHY_CONTROL,
 			PMU_HDMI_PHY_ENABLE_BIT, 0);
 
-	regulator_bulk_disable(res->regul_count, res->regul_bulk);
+	if (hdmi_regulator_disable(hdata))
+		DRM_DEBUG_KMS("failed to disable regulators\n");
 
 	pm_runtime_put_sync(hdata->dev);
 
@@ -2211,24 +2242,24 @@ static int hdmi_resources_init(struct hdmi_context *hdata)
 
 	clk_set_parent(res->mout_hdmi, res->sclk_pixel);
 
-	res->regul_bulk = devm_kzalloc(dev, ARRAY_SIZE(supply) *
-		sizeof(res->regul_bulk[0]), GFP_KERNEL);
-	if (!res->regul_bulk) {
-		ret = -ENOMEM;
-		goto fail;
-	}
+	res->regul_count = ARRAY_SIZE(supply);
+
+	res->regulators = devm_kzalloc(dev, res->regul_count *
+		sizeof(res->regulators[0]), GFP_KERNEL);
+	if (!res->regulators)
+		return -ENOMEM;
+
 	for (i = 0; i < ARRAY_SIZE(supply); ++i) {
-		res->regul_bulk[i].supply = supply[i];
-		res->regul_bulk[i].consumer = NULL;
-	}
-	ret = devm_regulator_bulk_get(dev, ARRAY_SIZE(supply), res->regul_bulk);
-	if (ret) {
-		DRM_ERROR("failed to get regulators\n");
-		return ret;
+		res->regulators[i] =
+			devm_regulator_get_optional(dev, supply[i]);
+		if (IS_ERR(res->regulators[i])) {
+			DRM_ERROR("fail to get regulator: %s.\n",
+				supply[i]);
+			return -EPROBE_DEFER;
+		}
 	}
-	res->regul_count = ARRAY_SIZE(supply);
 
-	return ret;
+	return 0;
 fail:
 	DRM_ERROR("HDMI resource init - failed\n");
 	return ret;
Signature · 1 line
1.7.9.5
maintainer
#1 lore raw
Quoted 6 lines · Rahul Sharma

HDMI probe proceeds with dummy regulators when the regulators are not provided in DT node or regulator provider has not get probed or failed to register the regulators.

This patch modify hdmi driver to defer the probe in case the regulators are not available.

No, already available. See the below comments.

Quoted 99 lines

---
Based on exynos-drm-fixes branch in Inki dae's tree.

 drivers/gpu/drm/exynos/exynos_hdmi.c |   69 ++++++++++++++++++++++++----------
 1 file changed, 50 insertions(+), 19 deletions(-)
drivers/gpu/drm/exynos/exynos_hdmi.c +42 -13
index aa259b0..3f24c49 100644
@@ -83,7 +83,7 @@ struct hdmi_resources {
 	struct clk			*sclk_pixel;
 	struct clk			*sclk_hdmiphy;
 	struct clk			*mout_hdmi;
-	struct regulator_bulk_data	*regul_bulk;
+	struct regulator		**regulators;
 	int				regul_count;
 };
 
@@ -2022,6 +2022,36 @@ static void hdmi_commit(struct exynos_drm_display *display)
 	hdmi_conf_apply(hdata);
 }
 
+int hdmi_regulator_enable(struct hdmi_context *hdata)
+{
+	struct hdmi_resources *res = &hdata->res;
+	int i, ret;
+
+	for (i = 0; i < res->regul_count; ++i) {
+		ret = regulator_enable(res->regulators[i]);
+		if (ret < 0) {
+			DRM_ERROR("fail to enable regulators.\n");
+			return ret;
+		}
+	}
+	return 0;
+}
+
+int hdmi_regulator_disable(struct hdmi_context *hdata)
+{
+	struct hdmi_resources *res = &hdata->res;
+	int i, ret;
+
+	for (i = 0; i < res->regul_count; ++i) {
+		ret = regulator_disable(res->regulators[i]);
+		if (ret < 0) {
+			DRM_ERROR("fail to disable regulators.\n");
+			return ret;
+		}
+	}
+	return 0;
+}
+
 static void hdmi_poweron(struct exynos_drm_display *display)
 {
 	struct hdmi_context *hdata = display->ctx;
@@ -2039,8 +2069,8 @@ static void hdmi_poweron(struct exynos_drm_display *display)
 
 	pm_runtime_get_sync(hdata->dev);
 
-	if (regulator_bulk_enable(res->regul_count, res->regul_bulk))
-		DRM_DEBUG_KMS("failed to enable regulator bulk\n");
+	if (hdmi_regulator_enable(hdata))
+		DRM_DEBUG_KMS("failed to enable regulators\n");
 
 	/* set pmu hdmiphy control bit to enable hdmiphy */
 	regmap_update_bits(hdata->pmureg, PMU_HDMI_PHY_CONTROL,
@@ -2077,7 +2107,8 @@ static void hdmi_poweroff(struct exynos_drm_display *display)
 	regmap_update_bits(hdata->pmureg, PMU_HDMI_PHY_CONTROL,
 			PMU_HDMI_PHY_ENABLE_BIT, 0);
 
-	regulator_bulk_disable(res->regul_count, res->regul_bulk);
+	if (hdmi_regulator_disable(hdata))
+		DRM_DEBUG_KMS("failed to disable regulators\n");
 
 	pm_runtime_put_sync(hdata->dev);
 
@@ -2211,24 +2242,24 @@ static int hdmi_resources_init(struct hdmi_context *hdata)
 
 	clk_set_parent(res->mout_hdmi, res->sclk_pixel);
 
-	res->regul_bulk = devm_kzalloc(dev, ARRAY_SIZE(supply) *
-		sizeof(res->regul_bulk[0]), GFP_KERNEL);
-	if (!res->regul_bulk) {
-		ret = -ENOMEM;
-		goto fail;
-	}
+	res->regul_count = ARRAY_SIZE(supply);
+
+	res->regulators = devm_kzalloc(dev, res->regul_count *
+		sizeof(res->regulators[0]), GFP_KERNEL);
+	if (!res->regulators)
+		return -ENOMEM;
+
 	for (i = 0; i < ARRAY_SIZE(supply); ++i) {
-		res->regul_bulk[i].supply = supply[i];
-		res->regul_bulk[i].consumer = NULL;
-	}

drivers/gpu/drm/exynos/exynos_hdmi.c static int hdmi_resources_init(struct hdmi_context *hdata) · line 2258

Quoted 10 lines
drivers/gpu/drm/exynos/exynos_hdmi.c +6 -4
-	ret = devm_regulator_bulk_get(dev, ARRAY_SIZE(supply), res->regul_bulk);
-	if (ret) {
-		DRM_ERROR("failed to get regulators\n");
-		return ret;
+		res->regulators[i] =
+			devm_regulator_get_optional(dev, supply[i]);
+		if (IS_ERR(res->regulators[i])) {
+			DRM_ERROR("fail to get regulator: %s.\n",
+				supply[i]);
+			return -EPROBE_DEFER;

devm_regulator_get_optional function would return -EPROBE_DEFER if needed. So it's not good to force returning -EPROBE_DEFER in case of all errors.

Thanks,
Inki Dae

drivers/gpu/drm/exynos/exynos_hdmi.c static int hdmi_resources_init(struct hdmi_context *hdata) · line 2265

Quoted 10 lines
drivers/gpu/drm/exynos/exynos_hdmi.c +2 -2
+		}
 	}
-	res->regul_count = ARRAY_SIZE(supply);
 
-	return ret;
+	return 0;
 fail:
 	DRM_ERROR("HDMI resource init - failed\n");
 	return ret;

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

#2 lore raw

Thanks Inki,

Quoted 115 lines · Inki Dae
Quoted 6 lines · Rahul Sharma

HDMI probe proceeds with dummy regulators when the regulators are not provided in DT node or regulator provider has not get probed or failed to register the regulators.

This patch modify hdmi driver to defer the probe in case the regulators are not available.

No, already available. See the below comments.

Quoted 105 lines

---
Based on exynos-drm-fixes branch in Inki dae's tree.

 drivers/gpu/drm/exynos/exynos_hdmi.c |   69 ++++++++++++++++++++++++----------
 1 file changed, 50 insertions(+), 19 deletions(-)
drivers/gpu/drm/exynos/exynos_hdmi.c +44 -17
index aa259b0..3f24c49 100644
@@ -83,7 +83,7 @@ struct hdmi_resources {
      struct clk                      *sclk_pixel;
      struct clk                      *sclk_hdmiphy;
      struct clk                      *mout_hdmi;
-     struct regulator_bulk_data      *regul_bulk;
+     struct regulator                **regulators;
      int                             regul_count;
 };
 
@@ -2022,6 +2022,36 @@ static void hdmi_commit(struct exynos_drm_display *display)
      hdmi_conf_apply(hdata);
 }
 
+int hdmi_regulator_enable(struct hdmi_context *hdata)
+{
+     struct hdmi_resources *res = &hdata->res;
+     int i, ret;
+
+     for (i = 0; i < res->regul_count; ++i) {
+             ret = regulator_enable(res->regulators[i]);
+             if (ret < 0) {
+                     DRM_ERROR("fail to enable regulators.\n");
+                     return ret;
+             }
+     }
+     return 0;
+}
+
+int hdmi_regulator_disable(struct hdmi_context *hdata)
+{
+     struct hdmi_resources *res = &hdata->res;
+     int i, ret;
+
+     for (i = 0; i < res->regul_count; ++i) {
+             ret = regulator_disable(res->regulators[i]);
+             if (ret < 0) {
+                     DRM_ERROR("fail to disable regulators.\n");
+                     return ret;
+             }
+     }
+     return 0;
+}
+
 static void hdmi_poweron(struct exynos_drm_display *display)
 {
      struct hdmi_context *hdata = display->ctx;
@@ -2039,8 +2069,8 @@ static void hdmi_poweron(struct exynos_drm_display *display)
 
      pm_runtime_get_sync(hdata->dev);
 
-     if (regulator_bulk_enable(res->regul_count, res->regul_bulk))
-             DRM_DEBUG_KMS("failed to enable regulator bulk\n");
+     if (hdmi_regulator_enable(hdata))
+             DRM_DEBUG_KMS("failed to enable regulators\n");
 
      /* set pmu hdmiphy control bit to enable hdmiphy */
      regmap_update_bits(hdata->pmureg, PMU_HDMI_PHY_CONTROL,
@@ -2077,7 +2107,8 @@ static void hdmi_poweroff(struct exynos_drm_display *display)
      regmap_update_bits(hdata->pmureg, PMU_HDMI_PHY_CONTROL,
                      PMU_HDMI_PHY_ENABLE_BIT, 0);
 
-     regulator_bulk_disable(res->regul_count, res->regul_bulk);
+     if (hdmi_regulator_disable(hdata))
+             DRM_DEBUG_KMS("failed to disable regulators\n");
 
      pm_runtime_put_sync(hdata->dev);
 
@@ -2211,24 +2242,24 @@ static int hdmi_resources_init(struct hdmi_context *hdata)
 
      clk_set_parent(res->mout_hdmi, res->sclk_pixel);
 
-     res->regul_bulk = devm_kzalloc(dev, ARRAY_SIZE(supply) *
-             sizeof(res->regul_bulk[0]), GFP_KERNEL);
-     if (!res->regul_bulk) {
-             ret = -ENOMEM;
-             goto fail;
-     }
+     res->regul_count = ARRAY_SIZE(supply);
+
+     res->regulators = devm_kzalloc(dev, res->regul_count *
+             sizeof(res->regulators[0]), GFP_KERNEL);
+     if (!res->regulators)
+             return -ENOMEM;
+
      for (i = 0; i < ARRAY_SIZE(supply); ++i) {
-             res->regul_bulk[i].supply = supply[i];
-             res->regul_bulk[i].consumer = NULL;
-     }
-     ret = devm_regulator_bulk_get(dev, ARRAY_SIZE(supply), res->regul_bulk);
-     if (ret) {
-             DRM_ERROR("failed to get regulators\n");
-             return ret;
+             res->regulators[i] =
+                     devm_regulator_get_optional(dev, supply[i]);
Quoted 9 lines

drivers/gpu/drm/exynos/exynos_hdmi.c static int hdmi_resources_init(struct hdmi_context *hdata) · line 2258

Quoted 4 lines
drivers/gpu/drm/exynos/exynos_hdmi.c +4 -0
+             if (IS_ERR(res->regulators[i])) {
+                     DRM_ERROR("fail to get regulator: %s.\n",
+                             supply[i]);
+                     return -EPROBE_DEFER;

devm_regulator_get_optional function would return -EPROBE_DEFER if needed. So it's not good to force returning -EPROBE_DEFER in case of all errors.

Yea you are right. Its returning -EPROBE_DEFER. I will change this in next version.

Regards,
Rahul Sharma.

Quoted 14 lines

Thanks,
Inki Dae

Quoted 10 lines
drivers/gpu/drm/exynos/exynos_hdmi.c +2 -2
+             }
      }
-     res->regul_count = ARRAY_SIZE(supply);
 
-     return ret;
+     return 0;
 fail:
      DRM_ERROR("HDMI resource init - failed\n");
      return ret;

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