Skip to contentSkip to conversation

mmc: sdhci-msm: Override DLL_CONFIG only if the valid value is supplied

PATCH In review Veerabhadrarao Badiganti 3 participants 11 messages Jul 8, 2020 – Jul 27, 2020

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

PATCH 1/1 mmc: sdhci-msm: Override DLL_CONFIG only if the valid value is supplied

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")
---
 drivers/mmc/host/sdhci-msm.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/mmc/host/sdhci-msm.c +3 -2
index efd2bae1430c..93d67a3a899f 100644
@@ -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 +
Signature · 1 line
Qualcomm India Private Limited, on behalf of Qualcomm Innovation Center, Inc., is a member of Code Aurora Forum, a Linux Foundation Collaborative Project
#1 lore raw

PATCH 1/1 mmc: sdhci-msm: Set IO pins in low power state during suspend

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

---
 drivers/mmc/host/sdhci-msm.c | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)
drivers/mmc/host/sdhci-msm.c +17 -0
index 392d41d57a6e..efd2bae1430c 100644
@@ -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;
Signature · 1 line
Qualcomm India Private Limited, on behalf of Qualcomm Innovation Center, Inc., is a member of Code Aurora Forum, a Linux Foundation Collaborative Project
#2 lore raw

Re: [PATCH V1] mmc: sdhci-msm: Set IO pins in low power state during suspend

Quoted 5 lines · Veerabhadrarao Badiganti

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

Applied for next, thanks!

Kind regards
Uffe

Quoted 49 lines
---
 drivers/mmc/host/sdhci-msm.c | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)
drivers/mmc/host/sdhci-msm.c +17 -1
index 392d41d57a6e..efd2bae1430c 100644
@@ -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

#3 lore raw

Re: [PATCH V1] mmc: sdhci-msm: Set IO pins in low power state during suspend

In reply to Veerabhadrarao Badiganti

Hi,

Quoted 41 lines · Veerabhadrarao Badiganti

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

---
 drivers/mmc/host/sdhci-msm.c | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)
drivers/mmc/host/sdhci-msm.c +14 -0
index 392d41d57a6e..efd2bae1430c 100644
@@ -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))

drivers/mmc/host/sdhci-msm.c static void sdhci_msm_handle_pwr_irq(struct sdhci_host *host, int irq) · line 1618

Quoted 9 lines
drivers/mmc/host/sdhci-msm.c +3 -0
@@ -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.

#4 lore raw

Re: [PATCH V1] mmc: sdhci-msm: Set IO pins in low power state during suspend

Hi Mathias,

Quoted 69 lines · Matthias Kaehlcke

Hi,

Quoted 41 lines · Veerabhadrarao Badiganti

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

---
  drivers/mmc/host/sdhci-msm.c | 17 +++++++++++++++++
  1 file changed, 17 insertions(+)
drivers/mmc/host/sdhci-msm.c +14 -0
index 392d41d57a6e..efd2bae1430c 100644
@@ -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))

drivers/mmc/host/sdhci-msm.c static void sdhci_msm_handle_pwr_irq(struct sdhci_host *host, int irq) · line 1618

Quoted 9 lines
drivers/mmc/host/sdhci-msm.c +3 -0
@@ -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)
Quoted 2 lines

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

#5 lore raw

Re: [PATCH V1] mmc: sdhci-msm: Set IO pins in low power state during suspend

Hi,

Quoted 70 lines · Veerabhadrarao Badiganti

Hi Mathias,

Quoted 67 lines · Matthias Kaehlcke

Hi,

Quoted 39 lines · Veerabhadrarao Badiganti

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

---
  drivers/mmc/host/sdhci-msm.c | 17 +++++++++++++++++
  1 file changed, 17 insertions(+)
drivers/mmc/host/sdhci-msm.c +14 -0
index 392d41d57a6e..efd2bae1430c 100644
@@ -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))

drivers/mmc/host/sdhci-msm.c static void sdhci_msm_handle_pwr_irq(struct sdhci_host *host, int irq) · line 1618

Quoted 9 lines
drivers/mmc/host/sdhci-msm.c +3 -0
@@ -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)
Quoted 5 lines
Quoted 2 lines

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 :)

Quoted 3 lines

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.

#6 lore raw

Re: [PATCH V1] mmc: sdhci-msm: Set IO pins in low power state during suspend

Quoted 73 lines · Matthias Kaehlcke

Hi,

Quoted 70 lines · Veerabhadrarao Badiganti

Hi Mathias,

Quoted 67 lines · Matthias Kaehlcke

Hi,

Quoted 39 lines · Veerabhadrarao Badiganti

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

---
   drivers/mmc/host/sdhci-msm.c | 17 +++++++++++++++++
   1 file changed, 17 insertions(+)
drivers/mmc/host/sdhci-msm.c +14 -0
index 392d41d57a6e..efd2bae1430c 100644
@@ -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))

drivers/mmc/host/sdhci-msm.c static void sdhci_msm_handle_pwr_irq(struct sdhci_host *host, int irq) · line 1618

Quoted 9 lines
drivers/mmc/host/sdhci-msm.c +3 -0
@@ -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)
Quoted 8 lines
Quoted 5 lines
Quoted 2 lines

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.

Quoted 7 lines
Quoted 3 lines

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.

#7 lore raw

Re: [PATCH V1] mmc: sdhci-msm: Set IO pins in low power state during suspend

Quoted 83 lines · Veerabhadrarao Badiganti
Quoted 81 lines · Matthias Kaehlcke

Hi,

Quoted 78 lines · Veerabhadrarao Badiganti

Hi Mathias,

Quoted 70 lines · Matthias Kaehlcke

Hi,

Quoted 49 lines · Veerabhadrarao Badiganti

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

---
   drivers/mmc/host/sdhci-msm.c | 17 +++++++++++++++++

   1 file changed, 17 insertions(+)
drivers/mmc/host/sdhci-msm.c +14 -0
index 392d41d57a6e..efd2bae1430c 100644
@@ -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))

drivers/mmc/host/sdhci-msm.c +3 -0
@@ -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;
Quoted 2 lines

           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)
Quoted 2 lines

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.

Quoted 9 lines
Quoted 3 lines

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:

arch/arm64/boot/dts/qcom/sc7180.dtsi +0 -0
index e2230f47a17d..9266d514e163 100644
@@ -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.

Quoted 7 lines
Quoted 7 lines
Quoted 3 lines

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

#8 lore raw

Re: [PATCH V1] mmc: sdhci-msm: Set IO pins in low power state during suspend

Quoted 137 lines · Veerabhadrarao Badiganti
Quoted 94 lines · Veerabhadrarao Badiganti
Quoted 86 lines · Matthias Kaehlcke

Hi,

Quoted 75 lines · Veerabhadrarao Badiganti

Hi Mathias,

Quoted 72 lines · Matthias Kaehlcke

Hi,

Quoted 51 lines · Veerabhadrarao Badiganti

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

---
   drivers/mmc/host/sdhci-msm.c | 17 +++++++++++++++++
   1 file changed, 17 insertions(+)
drivers/mmc/host/sdhci-msm.c +14 -0
index 392d41d57a6e..efd2bae1430c 100644
@@ -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))
drivers/mmc/host/sdhci-msm.c +3 -0
@@ -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
Quoted 1 line
               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)
Quoted 7 lines
Quoted 3 lines

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.

Quoted 6 lines

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 :)

Quoted 6 lines

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:

arch/arm64/boot/dts/qcom/sc7180.dtsi +1 -1
index e2230f47a17d..9266d514e163 100644
@@ -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.

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

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

Quoted 9 lines
Quoted 4 lines
Quoted 4 lines

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

#9 lore raw

Re: [PATCH V1] mmc: sdhci-msm: Set IO pins in low power state during suspend

Quoted 140 lines · Ulf Hansson
Quoted 138 lines · Veerabhadrarao Badiganti
Quoted 93 lines · Veerabhadrarao Badiganti
Quoted 86 lines · Matthias Kaehlcke

Hi,

Quoted 75 lines · Veerabhadrarao Badiganti

Hi Mathias,

Quoted 72 lines · Matthias Kaehlcke

Hi,

Quoted 51 lines · Veerabhadrarao Badiganti

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

---
    drivers/mmc/host/sdhci-msm.c | 17 +++++++++++++++++
    1 file changed, 17 insertions(+)
drivers/mmc/host/sdhci-msm.c +14 -0
index 392d41d57a6e..efd2bae1430c 100644
@@ -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))
drivers/mmc/host/sdhci-msm.c +3 -0
@@ -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
Quoted 1 line
                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)
Quoted 7 lines
Quoted 3 lines

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.

Quoted 6 lines

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 :)

Quoted 6 lines

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:

arch/arm64/boot/dts/qcom/sc7180.dtsi +1 -1
index e2230f47a17d..9266d514e163 100644
@@ -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.

Quoted 7 lines
Quoted 7 lines
Quoted 4 lines

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.

Quoted 7 lines
Quoted 5 lines
Quoted 1 line
Quoted 1 line

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

Quoted 1 line

Uffe

#10 lore raw
In reply to Veerabhadrarao Badiganti
Quoted 8 lines · Veerabhadrarao Badiganti

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")

Applied for fixes, thanks!

Kind regards
Uffe

Quoted 23 lines
---
 drivers/mmc/host/sdhci-msm.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/mmc/host/sdhci-msm.c +3 -3
index efd2bae1430c..93d67a3a899f 100644
@@ -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