Skip to content

Commit

Permalink
Merge tag 'mmc-v6.12-rc3' of git://git.kernel.org/pub/scm/linux/kerne…
Browse files Browse the repository at this point in the history
…l/git/ulfh/mmc

Pull mmc fixes from Ulf Hansson:

 - sdhci-pci-gli: A couple of fixes for low power mode on GL9767

* tag 'mmc-v6.12-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/ulfh/mmc:
  mmc: sdhci-pci-gli: GL9767: Fix low power mode in the SD Express process
  mmc: sdhci-pci-gli: GL9767: Fix low power mode on the set clock function
  • Loading branch information
torvalds committed Nov 4, 2024
2 parents a033940 + c4dedaa commit 557329b
Showing 1 changed file with 24 additions and 14 deletions.
38 changes: 24 additions & 14 deletions drivers/mmc/host/sdhci-pci-gli.c
Original file line number Diff line number Diff line change
Expand Up @@ -892,28 +892,40 @@ static void gl9767_disable_ssc_pll(struct pci_dev *pdev)
gl9767_vhs_read(pdev);
}

static void gl9767_set_low_power_negotiation(struct pci_dev *pdev, bool enable)
{
u32 value;

gl9767_vhs_write(pdev);

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

gl9767_vhs_read(pdev);
}

static void sdhci_gl9767_set_clock(struct sdhci_host *host, unsigned int clock)
{
struct sdhci_pci_slot *slot = sdhci_priv(host);
struct mmc_ios *ios = &host->mmc->ios;
struct pci_dev *pdev;
u32 value;
u16 clk;

pdev = slot->chip->pdev;
host->mmc->actual_clock = 0;

gl9767_vhs_write(pdev);

pci_read_config_dword(pdev, PCIE_GLI_9767_CFG, &value);
value |= PCIE_GLI_9767_CFG_LOW_PWR_OFF;
pci_write_config_dword(pdev, PCIE_GLI_9767_CFG, value);

gl9767_set_low_power_negotiation(pdev, false);
gl9767_disable_ssc_pll(pdev);
sdhci_writew(host, 0, SDHCI_CLOCK_CONTROL);

if (clock == 0)
if (clock == 0) {
gl9767_set_low_power_negotiation(pdev, true);
return;
}

clk = sdhci_calc_clk(host, clock, &host->mmc->actual_clock);
if (clock == 200000000 && ios->timing == MMC_TIMING_UHS_SDR104) {
Expand All @@ -922,12 +934,7 @@ static void sdhci_gl9767_set_clock(struct sdhci_host *host, unsigned int clock)
}

sdhci_enable_clk(host, clk);

pci_read_config_dword(pdev, PCIE_GLI_9767_CFG, &value);
value &= ~PCIE_GLI_9767_CFG_LOW_PWR_OFF;
pci_write_config_dword(pdev, PCIE_GLI_9767_CFG, value);

gl9767_vhs_read(pdev);
gl9767_set_low_power_negotiation(pdev, true);
}

static void gli_set_9767(struct sdhci_host *host)
Expand Down Expand Up @@ -1061,6 +1068,9 @@ static int gl9767_init_sd_express(struct mmc_host *mmc, struct mmc_ios *ios)
sdhci_writew(host, value, SDHCI_CLOCK_CONTROL);
}

pci_read_config_dword(pdev, PCIE_GLI_9767_CFG, &value);
value &= ~PCIE_GLI_9767_CFG_LOW_PWR_OFF;
pci_write_config_dword(pdev, PCIE_GLI_9767_CFG, value);
gl9767_vhs_read(pdev);

return 0;
Expand Down

0 comments on commit 557329b

Please sign in to comment.