Skip to contentSkip to conversation

mxcmmc: Add the ability to bind a regulator to manage the MMC card voltage

PATCH In review Alberto Panizzo 5 participants 14 messages Nov 2, 2010 – Nov 9, 2010

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

PATCH 1/1 mxcmmc: Add the ability to bind a regulator to manage the MMC card voltage

This implementation is based on the pxamci.c driver and it will be used to support the mx31_3ds machine.

---

This patch is based on the pengutronix for-rmk branch and apply to the linus tre, version:2.6.37-rc1

..cc the lists, sorry for the double mail.

 drivers/mmc/host/mxcmmc.c |   48 +++++++++++++++++++++++++++++++++++++++-----
 1 files changed, 42 insertions(+), 6 deletions(-)
drivers/mmc/host/mxcmmc.c +42 -6
index 350f78e..e4637fc 100644
@@ -31,6 +31,7 @@
 #include <linux/clk.h>
 #include <linux/io.h>
 #include <linux/gpio.h>
+#include <linux/regulator/consumer.h>
 
 #include <asm/dma.h>
 #include <asm/irq.h>
@@ -141,10 +142,45 @@ struct mxcmci_host {
 
 	struct work_struct	datawork;
 	spinlock_t		lock;
+
+	struct regulator	*vcc;
 };
 
 static void mxcmci_set_clk_rate(struct mxcmci_host *host, unsigned int clk_ios);
 
+static inline void mxcmci_init_ocr(struct mxcmci_host *host)
+{
+#ifdef CONFIG_REGULATOR
+	host->vcc = regulator_get(mmc_dev(host->mmc), "vmmc");
+
+	if (IS_ERR(host->vcc)) {
+		host->vcc = NULL;
+	} else {
+		host->mmc->ocr_avail = mmc_regulator_get_ocrmask(host->vcc);
+		if (host->pdata && host->pdata->ocr_avail)
+			dev_warn(mmc_dev(host->mmc),
+				"pdata->ocr_avail will not be used\n");
+	}
+#endif
+	if (host->vcc == NULL) {
+		/* fall-back to platform data */
+		if (host->pdata && host->pdata->ocr_avail)
+			host->mmc->ocr_avail = host->pdata->ocr_avail;
+		else
+			host->mmc->ocr_avail = MMC_VDD_32_33 | MMC_VDD_33_34;
+	}
+}
+
+static inline void mxcmci_set_power(struct mxcmci_host *host, unsigned int vdd)
+{
+#ifdef CONFIG_REGULATOR
+	if (host->vcc)
+		mmc_regulator_set_ocr(host->vcc, vdd);
+#endif
+	if (host->pdata && host->pdata->setpower)
+		host->pdata->setpower(mmc_dev(host->mmc), vdd);
+}
+
 static inline int mxcmci_use_dma(struct mxcmci_host *host)
 {
 	return host->do_dma;
@@ -680,9 +716,9 @@ static void mxcmci_set_ios(struct mmc_host *mmc, struct mmc_ios *ios)
 		host->cmdat &= ~CMD_DAT_CONT_BUS_WIDTH_4;
 
 	if (host->power_mode != ios->power_mode) {
-		if (host->pdata && host->pdata->setpower)
-			host->pdata->setpower(mmc_dev(mmc), ios->vdd);
+		mxcmci_set_power(host, ios->vdd);
 		host->power_mode = ios->power_mode;
+
 		if (ios->power_mode == MMC_POWER_ON)
 			host->cmdat |= CMD_DAT_CONT_INIT;
 	}
@@ -808,10 +844,7 @@ static int mxcmci_probe(struct platform_device *pdev)
 	host->pdata = pdev->dev.platform_data;
 	spin_lock_init(&host->lock);
 
-	if (host->pdata && host->pdata->ocr_avail)
-		mmc->ocr_avail = host->pdata->ocr_avail;
-	else
-		mmc->ocr_avail = MMC_VDD_32_33 | MMC_VDD_33_34;
+	mxcmci_init_ocr(host);
 
 	if (host->pdata && host->pdata->dat3_card_detect)
 		host->default_irq_mask =
@@ -916,6 +949,9 @@ static int mxcmci_remove(struct platform_device *pdev)
 
 	mmc_remove_host(mmc);
 
+	if (host->vcc)
+		regulator_put(host->vcc);
+
 	if (host->pdata && host->pdata->exit)
 		host->pdata->exit(&pdev->dev, mmc);
 
Signature · 1 line
1.6.3.3
maintainer Acked-by on v1 1/1
#1 lore raw
Quoted 4 lines · Alberto Panizzo

This implementation is based on the pxamci.c driver and it will be used to support the mx31_3ds machine.

Looks good to me

Quoted 109 lines

---

This patch is based on the pengutronix for-rmk branch and apply to the linus tre, version:2.6.37-rc1

..cc the lists, sorry for the double mail.

 drivers/mmc/host/mxcmmc.c |   48 +++++++++++++++++++++++++++++++++++++++-----
 1 files changed, 42 insertions(+), 6 deletions(-)
drivers/mmc/host/mxcmmc.c +42 -6
index 350f78e..e4637fc 100644
@@ -31,6 +31,7 @@
 #include <linux/clk.h>
 #include <linux/io.h>
 #include <linux/gpio.h>
+#include <linux/regulator/consumer.h>
 
 #include <asm/dma.h>
 #include <asm/irq.h>
@@ -141,10 +142,45 @@ struct mxcmci_host {
 
 	struct work_struct	datawork;
 	spinlock_t		lock;
+
+	struct regulator	*vcc;
 };
 
 static void mxcmci_set_clk_rate(struct mxcmci_host *host, unsigned int clk_ios);
 
+static inline void mxcmci_init_ocr(struct mxcmci_host *host)
+{
+#ifdef CONFIG_REGULATOR
+	host->vcc = regulator_get(mmc_dev(host->mmc), "vmmc");
+
+	if (IS_ERR(host->vcc)) {
+		host->vcc = NULL;
+	} else {
+		host->mmc->ocr_avail = mmc_regulator_get_ocrmask(host->vcc);
+		if (host->pdata && host->pdata->ocr_avail)
+			dev_warn(mmc_dev(host->mmc),
+				"pdata->ocr_avail will not be used\n");
+	}
+#endif
+	if (host->vcc == NULL) {
+		/* fall-back to platform data */
+		if (host->pdata && host->pdata->ocr_avail)
+			host->mmc->ocr_avail = host->pdata->ocr_avail;
+		else
+			host->mmc->ocr_avail = MMC_VDD_32_33 | MMC_VDD_33_34;
+	}
+}
+
+static inline void mxcmci_set_power(struct mxcmci_host *host, unsigned int vdd)
+{
+#ifdef CONFIG_REGULATOR
+	if (host->vcc)
+		mmc_regulator_set_ocr(host->vcc, vdd);
+#endif
+	if (host->pdata && host->pdata->setpower)
+		host->pdata->setpower(mmc_dev(host->mmc), vdd);
+}
+
 static inline int mxcmci_use_dma(struct mxcmci_host *host)
 {
 	return host->do_dma;
@@ -680,9 +716,9 @@ static void mxcmci_set_ios(struct mmc_host *mmc, struct mmc_ios *ios)
 		host->cmdat &= ~CMD_DAT_CONT_BUS_WIDTH_4;
 
 	if (host->power_mode != ios->power_mode) {
-		if (host->pdata && host->pdata->setpower)
-			host->pdata->setpower(mmc_dev(mmc), ios->vdd);
+		mxcmci_set_power(host, ios->vdd);
 		host->power_mode = ios->power_mode;
+
 		if (ios->power_mode == MMC_POWER_ON)
 			host->cmdat |= CMD_DAT_CONT_INIT;
 	}
@@ -808,10 +844,7 @@ static int mxcmci_probe(struct platform_device *pdev)
 	host->pdata = pdev->dev.platform_data;
 	spin_lock_init(&host->lock);
 
-	if (host->pdata && host->pdata->ocr_avail)
-		mmc->ocr_avail = host->pdata->ocr_avail;
-	else
-		mmc->ocr_avail = MMC_VDD_32_33 | MMC_VDD_33_34;
+	mxcmci_init_ocr(host);
 
 	if (host->pdata && host->pdata->dat3_card_detect)
 		host->default_irq_mask =
@@ -916,6 +949,9 @@ static int mxcmci_remove(struct platform_device *pdev)
 
 	mmc_remove_host(mmc);
 
+	if (host->vcc)
+		regulator_put(host->vcc);
+
 	if (host->pdata && host->pdata->exit)
 		host->pdata->exit(&pdev->dev, mmc);
 
Signature · 1 line
1.6.3.3
Signature · 4 lines
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |
#2 lore raw
Quoted 9 lines · Sascha Hauer
Quoted 4 lines · Alberto Panizzo

This implementation is based on the pxamci.c driver and it will be used to support the mx31_3ds machine.

Looks good to me

Tks Sascha, the only difference between the pxa implementations is in this part:

Quoted 10 lines

drivers/mmc/host/mxcmmc.c struct mxcmci_host { · line 183

Quoted 10 lines
drivers/mmc/host/mxcmmc.c +10 -0
+static inline void mxcmci_set_power(struct mxcmci_host *host, unsigned int vdd)
+{
+#ifdef CONFIG_REGULATOR
+	if (host->vcc)
+		mmc_regulator_set_ocr(host->vcc, vdd);
+#endif
+	if (host->pdata && host->pdata->setpower)
+		host->pdata->setpower(mmc_dev(host->mmc), vdd);
+}
+

The original one have this test:

	if (!host->vcc && host->pdata && host->pdata->setpower)
		host->pdata->setpower(mmc_dev(host->mmc), vdd);

But removing it, we are able to add further action than only powering with the right voltage the mmc card.
In the case of the mx31_3ds we are able to enable the external hardware buffer only when it is really needed.

Signature · 4 lines
Alberto!

        Be Persistent!
                - Greg Kroah-Hartman (FOSDEM 2010)
#3 lore raw
In reply to Sascha Hauer
Quoted 10 lines · Sascha Hauer
Quoted 4 lines · Alberto Panizzo

This implementation is based on the pxamci.c driver and it will be used to support the mx31_3ds machine.

Looks good to me

Sascha, must this one go to the Chris Ball mmc tree? or can you pick it up directly?
Is there any chance to have it on one of .37-rcN?

(Adding Chris to cc.)

Thanks,
Alberto!

Quoted 110 lines
Quoted 109 lines

---

This patch is based on the pengutronix for-rmk branch and apply to the linus tre, version:2.6.37-rc1

..cc the lists, sorry for the double mail.

 drivers/mmc/host/mxcmmc.c |   48 +++++++++++++++++++++++++++++++++++++++-----
 1 files changed, 42 insertions(+), 6 deletions(-)
drivers/mmc/host/mxcmmc.c +42 -6
index 350f78e..e4637fc 100644
@@ -31,6 +31,7 @@
 #include <linux/clk.h>
 #include <linux/io.h>
 #include <linux/gpio.h>
+#include <linux/regulator/consumer.h>
 
 #include <asm/dma.h>
 #include <asm/irq.h>
@@ -141,10 +142,45 @@ struct mxcmci_host {
 
 	struct work_struct	datawork;
 	spinlock_t		lock;
+
+	struct regulator	*vcc;
 };
 
 static void mxcmci_set_clk_rate(struct mxcmci_host *host, unsigned int clk_ios);
 
+static inline void mxcmci_init_ocr(struct mxcmci_host *host)
+{
+#ifdef CONFIG_REGULATOR
+	host->vcc = regulator_get(mmc_dev(host->mmc), "vmmc");
+
+	if (IS_ERR(host->vcc)) {
+		host->vcc = NULL;
+	} else {
+		host->mmc->ocr_avail = mmc_regulator_get_ocrmask(host->vcc);
+		if (host->pdata && host->pdata->ocr_avail)
+			dev_warn(mmc_dev(host->mmc),
+				"pdata->ocr_avail will not be used\n");
+	}
+#endif
+	if (host->vcc == NULL) {
+		/* fall-back to platform data */
+		if (host->pdata && host->pdata->ocr_avail)
+			host->mmc->ocr_avail = host->pdata->ocr_avail;
+		else
+			host->mmc->ocr_avail = MMC_VDD_32_33 | MMC_VDD_33_34;
+	}
+}
+
+static inline void mxcmci_set_power(struct mxcmci_host *host, unsigned int vdd)
+{
+#ifdef CONFIG_REGULATOR
+	if (host->vcc)
+		mmc_regulator_set_ocr(host->vcc, vdd);
+#endif
+	if (host->pdata && host->pdata->setpower)
+		host->pdata->setpower(mmc_dev(host->mmc), vdd);
+}
+
 static inline int mxcmci_use_dma(struct mxcmci_host *host)
 {
 	return host->do_dma;
@@ -680,9 +716,9 @@ static void mxcmci_set_ios(struct mmc_host *mmc, struct mmc_ios *ios)
 		host->cmdat &= ~CMD_DAT_CONT_BUS_WIDTH_4;
 
 	if (host->power_mode != ios->power_mode) {
-		if (host->pdata && host->pdata->setpower)
-			host->pdata->setpower(mmc_dev(mmc), ios->vdd);
+		mxcmci_set_power(host, ios->vdd);
 		host->power_mode = ios->power_mode;
+
 		if (ios->power_mode == MMC_POWER_ON)
 			host->cmdat |= CMD_DAT_CONT_INIT;
 	}
@@ -808,10 +844,7 @@ static int mxcmci_probe(struct platform_device *pdev)
 	host->pdata = pdev->dev.platform_data;
 	spin_lock_init(&host->lock);
 
-	if (host->pdata && host->pdata->ocr_avail)
-		mmc->ocr_avail = host->pdata->ocr_avail;
-	else
-		mmc->ocr_avail = MMC_VDD_32_33 | MMC_VDD_33_34;
+	mxcmci_init_ocr(host);
 
 	if (host->pdata && host->pdata->dat3_card_detect)
 		host->default_irq_mask =
@@ -916,6 +949,9 @@ static int mxcmci_remove(struct platform_device *pdev)
 
 	mmc_remove_host(mmc);
 
+	if (host->vcc)
+		regulator_put(host->vcc);
+
 	if (host->pdata && host->pdata->exit)
 		host->pdata->exit(&pdev->dev, mmc);
 
Signature · 1 line
1.6.3.3
maintainer
#4 lore raw
Quoted 7 lines · Alberto Panizzo
Quoted 6 lines · Sascha Hauer
Quoted 4 lines · Alberto Panizzo

This implementation is based on the pxamci.c driver and it will be used to support the mx31_3ds machine.

Quoted 7 lines
Quoted 4 lines

Looks good to me

Sascha, must this one go to the Chris Ball mmc tree? or can you pick it up directly?

Better to pass this via the mmc tree.

Sascha

Signature · 4 lines
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |
#5 lore raw
In reply to Alberto Panizzo
Quoted 11 lines · Alberto Panizzo
Quoted 10 lines · Sascha Hauer
Quoted 4 lines · Alberto Panizzo

This implementation is based on the pxamci.c driver and it will be used to support the mx31_3ds machine.

Looks good to me

Chris,
Please, any comment on this one?

Thanks,
Alberto!

Quoted 111 lines
Quoted 111 lines
Quoted 110 lines

---

This patch is based on the pengutronix for-rmk branch and apply to the linus tre, version:2.6.37-rc1

..cc the lists, sorry for the double mail.

 drivers/mmc/host/mxcmmc.c |   48 +++++++++++++++++++++++++++++++++++++++-----
 1 files changed, 42 insertions(+), 6 deletions(-)
drivers/mmc/host/mxcmmc.c +42 -6
index 350f78e..e4637fc 100644
@@ -31,6 +31,7 @@
 #include <linux/clk.h>
 #include <linux/io.h>
 #include <linux/gpio.h>
+#include <linux/regulator/consumer.h>
 
 #include <asm/dma.h>
 #include <asm/irq.h>
@@ -141,10 +142,45 @@ struct mxcmci_host {
 
 	struct work_struct	datawork;
 	spinlock_t		lock;
+
+	struct regulator	*vcc;
 };
 
 static void mxcmci_set_clk_rate(struct mxcmci_host *host, unsigned int clk_ios);
 
+static inline void mxcmci_init_ocr(struct mxcmci_host *host)
+{
+#ifdef CONFIG_REGULATOR
+	host->vcc = regulator_get(mmc_dev(host->mmc), "vmmc");
+
+	if (IS_ERR(host->vcc)) {
+		host->vcc = NULL;
+	} else {
+		host->mmc->ocr_avail = mmc_regulator_get_ocrmask(host->vcc);
+		if (host->pdata && host->pdata->ocr_avail)
+			dev_warn(mmc_dev(host->mmc),
+				"pdata->ocr_avail will not be used\n");
+	}
+#endif
+	if (host->vcc == NULL) {
+		/* fall-back to platform data */
+		if (host->pdata && host->pdata->ocr_avail)
+			host->mmc->ocr_avail = host->pdata->ocr_avail;
+		else
+			host->mmc->ocr_avail = MMC_VDD_32_33 | MMC_VDD_33_34;
+	}
+}
+
+static inline void mxcmci_set_power(struct mxcmci_host *host, unsigned int vdd)
+{
+#ifdef CONFIG_REGULATOR
+	if (host->vcc)
+		mmc_regulator_set_ocr(host->vcc, vdd);
+#endif
+	if (host->pdata && host->pdata->setpower)
+		host->pdata->setpower(mmc_dev(host->mmc), vdd);
+}
+
 static inline int mxcmci_use_dma(struct mxcmci_host *host)
 {
 	return host->do_dma;
@@ -680,9 +716,9 @@ static void mxcmci_set_ios(struct mmc_host *mmc, struct mmc_ios *ios)
 		host->cmdat &= ~CMD_DAT_CONT_BUS_WIDTH_4;
 
 	if (host->power_mode != ios->power_mode) {
-		if (host->pdata && host->pdata->setpower)
-			host->pdata->setpower(mmc_dev(mmc), ios->vdd);
+		mxcmci_set_power(host, ios->vdd);
 		host->power_mode = ios->power_mode;
+
 		if (ios->power_mode == MMC_POWER_ON)
 			host->cmdat |= CMD_DAT_CONT_INIT;
 	}
@@ -808,10 +844,7 @@ static int mxcmci_probe(struct platform_device *pdev)
 	host->pdata = pdev->dev.platform_data;
 	spin_lock_init(&host->lock);
 
-	if (host->pdata && host->pdata->ocr_avail)
-		mmc->ocr_avail = host->pdata->ocr_avail;
-	else
-		mmc->ocr_avail = MMC_VDD_32_33 | MMC_VDD_33_34;
+	mxcmci_init_ocr(host);
 
 	if (host->pdata && host->pdata->dat3_card_detect)
 		host->default_irq_mask =
@@ -916,6 +949,9 @@ static int mxcmci_remove(struct platform_device *pdev)
 
 	mmc_remove_host(mmc);
 
+	if (host->vcc)
+		regulator_put(host->vcc);
+
 	if (host->pdata && host->pdata->exit)
 		host->pdata->exit(&pdev->dev, mmc);
 
Signature · 1 line
1.6.3.3
#6 lore raw

Hi Alberto,

Quoted 4 lines · Alberto Panizzo
Quoted 1 line
Quoted 1 line

Chris,
Please, any comment on this one?

This is pushed to mmc-next and queued for 2.6.38 now. Thanks!

Signature · 2 lines
Chris Ball   <[email protected]>   <http://printf.net/>
One Laptop Per Child
#7 lore raw
Quoted 10 lines · Chris Ball

Hi Alberto,

Quoted 4 lines · Alberto Panizzo
Quoted 1 line
Quoted 1 line

Chris,
Please, any comment on this one?

This is pushed to mmc-next and queued for 2.6.38 now. Thanks!

Ok,
Thank you!

Signature · 4 lines
Alberto!

        Be Persistent!
                - Greg Kroah-Hartman (FOSDEM 2010)
#8 lore raw

PATCH 1/1 mxcmmc: update the regulator support code to the latest API

In reply to Chris Ball

This fix also the build problem introduced by my previous patch due to unhanded API changes introduced by commit:99fc5131018cbdc3cf42ce09fb394a4e8b053c74

---

This patch apply to the current mmc-next branch

 drivers/mmc/host/mxcmmc.c |   20 ++++++++++++--------
 1 files changed, 12 insertions(+), 8 deletions(-)
drivers/mmc/host/mxcmmc.c +12 -8
index 1a7f48c..2b9f7c8 100644
@@ -150,7 +150,6 @@ static void mxcmci_set_clk_rate(struct mxcmci_host *host, unsigned int clk_ios);
 
 static inline void mxcmci_init_ocr(struct mxcmci_host *host)
 {
-#ifdef CONFIG_REGULATOR
 	host->vcc = regulator_get(mmc_dev(host->mmc), "vmmc");
 
 	if (IS_ERR(host->vcc)) {
@@ -161,7 +160,7 @@ static inline void mxcmci_init_ocr(struct mxcmci_host *host)
 			dev_warn(mmc_dev(host->mmc),
 				"pdata->ocr_avail will not be used\n");
 	}
-#endif
+
 	if (host->vcc == NULL) {
 		/* fall-back to platform data */
 		if (host->pdata && host->pdata->ocr_avail)
@@ -171,12 +170,17 @@ static inline void mxcmci_init_ocr(struct mxcmci_host *host)
 	}
 }
 
-static inline void mxcmci_set_power(struct mxcmci_host *host, unsigned int vdd)
+static inline void mxcmci_set_power(struct mxcmci_host *host,
+				    unsigned char power_mode,
+				    unsigned int vdd)
 {
-#ifdef CONFIG_REGULATOR
-	if (host->vcc)
-		mmc_regulator_set_ocr(host->vcc, vdd);
-#endif
+	if (host->vcc) {
+		if (power_mode == MMC_POWER_UP)
+			mmc_regulator_set_ocr(host->mmc, host->vcc, vdd);
+		else if (power_mode == MMC_POWER_OFF)
+			mmc_regulator_set_ocr(host->mmc, host->vcc, 0);
+	}
+
 	if (host->pdata && host->pdata->setpower)
 		host->pdata->setpower(mmc_dev(host->mmc), vdd);
 }
@@ -716,7 +720,7 @@ static void mxcmci_set_ios(struct mmc_host *mmc, struct mmc_ios *ios)
 		host->cmdat &= ~CMD_DAT_CONT_BUS_WIDTH_4;
 
 	if (host->power_mode != ios->power_mode) {
-		mxcmci_set_power(host, ios->vdd);
+		mxcmci_set_power(host, ios->power_mode, ios->vdd);
 		host->power_mode = ios->power_mode;
 
 		if (ios->power_mode == MMC_POWER_ON)
Signature · 1 line
1.6.3.3
#9 lore raw

Re: [PATCH] mxcmmc: update the regulator support code to the latest API

Quoted 3 lines · Alberto Panizzo

This fix also the build problem introduced by my previous patch due to unhanded API changes introduced by

s/handed/handled/ ?

Quoted 1 line

commit:99fc5131018cbdc3cf42ce09fb394a4e8b053c74

Linus wants to have the commit shortlog for references to other commits. After doing:

	git config --global alias.one "show -s --pretty='format:%h (%s)'"

once you can simply use the output of

	git one 99fc5131018cbdc3cf42ce09fb394a4e8b053c74

for that.

Best regards
Uwe

Signature · 2 lines
Pengutronix e.K.                           | Uwe Kleine-König            |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
#10 lore raw

Re: [PATCH] mxcmmc: update the regulator support code to the latest API

Quoted 10 lines · Uwe Kleine-König
Quoted 3 lines · Alberto Panizzo

This fix also the build problem introduced by my previous patch due to unhanded API changes introduced by

s/handed/handled/ ?

Quoted 1 line

commit:99fc5131018cbdc3cf42ce09fb394a4e8b053c74

Linus wants to have the commit shortlog for references to other commits. After doing:

Quoted 7 lines
	git config --global alias.one "show -s --pretty='format:%h (%s)'"

once you can simply use the output of

	git one 99fc5131018cbdc3cf42ce09fb394a4e8b053c74

for that.

Ok Uwe,
I will update my patch pushing rules on this.
A cleaner patch will be sent soon.

Best Regards,

Signature · 4 lines
Alberto!

        Be Persistent!
                - Greg Kroah-Hartman (FOSDEM 2010)
#11 lore raw

PATCH v2 1/1 mxcmmc: update the regulator support code to the latest API

In reply to Chris Ball

This fix also the build problem introduced by my previous patch due to not handled API changes introduced by commit:
99fc513 (mmc: Move regulator handling closer to core)

---

This patch apply to the current mmc-next branch

 drivers/mmc/host/mxcmmc.c |   20 ++++++++++++--------
 1 files changed, 12 insertions(+), 8 deletions(-)
drivers/mmc/host/mxcmmc.c +12 -8
index 1a7f48c..2b9f7c8 100644
@@ -150,7 +150,6 @@ static void mxcmci_set_clk_rate(struct mxcmci_host *host, unsigned int clk_ios);
 
 static inline void mxcmci_init_ocr(struct mxcmci_host *host)
 {
-#ifdef CONFIG_REGULATOR
 	host->vcc = regulator_get(mmc_dev(host->mmc), "vmmc");
 
 	if (IS_ERR(host->vcc)) {
@@ -161,7 +160,7 @@ static inline void mxcmci_init_ocr(struct mxcmci_host *host)
 			dev_warn(mmc_dev(host->mmc),
 				"pdata->ocr_avail will not be used\n");
 	}
-#endif
+
 	if (host->vcc == NULL) {
 		/* fall-back to platform data */
 		if (host->pdata && host->pdata->ocr_avail)
@@ -171,12 +170,17 @@ static inline void mxcmci_init_ocr(struct mxcmci_host *host)
 	}
 }
 
-static inline void mxcmci_set_power(struct mxcmci_host *host, unsigned int vdd)
+static inline void mxcmci_set_power(struct mxcmci_host *host,
+				    unsigned char power_mode,
+				    unsigned int vdd)
 {
-#ifdef CONFIG_REGULATOR
-	if (host->vcc)
-		mmc_regulator_set_ocr(host->vcc, vdd);
-#endif
+	if (host->vcc) {
+		if (power_mode == MMC_POWER_UP)
+			mmc_regulator_set_ocr(host->mmc, host->vcc, vdd);
+		else if (power_mode == MMC_POWER_OFF)
+			mmc_regulator_set_ocr(host->mmc, host->vcc, 0);
+	}
+
 	if (host->pdata && host->pdata->setpower)
 		host->pdata->setpower(mmc_dev(host->mmc), vdd);
 }
@@ -716,7 +720,7 @@ static void mxcmci_set_ios(struct mmc_host *mmc, struct mmc_ios *ios)
 		host->cmdat &= ~CMD_DAT_CONT_BUS_WIDTH_4;
 
 	if (host->power_mode != ios->power_mode) {
-		mxcmci_set_power(host, ios->vdd);
+		mxcmci_set_power(host, ios->power_mode, ios->vdd);
 		host->power_mode = ios->power_mode;
 
 		if (ios->power_mode == MMC_POWER_ON)
Signature · 1 line
1.6.3.3
#12 lore raw
In reply to Alberto Panizzo

2010/11/2 Alberto Panizzo <[email protected]>:

Quoted 4 lines
drivers/mmc/host/mxcmmc.c +4 -0
+static inline void mxcmci_init_ocr(struct mxcmci_host *host)
+{
+#ifdef CONFIG_REGULATOR
+       host->vcc = regulator_get(mmc_dev(host->mmc), "vmmc");

drivers/mmc/host/mxcmmc.c struct mxcmci_host { · line 164

Quoted 10 lines
drivers/mmc/host/mxcmmc.c +10 -0
+
+       if (IS_ERR(host->vcc)) {
+               host->vcc = NULL;
+       } else {
+               host->mmc->ocr_avail = mmc_regulator_get_ocrmask(host->vcc);
+               if (host->pdata && host->pdata->ocr_avail)
+                       dev_warn(mmc_dev(host->mmc),
+                               "pdata->ocr_avail will not be used\n");
+       }
+#endif

You don't need these #ifdef CONFIG_REGULATOR guardposts anymore. I implemented stub functions for the ocrmask functions for 2.6.37.

drivers/mmc/host/mxcmmc.c struct mxcmci_host { · line 179

Quoted 6 lines
drivers/mmc/host/mxcmmc.c +6 -0
+static inline void mxcmci_set_power(struct mxcmci_host *host, unsigned int vdd)
+{
+#ifdef CONFIG_REGULATOR
+       if (host->vcc)
+               mmc_regulator_set_ocr(host->vcc, vdd);
+#endif

Neither here.

But for both cases: no big deal. Take it the day it disturbs you :-)

Yours,
Linus Walleij

#13 lore raw
Quoted 12 lines · Linus Walleij

2010/11/2 Alberto Panizzo <[email protected]>:

Quoted 10 lines
drivers/mmc/host/mxcmmc.c +10 -0
+static inline void mxcmci_init_ocr(struct mxcmci_host *host)
+{
+#ifdef CONFIG_REGULATOR
+       host->vcc = regulator_get(mmc_dev(host->mmc), "vmmc");
+
+       if (IS_ERR(host->vcc)) {
+               host->vcc = NULL;
+       } else {
+               host->mmc->ocr_avail = mmc_regulator_get_ocrmask(host->vcc);
+               if (host->pdata && host->pdata->ocr_avail)
Quoted 8 lines

drivers/mmc/host/mxcmmc.c struct mxcmci_host { · line 164

Quoted 4 lines
drivers/mmc/host/mxcmmc.c +4 -0
+                       dev_warn(mmc_dev(host->mmc),
+                               "pdata->ocr_avail will not be used\n");
+       }
+#endif

You don't need these #ifdef CONFIG_REGULATOR guardposts anymore. I implemented stub functions for the ocrmask functions for 2.6.37.

Ehm.. thank you really for pointing me this, because I've also used the old API breaking the build in the -next branch..

A Fix will be posted as soon as possible!

Thanks Linus!
Best regards,

Signature · 4 lines
Alberto!

        Be Persistent!
                - Greg Kroah-Hartman (FOSDEM 2010)