All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] drm/exynos: defer hdmi probe when fail to get regulators
@ 2014-06-18 13:42 Rahul Sharma
  2014-06-19  4:04 ` Inki Dae
  0 siblings, 1 reply; 3+ messages in thread
From: Rahul Sharma @ 2014-06-18 13:42 UTC (permalink / raw)
  To: dri-devel
  Cc: linux-samsung-soc, inki.dae, kgene.kim, joshi, r.sh.open, 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.

Signed-off-by: Rahul Sharma <rahul.sharma@samsung.com>
---
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(-)

diff --git a/drivers/gpu/drm/exynos/exynos_hdmi.c b/drivers/gpu/drm/exynos/exynos_hdmi.c
index aa259b0..3f24c49 100644
--- a/drivers/gpu/drm/exynos/exynos_hdmi.c
+++ b/drivers/gpu/drm/exynos/exynos_hdmi.c
@@ -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;
-- 
1.7.9.5

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] drm/exynos: defer hdmi probe when fail to get regulators
  2014-06-18 13:42 [PATCH] drm/exynos: defer hdmi probe when fail to get regulators Rahul Sharma
@ 2014-06-19  4:04 ` Inki Dae
  2014-06-19  4:37   ` Rahul Sharma
  0 siblings, 1 reply; 3+ messages in thread
From: Inki Dae @ 2014-06-19  4:04 UTC (permalink / raw)
  To: Rahul Sharma; +Cc: kgene.kim, linux-samsung-soc, joshi, dri-devel

On 2014년 06월 18일 22:42, Rahul Sharma wrote:
> 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.

> 
> Signed-off-by: Rahul Sharma <rahul.sharma@samsung.com>
> ---
> 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(-)
> 
> diff --git a/drivers/gpu/drm/exynos/exynos_hdmi.c b/drivers/gpu/drm/exynos/exynos_hdmi.c
> index aa259b0..3f24c49 100644
> --- a/drivers/gpu/drm/exynos/exynos_hdmi.c
> +++ b/drivers/gpu/drm/exynos/exynos_hdmi.c
> @@ -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;

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

> +		}
>  	}
> -	res->regul_count = ARRAY_SIZE(supply);
>  
> -	return ret;
> +	return 0;
>  fail:
>  	DRM_ERROR("HDMI resource init - failed\n");
>  	return ret;
> 

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] drm/exynos: defer hdmi probe when fail to get regulators
  2014-06-19  4:04 ` Inki Dae
@ 2014-06-19  4:37   ` Rahul Sharma
  0 siblings, 0 replies; 3+ messages in thread
From: Rahul Sharma @ 2014-06-19  4:37 UTC (permalink / raw)
  To: Inki Dae; +Cc: Kukjin Kim, linux-samsung-soc, sunil joshi, dri-devel

Thanks Inki,

On 19 June 2014 09:34, Inki Dae <inki.dae@samsung.com> wrote:
> On 2014년 06월 18일 22:42, Rahul Sharma wrote:
>> 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.
>
>>
>> Signed-off-by: Rahul Sharma <rahul.sharma@samsung.com>
>> ---
>> 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(-)
>>
>> diff --git a/drivers/gpu/drm/exynos/exynos_hdmi.c b/drivers/gpu/drm/exynos/exynos_hdmi.c
>> index aa259b0..3f24c49 100644
>> --- a/drivers/gpu/drm/exynos/exynos_hdmi.c
>> +++ b/drivers/gpu/drm/exynos/exynos_hdmi.c
>> @@ -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;
>
> 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.

> Thanks,
> Inki Dae
>
>> +             }
>>       }
>> -     res->regul_count = ARRAY_SIZE(supply);
>>
>> -     return ret;
>> +     return 0;
>>  fail:
>>       DRM_ERROR("HDMI resource init - failed\n");
>>       return ret;
>>
>
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2014-06-19  4:37 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-06-18 13:42 [PATCH] drm/exynos: defer hdmi probe when fail to get regulators Rahul Sharma
2014-06-19  4:04 ` Inki Dae
2014-06-19  4:37   ` Rahul Sharma

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.