From: Georg Gottleuber <g.gottleuber@tuxedocomputers.com>
To: Ulf Hansson <ulf.hansson@linaro.org>
Cc: victor.shih@genesyslogic.com.tw, Lucas.Lai@genesyslogic.com.tw,
Greg.tu@genesyslogic.com.tw, HL.Liu@genesyslogic.com.tw,
adrian.hunter@intel.com, linux-mmc@vger.kernel.org,
linux-kernel@vger.kernel.org,
Ben Chuang <ben.chuang@genesyslogic.com.tw>,
Georg Gottleuber <ggo@tuxedocomputers.com>
Subject: [RFC PATCH 1/1] mmc: sdhci-pci-gli: fix x86/S0ix SoCs suspend for GL9767
Date: Tue, 15 Oct 2024 14:47:34 +0200 [thread overview]
Message-ID: <4a517433-d105-4e2b-86f8-335e7c537d10@tuxedocomputers.com> (raw)
In-Reply-To: <CAPDyKFrT6-nes784c9rCtqdJZ0nCFS3O5X=600OB6trbz2yJ2w@mail.gmail.com>
Adapt commit 1202d617e3d04c ("mmc: sdhci-pci-gli: fix LPM negotiation
so x86/S0ix SoCs can suspend") also for GL9767 card reader.
This patch was written without specs or deeper knowledge of PCI sleep
states. Tests show that S0ix is reached and a lower power consumption
when suspended (6 watts vs 1.2 watts for TUXEDO InfinityBook Pro Gen9
Intel).
The function of the card reader appears to be normal.
Link: https://bugzilla.kernel.org/show_bug.cgi?id=219284
Co-developed-by: Christoffer Sandberg <cs@tuxedo.de>
Signed-off-by: Christoffer Sandberg <cs@tuxedo.de>
Signed-off-by: Georg Gottleuber <ggo@tuxedocomputers.com>
---
drivers/mmc/host/sdhci-pci-gli.c | 65 +++++++++++++++++++++++++++++++-
1 file changed, 64 insertions(+), 1 deletion(-)
diff --git a/drivers/mmc/host/sdhci-pci-gli.c
b/drivers/mmc/host/sdhci-pci-gli.c
index 0f81586a19df..40f43f5cd5c7 100644
--- a/drivers/mmc/host/sdhci-pci-gli.c
+++ b/drivers/mmc/host/sdhci-pci-gli.c
@@ -1205,6 +1205,32 @@ static void
gl9763e_set_low_power_negotiation(struct sdhci_pci_slot *slot,
pci_write_config_dword(pdev, PCIE_GLI_9763E_VHS, value);
}
+static void gl9767_set_low_power_negotiation(struct sdhci_pci_slot *slot,
+ bool enable)
+{
+ struct pci_dev *pdev = slot->chip->pdev;
+ u32 value;
+
+ pci_read_config_dword(pdev, PCIE_GLI_9767_VHS, &value);
+ value &= ~GLI_9767_VHS_REV;
+ value |= FIELD_PREP(GLI_9767_VHS_REV, GLI_9767_VHS_REV_W);
+ pci_write_config_dword(pdev, PCIE_GLI_9767_VHS, value);
+
+ pci_read_config_dword(pdev, PCIE_GLI_9767_CFG, &value);
+
+ if (enable)
+ value &= ~PCIE_GLI_9767_CFG_LOW_PWR_OFF;
+ else
+ value |= PCIE_GLI_9767_CFG_LOW_PWR_OFF;
+
+ pci_write_config_dword(pdev, PCIE_GLI_9767_CFG, value);
+
+ pci_read_config_dword(pdev, PCIE_GLI_9767_VHS, &value);
+ value &= ~GLI_9767_VHS_REV;
+ value |= FIELD_PREP(GLI_9767_VHS_REV, GLI_9767_VHS_REV_R);
+ pci_write_config_dword(pdev, PCIE_GLI_9767_VHS, value);
+}
+
static void sdhci_set_gl9763e_signaling(struct sdhci_host *host,
unsigned int timing)
{
@@ -1470,6 +1496,42 @@ static int gl9763e_suspend(struct sdhci_pci_chip
*chip)
gl9763e_set_low_power_negotiation(slot, false);
return ret;
}
+
+static int gl9767_resume(struct sdhci_pci_chip *chip)
+{
+ struct sdhci_pci_slot *slot = chip->slots[0];
+ int ret;
+
+ ret = sdhci_pci_gli_resume(chip);
+ if (ret)
+ return ret;
+
+ gl9767_set_low_power_negotiation(slot, false);
+
+ return 0;
+}
+
+static int gl9767_suspend(struct sdhci_pci_chip *chip)
+{
+ struct sdhci_pci_slot *slot = chip->slots[0];
+ int ret;
+
+ /*
+ * Certain SoCs can suspend only with the bus in low-
+ * power state, notably x86 SoCs when using S0ix.
+ * Re-enable LPM negotiation to allow entering L1 state
+ * and entering system suspend.
+ */
+ gl9767_set_low_power_negotiation(slot, true);
+
+ ret = sdhci_suspend_host(slot->host);
+ if (ret) {
+ gl9767_set_low_power_negotiation(slot, false);
+ return ret;
+ }
+
+ return 0;
+}
#endif
static int gli_probe_slot_gl9763e(struct sdhci_pci_slot *slot)
@@ -1605,6 +1667,7 @@ const struct sdhci_pci_fixes sdhci_gl9767 = {
.probe_slot = gli_probe_slot_gl9767,
.ops = &sdhci_gl9767_ops,
#ifdef CONFIG_PM_SLEEP
- .resume = sdhci_pci_gli_resume,
+ .resume = gl9767_resume,
+ .suspend = gl9767_suspend,
#endif
};
--
2.34.1
next prev parent reply other threads:[~2024-10-15 12:47 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-09-26 15:31 sdhci_pci module is blocking low power s0ix sleep with GL9767 Georg Gottleuber
2024-10-08 15:05 ` Ulf Hansson
2024-10-15 12:47 ` Georg Gottleuber [this message]
-- strict thread matches above, loose matches on Subject: below --
2024-10-16 2:39 [RFC PATCH 1/1] mmc: sdhci-pci-gli: fix x86/S0ix SoCs suspend for GL9767 Ben Chuang
2024-10-16 13:47 ` Georg Gottleuber
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4a517433-d105-4e2b-86f8-335e7c537d10@tuxedocomputers.com \
--to=g.gottleuber@tuxedocomputers.com \
--cc=Greg.tu@genesyslogic.com.tw \
--cc=HL.Liu@genesyslogic.com.tw \
--cc=Lucas.Lai@genesyslogic.com.tw \
--cc=adrian.hunter@intel.com \
--cc=ben.chuang@genesyslogic.com.tw \
--cc=ggo@tuxedocomputers.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mmc@vger.kernel.org \
--cc=ulf.hansson@linaro.org \
--cc=victor.shih@genesyslogic.com.tw \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox