* [PATCH v9 0/8] riscv: spacemit: enable SD card support with UHS modes for OrangePi RV2
@ 2026-05-11 8:53 Iker Pedrosa
2026-05-11 8:53 ` [PATCH v9 1/8] dt-bindings: mmc: spacemit,sdhci: add pinctrl support for voltage switching Iker Pedrosa
` (8 more replies)
0 siblings, 9 replies; 23+ messages in thread
From: Iker Pedrosa @ 2026-05-11 8:53 UTC (permalink / raw)
To: Rob Herring, Krzysztof Kozlowski, Conor Dooley, Adrian Hunter,
Paul Walmsley, Palmer Dabbelt, Albert Ou, Alexandre Ghiti,
Yixun Lan, Ulf Hansson, Ulf Hansson, Yixun Lan
Cc: Troy Mitchell, Michael Opdenacker, Javier Martinez Canillas,
linux-mmc, devicetree, linux-riscv, spacemit, linux-kernel,
Iker Pedrosa, Conor Dooley, Anand Moon, Trevor Gamblin,
Vincent Legoll, Margherita Milani
This series enables complete SD card support for the Spacemit K1-based
OrangePi RV2 board, including UHS (Ultra High Speed) modes for
high-performance SD card operation.
Background
The Spacemit K1 SoC includes an SDHCI controller capable of supporting
SD cards up to UHS-I speeds (SDR104 at 208MHz). However, mainline
currently lacks basic SD controller configuration, SDHCI driver
enhancements for voltage switching and tuning, and power management
infrastructure.
Implementation
The series enables SD card support through coordinated layers:
- Hardware infrastructure (patches 1-2): Device tree bindings for voltage
switching hardware and essential clock infrastructure.
- SDHCI driver enhancements (patches 3-7): Regulator framework
integration, pinctrl state switching for voltage domains, AIB register
programming, and comprehensive SDR tuning support for reliable UHS
operation.
- SoC and board integration (patches 8-10): Complete K1 SoC controller
definitions, PMIC power infrastructure, and OrangePi RV2 board enablement
with full UHS support.
This transforms the OrangePi RV2 from having no SD card support to full
UHS-I capability, enabling high-performance storage up to 208MHz.
Tested-by: Michael Opdenacker <michael.opdenacker@rootcommit.com>
Signed-off-by: Iker Pedrosa <ikerpedrosam@gmail.com>
---
Changes in v9:
- Rebased on top of "for-next" to include required infrastructure:
* P1 PMIC regulator definitions (commit c02c047b925c).
* GPIO pull-up/pull-down configuration support.
- Updated BananaPi F3 SD card detect configuration to use GPIO pull-up
instead of "broken-cd" workaround:
* cd-gpios = <&gpio K1_GPIO(80) (GPIO_ACTIVE_LOW | GPIO_PULL_UP)>;
- Link to v8: https://lore.kernel.org/r/20260413-orangepi-sd-card-uhs-v8-0-c21c40ec16d0@gmail.com
Changes in v8:
- Resending the series as v8. The v7 submission failed due to an SMTP
error during transit, which resulted in a broken thread on the mailing
list.
- No functional changes from v7.
- Link to v7: https://lore.kernel.org/r/20260413-orangepi-sd-card-uhs-v7-1-16650f49c022@gmail.com
Changes in v7:
- Remove sdhci-common.yaml reference from DT binding.
- Link to v6: https://lore.kernel.org/r/20260407-orangepi-sd-card-uhs-v6-0-b5b8a1b2bfc8@gmail.com
Changes in v6:
- Add pinctrl support for voltage switching. Document optional
pinctrl-names property supporting "default" and "uhs" pinctrl states
for coordinating pin configuration changes during UHS-I voltage
switching.
- Update pinctrl state naming from "state_uhs" to "uhs" to match DT
binding naming convention.
- Fix MMC drive strength values based on vendor kernel investigation.
Correct 3.3V operation from 7mA to 19mA and 1.8V UHS operation from
13mA to 42mA to match proven vendor implementation.
- Link to v5: https://lore.kernel.org/r/20260330-orangepi-sd-card-uhs-v5-0-bd853604322d@gmail.com
Changes in v5:
- Document optional pinctrl-names property supporting "default" and
"state_uhs" pinctrl states for coordinating pin configuration changes
during UHS-I voltage switching.
- Link to v4: https://lore.kernel.org/r/20260323-orangepi-sd-card-uhs-v4-0-567c9775fd0e@gmail.com
Changes in v4:
- Revert to start_signal_voltage_switch() approach for bidirectional
voltage switching: replace voltage_switch() callback with
start_signal_voltage_switch() to properly handle both 3.3V and 1.8V
signal voltage directions.
- Fix DC input voltage specification: corrected the main power supply
from 12V to 5V to match the OrangePi RV2 board specifications. The
board uses a 5V USB-C input connector, not a 12V rail as previously
specified in the device tree.
- k1-bananapi-f3.dts: add `broken-cd` property to work around card
detection. Using `broken-cd` disables hotplug detection but keeps SD
card functionality working without additional dependencies.
- Add SD card support for Muse Pi Pro board (contributed by Trevor
Gamblin): enable SD card support with UHS-I capabilities following the
same pattern as OrangePi RV2, including dual pinctrl states, PMIC
power supplies, and card detection.
- Link to v3: https://lore.kernel.org/r/20260316-orangepi-sd-card-uhs-v3-0-aefd3b7832df@gmail.com
Changes in v3:
- Rebase on mmc.git/next to resolve conflicts with "mmc: sdhci-of-k1:
add reset support" patch.
- Squash tuning infrastructure and implementation patches (3 and 4)
together to form complete functionality and avoid unused function
warnings.
- Reduce code nesting: implemented an early return sanity check in
spacemit_sdhci_voltage_switch() to reduce indentation and improve
logic flow.
- Refactor pinctrl initialization: moved pinctrl resource acquisition
and state lookup into a dedicated helper function,
spacemit_sdhci_get_pins().
- Use generic regulator node names (buck4, aldo1) instead of
device-specific aliases (sd_vmmc, sd_vqmmc) to better reflect that
these PMIC outputs serve multiple devices.
- Remove dead code handling 3.3V voltage switching from
spacemit_sdhci_voltage_switch().
- Optimize tuning algorithm to use single-pass window detection instead
of storing results in array, reducing memory usage and complexity.
- Remove unnecessary card detect check in execute_tuning() - rely on MMC
core.
- Clarify commit message to mention both SD (UHS-I) and eMMC (HS200)
tuning support.
- Add SD card support for Banana Pi BPI-F3 board with UHS-I capabilities
following the same pattern as OrangePi RV2.
- Link to v2: https://lore.kernel.org/r/20260309-orangepi-sd-card-uhs-v2-0-5bb2b574df5d@gmail.com
Changes in v2:
- Removed custom AIB voltage switching code per maintainer feedback. The
existing pinctrl driver already handles AIB voltage switching
automatically via power-source property changes during UHS mode
transitions. This eliminates code duplication.
- Squashed regulator and pinctrl commits into single voltage switching
implementation.
- Moved voltage switching callback from dynamic probe assignment to
static sdhci_ops declaration. Removed redundant SDHCI core call since
the framework handles standard voltage switching automatically.
- Made clock override (SDHC_OVRRD_CLK_OEN | SDHC_FORCE_CLK_ON)
conditional for SD/SDIO cards only. This follows vendor driver pattern
of differentiating SD and eMMC card handling.
- Include no-mmc property for SD card.
- Link to v1: https://lore.kernel.org/r/20260302-orangepi-sd-card-uhs-v1-0-89c219973c0c@gmail.com
---
Iker Pedrosa (7):
dt-bindings: mmc: spacemit,sdhci: add pinctrl support for voltage switching
mmc: sdhci-of-k1: enable essential clock infrastructure for SD operation
mmc: sdhci-of-k1: add regulator and pinctrl voltage switching support
mmc: sdhci-of-k1: add comprehensive SDR tuning support
riscv: dts: spacemit: k1: add SD card controller and pinctrl support
riscv: dts: spacemit: k1-orangepi-rv2: add SD card support with UHS modes
riscv: dts: spacemit: k1-bananapi-f3: add SD card support with UHS modes
Trevor Gamblin (1):
riscv: dts: spacemit: k1-musepi-pro: add SD card support with UHS modes
.../devicetree/bindings/mmc/spacemit,sdhci.yaml | 15 ++
arch/riscv/boot/dts/spacemit/k1-bananapi-f3.dts | 22 +-
arch/riscv/boot/dts/spacemit/k1-musepi-pro.dts | 66 ++++++
arch/riscv/boot/dts/spacemit/k1-orangepi-rv2.dts | 21 +-
arch/riscv/boot/dts/spacemit/k1-pinctrl.dtsi | 40 ++++
arch/riscv/boot/dts/spacemit/k1.dtsi | 13 ++
drivers/mmc/host/sdhci-of-k1.c | 257 +++++++++++++++++++++
7 files changed, 431 insertions(+), 3 deletions(-)
---
base-commit: f068b204555ad62d6a841a49feb4ea8c4f45b25c
change-id: 20260226-orangepi-sd-card-uhs-0ecb05839b0c
Best regards,
--
Iker Pedrosa <ikerpedrosam@gmail.com>
^ permalink raw reply [flat|nested] 23+ messages in thread
* [PATCH v9 1/8] dt-bindings: mmc: spacemit,sdhci: add pinctrl support for voltage switching
2026-05-11 8:53 [PATCH v9 0/8] riscv: spacemit: enable SD card support with UHS modes for OrangePi RV2 Iker Pedrosa
@ 2026-05-11 8:53 ` Iker Pedrosa
2026-05-12 1:01 ` sashiko-bot
2026-05-11 8:53 ` [PATCH v9 2/8] mmc: sdhci-of-k1: enable essential clock infrastructure for SD operation Iker Pedrosa
` (7 subsequent siblings)
8 siblings, 1 reply; 23+ messages in thread
From: Iker Pedrosa @ 2026-05-11 8:53 UTC (permalink / raw)
To: Rob Herring, Krzysztof Kozlowski, Conor Dooley, Adrian Hunter,
Paul Walmsley, Palmer Dabbelt, Albert Ou, Alexandre Ghiti,
Yixun Lan, Ulf Hansson, Ulf Hansson, Yixun Lan
Cc: Troy Mitchell, Michael Opdenacker, Javier Martinez Canillas,
linux-mmc, devicetree, linux-riscv, spacemit, linux-kernel,
Iker Pedrosa, Conor Dooley
Document pinctrl properties to support voltage-dependent pin
configuration switching for UHS-I SD card modes.
Add optional pinctrl-names property with two states:
- "default": For 3.3V operation with standard drive strength
- "state_uhs": For 1.8V operation with optimized drive strength
These pinctrl states allow the SDHCI driver to coordinate voltage
switching with pin configuration changes, ensuring proper signal
integrity during UHS-I mode transitions.
Acked-by: Conor Dooley <conor.dooley@microchip.com>
Signed-off-by: Iker Pedrosa <ikerpedrosam@gmail.com>
---
Documentation/devicetree/bindings/mmc/spacemit,sdhci.yaml | 15 +++++++++++++++
1 file changed, 15 insertions(+)
diff --git a/Documentation/devicetree/bindings/mmc/spacemit,sdhci.yaml b/Documentation/devicetree/bindings/mmc/spacemit,sdhci.yaml
index 9a055d963a7f..34d202af909f 100644
--- a/Documentation/devicetree/bindings/mmc/spacemit,sdhci.yaml
+++ b/Documentation/devicetree/bindings/mmc/spacemit,sdhci.yaml
@@ -44,6 +44,18 @@ properties:
- const: axi
- const: sdh
+ pinctrl-names:
+ minItems: 1
+ items:
+ - const: default
+ - const: uhs
+
+ pinctrl-0:
+ description: Default pinctrl state for 3.3V operation
+
+ pinctrl-1:
+ description: Optional pinctrl state for 1.8V UHS operation with "uhs" name
+
required:
- compatible
- reg
@@ -62,4 +74,7 @@ examples:
interrupt-parent = <&plic>;
clocks = <&clk_apmu 10>, <&clk_apmu 13>;
clock-names = "core", "io";
+ pinctrl-names = "default", "uhs";
+ pinctrl-0 = <&sdhci_default_cfg>;
+ pinctrl-1 = <&sdhci_uhs_cfg>;
};
--
2.54.0
^ permalink raw reply related [flat|nested] 23+ messages in thread
* [PATCH v9 2/8] mmc: sdhci-of-k1: enable essential clock infrastructure for SD operation
2026-05-11 8:53 [PATCH v9 0/8] riscv: spacemit: enable SD card support with UHS modes for OrangePi RV2 Iker Pedrosa
2026-05-11 8:53 ` [PATCH v9 1/8] dt-bindings: mmc: spacemit,sdhci: add pinctrl support for voltage switching Iker Pedrosa
@ 2026-05-11 8:53 ` Iker Pedrosa
2026-05-12 1:13 ` sashiko-bot
2026-05-11 8:53 ` [PATCH v9 3/8] mmc: sdhci-of-k1: add regulator and pinctrl voltage switching support Iker Pedrosa
` (6 subsequent siblings)
8 siblings, 1 reply; 23+ messages in thread
From: Iker Pedrosa @ 2026-05-11 8:53 UTC (permalink / raw)
To: Rob Herring, Krzysztof Kozlowski, Conor Dooley, Adrian Hunter,
Paul Walmsley, Palmer Dabbelt, Albert Ou, Alexandre Ghiti,
Yixun Lan, Ulf Hansson, Ulf Hansson, Yixun Lan
Cc: Troy Mitchell, Michael Opdenacker, Javier Martinez Canillas,
linux-mmc, devicetree, linux-riscv, spacemit, linux-kernel,
Iker Pedrosa, Anand Moon, Trevor Gamblin, Vincent Legoll
Ensure SD card pins receive clock signals by enabling pad clock
generation and overriding automatic clock gating. Required for all SD
operation modes.
The SDHC_GEN_PAD_CLK_ON setting in LEGACY_CTRL_REG is safe for both SD
and eMMC operation as both protocols use the same physical MMC interface
pins and require proper clock signal generation at the hardware level
for signal integrity and timing.
Additional SD-specific clock overrides (SDHC_OVRRD_CLK_OEN and
SDHC_FORCE_CLK_ON) are conditionally applied only for SD-only
controllers to handle removable card scenarios.
Tested-by: Anand Moon <linux.amoon@gmail.com>
Acked-by: Adrian Hunter <adrian.hunter@intel.com>
Tested-by: Trevor Gamblin <tgamblin@baylibre.com>
Reviewed-by: Troy Mitchell <troy.mitchell@linux.dev>
Tested-by: Vincent Legoll <legoll@online.fr>
Signed-off-by: Iker Pedrosa <ikerpedrosam@gmail.com>
---
drivers/mmc/host/sdhci-of-k1.c | 13 +++++++++++++
1 file changed, 13 insertions(+)
diff --git a/drivers/mmc/host/sdhci-of-k1.c b/drivers/mmc/host/sdhci-of-k1.c
index 455656f9842d..0dd06fc19b85 100644
--- a/drivers/mmc/host/sdhci-of-k1.c
+++ b/drivers/mmc/host/sdhci-of-k1.c
@@ -21,6 +21,13 @@
#include "sdhci.h"
#include "sdhci-pltfm.h"
+#define SPACEMIT_SDHC_OP_EXT_REG 0x108
+#define SDHC_OVRRD_CLK_OEN BIT(11)
+#define SDHC_FORCE_CLK_ON BIT(12)
+
+#define SPACEMIT_SDHC_LEGACY_CTRL_REG 0x10C
+#define SDHC_GEN_PAD_CLK_ON BIT(6)
+
#define SPACEMIT_SDHC_MMC_CTRL_REG 0x114
#define SDHC_MISC_INT_EN BIT(1)
#define SDHC_MISC_INT BIT(2)
@@ -101,6 +108,12 @@ static void spacemit_sdhci_reset(struct sdhci_host *host, u8 mask)
if (!(host->mmc->caps2 & MMC_CAP2_NO_MMC))
spacemit_sdhci_setbits(host, SDHC_MMC_CARD_MODE, SPACEMIT_SDHC_MMC_CTRL_REG);
+
+ spacemit_sdhci_setbits(host, SDHC_GEN_PAD_CLK_ON, SPACEMIT_SDHC_LEGACY_CTRL_REG);
+
+ if (host->mmc->caps2 & MMC_CAP2_NO_MMC)
+ spacemit_sdhci_setbits(host, SDHC_OVRRD_CLK_OEN | SDHC_FORCE_CLK_ON,
+ SPACEMIT_SDHC_OP_EXT_REG);
}
static void spacemit_sdhci_set_uhs_signaling(struct sdhci_host *host, unsigned int timing)
--
2.54.0
^ permalink raw reply related [flat|nested] 23+ messages in thread
* [PATCH v9 3/8] mmc: sdhci-of-k1: add regulator and pinctrl voltage switching support
2026-05-11 8:53 [PATCH v9 0/8] riscv: spacemit: enable SD card support with UHS modes for OrangePi RV2 Iker Pedrosa
2026-05-11 8:53 ` [PATCH v9 1/8] dt-bindings: mmc: spacemit,sdhci: add pinctrl support for voltage switching Iker Pedrosa
2026-05-11 8:53 ` [PATCH v9 2/8] mmc: sdhci-of-k1: enable essential clock infrastructure for SD operation Iker Pedrosa
@ 2026-05-11 8:53 ` Iker Pedrosa
2026-05-12 2:01 ` sashiko-bot
2026-05-11 8:53 ` [PATCH v9 4/8] mmc: sdhci-of-k1: add comprehensive SDR tuning support Iker Pedrosa
` (5 subsequent siblings)
8 siblings, 1 reply; 23+ messages in thread
From: Iker Pedrosa @ 2026-05-11 8:53 UTC (permalink / raw)
To: Rob Herring, Krzysztof Kozlowski, Conor Dooley, Adrian Hunter,
Paul Walmsley, Palmer Dabbelt, Albert Ou, Alexandre Ghiti,
Yixun Lan, Ulf Hansson, Ulf Hansson, Yixun Lan
Cc: Troy Mitchell, Michael Opdenacker, Javier Martinez Canillas,
linux-mmc, devicetree, linux-riscv, spacemit, linux-kernel,
Iker Pedrosa, Anand Moon, Trevor Gamblin, Vincent Legoll
Add voltage switching infrastructure for UHS-I modes by integrating both
regulator framework (for supply voltage control) and pinctrl state
switching (for pin drive strength optimization).
- Add regulator supply parsing and voltage switching callback
- Add optional pinctrl state switching between "default" (3.3V) and
"state_uhs" (1.8V) configurations
- Enable coordinated voltage and pin configuration changes for UHS modes
This provides complete voltage switching support while maintaining
backward compatibility when pinctrl states are not defined.
Tested-by: Anand Moon <linux.amoon@gmail.com>
Tested-by: Trevor Gamblin <tgamblin@baylibre.com>
Acked-by: Adrian Hunter <adrian.hunter@intel.com>
Reviewed-by: Troy Mitchell <troy.mitchell@linux.dev>
Tested-by: Vincent Legoll <legoll@online.fr>
Signed-off-by: Iker Pedrosa <ikerpedrosam@gmail.com>
---
drivers/mmc/host/sdhci-of-k1.c | 72 ++++++++++++++++++++++++++++++++++++++++++
1 file changed, 72 insertions(+)
diff --git a/drivers/mmc/host/sdhci-of-k1.c b/drivers/mmc/host/sdhci-of-k1.c
index 0dd06fc19b85..d9144537032a 100644
--- a/drivers/mmc/host/sdhci-of-k1.c
+++ b/drivers/mmc/host/sdhci-of-k1.c
@@ -16,6 +16,7 @@
#include <linux/of.h>
#include <linux/of_device.h>
#include <linux/reset.h>
+#include <linux/pinctrl/consumer.h>
#include <linux/platform_device.h>
#include "sdhci.h"
@@ -71,6 +72,9 @@
struct spacemit_sdhci_host {
struct clk *clk_core;
struct clk *clk_io;
+ struct pinctrl *pinctrl;
+ struct pinctrl_state *pinctrl_default;
+ struct pinctrl_state *pinctrl_uhs;
};
/* All helper functions will update clr/set while preserve rest bits */
@@ -219,6 +223,46 @@ static void spacemit_sdhci_pre_hs400_to_hs200(struct mmc_host *mmc)
SPACEMIT_SDHC_PHY_CTRL_REG);
}
+static int spacemit_sdhci_start_signal_voltage_switch(struct mmc_host *mmc,
+ struct mmc_ios *ios)
+{
+ struct sdhci_host *host = mmc_priv(mmc);
+ struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host);
+ struct spacemit_sdhci_host *sdhst = sdhci_pltfm_priv(pltfm_host);
+ struct pinctrl_state *state;
+ int ret;
+
+ ret = sdhci_start_signal_voltage_switch(mmc, ios);
+ if (ret)
+ return ret;
+
+ if (!sdhst->pinctrl)
+ return 0;
+
+ /* Select appropriate pinctrl state based on signal voltage */
+ switch (ios->signal_voltage) {
+ case MMC_SIGNAL_VOLTAGE_330:
+ state = sdhst->pinctrl_default;
+ break;
+ case MMC_SIGNAL_VOLTAGE_180:
+ state = sdhst->pinctrl_uhs;
+ break;
+ default:
+ dev_warn(mmc_dev(mmc), "unsupported voltage %d\n", ios->signal_voltage);
+ return 0;
+ }
+
+ ret = pinctrl_select_state(sdhst->pinctrl, state);
+ if (ret) {
+ dev_warn(mmc_dev(mmc), "failed to select pinctrl state: %d\n", ret);
+ return 0;
+ }
+ dev_dbg(mmc_dev(mmc), "switched to %s pinctrl state\n",
+ ios->signal_voltage == MMC_SIGNAL_VOLTAGE_180 ? "UHS" : "default");
+
+ return 0;
+}
+
static inline int spacemit_sdhci_get_clocks(struct device *dev,
struct sdhci_pltfm_host *pltfm_host)
{
@@ -252,6 +296,30 @@ static inline int spacemit_sdhci_get_resets(struct device *dev)
return 0;
}
+static inline void spacemit_sdhci_get_pins(struct device *dev,
+ struct sdhci_pltfm_host *pltfm_host)
+{
+ struct spacemit_sdhci_host *sdhst = sdhci_pltfm_priv(pltfm_host);
+
+ sdhst->pinctrl = devm_pinctrl_get(dev);
+ if (IS_ERR(sdhst->pinctrl)) {
+ sdhst->pinctrl = NULL;
+ dev_dbg(dev, "pinctrl not available, voltage switching will work without it\n");
+ return;
+ }
+
+ sdhst->pinctrl_default = pinctrl_lookup_state(sdhst->pinctrl, "default");
+ if (IS_ERR(sdhst->pinctrl_default))
+ sdhst->pinctrl_default = NULL;
+
+ sdhst->pinctrl_uhs = pinctrl_lookup_state(sdhst->pinctrl, "uhs");
+ if (IS_ERR(sdhst->pinctrl_uhs))
+ sdhst->pinctrl_uhs = NULL;
+
+ dev_dbg(dev, "pinctrl setup: default=%p, uhs=%p\n",
+ sdhst->pinctrl_default, sdhst->pinctrl_uhs);
+}
+
static const struct sdhci_ops spacemit_sdhci_ops = {
.get_max_clock = spacemit_sdhci_clk_get_max_clock,
.reset = spacemit_sdhci_reset,
@@ -324,6 +392,10 @@ static int spacemit_sdhci_probe(struct platform_device *pdev)
host->mmc->caps |= MMC_CAP_NEED_RSP_BUSY;
+ spacemit_sdhci_get_pins(dev, pltfm_host);
+
+ host->mmc_host_ops.start_signal_voltage_switch = spacemit_sdhci_start_signal_voltage_switch;
+
ret = spacemit_sdhci_get_clocks(dev, pltfm_host);
if (ret)
goto err_pltfm;
--
2.54.0
^ permalink raw reply related [flat|nested] 23+ messages in thread
* [PATCH v9 4/8] mmc: sdhci-of-k1: add comprehensive SDR tuning support
2026-05-11 8:53 [PATCH v9 0/8] riscv: spacemit: enable SD card support with UHS modes for OrangePi RV2 Iker Pedrosa
` (2 preceding siblings ...)
2026-05-11 8:53 ` [PATCH v9 3/8] mmc: sdhci-of-k1: add regulator and pinctrl voltage switching support Iker Pedrosa
@ 2026-05-11 8:53 ` Iker Pedrosa
2026-05-11 8:54 ` [PATCH v9 5/8] riscv: dts: spacemit: k1: add SD card controller and pinctrl support Iker Pedrosa
` (4 subsequent siblings)
8 siblings, 0 replies; 23+ messages in thread
From: Iker Pedrosa @ 2026-05-11 8:53 UTC (permalink / raw)
To: Rob Herring, Krzysztof Kozlowski, Conor Dooley, Adrian Hunter,
Paul Walmsley, Palmer Dabbelt, Albert Ou, Alexandre Ghiti,
Yixun Lan, Ulf Hansson, Ulf Hansson, Yixun Lan
Cc: Troy Mitchell, Michael Opdenacker, Javier Martinez Canillas,
linux-mmc, devicetree, linux-riscv, spacemit, linux-kernel,
Iker Pedrosa, Anand Moon, Trevor Gamblin, Vincent Legoll
Implement software tuning algorithm to enable UHS-I SDR modes for SD
card operation and HS200 mode for eMMC. This adds both TX and RX delay
line tuning based on the SpacemiT K1 controller capabilities.
Algorithm features:
- Add tuning register definitions (RX_CFG, DLINE_CTRL, DLINE_CFG)
- Conditional tuning: only for high-speed modes (≥100MHz)
- TX tuning: configure transmit delay line with optimal values
(dline_reg=0, delaycode=127) to ensure optimal signal output timing
- RX tuning: single-pass window detection algorithm testing full
delay range (0-255) to find optimal receive timing window
- Retry mechanism: multiple fallback delays within optimal window
for improved reliability
Tested-by: Anand Moon <linux.amoon@gmail.com>
Acked-by: Adrian Hunter <adrian.hunter@intel.com>
Tested-by: Trevor Gamblin <tgamblin@baylibre.com>
Tested-by: Vincent Legoll <legoll@online.fr>
Signed-off-by: Iker Pedrosa <ikerpedrosam@gmail.com>
---
drivers/mmc/host/sdhci-of-k1.c | 172 +++++++++++++++++++++++++++++++++++++++++
1 file changed, 172 insertions(+)
diff --git a/drivers/mmc/host/sdhci-of-k1.c b/drivers/mmc/host/sdhci-of-k1.c
index d9144537032a..37b0911e7cf2 100644
--- a/drivers/mmc/host/sdhci-of-k1.c
+++ b/drivers/mmc/host/sdhci-of-k1.c
@@ -69,6 +69,28 @@
#define SDHC_PHY_DRIVE_SEL GENMASK(2, 0)
#define SDHC_RX_BIAS_CTRL BIT(5)
+#define SPACEMIT_SDHC_RX_CFG_REG 0x118
+#define SDHC_RX_SDCLK_SEL0_MASK GENMASK(1, 0)
+#define SDHC_RX_SDCLK_SEL1_MASK GENMASK(3, 2)
+#define SDHC_RX_SDCLK_SEL1 FIELD_PREP(SDHC_RX_SDCLK_SEL1_MASK, 1)
+
+#define SPACEMIT_SDHC_DLINE_CTRL_REG 0x130
+#define SDHC_DLINE_PU BIT(0)
+#define SDHC_RX_DLINE_CODE_MASK GENMASK(23, 16)
+#define SDHC_TX_DLINE_CODE_MASK GENMASK(31, 24)
+
+#define SPACEMIT_SDHC_DLINE_CFG_REG 0x134
+#define SDHC_RX_DLINE_REG_MASK GENMASK(7, 0)
+#define SDHC_RX_DLINE_GAIN BIT(8)
+#define SDHC_TX_DLINE_REG_MASK GENMASK(23, 16)
+
+#define SPACEMIT_RX_DLINE_REG 9
+#define SPACEMIT_RX_TUNE_DELAY_MIN 0x0
+#define SPACEMIT_RX_TUNE_DELAY_MAX 0xFF
+
+#define SPACEMIT_TX_TUNING_DLINE_REG 0x00
+#define SPACEMIT_TX_TUNING_DELAYCODE 127
+
struct spacemit_sdhci_host {
struct clk *clk_core;
struct clk *clk_io;
@@ -96,6 +118,50 @@ static inline void spacemit_sdhci_clrsetbits(struct sdhci_host *host, u32 clr, u
sdhci_writel(host, val, reg);
}
+static void spacemit_sdhci_set_rx_delay(struct sdhci_host *host, u8 delay)
+{
+ spacemit_sdhci_clrsetbits(host, SDHC_RX_DLINE_CODE_MASK,
+ FIELD_PREP(SDHC_RX_DLINE_CODE_MASK, delay),
+ SPACEMIT_SDHC_DLINE_CTRL_REG);
+}
+
+static void spacemit_sdhci_set_tx_delay(struct sdhci_host *host, u8 delay)
+{
+ spacemit_sdhci_clrsetbits(host, SDHC_TX_DLINE_CODE_MASK,
+ FIELD_PREP(SDHC_TX_DLINE_CODE_MASK, delay),
+ SPACEMIT_SDHC_DLINE_CTRL_REG);
+}
+
+static void spacemit_sdhci_set_tx_dline_reg(struct sdhci_host *host, u8 dline_reg)
+{
+ spacemit_sdhci_clrsetbits(host, SDHC_TX_DLINE_REG_MASK,
+ FIELD_PREP(SDHC_TX_DLINE_REG_MASK, dline_reg),
+ SPACEMIT_SDHC_DLINE_CFG_REG);
+}
+
+static void spacemit_sdhci_tx_tuning_prepare(struct sdhci_host *host)
+{
+ spacemit_sdhci_setbits(host, SDHC_TX_MUX_SEL, SPACEMIT_SDHC_TX_CFG_REG);
+ spacemit_sdhci_setbits(host, SDHC_DLINE_PU, SPACEMIT_SDHC_DLINE_CTRL_REG);
+ udelay(5);
+}
+
+static void spacemit_sdhci_prepare_tuning(struct sdhci_host *host)
+{
+ spacemit_sdhci_clrsetbits(host, SDHC_RX_DLINE_REG_MASK,
+ FIELD_PREP(SDHC_RX_DLINE_REG_MASK, SPACEMIT_RX_DLINE_REG),
+ SPACEMIT_SDHC_DLINE_CFG_REG);
+
+ spacemit_sdhci_setbits(host, SDHC_DLINE_PU, SPACEMIT_SDHC_DLINE_CTRL_REG);
+ udelay(5);
+
+ spacemit_sdhci_clrsetbits(host, SDHC_RX_SDCLK_SEL1_MASK, SDHC_RX_SDCLK_SEL1,
+ SPACEMIT_SDHC_RX_CFG_REG);
+
+ if (host->mmc->ios.timing == MMC_TIMING_MMC_HS200)
+ spacemit_sdhci_setbits(host, SDHC_HS200_USE_RFIFO, SPACEMIT_SDHC_PHY_FUNC_REG);
+}
+
static void spacemit_sdhci_reset(struct sdhci_host *host, u8 mask)
{
sdhci_reset(host, mask);
@@ -191,6 +257,111 @@ static unsigned int spacemit_sdhci_clk_get_max_clock(struct sdhci_host *host)
return clk_get_rate(pltfm_host->clk);
}
+static int spacemit_sdhci_execute_tuning(struct sdhci_host *host, u32 opcode)
+{
+ int current_len = 0, current_start = 0;
+ int max_pass_len = 0, max_pass_start = 0;
+ struct mmc_host *mmc = host->mmc;
+ struct mmc_ios ios = mmc->ios;
+ u8 final_delay;
+ int ret = 0;
+ int i;
+
+ /*
+ * Tuning is required for SDR50/SDR104, HS200/HS400 cards and
+ * if clock frequency is greater than 100MHz in these modes.
+ */
+ if (host->clock < 100 * 1000 * 1000 ||
+ !(ios.timing == MMC_TIMING_MMC_HS200 ||
+ ios.timing == MMC_TIMING_UHS_SDR50 ||
+ ios.timing == MMC_TIMING_UHS_SDR104))
+ return 0;
+
+ if (mmc->caps2 & MMC_CAP2_NO_MMC) {
+ spacemit_sdhci_set_tx_dline_reg(host, SPACEMIT_TX_TUNING_DLINE_REG);
+ spacemit_sdhci_set_tx_delay(host, SPACEMIT_TX_TUNING_DELAYCODE);
+ spacemit_sdhci_tx_tuning_prepare(host);
+
+ dev_dbg(mmc_dev(host->mmc), "TX tuning: dline_reg=%d, delaycode=%d\n",
+ SPACEMIT_TX_TUNING_DLINE_REG, SPACEMIT_TX_TUNING_DELAYCODE);
+ }
+
+ spacemit_sdhci_prepare_tuning(host);
+
+ for (i = SPACEMIT_RX_TUNE_DELAY_MIN; i <= SPACEMIT_RX_TUNE_DELAY_MAX; i++) {
+ spacemit_sdhci_set_rx_delay(host, i);
+ ret = mmc_send_tuning(host->mmc, opcode, NULL);
+
+ dev_dbg(mmc_dev(host->mmc), "RX delay %d: %s\n",
+ i, ret == 0 ? "pass" : "fail");
+
+ if (ret == 0) {
+ /* Test passed - extend current window */
+ if (current_len == 0)
+ current_start = i;
+ current_len++;
+ } else {
+ /* Test failed - check if current window is best so far */
+ if (current_len > max_pass_len) {
+ max_pass_len = current_len;
+ max_pass_start = current_start;
+ }
+ current_len = 0;
+ }
+ }
+
+ if (current_len > max_pass_len) {
+ max_pass_len = current_len;
+ max_pass_start = current_start;
+ }
+
+ if (max_pass_len < 3) {
+ dev_err(mmc_dev(host->mmc), "Tuning failed: no stable window found\n");
+ return -EIO;
+ }
+
+ final_delay = max_pass_start + max_pass_len / 2;
+ spacemit_sdhci_set_rx_delay(host, final_delay);
+ ret = mmc_send_tuning(host->mmc, opcode, NULL);
+ if (ret) {
+ u8 retry_delays[] = {
+ max_pass_start + max_pass_len / 4,
+ max_pass_start + (3 * max_pass_len) / 4,
+ max_pass_start,
+ max_pass_start + max_pass_len - 1
+ };
+ int retry_count = ARRAY_SIZE(retry_delays);
+
+ dev_warn(mmc_dev(mmc), "Primary delay %d failed, trying alternatives\n",
+ final_delay);
+
+ for (i = 0; i < retry_count; i++) {
+ if (retry_delays[i] >= SPACEMIT_RX_TUNE_DELAY_MIN &&
+ retry_delays[i] <= SPACEMIT_RX_TUNE_DELAY_MAX) {
+ spacemit_sdhci_set_rx_delay(host, retry_delays[i]);
+ ret = mmc_send_tuning(host->mmc, opcode, NULL);
+ if (!ret) {
+ final_delay = retry_delays[i];
+ dev_info(mmc_dev(mmc), "Retry successful with delay %d\n",
+ final_delay);
+ break;
+ }
+ }
+ }
+
+ if (ret) {
+ dev_err(mmc_dev(mmc), "All retry attempts failed\n");
+ return -EIO;
+ }
+ }
+
+ dev_dbg(mmc_dev(host->mmc),
+ "Tuning successful: window %d-%d, using delay %d\n",
+ max_pass_start, max_pass_start + max_pass_len - 1, final_delay);
+
+ return 0;
+}
+
static int spacemit_sdhci_pre_select_hs400(struct mmc_host *mmc)
{
struct sdhci_host *host = mmc_priv(mmc);
@@ -326,6 +497,7 @@ static const struct sdhci_ops spacemit_sdhci_ops = {
.set_bus_width = sdhci_set_bus_width,
.set_clock = spacemit_sdhci_set_clock,
.set_uhs_signaling = spacemit_sdhci_set_uhs_signaling,
+ .platform_execute_tuning = spacemit_sdhci_execute_tuning,
};
static const struct sdhci_pltfm_data spacemit_sdhci_k1_pdata = {
--
2.54.0
^ permalink raw reply related [flat|nested] 23+ messages in thread
* [PATCH v9 5/8] riscv: dts: spacemit: k1: add SD card controller and pinctrl support
2026-05-11 8:53 [PATCH v9 0/8] riscv: spacemit: enable SD card support with UHS modes for OrangePi RV2 Iker Pedrosa
` (3 preceding siblings ...)
2026-05-11 8:53 ` [PATCH v9 4/8] mmc: sdhci-of-k1: add comprehensive SDR tuning support Iker Pedrosa
@ 2026-05-11 8:54 ` Iker Pedrosa
2026-05-12 2:47 ` sashiko-bot
2026-05-11 8:54 ` [PATCH v9 6/8] riscv: dts: spacemit: k1-orangepi-rv2: add SD card support with UHS modes Iker Pedrosa
` (3 subsequent siblings)
8 siblings, 1 reply; 23+ messages in thread
From: Iker Pedrosa @ 2026-05-11 8:54 UTC (permalink / raw)
To: Rob Herring, Krzysztof Kozlowski, Conor Dooley, Adrian Hunter,
Paul Walmsley, Palmer Dabbelt, Albert Ou, Alexandre Ghiti,
Yixun Lan, Ulf Hansson, Ulf Hansson, Yixun Lan
Cc: Troy Mitchell, Michael Opdenacker, Javier Martinez Canillas,
linux-mmc, devicetree, linux-riscv, spacemit, linux-kernel,
Iker Pedrosa, Anand Moon, Trevor Gamblin, Vincent Legoll
Add SD card controller infrastructure for SpacemiT K1 SoC with complete
pinctrl support for both standard and UHS modes.
- Add sdhci0 controller definition with clocks, resets and interrupts
- Add mmc1_cfg pinctrl for 3.3V standard SD operation
- Add mmc1_uhs_cfg pinctrl for 1.8V UHS high-speed operation
- Configure appropriate drive strength and power-source properties
This provides complete SD card infrastructure that K1-based boards can
enable.
Tested-by: Anand Moon <linux.amoon@gmail.com>
Tested-by: Trevor Gamblin <tgamblin@baylibre.com>
Tested-by: Vincent Legoll <legoll@online.fr>
Reviewed-by: Troy Mitchell <troy.mitchell@linux.dev>
Signed-off-by: Iker Pedrosa <ikerpedrosam@gmail.com>
---
arch/riscv/boot/dts/spacemit/k1-pinctrl.dtsi | 40 ++++++++++++++++++++++++++++
arch/riscv/boot/dts/spacemit/k1.dtsi | 13 +++++++++
2 files changed, 53 insertions(+)
diff --git a/arch/riscv/boot/dts/spacemit/k1-pinctrl.dtsi b/arch/riscv/boot/dts/spacemit/k1-pinctrl.dtsi
index 34d88334e95e..4e9a62d0e85b 100644
--- a/arch/riscv/boot/dts/spacemit/k1-pinctrl.dtsi
+++ b/arch/riscv/boot/dts/spacemit/k1-pinctrl.dtsi
@@ -590,4 +590,44 @@ ssp3-0-frm-pins {
power-source = <3300>;
};
};
+
+ mmc1_cfg: mmc1-cfg {
+ mmc1-data-cmd-pins {
+ pinmux = <K1_PADCONF(104, 0)>, /* mmc1_d3 */
+ <K1_PADCONF(105, 0)>, /* mmc1_d2 */
+ <K1_PADCONF(106, 0)>, /* mmc1_d1 */
+ <K1_PADCONF(107, 0)>, /* mmc1_d0 */
+ <K1_PADCONF(108, 0)>; /* mmc1_cmd */
+ bias-pull-up = <1>;
+ drive-strength = <19>;
+ power-source = <3300>;
+ };
+
+ mmc1-clk-pins {
+ pinmux = <K1_PADCONF(109, 0)>; /* mmc1_clk */
+ bias-pull-down = <1>;
+ drive-strength = <19>;
+ power-source = <3300>;
+ };
+ };
+
+ mmc1_uhs_cfg: mmc1-uhs-cfg {
+ mmc1-data-cmd-pins {
+ pinmux = <K1_PADCONF(104, 0)>, /* mmc1_d3 */
+ <K1_PADCONF(105, 0)>, /* mmc1_d2 */
+ <K1_PADCONF(106, 0)>, /* mmc1_d1 */
+ <K1_PADCONF(107, 0)>, /* mmc1_d0 */
+ <K1_PADCONF(108, 0)>; /* mmc1_cmd */
+ bias-pull-up = <1>;
+ drive-strength = <42>;
+ power-source = <1800>;
+ };
+
+ mmc1-clk-pins {
+ pinmux = <K1_PADCONF(109, 0)>; /* mmc1_clk */
+ bias-pull-down = <1>;
+ drive-strength = <42>;
+ power-source = <1800>;
+ };
+ };
};
diff --git a/arch/riscv/boot/dts/spacemit/k1.dtsi b/arch/riscv/boot/dts/spacemit/k1.dtsi
index 24becab4c959..6ded5c06b797 100644
--- a/arch/riscv/boot/dts/spacemit/k1.dtsi
+++ b/arch/riscv/boot/dts/spacemit/k1.dtsi
@@ -1226,6 +1226,19 @@ emmc: mmc@d4281000 {
interrupts = <101>;
status = "disabled";
};
+
+ sdhci0: mmc@d4280000 {
+ compatible = "spacemit,k1-sdhci";
+ reg = <0x0 0xd4280000 0x0 0x200>;
+ clocks = <&syscon_apmu CLK_SDH_AXI>,
+ <&syscon_apmu CLK_SDH0>;
+ clock-names = "core", "io";
+ resets = <&syscon_apmu RESET_SDH_AXI>,
+ <&syscon_apmu RESET_SDH0>;
+ reset-names = "axi", "sdh";
+ interrupts = <99>;
+ status = "disabled";
+ };
};
};
};
--
2.54.0
^ permalink raw reply related [flat|nested] 23+ messages in thread
* [PATCH v9 6/8] riscv: dts: spacemit: k1-orangepi-rv2: add SD card support with UHS modes
2026-05-11 8:53 [PATCH v9 0/8] riscv: spacemit: enable SD card support with UHS modes for OrangePi RV2 Iker Pedrosa
` (4 preceding siblings ...)
2026-05-11 8:54 ` [PATCH v9 5/8] riscv: dts: spacemit: k1: add SD card controller and pinctrl support Iker Pedrosa
@ 2026-05-11 8:54 ` Iker Pedrosa
2026-05-12 3:20 ` sashiko-bot
2026-05-11 8:54 ` [PATCH v9 7/8] riscv: dts: spacemit: k1-bananapi-f3: " Iker Pedrosa
` (2 subsequent siblings)
8 siblings, 1 reply; 23+ messages in thread
From: Iker Pedrosa @ 2026-05-11 8:54 UTC (permalink / raw)
To: Rob Herring, Krzysztof Kozlowski, Conor Dooley, Adrian Hunter,
Paul Walmsley, Palmer Dabbelt, Albert Ou, Alexandre Ghiti,
Yixun Lan, Ulf Hansson, Ulf Hansson, Yixun Lan
Cc: Troy Mitchell, Michael Opdenacker, Javier Martinez Canillas,
linux-mmc, devicetree, linux-riscv, spacemit, linux-kernel,
Iker Pedrosa, Anand Moon, Trevor Gamblin, Vincent Legoll
Add complete SD card controller support with UHS high-speed modes.
- Enable sdhci0 controller with 4-bit bus width
- Configure card detect GPIO with inversion
- Connect vmmc-supply to buck4 for 3.3V card power
- Connect vqmmc-supply to aldo1 for 1.8V/3.3V I/O switching
- Add dual pinctrl states for voltage-dependent pin configuration
- Support UHS-I SDR25, SDR50, and SDR104 modes
This enables full SD card functionality including high-speed UHS modes
for improved performance.
Tested-by: Anand Moon <linux.amoon@gmail.com>
Tested-by: Trevor Gamblin <tgamblin@baylibre.com>
Tested-by: Michael Opdenacker <michael.opdenacker@rootcommit.com>
Tested-by: Vincent Legoll <legoll@online.fr>
Signed-off-by: Iker Pedrosa <ikerpedrosam@gmail.com>
---
arch/riscv/boot/dts/spacemit/k1-orangepi-rv2.dts | 21 ++++++++++++++++++++-
1 file changed, 20 insertions(+), 1 deletion(-)
diff --git a/arch/riscv/boot/dts/spacemit/k1-orangepi-rv2.dts b/arch/riscv/boot/dts/spacemit/k1-orangepi-rv2.dts
index c95ca38e3d4a..1ed76e0ff806 100644
--- a/arch/riscv/boot/dts/spacemit/k1-orangepi-rv2.dts
+++ b/arch/riscv/boot/dts/spacemit/k1-orangepi-rv2.dts
@@ -202,7 +202,7 @@ buck6 {
regulator-always-on;
};
- aldo1 {
+ aldo1: aldo1 {
regulator-min-microvolt = <500000>;
regulator-max-microvolt = <3400000>;
regulator-boot-on;
@@ -319,3 +319,22 @@ hub_3_0: hub@2 {
vdd-supply = <&vcc_5v0>;
};
};
+
+&sdhci0 {
+ pinctrl-names = "default", "uhs";
+ pinctrl-0 = <&mmc1_cfg>;
+ pinctrl-1 = <&mmc1_uhs_cfg>;
+ bus-width = <4>;
+ cd-gpios = <&gpio K1_GPIO(80) GPIO_ACTIVE_HIGH>;
+ cd-inverted;
+ no-mmc;
+ no-sdio;
+ disable-wp;
+ cap-sd-highspeed;
+ vmmc-supply = <&buck4_3v3>;
+ vqmmc-supply = <&aldo1>;
+ sd-uhs-sdr25;
+ sd-uhs-sdr50;
+ sd-uhs-sdr104;
+ status = "okay";
+};
--
2.54.0
^ permalink raw reply related [flat|nested] 23+ messages in thread
* [PATCH v9 7/8] riscv: dts: spacemit: k1-bananapi-f3: add SD card support with UHS modes
2026-05-11 8:53 [PATCH v9 0/8] riscv: spacemit: enable SD card support with UHS modes for OrangePi RV2 Iker Pedrosa
` (5 preceding siblings ...)
2026-05-11 8:54 ` [PATCH v9 6/8] riscv: dts: spacemit: k1-orangepi-rv2: add SD card support with UHS modes Iker Pedrosa
@ 2026-05-11 8:54 ` Iker Pedrosa
2026-05-11 16:55 ` Aurelien Jarno
` (2 more replies)
2026-05-11 8:54 ` [PATCH v9 8/8] riscv: dts: spacemit: k1-musepi-pro: " Iker Pedrosa
2026-05-11 15:40 ` [PATCH v9 0/8] riscv: spacemit: enable SD card support with UHS modes for OrangePi RV2 Ulf Hansson
8 siblings, 3 replies; 23+ messages in thread
From: Iker Pedrosa @ 2026-05-11 8:54 UTC (permalink / raw)
To: Rob Herring, Krzysztof Kozlowski, Conor Dooley, Adrian Hunter,
Paul Walmsley, Palmer Dabbelt, Albert Ou, Alexandre Ghiti,
Yixun Lan, Ulf Hansson, Ulf Hansson, Yixun Lan
Cc: Troy Mitchell, Michael Opdenacker, Javier Martinez Canillas,
linux-mmc, devicetree, linux-riscv, spacemit, linux-kernel,
Iker Pedrosa, Anand Moon, Margherita Milani
Add complete SD card controller support with UHS high-speed modes.
- Enable sdhci0 controller with 4-bit bus width
- Configure card detect GPIO with inversion
- Connect vmmc-supply to buck4 for 3.3V card power
- Connect vqmmc-supply to aldo1 for 1.8V/3.3V I/O switching
- Add dual pinctrl states for voltage-dependent pin configuration
- Support UHS-I SDR25, SDR50, and SDR104 modes
This enables full SD card functionality including high-speed UHS modes
for improved performance.
Suggested-by: Anand Moon <linux.amoon@gmail.com>
Tested-by: Anand Moon <linux.amoon@gmail.com>
Tested-by: Margherita Milani <margherita.milani@amarulasolutions.com>
Signed-off-by: Iker Pedrosa <ikerpedrosam@gmail.com>
---
arch/riscv/boot/dts/spacemit/k1-bananapi-f3.dts | 22 ++++++++++++++++++++--
1 file changed, 20 insertions(+), 2 deletions(-)
diff --git a/arch/riscv/boot/dts/spacemit/k1-bananapi-f3.dts b/arch/riscv/boot/dts/spacemit/k1-bananapi-f3.dts
index e20daa50a152..8fea6e87acec 100644
--- a/arch/riscv/boot/dts/spacemit/k1-bananapi-f3.dts
+++ b/arch/riscv/boot/dts/spacemit/k1-bananapi-f3.dts
@@ -221,7 +221,7 @@ buck3_1v8: buck3 {
regulator-always-on;
};
- buck4 {
+ buck4: buck4 {
regulator-min-microvolt = <500000>;
regulator-max-microvolt = <3300000>;
regulator-ramp-delay = <5000>;
@@ -242,7 +242,7 @@ buck6 {
regulator-always-on;
};
- aldo1 {
+ aldo1: aldo1 {
regulator-min-microvolt = <500000>;
regulator-max-microvolt = <3400000>;
regulator-boot-on;
@@ -374,3 +374,21 @@ hub_3_0: hub@2 {
reset-gpios = <&gpio K1_GPIO(124) GPIO_ACTIVE_LOW>;
};
};
+
+&sdhci0 {
+ pinctrl-names = "default", "uhs";
+ pinctrl-0 = <&mmc1_cfg>;
+ pinctrl-1 = <&mmc1_uhs_cfg>;
+ bus-width = <4>;
+ cd-gpios = <&gpio K1_GPIO(80) (GPIO_ACTIVE_LOW | GPIO_PULL_UP)>;
+ no-mmc;
+ no-sdio;
+ disable-wp;
+ cap-sd-highspeed;
+ vmmc-supply = <&buck4>;
+ vqmmc-supply = <&aldo1>;
+ sd-uhs-sdr25;
+ sd-uhs-sdr50;
+ sd-uhs-sdr104;
+ status = "okay";
+};
--
2.54.0
^ permalink raw reply related [flat|nested] 23+ messages in thread
* [PATCH v9 8/8] riscv: dts: spacemit: k1-musepi-pro: add SD card support with UHS modes
2026-05-11 8:53 [PATCH v9 0/8] riscv: spacemit: enable SD card support with UHS modes for OrangePi RV2 Iker Pedrosa
` (6 preceding siblings ...)
2026-05-11 8:54 ` [PATCH v9 7/8] riscv: dts: spacemit: k1-bananapi-f3: " Iker Pedrosa
@ 2026-05-11 8:54 ` Iker Pedrosa
2026-05-11 11:43 ` Andre Heider
` (2 more replies)
2026-05-11 15:40 ` [PATCH v9 0/8] riscv: spacemit: enable SD card support with UHS modes for OrangePi RV2 Ulf Hansson
8 siblings, 3 replies; 23+ messages in thread
From: Iker Pedrosa @ 2026-05-11 8:54 UTC (permalink / raw)
To: Rob Herring, Krzysztof Kozlowski, Conor Dooley, Adrian Hunter,
Paul Walmsley, Palmer Dabbelt, Albert Ou, Alexandre Ghiti,
Yixun Lan, Ulf Hansson, Ulf Hansson, Yixun Lan
Cc: Troy Mitchell, Michael Opdenacker, Javier Martinez Canillas,
linux-mmc, devicetree, linux-riscv, spacemit, linux-kernel,
Iker Pedrosa, Trevor Gamblin
From: Trevor Gamblin <tgamblin@baylibre.com>
Update the Muse Pi Pro devicetree with SD card support to match what
was done for the OrangePi RV2 in [1]. More precisely:
- Enable sdhci0 controller with 4-bit bus width
- Configure card detect GPIO with inversion
- Connect vmmc-supply to buck4 for 3.3V card power
- Connect vqmmc-supply to aldo1 for 1.8V/3.3V I/O switching
- Add dual pinctrl states for voltage-dependent pin configuration
- Support UHS-I SDR25, SDR50, and SDR104 modes
[1] https://lore.kernel.org/linux-riscv/20260316-orangepi-sd-card-uhs-v3-0-aefd3b7832df@gmail.com/T/#
Signed-off-by: Trevor Gamblin <tgamblin@baylibre.com>
Signed-off-by: Iker Pedrosa <ikerpedrosam@gmail.com>
---
arch/riscv/boot/dts/spacemit/k1-musepi-pro.dts | 66 ++++++++++++++++++++++++++
1 file changed, 66 insertions(+)
diff --git a/arch/riscv/boot/dts/spacemit/k1-musepi-pro.dts b/arch/riscv/boot/dts/spacemit/k1-musepi-pro.dts
index 29e333b670cf..774a4640f065 100644
--- a/arch/riscv/boot/dts/spacemit/k1-musepi-pro.dts
+++ b/arch/riscv/boot/dts/spacemit/k1-musepi-pro.dts
@@ -18,6 +18,24 @@ aliases {
ethernet0 = ð0;
serial0 = &uart0;
};
+ reg_dc_in: dc-in-5v {
+ compatible = "regulator-fixed";
+ regulator-name = "dc_in_5v";
+ regulator-min-microvolt = <5000000>;
+ regulator-max-microvolt = <5000000>;
+ regulator-boot-on;
+ regulator-always-on;
+ };
+
+ reg_vcc_4v: vcc-4v {
+ compatible = "regulator-fixed";
+ regulator-name = "vcc_4v";
+ regulator-min-microvolt = <4000000>;
+ regulator-max-microvolt = <4000000>;
+ regulator-boot-on;
+ regulator-always-on;
+ };
+
chosen {
stdout-path = "serial0";
@@ -77,3 +95,51 @@ &uart0 {
pinctrl-names = "default";
status = "okay";
};
+
+&i2c8 {
+ pinctrl-names = "default";
+ pinctrl-0 = <&i2c8_cfg>;
+ status = "okay";
+
+ pmic@41 {
+ compatible = "spacemit,p1";
+ reg = <0x41>;
+ interrupts = <64>;
+ vin-supply = <®_vcc_4v>;
+
+ regulators {
+ buck4: buck4 {
+ regulator-min-microvolt = <500000>;
+ regulator-max-microvolt = <3300000>;
+ regulator-ramp-delay = <5000>;
+ regulator-always-on;
+ };
+
+ aldo1: aldo1 {
+ regulator-min-microvolt = <500000>;
+ regulator-max-microvolt = <3400000>;
+ regulator-boot-on;
+ regulator-always-on;
+ };
+ };
+ };
+};
+
+&sdhci0 {
+ pinctrl-names = "default", "uhs";
+ pinctrl-0 = <&mmc1_cfg>;
+ pinctrl-1 = <&mmc1_uhs_cfg>;
+ bus-width = <4>;
+ cd-gpios = <&gpio K1_GPIO(80) GPIO_ACTIVE_HIGH>;
+ cd-inverted;
+ no-mmc;
+ no-sdio;
+ disable-wp;
+ cap-sd-highspeed;
+ vmmc-supply = <&buck4>;
+ vqmmc-supply = <&aldo1>;
+ sd-uhs-sdr25;
+ sd-uhs-sdr50;
+ sd-uhs-sdr104;
+ status = "okay";
+};
--
2.54.0
^ permalink raw reply related [flat|nested] 23+ messages in thread
* Re: [PATCH v9 8/8] riscv: dts: spacemit: k1-musepi-pro: add SD card support with UHS modes
2026-05-11 8:54 ` [PATCH v9 8/8] riscv: dts: spacemit: k1-musepi-pro: " Iker Pedrosa
@ 2026-05-11 11:43 ` Andre Heider
2026-05-12 3:48 ` sashiko-bot
2026-05-12 5:20 ` Yixun Lan
2 siblings, 0 replies; 23+ messages in thread
From: Andre Heider @ 2026-05-11 11:43 UTC (permalink / raw)
To: Iker Pedrosa, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
Adrian Hunter, Paul Walmsley, Palmer Dabbelt, Albert Ou,
Alexandre Ghiti, Yixun Lan, Ulf Hansson
Cc: Troy Mitchell, Michael Opdenacker, Javier Martinez Canillas,
linux-mmc, devicetree, linux-riscv, spacemit, linux-kernel,
Trevor Gamblin
Hi Iker,
On 11.05.26 10:54 AM, Iker Pedrosa wrote:
> From: Trevor Gamblin <tgamblin@baylibre.com>
>
> Update the Muse Pi Pro devicetree with SD card support to match what
> was done for the OrangePi RV2 in [1]. More precisely:
>
> - Enable sdhci0 controller with 4-bit bus width
> - Configure card detect GPIO with inversion
> - Connect vmmc-supply to buck4 for 3.3V card power
> - Connect vqmmc-supply to aldo1 for 1.8V/3.3V I/O switching
> - Add dual pinctrl states for voltage-dependent pin configuration
> - Support UHS-I SDR25, SDR50, and SDR104 modes
>
> [1] https://lore.kernel.org/linux-riscv/20260316-orangepi-sd-card-uhs-v3-0-aefd3b7832df@gmail.com/T/#
>
> Signed-off-by: Trevor Gamblin <tgamblin@baylibre.com>
> Signed-off-by: Iker Pedrosa <ikerpedrosam@gmail.com>
with the cd issue mentioned below this is:
Tested-by: Andre Heider <a.heider@gmail.com>
> ---
> arch/riscv/boot/dts/spacemit/k1-musepi-pro.dts | 66 ++++++++++++++++++++++++++
> 1 file changed, 66 insertions(+)
>
> diff --git a/arch/riscv/boot/dts/spacemit/k1-musepi-pro.dts b/arch/riscv/boot/dts/spacemit/k1-musepi-pro.dts
> index 29e333b670cf..774a4640f065 100644
> --- a/arch/riscv/boot/dts/spacemit/k1-musepi-pro.dts
> +++ b/arch/riscv/boot/dts/spacemit/k1-musepi-pro.dts
> @@ -18,6 +18,24 @@ aliases {
> ethernet0 = ð0;
> serial0 = &uart0;
> };
> + reg_dc_in: dc-in-5v {
> + compatible = "regulator-fixed";
> + regulator-name = "dc_in_5v";
> + regulator-min-microvolt = <5000000>;
> + regulator-max-microvolt = <5000000>;
> + regulator-boot-on;
> + regulator-always-on;
> + };
> +
> + reg_vcc_4v: vcc-4v {
> + compatible = "regulator-fixed";
> + regulator-name = "vcc_4v";
> + regulator-min-microvolt = <4000000>;
> + regulator-max-microvolt = <4000000>;
> + regulator-boot-on;
> + regulator-always-on;
> + };
> +
>
> chosen {
> stdout-path = "serial0";
> @@ -77,3 +95,51 @@ &uart0 {
> pinctrl-names = "default";
> status = "okay";
> };
> +
> +&i2c8 {
> + pinctrl-names = "default";
> + pinctrl-0 = <&i2c8_cfg>;
> + status = "okay";
> +
> + pmic@41 {
> + compatible = "spacemit,p1";
> + reg = <0x41>;
> + interrupts = <64>;
> + vin-supply = <®_vcc_4v>;
> +
> + regulators {
> + buck4: buck4 {
> + regulator-min-microvolt = <500000>;
> + regulator-max-microvolt = <3300000>;
> + regulator-ramp-delay = <5000>;
> + regulator-always-on;
> + };
> +
> + aldo1: aldo1 {
> + regulator-min-microvolt = <500000>;
> + regulator-max-microvolt = <3400000>;
> + regulator-boot-on;
> + regulator-always-on;
> + };
> + };
> + };
> +};
> +
> +&sdhci0 {
> + pinctrl-names = "default", "uhs";
> + pinctrl-0 = <&mmc1_cfg>;
> + pinctrl-1 = <&mmc1_uhs_cfg>;
> + bus-width = <4>;
> + cd-gpios = <&gpio K1_GPIO(80) GPIO_ACTIVE_HIGH>;
> + cd-inverted;
cd doesn't work with that on my muse pi pro. This on top fixes it though:
diff --git a/arch/riscv/boot/dts/spacemit/k1-musepi-pro.dts b/arch/riscv/boot/dts/spacemit/k1-musepi-pro.dts
index c3920fc708f51..ad68ded8dfd7e 100644
--- a/arch/riscv/boot/dts/spacemit/k1-musepi-pro.dts
+++ b/arch/riscv/boot/dts/spacemit/k1-musepi-pro.dts
@@ -396,8 +396,7 @@ &sdhci0 {
pinctrl-0 = <&mmc1_cfg>;
pinctrl-1 = <&mmc1_uhs_cfg>;
bus-width = <4>;
- cd-gpios = <&gpio K1_GPIO(80) GPIO_ACTIVE_HIGH>;
- cd-inverted;
+ cd-gpios = <&gpio K1_GPIO(80) (GPIO_ACTIVE_HIGH | GPIO_PULL_UP)>;
no-mmc;
no-sdio;
disable-wp;
> + no-mmc;
> + no-sdio;
> + disable-wp;
> + cap-sd-highspeed;
> + vmmc-supply = <&buck4>;
> + vqmmc-supply = <&aldo1>;
> + sd-uhs-sdr25;
> + sd-uhs-sdr50;
> + sd-uhs-sdr104;
> + status = "okay";
> +};
>
Thanks!
Andre
^ permalink raw reply related [flat|nested] 23+ messages in thread
* Re: [PATCH v9 0/8] riscv: spacemit: enable SD card support with UHS modes for OrangePi RV2
2026-05-11 8:53 [PATCH v9 0/8] riscv: spacemit: enable SD card support with UHS modes for OrangePi RV2 Iker Pedrosa
` (7 preceding siblings ...)
2026-05-11 8:54 ` [PATCH v9 8/8] riscv: dts: spacemit: k1-musepi-pro: " Iker Pedrosa
@ 2026-05-11 15:40 ` Ulf Hansson
8 siblings, 0 replies; 23+ messages in thread
From: Ulf Hansson @ 2026-05-11 15:40 UTC (permalink / raw)
To: Iker Pedrosa
Cc: Rob Herring, Krzysztof Kozlowski, Conor Dooley, Adrian Hunter,
Paul Walmsley, Palmer Dabbelt, Albert Ou, Alexandre Ghiti,
Yixun Lan, Ulf Hansson, Troy Mitchell, Michael Opdenacker,
Javier Martinez Canillas, linux-mmc, devicetree, linux-riscv,
spacemit, linux-kernel, Conor Dooley, Anand Moon, Trevor Gamblin,
Vincent Legoll, Margherita Milani
On Mon, 11 May 2026 at 10:54, Iker Pedrosa <ikerpedrosam@gmail.com> wrote:
>
> This series enables complete SD card support for the Spacemit K1-based
> OrangePi RV2 board, including UHS (Ultra High Speed) modes for
> high-performance SD card operation.
>
> Background
>
> The Spacemit K1 SoC includes an SDHCI controller capable of supporting
> SD cards up to UHS-I speeds (SDR104 at 208MHz). However, mainline
> currently lacks basic SD controller configuration, SDHCI driver
> enhancements for voltage switching and tuning, and power management
> infrastructure.
>
> Implementation
>
> The series enables SD card support through coordinated layers:
>
> - Hardware infrastructure (patches 1-2): Device tree bindings for voltage
> switching hardware and essential clock infrastructure.
> - SDHCI driver enhancements (patches 3-7): Regulator framework
> integration, pinctrl state switching for voltage domains, AIB register
> programming, and comprehensive SDR tuning support for reliable UHS
> operation.
> - SoC and board integration (patches 8-10): Complete K1 SoC controller
> definitions, PMIC power infrastructure, and OrangePi RV2 board enablement
> with full UHS support.
>
> This transforms the OrangePi RV2 from having no SD card support to full
> UHS-I capability, enabling high-performance storage up to 208MHz.
>
> Tested-by: Michael Opdenacker <michael.opdenacker@rootcommit.com>
> Signed-off-by: Iker Pedrosa <ikerpedrosam@gmail.com>
> ---
> Changes in v9:
> - Rebased on top of "for-next" to include required infrastructure:
> * P1 PMIC regulator definitions (commit c02c047b925c).
> * GPIO pull-up/pull-down configuration support.
> - Updated BananaPi F3 SD card detect configuration to use GPIO pull-up
> instead of "broken-cd" workaround:
> * cd-gpios = <&gpio K1_GPIO(80) (GPIO_ACTIVE_LOW | GPIO_PULL_UP)>;
> - Link to v8: https://lore.kernel.org/r/20260413-orangepi-sd-card-uhs-v8-0-c21c40ec16d0@gmail.com
Patch 1 to 4 applied for next, thanks!
Kind regards
Uffe
>
> Changes in v8:
> - Resending the series as v8. The v7 submission failed due to an SMTP
> error during transit, which resulted in a broken thread on the mailing
> list.
> - No functional changes from v7.
> - Link to v7: https://lore.kernel.org/r/20260413-orangepi-sd-card-uhs-v7-1-16650f49c022@gmail.com
>
> Changes in v7:
> - Remove sdhci-common.yaml reference from DT binding.
> - Link to v6: https://lore.kernel.org/r/20260407-orangepi-sd-card-uhs-v6-0-b5b8a1b2bfc8@gmail.com
>
> Changes in v6:
> - Add pinctrl support for voltage switching. Document optional
> pinctrl-names property supporting "default" and "uhs" pinctrl states
> for coordinating pin configuration changes during UHS-I voltage
> switching.
> - Update pinctrl state naming from "state_uhs" to "uhs" to match DT
> binding naming convention.
> - Fix MMC drive strength values based on vendor kernel investigation.
> Correct 3.3V operation from 7mA to 19mA and 1.8V UHS operation from
> 13mA to 42mA to match proven vendor implementation.
> - Link to v5: https://lore.kernel.org/r/20260330-orangepi-sd-card-uhs-v5-0-bd853604322d@gmail.com
>
> Changes in v5:
> - Document optional pinctrl-names property supporting "default" and
> "state_uhs" pinctrl states for coordinating pin configuration changes
> during UHS-I voltage switching.
> - Link to v4: https://lore.kernel.org/r/20260323-orangepi-sd-card-uhs-v4-0-567c9775fd0e@gmail.com
>
> Changes in v4:
> - Revert to start_signal_voltage_switch() approach for bidirectional
> voltage switching: replace voltage_switch() callback with
> start_signal_voltage_switch() to properly handle both 3.3V and 1.8V
> signal voltage directions.
> - Fix DC input voltage specification: corrected the main power supply
> from 12V to 5V to match the OrangePi RV2 board specifications. The
> board uses a 5V USB-C input connector, not a 12V rail as previously
> specified in the device tree.
> - k1-bananapi-f3.dts: add `broken-cd` property to work around card
> detection. Using `broken-cd` disables hotplug detection but keeps SD
> card functionality working without additional dependencies.
> - Add SD card support for Muse Pi Pro board (contributed by Trevor
> Gamblin): enable SD card support with UHS-I capabilities following the
> same pattern as OrangePi RV2, including dual pinctrl states, PMIC
> power supplies, and card detection.
> - Link to v3: https://lore.kernel.org/r/20260316-orangepi-sd-card-uhs-v3-0-aefd3b7832df@gmail.com
>
> Changes in v3:
> - Rebase on mmc.git/next to resolve conflicts with "mmc: sdhci-of-k1:
> add reset support" patch.
> - Squash tuning infrastructure and implementation patches (3 and 4)
> together to form complete functionality and avoid unused function
> warnings.
> - Reduce code nesting: implemented an early return sanity check in
> spacemit_sdhci_voltage_switch() to reduce indentation and improve
> logic flow.
> - Refactor pinctrl initialization: moved pinctrl resource acquisition
> and state lookup into a dedicated helper function,
> spacemit_sdhci_get_pins().
> - Use generic regulator node names (buck4, aldo1) instead of
> device-specific aliases (sd_vmmc, sd_vqmmc) to better reflect that
> these PMIC outputs serve multiple devices.
> - Remove dead code handling 3.3V voltage switching from
> spacemit_sdhci_voltage_switch().
> - Optimize tuning algorithm to use single-pass window detection instead
> of storing results in array, reducing memory usage and complexity.
> - Remove unnecessary card detect check in execute_tuning() - rely on MMC
> core.
> - Clarify commit message to mention both SD (UHS-I) and eMMC (HS200)
> tuning support.
> - Add SD card support for Banana Pi BPI-F3 board with UHS-I capabilities
> following the same pattern as OrangePi RV2.
> - Link to v2: https://lore.kernel.org/r/20260309-orangepi-sd-card-uhs-v2-0-5bb2b574df5d@gmail.com
>
> Changes in v2:
> - Removed custom AIB voltage switching code per maintainer feedback. The
> existing pinctrl driver already handles AIB voltage switching
> automatically via power-source property changes during UHS mode
> transitions. This eliminates code duplication.
> - Squashed regulator and pinctrl commits into single voltage switching
> implementation.
> - Moved voltage switching callback from dynamic probe assignment to
> static sdhci_ops declaration. Removed redundant SDHCI core call since
> the framework handles standard voltage switching automatically.
> - Made clock override (SDHC_OVRRD_CLK_OEN | SDHC_FORCE_CLK_ON)
> conditional for SD/SDIO cards only. This follows vendor driver pattern
> of differentiating SD and eMMC card handling.
> - Include no-mmc property for SD card.
> - Link to v1: https://lore.kernel.org/r/20260302-orangepi-sd-card-uhs-v1-0-89c219973c0c@gmail.com
>
> ---
> Iker Pedrosa (7):
> dt-bindings: mmc: spacemit,sdhci: add pinctrl support for voltage switching
> mmc: sdhci-of-k1: enable essential clock infrastructure for SD operation
> mmc: sdhci-of-k1: add regulator and pinctrl voltage switching support
> mmc: sdhci-of-k1: add comprehensive SDR tuning support
> riscv: dts: spacemit: k1: add SD card controller and pinctrl support
> riscv: dts: spacemit: k1-orangepi-rv2: add SD card support with UHS modes
> riscv: dts: spacemit: k1-bananapi-f3: add SD card support with UHS modes
>
> Trevor Gamblin (1):
> riscv: dts: spacemit: k1-musepi-pro: add SD card support with UHS modes
>
> .../devicetree/bindings/mmc/spacemit,sdhci.yaml | 15 ++
> arch/riscv/boot/dts/spacemit/k1-bananapi-f3.dts | 22 +-
> arch/riscv/boot/dts/spacemit/k1-musepi-pro.dts | 66 ++++++
> arch/riscv/boot/dts/spacemit/k1-orangepi-rv2.dts | 21 +-
> arch/riscv/boot/dts/spacemit/k1-pinctrl.dtsi | 40 ++++
> arch/riscv/boot/dts/spacemit/k1.dtsi | 13 ++
> drivers/mmc/host/sdhci-of-k1.c | 257 +++++++++++++++++++++
> 7 files changed, 431 insertions(+), 3 deletions(-)
> ---
> base-commit: f068b204555ad62d6a841a49feb4ea8c4f45b25c
> change-id: 20260226-orangepi-sd-card-uhs-0ecb05839b0c
>
> Best regards,
> --
> Iker Pedrosa <ikerpedrosam@gmail.com>
>
^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: [PATCH v9 7/8] riscv: dts: spacemit: k1-bananapi-f3: add SD card support with UHS modes
2026-05-11 8:54 ` [PATCH v9 7/8] riscv: dts: spacemit: k1-bananapi-f3: " Iker Pedrosa
@ 2026-05-11 16:55 ` Aurelien Jarno
2026-05-12 3:32 ` sashiko-bot
2026-05-12 5:43 ` Yixun Lan
2 siblings, 0 replies; 23+ messages in thread
From: Aurelien Jarno @ 2026-05-11 16:55 UTC (permalink / raw)
To: Iker Pedrosa
Cc: Rob Herring, Krzysztof Kozlowski, Conor Dooley, Adrian Hunter,
Paul Walmsley, Palmer Dabbelt, Albert Ou, Alexandre Ghiti,
Yixun Lan, Ulf Hansson, devicetree, Margherita Milani,
Michael Opdenacker, Troy Mitchell, linux-mmc,
Javier Martinez Canillas, linux-kernel, linux-riscv, spacemit
On 2026-05-11 10:54, Iker Pedrosa wrote:
> Add complete SD card controller support with UHS high-speed modes.
>
> - Enable sdhci0 controller with 4-bit bus width
> - Configure card detect GPIO with inversion
> - Connect vmmc-supply to buck4 for 3.3V card power
> - Connect vqmmc-supply to aldo1 for 1.8V/3.3V I/O switching
> - Add dual pinctrl states for voltage-dependent pin configuration
> - Support UHS-I SDR25, SDR50, and SDR104 modes
>
> This enables full SD card functionality including high-speed UHS modes
> for improved performance.
>
> Suggested-by: Anand Moon <linux.amoon@gmail.com>
> Tested-by: Anand Moon <linux.amoon@gmail.com>
> Tested-by: Margherita Milani <margherita.milani@amarulasolutions.com>
> Signed-off-by: Iker Pedrosa <ikerpedrosam@gmail.com>
> ---
> arch/riscv/boot/dts/spacemit/k1-bananapi-f3.dts | 22 ++++++++++++++++++++--
> 1 file changed, 20 insertions(+), 2 deletions(-)
>
Thanks for including the card detect change.
Tested-by: Aurelien Jarno <aurelien@aurel32.net>
Reviewed-by: Aurelien Jarno <aurelien@aurel32.net>
--
Aurelien Jarno GPG: 4096R/1DDD8C9B
aurelien@aurel32.net http://aurel32.net
^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: [PATCH v9 1/8] dt-bindings: mmc: spacemit,sdhci: add pinctrl support for voltage switching
2026-05-11 8:53 ` [PATCH v9 1/8] dt-bindings: mmc: spacemit,sdhci: add pinctrl support for voltage switching Iker Pedrosa
@ 2026-05-12 1:01 ` sashiko-bot
0 siblings, 0 replies; 23+ messages in thread
From: sashiko-bot @ 2026-05-12 1:01 UTC (permalink / raw)
To: Iker Pedrosa; +Cc: devicetree, conor+dt, robh, krzk+dt
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] The commit message documents the UHS pinctrl state as `state_uhs`, but the YAML schema defines and enforces `uhs`.
--
commit 9737b985fb2ae6422b14964720c1ea756e86a00f
Author: Iker Pedrosa <ikerpedrosam@gmail.com>
dt-bindings: mmc: spacemit,sdhci: add pinctrl support for voltage switching
This commit documents pinctrl properties to support voltage-dependent pin
configuration switching for UHS-I SD card modes.
> Add optional pinctrl-names property with two states:
> - "default": For 3.3V operation with standard drive strength
> - "state_uhs": For 1.8V operation with optimized drive strength
Is state_uhs the intended name for this pinctrl state? The YAML schema
introduced in this patch restricts the second item in pinctrl-names to uhs,
and uses uhs in both the examples and property descriptions.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260511-orangepi-sd-card-uhs-v9-0-ae48c0b2b2cf@gmail.com?part=1
^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: [PATCH v9 2/8] mmc: sdhci-of-k1: enable essential clock infrastructure for SD operation
2026-05-11 8:53 ` [PATCH v9 2/8] mmc: sdhci-of-k1: enable essential clock infrastructure for SD operation Iker Pedrosa
@ 2026-05-12 1:13 ` sashiko-bot
0 siblings, 0 replies; 23+ messages in thread
From: sashiko-bot @ 2026-05-12 1:13 UTC (permalink / raw)
To: Iker Pedrosa; +Cc: conor+dt, devicetree, krzk+dt, robh
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [Medium] Incorrect condition used for targeting removable card scenarios, leading to power regressions for SDIO devices.
- [Medium] Missing explicit clear of SD-specific vendor overrides for non-SD controllers.
--
commit acf2ed5de9b1d692d653b998c6c50d3cddd4cff5
Author: Iker Pedrosa <ikerpedrosam@gmail.com>
mmc: sdhci-of-k1: enable essential clock infrastructure for SD operation
This commit enables clock generation for SD operation on the spacemit
sdhci-of-k1 controller. It sets SDHC_GEN_PAD_CLK_ON for all modes and
conditionally overrides automatic clock gating for SD-only controllers
to handle removable card scenarios.
> diff --git a/drivers/mmc/host/sdhci-of-k1.c b/drivers/mmc/host/sdhci-of-k1.c
> index 455656f9842df..0dd06fc19b857 100644
> --- a/drivers/mmc/host/sdhci-of-k1.c
> +++ b/drivers/mmc/host/sdhci-of-k1.c
[ ... ]
> @@ -101,6 +108,12 @@ static void spacemit_sdhci_reset(struct sdhci_host *host, u8 mask)
>
> if (!(host->mmc->caps2 & MMC_CAP2_NO_MMC))
> spacemit_sdhci_setbits(host, SDHC_MMC_CARD_MODE, SPACEMIT_SDHC_MMC_CTRL_REG);
> +
> + spacemit_sdhci_setbits(host, SDHC_GEN_PAD_CLK_ON, SPACEMIT_SDHC_LEGACY_CTRL_REG);
> +
> + if (host->mmc->caps2 & MMC_CAP2_NO_MMC)
> + spacemit_sdhci_setbits(host, SDHC_OVRRD_CLK_OEN | SDHC_FORCE_CLK_ON,
> + SPACEMIT_SDHC_OP_EXT_REG);
> }
The commit message states that the SD-specific clock overrides are intended
to handle removable card scenarios. Does checking for MMC_CAP2_NO_MMC
unintentionally apply these overrides to non-removable SDIO devices?
The MMC_CAP2_NO_MMC flag indicates the absence of eMMC support, which will
evaluate to true for both removable SD cards and non-removable SDIO modules
like Wi-Fi chips.
If the clock is forced to remain continuously on for SDIO devices, could this
override automatic clock gating and cause a power regression by preventing
deep sleep states?
Additionally, does this setup leave the vendor-specific clock overrides active
on eMMC interfaces if they were previously set by a bootloader?
Since SPACEMIT_SDHC_OP_EXT_REG is a vendor-specific register located at offset
0x108, it is typically untouched by the standard SDHCI_RESET_ALL mechanism.
If a prior execution stage leaves SDHC_OVRRD_CLK_OEN or SDHC_FORCE_CLK_ON set,
the absence of an explicit clear in this path could prevent automatic clock
gating on eMMC interfaces.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260511-orangepi-sd-card-uhs-v9-0-ae48c0b2b2cf@gmail.com?part=2
^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: [PATCH v9 3/8] mmc: sdhci-of-k1: add regulator and pinctrl voltage switching support
2026-05-11 8:53 ` [PATCH v9 3/8] mmc: sdhci-of-k1: add regulator and pinctrl voltage switching support Iker Pedrosa
@ 2026-05-12 2:01 ` sashiko-bot
0 siblings, 0 replies; 23+ messages in thread
From: sashiko-bot @ 2026-05-12 2:01 UTC (permalink / raw)
To: Iker Pedrosa; +Cc: conor+dt, krzk+dt, devicetree, robh
Thank you for your contribution! Sashiko AI review found 6 potential issue(s) to consider:
- [High] Passing a NULL state pointer to pinctrl_select_state() causes a kernel panic.
- [High] Swallowing -EPROBE_DEFER from devm_pinctrl_get() permanently breaks UHS-I voltage switching.
- [Medium] Masking failures from pinctrl_select_state() can lead to data corruption or hardware damage.
- [Medium] Switching back to 3.3V executes the regulator switch before configuring the IO pads, risking overvoltage.
- [Low] The code uses "uhs" for the pinctrl state name instead of the standard "state_uhs" specified in the commit message.
- [Low] Unsupported signal voltages log a warning but falsely return success.
--
commit 54952d6d0a322262708a9ecada7a38d6245d7b6c
Author: Iker Pedrosa <ikerpedrosam@gmail.com>
mmc: sdhci-of-k1: add regulator and pinctrl voltage switching support
This commit adds voltage switching infrastructure for UHS-I modes by integrating
both the regulator framework for supply voltage control and pinctrl state
switching for pin drive strength optimization.
> - Add optional pinctrl state switching between "default" (3.3V) and
> "state_uhs" (1.8V) configurations
This isn't a bug, but the commit message mentions "state_uhs" while the
code below looks for "uhs". Which one is expected by the device tree bindings?
> diff --git a/drivers/mmc/host/sdhci-of-k1.c b/drivers/mmc/host/sdhci-of-k1.c
> --- a/drivers/mmc/host/sdhci-of-k1.c
> +++ b/drivers/mmc/host/sdhci-of-k1.c
[ ... ]
> @@ -219,6 +223,46 @@ static void spacemit_sdhci_pre_hs400_to_hs200(struct mmc_host *mmc)
> static int spacemit_sdhci_start_signal_voltage_switch(struct mmc_host *mmc,
> struct mmc_ios *ios)
> {
> struct sdhci_host *host = mmc_priv(mmc);
> struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host);
> struct spacemit_sdhci_host *sdhst = sdhci_pltfm_priv(pltfm_host);
> struct pinctrl_state *state;
> int ret;
>
> ret = sdhci_start_signal_voltage_switch(mmc, ios);
> if (ret)
> return ret;
For transitions to 3.3V, sdhci_start_signal_voltage_switch() will increase
the vqmmc regulator voltage to 3.3V and wait 5ms for it to stabilize.
Because the pinctrl state is updated later in this function, the pads
will remain configured for 1.8V during this time.
Could this overvoltage stress the pads? Should the pinctrl state be
updated to "default" before raising the regulator voltage?
>
> if (!sdhst->pinctrl)
> return 0;
>
> /* Select appropriate pinctrl state based on signal voltage */
> switch (ios->signal_voltage) {
> case MMC_SIGNAL_VOLTAGE_330:
> state = sdhst->pinctrl_default;
> break;
> case MMC_SIGNAL_VOLTAGE_180:
> state = sdhst->pinctrl_uhs;
> break;
> default:
> dev_warn(mmc_dev(mmc), "unsupported voltage %d\n", ios->signal_voltage);
> return 0;
If the voltage is unsupported, should this return an error like -EINVAL
instead of 0? Returning 0 tells the mmc core the transition was successful.
> }
>
> ret = pinctrl_select_state(sdhst->pinctrl, state);
spacemit_sdhci_get_pins() treats the pinctrl states as optional and leaves
them as null if they aren't found in the device tree.
Does pinctrl_select_state() handle a null state pointer safely?
Looking at the pinctrl subsystem, it appears to unconditionally dereference
the state pointer. Should there be a check like if (!state) before calling
pinctrl_select_state() to avoid a panic?
> if (ret) {
> dev_warn(mmc_dev(mmc), "failed to select pinctrl state: %d\n", ret);
> return 0;
> }
If selecting the pinctrl state fails, returning 0 masks the failure and
tells the mmc core the pad configuration succeeded.
If the controller switches to 1.8V but the pads remain at 3.3V, could
this lead to data corruption or electrical damage? Should this return the
negative error code instead?
> dev_dbg(mmc_dev(mmc), "switched to %s pinctrl state\n",
> ios->signal_voltage == MMC_SIGNAL_VOLTAGE_180 ? "UHS" : "default");
>
> return 0;
> }
[ ... ]
> @@ -252,6 +296,30 @@ static inline int spacemit_sdhci_get_resets(struct device *dev)
> static inline void spacemit_sdhci_get_pins(struct device *dev,
> struct sdhci_pltfm_host *pltfm_host)
> {
> struct spacemit_sdhci_host *sdhst = sdhci_pltfm_priv(pltfm_host);
>
> sdhst->pinctrl = devm_pinctrl_get(dev);
> if (IS_ERR(sdhst->pinctrl)) {
> sdhst->pinctrl = NULL;
> dev_dbg(dev, "pinctrl not available, voltage switching will work without it\n");
> return;
> }
If the pin controller hasn't probed yet, devm_pinctrl_get() will return
-EPROBE_DEFER.
By swallowing this error and setting pinctrl to null, the host will
register without pinctrl support and UHS-I modes will permanently lack
correct pad configuration.
Should this propagate -EPROBE_DEFER back to spacemit_sdhci_probe() instead
of returning void?
>
> sdhst->pinctrl_default = pinctrl_lookup_state(sdhst->pinctrl, "default");
> if (IS_ERR(sdhst->pinctrl_default))
> sdhst->pinctrl_default = NULL;
>
> sdhst->pinctrl_uhs = pinctrl_lookup_state(sdhst->pinctrl, "uhs");
Does looking for "uhs" correctly match the expected device tree bindings?
The commit message states "state_uhs", and standard mmc bindings typically
use "state_uhs" as well.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260511-orangepi-sd-card-uhs-v9-0-ae48c0b2b2cf@gmail.com?part=3
^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: [PATCH v9 5/8] riscv: dts: spacemit: k1: add SD card controller and pinctrl support
2026-05-11 8:54 ` [PATCH v9 5/8] riscv: dts: spacemit: k1: add SD card controller and pinctrl support Iker Pedrosa
@ 2026-05-12 2:47 ` sashiko-bot
0 siblings, 0 replies; 23+ messages in thread
From: sashiko-bot @ 2026-05-12 2:47 UTC (permalink / raw)
To: Iker Pedrosa; +Cc: robh, conor+dt, krzk+dt, devicetree
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [Low] DT Node Sorting Violation in k1.dtsi
- [Low] Hardware Semantic Mismatch / Undocumented Hardware Quirk
--
commit b041436345c6321304b2ed59c04953c7c67e6e5f
Author: Iker Pedrosa <ikerpedrosam@gmail.com>
riscv: dts: spacemit: k1: add SD card controller and pinctrl support
This commit adds the SD card controller infrastructure for the SpacemiT
K1 SoC. It includes the sdhci0 controller definition along with the
corresponding mmc1 pinctrl configurations for standard and UHS modes.
> Add sdhci0 controller definition with clocks, resets and interrupts
> Add mmc1_cfg pinctrl for 3.3V standard SD operation
Does this hardware route the SDH0 controller logic to the MMC1 physical
pads?
Since the patch defines the sdhci0 controller (using base address
0xd4280000, CLK_SDH0, and RESET_SDH0) but adds pinctrl configurations
referencing mmc1_* pins, it appears there might be a cross-routing
hardware quirk.
Could this counter-intuitive hardware behavior be explicitly documented
in the commit message or through inline comments to prevent future
maintainability confusion?
> diff --git a/arch/riscv/boot/dts/spacemit/k1.dtsi b/arch/riscv/boot/dts/spacemit/k1.dtsi
> index 24becab4c9594..6ded5c06b7975 100644
> --- a/arch/riscv/boot/dts/spacemit/k1.dtsi
> +++ b/arch/riscv/boot/dts/spacemit/k1.dtsi
[ ... ]
> @@ -1226,6 +1226,19 @@ emmc: mmc@d4281000 {
> interrupts = <101>;
> status = "disabled";
> };
> +
> + sdhci0: mmc@d4280000 {
This isn't a bug, but should the sdhci0 node be placed before the
emmc node?
Device tree conventions dictate that nodes should be ordered by their
unit-address in ascending order, so mmc@d4280000 would typically come
before mmc@d4281000 in the storage-bus node.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260511-orangepi-sd-card-uhs-v9-0-ae48c0b2b2cf@gmail.com?part=5
^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: [PATCH v9 6/8] riscv: dts: spacemit: k1-orangepi-rv2: add SD card support with UHS modes
2026-05-11 8:54 ` [PATCH v9 6/8] riscv: dts: spacemit: k1-orangepi-rv2: add SD card support with UHS modes Iker Pedrosa
@ 2026-05-12 3:20 ` sashiko-bot
0 siblings, 0 replies; 23+ messages in thread
From: sashiko-bot @ 2026-05-12 3:20 UTC (permalink / raw)
To: Iker Pedrosa; +Cc: conor+dt, devicetree, robh, krzk+dt
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [High] `vmmc-supply` is mapped to an always-on regulator (`buck4_3v3`) while enabling UHS modes (`sd-uhs-sdr*`), which will break SD card initialization after a warm reboot or driver reset.
- [Low] The device tree specifies `cd-gpios = <&gpio K1_GPIO(80) GPIO_ACTIVE_HIGH>;` alongside the `cd-inverted;` property, creating an ambiguous double-inversion.
--
commit b95f288bf0d85d42bac4ccd6d594e14cf818a232
Author: Iker Pedrosa <ikerpedrosam@gmail.com>
riscv: dts: spacemit: k1-orangepi-rv2: add SD card support with UHS modes
Add complete SD card controller support with UHS high-speed modes,
including configuring the card detect GPIO and connecting the vmmc and
vqmmc supplies.
> diff --git a/arch/riscv/boot/dts/spacemit/k1-orangepi-rv2.dts b/arch/riscv/boot/dts/spacemit/k1-orangepi-rv2.dts
> index c95ca38e3d4a1..1ed76e0ff8064 100644
> --- a/arch/riscv/boot/dts/spacemit/k1-orangepi-rv2.dts
> +++ b/arch/riscv/boot/dts/spacemit/k1-orangepi-rv2.dts
[ ... ]
> +&sdhci0 {
> + pinctrl-names = "default", "uhs";
> + pinctrl-0 = <&mmc1_cfg>;
> + pinctrl-1 = <&mmc1_uhs_cfg>;
> + bus-width = <4>;
> + cd-gpios = <&gpio K1_GPIO(80) GPIO_ACTIVE_HIGH>;
> + cd-inverted;
This isn't a bug, but does this create a confusing double-inversion?
According to the MMC bindings, if a GPIO is used for card detect, its
polarity should be natively described in the phandle flag (e.g.,
GPIO_ACTIVE_LOW) and cd-inverted should be omitted. Combining
GPIO_ACTIVE_HIGH with cd-inverted forces the MMC core to perform an XOR
logic.
Would it be better to just use GPIO_ACTIVE_LOW and drop cd-inverted?
> + no-mmc;
> + no-sdio;
> + disable-wp;
> + cap-sd-highspeed;
> + vmmc-supply = <&buck4_3v3>;
Will this cause SD card initialization to fail after a warm reboot?
UHS modes require switching the SD card's signaling voltage from 3.3V to
1.8V. Since there is no software command to revert a card from 1.8V back
to 3.3V, it strictly requires a full physical power cycle.
However, if buck4_3v3 is configured with regulator-always-on elsewhere
in the device tree, mmc_power_cycle() will silently fail to cut the
physical power. After a warm reboot or driver error recovery, the host
controller will reset to 3.3V while the card remains stuck expecting
1.8V signaling.
If the hardware lacks a load switch to toggle the SD slot power, should
the UHS modes be disabled to prevent this?
> + vqmmc-supply = <&aldo1>;
> + sd-uhs-sdr25;
> + sd-uhs-sdr50;
> + sd-uhs-sdr104;
> + status = "okay";
> +};
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260511-orangepi-sd-card-uhs-v9-0-ae48c0b2b2cf@gmail.com?part=6
^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: [PATCH v9 7/8] riscv: dts: spacemit: k1-bananapi-f3: add SD card support with UHS modes
2026-05-11 8:54 ` [PATCH v9 7/8] riscv: dts: spacemit: k1-bananapi-f3: " Iker Pedrosa
2026-05-11 16:55 ` Aurelien Jarno
@ 2026-05-12 3:32 ` sashiko-bot
2026-05-12 5:43 ` Yixun Lan
2 siblings, 0 replies; 23+ messages in thread
From: sashiko-bot @ 2026-05-12 3:32 UTC (permalink / raw)
To: Iker Pedrosa; +Cc: conor+dt, robh, krzk+dt, devicetree
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] Enabling UHS-I modes with an `always-on` VMMC regulator prevents proper SD card resets, breaking soft reboots and driver rebinds.
--
commit da601a14dc433b25fd35c0c4098f9e5dcb5faea3
Author: Iker Pedrosa <ikerpedrosam@gmail.com>
riscv: dts: spacemit: k1-bananapi-f3: add SD card support with UHS modes
This commit enables the sdhci0 controller on the Banana Pi BPI-F3 with
high-speed UHS modes, wiring up the vmmc and vqmmc supplies.
> diff --git a/arch/riscv/boot/dts/spacemit/k1-bananapi-f3.dts b/arch/riscv/boot/dts/spacemit/k1-bananapi-f3.dts
> index e20daa50a152f..8fea6e87acec8 100644
> --- a/arch/riscv/boot/dts/spacemit/k1-bananapi-f3.dts
> +++ b/arch/riscv/boot/dts/spacemit/k1-bananapi-f3.dts
> @@ -221,7 +221,7 @@ buck3_1v8: buck3 {
> regulator-always-on;
> };
>
> - buck4 {
> + buck4: buck4 {
> regulator-min-microvolt = <500000>;
> regulator-max-microvolt = <3300000>;
> regulator-ramp-delay = <5000>;
[ ... ]
> @@ -374,3 +374,21 @@ hub_3_0: hub@2 {
> reset-gpios = <&gpio K1_GPIO(124) GPIO_ACTIVE_LOW>;
> };
> };
> +
> +&sdhci0 {
> + pinctrl-names = "default", "uhs";
> + pinctrl-0 = <&mmc1_cfg>;
> + pinctrl-1 = <&mmc1_uhs_cfg>;
> + bus-width = <4>;
> + cd-gpios = <&gpio K1_GPIO(80) (GPIO_ACTIVE_LOW | GPIO_PULL_UP)>;
> + no-mmc;
> + no-sdio;
> + disable-wp;
> + cap-sd-highspeed;
> + vmmc-supply = <&buck4>;
> + vqmmc-supply = <&aldo1>;
> + sd-uhs-sdr25;
> + sd-uhs-sdr50;
> + sd-uhs-sdr104;
Could enabling UHS-I modes here introduce a regression during soft reboots
or driver unbind and rebind cycles if buck4 is an always-on regulator?
When UHS-I is negotiated, the SD card switches to 1.8V signaling. The SD
physical layer specification dictates that resetting an SD card from 1.8V
mode back to the default 3.3V mode requires dropping the main VDD supply
(vmmc) to 0V.
Since buck4 is configured with regulator-always-on, the regulator framework
will not physically disable the supply when mmc_power_off() requests it.
This could leave the SD card stuck in 1.8V mode during a soft reboot,
preventing the host from communicating during the initial 3.3V sequence
and causing initialization to fail.
Should regulator-always-on be removed from buck4 if it isn't shared with
other always-on components, or should UHS modes be omitted if the regulator
must remain on?
> + status = "okay";
> +};
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260511-orangepi-sd-card-uhs-v9-0-ae48c0b2b2cf@gmail.com?part=7
^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: [PATCH v9 8/8] riscv: dts: spacemit: k1-musepi-pro: add SD card support with UHS modes
2026-05-11 8:54 ` [PATCH v9 8/8] riscv: dts: spacemit: k1-musepi-pro: " Iker Pedrosa
2026-05-11 11:43 ` Andre Heider
@ 2026-05-12 3:48 ` sashiko-bot
2026-05-12 5:20 ` Yixun Lan
2 siblings, 0 replies; 23+ messages in thread
From: sashiko-bot @ 2026-05-12 3:48 UTC (permalink / raw)
To: Iker Pedrosa; +Cc: robh, devicetree, conor+dt, krzk+dt
Thank you for your contribution! Sashiko AI review found 5 potential issue(s) to consider:
- [High] Incorrect PMIC parent supply bindings (`vin-supply` instead of `vinX-supply`).
- [High] Using `regulator-always-on` for SD card supplies breaks UHS soft reset/recovery.
- [Medium] Excessively broad voltage constraints for SD card regulators.
- [Low] Dead Code: Unreferenced `reg_dc_in` fixed regulator.
- [Low] Ambiguous Devicetree Pattern: `cd-inverted` combined with `GPIO_ACTIVE_HIGH`.
--
commit ba761ed57c645870aad2395144a4d7a3530a081d
Author: Trevor Gamblin <tgamblin@baylibre.com>
riscv: dts: spacemit: k1-musepi-pro: add SD card support with UHS modes
Update the Muse Pi Pro devicetree with SD card support to match what
was done for the OrangePi RV2.
Link: https://lore.kernel.org/linux-riscv/20260316-orangepi-sd-card-uhs-v3-0-aefd3b7832df@gmail.com/T/#
> diff --git a/arch/riscv/boot/dts/spacemit/k1-musepi-pro.dts b/arch/riscv/boot/dts/spacemit/k1-musepi-pro.dts
> index 29e333b670cf0..774a4640f0656 100644
> --- a/arch/riscv/boot/dts/spacemit/k1-musepi-pro.dts
> +++ b/arch/riscv/boot/dts/spacemit/k1-musepi-pro.dts
> @@ -18,6 +18,24 @@ aliases {
> ethernet0 = ð0;
> serial0 = &uart0;
> };
> + reg_dc_in: dc-in-5v {
> + compatible = "regulator-fixed";
> + regulator-name = "dc_in_5v";
> + regulator-min-microvolt = <5000000>;
> + regulator-max-microvolt = <5000000>;
> + regulator-boot-on;
> + regulator-always-on;
> + };
Is this fixed regulator used anywhere? It does not appear to be referenced
as a supply by any other node in this device tree.
[ ... ]
> +&i2c8 {
> + pinctrl-names = "default";
> + pinctrl-0 = <&i2c8_cfg>;
> + status = "okay";
> +
> + pmic@41 {
> + compatible = "spacemit,p1";
> + reg = <0x41>;
> + interrupts = <64>;
> + vin-supply = <®_vcc_4v>;
Will the regulator framework fail to resolve the parent supply here? The
spacemit-p1 regulator driver and bindings seem to require specific parent
supply names for each regulator group (e.g., vin4-supply for buck4 and
aldoin-supply for aldo1) rather than a generic vin-supply property.
> +
> + regulators {
> + buck4: buck4 {
> + regulator-min-microvolt = <500000>;
Does this constraint allow the voltage to drop below the safe operating
area for the connected hardware? SD cards typically require exactly 3.3V
for VMMC, so allowing 0.5V could potentially cause brownouts.
> + regulator-max-microvolt = <3300000>;
> + regulator-ramp-delay = <5000>;
> + regulator-always-on;
Will this prevent the MMC subsystem from properly resetting the SD card
during a soft reboot or initialization error recovery?
For UHS-I modes, the SD card switches to 1.8V signaling. To reset the card
back to 3.3V, the MMC core calls mmc_power_off() to power cycle the
vmmc-supply. If the regulator is marked as always-on, the disable request
is ignored, which can leave the card stuck in 1.8V mode.
> + };
> +
> + aldo1: aldo1 {
> + regulator-min-microvolt = <500000>;
Similarly, does this minimum voltage constraint need to be tighter for
the VQMMC supply, which usually operates between 1.8V and 3.3V?
> + regulator-max-microvolt = <3400000>;
> + regulator-boot-on;
> + regulator-always-on;
Does this always-on constraint also prevent the I/O power supply from
being properly managed during card power cycles?
> + };
> + };
> + };
> +};
> +
> +&sdhci0 {
> + pinctrl-names = "default", "uhs";
> + pinctrl-0 = <&mmc1_cfg>;
> + pinctrl-1 = <&mmc1_uhs_cfg>;
> + bus-width = <4>;
> + cd-gpios = <&gpio K1_GPIO(80) GPIO_ACTIVE_HIGH>;
> + cd-inverted;
This isn't a bug, but could the hardware polarity be encoded directly into
the GPIO specifier using GPIO_ACTIVE_LOW instead? The modern device tree
practice is to drop the cd-inverted property to avoid the ambiguous double
inversion.
[ ... ]
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260511-orangepi-sd-card-uhs-v9-0-ae48c0b2b2cf@gmail.com?part=8
^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: [PATCH v9 8/8] riscv: dts: spacemit: k1-musepi-pro: add SD card support with UHS modes
2026-05-11 8:54 ` [PATCH v9 8/8] riscv: dts: spacemit: k1-musepi-pro: " Iker Pedrosa
2026-05-11 11:43 ` Andre Heider
2026-05-12 3:48 ` sashiko-bot
@ 2026-05-12 5:20 ` Yixun Lan
2 siblings, 0 replies; 23+ messages in thread
From: Yixun Lan @ 2026-05-12 5:20 UTC (permalink / raw)
To: Iker Pedrosa
Cc: Rob Herring, Krzysztof Kozlowski, Conor Dooley, Adrian Hunter,
Paul Walmsley, Palmer Dabbelt, Albert Ou, Alexandre Ghiti,
Ulf Hansson, Troy Mitchell, Michael Opdenacker,
Javier Martinez Canillas, linux-mmc, devicetree, linux-riscv,
spacemit, linux-kernel, Trevor Gamblin
Hi Iker, Trevor,
On 10:54 Mon 11 May , Iker Pedrosa wrote:
> From: Trevor Gamblin <tgamblin@baylibre.com>
>
> Update the Muse Pi Pro devicetree with SD card support to match what
> was done for the OrangePi RV2 in [1]. More precisely:
>
> - Enable sdhci0 controller with 4-bit bus width
> - Configure card detect GPIO with inversion
> - Connect vmmc-supply to buck4 for 3.3V card power
> - Connect vqmmc-supply to aldo1 for 1.8V/3.3V I/O switching
> - Add dual pinctrl states for voltage-dependent pin configuration
> - Support UHS-I SDR25, SDR50, and SDR104 modes
>
> [1] https://lore.kernel.org/linux-riscv/20260316-orangepi-sd-card-uhs-v3-0-aefd3b7832df@gmail.com/T/#
>
> Signed-off-by: Trevor Gamblin <tgamblin@baylibre.com>
> Signed-off-by: Iker Pedrosa <ikerpedrosam@gmail.com>
> ---
> arch/riscv/boot/dts/spacemit/k1-musepi-pro.dts | 66 ++++++++++++++++++++++++++
> 1 file changed, 66 insertions(+)
>
> diff --git a/arch/riscv/boot/dts/spacemit/k1-musepi-pro.dts b/arch/riscv/boot/dts/spacemit/k1-musepi-pro.dts
> index 29e333b670cf..774a4640f065 100644
> --- a/arch/riscv/boot/dts/spacemit/k1-musepi-pro.dts
> +++ b/arch/riscv/boot/dts/spacemit/k1-musepi-pro.dts
> @@ -18,6 +18,24 @@ aliases {
> ethernet0 = ð0;
> serial0 = &uart0;
> };
Add one blank line here, but see comment below..
> + reg_dc_in: dc-in-5v {
> + compatible = "regulator-fixed";
> + regulator-name = "dc_in_5v";
> + regulator-min-microvolt = <5000000>;
> + regulator-max-microvolt = <5000000>;
> + regulator-boot-on;
> + regulator-always-on;
> + };
reg_dc_in is not used, drop it, for the reason, see recent discussion of
this thread here[1][2], especially refer to Krzysztof's original comment
https://lore.kernel.org/all/6530526f-59ca-4753-a068-46c62a1a1fed@kernel.org/ [1]
https://lore.kernel.org/all/20260511065338-GKA3624147@kernel.org/ [2]
> +
> + reg_vcc_4v: vcc-4v {
> + compatible = "regulator-fixed";
> + regulator-name = "vcc_4v";
> + regulator-min-microvolt = <4000000>;
> + regulator-max-microvolt = <4000000>;
> + regulator-boot-on;
> + regulator-always-on;
> + };
> +
>
> chosen {
> stdout-path = "serial0";
> @@ -77,3 +95,51 @@ &uart0 {
> pinctrl-names = "default";
> status = "okay";
> };
> +
> +&i2c8 {
> + pinctrl-names = "default";
> + pinctrl-0 = <&i2c8_cfg>;
> + status = "okay";
> +
> + pmic@41 {
> + compatible = "spacemit,p1";
> + reg = <0x41>;
> + interrupts = <64>;
..
> + vin-supply = <®_vcc_4v>;
This should be adjusted, please check schematics as I haven't done it
myself, for reason behind please refer to this patch (which was merged
in v7.1)
http://lore.kernel.org/r/20260206-spacemit-p1-v4-1-8f695d93811e@riscstar.com
> +
> + regulators {
> + buck4: buck4 {
> + regulator-min-microvolt = <500000>;
> + regulator-max-microvolt = <3300000>;
> + regulator-ramp-delay = <5000>;
> + regulator-always-on;
> + };
> +
> + aldo1: aldo1 {
> + regulator-min-microvolt = <500000>;
> + regulator-max-microvolt = <3400000>;
> + regulator-boot-on;
> + regulator-always-on;
> + };
> + };
> + };
> +};
> +
> +&sdhci0 {
> + pinctrl-names = "default", "uhs";
> + pinctrl-0 = <&mmc1_cfg>;
> + pinctrl-1 = <&mmc1_uhs_cfg>;
> + bus-width = <4>;
> + cd-gpios = <&gpio K1_GPIO(80) GPIO_ACTIVE_HIGH>;
> + cd-inverted;
> + no-mmc;
> + no-sdio;
> + disable-wp;
> + cap-sd-highspeed;
> + vmmc-supply = <&buck4>;
> + vqmmc-supply = <&aldo1>;
> + sd-uhs-sdr25;
> + sd-uhs-sdr50;
> + sd-uhs-sdr104;
> + status = "okay";
> +};
>
> --
> 2.54.0
>
--
Yixun Lan (dlan)
^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: [PATCH v9 7/8] riscv: dts: spacemit: k1-bananapi-f3: add SD card support with UHS modes
2026-05-11 8:54 ` [PATCH v9 7/8] riscv: dts: spacemit: k1-bananapi-f3: " Iker Pedrosa
2026-05-11 16:55 ` Aurelien Jarno
2026-05-12 3:32 ` sashiko-bot
@ 2026-05-12 5:43 ` Yixun Lan
2026-05-12 17:03 ` Aurelien Jarno
2 siblings, 1 reply; 23+ messages in thread
From: Yixun Lan @ 2026-05-12 5:43 UTC (permalink / raw)
To: Iker Pedrosa
Cc: Rob Herring, Krzysztof Kozlowski, Conor Dooley, Adrian Hunter,
Paul Walmsley, Palmer Dabbelt, Albert Ou, Alexandre Ghiti,
Ulf Hansson, Troy Mitchell, Michael Opdenacker,
Javier Martinez Canillas, linux-mmc, devicetree, linux-riscv,
spacemit, linux-kernel, Anand Moon, Margherita Milani
Hi Iker,
Please note, once you are sending new patch series, please drop patch 1-4
which already picked by Ulf, but keep increase the version number
On 10:54 Mon 11 May , Iker Pedrosa wrote:
> Add complete SD card controller support with UHS high-speed modes.
>
> - Enable sdhci0 controller with 4-bit bus width
> - Configure card detect GPIO with inversion
> - Connect vmmc-supply to buck4 for 3.3V card power
> - Connect vqmmc-supply to aldo1 for 1.8V/3.3V I/O switching
> - Add dual pinctrl states for voltage-dependent pin configuration
> - Support UHS-I SDR25, SDR50, and SDR104 modes
>
> This enables full SD card functionality including high-speed UHS modes
> for improved performance.
>
> Suggested-by: Anand Moon <linux.amoon@gmail.com>
> Tested-by: Anand Moon <linux.amoon@gmail.com>
> Tested-by: Margherita Milani <margherita.milani@amarulasolutions.com>
> Signed-off-by: Iker Pedrosa <ikerpedrosam@gmail.com>
> ---
> arch/riscv/boot/dts/spacemit/k1-bananapi-f3.dts | 22 ++++++++++++++++++++--
> 1 file changed, 20 insertions(+), 2 deletions(-)
>
> diff --git a/arch/riscv/boot/dts/spacemit/k1-bananapi-f3.dts b/arch/riscv/boot/dts/spacemit/k1-bananapi-f3.dts
> index e20daa50a152..8fea6e87acec 100644
> --- a/arch/riscv/boot/dts/spacemit/k1-bananapi-f3.dts
> +++ b/arch/riscv/boot/dts/spacemit/k1-bananapi-f3.dts
> @@ -221,7 +221,7 @@ buck3_1v8: buck3 {
> regulator-always-on;
> };
>
> - buck4 {
> + buck4: buck4 {
> regulator-min-microvolt = <500000>;
> regulator-max-microvolt = <3300000>;
> regulator-ramp-delay = <5000>;
> @@ -242,7 +242,7 @@ buck6 {
> regulator-always-on;
> };
>
> - aldo1 {
> + aldo1: aldo1 {
> regulator-min-microvolt = <500000>;
> regulator-max-microvolt = <3400000>;
> regulator-boot-on;
> @@ -374,3 +374,21 @@ hub_3_0: hub@2 {
> reset-gpios = <&gpio K1_GPIO(124) GPIO_ACTIVE_LOW>;
> };
> };
> +
> +&sdhci0 {
I'd suggest to add alias (to 'aliases' node), so we will have stable
dev node regardless whichever device probe first.. something should like
aliases {
..
mmc0 = &emmc;
mmc1 = &sdhci0;
..
}
So, how about let's make it convention here, first device is emmc, second
is SD card, third is sdio device (haven't added yet).. We introduced emmc
early before this patch, so it stays unchanged which is nice for end user
Please apply this alias idea to all boards although I only comment in this
patch..
> + pinctrl-names = "default", "uhs";
> + pinctrl-0 = <&mmc1_cfg>;
> + pinctrl-1 = <&mmc1_uhs_cfg>;
> + bus-width = <4>;
> + cd-gpios = <&gpio K1_GPIO(80) (GPIO_ACTIVE_LOW | GPIO_PULL_UP)>;
> + no-mmc;
> + no-sdio;
> + disable-wp;
> + cap-sd-highspeed;
> + vmmc-supply = <&buck4>;
> + vqmmc-supply = <&aldo1>;
> + sd-uhs-sdr25;
> + sd-uhs-sdr50;
> + sd-uhs-sdr104;
> + status = "okay";
> +};
>
> --
> 2.54.0
>
--
Yixun Lan (dlan)
^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: [PATCH v9 7/8] riscv: dts: spacemit: k1-bananapi-f3: add SD card support with UHS modes
2026-05-12 5:43 ` Yixun Lan
@ 2026-05-12 17:03 ` Aurelien Jarno
2026-05-12 22:49 ` Yixun Lan
0 siblings, 1 reply; 23+ messages in thread
From: Aurelien Jarno @ 2026-05-12 17:03 UTC (permalink / raw)
To: Yixun Lan
Cc: Iker Pedrosa, Rob Herring, Conor Dooley, Albert Ou,
Michael Opdenacker, Alexandre Ghiti, devicetree, linux-kernel,
Troy Mitchell, linux-mmc, Adrian Hunter, linux-riscv, Ulf Hansson,
Margherita Milani, Palmer Dabbelt, Javier Martinez Canillas,
Paul Walmsley, spacemit, Krzysztof Kozlowski
Hi Yixun,
On 2026-05-12 05:43, Yixun Lan wrote:
> Hi Iker,
>
> Please note, once you are sending new patch series, please drop patch 1-4
> which already picked by Ulf, but keep increase the version number
>
>
> On 10:54 Mon 11 May , Iker Pedrosa wrote:
> > Add complete SD card controller support with UHS high-speed modes.
> >
> > - Enable sdhci0 controller with 4-bit bus width
> > - Configure card detect GPIO with inversion
> > - Connect vmmc-supply to buck4 for 3.3V card power
> > - Connect vqmmc-supply to aldo1 for 1.8V/3.3V I/O switching
> > - Add dual pinctrl states for voltage-dependent pin configuration
> > - Support UHS-I SDR25, SDR50, and SDR104 modes
> >
> > This enables full SD card functionality including high-speed UHS modes
> > for improved performance.
> >
> > Suggested-by: Anand Moon <linux.amoon@gmail.com>
> > Tested-by: Anand Moon <linux.amoon@gmail.com>
> > Tested-by: Margherita Milani <margherita.milani@amarulasolutions.com>
> > Signed-off-by: Iker Pedrosa <ikerpedrosam@gmail.com>
> > ---
> > arch/riscv/boot/dts/spacemit/k1-bananapi-f3.dts | 22 ++++++++++++++++++++--
> > 1 file changed, 20 insertions(+), 2 deletions(-)
> >
> > diff --git a/arch/riscv/boot/dts/spacemit/k1-bananapi-f3.dts b/arch/riscv/boot/dts/spacemit/k1-bananapi-f3.dts
> > index e20daa50a152..8fea6e87acec 100644
> > --- a/arch/riscv/boot/dts/spacemit/k1-bananapi-f3.dts
> > +++ b/arch/riscv/boot/dts/spacemit/k1-bananapi-f3.dts
> > @@ -221,7 +221,7 @@ buck3_1v8: buck3 {
> > regulator-always-on;
> > };
> >
> > - buck4 {
> > + buck4: buck4 {
> > regulator-min-microvolt = <500000>;
> > regulator-max-microvolt = <3300000>;
> > regulator-ramp-delay = <5000>;
> > @@ -242,7 +242,7 @@ buck6 {
> > regulator-always-on;
> > };
> >
> > - aldo1 {
> > + aldo1: aldo1 {
> > regulator-min-microvolt = <500000>;
> > regulator-max-microvolt = <3400000>;
> > regulator-boot-on;
> > @@ -374,3 +374,21 @@ hub_3_0: hub@2 {
> > reset-gpios = <&gpio K1_GPIO(124) GPIO_ACTIVE_LOW>;
> > };
> > };
> > +
> > +&sdhci0 {
> I'd suggest to add alias (to 'aliases' node), so we will have stable
> dev node regardless whichever device probe first.. something should like
> aliases {
> ..
> mmc0 = &emmc;
> mmc1 = &sdhci0;
> ..
> }
>
> So, how about let's make it convention here, first device is emmc, second
> is SD card, third is sdio device (haven't added yet).. We introduced emmc
> early before this patch, so it stays unchanged which is nice for end user
>
> Please apply this alias idea to all boards although I only comment in this
> patch..
Having a stable naming is definitely a good idea.
What about boards that have no or optional emmc, like the Milk-V Jupiter
board? I plan to submit a patch for it, so I wonder if we still number
the SD card as mmc1 even if there is no emmc.
Thanks
Aurelien
--
Aurelien Jarno GPG: 4096R/1DDD8C9B
aurelien@aurel32.net http://aurel32.net
^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: [PATCH v9 7/8] riscv: dts: spacemit: k1-bananapi-f3: add SD card support with UHS modes
2026-05-12 17:03 ` Aurelien Jarno
@ 2026-05-12 22:49 ` Yixun Lan
0 siblings, 0 replies; 23+ messages in thread
From: Yixun Lan @ 2026-05-12 22:49 UTC (permalink / raw)
To: Iker Pedrosa, Rob Herring, Conor Dooley, Albert Ou,
Michael Opdenacker, Alexandre Ghiti, devicetree, linux-kernel,
Troy Mitchell, linux-mmc, Adrian Hunter, linux-riscv, Ulf Hansson,
Margherita Milani, Palmer Dabbelt, Javier Martinez Canillas,
Paul Walmsley, spacemit, Krzysztof Kozlowski
Hi Aurelien,
On 19:03 Tue 12 May , Aurelien Jarno wrote:
> Hi Yixun,
>
..
> >
> > So, how about let's make it convention here, first device is emmc, second
> > is SD card, third is sdio device (haven't added yet).. We introduced emmc
> > early before this patch, so it stays unchanged which is nice for end user
> >
> > Please apply this alias idea to all boards although I only comment in this
> > patch..
>
> Having a stable naming is definitely a good idea.
>
> What about boards that have no or optional emmc, like the Milk-V Jupiter
> board? I plan to submit a patch for it, so I wonder if we still number
> the SD card as mmc1 even if there is no emmc.
Yes, please
For Milk-V Jupiter, it has emmc slot despite plug the module in or not,
so it make sense to name it as mmc1, in other words, the board do support
emmc in the hardware level
For future board, if the board has no emmc feature design in, then I'd
be fine with name it as mmc0 or mmc1, shouldn't be much difference..
--
Yixun Lan (dlan)
^ permalink raw reply [flat|nested] 23+ messages in thread
end of thread, other threads:[~2026-05-12 22:49 UTC | newest]
Thread overview: 23+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-05-11 8:53 [PATCH v9 0/8] riscv: spacemit: enable SD card support with UHS modes for OrangePi RV2 Iker Pedrosa
2026-05-11 8:53 ` [PATCH v9 1/8] dt-bindings: mmc: spacemit,sdhci: add pinctrl support for voltage switching Iker Pedrosa
2026-05-12 1:01 ` sashiko-bot
2026-05-11 8:53 ` [PATCH v9 2/8] mmc: sdhci-of-k1: enable essential clock infrastructure for SD operation Iker Pedrosa
2026-05-12 1:13 ` sashiko-bot
2026-05-11 8:53 ` [PATCH v9 3/8] mmc: sdhci-of-k1: add regulator and pinctrl voltage switching support Iker Pedrosa
2026-05-12 2:01 ` sashiko-bot
2026-05-11 8:53 ` [PATCH v9 4/8] mmc: sdhci-of-k1: add comprehensive SDR tuning support Iker Pedrosa
2026-05-11 8:54 ` [PATCH v9 5/8] riscv: dts: spacemit: k1: add SD card controller and pinctrl support Iker Pedrosa
2026-05-12 2:47 ` sashiko-bot
2026-05-11 8:54 ` [PATCH v9 6/8] riscv: dts: spacemit: k1-orangepi-rv2: add SD card support with UHS modes Iker Pedrosa
2026-05-12 3:20 ` sashiko-bot
2026-05-11 8:54 ` [PATCH v9 7/8] riscv: dts: spacemit: k1-bananapi-f3: " Iker Pedrosa
2026-05-11 16:55 ` Aurelien Jarno
2026-05-12 3:32 ` sashiko-bot
2026-05-12 5:43 ` Yixun Lan
2026-05-12 17:03 ` Aurelien Jarno
2026-05-12 22:49 ` Yixun Lan
2026-05-11 8:54 ` [PATCH v9 8/8] riscv: dts: spacemit: k1-musepi-pro: " Iker Pedrosa
2026-05-11 11:43 ` Andre Heider
2026-05-12 3:48 ` sashiko-bot
2026-05-12 5:20 ` Yixun Lan
2026-05-11 15:40 ` [PATCH v9 0/8] riscv: spacemit: enable SD card support with UHS modes for OrangePi RV2 Ulf Hansson
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox