From: Greg Kroah-Hartman Date: Tue, 10 May 2022 10:21:34 +0000 (+0200) Subject: 5.17-stable patches X-Git-Tag: v4.9.313~29 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=bb2b7ac5d78ab5e16d22541d8e6c6b0827bfd19e;p=thirdparty%2Fkernel%2Fstable-queue.git 5.17-stable patches added patches: mmc-rtsx-add-74-clocks-in-power-on-flow.patch --- diff --git a/queue-5.17/mmc-rtsx-add-74-clocks-in-power-on-flow.patch b/queue-5.17/mmc-rtsx-add-74-clocks-in-power-on-flow.patch new file mode 100644 index 00000000000..cc24c44bdb2 --- /dev/null +++ b/queue-5.17/mmc-rtsx-add-74-clocks-in-power-on-flow.patch @@ -0,0 +1,122 @@ +From 1f311c94aabdb419c28e3147bcc8ab89269f1a7e Mon Sep 17 00:00:00 2001 +From: Ricky WU +Date: Wed, 2 Mar 2022 09:43:01 +0000 +Subject: mmc: rtsx: add 74 Clocks in power on flow + +From: Ricky WU + +commit 1f311c94aabdb419c28e3147bcc8ab89269f1a7e upstream. + +SD spec definition: +"Host provides at least 74 Clocks before issuing first command" +After 1ms for the voltage stable then start issuing the Clock signals + +if POWER STATE is +MMC_POWER_OFF to MMC_POWER_UP to issue Clock signal to card +MMC_POWER_UP to MMC_POWER_ON to stop issuing signal to card + +Signed-off-by: Ricky Wu +Link: https://lore.kernel.org/r/1badf10aba764191a1a752edcbf90389@realtek.com +Signed-off-by: Ulf Hansson +Cc: Christian Löhle +Signed-off-by: Greg Kroah-Hartman +--- + drivers/mmc/host/rtsx_pci_sdmmc.c | 29 +++++++++++++++++++---------- + 1 file changed, 19 insertions(+), 10 deletions(-) + +--- a/drivers/mmc/host/rtsx_pci_sdmmc.c ++++ b/drivers/mmc/host/rtsx_pci_sdmmc.c +@@ -38,10 +38,7 @@ struct realtek_pci_sdmmc { + bool double_clk; + bool eject; + bool initial_mode; +- int power_state; +-#define SDMMC_POWER_ON 1 +-#define SDMMC_POWER_OFF 0 +- ++ int prev_power_state; + int sg_count; + s32 cookie; + int cookie_sg_count; +@@ -905,7 +902,7 @@ static int sd_set_bus_width(struct realt + return err; + } + +-static int sd_power_on(struct realtek_pci_sdmmc *host) ++static int sd_power_on(struct realtek_pci_sdmmc *host, unsigned char power_mode) + { + struct rtsx_pcr *pcr = host->pcr; + struct mmc_host *mmc = host->mmc; +@@ -913,9 +910,14 @@ static int sd_power_on(struct realtek_pc + u32 val; + u8 test_mode; + +- if (host->power_state == SDMMC_POWER_ON) ++ if (host->prev_power_state == MMC_POWER_ON) + return 0; + ++ if (host->prev_power_state == MMC_POWER_UP) { ++ rtsx_pci_write_register(pcr, SD_BUS_STAT, SD_CLK_TOGGLE_EN, 0); ++ goto finish; ++ } ++ + msleep(100); + + rtsx_pci_init_cmd(pcr); +@@ -936,10 +938,15 @@ static int sd_power_on(struct realtek_pc + if (err < 0) + return err; + ++ mdelay(1); ++ + err = rtsx_pci_write_register(pcr, CARD_OE, SD_OUTPUT_EN, SD_OUTPUT_EN); + if (err < 0) + return err; + ++ /* send at least 74 clocks */ ++ rtsx_pci_write_register(pcr, SD_BUS_STAT, SD_CLK_TOGGLE_EN, SD_CLK_TOGGLE_EN); ++ + if (PCI_PID(pcr) == PID_5261) { + /* + * If test mode is set switch to SD Express mandatorily, +@@ -964,7 +971,8 @@ static int sd_power_on(struct realtek_pc + } + } + +- host->power_state = SDMMC_POWER_ON; ++finish: ++ host->prev_power_state = power_mode; + return 0; + } + +@@ -973,7 +981,7 @@ static int sd_power_off(struct realtek_p + struct rtsx_pcr *pcr = host->pcr; + int err; + +- host->power_state = SDMMC_POWER_OFF; ++ host->prev_power_state = MMC_POWER_OFF; + + rtsx_pci_init_cmd(pcr); + +@@ -999,7 +1007,7 @@ static int sd_set_power_mode(struct real + if (power_mode == MMC_POWER_OFF) + err = sd_power_off(host); + else +- err = sd_power_on(host); ++ err = sd_power_on(host, power_mode); + + return err; + } +@@ -1482,10 +1490,11 @@ static int rtsx_pci_sdmmc_drv_probe(stru + + host = mmc_priv(mmc); + host->pcr = pcr; ++ mmc->ios.power_delay_ms = 5; + host->mmc = mmc; + host->pdev = pdev; + host->cookie = -1; +- host->power_state = SDMMC_POWER_OFF; ++ host->prev_power_state = MMC_POWER_OFF; + INIT_WORK(&host->work, sd_request); + platform_set_drvdata(pdev, host); + pcr->slots[RTSX_SD_CARD].p_dev = pdev; diff --git a/queue-5.17/series b/queue-5.17/series index 1b8cecc4611..a676c8adbf3 100644 --- a/queue-5.17/series +++ b/queue-5.17/series @@ -119,3 +119,4 @@ kvm-x86-mmu-avoid-null-pointer-dereference-on-page-f.patch kvm-lapic-enable-timer-posted-interrupt-only-when-mw.patch selftest-vm-verify-mmap-addr-in-mremap_test.patch selftest-vm-verify-remap-destination-address-in-mrem.patch +mmc-rtsx-add-74-clocks-in-power-on-flow.patch