[PATCH 02/10] mmc: sdhci-of-k1: enable essential clock infrastructure for SD operation

Iker Pedrosa ikerpedrosam at gmail.com
Mon Mar 9 03:32:44 PDT 2026


El sáb, 7 mar 2026 a las 3:29, Yixun Lan (<dlan at kernel.org>) escribió:
>
> Hi Iker,
>
> On 16:13 Mon 02 Mar     , Iker Pedrosa wrote:
> > Ensure SD card pins receive clock signals by enabling pad clock
> > generation and overriding automatic clock gating. Required for all SD
> > operation modes.
> >
> > Signed-off-by: Iker Pedrosa <ikerpedrosam at gmail.com>
> > ---
> >  drivers/mmc/host/sdhci-of-k1.c | 11 +++++++++++
> >  1 file changed, 11 insertions(+)
> >
> > diff --git a/drivers/mmc/host/sdhci-of-k1.c b/drivers/mmc/host/sdhci-of-k1.c
> > index 0cc97e23a2f9c7b2f9376318a8a7ebb860571504..b703b78282ed8d89183c816477c149c0a565618a 100644
> > --- a/drivers/mmc/host/sdhci-of-k1.c
> > +++ b/drivers/mmc/host/sdhci-of-k1.c
> > @@ -20,6 +20,13 @@
> >  #include "sdhci.h"
> >  #include "sdhci-pltfm.h"
> >
> [snip]
>
> > +     spacemit_sdhci_setbits(host, SDHC_OVRRD_CLK_OEN | SDHC_FORCE_CLK_ON,
> > +                            SPACEMIT_SDHC_OP_EXT_REG);
> As I'm testing on Bananapi F3 board with emmc chip, this line will cause timeout problem
>
> [   27.613806] mmc2: Timeout waiting for hardware interrupt.
> [   27.616592] mmc2: sdhci: ============ SDHCI REGISTER DUMP ===========
> [   27.623007] mmc2: sdhci: Sys addr:  0x00000400 | Version:  0x00000002
> [   27.629429] mmc2: sdhci: Blk size:  0x00007200 | Blk cnt:  0x000003a6
> [   27.635853] mmc2: sdhci: Argument:  0x001ca0a0 | Trn mode: 0x0000002b
> [   27.642277] mmc2: sdhci: Present:   0x01f70106 | Host ctl: 0x00000035
> [   27.648700] mmc2: sdhci: Power:     0x0000000f | Blk gap:  0x00000000
> [   27.655124] mmc2: sdhci: Wake-up:   0x00000000 | Clock:    0x00000107
> [   27.661547] mmc2: sdhci: Timeout:   0x0000000e | Int stat: 0x00000000
> [   27.667971] mmc2: sdhci: Int enab:  0x03ff000b | Sig enab: 0x03ff000b
> [   27.674394] mmc2: sdhci: ACmd stat: 0x00000000 | Slot int: 0x00000000
> [   27.680818] mmc2: sdhci: Caps:      0x35fc0080 | Caps_1:   0x00002f77
> [   27.687241] mmc2: sdhci: Cmd:       0x0000193a | Max curr: 0x00000000
> [   27.693666] mmc2: sdhci: Resp[0]:   0x00000900 | Resp[1]:  0xfff6dbff
> [   27.700088] mmc2: sdhci: Resp[2]:   0x320f5903 | Resp[3]:  0x00000900
> [   27.706513] mmc2: sdhci: Host ctl2: 0x0000400d
> [   27.710940] mmc2: sdhci: ADMA Err:  0x00000000 | ADMA Ptr: 0x02080208
> [   27.717363] mmc2: sdhci: ============================================
>
> Drop it will make emmc work again.. but I'm still unable to make SD card driver work,
> that's probably another problem
>
> I've took a look at current K3's sdhci driver, all operations on SPACEMIT_SDHC_OP_EXT_REG
> register are used only when doing voltage switch with SD card, snip of the code from vendor
>
>         if (host->mmc->caps2 & MMC_CAP2_NO_MMC) {
>                 /* sd/sdio has no phy */
>                 spacemit_sdhci_setbits(host, SDHC_TX_INT_CLK_SEL, SPACEMIT_SDHC_TX_CFG_REG);
>
>         } else {
>                 /* use phy func mode */
>                 spacemit_sdhci_setbits(host, SDHC_PHY_FUNC_EN | SDHC_PHY_PLL_LOCK,
>                                        SPACEMIT_SDHC_PHY_CTRL_REG);
>                 spacemit_sdhci_clrsetbits(host, SDHC_PHY_DRIVE_SEL,
>                                           SDHC_RX_BIAS_CTRL |
>                                           FIELD_PREP(SDHC_PHY_DRIVE_SEL, 4),
>                                           SPACEMIT_SDHC_PHY_PADCFG_REG);
>                 /* mmc card mode */
>                 spacemit_sdhci_setbits(host, SDHC_MMC_CARD_MODE, SPACEMIT_SDHC_MMC_CTRL_REG);
>         }

You are right, SPACEMIT_SDHC_OP_EXT_REG should only be called for SD cards

>
> --
> Yixun Lan (dlan)



More information about the linux-riscv mailing list