Re: [PATCH V2 00/11] mmc: sdhci-esdhci-imx: fix cd/wp regression

2015-07-22 Thread Shawn Guo
On Wed, Jul 22, 2015 at 08:52:59PM +0800, Dong Aisheng wrote:
> Dong Aisheng (11):
>   dts: imx51: fix sd card gpio polarity specified in device tree
>   dts: imx53: fix sd card gpio polarity specified in device tree
>   dts: imx6: fix sd card gpio polarity specified in device tree
>   dts: imx25: fix sd card gpio polarity specified in device tree
>   dts: imx7: fix sd card gpio polarity specified in device tree

Acked-by: Shawn Guo 
--
To unsubscribe from this list: send the line "unsubscribe linux-mmc" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] mmc: sdhci-pxav3: fix platform_data is not initialized

2015-07-22 Thread Jingju Hou
From: Jingju Hou

pdev->dev.platform_data is not initialized if match is true in function
sdhci_pxav3_probe. Just local variable pdata is assigned the return value
from function pxav3_get_mmc_pdata().

static int sdhci_pxav3_probe(struct platform_device *pdev) {

struct sdhci_pxa_platdata *pdata = pdev->dev.platform_data;
...
if (match) {
ret = mmc_of_parse(host->mmc);
if (ret)
goto err_of_parse;
sdhci_get_of_property(pdev);
pdata = pxav3_get_mmc_pdata(dev);
 }
 ...
}

Signed-off-by: Jingju Hou
---
 drivers/mmc/host/sdhci-pxav3.c |1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/mmc/host/sdhci-pxav3.c b/drivers/mmc/host/sdhci-pxav3.c
index 9cd5fc6..946d37f 100644
--- a/drivers/mmc/host/sdhci-pxav3.c
+++ b/drivers/mmc/host/sdhci-pxav3.c
@@ -411,6 +411,7 @@ static int sdhci_pxav3_probe(struct platform_device *pdev)
goto err_of_parse;
sdhci_get_of_property(pdev);
pdata = pxav3_get_mmc_pdata(dev);
+   pdev->dev.platform_data = pdata;
} else if (pdata) {
/* on-chip device */
if (pdata->flags & PXA_FLAG_CARD_PERMANENT)
-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-mmc" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] mmc: sdhci-pxav3: fix platform_data is not initialized

2015-07-22 Thread houjingj
pdev->dev.platform_data is not initialized if match is true in function
sdhci_pxav3_probe. Just local variable pdata is assigned the return value
from function pxav3_get_mmc_pdata().

static int sdhci_pxav3_probe(struct platform_device *pdev) {

struct sdhci_pxa_platdata *pdata = pdev->dev.platform_data;
...
if (match) {
ret = mmc_of_parse(host->mmc);
if (ret)
goto err_of_parse;
sdhci_get_of_property(pdev);
pdata = pxav3_get_mmc_pdata(dev);
 }
 ...
}

Signed-off-by: houjingj 
---
 drivers/mmc/host/sdhci-pxav3.c |1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/mmc/host/sdhci-pxav3.c b/drivers/mmc/host/sdhci-pxav3.c
index 9cd5fc6..946d37f 100644
--- a/drivers/mmc/host/sdhci-pxav3.c
+++ b/drivers/mmc/host/sdhci-pxav3.c
@@ -411,6 +411,7 @@ static int sdhci_pxav3_probe(struct platform_device *pdev)
goto err_of_parse;
sdhci_get_of_property(pdev);
pdata = pxav3_get_mmc_pdata(dev);
+   pdev->dev.platform_data = pdata;
} else if (pdata) {
/* on-chip device */
if (pdata->flags & PXA_FLAG_CARD_PERMANENT)
-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-mmc" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCHv2 ] sdhci-esdhc: Make 8BIT bus work.

2015-07-22 Thread Ulf Hansson
On 22 July 2015 at 16:44, Joakim Tjernlund
 wrote:
> Support for 8BIT bus with was added some time ago to sdhci-esdhc but
> then missed to remove the 8BIT from the reserved bit mask which made
> 8BIT non functional.
>
> Signed-off-by: Joakim Tjernlund 
> Fixes: 66b50a00992d ("mmc: esdhc: Add support for 8-bit bus width and 
> non-removable card")

Thanks, applied for fixes!

Kind regards
Uffe

> ---
>
>  - v2: Added Fixes: tag
>
>  drivers/mmc/host/sdhci-esdhc.h | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/mmc/host/sdhci-esdhc.h b/drivers/mmc/host/sdhci-esdhc.h
> index 3497cfa..a870c42 100644
> --- a/drivers/mmc/host/sdhci-esdhc.h
> +++ b/drivers/mmc/host/sdhci-esdhc.h
> @@ -45,6 +45,6 @@
>  #define ESDHC_DMA_SYSCTL   0x40c
>  #define ESDHC_DMA_SNOOP0x0040
>
> -#define ESDHC_HOST_CONTROL_RES 0x05
> +#define ESDHC_HOST_CONTROL_RES 0x01
>
>  #endif /* _DRIVERS_MMC_SDHCI_ESDHC_H */
> --
> 2.3.6
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-mmc" in
> the body of a message to majord...@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
--
To unsubscribe from this list: send the line "unsubscribe linux-mmc" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCHv2 ] sdhci-esdhc: Make 8BIT bus work.

2015-07-22 Thread Joakim Tjernlund
Support for 8BIT bus with was added some time ago to sdhci-esdhc but
then missed to remove the 8BIT from the reserved bit mask which made
8BIT non functional.

Signed-off-by: Joakim Tjernlund 
Fixes: 66b50a00992d ("mmc: esdhc: Add support for 8-bit bus width and 
non-removable card")
---

 - v2: Added Fixes: tag
 
 drivers/mmc/host/sdhci-esdhc.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/mmc/host/sdhci-esdhc.h b/drivers/mmc/host/sdhci-esdhc.h
index 3497cfa..a870c42 100644
--- a/drivers/mmc/host/sdhci-esdhc.h
+++ b/drivers/mmc/host/sdhci-esdhc.h
@@ -45,6 +45,6 @@
 #define ESDHC_DMA_SYSCTL   0x40c
 #define ESDHC_DMA_SNOOP0x0040
 
-#define ESDHC_HOST_CONTROL_RES 0x05
+#define ESDHC_HOST_CONTROL_RES 0x01
 
 #endif /* _DRIVERS_MMC_SDHCI_ESDHC_H */
-- 
2.3.6

--
To unsubscribe from this list: send the line "unsubscribe linux-mmc" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [RFC PATCH v3] mmc: sleep notification

2015-07-22 Thread Ulf Hansson
On 18 June 2015 at 16:57, Alex Lemberg  wrote:
> Hi Ulf,
>
>> -Original Message-
>> From: Ulf Hansson [mailto:ulf.hans...@linaro.org]
>> Sent: Monday, June 15, 2015 11:24 AM
>> To: Alex Lemberg
>> Cc: Avi Shchislowski; linux-mmc
>> Subject: Re: [RFC PATCH v3] mmc: sleep notification
>>
>> On 8 June 2015 at 15:17, Alex Lemberg 
>> wrote:
>> > Hi Ulf,
>> >
>> > [...]
>> >
>> >>
>> >> One of my comments for v2, was that I think you should remove all
>> >> code which was related to HPI to interrupt sleep notification from
>> >> the runtime PM resume path. Instead I wanted you to add that
>> >> functionality as separate patch based on top of this patch.
>> >>
>> >> You haven't done that in v3, why?
>> >
>> > The sleep_notify call was moved to suspend() per your recommendation.
>> > As far as I understand, no new requests should be sent during
>> > mmc_suspend() process, thus HPI support is not needed anymore.
>> > Is this the correct assumption?
>>
>> Yes.
>>
>> I don't think you need mmc_card_set_sleep_notify() and the corresponding
>> new MMC_STATE_SLEEP_NOTIFY , mmc_device_prg_state(), etc.
>
> mmc_card_set_sleep_notify(), MMC_STATE_SLEEP_NOTIFY and the corresponding - 
> We are removing it from the current patch. Probably will add them as a 
> separate patch in future.

Great!

> mmc_device_prg_state() - is required for waiting for Sleep_Notification 
> completion/timeout, although we would like to leave this function.

Doesn't __mmc_switch() already deal with this? No, I don't think it's needed.

>
>>
>> Overall, I think this patch could be simplified yet another step.
>>
>> > The only case where HPI is used in this patch - is during sleep_notify
>> timeout error.
>>
>> Why?
>
> In case of timeout error, we would like to handle it by sending HPI - to let 
> device interrupt/stop the prg state.

Is that according to the spec? I think it would be better to try a
reset sequence to recover, by using CMD0 and so forth, what do you
think?

>
>>
>> One final question, I noticed that you have removed the check for
>> MMC_CAP2_FULL_PWR_CYCLE in the _mmc_suspend() function, why?
>
> As far as we understand, this MMC_CAP2_FULL_PWR_CYCLE was used to distinguish 
> between PON (when the power can be cut)
> and Sleep (when the power have to stay ON).
> Now we have Sleep_Notification PON, which allows to cut the power also in 
> case of Sleep.
> Hope the interpretation above is correct.

Unfortunate your interpretation is wrong.

MMC_CAP2_FULL_PWR_CYCLE, indicates whether the mmc host can cut *both*
VCC and VCCQ.

For the suspend case, the default behaviour is to send CMD5 (sleep),
as we don't trust hosts to set MMC_CAP2_FULL_PWR_CYCLE even if it
potentially could.
Keeping this policy is important, as we don't want to issue PON unless
we know that we will be cutting both VCC and VCCQ.

Kind regards
Uffe
--
To unsubscribe from this list: send the line "unsubscribe linux-mmc" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH V2 02/11] dts: imx53: fix sd card gpio polarity specified in device tree

2015-07-22 Thread Dong Aisheng
cd-gpios polarity should be changed to GPIO_ACTIVE_LOW and wp-gpios
should be changed to GPIO_ACTIVE_HIGH.
Otherwise, the SD may not work properly due to wrong polarity inversion
specified in DT after switch to common parsing function mmc_of_parse().

Signed-off-by: Dong Aisheng 
---
 arch/arm/boot/dts/imx53-ard.dts | 4 ++--
 arch/arm/boot/dts/imx53-m53evk.dts  | 4 ++--
 arch/arm/boot/dts/imx53-qsb-common.dtsi | 4 ++--
 arch/arm/boot/dts/imx53-smd.dts | 4 ++--
 arch/arm/boot/dts/imx53-tqma53.dtsi | 4 ++--
 arch/arm/boot/dts/imx53-tx53.dtsi   | 4 ++--
 arch/arm/boot/dts/imx53-voipac-bsb.dts  | 4 ++--
 7 files changed, 14 insertions(+), 14 deletions(-)

diff --git a/arch/arm/boot/dts/imx53-ard.dts b/arch/arm/boot/dts/imx53-ard.dts
index e9337ad..3bc1883 100644
--- a/arch/arm/boot/dts/imx53-ard.dts
+++ b/arch/arm/boot/dts/imx53-ard.dts
@@ -103,8 +103,8 @@
 &esdhc1 {
pinctrl-names = "default";
pinctrl-0 = <&pinctrl_esdhc1>;
-   cd-gpios = <&gpio1 1 0>;
-   wp-gpios = <&gpio1 9 0>;
+   cd-gpios = <&gpio1 1 GPIO_ACTIVE_LOW>;
+   wp-gpios = <&gpio1 9 GPIO_ACTIVE_HIGH>;
status = "okay";
 };
 
diff --git a/arch/arm/boot/dts/imx53-m53evk.dts 
b/arch/arm/boot/dts/imx53-m53evk.dts
index d0e0f57..53f4088 100644
--- a/arch/arm/boot/dts/imx53-m53evk.dts
+++ b/arch/arm/boot/dts/imx53-m53evk.dts
@@ -124,8 +124,8 @@
 &esdhc1 {
pinctrl-names = "default";
pinctrl-0 = <&pinctrl_esdhc1>;
-   cd-gpios = <&gpio1 1 0>;
-   wp-gpios = <&gpio1 9 0>;
+   cd-gpios = <&gpio1 1 GPIO_ACTIVE_LOW>;
+   wp-gpios = <&gpio1 9 GPIO_ACTIVE_HIGH>;
status = "okay";
 };
 
diff --git a/arch/arm/boot/dts/imx53-qsb-common.dtsi 
b/arch/arm/boot/dts/imx53-qsb-common.dtsi
index ab4ba39..b0d5542 100644
--- a/arch/arm/boot/dts/imx53-qsb-common.dtsi
+++ b/arch/arm/boot/dts/imx53-qsb-common.dtsi
@@ -147,8 +147,8 @@
 &esdhc3 {
pinctrl-names = "default";
pinctrl-0 = <&pinctrl_esdhc3>;
-   cd-gpios = <&gpio3 11 0>;
-   wp-gpios = <&gpio3 12 0>;
+   cd-gpios = <&gpio3 11 GPIO_ACTIVE_LOW>;
+   wp-gpios = <&gpio3 12 GPIO_ACTIVE_HIGH>;
bus-width = <8>;
status = "okay";
 };
diff --git a/arch/arm/boot/dts/imx53-smd.dts b/arch/arm/boot/dts/imx53-smd.dts
index 1d32557..fc89ce1 100644
--- a/arch/arm/boot/dts/imx53-smd.dts
+++ b/arch/arm/boot/dts/imx53-smd.dts
@@ -41,8 +41,8 @@
 &esdhc1 {
pinctrl-names = "default";
pinctrl-0 = <&pinctrl_esdhc1>;
-   cd-gpios = <&gpio3 13 0>;
-   wp-gpios = <&gpio4 11 0>;
+   cd-gpios = <&gpio3 13 GPIO_ACTIVE_LOW>;
+   wp-gpios = <&gpio4 11 GPIO_ACTIVE_HIGH>;
status = "okay";
 };
 
diff --git a/arch/arm/boot/dts/imx53-tqma53.dtsi 
b/arch/arm/boot/dts/imx53-tqma53.dtsi
index 4f1f0e2..e03373a 100644
--- a/arch/arm/boot/dts/imx53-tqma53.dtsi
+++ b/arch/arm/boot/dts/imx53-tqma53.dtsi
@@ -41,8 +41,8 @@
pinctrl-0 = <&pinctrl_esdhc2>,
<&pinctrl_esdhc2_cdwp>;
vmmc-supply = <®_3p3v>;
-   wp-gpios = <&gpio1 2 0>;
-   cd-gpios = <&gpio1 4 0>;
+   wp-gpios = <&gpio1 2 GPIO_ACTIVE_HIGH>;
+   cd-gpios = <&gpio1 4 GPIO_ACTIVE_LOW>;
status = "disabled";
 };
 
diff --git a/arch/arm/boot/dts/imx53-tx53.dtsi 
b/arch/arm/boot/dts/imx53-tx53.dtsi
index 704bd72..d3e50b2 100644
--- a/arch/arm/boot/dts/imx53-tx53.dtsi
+++ b/arch/arm/boot/dts/imx53-tx53.dtsi
@@ -183,7 +183,7 @@
 };
 
 &esdhc1 {
-   cd-gpios = <&gpio3 24 GPIO_ACTIVE_HIGH>;
+   cd-gpios = <&gpio3 24 GPIO_ACTIVE_LOW>;
fsl,wp-controller;
pinctrl-names = "default";
pinctrl-0 = <&pinctrl_esdhc1>;
@@ -191,7 +191,7 @@
 };
 
 &esdhc2 {
-   cd-gpios = <&gpio3 25 GPIO_ACTIVE_HIGH>;
+   cd-gpios = <&gpio3 25 GPIO_ACTIVE_LOW>;
fsl,wp-controller;
pinctrl-names = "default";
pinctrl-0 = <&pinctrl_esdhc2>;
diff --git a/arch/arm/boot/dts/imx53-voipac-bsb.dts 
b/arch/arm/boot/dts/imx53-voipac-bsb.dts
index c17d3ad..fc51b87 100644
--- a/arch/arm/boot/dts/imx53-voipac-bsb.dts
+++ b/arch/arm/boot/dts/imx53-voipac-bsb.dts
@@ -119,8 +119,8 @@
 &esdhc2 {
pinctrl-names = "default";
pinctrl-0 = <&pinctrl_esdhc2>;
-   cd-gpios = <&gpio3 25 0>;
-   wp-gpios = <&gpio2 19 0>;
+   cd-gpios = <&gpio3 25 GPIO_ACTIVE_LOW>;
+   wp-gpios = <&gpio2 19 GPIO_ACTIVE_HIGH>;
vmmc-supply = <®_3p3v>;
status = "okay";
 };
-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe linux-mmc" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 0/6] mmc: sdhci-esdhci-imx: fix cd/wp regression

2015-07-22 Thread Dong Aisheng
On Mon, Jul 20, 2015 at 02:44:07PM +0200, Ulf Hansson wrote:
> On 13 July 2015 at 13:43, Dong Aisheng  wrote:
> > On Thu, Jul 09, 2015 at 09:27:36PM +0800, Shawn Guo wrote:
> >> On Thu, Jul 09, 2015 at 05:29:50PM +0800, Dong Aisheng wrote:
> >> > I agree with you.
> >> > One difference is that i'd like to fix it ASAP without reverting 8d86e4f
> >> > due to more patches depends on it is already there as i mentioned above..
> >> > Revert it may need to revert a lot others.
> >> >
> >> > The pain is that v4.1 is left broken.
> >>
> >> Oh, crap!  I thought it's been there with only v4.2-rc1, and did not
> >> know v4.1 is already broken.  In that case, reverting 8d86e4f isn't
> >> the best option.  I suggest you rebase the dts series on top of
> >> v4.2-rc1, and send it via mmc tree.
> >>
> >
> > Yes, will go that way.
> >
> > Then you may need help take care of new dts going through your tree
> > to make sure no broken code in again.
> 
> Dong, Shawn,
> 
> I am happy to help out, I assume you want this to go as fixes for 4.2rc[n].
> 
> Correct me if I am wrong, you want me to apply the DTS patches prior
> the MMC patches. I tried applying the DTS patches on 4.2rc3 - it still
> works nicely so no re-base is needed.
> 
> 
> So, then I need an ack from Shawn for the DTS series...
> 

Hi Ulf,

I have merged the two seris into one (dts changes is before controller changes)
and rebase based on your ulf/next branch.
The updated patch series is just sent out for review.

Shawn,
Please help review and ACK for Ulf to apply.

Regards
Dong Aisheng

> Kind regards
> Uffe
--
To unsubscribe from this list: send the line "unsubscribe linux-mmc" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH V2 05/11] dts: imx7: fix sd card gpio polarity specified in device tree

2015-07-22 Thread Dong Aisheng
cd-gpios polarity should be changed to GPIO_ACTIVE_LOW and wp-gpios
should be changed to GPIO_ACTIVE_HIGH.
Otherwise, the SD may not work properly due to wrong polarity inversion
specified in DT after switch to common parsing function mmc_of_parse().

Signed-off-by: Dong Aisheng 
---
 arch/arm/boot/dts/imx7d-sdb.dts | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/arm/boot/dts/imx7d-sdb.dts b/arch/arm/boot/dts/imx7d-sdb.dts
index 4d1a4b9..fdd1d7c 100644
--- a/arch/arm/boot/dts/imx7d-sdb.dts
+++ b/arch/arm/boot/dts/imx7d-sdb.dts
@@ -234,8 +234,8 @@
 &usdhc1 {
pinctrl-names = "default";
pinctrl-0 = <&pinctrl_usdhc1>;
-   cd-gpios = <&gpio5 0 0>;
-   wp-gpios = <&gpio5 1 0>;
+   cd-gpios = <&gpio5 0 GPIO_ACTIVE_LOW>;
+   wp-gpios = <&gpio5 1 GPIO_ACTIVE_HIGH>;
enable-sdio-wakeup;
keep-power-in-suspend;
status = "okay";
-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe linux-mmc" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH V2 07/11] mmc: sdhci-esdhc-imx: move all non dt probe code into one function

2015-07-22 Thread Dong Aisheng
This is an incremental fix of commit
e62bd351b("mmc: sdhci-esdhc-imx: Do not break platform data boards").

After commit 8d86e4fcccf6 ("mmc: sdhci-esdhc-imx: Call mmc_of_parse()"),
we do not need to run the check of boarddata->wp_type/cd_type/max_bus_width
again for dt platform since those are already handled by mmc_of_parse().

Current code only exclude the checking of wp_type for dt platform which
does not make sense.

This patch moves all non dt probe code into one function.
Besides, since we only support SD3.0/eMMC HS200 for dt platform, the
support_vsel checking and ultra high speed pinctrl state are also merged
into sdhci_esdhc_imx_probe_dt.

Then we have two separately probe function for dt and non dt type.
This can make the driver probe more clearly.

Signed-off-by: Dong Aisheng 
---
 drivers/mmc/host/sdhci-esdhc-imx.c | 179 +++--
 1 file changed, 94 insertions(+), 85 deletions(-)

diff --git a/drivers/mmc/host/sdhci-esdhc-imx.c 
b/drivers/mmc/host/sdhci-esdhc-imx.c
index 4815391..10f03ee 100644
--- a/drivers/mmc/host/sdhci-esdhc-imx.c
+++ b/drivers/mmc/host/sdhci-esdhc-imx.c
@@ -878,14 +878,12 @@ static const struct sdhci_pltfm_data 
sdhci_esdhc_imx_pdata = {
 static int
 sdhci_esdhc_imx_probe_dt(struct platform_device *pdev,
 struct sdhci_host *host,
-struct esdhc_platform_data *boarddata)
+struct pltfm_imx_data *imx_data)
 {
struct device_node *np = pdev->dev.of_node;
+   struct esdhc_platform_data *boarddata = &imx_data->boarddata;
int ret;
 
-   if (!np)
-   return -ENODEV;
-
if (of_get_property(np, "non-removable", NULL))
boarddata->cd_type = ESDHC_CD_PERMANENT;
 
@@ -917,6 +915,26 @@ sdhci_esdhc_imx_probe_dt(struct platform_device *pdev,
 
mmc_of_parse_voltage(np, &host->ocr_mask);
 
+   /* sdr50 and sdr104 needs work on 1.8v signal voltage */
+   if ((boarddata->support_vsel) && esdhc_is_usdhc(imx_data) &&
+   !IS_ERR(imx_data->pins_default)) {
+   imx_data->pins_100mhz = pinctrl_lookup_state(imx_data->pinctrl,
+   ESDHC_PINCTRL_STATE_100MHZ);
+   imx_data->pins_200mhz = pinctrl_lookup_state(imx_data->pinctrl,
+   ESDHC_PINCTRL_STATE_200MHZ);
+   if (IS_ERR(imx_data->pins_100mhz) ||
+   IS_ERR(imx_data->pins_200mhz)) {
+   dev_warn(mmc_dev(host->mmc),
+   "could not get ultra high speed state, work on 
normal mode\n");
+   /*
+* fall back to not support uhs by specify no 1.8v quirk
+*/
+   host->quirks2 |= SDHCI_QUIRK2_NO_1_8_V;
+   }
+   } else {
+   host->quirks2 |= SDHCI_QUIRK2_NO_1_8_V;
+   }
+
/* call to generic mmc_of_parse to support additional capabilities */
ret = mmc_of_parse(host->mmc);
if (ret)
@@ -931,22 +949,85 @@ sdhci_esdhc_imx_probe_dt(struct platform_device *pdev,
 static inline int
 sdhci_esdhc_imx_probe_dt(struct platform_device *pdev,
 struct sdhci_host *host,
-struct esdhc_platform_data *boarddata)
+struct pltfm_imx_data *imx_data)
 {
return -ENODEV;
 }
 #endif
 
+static int sdhci_esdhc_imx_probe_nondt(struct platform_device *pdev,
+struct sdhci_host *host,
+struct pltfm_imx_data *imx_data)
+{
+   struct esdhc_platform_data *boarddata = &imx_data->boarddata;
+   int err;
+
+   if (!host->mmc->parent->platform_data) {
+   dev_err(mmc_dev(host->mmc), "no board data!\n");
+   return -EINVAL;
+   }
+
+   imx_data->boarddata = *((struct esdhc_platform_data *)
+   host->mmc->parent->platform_data);
+   /* write_protect */
+   if (boarddata->wp_type == ESDHC_WP_GPIO) {
+   err = mmc_gpio_request_ro(host->mmc, boarddata->wp_gpio);
+   if (err) {
+   dev_err(mmc_dev(host->mmc),
+   "failed to request write-protect gpio!\n");
+   return err;
+   }
+   host->mmc->caps2 |= MMC_CAP2_RO_ACTIVE_HIGH;
+   }
+
+   /* card_detect */
+   switch (boarddata->cd_type) {
+   case ESDHC_CD_GPIO:
+   err = mmc_gpio_request_cd(host->mmc, boarddata->cd_gpio, 0);
+   if (err) {
+   dev_err(mmc_dev(host->mmc),
+   "failed to request card-detect gpio!\n");
+   return err;
+   }
+   /* fall through */
+
+   case ESDHC_CD_CONTROLLER:
+   /* we have a working card_detect back */
+   host->quirks &= ~SDHCI

[PATCH V2 08/11] mmc: sdhci: make max-frequency property in device tree work

2015-07-22 Thread Dong Aisheng
Device tree provides option to specify the max freqency with property
"max-frequency" in dts and common parse function mmc_of_parse() will
parse it and use this value to set host->f_max to tell the MMC core
the maxinum frequency the host works.

However, current sdhci driver will finally overwrite this value with
host->max_clk regardless of the max-frequency property.

This patch makes sure not overwrite the max-frequency set from device
tree and do basic sanity check.

Signed-off-by: Dong Aisheng 
---
 drivers/mmc/host/sdhci.c | 9 +++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c
index 947033d..c83d110 100644
--- a/drivers/mmc/host/sdhci.c
+++ b/drivers/mmc/host/sdhci.c
@@ -2874,6 +2874,7 @@ int sdhci_add_host(struct sdhci_host *host)
u32 max_current_caps;
unsigned int ocr_avail;
unsigned int override_timeout_clk;
+   u32 max_clk;
int ret;
 
WARN_ON(host == NULL);
@@ -3058,18 +3059,22 @@ int sdhci_add_host(struct sdhci_host *host)
 * Set host parameters.
 */
mmc->ops = &sdhci_ops;
-   mmc->f_max = host->max_clk;
+   max_clk = host->max_clk;
+
if (host->ops->get_min_clock)
mmc->f_min = host->ops->get_min_clock(host);
else if (host->version >= SDHCI_SPEC_300) {
if (host->clk_mul) {
mmc->f_min = (host->max_clk * host->clk_mul) / 1024;
-   mmc->f_max = host->max_clk * host->clk_mul;
+   max_clk = host->max_clk * host->clk_mul;
} else
mmc->f_min = host->max_clk / SDHCI_MAX_DIV_SPEC_300;
} else
mmc->f_min = host->max_clk / SDHCI_MAX_DIV_SPEC_200;
 
+   if (!mmc->f_max || (mmc->f_max && (mmc->f_max > max_clk)))
+   mmc->f_max = max_clk;
+
if (!(host->quirks & SDHCI_QUIRK_DATA_TIMEOUT_USES_SDCLK)) {
host->timeout_clk = (caps[0] & SDHCI_TIMEOUT_CLK_MASK) >>
SDHCI_TIMEOUT_CLK_SHIFT;
-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe linux-mmc" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 0/6] mmc: sdhci-esdhci-imx: fix cd/wp regression

2015-07-22 Thread Dong Aisheng
On Tue, Jul 14, 2015 at 07:25:09AM +0200, Soeren Moch wrote:
> 
> 
> On 13.07.2015 13:43, Dong Aisheng wrote:
> > On Thu, Jul 09, 2015 at 09:27:36PM +0800, Shawn Guo wrote:
> >> On Thu, Jul 09, 2015 at 05:29:50PM +0800, Dong Aisheng wrote:
> >>> I agree with you.
> >>> One difference is that i'd like to fix it ASAP without reverting 8d86e4f
> >>> due to more patches depends on it is already there as i mentioned above..
> >>> Revert it may need to revert a lot others.
> >>>
> >>> The pain is that v4.1 is left broken.
> >>
> >> Oh, crap!  I thought it's been there with only v4.2-rc1, and did not
> >> know v4.1 is already broken.  In that case, reverting 8d86e4f isn't
> >> the best option.  I suggest you rebase the dts series on top of
> >> v4.2-rc1, and send it via mmc tree.
> >>
> > 
> > Yes, will go that way.
> > 
> > Then you may need help take care of new dts going through your tree
> > to make sure no broken code in again.
> 
> Dong,
> 
> I use a microSD card (mmc0) with the root filesystem on a tbs2910 board.
> I cannot see any difference between linux-4.0 and linux-4.1 (vanilla
> kernel with corresponding dtb), there is absolutely no problem with card
> detect.
> 
> Can you please explain what exactly is broken in linux-4.1?
> 

The CD function is broken.
If you enable CONFIG_MMC_DEBUG, you will see the MMC core keep polling the
card because MMC_CAP_NEEDS_POLL is wrongly set.
You can refer to cover-letter for more detailed explaination.

If you're using a non-removable card(having non-removable property in dts),
you may not have this issue.

Regards
Dong Aisheng

> Thanks,
> Soeren
> 
> > Thanks
> > 
> > Regards
> > Dong Aisheng
> > 
> >> Shawn
--
To unsubscribe from this list: send the line "unsubscribe linux-mmc" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH V2 09/11] mmc: sdhci-esdhc-imx: remove duplicated dts parsing

2015-07-22 Thread Dong Aisheng
After commit 8d86e4fcccf6 ("mmc: sdhci-esdhc-imx: Call mmc_of_parse()"),
we do not need those duplicated parsing anymore.

Note: fsl,cd-controller is also deleted due to the driver does
not support controller card detection anymore after switch to runtime pm.
And there's no user of it right now in device tree.

wp-gpios is kept because we're still support fsl,wp-controller,
so we need a way to check if it's gpio wp or controller wp.

Signed-off-by: Dong Aisheng 
---
 drivers/mmc/host/sdhci-esdhc-imx.c | 14 --
 1 file changed, 14 deletions(-)

diff --git a/drivers/mmc/host/sdhci-esdhc-imx.c 
b/drivers/mmc/host/sdhci-esdhc-imx.c
index 10f03ee..1b0e618 100644
--- a/drivers/mmc/host/sdhci-esdhc-imx.c
+++ b/drivers/mmc/host/sdhci-esdhc-imx.c
@@ -884,27 +884,13 @@ sdhci_esdhc_imx_probe_dt(struct platform_device *pdev,
struct esdhc_platform_data *boarddata = &imx_data->boarddata;
int ret;
 
-   if (of_get_property(np, "non-removable", NULL))
-   boarddata->cd_type = ESDHC_CD_PERMANENT;
-
-   if (of_get_property(np, "fsl,cd-controller", NULL))
-   boarddata->cd_type = ESDHC_CD_CONTROLLER;
-
if (of_get_property(np, "fsl,wp-controller", NULL))
boarddata->wp_type = ESDHC_WP_CONTROLLER;
 
-   boarddata->cd_gpio = of_get_named_gpio(np, "cd-gpios", 0);
-   if (gpio_is_valid(boarddata->cd_gpio))
-   boarddata->cd_type = ESDHC_CD_GPIO;
-
boarddata->wp_gpio = of_get_named_gpio(np, "wp-gpios", 0);
if (gpio_is_valid(boarddata->wp_gpio))
boarddata->wp_type = ESDHC_WP_GPIO;
 
-   of_property_read_u32(np, "bus-width", &boarddata->max_bus_width);
-
-   of_property_read_u32(np, "max-frequency", &boarddata->f_max);
-
if (of_find_property(np, "no-1-8-v", NULL))
boarddata->support_vsel = false;
else
-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe linux-mmc" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH V2 10/11] mmc: sdhci-esdhc-imx: clear f_max in boarddata

2015-07-22 Thread Dong Aisheng
After commit 8d86e4fcccf6 ("mmc: sdhci-esdhc-imx: Call mmc_of_parse()"),
it's not used anymore.

Signed-off-by: Dong Aisheng 
---
 drivers/mmc/host/sdhci-esdhc-imx.c  | 7 +--
 include/linux/platform_data/mmc-esdhc-imx.h | 1 -
 2 files changed, 1 insertion(+), 7 deletions(-)

diff --git a/drivers/mmc/host/sdhci-esdhc-imx.c 
b/drivers/mmc/host/sdhci-esdhc-imx.c
index 1b0e618..c6b9f64 100644
--- a/drivers/mmc/host/sdhci-esdhc-imx.c
+++ b/drivers/mmc/host/sdhci-esdhc-imx.c
@@ -581,13 +581,8 @@ static void esdhc_writeb_le(struct sdhci_host *host, u8 
val, int reg)
 static unsigned int esdhc_pltfm_get_max_clock(struct sdhci_host *host)
 {
struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host);
-   struct pltfm_imx_data *imx_data = pltfm_host->priv;
-   struct esdhc_platform_data *boarddata = &imx_data->boarddata;
 
-   if (boarddata->f_max && (boarddata->f_max < pltfm_host->clock))
-   return boarddata->f_max;
-   else
-   return pltfm_host->clock;
+   return pltfm_host->clock;
 }
 
 static unsigned int esdhc_pltfm_get_min_clock(struct sdhci_host *host)
diff --git a/include/linux/platform_data/mmc-esdhc-imx.h 
b/include/linux/platform_data/mmc-esdhc-imx.h
index 75f70f6..e1571ef 100644
--- a/include/linux/platform_data/mmc-esdhc-imx.h
+++ b/include/linux/platform_data/mmc-esdhc-imx.h
@@ -43,7 +43,6 @@ struct esdhc_platform_data {
enum wp_types wp_type;
enum cd_types cd_type;
int max_bus_width;
-   unsigned int f_max;
bool support_vsel;
unsigned int delay_line;
 };
-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe linux-mmc" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH V2 04/11] dts: imx25: fix sd card gpio polarity specified in device tree

2015-07-22 Thread Dong Aisheng
cd-gpios polarity should be changed to GPIO_ACTIVE_LOW and wp-gpios
should be changed to GPIO_ACTIVE_HIGH.
Otherwise, the SD may not work properly due to wrong polarity inversion
specified in DT after switch to common parsing function mmc_of_parse().

Signed-off-by: Dong Aisheng 
---
 arch/arm/boot/dts/imx25-pdk.dts | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/arm/boot/dts/imx25-pdk.dts b/arch/arm/boot/dts/imx25-pdk.dts
index dd45e69..faf252f 100644
--- a/arch/arm/boot/dts/imx25-pdk.dts
+++ b/arch/arm/boot/dts/imx25-pdk.dts
@@ -114,8 +114,8 @@
 &esdhc1 {
pinctrl-names = "default";
pinctrl-0 = <&pinctrl_esdhc1>;
-   cd-gpios = <&gpio2 1 0>;
-   wp-gpios = <&gpio2 0 0>;
+   cd-gpios = <&gpio2 1 GPIO_ACTIVE_LOW>;
+   wp-gpios = <&gpio2 0 GPIO_ACTIVE_HIGH>;
status = "okay";
 };
 
-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe linux-mmc" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH V2 11/11] dts: mmc: fsl-imx-esdhc: remove fsl,cd-controller support

2015-07-22 Thread Dong Aisheng
It's not supported by driver anymore after using runtime pm
and there's no user of it, so delete it now.

Signed-off-by: Dong Aisheng 
---
 Documentation/devicetree/bindings/mmc/fsl-imx-esdhc.txt | 2 --
 1 file changed, 2 deletions(-)

diff --git a/Documentation/devicetree/bindings/mmc/fsl-imx-esdhc.txt 
b/Documentation/devicetree/bindings/mmc/fsl-imx-esdhc.txt
index 5d0376b..211e778 100644
--- a/Documentation/devicetree/bindings/mmc/fsl-imx-esdhc.txt
+++ b/Documentation/devicetree/bindings/mmc/fsl-imx-esdhc.txt
@@ -17,7 +17,6 @@ Required properties:
   "fsl,imx6sx-usdhc"
 
 Optional properties:
-- fsl,cd-controller : Indicate to use controller internal card detection
 - fsl,wp-controller : Indicate to use controller internal write protection
 - fsl,delay-line : Specify the number of delay cells for override mode.
   This is used to set the clock delay for DLL(Delay Line) on override mode
@@ -35,7 +34,6 @@ esdhc@70004000 {
compatible = "fsl,imx51-esdhc";
reg = <0x70004000 0x4000>;
interrupts = <1>;
-   fsl,cd-controller;
fsl,wp-controller;
 };
 
-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe linux-mmc" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH V2 06/11] mmc: sdhci-esdhc-imx: fix cd regression for dt platform

2015-07-22 Thread Dong Aisheng
Current card detect probe process is that when driver finds a valid
ESDHC_CD_GPIO, it will clear the quirk SDHCI_QUIRK_BROKEN_CARD_DETECTION
which is set by default for all esdhc/usdhc controllers.
Then host driver will know there's a valid card detect function.

Commit 8d86e4fcccf6 ("mmc: sdhci-esdhc-imx: Call mmc_of_parse()")
breaks GPIO CD function for dt platform that it will return directly
when find ESDHC_CD_GPIO for dt platform which result in the later wrongly
to keep SDHCI_QUIRK_BROKEN_CARD_DETECTION for all dt platforms.
Then MMC_CAP_NEEDS_POLL will be used instead even there's a valid
GPIO card detect.

This patch adds back this function and follows the original approach to
clear the quirk if find an valid CD GPIO for dt platforms.

Fixes: 8d86e4fcccf6 ("mmc: sdhci-esdhc-imx: Call mmc_of_parse()")
Signed-off-by: Dong Aisheng 
---
 drivers/mmc/host/sdhci-esdhc-imx.c | 10 +-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/drivers/mmc/host/sdhci-esdhc-imx.c 
b/drivers/mmc/host/sdhci-esdhc-imx.c
index faf0cb9..4815391 100644
--- a/drivers/mmc/host/sdhci-esdhc-imx.c
+++ b/drivers/mmc/host/sdhci-esdhc-imx.c
@@ -881,6 +881,7 @@ sdhci_esdhc_imx_probe_dt(struct platform_device *pdev,
 struct esdhc_platform_data *boarddata)
 {
struct device_node *np = pdev->dev.of_node;
+   int ret;
 
if (!np)
return -ENODEV;
@@ -917,7 +918,14 @@ sdhci_esdhc_imx_probe_dt(struct platform_device *pdev,
mmc_of_parse_voltage(np, &host->ocr_mask);
 
/* call to generic mmc_of_parse to support additional capabilities */
-   return mmc_of_parse(host->mmc);
+   ret = mmc_of_parse(host->mmc);
+   if (ret)
+   return ret;
+
+   if (!IS_ERR_VALUE(mmc_gpio_get_cd(host->mmc)))
+   host->quirks &= ~SDHCI_QUIRK_BROKEN_CARD_DETECTION;
+
+   return 0;
 }
 #else
 static inline int
-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe linux-mmc" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH V2 03/11] dts: imx6: fix sd card gpio polarity specified in device tree

2015-07-22 Thread Dong Aisheng
cd-gpios polarity should be changed to GPIO_ACTIVE_LOW and wp-gpios
should be changed to GPIO_ACTIVE_HIGH.
Otherwise, the SD may not work properly due to wrong polarity inversion
specified in DT after switch to common parsing function mmc_of_parse().

Signed-off-by: Dong Aisheng 
---
 arch/arm/boot/dts/imx6dl-riotboard.dts   |  8 
 arch/arm/boot/dts/imx6q-arm2.dts |  5 +++--
 arch/arm/boot/dts/imx6q-gk802.dts|  3 ++-
 arch/arm/boot/dts/imx6q-tbs2910.dts  |  4 ++--
 arch/arm/boot/dts/imx6qdl-aristainetos.dtsi  |  4 ++--
 arch/arm/boot/dts/imx6qdl-aristainetos2.dtsi |  4 ++--
 arch/arm/boot/dts/imx6qdl-cubox-i.dtsi   |  2 +-
 arch/arm/boot/dts/imx6qdl-dfi-fs700-m60.dtsi |  4 +++-
 arch/arm/boot/dts/imx6qdl-gw52xx.dtsi|  2 +-
 arch/arm/boot/dts/imx6qdl-gw53xx.dtsi|  2 +-
 arch/arm/boot/dts/imx6qdl-gw54xx.dtsi|  2 +-
 arch/arm/boot/dts/imx6qdl-hummingboard.dtsi  |  2 +-
 arch/arm/boot/dts/imx6qdl-nitrogen6x.dtsi|  4 ++--
 arch/arm/boot/dts/imx6qdl-phytec-pfla02.dtsi |  8 
 arch/arm/boot/dts/imx6qdl-rex.dtsi   |  4 ++--
 arch/arm/boot/dts/imx6qdl-sabreauto.dtsi |  4 ++--
 arch/arm/boot/dts/imx6qdl-sabrelite.dtsi |  6 +++---
 arch/arm/boot/dts/imx6qdl-sabresd.dtsi   |  8 
 arch/arm/boot/dts/imx6qdl-tx6.dtsi   |  4 ++--
 arch/arm/boot/dts/imx6qdl-wandboard.dtsi |  6 --
 arch/arm/boot/dts/imx6sl-evk.dts | 10 +-
 arch/arm/boot/dts/imx6sx-sabreauto.dts   |  4 ++--
 arch/arm/boot/dts/imx6sx-sdb.dtsi|  4 ++--
 23 files changed, 55 insertions(+), 49 deletions(-)

diff --git a/arch/arm/boot/dts/imx6dl-riotboard.dts 
b/arch/arm/boot/dts/imx6dl-riotboard.dts
index 43cb3fd..5111f51 100644
--- a/arch/arm/boot/dts/imx6dl-riotboard.dts
+++ b/arch/arm/boot/dts/imx6dl-riotboard.dts
@@ -305,8 +305,8 @@
 &usdhc2 {
pinctrl-names = "default";
pinctrl-0 = <&pinctrl_usdhc2>;
-   cd-gpios = <&gpio1 4 0>;
-   wp-gpios = <&gpio1 2 0>;
+   cd-gpios = <&gpio1 4 GPIO_ACTIVE_LOW>;
+   wp-gpios = <&gpio1 2 GPIO_ACTIVE_HIGH>;
vmmc-supply = <®_3p3v>;
status = "okay";
 };
@@ -314,8 +314,8 @@
 &usdhc3 {
pinctrl-names = "default";
pinctrl-0 = <&pinctrl_usdhc3>;
-   cd-gpios = <&gpio7 0 0>;
-   wp-gpios = <&gpio7 1 0>;
+   cd-gpios = <&gpio7 0 GPIO_ACTIVE_LOW>;
+   wp-gpios = <&gpio7 1 GPIO_ACTIVE_HIGH>;
vmmc-supply = <®_3p3v>;
status = "okay";
 };
diff --git a/arch/arm/boot/dts/imx6q-arm2.dts b/arch/arm/boot/dts/imx6q-arm2.dts
index 78df05e..d6515f7 100644
--- a/arch/arm/boot/dts/imx6q-arm2.dts
+++ b/arch/arm/boot/dts/imx6q-arm2.dts
@@ -11,6 +11,7 @@
  */
 
 /dts-v1/;
+#include 
 #include "imx6q.dtsi"
 
 / {
@@ -196,8 +197,8 @@
 };
 
 &usdhc3 {
-   cd-gpios = <&gpio6 11 0>;
-   wp-gpios = <&gpio6 14 0>;
+   cd-gpios = <&gpio6 11 GPIO_ACTIVE_LOW>;
+   wp-gpios = <&gpio6 14 GPIO_ACTIVE_HIGH>;
vmmc-supply = <®_3p3v>;
pinctrl-names = "default";
pinctrl-0 = <&pinctrl_usdhc3
diff --git a/arch/arm/boot/dts/imx6q-gk802.dts 
b/arch/arm/boot/dts/imx6q-gk802.dts
index 703539c..00bd63e 100644
--- a/arch/arm/boot/dts/imx6q-gk802.dts
+++ b/arch/arm/boot/dts/imx6q-gk802.dts
@@ -7,6 +7,7 @@
  */
 
 /dts-v1/;
+#include 
 #include "imx6q.dtsi"
 
 / {
@@ -161,7 +162,7 @@
pinctrl-names = "default";
pinctrl-0 = <&pinctrl_usdhc3>;
bus-width = <4>;
-   cd-gpios = <&gpio6 11 0>;
+   cd-gpios = <&gpio6 11 GPIO_ACTIVE_LOW>;
vmmc-supply = <®_3p3v>;
status = "okay";
 };
diff --git a/arch/arm/boot/dts/imx6q-tbs2910.dts 
b/arch/arm/boot/dts/imx6q-tbs2910.dts
index a43abfa..5645d52 100644
--- a/arch/arm/boot/dts/imx6q-tbs2910.dts
+++ b/arch/arm/boot/dts/imx6q-tbs2910.dts
@@ -251,7 +251,7 @@
pinctrl-names = "default";
pinctrl-0 = <&pinctrl_usdhc2>;
bus-width = <4>;
-   cd-gpios = <&gpio2 2 GPIO_ACTIVE_HIGH>;
+   cd-gpios = <&gpio2 2 GPIO_ACTIVE_LOW>;
vmmc-supply = <®_3p3v>;
status = "okay";
 };
@@ -260,7 +260,7 @@
pinctrl-names = "default";
pinctrl-0 = <&pinctrl_usdhc3>;
bus-width = <4>;
-   cd-gpios = <&gpio2 0 GPIO_ACTIVE_HIGH>;
+   cd-gpios = <&gpio2 0 GPIO_ACTIVE_LOW>;
wp-gpios = <&gpio2 1 GPIO_ACTIVE_HIGH>;
vmmc-supply = <®_3p3v>;
status = "okay";
diff --git a/arch/arm/boot/dts/imx6qdl-aristainetos.dtsi 
b/arch/arm/boot/dts/imx6qdl-aristainetos.dtsi
index e6d9195..f4d6ae5 100644
--- a/arch/arm/boot/dts/imx6qdl-aristainetos.dtsi
+++ b/arch/arm/boot/dts/imx6qdl-aristainetos.dtsi
@@ -173,7 +173,7 @@
pinctrl-names = "default";
pinctrl-0 = <&pinctrl_usdhc1>;
vmmc-supply = <®_3p3v>;
-   cd-gpios = <&gpio4 7 GPIO_ACTIVE_HIGH>;
+   cd-gpios = <&gpio4 7 GPIO_ACTIVE_LOW>;
status = "okay";
 };
 
@@ -181,7 +181,7 @@
pinctrl-names = "default";
pinctrl-0 = <&pinctrl_usdhc2>;
vmmc-

[PATCH V2 00/11] mmc: sdhci-esdhci-imx: fix cd/wp regression

2015-07-22 Thread Dong Aisheng
This is a rebase version of former two patch series:
http://lists.infradead.org/pipermail/linux-arm-kernel/2015-June/351167.html
http://www.spinics.net/lists/arm-kernel/msg426156.html

No other changes.

Commit 8d86e4f mmc: sdhci-esdhc-imx: Call mmc_of_parse()
seriously break the sd card detect/write protect function
of most IMX platforms since a lot of GPIO flags of cd-gpios/wp-gpios
are wrongly set in devicetree.

It breaks the following things:
1) cd-gpio function enable
Most IMX boards GPIO card detect function becomes unwork and using card
polling mode instead by mistake.
Openning CONFIG_MMC_DEBUG will easily see that.
It is caused by the default quirk SDHCI_QUIRK_BROKEN_CARD_DETECTION
is not cleared for dt platform by commit 8d86e4f, then
MMC_CAP_NEEDS_POLL is wrongly set.

This is fixed by patch 6~7

2) cd-gpio/wp-gpio polarity
Before commit 8d86e4f, we do not use GPIO flags passed from
devicetree. But after it, GPIO flags specfied in dt becomes valid
and will affect the normal cd/wp function.

This is fixed by patch 1~5

3) max-frequency not work in sdhci
mmc_of_parse will parse the max-frequency from devicetree,
however, its value will be overwritten by common sdhci driver
finnally,so it does not actually work.
Patch 8 is to fix it.

4) patch 9~11 clear unneeded parsing code after switch to mmc_of_parse().

The series is based on ulf/next tree.

I also CCed this patch series to all board maintainer related in this
change, hope they can help test it.
I only tested some freescale IMX boards.

Dong Aisheng (11):
  dts: imx51: fix sd card gpio polarity specified in device tree
  dts: imx53: fix sd card gpio polarity specified in device tree
  dts: imx6: fix sd card gpio polarity specified in device tree
  dts: imx25: fix sd card gpio polarity specified in device tree
  dts: imx7: fix sd card gpio polarity specified in device tree
  mmc: sdhci-esdhc-imx: fix cd regression for dt platform
  mmc: sdhci-esdhc-imx: move all non dt probe code into one function
  mmc: sdhci: make max-frequency property in device tree work
  mmc: sdhci-esdhc-imx: remove duplicated dts parsing
  mmc: sdhci-esdhc-imx: clear f_max in boarddata
  dts: mmc: fsl-imx-esdhc: remove fsl,cd-controller support

 .../devicetree/bindings/mmc/fsl-imx-esdhc.txt  |   2 -
 arch/arm/boot/dts/imx25-pdk.dts|   4 +-
 arch/arm/boot/dts/imx51-apf51dev.dts   |   2 +-
 arch/arm/boot/dts/imx53-ard.dts|   4 +-
 arch/arm/boot/dts/imx53-m53evk.dts |   4 +-
 arch/arm/boot/dts/imx53-qsb-common.dtsi|   4 +-
 arch/arm/boot/dts/imx53-smd.dts|   4 +-
 arch/arm/boot/dts/imx53-tqma53.dtsi|   4 +-
 arch/arm/boot/dts/imx53-tx53.dtsi  |   4 +-
 arch/arm/boot/dts/imx53-voipac-bsb.dts |   4 +-
 arch/arm/boot/dts/imx6dl-riotboard.dts |   8 +-
 arch/arm/boot/dts/imx6q-arm2.dts   |   5 +-
 arch/arm/boot/dts/imx6q-gk802.dts  |   3 +-
 arch/arm/boot/dts/imx6q-tbs2910.dts|   4 +-
 arch/arm/boot/dts/imx6qdl-aristainetos.dtsi|   4 +-
 arch/arm/boot/dts/imx6qdl-aristainetos2.dtsi   |   4 +-
 arch/arm/boot/dts/imx6qdl-cubox-i.dtsi |   2 +-
 arch/arm/boot/dts/imx6qdl-dfi-fs700-m60.dtsi   |   4 +-
 arch/arm/boot/dts/imx6qdl-gw52xx.dtsi  |   2 +-
 arch/arm/boot/dts/imx6qdl-gw53xx.dtsi  |   2 +-
 arch/arm/boot/dts/imx6qdl-gw54xx.dtsi  |   2 +-
 arch/arm/boot/dts/imx6qdl-hummingboard.dtsi|   2 +-
 arch/arm/boot/dts/imx6qdl-nitrogen6x.dtsi  |   4 +-
 arch/arm/boot/dts/imx6qdl-phytec-pfla02.dtsi   |   8 +-
 arch/arm/boot/dts/imx6qdl-rex.dtsi |   4 +-
 arch/arm/boot/dts/imx6qdl-sabreauto.dtsi   |   4 +-
 arch/arm/boot/dts/imx6qdl-sabrelite.dtsi   |   6 +-
 arch/arm/boot/dts/imx6qdl-sabresd.dtsi |   8 +-
 arch/arm/boot/dts/imx6qdl-tx6.dtsi |   4 +-
 arch/arm/boot/dts/imx6qdl-wandboard.dtsi   |   6 +-
 arch/arm/boot/dts/imx6sl-evk.dts   |  10 +-
 arch/arm/boot/dts/imx6sx-sabreauto.dts |   4 +-
 arch/arm/boot/dts/imx6sx-sdb.dtsi  |   4 +-
 arch/arm/boot/dts/imx7d-sdb.dts|   4 +-
 drivers/mmc/host/sdhci-esdhc-imx.c | 210 ++---
 drivers/mmc/host/sdhci.c   |   9 +-
 include/linux/platform_data/mmc-esdhc-imx.h|   1 -
 37 files changed, 185 insertions(+), 179 deletions(-)

-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe linux-mmc" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH V2 01/11] dts: imx51: fix sd card gpio polarity specified in device tree

2015-07-22 Thread Dong Aisheng
cd-gpios polarity should be changed to GPIO_ACTIVE_LOW and wp-gpios
should be changed to GPIO_ACTIVE_HIGH.
Otherwise, the SD may not work properly due to wrong polarity inversion
specified in DT after switch to common parsing function mmc_of_parse().

Signed-off-by: Dong Aisheng 
---
 arch/arm/boot/dts/imx51-apf51dev.dts | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/arm/boot/dts/imx51-apf51dev.dts 
b/arch/arm/boot/dts/imx51-apf51dev.dts
index 93d3ea1..0f3fe29 100644
--- a/arch/arm/boot/dts/imx51-apf51dev.dts
+++ b/arch/arm/boot/dts/imx51-apf51dev.dts
@@ -98,7 +98,7 @@
 &esdhc1 {
pinctrl-names = "default";
pinctrl-0 = <&pinctrl_esdhc1>;
-   cd-gpios = <&gpio2 29 GPIO_ACTIVE_HIGH>;
+   cd-gpios = <&gpio2 29 GPIO_ACTIVE_LOW>;
bus-width = <4>;
status = "okay";
 };
-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe linux-mmc" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] sdhci-esdhc: Make 8BIT bus work.

2015-07-22 Thread Joakim Tjernlund
On Wed, 2015-07-22 at 14:18 +0200, Ulf Hansson wrote:
> On 20 July 2015 at 18:19, Joakim Tjernlund
>  wrote:
> > Support for 8BIT bus with was added some time ago to sdhci-esdhc but
> > then missed to remove the 8BIT from the reserved bit mask which made
> > 8BIT non functional.
> > 
> > Signed-off-by: Joakim Tjernlund 
> 
> Should this be queued as a fix then? If so, please resend and include
> a fixes tag.

8BIT never worked for this controller, when support for 8BIT was added no one
noticed that it didn't work for sdhci-esdhc. I suspect it was never tested.

If that qualifies as a fix I can add an:

Fixes: 66b50a00992d ("mmc: esdhc: Add support for 8-bit bus width and 
non-removable card")

> 
> Kind regards
> Uffe
> 
> > ---
> >  drivers/mmc/host/sdhci-esdhc.h | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> > diff --git a/drivers/mmc/host/sdhci-esdhc.h b/drivers/mmc/host/sdhci-esdhc.h
> > index 3497cfa..a870c42 100644
> > --- a/drivers/mmc/host/sdhci-esdhc.h
> > +++ b/drivers/mmc/host/sdhci-esdhc.h
> > @@ -45,6 +45,6 @@
> >  #define ESDHC_DMA_SYSCTL   0x40c
> >  #define ESDHC_DMA_SNOOP0x0040
> > 
> > -#define ESDHC_HOST_CONTROL_RES 0x05
> > +#define ESDHC_HOST_CONTROL_RES 0x01
> > 
> >  #endif /* _DRIVERS_MMC_SDHCI_ESDHC_H */
> > --
> > 2.3.6
> > 
> > --
> > To unsubscribe from this list: send the line "unsubscribe linux-mmc" in
> > the body of a message to majord...@vger.kernel.org
> > More majordomo info at  http://vger.kernel.org/majordomo-info.html
--
To unsubscribe from this list: send the line "unsubscribe linux-mmc" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] sdhci-esdhc: Make 8BIT bus work.

2015-07-22 Thread Ulf Hansson
On 20 July 2015 at 18:19, Joakim Tjernlund
 wrote:
> Support for 8BIT bus with was added some time ago to sdhci-esdhc but
> then missed to remove the 8BIT from the reserved bit mask which made
> 8BIT non functional.
>
> Signed-off-by: Joakim Tjernlund 

Should this be queued as a fix then? If so, please resend and include
a fixes tag.

Kind regards
Uffe

> ---
>  drivers/mmc/host/sdhci-esdhc.h | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/mmc/host/sdhci-esdhc.h b/drivers/mmc/host/sdhci-esdhc.h
> index 3497cfa..a870c42 100644
> --- a/drivers/mmc/host/sdhci-esdhc.h
> +++ b/drivers/mmc/host/sdhci-esdhc.h
> @@ -45,6 +45,6 @@
>  #define ESDHC_DMA_SYSCTL   0x40c
>  #define ESDHC_DMA_SNOOP0x0040
>
> -#define ESDHC_HOST_CONTROL_RES 0x05
> +#define ESDHC_HOST_CONTROL_RES 0x01
>
>  #endif /* _DRIVERS_MMC_SDHCI_ESDHC_H */
> --
> 2.3.6
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-mmc" in
> the body of a message to majord...@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
--
To unsubscribe from this list: send the line "unsubscribe linux-mmc" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] mmc: omap_hsmmc: Update driver to support without regulators

2015-07-22 Thread Kishon Vijay Abraham I
Hi,

On Wednesday 22 July 2015 05:37 PM, Ulf Hansson wrote:
> [...]
> 
>> Hi Ulf,
>>
>> Just to clarify do you have an issue with this patch or in general
>> you rather nothave !CONFIG_REGULATOR supported? If its the latter
>> then wouldit be better to remove the !CONFIG_REGULATOR portion from
>> this driver all together.
> 
> I don't like this patch as is, as it seems like you are replacing the
> VMMC regulator that actually exist in HW by parsing a DT property.
> 
> I think mmc_of_parse_voltage() shall *only* be used when the OCR mask
> (->ocr_avail) can't be fetched by using a regulator. Typically that's
> when the VMMC voltage levels are managed within the mmc controller
> itself.
> 
> I don't have a strong opinion on how you solve that, but I guess you
> have two options.
> 
> 1.
> Make sure the driver can be build and used both for CONFIG_REGULATOR
> and !CONFIG_REGULATOR. What you need to take care of then, is to
> assign the ->ocr_avail mask to a default value in the case when it
> can't be fetched from a regulator. Most mmc drivers has some kind of
> fall-back mechanism like this.

I'm working on cleaning up omap_hsmmc driver where I have taken care to avoid
dependency with CONFIG_REGULATOR. I'll post the series asap.

Thanks
Kishon
--
To unsubscribe from this list: send the line "unsubscribe linux-mmc" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] mmc: omap_hsmmc: Update driver to support without regulators

2015-07-22 Thread Ulf Hansson
[...]

> Hi Ulf,
>
> Just to clarify do you have an issue with this patch or in general
> you rather nothave !CONFIG_REGULATOR supported? If its the latter
> then wouldit be better to remove the !CONFIG_REGULATOR portion from
> this driver all together.

I don't like this patch as is, as it seems like you are replacing the
VMMC regulator that actually exist in HW by parsing a DT property.

I think mmc_of_parse_voltage() shall *only* be used when the OCR mask
(->ocr_avail) can't be fetched by using a regulator. Typically that's
when the VMMC voltage levels are managed within the mmc controller
itself.

I don't have a strong opinion on how you solve that, but I guess you
have two options.

1.
Make sure the driver can be build and used both for CONFIG_REGULATOR
and !CONFIG_REGULATOR. What you need to take care of then, is to
assign the ->ocr_avail mask to a default value in the case when it
can't be fetched from a regulator. Most mmc drivers has some kind of
fall-back mechanism like this.

For those SoC where you need/can control the VMMC regulator, make sure
those enables CONFIG_REGULATOR to get the proper behaviour by
omap_hsmmc.

2.
Force omap_hsmmc to be build with CONFIG_REGULATOR.

Kind regards
Uffe
--
To unsubscribe from this list: send the line "unsubscribe linux-mmc" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [RFC PATCH 0/4] mmc: sdhci: Support maximum DMA latency request via PM QoS

2015-07-22 Thread Bastien Nocera
Adrian Hunter  intel.com> writes:
> Ad hoc testing with Lenovo Thinkpad 10 showed a stress
> test could run for at least 24 hours with the patches,
> compared to less than an hour without.

I've had the same sort of problems on 2 different BayTrail tablets (a Onda
v975w and a WinBook TW100), usually hanging hard during package installation
and was wondering whether you would resubmit your patches to be merged (I
understand that the CPU detection was problematic), or whether I should ship
those in our vendor kernel in the meanwhile.

I'll report shortly how well that patch series works after testing.

> These patches are on top of my driver strength patches
> which are on top of my re-tuning patches.

Those 2 patchsets got merged upstream now, correct?

Cheers


--
To unsubscribe from this list: send the line "unsubscribe linux-mmc" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] mmc: omap_hsmmc: Update driver to support without regulators

2015-07-22 Thread Franklin S Cooper Jr.


On 07/21/2015 02:39 PM, Franklin S Cooper Jr. wrote:
>
> On 07/21/2015 06:40 AM, Ulf Hansson wrote:
>> On 14 July 2015 at 21:29, Franklin S Cooper Jr  wrote:
>>> From: Roger Quadros 
>>>
>>> Update driver to support without regulators.
>>>
>>> Without this patch boards that do not enable regulator config options will
>>> fail to boot with a kernel panic.
>> I guess that's because the rootfs is mounted on the card that doesn't
>> get detected, right?
> No at ramfs was used to validate this and was loaded via ethernet in U-boot.
>>> Signed-off-by: Roger Quadros 
>>> Signed-off-by: Lokesh Vutla 
>>> Signed-off-by: Murali Karicheri 
>>> Signed-off-by: Franklin S Cooper Jr 
>>> ---
>>>  Documentation/devicetree/bindings/mmc/ti-omap-hsmmc.txt |  2 ++
>>>  drivers/mmc/host/omap_hsmmc.c   | 14 ++
>>>  2 files changed, 12 insertions(+), 4 deletions(-)
>>>
>>> diff --git a/Documentation/devicetree/bindings/mmc/ti-omap-hsmmc.txt 
>>> b/Documentation/devicetree/bindings/mmc/ti-omap-hsmmc.txt
>>> index 76bf087..2408e87 100644
>>> --- a/Documentation/devicetree/bindings/mmc/ti-omap-hsmmc.txt
>>> +++ b/Documentation/devicetree/bindings/mmc/ti-omap-hsmmc.txt
>>> @@ -22,6 +22,8 @@ ti,dual-volt: boolean, supports dual voltage cards
>>>  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
>>> +voltage-ranges: Specify the voltage range supported if regulator framework
>>> +isn't enabled.
>>>  dmas: List of DMA specifiers with the controller specific format
>>>  as described in the generic DMA client binding. A tx and rx
>>>  specifier is required.
>>> diff --git a/drivers/mmc/host/omap_hsmmc.c b/drivers/mmc/host/omap_hsmmc.c
>>> index b2b411d..16c870f 100644
>>> --- a/drivers/mmc/host/omap_hsmmc.c
>>> +++ b/drivers/mmc/host/omap_hsmmc.c
>>> @@ -1551,10 +1551,13 @@ static void omap_hsmmc_set_ios(struct mmc_host 
>>> *mmc, struct mmc_ios *ios)
>>> if (ios->power_mode != host->power_mode) {
>>> switch (ios->power_mode) {
>>> case MMC_POWER_OFF:
>>> -   mmc_pdata(host)->set_power(host->dev, 0, 0);
>>> +   if (host->use_reg)
>>> +   mmc_pdata(host)->set_power(host->dev, 0, 0);
>>> break;
>>> case MMC_POWER_UP:
>>> -   mmc_pdata(host)->set_power(host->dev, 1, ios->vdd);
>>> +   if (host->use_reg)
>>> +   mmc_pdata(host)->set_power(host->dev, 1,
>>> +  ios->vdd);
>>> break;
>>> case MMC_POWER_ON:
>>> do_send_init_stream = 1;
>>> @@ -2082,10 +2085,13 @@ static int omap_hsmmc_probe(struct platform_device 
>>> *pdev)
>>> if (ret)
>>> goto err_irq;
>>> host->use_reg = 1;
>>> +   mmc->ocr_avail = mmc_pdata(host)->ocr_mask;
>>> +   } else {
>>> +   ret = mmc_of_parse_voltage(pdev->dev.of_node, 
>>> &mmc->ocr_avail);
>>> +   if (ret)
>>> +   goto err_irq;
>>> }
>>>
>>> -   mmc->ocr_avail = mmc_pdata(host)->ocr_mask;
>>> -
>>> omap_hsmmc_disable_irq(host);
>>>
>>> /*
>>> --
>>> 1.9.1
>>>
>>> --
>>> To unsubscribe from this list: send the line "unsubscribe linux-mmc" in
>>> the body of a message to majord...@vger.kernel.org
>>> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>> No, I don't like this patch. If your board have regulators which can
>> be used to find out the voltage levels, we shall use them. We shall
>> not use DT to workaround this.
>>
>> So, perhaps the Kconfig section for omap_hsmmc should select
>> CONFIG_REGULATOR (and friends)?
> Looking at the code the "ifdefCONFIG_REGULATOR" and the usage of use_reg
> (use regulator) shows that this driver is suppose to support boards that
> don't have the regulator framework enabled.
>
> This patches insures that this driver can work without the regulator framework
> which is currently broken.
Hi Ulf,

Just to clarify do you have an issue with this patch or in general
you rather nothave !CONFIG_REGULATOR supported? If its the latter
then wouldit be better to remove the !CONFIG_REGULATOR portion from
this driver all together.
>> Kind regards
>> Uffe
> --
> To unsubscribe from this list: send the line "unsubscribe linux-omap" in
> the body of a message to majord...@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

--
To unsubscribe from this list: send the line "unsubscribe linux-mmc" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 3/3] mmc: host: omap_hsmmc: Add custom card detect irq handler

2015-07-22 Thread Vignesh R
Hi Andreas,

On 07/21/2015 01:46 PM, Andreas Fenkart wrote:
> Hi Vignesh,
> 
> Generally I don't like this patch, it will make it harder, not easier,
> to maintain the omap hsmmc driver. Also given that the bug occurs
> rarely, people will be reluctant to clean it up later or accept
> patches.
> 
> see also comments below
> 
[snip]
> 2015-06-22 15:18 GMT+02:00 Vignesh R :
>>
> 
>> But calls to omap_hsmmc_card_init or omap_hsmmc_get_cd are in the same
>> mmc_rescan thread. Hence, moving the recovery code to init_card does not
>> help.
> 
> what about clearing any pending transfer in
> - mmc_gpio_cd_irqt, or
> - mmc_detect_change
> 
> e.g. trigger the later mentioned .card_event callback from those
> functions, instead mmc_rescan? Then you can install your
> omap_hsmmc_request_clear as the card_event callback. This makes your
> custom isr handler redundant, actually your isr handler became
> standard.
> 

I looked  at the commit fa372a51cb5f93800f711473e5a36e0e0c9a8f00 which
moved .card_event out of mmc_gpio_cd_irqt. It points to two threads
where discussion to move .card_event to mmc_rescan happened[1][2]. The
concern there was this callback was being called from "atomic context"
but, I don't understand how threaded irq is "atomic context". (I am not
sure, if this is because those drivers have irqs disabled till threaded
irq is complete) But, I believe moving card_event callback back to
mmc_gpio_cd_irqt may break some drivers.
I will look into this further.
Do you have any insight on this commit? Thanks!

[1]https://lkml.org/lkml/2014/3/19/79
[2]https://lkml.org/lkml/2013/8/19/539

-- 
Regards
Vignesh
--
To unsubscribe from this list: send the line "unsubscribe linux-mmc" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html