Skip to contentSkip to conversation

omap_hsmmc: use mmc_regulator_get_supply() to get regulators

PATCH In review Kishon Vijay Abraham I 3 participants 9 messages Jun 7, 2017 – Jun 12, 2017

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

cover omap_hsmmc: use mmc_regulator_get_supply() to get regulators

This series deprecates "vmmc_aux" supply property and uses the generic "vqmmc" property.

Not sure how exactly to handle omap3-overo-base.dtsi which already has both vqmmc-supply and vmmc_aux-supply without breaking old dt compatibility. (vqmmc-supply seems to have been added there by mistake from 3.15).

In the dt series that will follow, will replace all vmmc_aux-supply with vqmmc-supply (In omap3-overo-base.dtsi remove the existing vqmmc-supply and then replace vmmc_aux-supply with vqmmc-supply).

Kishon Vijay Abraham I (3):
mmc: host: omap_hsmmc: Do not initialize MMC regulators to NULL on
error
mmc: host: omap_hsmmc: use mmc_regulator_get_supply() to get
regulators
Documentation: dt-bindings: Document deprecation of "vmmc_aux" and
using "vqmmc"

 .../devicetree/bindings/mmc/ti-omap-hsmmc.txt      |  2 +-
 drivers/mmc/host/omap_hsmmc.c                      | 55 +++++++++-------------
 2 files changed, 24 insertions(+), 33 deletions(-)
Signature · 1 line
2.11.0
#1 lore raw

PATCH 1/3 mmc: host: omap_hsmmc: Do not initialize MMC regulators to NULL on error

Do not initialize MMC regulators to NULL on error in omap_hsmmc driver similar to what is done in mmc_regulator_get_supply(). This is in preparation for using mmc_regulator_get_supply() to get MMC regulators.

---
 drivers/mmc/host/omap_hsmmc.c | 21 +++++++++------------
 1 file changed, 9 insertions(+), 12 deletions(-)
drivers/mmc/host/omap_hsmmc.c +9 -12
index 8c39dccacf39..de82ac0a87e2 100644
@@ -250,14 +250,14 @@ static int omap_hsmmc_enable_supply(struct mmc_host *mmc)
 	struct omap_hsmmc_host *host = mmc_priv(mmc);
 	struct mmc_ios *ios = &mmc->ios;
 
-	if (mmc->supply.vmmc) {
+	if (!IS_ERR(mmc->supply.vmmc)) {
 		ret = mmc_regulator_set_ocr(mmc, mmc->supply.vmmc, ios->vdd);
 		if (ret)
 			return ret;
 	}
 
 	/* Enable interface voltage rail, if needed */
-	if (mmc->supply.vqmmc && !host->vqmmc_enabled) {
+	if (!IS_ERR(mmc->supply.vqmmc) && !host->vqmmc_enabled) {
 		ret = regulator_enable(mmc->supply.vqmmc);
 		if (ret) {
 			dev_err(mmc_dev(mmc), "vmmc_aux reg enable failed\n");
@@ -269,7 +269,7 @@ static int omap_hsmmc_enable_supply(struct mmc_host *mmc)
 	return 0;
 
 err_vqmmc:
-	if (mmc->supply.vmmc)
+	if (!IS_ERR(mmc->supply.vmmc))
 		mmc_regulator_set_ocr(mmc, mmc->supply.vmmc, 0);
 
 	return ret;
@@ -281,7 +281,7 @@ static int omap_hsmmc_disable_supply(struct mmc_host *mmc)
 	int status;
 	struct omap_hsmmc_host *host = mmc_priv(mmc);
 
-	if (mmc->supply.vqmmc && host->vqmmc_enabled) {
+	if (!IS_ERR(mmc->supply.vqmmc) && host->vqmmc_enabled) {
 		ret = regulator_disable(mmc->supply.vqmmc);
 		if (ret) {
 			dev_err(mmc_dev(mmc), "vmmc_aux reg disable failed\n");
@@ -290,7 +290,7 @@ static int omap_hsmmc_disable_supply(struct mmc_host *mmc)
 		host->vqmmc_enabled = 0;
 	}
 
-	if (mmc->supply.vmmc) {
+	if (!IS_ERR(mmc->supply.vmmc)) {
 		ret = mmc_regulator_set_ocr(mmc, mmc->supply.vmmc, 0);
 		if (ret)
 			goto err_set_ocr;
@@ -299,7 +299,7 @@ static int omap_hsmmc_disable_supply(struct mmc_host *mmc)
 	return 0;
 
 err_set_ocr:
-	if (mmc->supply.vqmmc) {
+	if (!IS_ERR(mmc->supply.vqmmc)) {
 		status = regulator_enable(mmc->supply.vqmmc);
 		if (status)
 			dev_err(mmc_dev(mmc), "vmmc_aux re-enable failed\n");
@@ -313,7 +313,7 @@ static int omap_hsmmc_set_pbias(struct omap_hsmmc_host *host, bool power_on,
 {
 	int ret;
 
-	if (!host->pbias)
+	if (IS_ERR(host->pbias))
 		return 0;
 
 	if (power_on) {
@@ -363,7 +363,7 @@ static int omap_hsmmc_set_power(struct omap_hsmmc_host *host, int power_on,
 	 * If we don't see a Vcc regulator, assume it's a fixed
 	 * voltage always-on regulator.
 	 */
-	if (!mmc->supply.vmmc)
+	if (IS_ERR(mmc->supply.vmmc))
 		return 0;
 
 	if (mmc_pdata(host)->before_set_reg)
@@ -415,7 +415,7 @@ static int omap_hsmmc_disable_boot_regulator(struct regulator *reg)
 {
 	int ret;
 
-	if (!reg)
+	if (IS_ERR(reg))
 		return 0;
 
 	if (regulator_is_enabled(reg)) {
@@ -480,7 +480,6 @@ static int omap_hsmmc_reg_get(struct omap_hsmmc_host *host)
 			return ret;
 		dev_dbg(host->dev, "unable to get vmmc regulator %ld\n",
 			PTR_ERR(mmc->supply.vmmc));
-		mmc->supply.vmmc = NULL;
 	} else {
 		ocr_value = mmc_regulator_get_ocrmask(mmc->supply.vmmc);
 		if (ocr_value > 0)
@@ -495,7 +494,6 @@ static int omap_hsmmc_reg_get(struct omap_hsmmc_host *host)
 			return ret;
 		dev_dbg(host->dev, "unable to get vmmc_aux regulator %ld\n",
 			PTR_ERR(mmc->supply.vqmmc));
-		mmc->supply.vqmmc = NULL;
 	}
 
 	host->pbias = devm_regulator_get_optional(host->dev, "pbias");
@@ -508,7 +506,6 @@ static int omap_hsmmc_reg_get(struct omap_hsmmc_host *host)
 		}
 		dev_dbg(host->dev, "unable to get pbias regulator %ld\n",
 			PTR_ERR(host->pbias));
-		host->pbias = NULL;
 	}
 
 	/* For eMMC do not power off when not in sleep state */
Signature · 1 line
2.11.0
#2 lore raw

PATCH 2/3 mmc: host: omap_hsmmc: use mmc_regulator_get_supply() to get regulators

In reply to Kishon Vijay Abraham I

In preparation for using the generic mmc binding for io regulator ("vqmmc"), use mmc_regulator_get_supply() to get vmmc and vqmmc regulators. Only if "vqmmc" regulator isn't found, fallback to use "vmmc_aux" regulator.

---
 drivers/mmc/host/omap_hsmmc.c | 34 ++++++++++++++--------------------
 1 file changed, 14 insertions(+), 20 deletions(-)
drivers/mmc/host/omap_hsmmc.c +14 -20
index de82ac0a87e2..f6da8bc0d64f 100644
@@ -466,34 +466,27 @@ static int omap_hsmmc_disable_boot_regulators(struct omap_hsmmc_host *host)
 
 static int omap_hsmmc_reg_get(struct omap_hsmmc_host *host)
 {
-	int ocr_value = 0;
 	int ret;
 	struct mmc_host *mmc = host->mmc;
 
 	if (mmc_pdata(host)->set_power)
 		return 0;
 
-	mmc->supply.vmmc = devm_regulator_get_optional(host->dev, "vmmc");
-	if (IS_ERR(mmc->supply.vmmc)) {
-		ret = PTR_ERR(mmc->supply.vmmc);
-		if ((ret != -ENODEV) && host->dev->of_node)
-			return ret;
-		dev_dbg(host->dev, "unable to get vmmc regulator %ld\n",
-			PTR_ERR(mmc->supply.vmmc));
-	} else {
-		ocr_value = mmc_regulator_get_ocrmask(mmc->supply.vmmc);
-		if (ocr_value > 0)
-			mmc_pdata(host)->ocr_mask = ocr_value;
-	}
+	ret = mmc_regulator_get_supply(mmc);
+	if (ret == -EPROBE_DEFER)
+		return ret;
 
 	/* Allow an aux regulator */
-	mmc->supply.vqmmc = devm_regulator_get_optional(host->dev, "vmmc_aux");
 	if (IS_ERR(mmc->supply.vqmmc)) {
-		ret = PTR_ERR(mmc->supply.vqmmc);
-		if ((ret != -ENODEV) && host->dev->of_node)
-			return ret;
-		dev_dbg(host->dev, "unable to get vmmc_aux regulator %ld\n",
-			PTR_ERR(mmc->supply.vqmmc));
+		mmc->supply.vqmmc = devm_regulator_get_optional(host->dev,
+								"vmmc_aux");
+		if (IS_ERR(mmc->supply.vqmmc)) {
+			ret = PTR_ERR(mmc->supply.vqmmc);
+			if ((ret != -ENODEV) && host->dev->of_node)
+				return ret;
+			dev_dbg(host->dev, "unable to get vmmc_aux regulator %ld\n",
+				PTR_ERR(mmc->supply.vqmmc));
+		}
 	}
 
 	host->pbias = devm_regulator_get_optional(host->dev, "pbias");
@@ -2143,7 +2136,8 @@ static int omap_hsmmc_probe(struct platform_device *pdev)
 	if (ret)
 		goto err_irq;
 
-	mmc->ocr_avail = mmc_pdata(host)->ocr_mask;
+	if (mmc_pdata(host)->ocr_mask)
+		mmc->ocr_avail = mmc_pdata(host)->ocr_mask;
 
 	omap_hsmmc_disable_irq(host);
 
Signature · 1 line
2.11.0
#4 lore raw

PATCH 3/3 Documentation: dt-bindings: Document deprecation of "vmmc_aux" and using "vqmmc"

In reply to Kishon Vijay Abraham I

Document deprecation of "vmmc_aux" for io regulator and use of generic mmc binding "vqmmc" in omap-hsmmc.

---
 Documentation/devicetree/bindings/mmc/ti-omap-hsmmc.txt | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Documentation/devicetree/bindings/mmc/ti-omap-hsmmc.txt +1 -1
index 74166a0d460d..0e026c151c1c 100644
@@ -18,7 +18,7 @@ Required properties:
 Optional properties:
 ti,dual-volt: boolean, supports dual voltage cards
 <supply-name>-supply: phandle to the regulator device tree node
-"supply-name" examples are "vmmc", "vmmc_aux" etc
+"supply-name" examples are "vmmc", "vmmc_aux"(deprecated)/"vqmmc" etc
 ti,non-removable: non-removable slot (like eMMC)
 ti,needs-special-reset: Requires a special softreset sequence
 ti,needs-special-hs-handling: HSMMC IP needs special setting for handling High Speed
Signature · 1 line
2.11.0
#3 lore raw

Re: [PATCH 2/3] mmc: host: omap_hsmmc: use mmc_regulator_get_supply() to get regulators

In reply to Kishon Vijay Abraham I

drivers/mmc/host/omap_hsmmc.c static int omap_hsmmc_probe(struct platform_device *pdev) · line 2140

Quoted 8 lines
        host->pbias = devm_regulator_get_optional(host->dev, "pbias");
drivers/mmc/host/omap_hsmmc.c +2 -1
@@ -2143,7 +2136,8 @@ static int omap_hsmmc_probe(struct platform_device *pdev)
        if (ret)
                goto err_irq;
 
-       mmc->ocr_avail = mmc_pdata(host)->ocr_mask;
+       if (mmc_pdata(host)->ocr_mask)
+               mmc->ocr_avail = mmc_pdata(host)->ocr_mask;

This should rather be:

if (!mmc->ocr_avail)

     mmc->ocr_avail = mmc_pdata(host)->ocr_mask

In other words, fall back to the platform ocr mask.

Quoted 6 lines
drivers/mmc/host/omap_hsmmc.c +0 -1
        omap_hsmmc_disable_irq(host);
 
--

2.11.0

Kind regards
Uffe

#6 lore raw
In reply to Kishon Vijay Abraham I
Quoted 20 lines · Kishon Vijay Abraham I

This series deprecates "vmmc_aux" supply property and uses the generic "vqmmc" property.

Not sure how exactly to handle omap3-overo-base.dtsi which already has both vqmmc-supply and vmmc_aux-supply without breaking old dt compatibility. (vqmmc-supply seems to have been added there by mistake from 3.15).

In the dt series that will follow, will replace all vmmc_aux-supply with vqmmc-supply (In omap3-overo-base.dtsi remove the existing vqmmc-supply and then replace vmmc_aux-supply with vqmmc-supply).

Kishon Vijay Abraham I (3):
mmc: host: omap_hsmmc: Do not initialize MMC regulators to NULL on
error
mmc: host: omap_hsmmc: use mmc_regulator_get_supply() to get
regulators
Documentation: dt-bindings: Document deprecation of "vmmc_aux" and
using "vqmmc"

Quoted 7 lines
 .../devicetree/bindings/mmc/ti-omap-hsmmc.txt      |  2 +-
 drivers/mmc/host/omap_hsmmc.c                      | 55 +++++++++-------------
 2 files changed, 24 insertions(+), 33 deletions(-)

--
2.11.0

Besides the minor comment for patch2 this looks good to me.

In case there are no other comments, and that you agree with my suggested change, you don't need to re-spin.

Kind regards
Uffe

#7 lore raw

Hi Uffe,

Quoted 25 lines · Ulf Hansson
Quoted 24 lines · Kishon Vijay Abraham I

This series deprecates "vmmc_aux" supply property and uses the generic "vqmmc" property.

Not sure how exactly to handle omap3-overo-base.dtsi which already has both vqmmc-supply and vmmc_aux-supply without breaking old dt compatibility. (vqmmc-supply seems to have been added there by mistake from 3.15).

In the dt series that will follow, will replace all vmmc_aux-supply with vqmmc-supply (In omap3-overo-base.dtsi remove the existing vqmmc-supply and then replace vmmc_aux-supply with vqmmc-supply).

Kishon Vijay Abraham I (3):
mmc: host: omap_hsmmc: Do not initialize MMC regulators to NULL on
error
mmc: host: omap_hsmmc: use mmc_regulator_get_supply() to get
regulators
Documentation: dt-bindings: Document deprecation of "vmmc_aux" and
using "vqmmc"

 .../devicetree/bindings/mmc/ti-omap-hsmmc.txt      |  2 +-
 drivers/mmc/host/omap_hsmmc.c                      | 55 +++++++++-------------
 2 files changed, 24 insertions(+), 33 deletions(-)
Quoted 8 lines
Quoted 3 lines

--
2.11.0

Besides the minor comment for patch2 this looks good to me.

In case there are no other comments, and that you agree with my suggested change, you don't need to re-spin.

Your suggested change looks good.

Thanks
Kishon

maintainer Acked-by on v1 3/3
#5 lore raw

Re: [PATCH 3/3] Documentation: dt-bindings: Document deprecation of "vmmc_aux" and using "vqmmc"

In reply to Kishon Vijay Abraham I
Quoted 7 lines · Kishon Vijay Abraham I

Document deprecation of "vmmc_aux" for io regulator and use of generic mmc binding "vqmmc" in omap-hsmmc.

---
 Documentation/devicetree/bindings/mmc/ti-omap-hsmmc.txt | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
#8 lore raw
In reply to Kishon Vijay Abraham I
Quoted 32 lines · Kishon Vijay Abraham I

Hi Uffe,

Quoted 29 lines · Ulf Hansson
Quoted 27 lines · Kishon Vijay Abraham I

This series deprecates "vmmc_aux" supply property and uses the generic "vqmmc" property.

Not sure how exactly to handle omap3-overo-base.dtsi which already has both vqmmc-supply and vmmc_aux-supply without breaking old dt compatibility. (vqmmc-supply seems to have been added there by mistake from 3.15).

In the dt series that will follow, will replace all vmmc_aux-supply with vqmmc-supply (In omap3-overo-base.dtsi remove the existing vqmmc-supply and then replace vmmc_aux-supply with vqmmc-supply).

Kishon Vijay Abraham I (3):
mmc: host: omap_hsmmc: Do not initialize MMC regulators to NULL on
error
mmc: host: omap_hsmmc: use mmc_regulator_get_supply() to get
regulators
Documentation: dt-bindings: Document deprecation of "vmmc_aux" and
using "vqmmc"

 .../devicetree/bindings/mmc/ti-omap-hsmmc.txt      |  2 +-
 drivers/mmc/host/omap_hsmmc.c                      | 55 +++++++++-------------
 2 files changed, 24 insertions(+), 33 deletions(-)

--
2.11.0

Quoted 6 lines
Quoted 4 lines

Besides the minor comment for patch2 this looks good to me.

In case there are no other comments, and that you agree with my suggested change, you don't need to re-spin.

Your suggested change looks good.

Great! I amended the change and I have applied this series for next!

Kind regards
Uffe