Linux-mmc Archive on lore.kernel.org
 help / color / Atom feed
* [PATCH V1] mmc: sdhci-msm: Override DLL_CONFIG only if the valid value is supplied
@ 2020-07-08 13:11 Veerabhadrarao Badiganti
  2020-07-08 13:11 ` [PATCH V1] mmc: sdhci-msm: Set IO pins in low power state during suspend Veerabhadrarao Badiganti
  2020-07-08 13:33 ` [PATCH V1] mmc: sdhci-msm: Override DLL_CONFIG only if the valid value is supplied Ulf Hansson
  0 siblings, 2 replies; 11+ messages in thread
From: Veerabhadrarao Badiganti @ 2020-07-08 13:11 UTC (permalink / raw)
  To: adrian.hunter, ulf.hansson, bjorn.andersson
  Cc: linux-mmc, linux-kernel, linux-arm-msm, Veerabhadrarao Badiganti,
	Andy Gross, Bao D. Nguyen, Sarthak Garg

During DLL initialization, the DLL_CONFIG register value would be
updated with the value supplied from the device-tree.

Override this register only if a valid value is supplied.

Fixes: 03591160ca19 ("mmc: sdhci-msm: Read and use DLL Config property from device tree file")
Signed-off-by: Veerabhadrarao Badiganti <vbadigan@codeaurora.org>
---
 drivers/mmc/host/sdhci-msm.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/mmc/host/sdhci-msm.c b/drivers/mmc/host/sdhci-msm.c
index efd2bae1430c..93d67a3a899f 100644
--- a/drivers/mmc/host/sdhci-msm.c
+++ b/drivers/mmc/host/sdhci-msm.c
@@ -626,8 +626,9 @@ static int msm_init_cm_dll(struct sdhci_host *host)
 	config &= ~CORE_CLK_PWRSAVE;
 	writel_relaxed(config, host->ioaddr + msm_offset->core_vendor_spec);
 
-	config = msm_host->dll_config;
-	writel_relaxed(config, host->ioaddr + msm_offset->core_dll_config);
+	if (msm_host->dll_config)
+		writel_relaxed(msm_host->dll_config,
+				host->ioaddr + msm_offset->core_dll_config);
 
 	if (msm_host->use_14lpp_dll_reset) {
 		config = readl_relaxed(host->ioaddr +
-- 
Qualcomm India Private Limited, on behalf of Qualcomm Innovation Center, Inc., is a member of Code Aurora Forum, a Linux Foundation Collaborative Project


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

* [PATCH V1] mmc: sdhci-msm: Set IO pins in low power state during suspend
  2020-07-08 13:11 [PATCH V1] mmc: sdhci-msm: Override DLL_CONFIG only if the valid value is supplied Veerabhadrarao Badiganti
@ 2020-07-08 13:11 ` Veerabhadrarao Badiganti
  2020-07-08 13:33   ` Ulf Hansson
  2020-07-10  0:52   ` Matthias Kaehlcke
  2020-07-08 13:33 ` [PATCH V1] mmc: sdhci-msm: Override DLL_CONFIG only if the valid value is supplied Ulf Hansson
  1 sibling, 2 replies; 11+ messages in thread
From: Veerabhadrarao Badiganti @ 2020-07-08 13:11 UTC (permalink / raw)
  To: adrian.hunter, ulf.hansson, bjorn.andersson
  Cc: linux-mmc, linux-kernel, linux-arm-msm, Veerabhadrarao Badiganti,
	Andy Gross

Configure SDHC IO pins with low power configuration when the driver
is in suspend state.

Signed-off-by: Veerabhadrarao Badiganti <vbadigan@codeaurora.org>
---
 drivers/mmc/host/sdhci-msm.c | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/drivers/mmc/host/sdhci-msm.c b/drivers/mmc/host/sdhci-msm.c
index 392d41d57a6e..efd2bae1430c 100644
--- a/drivers/mmc/host/sdhci-msm.c
+++ b/drivers/mmc/host/sdhci-msm.c
@@ -15,6 +15,7 @@
 #include <linux/iopoll.h>
 #include <linux/regulator/consumer.h>
 #include <linux/interconnect.h>
+#include <linux/pinctrl/consumer.h>
 
 #include "sdhci-pltfm.h"
 #include "cqhci.h"
@@ -1352,6 +1353,19 @@ static void sdhci_msm_set_uhs_signaling(struct sdhci_host *host,
 		sdhci_msm_hs400(host, &mmc->ios);
 }
 
+static int sdhci_msm_set_pincfg(struct sdhci_msm_host *msm_host, bool level)
+{
+	struct platform_device *pdev = msm_host->pdev;
+	int ret;
+
+	if (level)
+		ret = pinctrl_pm_select_default_state(&pdev->dev);
+	else
+		ret = pinctrl_pm_select_sleep_state(&pdev->dev);
+
+	return ret;
+}
+
 static int sdhci_msm_set_vmmc(struct mmc_host *mmc)
 {
 	if (IS_ERR(mmc->supply.vmmc))
@@ -1596,6 +1610,9 @@ static void sdhci_msm_handle_pwr_irq(struct sdhci_host *host, int irq)
 			ret = sdhci_msm_set_vqmmc(msm_host, mmc,
 					pwr_state & REQ_BUS_ON);
 		if (!ret)
+			ret = sdhci_msm_set_pincfg(msm_host,
+					pwr_state & REQ_BUS_ON);
+		if (!ret)
 			irq_ack |= CORE_PWRCTL_BUS_SUCCESS;
 		else
 			irq_ack |= CORE_PWRCTL_BUS_FAIL;
-- 
Qualcomm India Private Limited, on behalf of Qualcomm Innovation Center, Inc., is a member of Code Aurora Forum, a Linux Foundation Collaborative Project


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

* Re: [PATCH V1] mmc: sdhci-msm: Set IO pins in low power state during suspend
  2020-07-08 13:11 ` [PATCH V1] mmc: sdhci-msm: Set IO pins in low power state during suspend Veerabhadrarao Badiganti
@ 2020-07-08 13:33   ` Ulf Hansson
  2020-07-10  0:52   ` Matthias Kaehlcke
  1 sibling, 0 replies; 11+ messages in thread
From: Ulf Hansson @ 2020-07-08 13:33 UTC (permalink / raw)
  To: Veerabhadrarao Badiganti
  Cc: Adrian Hunter, Bjorn Andersson, linux-mmc,
	Linux Kernel Mailing List, linux-arm-msm, Andy Gross

On Wed, 8 Jul 2020 at 15:12, Veerabhadrarao Badiganti
<vbadigan@codeaurora.org> wrote:
>
> Configure SDHC IO pins with low power configuration when the driver
> is in suspend state.
>
> Signed-off-by: Veerabhadrarao Badiganti <vbadigan@codeaurora.org>

Applied for next, thanks!

Kind regards
Uffe


> ---
>  drivers/mmc/host/sdhci-msm.c | 17 +++++++++++++++++
>  1 file changed, 17 insertions(+)
>
> diff --git a/drivers/mmc/host/sdhci-msm.c b/drivers/mmc/host/sdhci-msm.c
> index 392d41d57a6e..efd2bae1430c 100644
> --- a/drivers/mmc/host/sdhci-msm.c
> +++ b/drivers/mmc/host/sdhci-msm.c
> @@ -15,6 +15,7 @@
>  #include <linux/iopoll.h>
>  #include <linux/regulator/consumer.h>
>  #include <linux/interconnect.h>
> +#include <linux/pinctrl/consumer.h>
>
>  #include "sdhci-pltfm.h"
>  #include "cqhci.h"
> @@ -1352,6 +1353,19 @@ static void sdhci_msm_set_uhs_signaling(struct sdhci_host *host,
>                 sdhci_msm_hs400(host, &mmc->ios);
>  }
>
> +static int sdhci_msm_set_pincfg(struct sdhci_msm_host *msm_host, bool level)
> +{
> +       struct platform_device *pdev = msm_host->pdev;
> +       int ret;
> +
> +       if (level)
> +               ret = pinctrl_pm_select_default_state(&pdev->dev);
> +       else
> +               ret = pinctrl_pm_select_sleep_state(&pdev->dev);
> +
> +       return ret;
> +}
> +
>  static int sdhci_msm_set_vmmc(struct mmc_host *mmc)
>  {
>         if (IS_ERR(mmc->supply.vmmc))
> @@ -1596,6 +1610,9 @@ static void sdhci_msm_handle_pwr_irq(struct sdhci_host *host, int irq)
>                         ret = sdhci_msm_set_vqmmc(msm_host, mmc,
>                                         pwr_state & REQ_BUS_ON);
>                 if (!ret)
> +                       ret = sdhci_msm_set_pincfg(msm_host,
> +                                       pwr_state & REQ_BUS_ON);
> +               if (!ret)
>                         irq_ack |= CORE_PWRCTL_BUS_SUCCESS;
>                 else
>                         irq_ack |= CORE_PWRCTL_BUS_FAIL;
> --
> Qualcomm India Private Limited, on behalf of Qualcomm Innovation Center, Inc., is a member of Code Aurora Forum, a Linux Foundation Collaborative Project
>

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

* Re: [PATCH V1] mmc: sdhci-msm: Override DLL_CONFIG only if the valid value is supplied
  2020-07-08 13:11 [PATCH V1] mmc: sdhci-msm: Override DLL_CONFIG only if the valid value is supplied Veerabhadrarao Badiganti
  2020-07-08 13:11 ` [PATCH V1] mmc: sdhci-msm: Set IO pins in low power state during suspend Veerabhadrarao Badiganti
@ 2020-07-08 13:33 ` Ulf Hansson
  1 sibling, 0 replies; 11+ messages in thread
From: Ulf Hansson @ 2020-07-08 13:33 UTC (permalink / raw)
  To: Veerabhadrarao Badiganti
  Cc: Adrian Hunter, Bjorn Andersson, linux-mmc,
	Linux Kernel Mailing List, linux-arm-msm, Andy Gross,
	Bao D. Nguyen, Sarthak Garg

On Wed, 8 Jul 2020 at 15:12, Veerabhadrarao Badiganti
<vbadigan@codeaurora.org> wrote:
>
> During DLL initialization, the DLL_CONFIG register value would be
> updated with the value supplied from the device-tree.
>
> Override this register only if a valid value is supplied.
>
> Fixes: 03591160ca19 ("mmc: sdhci-msm: Read and use DLL Config property from device tree file")
> Signed-off-by: Veerabhadrarao Badiganti <vbadigan@codeaurora.org>

Applied for fixes, thanks!

Kind regards
Uffe


> ---
>  drivers/mmc/host/sdhci-msm.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/mmc/host/sdhci-msm.c b/drivers/mmc/host/sdhci-msm.c
> index efd2bae1430c..93d67a3a899f 100644
> --- a/drivers/mmc/host/sdhci-msm.c
> +++ b/drivers/mmc/host/sdhci-msm.c
> @@ -626,8 +626,9 @@ static int msm_init_cm_dll(struct sdhci_host *host)
>         config &= ~CORE_CLK_PWRSAVE;
>         writel_relaxed(config, host->ioaddr + msm_offset->core_vendor_spec);
>
> -       config = msm_host->dll_config;
> -       writel_relaxed(config, host->ioaddr + msm_offset->core_dll_config);
> +       if (msm_host->dll_config)
> +               writel_relaxed(msm_host->dll_config,
> +                               host->ioaddr + msm_offset->core_dll_config);
>
>         if (msm_host->use_14lpp_dll_reset) {
>                 config = readl_relaxed(host->ioaddr +
> --
> Qualcomm India Private Limited, on behalf of Qualcomm Innovation Center, Inc., is a member of Code Aurora Forum, a Linux Foundation Collaborative Project
>

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

* Re: [PATCH V1] mmc: sdhci-msm: Set IO pins in low power state during suspend
  2020-07-08 13:11 ` [PATCH V1] mmc: sdhci-msm: Set IO pins in low power state during suspend Veerabhadrarao Badiganti
  2020-07-08 13:33   ` Ulf Hansson
@ 2020-07-10  0:52   ` Matthias Kaehlcke
  2020-07-10 10:58     ` Veerabhadrarao Badiganti
  1 sibling, 1 reply; 11+ messages in thread
From: Matthias Kaehlcke @ 2020-07-10  0:52 UTC (permalink / raw)
  To: Veerabhadrarao Badiganti
  Cc: adrian.hunter, ulf.hansson, bjorn.andersson, linux-mmc,
	linux-kernel, linux-arm-msm, Andy Gross

Hi,

On Wed, Jul 08, 2020 at 06:41:20PM +0530, Veerabhadrarao Badiganti wrote:
> Configure SDHC IO pins with low power configuration when the driver
> is in suspend state.
> 
> Signed-off-by: Veerabhadrarao Badiganti <vbadigan@codeaurora.org>
> ---
>  drivers/mmc/host/sdhci-msm.c | 17 +++++++++++++++++
>  1 file changed, 17 insertions(+)
> 
> diff --git a/drivers/mmc/host/sdhci-msm.c b/drivers/mmc/host/sdhci-msm.c
> index 392d41d57a6e..efd2bae1430c 100644
> --- a/drivers/mmc/host/sdhci-msm.c
> +++ b/drivers/mmc/host/sdhci-msm.c
> @@ -15,6 +15,7 @@
>  #include <linux/iopoll.h>
>  #include <linux/regulator/consumer.h>
>  #include <linux/interconnect.h>
> +#include <linux/pinctrl/consumer.h>
>  
>  #include "sdhci-pltfm.h"
>  #include "cqhci.h"
> @@ -1352,6 +1353,19 @@ static void sdhci_msm_set_uhs_signaling(struct sdhci_host *host,
>  		sdhci_msm_hs400(host, &mmc->ios);
>  }
>  
> +static int sdhci_msm_set_pincfg(struct sdhci_msm_host *msm_host, bool level)
> +{
> +	struct platform_device *pdev = msm_host->pdev;
> +	int ret;
> +
> +	if (level)
> +		ret = pinctrl_pm_select_default_state(&pdev->dev);
> +	else
> +		ret = pinctrl_pm_select_sleep_state(&pdev->dev);
> +
> +	return ret;
> +}
> +
>  static int sdhci_msm_set_vmmc(struct mmc_host *mmc)
>  {
>  	if (IS_ERR(mmc->supply.vmmc))
> @@ -1596,6 +1610,9 @@ static void sdhci_msm_handle_pwr_irq(struct sdhci_host *host, int irq)
>  			ret = sdhci_msm_set_vqmmc(msm_host, mmc,
>  					pwr_state & REQ_BUS_ON);
>  		if (!ret)
> +			ret = sdhci_msm_set_pincfg(msm_host,
> +					pwr_state & REQ_BUS_ON);
> +		if (!ret)
>  			irq_ack |= CORE_PWRCTL_BUS_SUCCESS;
>  		else
>  			irq_ack |= CORE_PWRCTL_BUS_FAIL;

I happened to have a debug patch in my tree which logs when regulators
are enabled/disabled, with this patch I see the SD card regulator
toggling constantly after returning from the first system suspend.

I added more logs:

[ 1156.085819] DBG: sdhci_msm_set_pincfg: level = 0 (ret: 0)
[ 1156.248936] DBG: sdhci_msm_set_pincfg: level = 1 (ret: 0)
[ 1156.301989] DBG: sdhci_msm_set_pincfg: level = 0 (ret: 0)
[ 1156.462383] DBG: sdhci_msm_set_pincfg: level = 1 (ret: 0)
[ 1156.525988] DBG: sdhci_msm_set_pincfg: level = 0 (ret: 0)
[ 1156.670372] DBG: sdhci_msm_set_pincfg: level = 1 (ret: 0)
[ 1156.717935] DBG: sdhci_msm_set_pincfg: level = 0 (ret: 0)
[ 1156.878122] DBG: sdhci_msm_set_pincfg: level = 1 (ret: 0)
[ 1156.928134] DBG: sdhci_msm_set_pincfg: level = 0 (ret: 0)

This is on an SC7180 platform. It doesn't run an upstream kernel though,
but v5.4 with plenty of upstream patches.

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

* Re: [PATCH V1] mmc: sdhci-msm: Set IO pins in low power state during suspend
  2020-07-10  0:52   ` Matthias Kaehlcke
@ 2020-07-10 10:58     ` Veerabhadrarao Badiganti
  2020-07-11  0:19       ` Matthias Kaehlcke
  0 siblings, 1 reply; 11+ messages in thread
From: Veerabhadrarao Badiganti @ 2020-07-10 10:58 UTC (permalink / raw)
  To: Matthias Kaehlcke
  Cc: adrian.hunter, ulf.hansson, bjorn.andersson, linux-mmc,
	linux-kernel, linux-arm-msm, Andy Gross

Hi Mathias,

On 7/10/2020 6:22 AM, Matthias Kaehlcke wrote:
> Hi,
>
> On Wed, Jul 08, 2020 at 06:41:20PM +0530, Veerabhadrarao Badiganti wrote:
>> Configure SDHC IO pins with low power configuration when the driver
>> is in suspend state.
>>
>> Signed-off-by: Veerabhadrarao Badiganti <vbadigan@codeaurora.org>
>> ---
>>   drivers/mmc/host/sdhci-msm.c | 17 +++++++++++++++++
>>   1 file changed, 17 insertions(+)
>>
>> diff --git a/drivers/mmc/host/sdhci-msm.c b/drivers/mmc/host/sdhci-msm.c
>> index 392d41d57a6e..efd2bae1430c 100644
>> --- a/drivers/mmc/host/sdhci-msm.c
>> +++ b/drivers/mmc/host/sdhci-msm.c
>> @@ -15,6 +15,7 @@
>>   #include <linux/iopoll.h>
>>   #include <linux/regulator/consumer.h>
>>   #include <linux/interconnect.h>
>> +#include <linux/pinctrl/consumer.h>
>>   
>>   #include "sdhci-pltfm.h"
>>   #include "cqhci.h"
>> @@ -1352,6 +1353,19 @@ static void sdhci_msm_set_uhs_signaling(struct sdhci_host *host,
>>   		sdhci_msm_hs400(host, &mmc->ios);
>>   }
>>   
>> +static int sdhci_msm_set_pincfg(struct sdhci_msm_host *msm_host, bool level)
>> +{
>> +	struct platform_device *pdev = msm_host->pdev;
>> +	int ret;
>> +
>> +	if (level)
>> +		ret = pinctrl_pm_select_default_state(&pdev->dev);
>> +	else
>> +		ret = pinctrl_pm_select_sleep_state(&pdev->dev);
>> +
>> +	return ret;
>> +}
>> +
>>   static int sdhci_msm_set_vmmc(struct mmc_host *mmc)
>>   {
>>   	if (IS_ERR(mmc->supply.vmmc))
>> @@ -1596,6 +1610,9 @@ static void sdhci_msm_handle_pwr_irq(struct sdhci_host *host, int irq)
>>   			ret = sdhci_msm_set_vqmmc(msm_host, mmc,
>>   					pwr_state & REQ_BUS_ON);
>>   		if (!ret)
>> +			ret = sdhci_msm_set_pincfg(msm_host,
>> +					pwr_state & REQ_BUS_ON);
>> +		if (!ret)
>>   			irq_ack |= CORE_PWRCTL_BUS_SUCCESS;
>>   		else
>>   			irq_ack |= CORE_PWRCTL_BUS_FAIL;
> I happened to have a debug patch in my tree which logs when regulators
> are enabled/disabled, with this patch I see the SD card regulator
> toggling constantly after returning from the first system suspend.
>
> I added more logs:
>
> [ 1156.085819] DBG: sdhci_msm_set_pincfg: level = 0 (ret: 0)
> [ 1156.248936] DBG: sdhci_msm_set_pincfg: level = 1 (ret: 0)
> [ 1156.301989] DBG: sdhci_msm_set_pincfg: level = 0 (ret: 0)
> [ 1156.462383] DBG: sdhci_msm_set_pincfg: level = 1 (ret: 0)
> [ 1156.525988] DBG: sdhci_msm_set_pincfg: level = 0 (ret: 0)
> [ 1156.670372] DBG: sdhci_msm_set_pincfg: level = 1 (ret: 0)
> [ 1156.717935] DBG: sdhci_msm_set_pincfg: level = 0 (ret: 0)
> [ 1156.878122] DBG: sdhci_msm_set_pincfg: level = 1 (ret: 0)
> [ 1156.928134] DBG: sdhci_msm_set_pincfg: level = 0 (ret: 0)
>
> This is on an SC7180 platform. It doesn't run an upstream kernel though,
> but v5.4 with plenty of upstream patches.
I have verified this on couple of sc7180 targets (on Chrome platform 
with Chrome kernel).
But didn't see any issue. Its working as expected.

Let me know if you are observing this issue constantly on multiple 
boards, I will share you
a debug patch to check it further.

Thanks
Veera



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

* Re: [PATCH V1] mmc: sdhci-msm: Set IO pins in low power state during suspend
  2020-07-10 10:58     ` Veerabhadrarao Badiganti
@ 2020-07-11  0:19       ` Matthias Kaehlcke
  2020-07-13 15:56         ` Veerabhadrarao Badiganti
  0 siblings, 1 reply; 11+ messages in thread
From: Matthias Kaehlcke @ 2020-07-11  0:19 UTC (permalink / raw)
  To: Veerabhadrarao Badiganti
  Cc: adrian.hunter, ulf.hansson, bjorn.andersson, linux-mmc,
	linux-kernel, linux-arm-msm, Andy Gross

Hi,

On Fri, Jul 10, 2020 at 04:28:36PM +0530, Veerabhadrarao Badiganti wrote:
> Hi Mathias,
> 
> On 7/10/2020 6:22 AM, Matthias Kaehlcke wrote:
> > Hi,
> > 
> > On Wed, Jul 08, 2020 at 06:41:20PM +0530, Veerabhadrarao Badiganti wrote:
> > > Configure SDHC IO pins with low power configuration when the driver
> > > is in suspend state.
> > > 
> > > Signed-off-by: Veerabhadrarao Badiganti <vbadigan@codeaurora.org>
> > > ---
> > >   drivers/mmc/host/sdhci-msm.c | 17 +++++++++++++++++
> > >   1 file changed, 17 insertions(+)
> > > 
> > > diff --git a/drivers/mmc/host/sdhci-msm.c b/drivers/mmc/host/sdhci-msm.c
> > > index 392d41d57a6e..efd2bae1430c 100644
> > > --- a/drivers/mmc/host/sdhci-msm.c
> > > +++ b/drivers/mmc/host/sdhci-msm.c
> > > @@ -15,6 +15,7 @@
> > >   #include <linux/iopoll.h>
> > >   #include <linux/regulator/consumer.h>
> > >   #include <linux/interconnect.h>
> > > +#include <linux/pinctrl/consumer.h>
> > >   #include "sdhci-pltfm.h"
> > >   #include "cqhci.h"
> > > @@ -1352,6 +1353,19 @@ static void sdhci_msm_set_uhs_signaling(struct sdhci_host *host,
> > >   		sdhci_msm_hs400(host, &mmc->ios);
> > >   }
> > > +static int sdhci_msm_set_pincfg(struct sdhci_msm_host *msm_host, bool level)
> > > +{
> > > +	struct platform_device *pdev = msm_host->pdev;
> > > +	int ret;
> > > +
> > > +	if (level)
> > > +		ret = pinctrl_pm_select_default_state(&pdev->dev);
> > > +	else
> > > +		ret = pinctrl_pm_select_sleep_state(&pdev->dev);
> > > +
> > > +	return ret;
> > > +}
> > > +
> > >   static int sdhci_msm_set_vmmc(struct mmc_host *mmc)
> > >   {
> > >   	if (IS_ERR(mmc->supply.vmmc))
> > > @@ -1596,6 +1610,9 @@ static void sdhci_msm_handle_pwr_irq(struct sdhci_host *host, int irq)
> > >   			ret = sdhci_msm_set_vqmmc(msm_host, mmc,
> > >   					pwr_state & REQ_BUS_ON);
> > >   		if (!ret)
> > > +			ret = sdhci_msm_set_pincfg(msm_host,
> > > +					pwr_state & REQ_BUS_ON);
> > > +		if (!ret)
> > >   			irq_ack |= CORE_PWRCTL_BUS_SUCCESS;
> > >   		else
> > >   			irq_ack |= CORE_PWRCTL_BUS_FAIL;
> > I happened to have a debug patch in my tree which logs when regulators
> > are enabled/disabled, with this patch I see the SD card regulator
> > toggling constantly after returning from the first system suspend.
> > 
> > I added more logs:
> > 
> > [ 1156.085819] DBG: sdhci_msm_set_pincfg: level = 0 (ret: 0)
> > [ 1156.248936] DBG: sdhci_msm_set_pincfg: level = 1 (ret: 0)
> > [ 1156.301989] DBG: sdhci_msm_set_pincfg: level = 0 (ret: 0)
> > [ 1156.462383] DBG: sdhci_msm_set_pincfg: level = 1 (ret: 0)
> > [ 1156.525988] DBG: sdhci_msm_set_pincfg: level = 0 (ret: 0)
> > [ 1156.670372] DBG: sdhci_msm_set_pincfg: level = 1 (ret: 0)
> > [ 1156.717935] DBG: sdhci_msm_set_pincfg: level = 0 (ret: 0)
> > [ 1156.878122] DBG: sdhci_msm_set_pincfg: level = 1 (ret: 0)
> > [ 1156.928134] DBG: sdhci_msm_set_pincfg: level = 0 (ret: 0)
> > 
> > This is on an SC7180 platform. It doesn't run an upstream kernel though,
> > but v5.4 with plenty of upstream patches.
> I have verified this on couple of sc7180 targets (on Chrome platform with
> Chrome kernel).
> But didn't see any issue. Its working as expected.

Did you test system suspend too? At least in the Chrome OS kernel tree system
suspend is not supported yet in the main branch, you'd need a pile of 30+
extra patches to get it to work. This is expected to change soon though :)

> Let me know if you are observing this issue constantly on multiple boards, I
> will share you
> a debug patch to check it further.

I currently have only one board with the SD card slot populated, I might
get another one next week.

The toggling occurs only when no SD card is inserted.

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

* Re: [PATCH V1] mmc: sdhci-msm: Set IO pins in low power state during suspend
  2020-07-11  0:19       ` Matthias Kaehlcke
@ 2020-07-13 15:56         ` Veerabhadrarao Badiganti
  2020-07-14 14:12           ` Veerabhadrarao Badiganti
  0 siblings, 1 reply; 11+ messages in thread
From: Veerabhadrarao Badiganti @ 2020-07-13 15:56 UTC (permalink / raw)
  To: Matthias Kaehlcke
  Cc: adrian.hunter, ulf.hansson, bjorn.andersson, linux-mmc,
	linux-kernel, linux-arm-msm, Andy Gross


On 7/11/2020 5:49 AM, Matthias Kaehlcke wrote:
> Hi,
>
> On Fri, Jul 10, 2020 at 04:28:36PM +0530, Veerabhadrarao Badiganti wrote:
>> Hi Mathias,
>>
>> On 7/10/2020 6:22 AM, Matthias Kaehlcke wrote:
>>> Hi,
>>>
>>> On Wed, Jul 08, 2020 at 06:41:20PM +0530, Veerabhadrarao Badiganti wrote:
>>>> Configure SDHC IO pins with low power configuration when the driver
>>>> is in suspend state.
>>>>
>>>> Signed-off-by: Veerabhadrarao Badiganti <vbadigan@codeaurora.org>
>>>> ---
>>>>    drivers/mmc/host/sdhci-msm.c | 17 +++++++++++++++++
>>>>    1 file changed, 17 insertions(+)
>>>>
>>>> diff --git a/drivers/mmc/host/sdhci-msm.c b/drivers/mmc/host/sdhci-msm.c
>>>> index 392d41d57a6e..efd2bae1430c 100644
>>>> --- a/drivers/mmc/host/sdhci-msm.c
>>>> +++ b/drivers/mmc/host/sdhci-msm.c
>>>> @@ -15,6 +15,7 @@
>>>>    #include <linux/iopoll.h>
>>>>    #include <linux/regulator/consumer.h>
>>>>    #include <linux/interconnect.h>
>>>> +#include <linux/pinctrl/consumer.h>
>>>>    #include "sdhci-pltfm.h"
>>>>    #include "cqhci.h"
>>>> @@ -1352,6 +1353,19 @@ static void sdhci_msm_set_uhs_signaling(struct sdhci_host *host,
>>>>    		sdhci_msm_hs400(host, &mmc->ios);
>>>>    }
>>>> +static int sdhci_msm_set_pincfg(struct sdhci_msm_host *msm_host, bool level)
>>>> +{
>>>> +	struct platform_device *pdev = msm_host->pdev;
>>>> +	int ret;
>>>> +
>>>> +	if (level)
>>>> +		ret = pinctrl_pm_select_default_state(&pdev->dev);
>>>> +	else
>>>> +		ret = pinctrl_pm_select_sleep_state(&pdev->dev);
>>>> +
>>>> +	return ret;
>>>> +}
>>>> +
>>>>    static int sdhci_msm_set_vmmc(struct mmc_host *mmc)
>>>>    {
>>>>    	if (IS_ERR(mmc->supply.vmmc))
>>>> @@ -1596,6 +1610,9 @@ static void sdhci_msm_handle_pwr_irq(struct sdhci_host *host, int irq)
>>>>    			ret = sdhci_msm_set_vqmmc(msm_host, mmc,
>>>>    					pwr_state & REQ_BUS_ON);
>>>>    		if (!ret)
>>>> +			ret = sdhci_msm_set_pincfg(msm_host,
>>>> +					pwr_state & REQ_BUS_ON);
>>>> +		if (!ret)
>>>>    			irq_ack |= CORE_PWRCTL_BUS_SUCCESS;
>>>>    		else
>>>>    			irq_ack |= CORE_PWRCTL_BUS_FAIL;
>>> I happened to have a debug patch in my tree which logs when regulators
>>> are enabled/disabled, with this patch I see the SD card regulator
>>> toggling constantly after returning from the first system suspend.
>>>
>>> I added more logs:
>>>
>>> [ 1156.085819] DBG: sdhci_msm_set_pincfg: level = 0 (ret: 0)
>>> [ 1156.248936] DBG: sdhci_msm_set_pincfg: level = 1 (ret: 0)
>>> [ 1156.301989] DBG: sdhci_msm_set_pincfg: level = 0 (ret: 0)
>>> [ 1156.462383] DBG: sdhci_msm_set_pincfg: level = 1 (ret: 0)
>>> [ 1156.525988] DBG: sdhci_msm_set_pincfg: level = 0 (ret: 0)
>>> [ 1156.670372] DBG: sdhci_msm_set_pincfg: level = 1 (ret: 0)
>>> [ 1156.717935] DBG: sdhci_msm_set_pincfg: level = 0 (ret: 0)
>>> [ 1156.878122] DBG: sdhci_msm_set_pincfg: level = 1 (ret: 0)
>>> [ 1156.928134] DBG: sdhci_msm_set_pincfg: level = 0 (ret: 0)
>>>
>>> This is on an SC7180 platform. It doesn't run an upstream kernel though,
>>> but v5.4 with plenty of upstream patches.
>> I have verified this on couple of sc7180 targets (on Chrome platform with
>> Chrome kernel).
>> But didn't see any issue. Its working as expected.
> Did you test system suspend too? At least in the Chrome OS kernel tree system
> suspend is not supported yet in the main branch, you'd need a pile of 30+
> extra patches to get it to work. This is expected to change soon though :)
Yes. I have verified with system  suspend-resume scenario.
Sorry forgot to mention this point explicitly in last response.

I believe all the needed patches were present on qcom internal tree.
Suspend-resume is working fine on sc7180 qcom chrome tree.

>> Let me know if you are observing this issue constantly on multiple boards, I
>> will share you
>> a debug patch to check it further.
> I currently have only one board with the SD card slot populated, I might
> get another one next week.
>
> The toggling occurs only when no SD card is inserted.

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

* Re: [PATCH V1] mmc: sdhci-msm: Set IO pins in low power state during suspend
  2020-07-13 15:56         ` Veerabhadrarao Badiganti
@ 2020-07-14 14:12           ` Veerabhadrarao Badiganti
  2020-07-24  9:36             ` Ulf Hansson
  0 siblings, 1 reply; 11+ messages in thread
From: Veerabhadrarao Badiganti @ 2020-07-14 14:12 UTC (permalink / raw)
  To: Matthias Kaehlcke
  Cc: adrian.hunter, ulf.hansson, bjorn.andersson, linux-mmc,
	linux-kernel, linux-arm-msm, Andy Gross


On 7/13/2020 9:26 PM, Veerabhadrarao Badiganti wrote:
>
> On 7/11/2020 5:49 AM, Matthias Kaehlcke wrote:
>> Hi,
>>
>> On Fri, Jul 10, 2020 at 04:28:36PM +0530, Veerabhadrarao Badiganti 
>> wrote:
>>> Hi Mathias,
>>>
>>> On 7/10/2020 6:22 AM, Matthias Kaehlcke wrote:
>>>> Hi,
>>>>
>>>> On Wed, Jul 08, 2020 at 06:41:20PM +0530, Veerabhadrarao Badiganti 
>>>> wrote:
>>>>> Configure SDHC IO pins with low power configuration when the driver
>>>>> is in suspend state.
>>>>>
>>>>> Signed-off-by: Veerabhadrarao Badiganti <vbadigan@codeaurora.org>
>>>>> ---
>>>>>    drivers/mmc/host/sdhci-msm.c | 17 +++++++++++++++++
>>>>>    1 file changed, 17 insertions(+)
>>>>>
>>>>> diff --git a/drivers/mmc/host/sdhci-msm.c 
>>>>> b/drivers/mmc/host/sdhci-msm.c
>>>>> index 392d41d57a6e..efd2bae1430c 100644
>>>>> --- a/drivers/mmc/host/sdhci-msm.c
>>>>> +++ b/drivers/mmc/host/sdhci-msm.c
>>>>> @@ -15,6 +15,7 @@
>>>>>    #include <linux/iopoll.h>
>>>>>    #include <linux/regulator/consumer.h>
>>>>>    #include <linux/interconnect.h>
>>>>> +#include <linux/pinctrl/consumer.h>
>>>>>    #include "sdhci-pltfm.h"
>>>>>    #include "cqhci.h"
>>>>> @@ -1352,6 +1353,19 @@ static void 
>>>>> sdhci_msm_set_uhs_signaling(struct sdhci_host *host,
>>>>>            sdhci_msm_hs400(host, &mmc->ios);
>>>>>    }
>>>>> +static int sdhci_msm_set_pincfg(struct sdhci_msm_host *msm_host, 
>>>>> bool level)
>>>>> +{
>>>>> +    struct platform_device *pdev = msm_host->pdev;
>>>>> +    int ret;
>>>>> +
>>>>> +    if (level)
>>>>> +        ret = pinctrl_pm_select_default_state(&pdev->dev);
>>>>> +    else
>>>>> +        ret = pinctrl_pm_select_sleep_state(&pdev->dev);
>>>>> +
>>>>> +    return ret;
>>>>> +}
>>>>> +
>>>>>    static int sdhci_msm_set_vmmc(struct mmc_host *mmc)
>>>>>    {
>>>>>        if (IS_ERR(mmc->supply.vmmc))
>>>>> @@ -1596,6 +1610,9 @@ static void sdhci_msm_handle_pwr_irq(struct 
>>>>> sdhci_host *host, int irq)
>>>>>                ret = sdhci_msm_set_vqmmc(msm_host, mmc,
>>>>>                        pwr_state & REQ_BUS_ON);
>>>>>            if (!ret)
>>>>> +            ret = sdhci_msm_set_pincfg(msm_host,
>>>>> +                    pwr_state & REQ_BUS_ON);
>>>>> +        if (!ret)
>>>>>                irq_ack |= CORE_PWRCTL_BUS_SUCCESS;
>>>>>            else
>>>>>                irq_ack |= CORE_PWRCTL_BUS_FAIL;
>>>> I happened to have a debug patch in my tree which logs when regulators
>>>> are enabled/disabled, with this patch I see the SD card regulator
>>>> toggling constantly after returning from the first system suspend.
>>>>
>>>> I added more logs:
>>>>
>>>> [ 1156.085819] DBG: sdhci_msm_set_pincfg: level = 0 (ret: 0)
>>>> [ 1156.248936] DBG: sdhci_msm_set_pincfg: level = 1 (ret: 0)
>>>> [ 1156.301989] DBG: sdhci_msm_set_pincfg: level = 0 (ret: 0)
>>>> [ 1156.462383] DBG: sdhci_msm_set_pincfg: level = 1 (ret: 0)
>>>> [ 1156.525988] DBG: sdhci_msm_set_pincfg: level = 0 (ret: 0)
>>>> [ 1156.670372] DBG: sdhci_msm_set_pincfg: level = 1 (ret: 0)
>>>> [ 1156.717935] DBG: sdhci_msm_set_pincfg: level = 0 (ret: 0)
>>>> [ 1156.878122] DBG: sdhci_msm_set_pincfg: level = 1 (ret: 0)
>>>> [ 1156.928134] DBG: sdhci_msm_set_pincfg: level = 0 (ret: 0)
>>>>
>>>> This is on an SC7180 platform. It doesn't run an upstream kernel 
>>>> though,
>>>> but v5.4 with plenty of upstream patches.
>>> I have verified this on couple of sc7180 targets (on Chrome platform 
>>> with
>>> Chrome kernel).
>>> But didn't see any issue. Its working as expected.
>> Did you test system suspend too? At least in the Chrome OS kernel 
>> tree system
>> suspend is not supported yet in the main branch, you'd need a pile of 
>> 30+
>> extra patches to get it to work. This is expected to change soon 
>> though :)
> Yes. I have verified with system  suspend-resume scenario.
> Sorry forgot to mention this point explicitly in last response.
>
> I believe all the needed patches were present on qcom internal tree.
> Suspend-resume is working fine on sc7180 qcom chrome tree.
>
Thanks Matthias. I cloud reproduce the issue on device without SDcard.

Without SDcard inserted, cd-gpio (SD card detect GPIO) is getting read 
as active HIGH
(as if card is inserted) during system-resume, resulting SDcard probe/scan.

After that its triggering interrupt again when pinctrl config is applied 
during SDcard
power-up sequence (as part of probe/scan) which is again triggering 
sdcard scan.

I will have to change SDcard cd-gpio sleep config to fix this issue like 
below:

diff --git a/arch/arm64/boot/dts/qcom/sc7180.dtsi 
b/arch/arm64/boot/dts/qcom/sc7180.dtsi
index e2230f47a17d..9266d514e163 100644
--- a/arch/arm64/boot/dts/qcom/sc7180.dtsi
+++ b/arch/arm64/boot/dts/qcom/sc7180.dtsi
@@ -2447,7 +2447,7 @@

                                 pinconf-sd-cd {
                                         pins = "gpio69";
-                                       bias-disable;
+                                       bias-pull-up;
                                         drive-strength = <2>;

I will check more on why its getting read as active HIGH during resume.


>>> Let me know if you are observing this issue constantly on multiple 
>>> boards, I
>>> will share you
>>> a debug patch to check it further.
>> I currently have only one board with the SD card slot populated, I might
>> get another one next week.
>>
>> The toggling occurs only when no SD card is inserted.

Thanks

Veera


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

* Re: [PATCH V1] mmc: sdhci-msm: Set IO pins in low power state during suspend
  2020-07-14 14:12           ` Veerabhadrarao Badiganti
@ 2020-07-24  9:36             ` Ulf Hansson
  2020-07-27 10:21               ` Veerabhadrarao Badiganti
  0 siblings, 1 reply; 11+ messages in thread
From: Ulf Hansson @ 2020-07-24  9:36 UTC (permalink / raw)
  To: Veerabhadrarao Badiganti, Matthias Kaehlcke
  Cc: Adrian Hunter, Bjorn Andersson, linux-mmc,
	Linux Kernel Mailing List, linux-arm-msm, Andy Gross

On Tue, 14 Jul 2020 at 16:12, Veerabhadrarao Badiganti
<vbadigan@codeaurora.org> wrote:
>
>
> On 7/13/2020 9:26 PM, Veerabhadrarao Badiganti wrote:
> >
> > On 7/11/2020 5:49 AM, Matthias Kaehlcke wrote:
> >> Hi,
> >>
> >> On Fri, Jul 10, 2020 at 04:28:36PM +0530, Veerabhadrarao Badiganti
> >> wrote:
> >>> Hi Mathias,
> >>>
> >>> On 7/10/2020 6:22 AM, Matthias Kaehlcke wrote:
> >>>> Hi,
> >>>>
> >>>> On Wed, Jul 08, 2020 at 06:41:20PM +0530, Veerabhadrarao Badiganti
> >>>> wrote:
> >>>>> Configure SDHC IO pins with low power configuration when the driver
> >>>>> is in suspend state.
> >>>>>
> >>>>> Signed-off-by: Veerabhadrarao Badiganti <vbadigan@codeaurora.org>
> >>>>> ---
> >>>>>    drivers/mmc/host/sdhci-msm.c | 17 +++++++++++++++++
> >>>>>    1 file changed, 17 insertions(+)
> >>>>>
> >>>>> diff --git a/drivers/mmc/host/sdhci-msm.c
> >>>>> b/drivers/mmc/host/sdhci-msm.c
> >>>>> index 392d41d57a6e..efd2bae1430c 100644
> >>>>> --- a/drivers/mmc/host/sdhci-msm.c
> >>>>> +++ b/drivers/mmc/host/sdhci-msm.c
> >>>>> @@ -15,6 +15,7 @@
> >>>>>    #include <linux/iopoll.h>
> >>>>>    #include <linux/regulator/consumer.h>
> >>>>>    #include <linux/interconnect.h>
> >>>>> +#include <linux/pinctrl/consumer.h>
> >>>>>    #include "sdhci-pltfm.h"
> >>>>>    #include "cqhci.h"
> >>>>> @@ -1352,6 +1353,19 @@ static void
> >>>>> sdhci_msm_set_uhs_signaling(struct sdhci_host *host,
> >>>>>            sdhci_msm_hs400(host, &mmc->ios);
> >>>>>    }
> >>>>> +static int sdhci_msm_set_pincfg(struct sdhci_msm_host *msm_host,
> >>>>> bool level)
> >>>>> +{
> >>>>> +    struct platform_device *pdev = msm_host->pdev;
> >>>>> +    int ret;
> >>>>> +
> >>>>> +    if (level)
> >>>>> +        ret = pinctrl_pm_select_default_state(&pdev->dev);
> >>>>> +    else
> >>>>> +        ret = pinctrl_pm_select_sleep_state(&pdev->dev);
> >>>>> +
> >>>>> +    return ret;
> >>>>> +}
> >>>>> +
> >>>>>    static int sdhci_msm_set_vmmc(struct mmc_host *mmc)
> >>>>>    {
> >>>>>        if (IS_ERR(mmc->supply.vmmc))
> >>>>> @@ -1596,6 +1610,9 @@ static void sdhci_msm_handle_pwr_irq(struct
> >>>>> sdhci_host *host, int irq)
> >>>>>                ret = sdhci_msm_set_vqmmc(msm_host, mmc,
> >>>>>                        pwr_state & REQ_BUS_ON);
> >>>>>            if (!ret)
> >>>>> +            ret = sdhci_msm_set_pincfg(msm_host,
> >>>>> +                    pwr_state & REQ_BUS_ON);
> >>>>> +        if (!ret)
> >>>>>                irq_ack |= CORE_PWRCTL_BUS_SUCCESS;
> >>>>>            else
> >>>>>                irq_ack |= CORE_PWRCTL_BUS_FAIL;
> >>>> I happened to have a debug patch in my tree which logs when regulators
> >>>> are enabled/disabled, with this patch I see the SD card regulator
> >>>> toggling constantly after returning from the first system suspend.
> >>>>
> >>>> I added more logs:
> >>>>
> >>>> [ 1156.085819] DBG: sdhci_msm_set_pincfg: level = 0 (ret: 0)
> >>>> [ 1156.248936] DBG: sdhci_msm_set_pincfg: level = 1 (ret: 0)
> >>>> [ 1156.301989] DBG: sdhci_msm_set_pincfg: level = 0 (ret: 0)
> >>>> [ 1156.462383] DBG: sdhci_msm_set_pincfg: level = 1 (ret: 0)
> >>>> [ 1156.525988] DBG: sdhci_msm_set_pincfg: level = 0 (ret: 0)
> >>>> [ 1156.670372] DBG: sdhci_msm_set_pincfg: level = 1 (ret: 0)
> >>>> [ 1156.717935] DBG: sdhci_msm_set_pincfg: level = 0 (ret: 0)
> >>>> [ 1156.878122] DBG: sdhci_msm_set_pincfg: level = 1 (ret: 0)
> >>>> [ 1156.928134] DBG: sdhci_msm_set_pincfg: level = 0 (ret: 0)
> >>>>
> >>>> This is on an SC7180 platform. It doesn't run an upstream kernel
> >>>> though,
> >>>> but v5.4 with plenty of upstream patches.
> >>> I have verified this on couple of sc7180 targets (on Chrome platform
> >>> with
> >>> Chrome kernel).
> >>> But didn't see any issue. Its working as expected.
> >> Did you test system suspend too? At least in the Chrome OS kernel
> >> tree system
> >> suspend is not supported yet in the main branch, you'd need a pile of
> >> 30+
> >> extra patches to get it to work. This is expected to change soon
> >> though :)
> > Yes. I have verified with system  suspend-resume scenario.
> > Sorry forgot to mention this point explicitly in last response.
> >
> > I believe all the needed patches were present on qcom internal tree.
> > Suspend-resume is working fine on sc7180 qcom chrome tree.
> >
> Thanks Matthias. I cloud reproduce the issue on device without SDcard.
>
> Without SDcard inserted, cd-gpio (SD card detect GPIO) is getting read
> as active HIGH
> (as if card is inserted) during system-resume, resulting SDcard probe/scan.
>
> After that its triggering interrupt again when pinctrl config is applied
> during SDcard
> power-up sequence (as part of probe/scan) which is again triggering
> sdcard scan.
>
> I will have to change SDcard cd-gpio sleep config to fix this issue like
> below:
>
> diff --git a/arch/arm64/boot/dts/qcom/sc7180.dtsi
> b/arch/arm64/boot/dts/qcom/sc7180.dtsi
> index e2230f47a17d..9266d514e163 100644
> --- a/arch/arm64/boot/dts/qcom/sc7180.dtsi
> +++ b/arch/arm64/boot/dts/qcom/sc7180.dtsi
> @@ -2447,7 +2447,7 @@
>
>                                  pinconf-sd-cd {
>                                          pins = "gpio69";
> -                                       bias-disable;
> +                                       bias-pull-up;
>                                          drive-strength = <2>;
>
> I will check more on why its getting read as active HIGH during resume.
>
>
> >>> Let me know if you are observing this issue constantly on multiple
> >>> boards, I
> >>> will share you
> >>> a debug patch to check it further.
> >> I currently have only one board with the SD card slot populated, I might
> >> get another one next week.
> >>
> >> The toggling occurs only when no SD card is inserted.
>
> Thanks
>
> Veera
>

Thanks for testing and for looking into this. Perhaps I should drop
the $subject patch then?

Kind regards
Uffe

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

* Re: [PATCH V1] mmc: sdhci-msm: Set IO pins in low power state during suspend
  2020-07-24  9:36             ` Ulf Hansson
@ 2020-07-27 10:21               ` Veerabhadrarao Badiganti
  0 siblings, 0 replies; 11+ messages in thread
From: Veerabhadrarao Badiganti @ 2020-07-27 10:21 UTC (permalink / raw)
  To: Ulf Hansson, Matthias Kaehlcke
  Cc: Adrian Hunter, Bjorn Andersson, linux-mmc,
	Linux Kernel Mailing List, linux-arm-msm, Andy Gross


On 7/24/2020 3:06 PM, Ulf Hansson wrote:
> On Tue, 14 Jul 2020 at 16:12, Veerabhadrarao Badiganti
> <vbadigan@codeaurora.org> wrote:
>>
>> On 7/13/2020 9:26 PM, Veerabhadrarao Badiganti wrote:
>>> On 7/11/2020 5:49 AM, Matthias Kaehlcke wrote:
>>>> Hi,
>>>>
>>>> On Fri, Jul 10, 2020 at 04:28:36PM +0530, Veerabhadrarao Badiganti
>>>> wrote:
>>>>> Hi Mathias,
>>>>>
>>>>> On 7/10/2020 6:22 AM, Matthias Kaehlcke wrote:
>>>>>> Hi,
>>>>>>
>>>>>> On Wed, Jul 08, 2020 at 06:41:20PM +0530, Veerabhadrarao Badiganti
>>>>>> wrote:
>>>>>>> Configure SDHC IO pins with low power configuration when the driver
>>>>>>> is in suspend state.
>>>>>>>
>>>>>>> Signed-off-by: Veerabhadrarao Badiganti <vbadigan@codeaurora.org>
>>>>>>> ---
>>>>>>>     drivers/mmc/host/sdhci-msm.c | 17 +++++++++++++++++
>>>>>>>     1 file changed, 17 insertions(+)
>>>>>>>
>>>>>>> diff --git a/drivers/mmc/host/sdhci-msm.c
>>>>>>> b/drivers/mmc/host/sdhci-msm.c
>>>>>>> index 392d41d57a6e..efd2bae1430c 100644
>>>>>>> --- a/drivers/mmc/host/sdhci-msm.c
>>>>>>> +++ b/drivers/mmc/host/sdhci-msm.c
>>>>>>> @@ -15,6 +15,7 @@
>>>>>>>     #include <linux/iopoll.h>
>>>>>>>     #include <linux/regulator/consumer.h>
>>>>>>>     #include <linux/interconnect.h>
>>>>>>> +#include <linux/pinctrl/consumer.h>
>>>>>>>     #include "sdhci-pltfm.h"
>>>>>>>     #include "cqhci.h"
>>>>>>> @@ -1352,6 +1353,19 @@ static void
>>>>>>> sdhci_msm_set_uhs_signaling(struct sdhci_host *host,
>>>>>>>             sdhci_msm_hs400(host, &mmc->ios);
>>>>>>>     }
>>>>>>> +static int sdhci_msm_set_pincfg(struct sdhci_msm_host *msm_host,
>>>>>>> bool level)
>>>>>>> +{
>>>>>>> +    struct platform_device *pdev = msm_host->pdev;
>>>>>>> +    int ret;
>>>>>>> +
>>>>>>> +    if (level)
>>>>>>> +        ret = pinctrl_pm_select_default_state(&pdev->dev);
>>>>>>> +    else
>>>>>>> +        ret = pinctrl_pm_select_sleep_state(&pdev->dev);
>>>>>>> +
>>>>>>> +    return ret;
>>>>>>> +}
>>>>>>> +
>>>>>>>     static int sdhci_msm_set_vmmc(struct mmc_host *mmc)
>>>>>>>     {
>>>>>>>         if (IS_ERR(mmc->supply.vmmc))
>>>>>>> @@ -1596,6 +1610,9 @@ static void sdhci_msm_handle_pwr_irq(struct
>>>>>>> sdhci_host *host, int irq)
>>>>>>>                 ret = sdhci_msm_set_vqmmc(msm_host, mmc,
>>>>>>>                         pwr_state & REQ_BUS_ON);
>>>>>>>             if (!ret)
>>>>>>> +            ret = sdhci_msm_set_pincfg(msm_host,
>>>>>>> +                    pwr_state & REQ_BUS_ON);
>>>>>>> +        if (!ret)
>>>>>>>                 irq_ack |= CORE_PWRCTL_BUS_SUCCESS;
>>>>>>>             else
>>>>>>>                 irq_ack |= CORE_PWRCTL_BUS_FAIL;
>>>>>> I happened to have a debug patch in my tree which logs when regulators
>>>>>> are enabled/disabled, with this patch I see the SD card regulator
>>>>>> toggling constantly after returning from the first system suspend.
>>>>>>
>>>>>> I added more logs:
>>>>>>
>>>>>> [ 1156.085819] DBG: sdhci_msm_set_pincfg: level = 0 (ret: 0)
>>>>>> [ 1156.248936] DBG: sdhci_msm_set_pincfg: level = 1 (ret: 0)
>>>>>> [ 1156.301989] DBG: sdhci_msm_set_pincfg: level = 0 (ret: 0)
>>>>>> [ 1156.462383] DBG: sdhci_msm_set_pincfg: level = 1 (ret: 0)
>>>>>> [ 1156.525988] DBG: sdhci_msm_set_pincfg: level = 0 (ret: 0)
>>>>>> [ 1156.670372] DBG: sdhci_msm_set_pincfg: level = 1 (ret: 0)
>>>>>> [ 1156.717935] DBG: sdhci_msm_set_pincfg: level = 0 (ret: 0)
>>>>>> [ 1156.878122] DBG: sdhci_msm_set_pincfg: level = 1 (ret: 0)
>>>>>> [ 1156.928134] DBG: sdhci_msm_set_pincfg: level = 0 (ret: 0)
>>>>>>
>>>>>> This is on an SC7180 platform. It doesn't run an upstream kernel
>>>>>> though,
>>>>>> but v5.4 with plenty of upstream patches.
>>>>> I have verified this on couple of sc7180 targets (on Chrome platform
>>>>> with
>>>>> Chrome kernel).
>>>>> But didn't see any issue. Its working as expected.
>>>> Did you test system suspend too? At least in the Chrome OS kernel
>>>> tree system
>>>> suspend is not supported yet in the main branch, you'd need a pile of
>>>> 30+
>>>> extra patches to get it to work. This is expected to change soon
>>>> though :)
>>> Yes. I have verified with system  suspend-resume scenario.
>>> Sorry forgot to mention this point explicitly in last response.
>>>
>>> I believe all the needed patches were present on qcom internal tree.
>>> Suspend-resume is working fine on sc7180 qcom chrome tree.
>>>
>> Thanks Matthias. I cloud reproduce the issue on device without SDcard.
>>
>> Without SDcard inserted, cd-gpio (SD card detect GPIO) is getting read
>> as active HIGH
>> (as if card is inserted) during system-resume, resulting SDcard probe/scan.
>>
>> After that its triggering interrupt again when pinctrl config is applied
>> during SDcard
>> power-up sequence (as part of probe/scan) which is again triggering
>> sdcard scan.
>>
>> I will have to change SDcard cd-gpio sleep config to fix this issue like
>> below:
>>
>> diff --git a/arch/arm64/boot/dts/qcom/sc7180.dtsi
>> b/arch/arm64/boot/dts/qcom/sc7180.dtsi
>> index e2230f47a17d..9266d514e163 100644
>> --- a/arch/arm64/boot/dts/qcom/sc7180.dtsi
>> +++ b/arch/arm64/boot/dts/qcom/sc7180.dtsi
>> @@ -2447,7 +2447,7 @@
>>
>>                                   pinconf-sd-cd {
>>                                           pins = "gpio69";
>> -                                       bias-disable;
>> +                                       bias-pull-up;
>>                                           drive-strength = <2>;
>>
>> I will check more on why its getting read as active HIGH during resume.
>>
>>
>>>>> Let me know if you are observing this issue constantly on multiple
>>>>> boards, I
>>>>> will share you
>>>>> a debug patch to check it further.
>>>> I currently have only one board with the SD card slot populated, I might
>>>> get another one next week.
>>>>
>>>> The toggling occurs only when no SD card is inserted.
>> Thanks
>>
>> Veera
>>
> Thanks for testing and for looking into this. Perhaps I should drop
> the $subject patch then?
Hi Uffe,

No need to drop this. We could root-casue the issue. Its a board 
specific issue.
This particular platform/board doesn't have external pull-up on the 
cd-gpio pin.

So internal pull-up config has to be applied on cd-gpio all the time.
We posted this dt change to enable internal pull 
https://patchwork.kernel.org/patch/11675347/

Thanks
Veera

> Uffe

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

end of thread, back to index

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-08 13:11 [PATCH V1] mmc: sdhci-msm: Override DLL_CONFIG only if the valid value is supplied Veerabhadrarao Badiganti
2020-07-08 13:11 ` [PATCH V1] mmc: sdhci-msm: Set IO pins in low power state during suspend Veerabhadrarao Badiganti
2020-07-08 13:33   ` Ulf Hansson
2020-07-10  0:52   ` Matthias Kaehlcke
2020-07-10 10:58     ` Veerabhadrarao Badiganti
2020-07-11  0:19       ` Matthias Kaehlcke
2020-07-13 15:56         ` Veerabhadrarao Badiganti
2020-07-14 14:12           ` Veerabhadrarao Badiganti
2020-07-24  9:36             ` Ulf Hansson
2020-07-27 10:21               ` Veerabhadrarao Badiganti
2020-07-08 13:33 ` [PATCH V1] mmc: sdhci-msm: Override DLL_CONFIG only if the valid value is supplied Ulf Hansson

Linux-mmc Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-mmc/0 linux-mmc/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-mmc linux-mmc/ https://lore.kernel.org/linux-mmc \
		linux-mmc@vger.kernel.org
	public-inbox-index linux-mmc

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-mmc


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git