mmc: sdhci: Disable SD card clock before changing parameters
PATCH 1/1 mmc: sdhci: Disable SD card clock before changing parameters
Per the SD Host Controller Simplified Specification v4.20 §3.2.3, change the SD card clock parameters only after first disabling the external card clock. Doing this fixes a spurious clock pulse on Baytrail and Apollo Lake SD controllers which otherwise breaks voltage switching with a specific Swissbit SD card. This change is limited to Intel host controllers to avoid an issue reported on ARM64 devices.
--- drivers/mmc/host/sdhci-pci-core.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-)
drivers/mmc/host/sdhci-pci-core.c +13 -2
@@ -689,8 +689,19 @@ static int intel_start_signal_voltage_switch(struct mmc_host *mmc,return 0 ; } +static void sdhci_intel_set_clock (struct sdhci_host *host,unsigned int clock) +{ +u16 clk =sdhci_readw (host,SDHCI_CLOCK_CONTROL ); + +/* Stop card clock separately to avoid glitches on clock line */ +if (clk &SDHCI_CLOCK_CARD_EN ) +sdhci_writew (host, clk & ~SDHCI_CLOCK_CARD_EN ,SDHCI_CLOCK_CONTROL ); + +sdhci_set_clock (host, clock); +} +static const struct sdhci_ops sdhci_intel_byt_ops = { - .set_clock = sdhci_set_clock, + .set_clock = sdhci_intel_set_clock, .set_power = sdhci_intel_set_power, .enable_dma = sdhci_pci_enable_dma, .set_bus_width = sdhci_set_bus_width,
@@ -700,7 +711,7 @@ static const struct sdhci_ops sdhci_intel_byt_ops = { };static const struct sdhci_ops sdhci_intel_glk_ops = { - .set_clock = sdhci_set_clock, + .set_clock = sdhci_intel_set_clock, .set_power = sdhci_intel_set_power, .enable_dma = sdhci_pci_enable_dma, .set_bus_width = sdhci_set_bus_width,
Signature · 1 line
2.43.0
Quoted 10 lines · Erick Shepherd
Per the SD Host Controller Simplified Specification v4.20 §3.2.3, change the SD card clock parameters only after first disabling the external card clock. Doing this fixes a spurious clock pulse on Baytrail and Apollo Lake SD controllers which otherwise breaks voltage switching with a specific Swissbit SD card. This change is limited to Intel host controllers to avoid an issue reported on ARM64 devices.
Signed-off-by Kyle Roeschley <[email protected]>Signed-off-by Brad Mouring <[email protected]>Signed-off-by Erick Shepherd <[email protected]>
One formatting error below, otherwise:
Quoted 11 lines
--- drivers/mmc/host/sdhci-pci-core.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-)drivers/mmc/host/sdhci-pci-core.c +0
-0@@ -689,8 +689,19 @@ static int intel_start_signal_voltage_switch(struct mmc_host *mmc,return 0 ; }
drivers/mmc/host/sdhci-pci-core.c static int intel_start_signal_voltage_switch(struct mmc_host *mmc, · line 700
Quoted 10 lines
drivers/mmc/host/sdhci-pci-core.c +9
-0+static void sdhci_intel_set_clock (struct sdhci_host *host,unsigned int clock) +{ +u16 clk =sdhci_readw (host,SDHCI_CLOCK_CONTROL ); + +/* Stop card clock separately to avoid glitches on clock line */ +if (clk &SDHCI_CLOCK_CARD_EN ) +sdhci_writew (host, clk & ~SDHCI_CLOCK_CARD_EN ,SDHCI_CLOCK_CONTROL ); + +sdhci_set_clock (host, clock);
The indent is a space but needs to be tab
Quoted 17 lines
drivers/mmc/host/sdhci-pci-core.c +4
-2+} +static const struct sdhci_ops sdhci_intel_byt_ops = { - .set_clock = sdhci_set_clock, + .set_clock = sdhci_intel_set_clock, .set_power = sdhci_intel_set_power, .enable_dma = sdhci_pci_enable_dma, .set_bus_width = sdhci_set_bus_width,@@ -700,7 +711,7 @@ static const struct sdhci_ops sdhci_intel_byt_ops = { };static const struct sdhci_ops sdhci_intel_glk_ops = { - .set_clock = sdhci_set_clock, + .set_clock = sdhci_intel_set_clock, .set_power = sdhci_intel_set_power, .enable_dma = sdhci_pci_enable_dma, .set_bus_width = sdhci_set_bus_width,
Per the SD Host Controller Simplified Specification v4.20 §3.2.3, change the SD card clock parameters only after first disabling the external card clock. Doing this fixes a spurious clock pulse on Baytrail and Apollo Lake SD controllers which otherwise breaks voltage switching with a specific Swissbit SD card. This change is limited to Intel host controllers to avoid an issue reported on ARM64 devices.
--- drivers/mmc/host/sdhci-pci-core.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-)
drivers/mmc/host/sdhci-pci-core.c +13 -2
@@ -689,8 +689,19 @@ static int intel_start_signal_voltage_switch(struct mmc_host *mmc,return 0 ; } +static void sdhci_intel_set_clock (struct sdhci_host *host,unsigned int clock) +{ +u16 clk =sdhci_readw (host,SDHCI_CLOCK_CONTROL ); + +/* Stop card clock separately to avoid glitches on clock line */ +if (clk &SDHCI_CLOCK_CARD_EN ) +sdhci_writew (host, clk & ~SDHCI_CLOCK_CARD_EN ,SDHCI_CLOCK_CONTROL ); + +sdhci_set_clock (host, clock); +} +static const struct sdhci_ops sdhci_intel_byt_ops = { - .set_clock = sdhci_set_clock, + .set_clock = sdhci_intel_set_clock, .set_power = sdhci_intel_set_power, .enable_dma = sdhci_pci_enable_dma, .set_bus_width = sdhci_set_bus_width,
@@ -700,7 +711,7 @@ static const struct sdhci_ops sdhci_intel_byt_ops = { };static const struct sdhci_ops sdhci_intel_glk_ops = { - .set_clock = sdhci_set_clock, + .set_clock = sdhci_intel_set_clock, .set_power = sdhci_intel_set_power, .enable_dma = sdhci_pci_enable_dma, .set_bus_width = sdhci_set_bus_width,
Signature · 1 line
2.43.0
Quoted 10 lines · Erick Shepherd
Per the SD Host Controller Simplified Specification v4.20 §3.2.3, change the SD card clock parameters only after first disabling the external card clock. Doing this fixes a spurious clock pulse on Baytrail and Apollo Lake SD controllers which otherwise breaks voltage switching with a specific Swissbit SD card. This change is limited to Intel host controllers to avoid an issue reported on ARM64 devices.
Signed-off-by Kyle Roeschley <[email protected]>Signed-off-by Brad Mouring <[email protected]>Signed-off-by Erick Shepherd <[email protected]>
Quoted 38 lines
--- drivers/mmc/host/sdhci-pci-core.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-)drivers/mmc/host/sdhci-pci-core.c +13
-2@@ -689,8 +689,19 @@ static int intel_start_signal_voltage_switch(struct mmc_host *mmc,return 0 ; } +static void sdhci_intel_set_clock (struct sdhci_host *host,unsigned int clock) +{ +u16 clk =sdhci_readw (host,SDHCI_CLOCK_CONTROL ); + +/* Stop card clock separately to avoid glitches on clock line */ +if (clk &SDHCI_CLOCK_CARD_EN ) +sdhci_writew (host, clk & ~SDHCI_CLOCK_CARD_EN ,SDHCI_CLOCK_CONTROL ); + +sdhci_set_clock (host, clock); +} +static const struct sdhci_ops sdhci_intel_byt_ops = { - .set_clock = sdhci_set_clock, + .set_clock = sdhci_intel_set_clock, .set_power = sdhci_intel_set_power, .enable_dma = sdhci_pci_enable_dma, .set_bus_width = sdhci_set_bus_width,@@ -700,7 +711,7 @@ static const struct sdhci_ops sdhci_intel_byt_ops = { };static const struct sdhci_ops sdhci_intel_glk_ops = { - .set_clock = sdhci_set_clock, + .set_clock = sdhci_intel_set_clock, .set_power = sdhci_intel_set_power, .enable_dma = sdhci_pci_enable_dma, .set_bus_width = sdhci_set_bus_width,
Quoted 11 lines · Erick Shepherd
Per the SD Host Controller Simplified Specification v4.20 §3.2.3, change the SD card clock parameters only after first disabling the external card clock. Doing this fixes a spurious clock pulse on Baytrail and Apollo Lake SD controllers which otherwise breaks voltage switching with a specific Swissbit SD card. This change is limited to Intel host controllers to avoid an issue reported on ARM64 devices.
Signed-off-by Kyle Roeschley <[email protected]>Signed-off-by Brad Mouring <[email protected]>Signed-off-by Erick Shepherd <[email protected]>
Applied for next, thanks!
Kind regards
Uffe
Quoted 41 lines
--- drivers/mmc/host/sdhci-pci-core.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-)drivers/mmc/host/sdhci-pci-core.c +13
-3@@ -689,8 +689,19 @@ static int intel_start_signal_voltage_switch(struct mmc_host *mmc,return 0 ; } +static void sdhci_intel_set_clock (struct sdhci_host *host,unsigned int clock) +{ +u16 clk =sdhci_readw (host,SDHCI_CLOCK_CONTROL ); + +/* Stop card clock separately to avoid glitches on clock line */ +if (clk &SDHCI_CLOCK_CARD_EN ) +sdhci_writew (host, clk & ~SDHCI_CLOCK_CARD_EN ,SDHCI_CLOCK_CONTROL ); + +sdhci_set_clock (host, clock); +} +static const struct sdhci_ops sdhci_intel_byt_ops = { - .set_clock = sdhci_set_clock, + .set_clock = sdhci_intel_set_clock, .set_power = sdhci_intel_set_power, .enable_dma = sdhci_pci_enable_dma, .set_bus_width = sdhci_set_bus_width,@@ -700,7 +711,7 @@ static const struct sdhci_ops sdhci_intel_byt_ops = { };static const struct sdhci_ops sdhci_intel_glk_ops = { - .set_clock = sdhci_set_clock, + .set_clock = sdhci_intel_set_clock, .set_power = sdhci_intel_set_power, .enable_dma = sdhci_pci_enable_dma, .set_bus_width = sdhci_set_bus_width, --2.43.0
kernel test robot
build botkernel test robot noticed the following build warnings:
Hi Erick,
kernel test robot noticed the following build warnings:
[auto build test WARNING on linus/master]
[also build test WARNING on ulf-hansson-mmc-mirror/next v6.16 next-20250728] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Erick-Shepherd/mmc-sdhci-Disable-SD-card-clock-before-changing-parameters/20250724-054337 base: linus/master patch link: https://lore.kernel.org/r/20250723214216.3259-1-erick.shepherd%40ni.com patch subject: [PATCH] mmc: sdhci: Disable SD card clock before changing parameters config: i386-randconfig-141-20250728 (https://download.01.org/0day-ci/archive/20250729/[email protected]/config) compiler: clang version 20.1.8 (https://github.com/llvm/llvm-project 87f0227cb60147a26a1eeb4fb06e3b505e9c7261)
If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
smatch warnings:drivers/mmc/host/sdhci-pci-core.c:701 sdhci_intel_set_clock() warn: inconsistent indenting
vim +701 drivers/mmc/host/sdhci-pci-core.c
692
693 static void sdhci_intel_set_clock(struct sdhci_host *host, unsigned int clock)
694 {
695 u16 clk = sdhci_readw(host, SDHCI_CLOCK_CONTROL);
696
697 /* Stop card clock separately to avoid glitches on clock line */
698 if (clk & SDHCI_CLOCK_CARD_EN)
699 sdhci_writew(host, clk & ~SDHCI_CLOCK_CARD_EN, SDHCI_CLOCK_CONTROL);
700
> 701 sdhci_set_clock(host, clock);
702 }
703
Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki