Devicetree
 help / color / mirror / Atom feed
* [PATCH v10 0/4] riscv: spacemit: enable SD card support with UHS modes for OrangePi RV2
@ 2026-05-15 10:48 Iker Pedrosa
  2026-05-15 10:48 ` [PATCH v10 1/4] riscv: dts: spacemit: k1: add SD card controller and pinctrl support Iker Pedrosa
                   ` (3 more replies)
  0 siblings, 4 replies; 8+ messages in thread
From: Iker Pedrosa @ 2026-05-15 10:48 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,
	Margherita Milani, Aurelien Jarno, Andre Heider

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 v10:
- Rebased on ulf-mmc/next (patches 1-4 from v9 already applied by Ulf
  Hansson).
- Device tree node ordering. Fixed k1.dtsi to order sdhci0 before emmc
  per device tree conventions.
- Added stable mmc device aliases in all boards:
  * mmc0 = &emmc (eMMC controller)
  * mmc1 = &sdhci0 (SD card controller)
- Card detect logic simplification. Replaced "GPIO_ACTIVE_HIGH +         
  cd-inverted" with direct GPIO_ACTIVE_LOW for OrangePi RV2 to eliminate 
  double-inversion.
- Use minimal PMIC supply configuration in MusePi Pro.
- Remove unused reg_dc_in regulator in MusePi Pro.
- Card detect GPIO properly configured with GPIO_PULL_UP in MusePi Pro.
- Update PMIC to use per-regulator supply properties in MusePi Pro.
- Link to v9: https://lore.kernel.org/r/20260511-orangepi-sd-card-uhs-v9-0-ae48c0b2b2cf@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 (3):
      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

 arch/riscv/boot/dts/spacemit/k1-bananapi-f3.dts  | 24 +++++++++-
 arch/riscv/boot/dts/spacemit/k1-musepi-pro.dts   | 60 ++++++++++++++++++++++++
 arch/riscv/boot/dts/spacemit/k1-orangepi-rv2.dts | 22 ++++++++-
 arch/riscv/boot/dts/spacemit/k1-pinctrl.dtsi     | 40 ++++++++++++++++
 arch/riscv/boot/dts/spacemit/k1.dtsi             | 13 +++++
 5 files changed, 156 insertions(+), 3 deletions(-)
---
base-commit: effc0aace34218afcf080cdc5fac518410709619
change-id: 20260226-orangepi-sd-card-uhs-0ecb05839b0c

Best regards,
-- 
Iker Pedrosa <ikerpedrosam@gmail.com>


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH v10 1/4] riscv: dts: spacemit: k1: add SD card controller and pinctrl support
  2026-05-15 10:48 [PATCH v10 0/4] riscv: spacemit: enable SD card support with UHS modes for OrangePi RV2 Iker Pedrosa
@ 2026-05-15 10:48 ` Iker Pedrosa
  2026-05-15 10:49 ` [PATCH v10 2/4] riscv: dts: spacemit: k1-orangepi-rv2: add SD card support with UHS modes Iker Pedrosa
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 8+ messages in thread
From: Iker Pedrosa @ 2026-05-15 10:48 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..06469c364eef 100644
--- a/arch/riscv/boot/dts/spacemit/k1.dtsi
+++ b/arch/riscv/boot/dts/spacemit/k1.dtsi
@@ -1214,6 +1214,19 @@ usb_dwc3: usb@c0a00000 {
 				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";
+			};
+
 			emmc: mmc@d4281000 {
 				compatible = "spacemit,k1-sdhci";
 				reg = <0x0 0xd4281000 0x0 0x200>;

-- 
2.54.0


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH v10 2/4] riscv: dts: spacemit: k1-orangepi-rv2: add SD card support with UHS modes
  2026-05-15 10:48 [PATCH v10 0/4] riscv: spacemit: enable SD card support with UHS modes for OrangePi RV2 Iker Pedrosa
  2026-05-15 10:48 ` [PATCH v10 1/4] riscv: dts: spacemit: k1: add SD card controller and pinctrl support Iker Pedrosa
@ 2026-05-15 10:49 ` Iker Pedrosa
  2026-05-15 11:27   ` sashiko-bot
  2026-05-15 10:49 ` [PATCH v10 3/4] riscv: dts: spacemit: k1-bananapi-f3: " Iker Pedrosa
  2026-05-15 10:49 ` [PATCH v10 4/4] riscv: dts: spacemit: k1-musepi-pro: " Iker Pedrosa
  3 siblings, 1 reply; 8+ messages in thread
From: Iker Pedrosa @ 2026-05-15 10:49 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 GPIO_ACTIVE_LOW logic
- 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
- Add stable MMC device aliases (mmc0 = eMMC, mmc1 = SD card)

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 | 22 +++++++++++++++++++++-
 1 file changed, 21 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..bd40bc9011e2 100644
--- a/arch/riscv/boot/dts/spacemit/k1-orangepi-rv2.dts
+++ b/arch/riscv/boot/dts/spacemit/k1-orangepi-rv2.dts
@@ -17,6 +17,8 @@ aliases {
 		serial0 = &uart0;
 		ethernet0 = &eth0;
 		ethernet1 = &eth1;
+		mmc0 = &emmc;
+		mmc1 = &sdhci0;
 	};
 
 	chosen {
@@ -202,7 +204,7 @@ buck6 {
 				regulator-always-on;
 			};
 
-			aldo1 {
+			aldo1: aldo1 {
 				regulator-min-microvolt = <500000>;
 				regulator-max-microvolt = <3400000>;
 				regulator-boot-on;
@@ -319,3 +321,21 @@ 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_LOW>;
+	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] 8+ messages in thread

* [PATCH v10 3/4] riscv: dts: spacemit: k1-bananapi-f3: add SD card support with UHS modes
  2026-05-15 10:48 [PATCH v10 0/4] riscv: spacemit: enable SD card support with UHS modes for OrangePi RV2 Iker Pedrosa
  2026-05-15 10:48 ` [PATCH v10 1/4] riscv: dts: spacemit: k1: add SD card controller and pinctrl support Iker Pedrosa
  2026-05-15 10:49 ` [PATCH v10 2/4] riscv: dts: spacemit: k1-orangepi-rv2: add SD card support with UHS modes Iker Pedrosa
@ 2026-05-15 10:49 ` Iker Pedrosa
  2026-05-15 11:43   ` sashiko-bot
  2026-05-15 10:49 ` [PATCH v10 4/4] riscv: dts: spacemit: k1-musepi-pro: " Iker Pedrosa
  3 siblings, 1 reply; 8+ messages in thread
From: Iker Pedrosa @ 2026-05-15 10:49 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, Aurelien Jarno

Add complete SD card controller support with UHS high-speed modes.

- Enable sdhci0 controller with 4-bit bus width
- Configure card detect GPIO with GPIO_ACTIVE_LOW and internal pull-up
  support
- 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
- Add stable MMC device aliases (mmc0 = eMMC, mmc1 = SD card)

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>
Tested-by: Aurelien Jarno <aurelien@aurel32.net>
Reviewed-by: Aurelien Jarno <aurelien@aurel32.net>
Signed-off-by: Iker Pedrosa <ikerpedrosam@gmail.com>
---
 arch/riscv/boot/dts/spacemit/k1-bananapi-f3.dts | 24 ++++++++++++++++++++++--
 1 file changed, 22 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..72f77e9edd63 100644
--- a/arch/riscv/boot/dts/spacemit/k1-bananapi-f3.dts
+++ b/arch/riscv/boot/dts/spacemit/k1-bananapi-f3.dts
@@ -17,6 +17,8 @@ aliases {
 		spi3 = &spi3;
 		i2c2 = &i2c2;
 		i2c8 = &i2c8;
+		mmc0 = &emmc;
+		mmc1 = &sdhci0;
 	};
 
 	chosen {
@@ -221,7 +223,7 @@ buck3_1v8: buck3 {
 				regulator-always-on;
 			};
 
-			buck4 {
+			buck4: buck4 {
 				regulator-min-microvolt = <500000>;
 				regulator-max-microvolt = <3300000>;
 				regulator-ramp-delay = <5000>;
@@ -242,7 +244,7 @@ buck6 {
 				regulator-always-on;
 			};
 
-			aldo1 {
+			aldo1: aldo1 {
 				regulator-min-microvolt = <500000>;
 				regulator-max-microvolt = <3400000>;
 				regulator-boot-on;
@@ -374,3 +376,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] 8+ messages in thread

* [PATCH v10 4/4] riscv: dts: spacemit: k1-musepi-pro: add SD card support with UHS modes
  2026-05-15 10:48 [PATCH v10 0/4] riscv: spacemit: enable SD card support with UHS modes for OrangePi RV2 Iker Pedrosa
                   ` (2 preceding siblings ...)
  2026-05-15 10:49 ` [PATCH v10 3/4] riscv: dts: spacemit: k1-bananapi-f3: " Iker Pedrosa
@ 2026-05-15 10:49 ` Iker Pedrosa
  2026-05-15 11:59   ` sashiko-bot
  3 siblings, 1 reply; 8+ messages in thread
From: Iker Pedrosa @ 2026-05-15 10:49 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, Andre Heider

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 internal pull-up support
- 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
- Add stable MMC device aliases (mmc0 = eMMC, mmc1 = SD card)
- Update PMIC configuration to use per-regulator supply properties

[1] https://lore.kernel.org/linux-riscv/20260316-orangepi-sd-card-uhs-v3-0-aefd3b7832df@gmail.com/T/#

Tested-by: Andre Heider <a.heider@gmail.com>
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 | 60 ++++++++++++++++++++++++++
 1 file changed, 60 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..81d3ce85d460 100644
--- a/arch/riscv/boot/dts/spacemit/k1-musepi-pro.dts
+++ b/arch/riscv/boot/dts/spacemit/k1-musepi-pro.dts
@@ -17,8 +17,20 @@ / {
 	aliases {
 		ethernet0 = &eth0;
 		serial0 = &uart0;
+		mmc0 = &emmc;
+		mmc1 = &sdhci0;
 	};
 
+	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 +89,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>;
+		vin4-supply = <&reg_vcc_4v>;
+		aldoin-supply = <&reg_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 | 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] 8+ messages in thread

* Re: [PATCH v10 2/4] riscv: dts: spacemit: k1-orangepi-rv2: add SD card support with UHS modes
  2026-05-15 10:49 ` [PATCH v10 2/4] riscv: dts: spacemit: k1-orangepi-rv2: add SD card support with UHS modes Iker Pedrosa
@ 2026-05-15 11:27   ` sashiko-bot
  0 siblings, 0 replies; 8+ messages in thread
From: sashiko-bot @ 2026-05-15 11:27 UTC (permalink / raw)
  To: Iker Pedrosa; +Cc: robh, krzk+dt, devicetree, conor+dt

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [High] The intended 'uhs' pinctrl state will never be applied because the underlying host driver (`sdhci-of-k1.c`) lacks dynamic pinctrl state switching logic.
- [Medium] The pinctrl state name 'uhs' deviates from the established MMC subsystem standard 'state_uhs'.
--

commit d986961bd58045bfd797f79421e91fffcf930dbd
Author: Iker Pedrosa <ikerpedrosam@gmail.com>

riscv: dts: spacemit: k1-orangepi-rv2: add SD card support with UHS modes

This commit adds complete SD card controller support with UHS high-speed
modes for the SpacemiT K1 Orange Pi RV2. It enables the sdhci0 controller
with 4-bit bus width, configures power supplies, and sets up pinctrl states
for voltage-dependent pin configuration.

> diff --git a/arch/riscv/boot/dts/spacemit/k1-orangepi-rv2.dts b/arch/riscv/boot/dts/spacemit/k1-orangepi-rv2.dts
> index 3a829e3c9cbcd..74665795b9e88 100644
> --- a/arch/riscv/boot/dts/spacemit/k1-orangepi-rv2.dts
> +++ b/arch/riscv/boot/dts/spacemit/k1-orangepi-rv2.dts

[ ... ]

> @@ -309,3 +311,21 @@ hub_3_0: hub@2 {
>  		vdd-supply = <&vcc_5v0>;
>  	};
>  };
> +
> +&sdhci0 {
> +	pinctrl-names = "default", "uhs";

Is this pinctrl state name standard for the MMC subsystem? Other device
tree bindings typically use state_uhs rather than uhs for the alternate
UHS pin state. Using state_uhs would align with the established standard
across the subsystem.

> +	pinctrl-0 = <&mmc1_cfg>;
> +	pinctrl-1 = <&mmc1_uhs_cfg>;

Does the underlying host driver (sdhci-of-k1.c) actually switch to this
alternate pinctrl state during voltage changes?

The generic MMC and SDHCI core frameworks do not automatically switch
pinctrl states when entering 1.8V UHS modes. If the host driver lacks the
explicit pinctrl_lookup_state() or pinctrl_select_state() logic, the
physical IO pins will remain permanently stuck in the default 3.3V hardware
state.

Can operating in high-speed modes with mismatched physical signaling
constraints lead to signal integrity failures or data corruption?

> +	bus-width = <4>;
> +	cd-gpios = <&gpio K1_GPIO(80) GPIO_ACTIVE_LOW>;

[ ... ]

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260515-orangepi-sd-card-uhs-v10-0-094af27e310d@gmail.com?part=2

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH v10 3/4] riscv: dts: spacemit: k1-bananapi-f3: add SD card support with UHS modes
  2026-05-15 10:49 ` [PATCH v10 3/4] riscv: dts: spacemit: k1-bananapi-f3: " Iker Pedrosa
@ 2026-05-15 11:43   ` sashiko-bot
  0 siblings, 0 replies; 8+ messages in thread
From: sashiko-bot @ 2026-05-15 11:43 UTC (permalink / raw)
  To: Iker Pedrosa; +Cc: devicetree, robh, krzk+dt, conor+dt

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] Missing driver support for UHS pinctrl state switching in SpacemiT SDHCI driver
--

commit dccbc831846f54656728199aecf02388bd320143
Author: Iker Pedrosa <ikerpedrosam@gmail.com>

riscv: dts: spacemit: k1-bananapi-f3: add SD card support with UHS modes

This commit adds complete SD card controller support with UHS high-speed
modes for the SpacemiT K1 Banana Pi F3. It configures the sdhci0
controller, including regulators for power switching and dual pinctrl
states for voltage-dependent pin configuration.

> diff --git a/arch/riscv/boot/dts/spacemit/k1-bananapi-f3.dts b/arch/riscv/boot/dts/spacemit/k1-bananapi-f3.dts
> index e20daa50a152f..72f77e9edd63d 100644
> --- a/arch/riscv/boot/dts/spacemit/k1-bananapi-f3.dts
> +++ b/arch/riscv/boot/dts/spacemit/k1-bananapi-f3.dts
[ ... ]
> @@ -374,3 +376,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>;

Does the host controller driver (sdhci-of-k1) support switching to the "uhs"
pinctrl state?

The generic mmc and sdhci core subsystems do not automatically parse or
switch to a "uhs" pinctrl state, unlike standard states like "default" or
"sleep".

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

If the driver does not manually look up and select the "uhs" state when
dropping the vqmmc-supply to 1.8V for UHS modes, will the pads remain
locked to the 3.3V configuration?

Could this mismatch between the pad configuration and the supplied power
cause signal integrity issues or data corruption when operating in sdr25,
sdr50, or sdr104 modes?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260515-orangepi-sd-card-uhs-v10-0-094af27e310d@gmail.com?part=3

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH v10 4/4] riscv: dts: spacemit: k1-musepi-pro: add SD card support with UHS modes
  2026-05-15 10:49 ` [PATCH v10 4/4] riscv: dts: spacemit: k1-musepi-pro: " Iker Pedrosa
@ 2026-05-15 11:59   ` sashiko-bot
  0 siblings, 0 replies; 8+ messages in thread
From: sashiko-bot @ 2026-05-15 11:59 UTC (permalink / raw)
  To: Iker Pedrosa; +Cc: devicetree, krzk+dt, conor+dt, robh

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [High] The SD card detect GPIO (`cd-gpios`) is configured with incorrect active polarity (`GPIO_ACTIVE_HIGH`), which will invert card detection.
- [Medium] The UHS-I I/O voltage supply (`aldo1`) is incorrectly marked `regulator-always-on`, preventing the MMC core from physically power-cycling the SD card during error recovery.
--

commit 6129b29ed8762cd8d45153d74898125f35ee85bc
Author: Trevor Gamblin <tgamblin@baylibre.com>

riscv: dts: spacemit: k1-musepi-pro: add SD card support with UHS modes

This commit updates the Muse Pi Pro devicetree with SD card support to match
the OrangePi RV2. It enables the sdhci0 controller, configures the pmic
regulators for card power and I/O switching, and adds UHS-I mode support.

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
> --- a/arch/riscv/boot/dts/spacemit/k1-musepi-pro.dts
> +++ b/arch/riscv/boot/dts/spacemit/k1-musepi-pro.dts

[ ... ]

> +	pmic@41 {
> +		compatible = "spacemit,p1";
> +		reg = <0x41>;

[ ... ]

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

Will marking aldo1 as regulator-always-on prevent the MMC subsystem from
power-cycling the SD card during error recovery?

If a UHS-I voltage switch fails, the MMC core calls regulator_disable() on
vqmmc to drop the voltage to 0V and reset the card's internal state
machine.

The commit message notes this matches the OrangePi RV2, but the OrangePi
RV2 leaves aldo1 without the regulator-always-on constraint.

> +			};
> +		};
> +	};
> +};
> +
> +&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 | GPIO_PULL_UP)>;

Does using GPIO_ACTIVE_HIGH invert the card detection logic?

With the internal pull-up enabled, the physical pin inherently reads high
when the slot is empty. To map the physical low state of a card insertion
to a logical true, this usually requires GPIO_ACTIVE_LOW.

The commit message mentions matching the OrangePi RV2, which uses
GPIO_ACTIVE_LOW for this same pin.

> +	no-mmc;
> +	no-sdio;

[ ... ]

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260515-orangepi-sd-card-uhs-v10-0-094af27e310d@gmail.com?part=4

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2026-05-15 11:59 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-05-15 10:48 [PATCH v10 0/4] riscv: spacemit: enable SD card support with UHS modes for OrangePi RV2 Iker Pedrosa
2026-05-15 10:48 ` [PATCH v10 1/4] riscv: dts: spacemit: k1: add SD card controller and pinctrl support Iker Pedrosa
2026-05-15 10:49 ` [PATCH v10 2/4] riscv: dts: spacemit: k1-orangepi-rv2: add SD card support with UHS modes Iker Pedrosa
2026-05-15 11:27   ` sashiko-bot
2026-05-15 10:49 ` [PATCH v10 3/4] riscv: dts: spacemit: k1-bananapi-f3: " Iker Pedrosa
2026-05-15 11:43   ` sashiko-bot
2026-05-15 10:49 ` [PATCH v10 4/4] riscv: dts: spacemit: k1-musepi-pro: " Iker Pedrosa
2026-05-15 11:59   ` sashiko-bot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox