diff mbox

[v2] mmc: sdhci-xenon: add set_power callback

Message ID 1503338529-21102-1-git-send-email-zjwu@marvell.com (mailing list archive)
State New, archived
Headers show

Commit Message

Zhoujie Wu Aug. 21, 2017, 6:02 p.m. UTC
Xenon sdh controller requests proper SD bus voltage select
bits programmed even with vmmc power supply. Any reserved
value(100b-000b) programmed in this field will lead to controller
ignore SD bus power bit and keep its value at zero.
Add set_power callback to handle this.

Signed-off-by: Zhoujie Wu <zjwu@marvell.com>
---
Updated according to Jisheng Zhang's comment.
 drivers/mmc/host/sdhci-xenon.c | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

Comments

Adrian Hunter Aug. 28, 2017, 9:57 a.m. UTC | #1
On 21/08/17 21:02, Zhoujie Wu wrote:
> Xenon sdh controller requests proper SD bus voltage select
> bits programmed even with vmmc power supply. Any reserved
> value(100b-000b) programmed in this field will lead to controller
> ignore SD bus power bit and keep its value at zero.
> Add set_power callback to handle this.
> 
> Signed-off-by: Zhoujie Wu <zjwu@marvell.com>

Acked-by: Adrian Hunter <adrian.hunter@intel.com>

> ---
> Updated according to Jisheng Zhang's comment.
>  drivers/mmc/host/sdhci-xenon.c | 19 +++++++++++++++++++
>  1 file changed, 19 insertions(+)
> 
> diff --git a/drivers/mmc/host/sdhci-xenon.c b/drivers/mmc/host/sdhci-xenon.c
> index edd4d915..a4be2fd 100644
> --- a/drivers/mmc/host/sdhci-xenon.c
> +++ b/drivers/mmc/host/sdhci-xenon.c
> @@ -210,8 +210,27 @@ static void xenon_set_uhs_signaling(struct sdhci_host *host,
>  	sdhci_writew(host, ctrl_2, SDHCI_HOST_CONTROL2);
>  }
>  
> +static void xenon_set_power(struct sdhci_host *host, unsigned char mode,
> +		unsigned short vdd)
> +{
> +	struct mmc_host *mmc = host->mmc;
> +	u8 pwr = host->pwr;
> +
> +	sdhci_set_power_noreg(host, mode, vdd);
> +
> +	if (host->pwr == pwr)
> +		return;
> +
> +	if (host->pwr == 0)
> +		vdd = 0;
> +
> +	if (!IS_ERR(mmc->supply.vmmc))
> +		mmc_regulator_set_ocr(mmc, mmc->supply.vmmc, vdd);
> +}
> +
>  static const struct sdhci_ops sdhci_xenon_ops = {
>  	.set_clock		= sdhci_set_clock,
> +	.set_power		= xenon_set_power,
>  	.set_bus_width		= sdhci_set_bus_width,
>  	.reset			= xenon_reset,
>  	.set_uhs_signaling	= xenon_set_uhs_signaling,
> 

--
To unsubscribe from this list: send the line "unsubscribe linux-mmc" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Gregory CLEMENT Aug. 28, 2017, 3:54 p.m. UTC | #2
Hi,
 
 On lun., août 28 2017, Adrian Hunter <adrian.hunter@intel.com> wrote:

> On 21/08/17 21:02, Zhoujie Wu wrote:
>> Xenon sdh controller requests proper SD bus voltage select
>> bits programmed even with vmmc power supply. Any reserved
>> value(100b-000b) programmed in this field will lead to controller
>> ignore SD bus power bit and keep its value at zero.
>> Add set_power callback to handle this.
>> 
>> Signed-off-by: Zhoujie Wu <zjwu@marvell.com>
>
> Acked-by: Adrian Hunter <adrian.hunter@intel.com>

I tested this patch on the Armada 3720 DB board. And thanks to this patch
and by adding a vmmc regulator in the device tree I did not have anymore
the issue UHS card not detected on warm reset.

Tested-by: Gregory CLEMENT <gregory.clement@free-electrons.com>

Actually for me this should be a fix. Indeed if I try to use a vmmc
regulator without this patch then the SD card does not work at all I
only have the following messages:

"mmc1: Timeout waiting for hardware cmd interrupt."

Thanks,

Gregory


>
>> ---
>> Updated according to Jisheng Zhang's comment.
>>  drivers/mmc/host/sdhci-xenon.c | 19 +++++++++++++++++++
>>  1 file changed, 19 insertions(+)
>> 
>> diff --git a/drivers/mmc/host/sdhci-xenon.c b/drivers/mmc/host/sdhci-xenon.c
>> index edd4d915..a4be2fd 100644
>> --- a/drivers/mmc/host/sdhci-xenon.c
>> +++ b/drivers/mmc/host/sdhci-xenon.c
>> @@ -210,8 +210,27 @@ static void xenon_set_uhs_signaling(struct sdhci_host *host,
>>  	sdhci_writew(host, ctrl_2, SDHCI_HOST_CONTROL2);
>>  }
>>  
>> +static void xenon_set_power(struct sdhci_host *host, unsigned char mode,
>> +		unsigned short vdd)
>> +{
>> +	struct mmc_host *mmc = host->mmc;
>> +	u8 pwr = host->pwr;
>> +
>> +	sdhci_set_power_noreg(host, mode, vdd);
>> +
>> +	if (host->pwr == pwr)
>> +		return;
>> +
>> +	if (host->pwr == 0)
>> +		vdd = 0;
>> +
>> +	if (!IS_ERR(mmc->supply.vmmc))
>> +		mmc_regulator_set_ocr(mmc, mmc->supply.vmmc, vdd);
>> +}
>> +
>>  static const struct sdhci_ops sdhci_xenon_ops = {
>>  	.set_clock		= sdhci_set_clock,
>> +	.set_power		= xenon_set_power,
>>  	.set_bus_width		= sdhci_set_bus_width,
>>  	.reset			= xenon_reset,
>>  	.set_uhs_signaling	= xenon_set_uhs_signaling,
>> 
>
Zhoujie Wu Aug. 28, 2017, 6:45 p.m. UTC | #3
Hi Gregory,

On 08/28/2017 08:54 AM, Gregory CLEMENT wrote:
> Hi,
>   
>   On lun., août 28 2017, Adrian Hunter <adrian.hunter@intel.com> wrote:
>
>> On 21/08/17 21:02, Zhoujie Wu wrote:
>>> Xenon sdh controller requests proper SD bus voltage select
>>> bits programmed even with vmmc power supply. Any reserved
>>> value(100b-000b) programmed in this field will lead to controller
>>> ignore SD bus power bit and keep its value at zero.
>>> Add set_power callback to handle this.
>>>
>>> Signed-off-by: Zhoujie Wu <zjwu@marvell.com>
>> Acked-by: Adrian Hunter <adrian.hunter@intel.com>
> I tested this patch on the Armada 3720 DB board. And thanks to this patch
> and by adding a vmmc regulator in the device tree I did not have anymore
> the issue UHS card not detected on warm reset.
>
> Tested-by: Gregory CLEMENT <gregory.clement@free-electrons.com>
>
> Actually for me this should be a fix. Indeed if I try to use a vmmc
> regulator without this patch then the SD card does not work at all I
> only have the following messages:
>
> "mmc1: Timeout waiting for hardware cmd interrupt."
This patch with sd vmmc power supply(must be claimed as AON, or card 
detection can't work)enabled can solve the issue for warm reset. This 
patch is must for xenon controller once vmmc power supply enabled, since 
the HW will ignore any reserved value for sd bus voltage select field 
and ignore the pwr_en in this case.
But recently we met another issue after resume, it is similar as warm 
reset. When resume back, SD card(UHS) is re-initialized and it is 
recognized as HS again. It needs power-cycle before initialization to 
solve the resume issue. But vmmc is claimed as AON, it won't be shut 
down in standby, so vmmc and this patch won't solve resume issue. I have 
no better idea to solve both warm reset and resume issue, I added a 
dedicated pwrseq for a3700 sd card, it will do power cycle during pre 
and post pwrseq, but keep power when power off the card.
Do you have any other better suggestion?
>
> Thanks,
>
> Gregory
>
>
>>> ---
>>> Updated according to Jisheng Zhang's comment.
>>>   drivers/mmc/host/sdhci-xenon.c | 19 +++++++++++++++++++
>>>   1 file changed, 19 insertions(+)
>>>
>>> diff --git a/drivers/mmc/host/sdhci-xenon.c b/drivers/mmc/host/sdhci-xenon.c
>>> index edd4d915..a4be2fd 100644
>>> --- a/drivers/mmc/host/sdhci-xenon.c
>>> +++ b/drivers/mmc/host/sdhci-xenon.c
>>> @@ -210,8 +210,27 @@ static void xenon_set_uhs_signaling(struct sdhci_host *host,
>>>   	sdhci_writew(host, ctrl_2, SDHCI_HOST_CONTROL2);
>>>   }
>>>   
>>> +static void xenon_set_power(struct sdhci_host *host, unsigned char mode,
>>> +		unsigned short vdd)
>>> +{
>>> +	struct mmc_host *mmc = host->mmc;
>>> +	u8 pwr = host->pwr;
>>> +
>>> +	sdhci_set_power_noreg(host, mode, vdd);
>>> +
>>> +	if (host->pwr == pwr)
>>> +		return;
>>> +
>>> +	if (host->pwr == 0)
>>> +		vdd = 0;
>>> +
>>> +	if (!IS_ERR(mmc->supply.vmmc))
>>> +		mmc_regulator_set_ocr(mmc, mmc->supply.vmmc, vdd);
>>> +}
>>> +
>>>   static const struct sdhci_ops sdhci_xenon_ops = {
>>>   	.set_clock		= sdhci_set_clock,
>>> +	.set_power		= xenon_set_power,
>>>   	.set_bus_width		= sdhci_set_bus_width,
>>>   	.reset			= xenon_reset,
>>>   	.set_uhs_signaling	= xenon_set_uhs_signaling,
>>>

--
To unsubscribe from this list: send the line "unsubscribe linux-mmc" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Shawn Lin Aug. 29, 2017, 3:29 a.m. UTC | #4
On 2017/8/29 2:45, Zhoujie Wu wrote:
> Hi Gregory,
> 
> On 08/28/2017 08:54 AM, Gregory CLEMENT wrote:
>> Hi,
>>   On lun., août 28 2017, Adrian Hunter <adrian.hunter@intel.com> wrote:
>>
>>> On 21/08/17 21:02, Zhoujie Wu wrote:
>>>> Xenon sdh controller requests proper SD bus voltage select
>>>> bits programmed even with vmmc power supply. Any reserved
>>>> value(100b-000b) programmed in this field will lead to controller
>>>> ignore SD bus power bit and keep its value at zero.
>>>> Add set_power callback to handle this.
>>>>
>>>> Signed-off-by: Zhoujie Wu <zjwu@marvell.com>
>>> Acked-by: Adrian Hunter <adrian.hunter@intel.com>
>> I tested this patch on the Armada 3720 DB board. And thanks to this patch
>> and by adding a vmmc regulator in the device tree I did not have anymore
>> the issue UHS card not detected on warm reset.
>>
>> Tested-by: Gregory CLEMENT <gregory.clement@free-electrons.com>
>>
>> Actually for me this should be a fix. Indeed if I try to use a vmmc
>> regulator without this patch then the SD card does not work at all I
>> only have the following messages:
>>
>> "mmc1: Timeout waiting for hardware cmd interrupt."
> This patch with sd vmmc power supply(must be claimed as AON, or card 
> detection can't work)enabled can solve the issue for warm reset. This 
> patch is must for xenon controller once vmmc power supply enabled, since 
> the HW will ignore any reserved value for sd bus voltage select field 
> and ignore the pwr_en in this case.
> But recently we met another issue after resume, it is similar as warm 
> reset. When resume back, SD card(UHS) is re-initialized and it is 
> recognized as HS again. It needs power-cycle before initialization to 
> solve the resume issue. But vmmc is claimed as AON, it won't be shut 

This is a expected behaviour from the spec's POV. So you need a high
level solution to solve it for all hosts. I just quickly cook a patch[1]
for test, maybe it doesn't work at all but I guess it helps.:)

[1]: https://patchwork.kernel.org/patch/9926715/

> down in standby, so vmmc and this patch won't solve resume issue. I have 
> no better idea to solve both warm reset and resume issue, I added a 
> dedicated pwrseq for a3700 sd card, it will do power cycle during pre 
> and post pwrseq, but keep power when power off the card.
> Do you have any other better suggestion?
>>
>> Thanks,
>>
>> Gregory
>>
>>
>>>> ---
>>>> Updated according to Jisheng Zhang's comment.
>>>>   drivers/mmc/host/sdhci-xenon.c | 19 +++++++++++++++++++
>>>>   1 file changed, 19 insertions(+)
>>>>
>>>> diff --git a/drivers/mmc/host/sdhci-xenon.c 
>>>> b/drivers/mmc/host/sdhci-xenon.c
>>>> index edd4d915..a4be2fd 100644
>>>> --- a/drivers/mmc/host/sdhci-xenon.c
>>>> +++ b/drivers/mmc/host/sdhci-xenon.c
>>>> @@ -210,8 +210,27 @@ static void xenon_set_uhs_signaling(struct 
>>>> sdhci_host *host,
>>>>       sdhci_writew(host, ctrl_2, SDHCI_HOST_CONTROL2);
>>>>   }
>>>> +static void xenon_set_power(struct sdhci_host *host, unsigned char 
>>>> mode,
>>>> +        unsigned short vdd)
>>>> +{
>>>> +    struct mmc_host *mmc = host->mmc;
>>>> +    u8 pwr = host->pwr;
>>>> +
>>>> +    sdhci_set_power_noreg(host, mode, vdd);
>>>> +
>>>> +    if (host->pwr == pwr)
>>>> +        return;
>>>> +
>>>> +    if (host->pwr == 0)
>>>> +        vdd = 0;
>>>> +
>>>> +    if (!IS_ERR(mmc->supply.vmmc))
>>>> +        mmc_regulator_set_ocr(mmc, mmc->supply.vmmc, vdd);
>>>> +}
>>>> +
>>>>   static const struct sdhci_ops sdhci_xenon_ops = {
>>>>       .set_clock        = sdhci_set_clock,
>>>> +    .set_power        = xenon_set_power,
>>>>       .set_bus_width        = sdhci_set_bus_width,
>>>>       .reset            = xenon_reset,
>>>>       .set_uhs_signaling    = xenon_set_uhs_signaling,
>>>>
> 
> -- 
> To unsubscribe from this list: send the line "unsubscribe linux-mmc" in
> the body of a message to majordomo@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 majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Shawn Lin Aug. 29, 2017, 3:56 a.m. UTC | #5
On 2017/8/29 11:29, Shawn Lin wrote:
> On 2017/8/29 2:45, Zhoujie Wu wrote:
>> Hi Gregory,
>>
>> On 08/28/2017 08:54 AM, Gregory CLEMENT wrote:
>>> Hi,
>>>   On lun., août 28 2017, Adrian Hunter <adrian.hunter@intel.com> wrote:
>>>
>>>> On 21/08/17 21:02, Zhoujie Wu wrote:
>>>>> Xenon sdh controller requests proper SD bus voltage select
>>>>> bits programmed even with vmmc power supply. Any reserved
>>>>> value(100b-000b) programmed in this field will lead to controller
>>>>> ignore SD bus power bit and keep its value at zero.
>>>>> Add set_power callback to handle this.
>>>>>
>>>>> Signed-off-by: Zhoujie Wu <zjwu@marvell.com>
>>>> Acked-by: Adrian Hunter <adrian.hunter@intel.com>
>>> I tested this patch on the Armada 3720 DB board. And thanks to this 
>>> patch
>>> and by adding a vmmc regulator in the device tree I did not have anymore
>>> the issue UHS card not detected on warm reset.
>>>
>>> Tested-by: Gregory CLEMENT <gregory.clement@free-electrons.com>
>>>
>>> Actually for me this should be a fix. Indeed if I try to use a vmmc
>>> regulator without this patch then the SD card does not work at all I
>>> only have the following messages:
>>>
>>> "mmc1: Timeout waiting for hardware cmd interrupt."
>> This patch with sd vmmc power supply(must be claimed as AON, or card 
>> detection can't work)enabled can solve the issue for warm reset. This 
>> patch is must for xenon controller once vmmc power supply enabled, 
>> since the HW will ignore any reserved value for sd bus voltage select 
>> field and ignore the pwr_en in this case.
>> But recently we met another issue after resume, it is similar as warm 
>> reset. When resume back, SD card(UHS) is re-initialized and it is 
>> recognized as HS again. It needs power-cycle before initialization to 
>> solve the resume issue. But vmmc is claimed as AON, it won't be shut 
> 
> This is a expected behaviour from the spec's POV. So you need a high
> level solution to solve it for all hosts. I just quickly cook a patch[1]
> for test, maybe it doesn't work at all but I guess it helps.:)
> 
> [1]: https://patchwork.kernel.org/patch/9926715/

Hmm.. sorry. update v2 for setting voltage to 1v8 for that case.

https://patchwork.kernel.org/patch/9926723/

> 
>> down in standby, so vmmc and this patch won't solve resume issue. I 
>> have no better idea to solve both warm reset and resume issue, I added 
>> a dedicated pwrseq for a3700 sd card, it will do power cycle during 
>> pre and post pwrseq, but keep power when power off the card.
>> Do you have any other better suggestion?
>>>
>>> Thanks,
>>>
>>> Gregory
>>>
>>>
>>>>> ---
>>>>> Updated according to Jisheng Zhang's comment.
>>>>>   drivers/mmc/host/sdhci-xenon.c | 19 +++++++++++++++++++
>>>>>   1 file changed, 19 insertions(+)
>>>>>
>>>>> diff --git a/drivers/mmc/host/sdhci-xenon.c 
>>>>> b/drivers/mmc/host/sdhci-xenon.c
>>>>> index edd4d915..a4be2fd 100644
>>>>> --- a/drivers/mmc/host/sdhci-xenon.c
>>>>> +++ b/drivers/mmc/host/sdhci-xenon.c
>>>>> @@ -210,8 +210,27 @@ static void xenon_set_uhs_signaling(struct 
>>>>> sdhci_host *host,
>>>>>       sdhci_writew(host, ctrl_2, SDHCI_HOST_CONTROL2);
>>>>>   }
>>>>> +static void xenon_set_power(struct sdhci_host *host, unsigned char 
>>>>> mode,
>>>>> +        unsigned short vdd)
>>>>> +{
>>>>> +    struct mmc_host *mmc = host->mmc;
>>>>> +    u8 pwr = host->pwr;
>>>>> +
>>>>> +    sdhci_set_power_noreg(host, mode, vdd);
>>>>> +
>>>>> +    if (host->pwr == pwr)
>>>>> +        return;
>>>>> +
>>>>> +    if (host->pwr == 0)
>>>>> +        vdd = 0;
>>>>> +
>>>>> +    if (!IS_ERR(mmc->supply.vmmc))
>>>>> +        mmc_regulator_set_ocr(mmc, mmc->supply.vmmc, vdd);
>>>>> +}
>>>>> +
>>>>>   static const struct sdhci_ops sdhci_xenon_ops = {
>>>>>       .set_clock        = sdhci_set_clock,
>>>>> +    .set_power        = xenon_set_power,
>>>>>       .set_bus_width        = sdhci_set_bus_width,
>>>>>       .reset            = xenon_reset,
>>>>>       .set_uhs_signaling    = xenon_set_uhs_signaling,
>>>>>
>>
>> -- 
>> To unsubscribe from this list: send the line "unsubscribe linux-mmc" in
>> the body of a message to majordomo@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 majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Gregory CLEMENT Aug. 29, 2017, 10:18 a.m. UTC | #6
Hi Zhoujie,
 
 On lun., août 28 2017, Zhoujie Wu <zjwu@marvell.com> wrote:

> Hi Gregory,
>
> On 08/28/2017 08:54 AM, Gregory CLEMENT wrote:
>> Hi,
>>     On lun., août 28 2017, Adrian Hunter <adrian.hunter@intel.com>
>> wrote:
>>
>>> On 21/08/17 21:02, Zhoujie Wu wrote:
>>>> Xenon sdh controller requests proper SD bus voltage select
>>>> bits programmed even with vmmc power supply. Any reserved
>>>> value(100b-000b) programmed in this field will lead to controller
>>>> ignore SD bus power bit and keep its value at zero.
>>>> Add set_power callback to handle this.
>>>>
>>>> Signed-off-by: Zhoujie Wu <zjwu@marvell.com>
>>> Acked-by: Adrian Hunter <adrian.hunter@intel.com>
>> I tested this patch on the Armada 3720 DB board. And thanks to this patch
>> and by adding a vmmc regulator in the device tree I did not have anymore
>> the issue UHS card not detected on warm reset.
>>
>> Tested-by: Gregory CLEMENT <gregory.clement@free-electrons.com>
>>
>> Actually for me this should be a fix. Indeed if I try to use a vmmc
>> regulator without this patch then the SD card does not work at all I
>> only have the following messages:
>>
>> "mmc1: Timeout waiting for hardware cmd interrupt."
> This patch with sd vmmc power supply(must be claimed as AON, or card
> detection can't work)enabled can solve the issue for warm reset. This
> patch is must for xenon controller once vmmc power supply enabled,
> since the HW will ignore any reserved value for sd bus voltage select
> field and ignore the pwr_en in this case.

That's why I would like that this patch was tagged as a fix.

Adrian, Ulf, do you think it could be applied on the v4.13-rc or at
least applied with the following tags ?

Fixes: 3a3748dba881(" mmc: sdhci-xenon: Add Marvell Xenon SDHC core
functionality")
Cc: <stable@vger.kernel.org>

Thanks,

Gregory

> But recently we met another issue after resume, it is similar as warm
> reset. When resume back, SD card(UHS) is re-initialized and it is
> recognized as HS again. It needs power-cycle before initialization to
> solve the resume issue. But vmmc is claimed as AON, it won't be shut
> down in standby, so vmmc and this patch won't solve resume issue. I
> have no better idea to solve both warm reset and resume issue, I added
> a dedicated pwrseq for a3700 sd card, it will do power cycle during
> pre and post pwrseq, but keep power when power off the card.
> Do you have any other better suggestion?
>>
>> Thanks,
>>
>> Gregory
>>
>>
>>>> ---
>>>> Updated according to Jisheng Zhang's comment.
>>>>   drivers/mmc/host/sdhci-xenon.c | 19 +++++++++++++++++++
>>>>   1 file changed, 19 insertions(+)
>>>>
>>>> diff --git a/drivers/mmc/host/sdhci-xenon.c b/drivers/mmc/host/sdhci-xenon.c
>>>> index edd4d915..a4be2fd 100644
>>>> --- a/drivers/mmc/host/sdhci-xenon.c
>>>> +++ b/drivers/mmc/host/sdhci-xenon.c
>>>> @@ -210,8 +210,27 @@ static void xenon_set_uhs_signaling(struct sdhci_host *host,
>>>>   	sdhci_writew(host, ctrl_2, SDHCI_HOST_CONTROL2);
>>>>   }
>>>>   +static void xenon_set_power(struct sdhci_host *host, unsigned
>>>> char mode,
>>>> +		unsigned short vdd)
>>>> +{
>>>> +	struct mmc_host *mmc = host->mmc;
>>>> +	u8 pwr = host->pwr;
>>>> +
>>>> +	sdhci_set_power_noreg(host, mode, vdd);
>>>> +
>>>> +	if (host->pwr == pwr)
>>>> +		return;
>>>> +
>>>> +	if (host->pwr == 0)
>>>> +		vdd = 0;
>>>> +
>>>> +	if (!IS_ERR(mmc->supply.vmmc))
>>>> +		mmc_regulator_set_ocr(mmc, mmc->supply.vmmc, vdd);
>>>> +}
>>>> +
>>>>   static const struct sdhci_ops sdhci_xenon_ops = {
>>>>   	.set_clock		= sdhci_set_clock,
>>>> +	.set_power		= xenon_set_power,
>>>>   	.set_bus_width		= sdhci_set_bus_width,
>>>>   	.reset			= xenon_reset,
>>>>   	.set_uhs_signaling	= xenon_set_uhs_signaling,
>>>>
>
Adrian Hunter Aug. 29, 2017, 10:25 a.m. UTC | #7
On 29/08/17 13:18, Gregory CLEMENT wrote:
> Hi Zhoujie,
>  
>  On lun., août 28 2017, Zhoujie Wu <zjwu@marvell.com> wrote:
> 
>> Hi Gregory,
>>
>> On 08/28/2017 08:54 AM, Gregory CLEMENT wrote:
>>> Hi,
>>>     On lun., août 28 2017, Adrian Hunter <adrian.hunter@intel.com>
>>> wrote:
>>>
>>>> On 21/08/17 21:02, Zhoujie Wu wrote:
>>>>> Xenon sdh controller requests proper SD bus voltage select
>>>>> bits programmed even with vmmc power supply. Any reserved
>>>>> value(100b-000b) programmed in this field will lead to controller
>>>>> ignore SD bus power bit and keep its value at zero.
>>>>> Add set_power callback to handle this.
>>>>>
>>>>> Signed-off-by: Zhoujie Wu <zjwu@marvell.com>
>>>> Acked-by: Adrian Hunter <adrian.hunter@intel.com>
>>> I tested this patch on the Armada 3720 DB board. And thanks to this patch
>>> and by adding a vmmc regulator in the device tree I did not have anymore
>>> the issue UHS card not detected on warm reset.
>>>
>>> Tested-by: Gregory CLEMENT <gregory.clement@free-electrons.com>
>>>
>>> Actually for me this should be a fix. Indeed if I try to use a vmmc
>>> regulator without this patch then the SD card does not work at all I
>>> only have the following messages:
>>>
>>> "mmc1: Timeout waiting for hardware cmd interrupt."
>> This patch with sd vmmc power supply(must be claimed as AON, or card
>> detection can't work)enabled can solve the issue for warm reset. This
>> patch is must for xenon controller once vmmc power supply enabled,
>> since the HW will ignore any reserved value for sd bus voltage select
>> field and ignore the pwr_en in this case.
> 
> That's why I would like that this patch was tagged as a fix.
> 
> Adrian, Ulf, do you think it could be applied on the v4.13-rc or at
> least applied with the following tags ?
> 
> Fixes: 3a3748dba881(" mmc: sdhci-xenon: Add Marvell Xenon SDHC core
> functionality")
> Cc: <stable@vger.kernel.org>

I have no objections.

> 
> Thanks,
> 
> Gregory
> 
>> But recently we met another issue after resume, it is similar as warm
>> reset. When resume back, SD card(UHS) is re-initialized and it is
>> recognized as HS again. It needs power-cycle before initialization to
>> solve the resume issue. But vmmc is claimed as AON, it won't be shut
>> down in standby, so vmmc and this patch won't solve resume issue. I
>> have no better idea to solve both warm reset and resume issue, I added
>> a dedicated pwrseq for a3700 sd card, it will do power cycle during
>> pre and post pwrseq, but keep power when power off the card.
>> Do you have any other better suggestion?
>>>
>>> Thanks,
>>>
>>> Gregory
>>>
>>>
>>>>> ---
>>>>> Updated according to Jisheng Zhang's comment.
>>>>>   drivers/mmc/host/sdhci-xenon.c | 19 +++++++++++++++++++
>>>>>   1 file changed, 19 insertions(+)
>>>>>
>>>>> diff --git a/drivers/mmc/host/sdhci-xenon.c b/drivers/mmc/host/sdhci-xenon.c
>>>>> index edd4d915..a4be2fd 100644
>>>>> --- a/drivers/mmc/host/sdhci-xenon.c
>>>>> +++ b/drivers/mmc/host/sdhci-xenon.c
>>>>> @@ -210,8 +210,27 @@ static void xenon_set_uhs_signaling(struct sdhci_host *host,
>>>>>   	sdhci_writew(host, ctrl_2, SDHCI_HOST_CONTROL2);
>>>>>   }
>>>>>   +static void xenon_set_power(struct sdhci_host *host, unsigned
>>>>> char mode,
>>>>> +		unsigned short vdd)
>>>>> +{
>>>>> +	struct mmc_host *mmc = host->mmc;
>>>>> +	u8 pwr = host->pwr;
>>>>> +
>>>>> +	sdhci_set_power_noreg(host, mode, vdd);
>>>>> +
>>>>> +	if (host->pwr == pwr)
>>>>> +		return;
>>>>> +
>>>>> +	if (host->pwr == 0)
>>>>> +		vdd = 0;
>>>>> +
>>>>> +	if (!IS_ERR(mmc->supply.vmmc))
>>>>> +		mmc_regulator_set_ocr(mmc, mmc->supply.vmmc, vdd);
>>>>> +}
>>>>> +
>>>>>   static const struct sdhci_ops sdhci_xenon_ops = {
>>>>>   	.set_clock		= sdhci_set_clock,
>>>>> +	.set_power		= xenon_set_power,
>>>>>   	.set_bus_width		= sdhci_set_bus_width,
>>>>>   	.reset			= xenon_reset,
>>>>>   	.set_uhs_signaling	= xenon_set_uhs_signaling,
>>>>>
>>
> 

--
To unsubscribe from this list: send the line "unsubscribe linux-mmc" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Ulf Hansson Aug. 30, 2017, 1:13 p.m. UTC | #8
On 29 August 2017 at 12:18, Gregory CLEMENT
<gregory.clement@free-electrons.com> wrote:
> Hi Zhoujie,
>
>  On lun., août 28 2017, Zhoujie Wu <zjwu@marvell.com> wrote:
>
>> Hi Gregory,
>>
>> On 08/28/2017 08:54 AM, Gregory CLEMENT wrote:
>>> Hi,
>>>     On lun., août 28 2017, Adrian Hunter <adrian.hunter@intel.com>
>>> wrote:
>>>
>>>> On 21/08/17 21:02, Zhoujie Wu wrote:
>>>>> Xenon sdh controller requests proper SD bus voltage select
>>>>> bits programmed even with vmmc power supply. Any reserved
>>>>> value(100b-000b) programmed in this field will lead to controller
>>>>> ignore SD bus power bit and keep its value at zero.
>>>>> Add set_power callback to handle this.
>>>>>
>>>>> Signed-off-by: Zhoujie Wu <zjwu@marvell.com>
>>>> Acked-by: Adrian Hunter <adrian.hunter@intel.com>
>>> I tested this patch on the Armada 3720 DB board. And thanks to this patch
>>> and by adding a vmmc regulator in the device tree I did not have anymore
>>> the issue UHS card not detected on warm reset.
>>>
>>> Tested-by: Gregory CLEMENT <gregory.clement@free-electrons.com>
>>>
>>> Actually for me this should be a fix. Indeed if I try to use a vmmc
>>> regulator without this patch then the SD card does not work at all I
>>> only have the following messages:
>>>
>>> "mmc1: Timeout waiting for hardware cmd interrupt."
>> This patch with sd vmmc power supply(must be claimed as AON, or card
>> detection can't work)enabled can solve the issue for warm reset. This
>> patch is must for xenon controller once vmmc power supply enabled,
>> since the HW will ignore any reserved value for sd bus voltage select
>> field and ignore the pwr_en in this case.
>
> That's why I would like that this patch was tagged as a fix.
>
> Adrian, Ulf, do you think it could be applied on the v4.13-rc or at
> least applied with the following tags ?
>
> Fixes: 3a3748dba881(" mmc: sdhci-xenon: Add Marvell Xenon SDHC core
> functionality")
> Cc: <stable@vger.kernel.org>
>
> Thanks,
>
> Gregory

Thanks, applied for fixes and by adding the above tags!

[...]

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

Patch

diff --git a/drivers/mmc/host/sdhci-xenon.c b/drivers/mmc/host/sdhci-xenon.c
index edd4d915..a4be2fd 100644
--- a/drivers/mmc/host/sdhci-xenon.c
+++ b/drivers/mmc/host/sdhci-xenon.c
@@ -210,8 +210,27 @@  static void xenon_set_uhs_signaling(struct sdhci_host *host,
 	sdhci_writew(host, ctrl_2, SDHCI_HOST_CONTROL2);
 }
 
+static void xenon_set_power(struct sdhci_host *host, unsigned char mode,
+		unsigned short vdd)
+{
+	struct mmc_host *mmc = host->mmc;
+	u8 pwr = host->pwr;
+
+	sdhci_set_power_noreg(host, mode, vdd);
+
+	if (host->pwr == pwr)
+		return;
+
+	if (host->pwr == 0)
+		vdd = 0;
+
+	if (!IS_ERR(mmc->supply.vmmc))
+		mmc_regulator_set_ocr(mmc, mmc->supply.vmmc, vdd);
+}
+
 static const struct sdhci_ops sdhci_xenon_ops = {
 	.set_clock		= sdhci_set_clock,
+	.set_power		= xenon_set_power,
 	.set_bus_width		= sdhci_set_bus_width,
 	.reset			= xenon_reset,
 	.set_uhs_signaling	= xenon_set_uhs_signaling,