* [PATCH v3 0/6] mmc: host: renesas_sdhi_core: support configuring an optional sdio mux
@ 2025-12-10 17:38 Josua Mayer
2025-12-10 17:38 ` [PATCH v3 1/6] phy: can-transceiver: rename temporary helper function to avoid conflict Josua Mayer
` (5 more replies)
0 siblings, 6 replies; 7+ messages in thread
From: Josua Mayer @ 2025-12-10 17:38 UTC (permalink / raw)
To: Ulf Hansson, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
Geert Uytterhoeven, Magnus Damm, Wolfram Sang, Marc Kleine-Budde,
Vincent Mailhol, Vinod Koul, Kishon Vijay Abraham I, Peter Rosin,
Aaro Koskinen, Andreas Kemnade, Kevin Hilman, Roger Quadros,
Tony Lindgren, Vignesh R, Janusz Krzysztofik, Andi Shyti
Cc: Mikhail Anikin, Yazan Shhady, Jon Nettleton, linux-mmc,
devicetree, linux-kernel, linux-renesas-soc, linux-can, linux-phy,
linux-omap, linux-i2c, Josua Mayer
Some Renesas SoC based boards mux SD and eMMC on a single sdio
controller, exposing user control by dip switch and software control by
gpio.
Purpose is to simplify development and provisioning by selecting boot
media at power-on, and again before starting linux.
Add binding and driver support for linking a (gpio) mux to renesas sdio
controller.
Introduce generic helper functions for getting managed and selected
mux-state objects, and switch i2c-omap and phy-can-transceiver drivers.
Signed-off-by: Josua Mayer <josua@solid-run.com>
---
Changes in v3:
- updated omap-i2c and phy-can-transceiver to use new helpers.
- created generic helper functions for getting managed optional mux-state.
(Reported-by: Rob Herring <robh@kernel.org>)
- picked up binding ack by Rob Herring.
- replaced use of "SDIO" with "SD/SDIO/eMMC" in binding document and
commit descriptions.
(Reported-by: Ulf Hansson <ulf.hansson@linaro.org>)
- Link to v2: https://lore.kernel.org/r/20251201-rz-sdio-mux-v2-0-bcb581b88dd7@solid-run.com
Changes in v2:
- dropped mux-controller node from dt binding example
(Reported-by: Conor Dooley <conor@kernel.org>
Reported-by: Krzysztof Kozlowski <krzk@kernel.org>)
- Link to v1: https://lore.kernel.org/r/20251128-rz-sdio-mux-v1-0-1ede318d160f@solid-run.com
---
Josua Mayer (6):
phy: can-transceiver: rename temporary helper function to avoid conflict
mux: Add helper functions for getting optional and selected mux-state
phy: can-transceiver: drop temporary helper getting optional mux-state
i2c: omap: switch to new generic helper for getting selected mux-state
dt-bindings: mmc: renesas,sdhi: Add mux-states property
mmc: host: renesas_sdhi_core: support selecting an optional mux
.../devicetree/bindings/mmc/renesas,sdhi.yaml | 6 ++
drivers/i2c/busses/i2c-omap.c | 19 ++----
drivers/mmc/host/Kconfig | 1 +
drivers/mmc/host/renesas_sdhi.h | 1 +
drivers/mmc/host/renesas_sdhi_core.c | 16 +++++-
drivers/mux/core.c | 67 +++++++++++++++++++---
drivers/phy/phy-can-transceiver.c | 10 ----
include/linux/mux/consumer.h | 4 ++
8 files changed, 89 insertions(+), 35 deletions(-)
---
base-commit: 3a8660878839faadb4f1a6dd72c3179c1df56787
change-id: 20251128-rz-sdio-mux-acc5137f1618
Best regards,
--
Josua Mayer <josua@solid-run.com>
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH v3 1/6] phy: can-transceiver: rename temporary helper function to avoid conflict
2025-12-10 17:38 [PATCH v3 0/6] mmc: host: renesas_sdhi_core: support configuring an optional sdio mux Josua Mayer
@ 2025-12-10 17:38 ` Josua Mayer
2025-12-10 17:38 ` [PATCH v3 2/6] mux: Add helper functions for getting optional and selected mux-state Josua Mayer
` (4 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: Josua Mayer @ 2025-12-10 17:38 UTC (permalink / raw)
To: Ulf Hansson, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
Geert Uytterhoeven, Magnus Damm, Wolfram Sang, Marc Kleine-Budde,
Vincent Mailhol, Vinod Koul, Kishon Vijay Abraham I, Peter Rosin,
Aaro Koskinen, Andreas Kemnade, Kevin Hilman, Roger Quadros,
Tony Lindgren, Vignesh R, Janusz Krzysztofik, Andi Shyti
Cc: Mikhail Anikin, Yazan Shhady, Jon Nettleton, linux-mmc,
devicetree, linux-kernel, linux-renesas-soc, linux-can, linux-phy,
linux-omap, linux-i2c, Josua Mayer
Rename the temporary devm_mux_state_get_optional function to avoid
conflict with upcoming implementation in multiplexer subsystem.
Signed-off-by: Josua Mayer <josua@solid-run.com>
---
drivers/phy/phy-can-transceiver.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/phy/phy-can-transceiver.c b/drivers/phy/phy-can-transceiver.c
index f59caff4b3d4c..c02d99f0f29fc 100644
--- a/drivers/phy/phy-can-transceiver.c
+++ b/drivers/phy/phy-can-transceiver.c
@@ -95,7 +95,7 @@ MODULE_DEVICE_TABLE(of, can_transceiver_phy_ids);
/* Temporary wrapper until the multiplexer subsystem supports optional muxes */
static inline struct mux_state *
-devm_mux_state_get_optional(struct device *dev, const char *mux_name)
+temp_devm_mux_state_get_optional(struct device *dev, const char *mux_name)
{
if (!of_property_present(dev->of_node, "mux-states"))
return NULL;
@@ -124,7 +124,7 @@ static int can_transceiver_phy_probe(struct platform_device *pdev)
match = of_match_node(can_transceiver_phy_ids, pdev->dev.of_node);
drvdata = match->data;
- mux_state = devm_mux_state_get_optional(dev, NULL);
+ mux_state = temp_devm_mux_state_get_optional(dev, NULL);
if (IS_ERR(mux_state))
return PTR_ERR(mux_state);
--
2.51.0
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH v3 2/6] mux: Add helper functions for getting optional and selected mux-state
2025-12-10 17:38 [PATCH v3 0/6] mmc: host: renesas_sdhi_core: support configuring an optional sdio mux Josua Mayer
2025-12-10 17:38 ` [PATCH v3 1/6] phy: can-transceiver: rename temporary helper function to avoid conflict Josua Mayer
@ 2025-12-10 17:38 ` Josua Mayer
2025-12-10 17:38 ` [PATCH v3 3/6] phy: can-transceiver: drop temporary helper getting optional mux-state Josua Mayer
` (3 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: Josua Mayer @ 2025-12-10 17:38 UTC (permalink / raw)
To: Ulf Hansson, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
Geert Uytterhoeven, Magnus Damm, Wolfram Sang, Marc Kleine-Budde,
Vincent Mailhol, Vinod Koul, Kishon Vijay Abraham I, Peter Rosin,
Aaro Koskinen, Andreas Kemnade, Kevin Hilman, Roger Quadros,
Tony Lindgren, Vignesh R, Janusz Krzysztofik, Andi Shyti
Cc: Mikhail Anikin, Yazan Shhady, Jon Nettleton, linux-mmc,
devicetree, linux-kernel, linux-renesas-soc, linux-can, linux-phy,
linux-omap, linux-i2c, Josua Mayer
In-tree phy-can-transceiver driver has already implemented a local
version of devm_mux_state_get_optional.
The omap-i2c driver gets and selects an optional mux in its probe
function without using any helper.
Add new helper functions covering both aforementioned use-cases:
- devm_mux_state_get_optional:
Get a mux-state if specified in dt, return NULL otherwise.
- devm_mux_state_get_optional_selected:
Get and select a mux-state if specified in dt, return error or NULL.
Existing mux_get helper function is changed to return -ENOENT in case dt
did not specify a mux-state or -control matching given name (if valid).
This matches of_parse_phandle_with_args semantics which also returns
-ENOENT if the property does nto exists, or its value is zero.
The new helper functions check for ENOENT to return NULL for optional
muxes.
Commit e153fdea9db04 ("phy: can-transceiver: Re-instate "mux-states"
property presence check") noted that "mux_get() always prints an error
message in case of an error, including when the property is not present,
confusing the user."
The first error message covers the case that a mux name is not matched
in dt. This is removed as the returned error code (-ENOENT) is clear.
The second error message is based on of_parse_phandle_with_args return
value. In case mux description is missing from DT, it returns -ENOENT.
Print error message only for other error codes.
This ensures that the new helper functions will not confuse the user
either.
Signed-off-by: Josua Mayer <josua@solid-run.com>
---
drivers/mux/core.c | 67 +++++++++++++++++++++++++++++++++++++++-----
include/linux/mux/consumer.h | 4 +++
2 files changed, 64 insertions(+), 7 deletions(-)
diff --git a/drivers/mux/core.c b/drivers/mux/core.c
index a3840fe0995fe..130ca47a8be37 100644
--- a/drivers/mux/core.c
+++ b/drivers/mux/core.c
@@ -542,11 +542,8 @@ static struct mux_control *mux_get(struct device *dev, const char *mux_name,
else
index = of_property_match_string(np, "mux-control-names",
mux_name);
- if (index < 0) {
- dev_err(dev, "mux controller '%s' not found\n",
- mux_name);
- return ERR_PTR(index);
- }
+ if (index < 0)
+ return ERR_PTR(-ENOENT);
}
if (state)
@@ -558,8 +555,10 @@ static struct mux_control *mux_get(struct device *dev, const char *mux_name,
"mux-controls", "#mux-control-cells",
index, &args);
if (ret) {
- dev_err(dev, "%pOF: failed to get mux-%s %s(%i)\n",
- np, state ? "state" : "control", mux_name ?: "", index);
+ if (ret != -ENOENT)
+ dev_err(dev, "%pOF: failed to get mux-%s %s(%i)\n",
+ np, state ? "state" : "control",
+ mux_name ?: "", index);
return ERR_PTR(ret);
}
@@ -745,6 +744,60 @@ struct mux_state *devm_mux_state_get(struct device *dev,
}
EXPORT_SYMBOL_GPL(devm_mux_state_get);
+/**
+ * devm_mux_state_get_optional() - Get the optional mux-state for a device,
+ * with resource management.
+ * @dev: The device that needs a mux-state.
+ * @mux_name: The name identifying the mux-state.
+ *
+ * Return: Pointer to the mux-state, or an ERR_PTR with a negative errno.
+ */
+struct mux_state *devm_mux_state_get_optional(struct device *dev,
+ const char *mux_name)
+{
+ struct mux_state *mux_state = devm_mux_state_get(dev, mux_name);
+
+ if (IS_ERR(mux_state) && PTR_ERR(mux_state) == -ENOENT)
+ return NULL;
+
+ return mux_state;
+}
+EXPORT_SYMBOL_GPL(devm_mux_state_get_optional);
+
+/**
+ * devm_mux_state_get_optional_selected() - Get the optional mux-state for
+ * a device, with resource management.
+ * @dev: The device that needs a mux-state.
+ * @mux_name: The name identifying the mux-state.
+ *
+ * Return: Pointer to the mux-state, or an ERR_PTR with a negative errno.
+ *
+ * The returned mux-state (if valid) is already selected.
+ */
+struct mux_state *devm_mux_state_get_optional_selected(struct device *dev,
+ const char *mux_name)
+{
+ struct mux_state *mux_state;
+ int ret;
+
+ mux_state = devm_mux_state_get_optional(dev, mux_name);
+ if (IS_ERR_OR_NULL(mux_state))
+ return mux_state;
+
+ ret = mux_state_select(mux_state);
+ if (ret) {
+ if (ret != -EPROBE_DEFER)
+ dev_err(dev, "failed to select mux-state %s: %d\n",
+ mux_name ?: "", ret);
+
+ mux_state_put(mux_state);
+ return ERR_PTR(ret);
+ }
+
+ return mux_state;
+}
+EXPORT_SYMBOL_GPL(devm_mux_state_get_optional_selected);
+
/*
* Using subsys_initcall instead of module_init here to try to ensure - for
* the non-modular case - that the subsystem is initialized when mux consumers
diff --git a/include/linux/mux/consumer.h b/include/linux/mux/consumer.h
index 2e25c838f8312..a5da2e33a45c0 100644
--- a/include/linux/mux/consumer.h
+++ b/include/linux/mux/consumer.h
@@ -60,5 +60,9 @@ struct mux_control *devm_mux_control_get(struct device *dev,
const char *mux_name);
struct mux_state *devm_mux_state_get(struct device *dev,
const char *mux_name);
+struct mux_state *devm_mux_state_get_optional(struct device *dev,
+ const char *mux_name);
+struct mux_state *devm_mux_state_get_optional_selected(struct device *dev,
+ const char *mux_name);
#endif /* _LINUX_MUX_CONSUMER_H */
--
2.51.0
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH v3 3/6] phy: can-transceiver: drop temporary helper getting optional mux-state
2025-12-10 17:38 [PATCH v3 0/6] mmc: host: renesas_sdhi_core: support configuring an optional sdio mux Josua Mayer
2025-12-10 17:38 ` [PATCH v3 1/6] phy: can-transceiver: rename temporary helper function to avoid conflict Josua Mayer
2025-12-10 17:38 ` [PATCH v3 2/6] mux: Add helper functions for getting optional and selected mux-state Josua Mayer
@ 2025-12-10 17:38 ` Josua Mayer
2025-12-10 17:38 ` [PATCH v3 4/6] i2c: omap: switch to new generic helper for getting selected mux-state Josua Mayer
` (2 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: Josua Mayer @ 2025-12-10 17:38 UTC (permalink / raw)
To: Ulf Hansson, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
Geert Uytterhoeven, Magnus Damm, Wolfram Sang, Marc Kleine-Budde,
Vincent Mailhol, Vinod Koul, Kishon Vijay Abraham I, Peter Rosin,
Aaro Koskinen, Andreas Kemnade, Kevin Hilman, Roger Quadros,
Tony Lindgren, Vignesh R, Janusz Krzysztofik, Andi Shyti
Cc: Mikhail Anikin, Yazan Shhady, Jon Nettleton, linux-mmc,
devicetree, linux-kernel, linux-renesas-soc, linux-can, linux-phy,
linux-omap, linux-i2c, Josua Mayer
Multiplexer subsystem has now added helpers for getting managed optional
mux-state.
Switch to the new devm_mux_state_get_optional helper.
This change is only compile-tested.
Signed-off-by: Josua Mayer <josua@solid-run.com>
---
drivers/phy/phy-can-transceiver.c | 12 +-----------
1 file changed, 1 insertion(+), 11 deletions(-)
diff --git a/drivers/phy/phy-can-transceiver.c b/drivers/phy/phy-can-transceiver.c
index c02d99f0f29fc..68d72d8d49251 100644
--- a/drivers/phy/phy-can-transceiver.c
+++ b/drivers/phy/phy-can-transceiver.c
@@ -93,16 +93,6 @@ static const struct of_device_id can_transceiver_phy_ids[] = {
};
MODULE_DEVICE_TABLE(of, can_transceiver_phy_ids);
-/* Temporary wrapper until the multiplexer subsystem supports optional muxes */
-static inline struct mux_state *
-temp_devm_mux_state_get_optional(struct device *dev, const char *mux_name)
-{
- if (!of_property_present(dev->of_node, "mux-states"))
- return NULL;
-
- return devm_mux_state_get(dev, mux_name);
-}
-
static int can_transceiver_phy_probe(struct platform_device *pdev)
{
struct phy_provider *phy_provider;
@@ -124,7 +114,7 @@ static int can_transceiver_phy_probe(struct platform_device *pdev)
match = of_match_node(can_transceiver_phy_ids, pdev->dev.of_node);
drvdata = match->data;
- mux_state = temp_devm_mux_state_get_optional(dev, NULL);
+ mux_state = devm_mux_state_get_optional(dev, NULL);
if (IS_ERR(mux_state))
return PTR_ERR(mux_state);
--
2.51.0
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH v3 4/6] i2c: omap: switch to new generic helper for getting selected mux-state
2025-12-10 17:38 [PATCH v3 0/6] mmc: host: renesas_sdhi_core: support configuring an optional sdio mux Josua Mayer
` (2 preceding siblings ...)
2025-12-10 17:38 ` [PATCH v3 3/6] phy: can-transceiver: drop temporary helper getting optional mux-state Josua Mayer
@ 2025-12-10 17:38 ` Josua Mayer
2025-12-10 17:38 ` [PATCH v3 5/6] dt-bindings: mmc: renesas,sdhi: Add mux-states property Josua Mayer
2025-12-10 17:38 ` [PATCH v3 6/6] mmc: host: renesas_sdhi_core: support selecting an optional mux Josua Mayer
5 siblings, 0 replies; 7+ messages in thread
From: Josua Mayer @ 2025-12-10 17:38 UTC (permalink / raw)
To: Ulf Hansson, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
Geert Uytterhoeven, Magnus Damm, Wolfram Sang, Marc Kleine-Budde,
Vincent Mailhol, Vinod Koul, Kishon Vijay Abraham I, Peter Rosin,
Aaro Koskinen, Andreas Kemnade, Kevin Hilman, Roger Quadros,
Tony Lindgren, Vignesh R, Janusz Krzysztofik, Andi Shyti
Cc: Mikhail Anikin, Yazan Shhady, Jon Nettleton, linux-mmc,
devicetree, linux-kernel, linux-renesas-soc, linux-can, linux-phy,
linux-omap, linux-i2c, Josua Mayer
Multiplexer subsystem has added generic helper functiosn for getting an
already selected mux-state object.
Replace existing logic in probe with the equivalent helper function.
This change is only compile-tested.
Signed-off-by: Josua Mayer <josua@solid-run.com>
---
drivers/i2c/busses/i2c-omap.c | 19 ++++---------------
1 file changed, 4 insertions(+), 15 deletions(-)
diff --git a/drivers/i2c/busses/i2c-omap.c b/drivers/i2c/busses/i2c-omap.c
index 5fcc9f6c33e5b..89802027a3eac 100644
--- a/drivers/i2c/busses/i2c-omap.c
+++ b/drivers/i2c/busses/i2c-omap.c
@@ -1454,21 +1454,10 @@ omap_i2c_probe(struct platform_device *pdev)
(1000 * omap->speed / 8);
}
- if (of_property_present(node, "mux-states")) {
- struct mux_state *mux_state;
-
- mux_state = devm_mux_state_get(&pdev->dev, NULL);
- if (IS_ERR(mux_state)) {
- r = PTR_ERR(mux_state);
- dev_dbg(&pdev->dev, "failed to get I2C mux: %d\n", r);
- goto err_put_pm;
- }
- omap->mux_state = mux_state;
- r = mux_state_select(omap->mux_state);
- if (r) {
- dev_err(&pdev->dev, "failed to select I2C mux: %d\n", r);
- goto err_put_pm;
- }
+ omap->mux_state = devm_mux_state_get_optional_selected(&pdev->dev, NULL);
+ if (IS_ERR(omap->mux_state)) {
+ r = PTR_ERR(omap->mux_state);
+ goto err_put_pm;
}
/* reset ASAP, clearing any IRQs */
--
2.51.0
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH v3 5/6] dt-bindings: mmc: renesas,sdhi: Add mux-states property
2025-12-10 17:38 [PATCH v3 0/6] mmc: host: renesas_sdhi_core: support configuring an optional sdio mux Josua Mayer
` (3 preceding siblings ...)
2025-12-10 17:38 ` [PATCH v3 4/6] i2c: omap: switch to new generic helper for getting selected mux-state Josua Mayer
@ 2025-12-10 17:38 ` Josua Mayer
2025-12-10 17:38 ` [PATCH v3 6/6] mmc: host: renesas_sdhi_core: support selecting an optional mux Josua Mayer
5 siblings, 0 replies; 7+ messages in thread
From: Josua Mayer @ 2025-12-10 17:38 UTC (permalink / raw)
To: Ulf Hansson, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
Geert Uytterhoeven, Magnus Damm, Wolfram Sang, Marc Kleine-Budde,
Vincent Mailhol, Vinod Koul, Kishon Vijay Abraham I, Peter Rosin,
Aaro Koskinen, Andreas Kemnade, Kevin Hilman, Roger Quadros,
Tony Lindgren, Vignesh R, Janusz Krzysztofik, Andi Shyti
Cc: Mikhail Anikin, Yazan Shhady, Jon Nettleton, linux-mmc,
devicetree, linux-kernel, linux-renesas-soc, linux-can, linux-phy,
linux-omap, linux-i2c, Josua Mayer
Add mux controller support for data or control lines that are muxed
between a host and multiple cards.
There are several devices supporting a choice of eMMC or SD on a single
board by both dip switch and gpio, e.g. Renesas RZ/G2L SMARC SoM and
SolidRun RZ/G2L SoM.
In-tree dts for the Renesas boards currently rely on preprocessor macros
and gpio hogs to describe the respective cards.
By adding mux-states property to sdhi controller description, boards can
correctly describe the mux that already exists in hardware - and drivers
can coordinate between mux selection and probing for cards.
Acked-by: Rob Herring (Arm) <robh@kernel.org>
Signed-off-by: Josua Mayer <josua@solid-run.com>
---
Documentation/devicetree/bindings/mmc/renesas,sdhi.yaml | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/Documentation/devicetree/bindings/mmc/renesas,sdhi.yaml b/Documentation/devicetree/bindings/mmc/renesas,sdhi.yaml
index c754ea71f51f7..64fac0d11329a 100644
--- a/Documentation/devicetree/bindings/mmc/renesas,sdhi.yaml
+++ b/Documentation/devicetree/bindings/mmc/renesas,sdhi.yaml
@@ -106,6 +106,11 @@ properties:
iommus:
maxItems: 1
+ mux-states:
+ description:
+ mux controller node to route the SD/SDIO/eMMC signals from SoC to cards.
+ maxItems: 1
+
power-domains:
maxItems: 1
@@ -275,6 +280,7 @@ examples:
max-frequency = <195000000>;
power-domains = <&sysc R8A7790_PD_ALWAYS_ON>;
resets = <&cpg 314>;
+ mux-states = <&mux 0>;
};
sdhi1: mmc@ee120000 {
--
2.51.0
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH v3 6/6] mmc: host: renesas_sdhi_core: support selecting an optional mux
2025-12-10 17:38 [PATCH v3 0/6] mmc: host: renesas_sdhi_core: support configuring an optional sdio mux Josua Mayer
` (4 preceding siblings ...)
2025-12-10 17:38 ` [PATCH v3 5/6] dt-bindings: mmc: renesas,sdhi: Add mux-states property Josua Mayer
@ 2025-12-10 17:38 ` Josua Mayer
5 siblings, 0 replies; 7+ messages in thread
From: Josua Mayer @ 2025-12-10 17:38 UTC (permalink / raw)
To: Ulf Hansson, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
Geert Uytterhoeven, Magnus Damm, Wolfram Sang, Marc Kleine-Budde,
Vincent Mailhol, Vinod Koul, Kishon Vijay Abraham I, Peter Rosin,
Aaro Koskinen, Andreas Kemnade, Kevin Hilman, Roger Quadros,
Tony Lindgren, Vignesh R, Janusz Krzysztofik, Andi Shyti
Cc: Mikhail Anikin, Yazan Shhady, Jon Nettleton, linux-mmc,
devicetree, linux-kernel, linux-renesas-soc, linux-can, linux-phy,
linux-omap, linux-i2c, Josua Mayer
Some hardware designs route data or control signals through a mux to
support multiple devices on a single sdhi controller.
In particular SolidRun RZ/G2L/G2LC/V2L System on Module use a mux for
switching between soldered eMMC and an optional microSD on a carrier
board, e.g. for development or provisioning.
SD/SDIO/eMMC are not well suited for runtime switching between different
cards, however boot-time selection is possible and useful - in
particular considering dt overlays.
Add support for an optional SD/SDIO/eMMC mux defined in dt, and select
it during probe.
Similar functionality already exists in other places, e.g. i2c-omap.
Signed-off-by: Josua Mayer <josua@solid-run.com>
---
drivers/mmc/host/Kconfig | 1 +
drivers/mmc/host/renesas_sdhi.h | 1 +
drivers/mmc/host/renesas_sdhi_core.c | 16 +++++++++++++---
3 files changed, 15 insertions(+), 3 deletions(-)
diff --git a/drivers/mmc/host/Kconfig b/drivers/mmc/host/Kconfig
index 2c963cb6724b9..c01ab7d81a5af 100644
--- a/drivers/mmc/host/Kconfig
+++ b/drivers/mmc/host/Kconfig
@@ -707,6 +707,7 @@ config MMC_SDHI
depends on SUPERH || ARCH_RENESAS || COMPILE_TEST
depends on (RESET_CONTROLLER && REGULATOR) || !OF
select MMC_TMIO_CORE
+ select MULTIPLEXER
help
This provides support for the SDHI SD/SDIO controller found in
Renesas SuperH, ARM and ARM64 based SoCs
diff --git a/drivers/mmc/host/renesas_sdhi.h b/drivers/mmc/host/renesas_sdhi.h
index 084964cecf9d8..9508908d8179f 100644
--- a/drivers/mmc/host/renesas_sdhi.h
+++ b/drivers/mmc/host/renesas_sdhi.h
@@ -97,6 +97,7 @@ struct renesas_sdhi {
struct reset_control *rstc;
struct tmio_mmc_host *host;
struct regulator_dev *rdev;
+ struct mux_state *mux_state;
};
#define host_to_priv(host) \
diff --git a/drivers/mmc/host/renesas_sdhi_core.c b/drivers/mmc/host/renesas_sdhi_core.c
index f56fa2cd208dd..3d833a325c61f 100644
--- a/drivers/mmc/host/renesas_sdhi_core.c
+++ b/drivers/mmc/host/renesas_sdhi_core.c
@@ -26,6 +26,7 @@
#include <linux/mmc/mmc.h>
#include <linux/mmc/slot-gpio.h>
#include <linux/module.h>
+#include <linux/mux/consumer.h>
#include <linux/pinctrl/consumer.h>
#include <linux/pinctrl/pinctrl-state.h>
#include <linux/platform_data/tmio.h>
@@ -1115,9 +1116,15 @@ int renesas_sdhi_probe(struct platform_device *pdev,
"state_uhs");
}
+ priv->mux_state = devm_mux_state_get_optional_selected(&pdev->dev, NULL);
+ if (IS_ERR(priv->mux_state))
+ return PTR_ERR(priv->mux_state);
+
host = tmio_mmc_host_alloc(pdev, mmc_data);
- if (IS_ERR(host))
- return PTR_ERR(host);
+ if (IS_ERR(host)) {
+ ret = PTR_ERR(host);
+ goto edselmux;
+ }
priv->host = host;
@@ -1200,7 +1207,7 @@ int renesas_sdhi_probe(struct platform_device *pdev,
ret = renesas_sdhi_clk_enable(host);
if (ret)
- return ret;
+ goto edselmux;
rcfg.of_node = of_get_available_child_by_name(dev->of_node, "vqmmc-regulator");
if (rcfg.of_node) {
@@ -1304,6 +1311,9 @@ int renesas_sdhi_probe(struct platform_device *pdev,
edisclk:
renesas_sdhi_clk_disable(host);
+edselmux:
+ if (priv->mux_state)
+ mux_state_deselect(priv->mux_state);
return ret;
}
EXPORT_SYMBOL_GPL(renesas_sdhi_probe);
--
2.51.0
^ permalink raw reply related [flat|nested] 7+ messages in thread
end of thread, other threads:[~2025-12-10 17:39 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-12-10 17:38 [PATCH v3 0/6] mmc: host: renesas_sdhi_core: support configuring an optional sdio mux Josua Mayer
2025-12-10 17:38 ` [PATCH v3 1/6] phy: can-transceiver: rename temporary helper function to avoid conflict Josua Mayer
2025-12-10 17:38 ` [PATCH v3 2/6] mux: Add helper functions for getting optional and selected mux-state Josua Mayer
2025-12-10 17:38 ` [PATCH v3 3/6] phy: can-transceiver: drop temporary helper getting optional mux-state Josua Mayer
2025-12-10 17:38 ` [PATCH v3 4/6] i2c: omap: switch to new generic helper for getting selected mux-state Josua Mayer
2025-12-10 17:38 ` [PATCH v3 5/6] dt-bindings: mmc: renesas,sdhi: Add mux-states property Josua Mayer
2025-12-10 17:38 ` [PATCH v3 6/6] mmc: host: renesas_sdhi_core: support selecting an optional mux Josua Mayer
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).