* [PATCH 6.1.y-cip 00/17] Add support for RZ/G3E SDHI
@ 2025-06-23 14:46 Tommaso Merciai
2025-06-23 14:46 ` [PATCH 6.1.y-cip 01/17] clk: renesas: r9a09g047: Add SDHI clocks/resets Tommaso Merciai
` (17 more replies)
0 siblings, 18 replies; 21+ messages in thread
From: Tommaso Merciai @ 2025-06-23 14:46 UTC (permalink / raw)
To: cip-dev, Nobuhiro Iwamatsu, Pavel Machek
Cc: Biju Das, Lad Prabhakar, tomm.merciai
Hi All,
This patch series aims to add SDHI support for the Renesas RZ/G3E SoCs
into the linux-6.1.y-cip kernel.
The SD/MMC block on the RZ/G3E ("R9A09G047") SoC is similar to that
of the RZ/V2H, but the SD0 channel has only dedicated pins, so we must
use SD_STATUS register to control voltage and power enable (internal
regulator).
For SD1 and SD2 channel we can either use gpio regulator or internal
regulator (using SD_STATUS register) for voltage switching.
This patchset applies on top of [1]
[1] https://patchwork.kernel.org/project/cip-dev/list/?series=974771
Thanks & Regards,
Tommaso
Biju Das (10):
clk: renesas: r9a09g047: Add SDHI clocks/resets
dt-bindings: mmc: renesas,sdhi: Document RZ/G3E support
of: base: Add of_get_available_child_by_name()
mmc: renesas_sdhi: Add support for RZ/G3E SoC
mmc: renesas_sdhi: Use of_get_available_child_by_name()
arm64: dts: renesas: r9a09g047: Add SDHI0-SDHI2 nodes
arm64: dts: renesas: r9a09g057: Add support for enabling SDHI internal
regulator
arm64: dts: renesas: rzg3e-smarc-som: Enable SDHI{0,2}
arm64: dts: renesas: rzg3e-smarc-som: Add support to enable SD on
SDHI0
arm64: dts: renesas: r9a09g047e57-smarc: Enable SDHI1
Krzysztof Kozlowski (1):
mmc: renesas_sdhi: use typedef for dma_filter_fn
Wolfram Sang (6):
mmc: tmio: add callback for dma irq
mmc: renesas_sdhi: improve naming of DMA struct
mmc: renesas_sdhi: remove accessor function for internal_dmac
mmc: renesas_sdhi: take DMA end interrupts into account
mmc: renesas_sdhi: add helper to access quirks
mmc: renesas_sdhi: use plain numbers for end_flags
.../devicetree/bindings/mmc/renesas,sdhi.yaml | 16 ++
arch/arm64/boot/dts/renesas/r9a09g047.dtsi | 60 +++++++
.../boot/dts/renesas/r9a09g047e57-smarc.dts | 49 ++++++
arch/arm64/boot/dts/renesas/r9a09g057.dtsi | 21 +++
.../boot/dts/renesas/renesas-smarc2.dtsi | 18 ++
.../boot/dts/renesas/rzg3e-smarc-som.dtsi | 154 ++++++++++++++++++
drivers/clk/renesas/r9a09g047-cpg.c | 31 ++++
drivers/mmc/host/Kconfig | 2 +-
drivers/mmc/host/renesas_sdhi.h | 20 ++-
drivers/mmc/host/renesas_sdhi_core.c | 148 +++++++++++++++--
drivers/mmc/host/renesas_sdhi_internal_dmac.c | 82 ++++++----
drivers/mmc/host/tmio_mmc.h | 11 ++
drivers/mmc/host/tmio_mmc_core.c | 3 +
drivers/of/base.c | 27 +++
include/linux/of.h | 9 +
15 files changed, 605 insertions(+), 46 deletions(-)
--
2.43.0
^ permalink raw reply [flat|nested] 21+ messages in thread
* [PATCH 6.1.y-cip 01/17] clk: renesas: r9a09g047: Add SDHI clocks/resets
2025-06-23 14:46 [PATCH 6.1.y-cip 00/17] Add support for RZ/G3E SDHI Tommaso Merciai
@ 2025-06-23 14:46 ` Tommaso Merciai
2025-06-23 14:46 ` [PATCH 6.1.y-cip 02/17] dt-bindings: mmc: renesas,sdhi: Document RZ/G3E support Tommaso Merciai
` (16 subsequent siblings)
17 siblings, 0 replies; 21+ messages in thread
From: Tommaso Merciai @ 2025-06-23 14:46 UTC (permalink / raw)
To: cip-dev, Nobuhiro Iwamatsu, Pavel Machek
Cc: Biju Das, Lad Prabhakar, tomm.merciai
From: Biju Das <biju.das.jz@bp.renesas.com>
commit 922c892834689939953c74bd34d01788b17feb7e upstream.
Add SDHI[0-2] clock and reset entries.
Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
Reviewed-by: Tommaso Merciai <tommaso.merciai.xr@bp.renesas.com>
Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
Link: https://lore.kernel.org/20250126134616.37334-3-biju.das.jz@bp.renesas.com
Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
Signed-off-by: Tommaso Merciai <tommaso.merciai.xr@bp.renesas.com>
---
drivers/clk/renesas/r9a09g047-cpg.c | 31 +++++++++++++++++++++++++++++
1 file changed, 31 insertions(+)
diff --git a/drivers/clk/renesas/r9a09g047-cpg.c b/drivers/clk/renesas/r9a09g047-cpg.c
index 1886eab9ef9e..133582317490 100644
--- a/drivers/clk/renesas/r9a09g047-cpg.c
+++ b/drivers/clk/renesas/r9a09g047-cpg.c
@@ -31,6 +31,8 @@ enum clk_ids {
/* Internal Core Clocks */
CLK_PLLCM33_DIV16,
+ CLK_PLLCLN_DIV2,
+ CLK_PLLCLN_DIV8,
CLK_PLLCLN_DIV16,
CLK_PLLDTY_ACPU,
CLK_PLLDTY_ACPU_DIV4,
@@ -71,6 +73,8 @@ static const struct cpg_core_clk r9a09g047_core_clks[] __initconst = {
/* Internal Core Clocks */
DEF_FIXED(".pllcm33_div16", CLK_PLLCM33_DIV16, CLK_PLLCM33, 1, 16),
+ DEF_FIXED(".pllcln_div2", CLK_PLLCLN_DIV2, CLK_PLLCLN, 1, 2),
+ DEF_FIXED(".pllcln_div8", CLK_PLLCLN_DIV8, CLK_PLLCLN, 1, 8),
DEF_FIXED(".pllcln_div16", CLK_PLLCLN_DIV16, CLK_PLLCLN, 1, 16),
DEF_DDIV(".plldty_acpu", CLK_PLLDTY_ACPU, CLK_PLLDTY, CDDIV0_DIVCTL2, dtable_2_64),
@@ -124,6 +128,30 @@ static const struct rzv2h_mod_clk r9a09g047_mod_clks[] __initconst = {
BUS_MSTOP(1, BIT(7))),
DEF_MOD("riic_7_ckm", CLK_PLLCLN_DIV16, 9, 11, 4, 27,
BUS_MSTOP(1, BIT(8))),
+ DEF_MOD("sdhi_0_imclk", CLK_PLLCLN_DIV8, 10, 3, 5, 3,
+ BUS_MSTOP(8, BIT(2))),
+ DEF_MOD("sdhi_0_imclk2", CLK_PLLCLN_DIV8, 10, 4, 5, 4,
+ BUS_MSTOP(8, BIT(2))),
+ DEF_MOD("sdhi_0_clk_hs", CLK_PLLCLN_DIV2, 10, 5, 5, 5,
+ BUS_MSTOP(8, BIT(2))),
+ DEF_MOD("sdhi_0_aclk", CLK_PLLDTY_ACPU_DIV4, 10, 6, 5, 6,
+ BUS_MSTOP(8, BIT(2))),
+ DEF_MOD("sdhi_1_imclk", CLK_PLLCLN_DIV8, 10, 7, 5, 7,
+ BUS_MSTOP(8, BIT(3))),
+ DEF_MOD("sdhi_1_imclk2", CLK_PLLCLN_DIV8, 10, 8, 5, 8,
+ BUS_MSTOP(8, BIT(3))),
+ DEF_MOD("sdhi_1_clk_hs", CLK_PLLCLN_DIV2, 10, 9, 5, 9,
+ BUS_MSTOP(8, BIT(3))),
+ DEF_MOD("sdhi_1_aclk", CLK_PLLDTY_ACPU_DIV4, 10, 10, 5, 10,
+ BUS_MSTOP(8, BIT(3))),
+ DEF_MOD("sdhi_2_imclk", CLK_PLLCLN_DIV8, 10, 11, 5, 11,
+ BUS_MSTOP(8, BIT(4))),
+ DEF_MOD("sdhi_2_imclk2", CLK_PLLCLN_DIV8, 10, 12, 5, 12,
+ BUS_MSTOP(8, BIT(4))),
+ DEF_MOD("sdhi_2_clk_hs", CLK_PLLCLN_DIV2, 10, 13, 5, 13,
+ BUS_MSTOP(8, BIT(4))),
+ DEF_MOD("sdhi_2_aclk", CLK_PLLDTY_ACPU_DIV4, 10, 14, 5, 14,
+ BUS_MSTOP(8, BIT(4))),
};
static const struct rzv2h_reset r9a09g047_resets[] __initconst = {
@@ -143,6 +171,9 @@ static const struct rzv2h_reset r9a09g047_resets[] __initconst = {
DEF_RST(9, 14, 4, 15), /* RIIC_6_MRST */
DEF_RST(9, 15, 4, 16), /* RIIC_7_MRST */
DEF_RST(10, 0, 4, 17), /* RIIC_8_MRST */
+ DEF_RST(10, 7, 4, 24), /* SDHI_0_IXRST */
+ DEF_RST(10, 8, 4, 25), /* SDHI_1_IXRST */
+ DEF_RST(10, 9, 4, 26), /* SDHI_2_IXRST */
};
const struct rzv2h_cpg_info r9a09g047_cpg_info __initconst = {
--
2.43.0
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [PATCH 6.1.y-cip 02/17] dt-bindings: mmc: renesas,sdhi: Document RZ/G3E support
2025-06-23 14:46 [PATCH 6.1.y-cip 00/17] Add support for RZ/G3E SDHI Tommaso Merciai
2025-06-23 14:46 ` [PATCH 6.1.y-cip 01/17] clk: renesas: r9a09g047: Add SDHI clocks/resets Tommaso Merciai
@ 2025-06-23 14:46 ` Tommaso Merciai
2025-06-23 14:46 ` [PATCH 6.1.y-cip 03/17] of: base: Add of_get_available_child_by_name() Tommaso Merciai
` (15 subsequent siblings)
17 siblings, 0 replies; 21+ messages in thread
From: Tommaso Merciai @ 2025-06-23 14:46 UTC (permalink / raw)
To: cip-dev, Nobuhiro Iwamatsu, Pavel Machek
Cc: Biju Das, Lad Prabhakar, tomm.merciai
From: Biju Das <biju.das.jz@bp.renesas.com>
commit 93745285ad9ba11ef68922787e0f46da408ab0b7 upstream.
The SD/MMC block on the RZ/G3E ("R9A09G047") SoC is similar to that
of the RZ/V2H, but the SD0 channel has only dedicated pins, so we must
use SD_STATUS register to control voltage and power enable (internal
regulator), for non-fixed voltage (SD) MMC interface. However, it is
optional for fixed voltage MMC interface (eMMC).
For SD1 and SD2 channels, we can either use gpio regulator or internal
regulator (using SD_STATUS register) for voltage switching.
Document RZ/G3E SDHI IP support with optional internal regulator for
both RZ/G3E and RZ/V2H SoC.
Acked-by: Conor Dooley <conor.dooley@microchip.com>
Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
Reviewed-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
Link: https://lore.kernel.org/r/20250305092958.21865-2-biju.das.jz@bp.renesas.com
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
Signed-off-by: Tommaso Merciai <tommaso.merciai.xr@bp.renesas.com>
---
.../devicetree/bindings/mmc/renesas,sdhi.yaml | 16 ++++++++++++++++
1 file changed, 16 insertions(+)
diff --git a/Documentation/devicetree/bindings/mmc/renesas,sdhi.yaml b/Documentation/devicetree/bindings/mmc/renesas,sdhi.yaml
index 653832d4f32b..d7473e99fbd2 100644
--- a/Documentation/devicetree/bindings/mmc/renesas,sdhi.yaml
+++ b/Documentation/devicetree/bindings/mmc/renesas,sdhi.yaml
@@ -66,6 +66,9 @@ properties:
- renesas,sdhi-r9a08g045 # RZ/G3S
- renesas,sdhi-r9a09g011 # RZ/V2M
- const: renesas,rzg2l-sdhi
+ - items:
+ - const: renesas,sdhi-r9a09g047 # RZ/G3E
+ - const: renesas,sdhi-r9a09g057 # RZ/V2H(P)
reg:
maxItems: 1
@@ -205,6 +208,19 @@ allOf:
sectioned off to be run by a separate second clock source to allow
the main core clock to be turned off to save power.
+ - if:
+ properties:
+ compatible:
+ contains:
+ const: renesas,sdhi-r9a09g057
+ then:
+ properties:
+ vqmmc-regulator:
+ type: object
+ description: VQMMC SD regulator
+ $ref: /schemas/regulator/regulator.yaml#
+ unevaluatedProperties: false
+
required:
- compatible
- reg
--
2.43.0
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [PATCH 6.1.y-cip 03/17] of: base: Add of_get_available_child_by_name()
2025-06-23 14:46 [PATCH 6.1.y-cip 00/17] Add support for RZ/G3E SDHI Tommaso Merciai
2025-06-23 14:46 ` [PATCH 6.1.y-cip 01/17] clk: renesas: r9a09g047: Add SDHI clocks/resets Tommaso Merciai
2025-06-23 14:46 ` [PATCH 6.1.y-cip 02/17] dt-bindings: mmc: renesas,sdhi: Document RZ/G3E support Tommaso Merciai
@ 2025-06-23 14:46 ` Tommaso Merciai
2025-06-23 14:46 ` [PATCH 6.1.y-cip 04/17] mmc: tmio: add callback for dma irq Tommaso Merciai
` (14 subsequent siblings)
17 siblings, 0 replies; 21+ messages in thread
From: Tommaso Merciai @ 2025-06-23 14:46 UTC (permalink / raw)
To: cip-dev, Nobuhiro Iwamatsu, Pavel Machek
Cc: Biju Das, Lad Prabhakar, tomm.merciai
From: Biju Das <biju.das.jz@bp.renesas.com>
commit 8d3bbe4355aded32961b9009b31de6d41b7352e9 upstream.
There are lot of drivers using of_get_child_by_name() followed by
of_device_is_available() to find the available child node by name for a
given parent. Provide a helper for these users to simplify the code.
Suggested-by: Geert Uytterhoeven <geert+renesas@glider.be>
Reviewed-by: Rob Herring <robh@kernel.org>
Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
Reviewed-by: Simon Horman <horms@kernel.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Tommaso Merciai <tommaso.merciai.xr@bp.renesas.com>
---
drivers/of/base.c | 27 +++++++++++++++++++++++++++
include/linux/of.h | 9 +++++++++
2 files changed, 36 insertions(+)
diff --git a/drivers/of/base.c b/drivers/of/base.c
index 90c934bb91da..788706579419 100644
--- a/drivers/of/base.c
+++ b/drivers/of/base.c
@@ -904,6 +904,33 @@ struct device_node *of_get_child_by_name(const struct device_node *node,
}
EXPORT_SYMBOL(of_get_child_by_name);
+/**
+ * of_get_available_child_by_name - Find the available child node by name for a given parent
+ * @node: parent node
+ * @name: child name to look for.
+ *
+ * This function looks for child node for given matching name and checks the
+ * device's availability for use.
+ *
+ * Return: A node pointer if found, with refcount incremented, use
+ * of_node_put() on it when done.
+ * Returns NULL if node is not found.
+ */
+struct device_node *of_get_available_child_by_name(const struct device_node *node,
+ const char *name)
+{
+ struct device_node *child;
+
+ child = of_get_child_by_name(node, name);
+ if (child && !of_device_is_available(child)) {
+ of_node_put(child);
+ return NULL;
+ }
+
+ return child;
+}
+EXPORT_SYMBOL(of_get_available_child_by_name);
+
struct device_node *__of_find_node_by_path(struct device_node *parent,
const char *path)
{
diff --git a/include/linux/of.h b/include/linux/of.h
index 2960e609ca05..44e432dbf67f 100644
--- a/include/linux/of.h
+++ b/include/linux/of.h
@@ -296,6 +296,8 @@ extern struct device_node *of_get_compatible_child(const struct device_node *par
const char *compatible);
extern struct device_node *of_get_child_by_name(const struct device_node *node,
const char *name);
+extern struct device_node *of_get_available_child_by_name(const struct device_node *node,
+ const char *name);
/* cache lookup */
extern struct device_node *of_find_next_cache_node(const struct device_node *);
@@ -558,6 +560,13 @@ static inline struct device_node *of_get_child_by_name(
return NULL;
}
+static inline struct device_node *of_get_available_child_by_name(
+ const struct device_node *node,
+ const char *name)
+{
+ return NULL;
+}
+
static inline int of_device_is_compatible(const struct device_node *device,
const char *name)
{
--
2.43.0
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [PATCH 6.1.y-cip 04/17] mmc: tmio: add callback for dma irq
2025-06-23 14:46 [PATCH 6.1.y-cip 00/17] Add support for RZ/G3E SDHI Tommaso Merciai
` (2 preceding siblings ...)
2025-06-23 14:46 ` [PATCH 6.1.y-cip 03/17] of: base: Add of_get_available_child_by_name() Tommaso Merciai
@ 2025-06-23 14:46 ` Tommaso Merciai
2025-06-23 14:46 ` [PATCH 6.1.y-cip 05/17] mmc: renesas_sdhi: improve naming of DMA struct Tommaso Merciai
` (13 subsequent siblings)
17 siblings, 0 replies; 21+ messages in thread
From: Tommaso Merciai @ 2025-06-23 14:46 UTC (permalink / raw)
To: cip-dev, Nobuhiro Iwamatsu, Pavel Machek
Cc: Biju Das, Lad Prabhakar, tomm.merciai
From: Wolfram Sang <wsa+renesas@sang-engineering.com>
commit af728d7ae20483add9f8d3c81280dc6298a0aa2e upstream.
We don't want to rely only on the access_end irq in the future, so
implement a callback for dma irqs.
Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Tested-by: Duy Nguyen <duy.nguyen.rh@renesas.com>
Tested-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
Link: https://lore.kernel.org/r/20221006190452.5316-4-wsa+renesas@sang-engineering.com
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
Signed-off-by: Tommaso Merciai <tommaso.merciai.xr@bp.renesas.com>
---
drivers/mmc/host/tmio_mmc.h | 1 +
drivers/mmc/host/tmio_mmc_core.c | 3 +++
2 files changed, 4 insertions(+)
diff --git a/drivers/mmc/host/tmio_mmc.h b/drivers/mmc/host/tmio_mmc.h
index 501613c74406..873a06a179c8 100644
--- a/drivers/mmc/host/tmio_mmc.h
+++ b/drivers/mmc/host/tmio_mmc.h
@@ -128,6 +128,7 @@ struct tmio_mmc_dma_ops {
/* optional */
void (*end)(struct tmio_mmc_host *host); /* held host->lock */
+ bool (*dma_irq)(struct tmio_mmc_host *host);
};
struct tmio_mmc_host {
diff --git a/drivers/mmc/host/tmio_mmc_core.c b/drivers/mmc/host/tmio_mmc_core.c
index 5024cae411d3..7283252aa07b 100644
--- a/drivers/mmc/host/tmio_mmc_core.c
+++ b/drivers/mmc/host/tmio_mmc_core.c
@@ -672,6 +672,9 @@ static bool __tmio_mmc_sdcard_irq(struct tmio_mmc_host *host, int ireg,
return true;
}
+ if (host->dma_ops && host->dma_ops->dma_irq && host->dma_ops->dma_irq(host))
+ return true;
+
return false;
}
--
2.43.0
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [PATCH 6.1.y-cip 05/17] mmc: renesas_sdhi: improve naming of DMA struct
2025-06-23 14:46 [PATCH 6.1.y-cip 00/17] Add support for RZ/G3E SDHI Tommaso Merciai
` (3 preceding siblings ...)
2025-06-23 14:46 ` [PATCH 6.1.y-cip 04/17] mmc: tmio: add callback for dma irq Tommaso Merciai
@ 2025-06-23 14:46 ` Tommaso Merciai
2025-06-23 14:46 ` [PATCH 6.1.y-cip 06/17] mmc: renesas_sdhi: remove accessor function for internal_dmac Tommaso Merciai
` (12 subsequent siblings)
17 siblings, 0 replies; 21+ messages in thread
From: Tommaso Merciai @ 2025-06-23 14:46 UTC (permalink / raw)
To: cip-dev, Nobuhiro Iwamatsu, Pavel Machek
Cc: Biju Das, Lad Prabhakar, tomm.merciai
From: Wolfram Sang <wsa+renesas@sang-engineering.com>
commit 7f3ea248cd1b2ea9b49f6f3523250bc8e622dd5e upstream.
Commit 058db2868cd8 ("mmc: tmio, renesas_sdhi: move struct tmio_mmc_dma
to renesas_sdhi.h") is correct. The DMA struct should be prefixed with
'renesas_sdhi' to avoid confusion about is namespace. Fix some
indentation while here.
Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Tested-by: Duy Nguyen <duy.nguyen.rh@renesas.com>
Tested-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
Link: https://lore.kernel.org/r/20221006190452.5316-3-wsa+renesas@sang-engineering.com
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
Signed-off-by: Tommaso Merciai <tommaso.merciai.xr@bp.renesas.com>
---
drivers/mmc/host/renesas_sdhi.h | 8 ++++----
drivers/mmc/host/renesas_sdhi_core.c | 2 +-
2 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/drivers/mmc/host/renesas_sdhi.h b/drivers/mmc/host/renesas_sdhi.h
index e4c490729c98..fa88b721364c 100644
--- a/drivers/mmc/host/renesas_sdhi.h
+++ b/drivers/mmc/host/renesas_sdhi.h
@@ -54,12 +54,12 @@ struct renesas_sdhi_of_data_with_quirks {
const struct renesas_sdhi_quirks *quirks;
};
-struct tmio_mmc_dma {
+struct renesas_sdhi_dma {
enum dma_slave_buswidth dma_buswidth;
bool (*filter)(struct dma_chan *chan, void *arg);
void (*enable)(struct tmio_mmc_host *host, bool enable);
- struct completion dma_dataend;
- struct tasklet_struct dma_complete;
+ struct completion dma_dataend;
+ struct tasklet_struct dma_complete;
};
struct renesas_sdhi {
@@ -67,7 +67,7 @@ struct renesas_sdhi {
struct clk *clkh;
struct clk *clk_cd;
struct tmio_mmc_data mmc_data;
- struct tmio_mmc_dma dma_priv;
+ struct renesas_sdhi_dma dma_priv;
const struct renesas_sdhi_quirks *quirks;
struct pinctrl *pinctrl;
struct pinctrl_state *pins_default, *pins_uhs;
diff --git a/drivers/mmc/host/renesas_sdhi_core.c b/drivers/mmc/host/renesas_sdhi_core.c
index d0a15645a0b8..3ec5695b58ca 100644
--- a/drivers/mmc/host/renesas_sdhi_core.c
+++ b/drivers/mmc/host/renesas_sdhi_core.c
@@ -908,7 +908,7 @@ int renesas_sdhi_probe(struct platform_device *pdev,
{
struct tmio_mmc_data *mmd = pdev->dev.platform_data;
struct tmio_mmc_data *mmc_data;
- struct tmio_mmc_dma *dma_priv;
+ struct renesas_sdhi_dma *dma_priv;
struct tmio_mmc_host *host;
struct renesas_sdhi *priv;
int num_irqs, irq, ret, i;
--
2.43.0
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [PATCH 6.1.y-cip 06/17] mmc: renesas_sdhi: remove accessor function for internal_dmac
2025-06-23 14:46 [PATCH 6.1.y-cip 00/17] Add support for RZ/G3E SDHI Tommaso Merciai
` (4 preceding siblings ...)
2025-06-23 14:46 ` [PATCH 6.1.y-cip 05/17] mmc: renesas_sdhi: improve naming of DMA struct Tommaso Merciai
@ 2025-06-23 14:46 ` Tommaso Merciai
2025-06-23 14:46 ` [PATCH 6.1.y-cip 07/17] mmc: renesas_sdhi: take DMA end interrupts into account Tommaso Merciai
` (11 subsequent siblings)
17 siblings, 0 replies; 21+ messages in thread
From: Tommaso Merciai @ 2025-06-23 14:46 UTC (permalink / raw)
To: cip-dev, Nobuhiro Iwamatsu, Pavel Machek
Cc: Biju Das, Lad Prabhakar, tomm.merciai
From: Wolfram Sang <wsa+renesas@sang-engineering.com>
commit a8687078fc5e7606b3e91f32cb6ba2574d83736d upstream.
This accessor function does not help readability but makes it worse.
Because I soon need to read from the registers as well and don't want to
add another function like this, I chose to remove the existing one and
use the accessor directly. I also switch from writeq to writel because
no 64 bit register is actually involved.
Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Tested-by: Duy Nguyen <duy.nguyen.rh@renesas.com>
Tested-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
Link: https://lore.kernel.org/r/20221006190452.5316-2-wsa+renesas@sang-engineering.com
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
Signed-off-by: Tommaso Merciai <tommaso.merciai.xr@bp.renesas.com>
---
drivers/mmc/host/renesas_sdhi_internal_dmac.c | 31 +++++--------------
1 file changed, 8 insertions(+), 23 deletions(-)
diff --git a/drivers/mmc/host/renesas_sdhi_internal_dmac.c b/drivers/mmc/host/renesas_sdhi_internal_dmac.c
index db4815f36756..c32e65a3effe 100644
--- a/drivers/mmc/host/renesas_sdhi_internal_dmac.c
+++ b/drivers/mmc/host/renesas_sdhi_internal_dmac.c
@@ -294,13 +294,6 @@ static const struct of_device_id renesas_sdhi_internal_dmac_of_match[] = {
};
MODULE_DEVICE_TABLE(of, renesas_sdhi_internal_dmac_of_match);
-static void
-renesas_sdhi_internal_dmac_dm_write(struct tmio_mmc_host *host,
- int addr, u64 val)
-{
- writeq(val, host->ctl + addr);
-}
-
static void
renesas_sdhi_internal_dmac_enable_dma(struct tmio_mmc_host *host, bool enable)
{
@@ -310,8 +303,7 @@ renesas_sdhi_internal_dmac_enable_dma(struct tmio_mmc_host *host, bool enable)
return;
if (!enable)
- renesas_sdhi_internal_dmac_dm_write(host, DM_CM_INFO1,
- INFO1_CLEAR);
+ writel(INFO1_CLEAR, host->ctl + DM_CM_INFO1);
if (priv->dma_priv.enable)
priv->dma_priv.enable(host, enable);
@@ -324,10 +316,8 @@ renesas_sdhi_internal_dmac_abort_dma(struct tmio_mmc_host *host)
renesas_sdhi_internal_dmac_enable_dma(host, false);
- renesas_sdhi_internal_dmac_dm_write(host, DM_CM_RST,
- RST_RESERVED_BITS & ~val);
- renesas_sdhi_internal_dmac_dm_write(host, DM_CM_RST,
- RST_RESERVED_BITS | val);
+ writel(RST_RESERVED_BITS & ~val, host->ctl + DM_CM_RST);
+ writel(RST_RESERVED_BITS | val, host->ctl + DM_CM_RST);
clear_bit(SDHI_INTERNAL_DMAC_RX_IN_USE, &global_flags);
@@ -412,10 +402,8 @@ renesas_sdhi_internal_dmac_start_dma(struct tmio_mmc_host *host,
renesas_sdhi_internal_dmac_enable_dma(host, true);
/* set dma parameters */
- renesas_sdhi_internal_dmac_dm_write(host, DM_CM_DTRAN_MODE,
- dtran_mode);
- renesas_sdhi_internal_dmac_dm_write(host, DM_DTRAN_ADDR,
- sg_dma_address(sg));
+ writel(dtran_mode, host->ctl + DM_CM_DTRAN_MODE);
+ writel(sg_dma_address(sg), host->ctl + DM_DTRAN_ADDR);
host->dma_on = true;
@@ -435,8 +423,7 @@ static void renesas_sdhi_internal_dmac_issue_tasklet_fn(unsigned long arg)
tmio_mmc_enable_mmc_irqs(host, TMIO_STAT_DATAEND);
/* start the DMAC */
- renesas_sdhi_internal_dmac_dm_write(host, DM_CM_DTRAN_CTRL,
- DTRAN_CTRL_DM_START);
+ writel(DTRAN_CTRL_DM_START, host->ctl + DM_CM_DTRAN_CTRL);
}
static bool renesas_sdhi_internal_dmac_complete(struct tmio_mmc_host *host)
@@ -517,10 +504,8 @@ renesas_sdhi_internal_dmac_request_dma(struct tmio_mmc_host *host,
struct renesas_sdhi *priv = host_to_priv(host);
/* Disable DMAC interrupts, we don't use them */
- renesas_sdhi_internal_dmac_dm_write(host, DM_CM_INFO1_MASK,
- INFO1_MASK_CLEAR);
- renesas_sdhi_internal_dmac_dm_write(host, DM_CM_INFO2_MASK,
- INFO2_MASK_CLEAR);
+ writel(INFO1_MASK_CLEAR, host->ctl + DM_CM_INFO1_MASK);
+ writel(INFO2_MASK_CLEAR, host->ctl + DM_CM_INFO2_MASK);
/* Each value is set to non-zero to assume "enabling" each DMA */
host->chan_rx = host->chan_tx = (void *)0xdeadbeaf;
--
2.43.0
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [PATCH 6.1.y-cip 07/17] mmc: renesas_sdhi: take DMA end interrupts into account
2025-06-23 14:46 [PATCH 6.1.y-cip 00/17] Add support for RZ/G3E SDHI Tommaso Merciai
` (5 preceding siblings ...)
2025-06-23 14:46 ` [PATCH 6.1.y-cip 06/17] mmc: renesas_sdhi: remove accessor function for internal_dmac Tommaso Merciai
@ 2025-06-23 14:46 ` Tommaso Merciai
2025-06-24 8:44 ` Pavel Machek
2025-06-23 14:46 ` [PATCH 6.1.y-cip 08/17] mmc: renesas_sdhi: add helper to access quirks Tommaso Merciai
` (10 subsequent siblings)
17 siblings, 1 reply; 21+ messages in thread
From: Tommaso Merciai @ 2025-06-23 14:46 UTC (permalink / raw)
To: cip-dev, Nobuhiro Iwamatsu, Pavel Machek
Cc: Biju Das, Lad Prabhakar, tomm.merciai
From: Wolfram Sang <wsa+renesas@sang-engineering.com>
commit c330601c9c93392000c077d973b182cc0164b9ac upstream.
So far, we have been relying on access_end interrupts only to mark DMA
transfers as done implying that DMA end interrupts have occurred by then
anyhow. On some SoCs under some conditions, this turned out to be not
enough. So, we enable DMA interrupts as well and make sure that both
events, DMA irq and access_end irq, have happened before finishing the
DMA transfer.
Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Tested-by: Duy Nguyen <duy.nguyen.rh@renesas.com>
Tested-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
Link: https://lore.kernel.org/r/20221006190452.5316-6-wsa+renesas@sang-engineering.com
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
Signed-off-by: Tommaso Merciai <tommaso.merciai.xr@bp.renesas.com>
---
drivers/mmc/host/renesas_sdhi.h | 5 ++
drivers/mmc/host/renesas_sdhi_internal_dmac.c | 51 ++++++++++++++++---
2 files changed, 49 insertions(+), 7 deletions(-)
diff --git a/drivers/mmc/host/renesas_sdhi.h b/drivers/mmc/host/renesas_sdhi.h
index fa88b721364c..8f96457c9739 100644
--- a/drivers/mmc/host/renesas_sdhi.h
+++ b/drivers/mmc/host/renesas_sdhi.h
@@ -54,7 +54,12 @@ struct renesas_sdhi_of_data_with_quirks {
const struct renesas_sdhi_quirks *quirks;
};
+/* We want both end_flags to be set before we mark DMA as finished */
+#define SDHI_DMA_END_FLAG_DMA BIT(0)
+#define SDHI_DMA_END_FLAG_ACCESS BIT(1)
+
struct renesas_sdhi_dma {
+ unsigned long end_flags;
enum dma_slave_buswidth dma_buswidth;
bool (*filter)(struct dma_chan *chan, void *arg);
void (*enable)(struct tmio_mmc_host *host, bool enable);
diff --git a/drivers/mmc/host/renesas_sdhi_internal_dmac.c b/drivers/mmc/host/renesas_sdhi_internal_dmac.c
index c32e65a3effe..fc76370daec0 100644
--- a/drivers/mmc/host/renesas_sdhi_internal_dmac.c
+++ b/drivers/mmc/host/renesas_sdhi_internal_dmac.c
@@ -47,7 +47,6 @@
#define RST_RESERVED_BITS GENMASK_ULL(31, 0)
/* DM_CM_INFO1 and DM_CM_INFO1_MASK */
-#define INFO1_CLEAR 0
#define INFO1_MASK_CLEAR GENMASK_ULL(31, 0)
#define INFO1_DTRANEND1 BIT(20)
#define INFO1_DTRANEND1_OLD BIT(17)
@@ -298,12 +297,14 @@ static void
renesas_sdhi_internal_dmac_enable_dma(struct tmio_mmc_host *host, bool enable)
{
struct renesas_sdhi *priv = host_to_priv(host);
+ u32 dma_irqs = INFO1_DTRANEND0 |
+ (priv->quirks && priv->quirks->old_info1_layout ?
+ INFO1_DTRANEND1_OLD : INFO1_DTRANEND1);
if (!host->chan_tx || !host->chan_rx)
return;
- if (!enable)
- writel(INFO1_CLEAR, host->ctl + DM_CM_INFO1);
+ writel(enable ? ~dma_irqs : INFO1_MASK_CLEAR, host->ctl + DM_CM_INFO1_MASK);
if (priv->dma_priv.enable)
priv->dma_priv.enable(host, enable);
@@ -324,12 +325,36 @@ renesas_sdhi_internal_dmac_abort_dma(struct tmio_mmc_host *host)
renesas_sdhi_internal_dmac_enable_dma(host, true);
}
+static bool renesas_sdhi_internal_dmac_dma_irq(struct tmio_mmc_host *host)
+{
+ struct renesas_sdhi *priv = host_to_priv(host);
+ struct renesas_sdhi_dma *dma_priv = &priv->dma_priv;
+
+ u32 dma_irqs = INFO1_DTRANEND0 |
+ (priv->quirks && priv->quirks->old_info1_layout ?
+ INFO1_DTRANEND1_OLD : INFO1_DTRANEND1);
+ u32 status = readl(host->ctl + DM_CM_INFO1);
+
+ if (status & dma_irqs) {
+ writel(status ^ dma_irqs, host->ctl + DM_CM_INFO1);
+ set_bit(SDHI_DMA_END_FLAG_DMA, &dma_priv->end_flags);
+ if (test_bit(SDHI_DMA_END_FLAG_ACCESS, &dma_priv->end_flags))
+ tasklet_schedule(&dma_priv->dma_complete);
+ }
+
+ return status & dma_irqs;
+}
+
static void
renesas_sdhi_internal_dmac_dataend_dma(struct tmio_mmc_host *host)
{
struct renesas_sdhi *priv = host_to_priv(host);
+ struct renesas_sdhi_dma *dma_priv = &priv->dma_priv;
- tasklet_schedule(&priv->dma_priv.dma_complete);
+ set_bit(SDHI_DMA_END_FLAG_ACCESS, &dma_priv->end_flags);
+ if (test_bit(SDHI_DMA_END_FLAG_DMA, &dma_priv->end_flags) ||
+ host->data->error)
+ tasklet_schedule(&dma_priv->dma_complete);
}
/*
@@ -399,6 +424,7 @@ renesas_sdhi_internal_dmac_start_dma(struct tmio_mmc_host *host,
dtran_mode |= DTRAN_MODE_CH_NUM_CH0;
}
+ priv->dma_priv.end_flags = 0;
renesas_sdhi_internal_dmac_enable_dma(host, true);
/* set dma parameters */
@@ -419,11 +445,19 @@ renesas_sdhi_internal_dmac_start_dma(struct tmio_mmc_host *host,
static void renesas_sdhi_internal_dmac_issue_tasklet_fn(unsigned long arg)
{
struct tmio_mmc_host *host = (struct tmio_mmc_host *)arg;
+ struct renesas_sdhi *priv = host_to_priv(host);
tmio_mmc_enable_mmc_irqs(host, TMIO_STAT_DATAEND);
- /* start the DMAC */
- writel(DTRAN_CTRL_DM_START, host->ctl + DM_CM_DTRAN_CTRL);
+ if (!host->cmd->error) {
+ /* start the DMAC */
+ writel(DTRAN_CTRL_DM_START, host->ctl + DM_CM_DTRAN_CTRL);
+ } else {
+ /* on CMD errors, simulate DMA end immediately */
+ set_bit(SDHI_DMA_END_FLAG_DMA, &priv->dma_priv.end_flags);
+ if (test_bit(SDHI_DMA_END_FLAG_ACCESS, &priv->dma_priv.end_flags))
+ tasklet_schedule(&priv->dma_priv.dma_complete);
+ }
}
static bool renesas_sdhi_internal_dmac_complete(struct tmio_mmc_host *host)
@@ -503,9 +537,11 @@ renesas_sdhi_internal_dmac_request_dma(struct tmio_mmc_host *host,
{
struct renesas_sdhi *priv = host_to_priv(host);
- /* Disable DMAC interrupts, we don't use them */
+ /* Disable DMAC interrupts initially */
writel(INFO1_MASK_CLEAR, host->ctl + DM_CM_INFO1_MASK);
writel(INFO2_MASK_CLEAR, host->ctl + DM_CM_INFO2_MASK);
+ writel(0, host->ctl + DM_CM_INFO1);
+ writel(0, host->ctl + DM_CM_INFO2);
/* Each value is set to non-zero to assume "enabling" each DMA */
host->chan_rx = host->chan_tx = (void *)0xdeadbeaf;
@@ -537,6 +573,7 @@ static const struct tmio_mmc_dma_ops renesas_sdhi_internal_dmac_dma_ops = {
.abort = renesas_sdhi_internal_dmac_abort_dma,
.dataend = renesas_sdhi_internal_dmac_dataend_dma,
.end = renesas_sdhi_internal_dmac_end_dma,
+ .dma_irq = renesas_sdhi_internal_dmac_dma_irq,
};
static int renesas_sdhi_internal_dmac_probe(struct platform_device *pdev)
--
2.43.0
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [PATCH 6.1.y-cip 08/17] mmc: renesas_sdhi: add helper to access quirks
2025-06-23 14:46 [PATCH 6.1.y-cip 00/17] Add support for RZ/G3E SDHI Tommaso Merciai
` (6 preceding siblings ...)
2025-06-23 14:46 ` [PATCH 6.1.y-cip 07/17] mmc: renesas_sdhi: take DMA end interrupts into account Tommaso Merciai
@ 2025-06-23 14:46 ` Tommaso Merciai
2025-06-23 14:46 ` [PATCH 6.1.y-cip 09/17] mmc: renesas_sdhi: use plain numbers for end_flags Tommaso Merciai
` (9 subsequent siblings)
17 siblings, 0 replies; 21+ messages in thread
From: Tommaso Merciai @ 2025-06-23 14:46 UTC (permalink / raw)
To: cip-dev, Nobuhiro Iwamatsu, Pavel Machek
Cc: Biju Das, Lad Prabhakar, tomm.merciai
From: Wolfram Sang <wsa+renesas@sang-engineering.com>
commit 48c917fa998c00980167ba732c8ccbf603c9fb70 upstream.
Add a macro to check for a quirk because it a) ensures that the check
for non-empty 'quirks' struct is not forgotten and b) is easier to read.
Convert existing quirk access as well.
Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
Reviewed-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
Tested-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
Link: https://lore.kernel.org/r/20221120113457.42010-4-wsa+renesas@sang-engineering.com
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
Signed-off-by: Tommaso Merciai <tommaso.merciai.xr@bp.renesas.com>
---
drivers/mmc/host/renesas_sdhi.h | 2 ++
drivers/mmc/host/renesas_sdhi_core.c | 18 +++++++++---------
drivers/mmc/host/renesas_sdhi_internal_dmac.c | 8 ++++----
3 files changed, 15 insertions(+), 13 deletions(-)
diff --git a/drivers/mmc/host/renesas_sdhi.h b/drivers/mmc/host/renesas_sdhi.h
index 8f96457c9739..ea2a85174a09 100644
--- a/drivers/mmc/host/renesas_sdhi.h
+++ b/drivers/mmc/host/renesas_sdhi.h
@@ -38,6 +38,8 @@ struct renesas_sdhi_of_data {
#define SDHI_CALIB_TABLE_MAX 32
+#define sdhi_has_quirk(p, q) ((p)->quirks && (p)->quirks->q)
+
struct renesas_sdhi_quirks {
bool hs400_disabled;
bool hs400_4taps;
diff --git a/drivers/mmc/host/renesas_sdhi_core.c b/drivers/mmc/host/renesas_sdhi_core.c
index 3ec5695b58ca..4052ef027647 100644
--- a/drivers/mmc/host/renesas_sdhi_core.c
+++ b/drivers/mmc/host/renesas_sdhi_core.c
@@ -141,7 +141,7 @@ static unsigned int renesas_sdhi_clk_update(struct tmio_mmc_host *host,
if (priv->clkh) {
/* HS400 with 4TAP needs different clock settings */
- bool use_4tap = priv->quirks && priv->quirks->hs400_4taps;
+ bool use_4tap = sdhi_has_quirk(priv, hs400_4taps);
bool need_slow_clkh = host->mmc->ios.timing == MMC_TIMING_MMC_HS400;
clkh_shift = use_4tap && need_slow_clkh ? 1 : 2;
ref_clk = priv->clkh;
@@ -383,7 +383,7 @@ static void renesas_sdhi_hs400_complete(struct mmc_host *mmc)
struct tmio_mmc_host *host = mmc_priv(mmc);
struct renesas_sdhi *priv = host_to_priv(host);
u32 bad_taps = priv->quirks ? priv->quirks->hs400_bad_taps : 0;
- bool use_4tap = priv->quirks && priv->quirks->hs400_4taps;
+ bool use_4tap = sdhi_has_quirk(priv, hs400_4taps);
sd_ctrl_write16(host, CTL_SD_CARD_CLK_CTL, ~CLK_CTL_SCLKEN &
sd_ctrl_read16(host, CTL_SD_CARD_CLK_CTL));
@@ -395,7 +395,7 @@ static void renesas_sdhi_hs400_complete(struct mmc_host *mmc)
sd_scc_write32(host, priv, SH_MOBILE_SDHI_SCC_DT2FF,
priv->scc_tappos_hs400);
- if (priv->quirks && priv->quirks->manual_tap_correction)
+ if (sdhi_has_quirk(priv, manual_tap_correction))
sd_scc_write32(host, priv, SH_MOBILE_SDHI_SCC_RVSCNTL,
~SH_MOBILE_SDHI_SCC_RVSCNTL_RVSEN &
sd_scc_read32(host, priv, SH_MOBILE_SDHI_SCC_RVSCNTL));
@@ -546,7 +546,7 @@ static void renesas_sdhi_reset_hs400_mode(struct tmio_mmc_host *host,
SH_MOBILE_SDHI_SCC_TMPPORT2_HS400OSEL) &
sd_scc_read32(host, priv, SH_MOBILE_SDHI_SCC_TMPPORT2));
- if (priv->quirks && (priv->quirks->hs400_calib_table || priv->quirks->hs400_bad_taps))
+ if (sdhi_has_quirk(priv, hs400_calib_table) || sdhi_has_quirk(priv, hs400_bad_taps))
renesas_sdhi_adjust_hs400_mode_disable(host);
sd_ctrl_write16(host, CTL_SD_CARD_CLK_CTL, CLK_CTL_SCLKEN |
@@ -732,7 +732,7 @@ static bool renesas_sdhi_manual_correction(struct tmio_mmc_host *host, bool use_
sd_scc_write32(host, priv, SH_MOBILE_SDHI_SCC_RVSREQ, 0);
/* Change TAP position according to correction status */
- if (priv->quirks && priv->quirks->manual_tap_correction &&
+ if (sdhi_has_quirk(priv, manual_tap_correction) &&
host->mmc->ios.timing == MMC_TIMING_MMC_HS400) {
u32 bad_taps = priv->quirks ? priv->quirks->hs400_bad_taps : 0;
/*
@@ -796,7 +796,7 @@ static bool renesas_sdhi_check_scc_error(struct tmio_mmc_host *host,
struct mmc_request *mrq)
{
struct renesas_sdhi *priv = host_to_priv(host);
- bool use_4tap = priv->quirks && priv->quirks->hs400_4taps;
+ bool use_4tap = sdhi_has_quirk(priv, hs400_4taps);
bool ret = false;
/*
@@ -990,7 +990,7 @@ int renesas_sdhi_probe(struct platform_device *pdev,
host->multi_io_quirk = renesas_sdhi_multi_io_quirk;
host->dma_ops = dma_ops;
- if (quirks && quirks->hs400_disabled)
+ if (sdhi_has_quirk(priv, hs400_disabled))
host->mmc->caps2 &= ~(MMC_CAP2_HS400 | MMC_CAP2_HS400_ES);
/* For some SoC, we disable internal WP. GPIO may override this */
@@ -1058,7 +1058,7 @@ int renesas_sdhi_probe(struct platform_device *pdev,
if (ver == SDHI_VER_GEN2_SDR50)
mmc_data->flags &= ~TMIO_MMC_HAVE_CBSY;
- if (ver == SDHI_VER_GEN3_SDMMC && quirks && quirks->hs400_calib_table) {
+ if (ver == SDHI_VER_GEN3_SDMMC && sdhi_has_quirk(priv, hs400_calib_table)) {
host->fixup_request = renesas_sdhi_fixup_request;
priv->adjust_hs400_calib_table = *(
res->start == SDHI_GEN3_MMC0_ADDR ?
@@ -1079,7 +1079,7 @@ int renesas_sdhi_probe(struct platform_device *pdev,
host->mmc->caps2 & (MMC_CAP2_HS200_1_8V_SDR |
MMC_CAP2_HS400_1_8V))) {
const struct renesas_sdhi_scc *taps = of_data->taps;
- bool use_4tap = quirks && quirks->hs400_4taps;
+ bool use_4tap = sdhi_has_quirk(priv, hs400_4taps);
bool hit = false;
for (i = 0; i < of_data->taps_num; i++) {
diff --git a/drivers/mmc/host/renesas_sdhi_internal_dmac.c b/drivers/mmc/host/renesas_sdhi_internal_dmac.c
index fc76370daec0..56fa2bc7146d 100644
--- a/drivers/mmc/host/renesas_sdhi_internal_dmac.c
+++ b/drivers/mmc/host/renesas_sdhi_internal_dmac.c
@@ -298,7 +298,7 @@ renesas_sdhi_internal_dmac_enable_dma(struct tmio_mmc_host *host, bool enable)
{
struct renesas_sdhi *priv = host_to_priv(host);
u32 dma_irqs = INFO1_DTRANEND0 |
- (priv->quirks && priv->quirks->old_info1_layout ?
+ (sdhi_has_quirk(priv, old_info1_layout) ?
INFO1_DTRANEND1_OLD : INFO1_DTRANEND1);
if (!host->chan_tx || !host->chan_rx)
@@ -331,7 +331,7 @@ static bool renesas_sdhi_internal_dmac_dma_irq(struct tmio_mmc_host *host)
struct renesas_sdhi_dma *dma_priv = &priv->dma_priv;
u32 dma_irqs = INFO1_DTRANEND0 |
- (priv->quirks && priv->quirks->old_info1_layout ?
+ (sdhi_has_quirk(priv, old_info1_layout) ?
INFO1_DTRANEND1_OLD : INFO1_DTRANEND1);
u32 status = readl(host->ctl + DM_CM_INFO1);
@@ -409,7 +409,7 @@ renesas_sdhi_internal_dmac_start_dma(struct tmio_mmc_host *host,
struct scatterlist *sg = host->sg_ptr;
u32 dtran_mode = DTRAN_MODE_BUS_WIDTH;
- if (!(priv->quirks && priv->quirks->fixed_addr_mode))
+ if (!sdhi_has_quirk(priv, fixed_addr_mode))
dtran_mode |= DTRAN_MODE_ADDR_MODE;
if (!renesas_sdhi_internal_dmac_map(host, data, COOKIE_MAPPED))
@@ -417,7 +417,7 @@ renesas_sdhi_internal_dmac_start_dma(struct tmio_mmc_host *host,
if (data->flags & MMC_DATA_READ) {
dtran_mode |= DTRAN_MODE_CH_NUM_CH1;
- if (priv->quirks && priv->quirks->dma_one_rx_only &&
+ if (sdhi_has_quirk(priv, dma_one_rx_only) &&
test_and_set_bit(SDHI_INTERNAL_DMAC_RX_IN_USE, &global_flags))
goto force_pio_with_unmap;
} else {
--
2.43.0
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [PATCH 6.1.y-cip 09/17] mmc: renesas_sdhi: use plain numbers for end_flags
2025-06-23 14:46 [PATCH 6.1.y-cip 00/17] Add support for RZ/G3E SDHI Tommaso Merciai
` (7 preceding siblings ...)
2025-06-23 14:46 ` [PATCH 6.1.y-cip 08/17] mmc: renesas_sdhi: add helper to access quirks Tommaso Merciai
@ 2025-06-23 14:46 ` Tommaso Merciai
2025-06-23 14:46 ` [PATCH 6.1.y-cip 10/17] mmc: renesas_sdhi: use typedef for dma_filter_fn Tommaso Merciai
` (8 subsequent siblings)
17 siblings, 0 replies; 21+ messages in thread
From: Tommaso Merciai @ 2025-06-23 14:46 UTC (permalink / raw)
To: cip-dev, Nobuhiro Iwamatsu, Pavel Machek
Cc: Biju Das, Lad Prabhakar, tomm.merciai
From: Wolfram Sang <wsa+renesas@sang-engineering.com>
commit ffbace4378dc1aedb02248bbbe5d231754e4df3a upstream.
Linux *_bit accessors take plain bit numbers, no need for BIT().
Fixes: c330601c9c93 ("mmc: renesas_sdhi: take DMA end interrupts into account")
Reported-by: kernel test robot <lkp@intel.com>
Reported-by: Dan Carpenter <error27@gmail.com>
Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Link: https://lore.kernel.org/r/20221122080554.4468-1-wsa+renesas@sang-engineering.com
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
Signed-off-by: Tommaso Merciai <tommaso.merciai.xr@bp.renesas.com>
---
drivers/mmc/host/renesas_sdhi.h | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/mmc/host/renesas_sdhi.h b/drivers/mmc/host/renesas_sdhi.h
index ea2a85174a09..68da3da9e2e5 100644
--- a/drivers/mmc/host/renesas_sdhi.h
+++ b/drivers/mmc/host/renesas_sdhi.h
@@ -57,8 +57,8 @@ struct renesas_sdhi_of_data_with_quirks {
};
/* We want both end_flags to be set before we mark DMA as finished */
-#define SDHI_DMA_END_FLAG_DMA BIT(0)
-#define SDHI_DMA_END_FLAG_ACCESS BIT(1)
+#define SDHI_DMA_END_FLAG_DMA 0
+#define SDHI_DMA_END_FLAG_ACCESS 1
struct renesas_sdhi_dma {
unsigned long end_flags;
--
2.43.0
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [PATCH 6.1.y-cip 10/17] mmc: renesas_sdhi: use typedef for dma_filter_fn
2025-06-23 14:46 [PATCH 6.1.y-cip 00/17] Add support for RZ/G3E SDHI Tommaso Merciai
` (8 preceding siblings ...)
2025-06-23 14:46 ` [PATCH 6.1.y-cip 09/17] mmc: renesas_sdhi: use plain numbers for end_flags Tommaso Merciai
@ 2025-06-23 14:46 ` Tommaso Merciai
2025-06-23 14:46 ` [PATCH 6.1.y-cip 11/17] mmc: renesas_sdhi: Add support for RZ/G3E SoC Tommaso Merciai
` (7 subsequent siblings)
17 siblings, 0 replies; 21+ messages in thread
From: Tommaso Merciai @ 2025-06-23 14:46 UTC (permalink / raw)
To: cip-dev, Nobuhiro Iwamatsu, Pavel Machek
Cc: Biju Das, Lad Prabhakar, tomm.merciai
From: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
commit d6e5288c8bf4f9bfbb9d3630d8605f45f15a525f upstream.
Use existing typedef for dma_filter_fn to avoid duplicating type
definition.
Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Reviewed-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Link: https://lore.kernel.org/r/20240208202137.630281-1-krzysztof.kozlowski@linaro.org
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
Signed-off-by: Tommaso Merciai <tommaso.merciai.xr@bp.renesas.com>
---
drivers/mmc/host/renesas_sdhi.h | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/mmc/host/renesas_sdhi.h b/drivers/mmc/host/renesas_sdhi.h
index 68da3da9e2e5..770850ee067f 100644
--- a/drivers/mmc/host/renesas_sdhi.h
+++ b/drivers/mmc/host/renesas_sdhi.h
@@ -9,6 +9,7 @@
#ifndef RENESAS_SDHI_H
#define RENESAS_SDHI_H
+#include <linux/dmaengine.h>
#include <linux/platform_device.h>
#include "tmio_mmc.h"
@@ -63,7 +64,7 @@ struct renesas_sdhi_of_data_with_quirks {
struct renesas_sdhi_dma {
unsigned long end_flags;
enum dma_slave_buswidth dma_buswidth;
- bool (*filter)(struct dma_chan *chan, void *arg);
+ dma_filter_fn filter;
void (*enable)(struct tmio_mmc_host *host, bool enable);
struct completion dma_dataend;
struct tasklet_struct dma_complete;
--
2.43.0
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [PATCH 6.1.y-cip 11/17] mmc: renesas_sdhi: Add support for RZ/G3E SoC
2025-06-23 14:46 [PATCH 6.1.y-cip 00/17] Add support for RZ/G3E SDHI Tommaso Merciai
` (9 preceding siblings ...)
2025-06-23 14:46 ` [PATCH 6.1.y-cip 10/17] mmc: renesas_sdhi: use typedef for dma_filter_fn Tommaso Merciai
@ 2025-06-23 14:46 ` Tommaso Merciai
2025-06-23 14:46 ` [PATCH 6.1.y-cip 12/17] mmc: renesas_sdhi: Use of_get_available_child_by_name() Tommaso Merciai
` (6 subsequent siblings)
17 siblings, 0 replies; 21+ messages in thread
From: Tommaso Merciai @ 2025-06-23 14:46 UTC (permalink / raw)
To: cip-dev, Nobuhiro Iwamatsu, Pavel Machek
Cc: Biju Das, Lad Prabhakar, tomm.merciai
From: Biju Das <biju.das.jz@bp.renesas.com>
commit fae80a99dc0320be854aa789cbe7ed0e1e574c61 upstream.
The SDHI/eMMC IPs in the RZ/G3E SoC are similar to those in R-Car Gen3.
However, the RZ/G3E SD0 channel has Voltage level control and PWEN pin
support via SD_STATUS register.
internal regulator support is added to control the voltage levels of
the SD pins via sd_iovs/sd_pwen bits in SD_STATUS register by populating
vqmmc-regulator child node.
SD1 and SD2 channels have gpio regulator support and internal regulator
support. Selection of the regulator is based on the regulator phandle.
Similar case for SD0 fixed voltage (eMMC) that uses fixed regulator and
SD0 non-fixed voltage (SD0) that uses internal regulator.
Reviewed-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
Link: https://lore.kernel.org/r/20250305092958.21865-3-biju.das.jz@bp.renesas.com
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
[tommaso: Squashed the commits ede057759b83("mmc: renesas_sdhi: fix
error code in renesas_sdhi_probe()") and
77183db6b8db("mmc: renesas_sdhi: disable clocks if registering
regulator failed") and
9078f01fec12("mmc: renesas_sdhi: add regulator dependency")]
Signed-off-by: Tommaso Merciai <tommaso.merciai.xr@bp.renesas.com>
---
drivers/mmc/host/Kconfig | 2 +-
drivers/mmc/host/renesas_sdhi.h | 2 +
drivers/mmc/host/renesas_sdhi_core.c | 133 +++++++++++++++++++++++++++
drivers/mmc/host/tmio_mmc.h | 10 ++
4 files changed, 146 insertions(+), 1 deletion(-)
diff --git a/drivers/mmc/host/Kconfig b/drivers/mmc/host/Kconfig
index 525a9ff39a54..eda621cdafa1 100644
--- a/drivers/mmc/host/Kconfig
+++ b/drivers/mmc/host/Kconfig
@@ -713,8 +713,8 @@ config MMC_TMIO
config MMC_SDHI
tristate "Renesas SDHI SD/SDIO controller support"
depends on SUPERH || ARCH_RENESAS || COMPILE_TEST
+ depends on (RESET_CONTROLLER && REGULATOR) || !OF
select MMC_TMIO_CORE
- select RESET_CONTROLLER if ARCH_RENESAS
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 770850ee067f..517c21ea9751 100644
--- a/drivers/mmc/host/renesas_sdhi.h
+++ b/drivers/mmc/host/renesas_sdhi.h
@@ -93,6 +93,8 @@ struct renesas_sdhi {
unsigned int tap_set;
struct reset_control *rstc;
+ struct tmio_mmc_host *host;
+ struct regulator_dev *rdev;
};
#define host_to_priv(host) \
diff --git a/drivers/mmc/host/renesas_sdhi_core.c b/drivers/mmc/host/renesas_sdhi_core.c
index 4052ef027647..cb089997e4bb 100644
--- a/drivers/mmc/host/renesas_sdhi_core.c
+++ b/drivers/mmc/host/renesas_sdhi_core.c
@@ -32,6 +32,8 @@
#include <linux/platform_device.h>
#include <linux/pm_domain.h>
#include <linux/regulator/consumer.h>
+#include <linux/regulator/driver.h>
+#include <linux/regulator/of_regulator.h>
#include <linux/reset.h>
#include <linux/sh_dma.h>
#include <linux/slab.h>
@@ -581,12 +583,24 @@ static void renesas_sdhi_reset(struct tmio_mmc_host *host, bool preserve)
if (!preserve) {
if (priv->rstc) {
+ u32 sd_status;
+ /*
+ * HW reset might have toggled the regulator state in
+ * HW which regulator core might be unaware of so save
+ * and restore the regulator state during HW reset.
+ */
+ if (priv->rdev)
+ sd_status = sd_ctrl_read32(host, CTL_SD_STATUS);
+
reset_control_reset(priv->rstc);
/* Unknown why but without polling reset status, it will hang */
read_poll_timeout(reset_control_status, ret, ret == 0, 1, 100,
false, priv->rstc);
/* At least SDHI_VER_GEN2_SDR50 needs manual release of reset */
sd_ctrl_write16(host, CTL_RESET_SD, 0x0001);
+ if (priv->rdev)
+ sd_ctrl_write32(host, CTL_SD_STATUS, sd_status);
+
priv->needs_adjust_hs400 = false;
renesas_sdhi_set_clock(host, host->clk_cache);
} else if (priv->scc_ctl) {
@@ -901,6 +915,102 @@ static void renesas_sdhi_enable_dma(struct tmio_mmc_host *host, bool enable)
renesas_sdhi_sdbuf_width(host, enable ? width : 16);
}
+static const unsigned int renesas_sdhi_vqmmc_voltages[] = {
+ 3300000, 1800000
+};
+
+static int renesas_sdhi_regulator_disable(struct regulator_dev *rdev)
+{
+ struct tmio_mmc_host *host = rdev_get_drvdata(rdev);
+ u32 sd_status;
+
+ sd_status = sd_ctrl_read32(host, CTL_SD_STATUS);
+ sd_status &= ~SD_STATUS_PWEN;
+ sd_ctrl_write32(host, CTL_SD_STATUS, sd_status);
+
+ return 0;
+}
+
+static int renesas_sdhi_regulator_enable(struct regulator_dev *rdev)
+{
+ struct tmio_mmc_host *host = rdev_get_drvdata(rdev);
+ u32 sd_status;
+
+ sd_status = sd_ctrl_read32(host, CTL_SD_STATUS);
+ sd_status |= SD_STATUS_PWEN;
+ sd_ctrl_write32(host, CTL_SD_STATUS, sd_status);
+
+ return 0;
+}
+
+static int renesas_sdhi_regulator_is_enabled(struct regulator_dev *rdev)
+{
+ struct tmio_mmc_host *host = rdev_get_drvdata(rdev);
+ u32 sd_status;
+
+ sd_status = sd_ctrl_read32(host, CTL_SD_STATUS);
+
+ return (sd_status & SD_STATUS_PWEN) ? 1 : 0;
+}
+
+static int renesas_sdhi_regulator_get_voltage(struct regulator_dev *rdev)
+{
+ struct tmio_mmc_host *host = rdev_get_drvdata(rdev);
+ u32 sd_status;
+
+ sd_status = sd_ctrl_read32(host, CTL_SD_STATUS);
+
+ return (sd_status & SD_STATUS_IOVS) ? 1800000 : 3300000;
+}
+
+static int renesas_sdhi_regulator_set_voltage(struct regulator_dev *rdev,
+ int min_uV, int max_uV,
+ unsigned int *selector)
+{
+ struct tmio_mmc_host *host = rdev_get_drvdata(rdev);
+ u32 sd_status;
+
+ sd_status = sd_ctrl_read32(host, CTL_SD_STATUS);
+ if (min_uV >= 1700000 && max_uV <= 1950000) {
+ sd_status |= SD_STATUS_IOVS;
+ *selector = 1;
+ } else {
+ sd_status &= ~SD_STATUS_IOVS;
+ *selector = 0;
+ }
+ sd_ctrl_write32(host, CTL_SD_STATUS, sd_status);
+
+ return 0;
+}
+
+static int renesas_sdhi_regulator_list_voltage(struct regulator_dev *rdev,
+ unsigned int selector)
+{
+ if (selector >= ARRAY_SIZE(renesas_sdhi_vqmmc_voltages))
+ return -EINVAL;
+
+ return renesas_sdhi_vqmmc_voltages[selector];
+}
+
+static const struct regulator_ops renesas_sdhi_regulator_voltage_ops = {
+ .enable = renesas_sdhi_regulator_enable,
+ .disable = renesas_sdhi_regulator_disable,
+ .is_enabled = renesas_sdhi_regulator_is_enabled,
+ .list_voltage = renesas_sdhi_regulator_list_voltage,
+ .get_voltage = renesas_sdhi_regulator_get_voltage,
+ .set_voltage = renesas_sdhi_regulator_set_voltage,
+};
+
+static const struct regulator_desc renesas_sdhi_vqmmc_regulator = {
+ .name = "sdhi-vqmmc-regulator",
+ .of_match = of_match_ptr("vqmmc-regulator"),
+ .type = REGULATOR_VOLTAGE,
+ .owner = THIS_MODULE,
+ .ops = &renesas_sdhi_regulator_voltage_ops,
+ .volt_table = renesas_sdhi_vqmmc_voltages,
+ .n_voltages = ARRAY_SIZE(renesas_sdhi_vqmmc_voltages),
+};
+
int renesas_sdhi_probe(struct platform_device *pdev,
const struct tmio_mmc_dma_ops *dma_ops,
const struct renesas_sdhi_of_data *of_data,
@@ -908,7 +1018,10 @@ int renesas_sdhi_probe(struct platform_device *pdev,
{
struct tmio_mmc_data *mmd = pdev->dev.platform_data;
struct tmio_mmc_data *mmc_data;
+ struct regulator_config rcfg = { .dev = &pdev->dev, };
+ struct regulator_dev *rdev;
struct renesas_sdhi_dma *dma_priv;
+ struct device *dev = &pdev->dev;
struct tmio_mmc_host *host;
struct renesas_sdhi *priv;
int num_irqs, irq, ret, i;
@@ -967,6 +1080,8 @@ int renesas_sdhi_probe(struct platform_device *pdev,
if (IS_ERR(host))
return PTR_ERR(host);
+ priv->host = host;
+
if (of_data) {
mmc_data->flags |= of_data->tmio_flags;
mmc_data->ocr_mask = of_data->tmio_ocr_mask;
@@ -1049,6 +1164,24 @@ int renesas_sdhi_probe(struct platform_device *pdev,
if (ret)
goto efree;
+ rcfg.of_node = of_get_child_by_name(dev->of_node, "vqmmc-regulator");
+ if (!of_device_is_available(rcfg.of_node)) {
+ of_node_put(rcfg.of_node);
+ rcfg.of_node = NULL;
+ }
+
+ if (rcfg.of_node) {
+ rcfg.driver_data = priv->host;
+ rdev = devm_regulator_register(dev, &renesas_sdhi_vqmmc_regulator, &rcfg);
+ of_node_put(rcfg.of_node);
+ if (IS_ERR(rdev)) {
+ dev_err(dev, "regulator register failed err=%ld", PTR_ERR(rdev));
+ ret = PTR_ERR(rdev);
+ goto edisclk;
+ }
+ priv->rdev = rdev;
+ }
+
ver = sd_ctrl_read16(host, CTL_VERSION);
/* GEN2_SDR104 is first known SDHI to use 32bit block count */
if (ver < SDHI_VER_GEN2_SDR104 && mmc_data->max_blk_count > U16_MAX)
diff --git a/drivers/mmc/host/tmio_mmc.h b/drivers/mmc/host/tmio_mmc.h
index 873a06a179c8..86bf13fa8bde 100644
--- a/drivers/mmc/host/tmio_mmc.h
+++ b/drivers/mmc/host/tmio_mmc.h
@@ -43,6 +43,7 @@
#define CTL_RESET_SD 0xe0
#define CTL_VERSION 0xe2
#define CTL_SDIF_MODE 0xe6 /* only known on R-Car 2+ */
+#define CTL_SD_STATUS 0xf2 /* only known on RZ/{G2L,G3E,V2H} */
/* Definitions for values the CTL_STOP_INTERNAL_ACTION register can take */
#define TMIO_STOP_STP BIT(0)
@@ -102,6 +103,10 @@
/* Definitions for values the CTL_SDIF_MODE register can take */
#define SDIF_MODE_HS400 BIT(0) /* only known on R-Car 2+ */
+/* Definitions for values the CTL_SD_STATUS register can take */
+#define SD_STATUS_PWEN BIT(0) /* only known on RZ/{G3E,V2H} */
+#define SD_STATUS_IOVS BIT(16) /* only known on RZ/{G3E,V2H} */
+
/* Define some IRQ masks */
/* This is the mask used at reset by the chip */
#define TMIO_MASK_ALL 0x837f031d
@@ -242,6 +247,11 @@ static inline u32 sd_ctrl_read16_and_16_as_32(struct tmio_mmc_host *host,
ioread16(host->ctl + ((addr + 2) << host->bus_shift)) << 16;
}
+static inline u32 sd_ctrl_read32(struct tmio_mmc_host *host, int addr)
+{
+ return ioread32(host->ctl + (addr << host->bus_shift));
+}
+
static inline void sd_ctrl_read32_rep(struct tmio_mmc_host *host, int addr,
u32 *buf, int count)
{
--
2.43.0
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [PATCH 6.1.y-cip 12/17] mmc: renesas_sdhi: Use of_get_available_child_by_name()
2025-06-23 14:46 [PATCH 6.1.y-cip 00/17] Add support for RZ/G3E SDHI Tommaso Merciai
` (10 preceding siblings ...)
2025-06-23 14:46 ` [PATCH 6.1.y-cip 11/17] mmc: renesas_sdhi: Add support for RZ/G3E SoC Tommaso Merciai
@ 2025-06-23 14:46 ` Tommaso Merciai
2025-06-23 14:46 ` [PATCH 6.1.y-cip 13/17] arm64: dts: renesas: r9a09g047: Add SDHI0-SDHI2 nodes Tommaso Merciai
` (5 subsequent siblings)
17 siblings, 0 replies; 21+ messages in thread
From: Tommaso Merciai @ 2025-06-23 14:46 UTC (permalink / raw)
To: cip-dev, Nobuhiro Iwamatsu, Pavel Machek
Cc: Biju Das, Lad Prabhakar, tomm.merciai
From: Biju Das <biju.das.jz@bp.renesas.com>
commit 18da3ecdbaf6f140eb45818fd848b85d2c414db6 upstream.
Use the helper of_get_available_child_by_name() to simplify
renesas_sdhi_probe().
Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
Reviewed-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Tested-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Link: https://lore.kernel.org/r/20250407092144.35268-1-biju.das.jz@bp.renesas.com
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
Signed-off-by: Tommaso Merciai <tommaso.merciai.xr@bp.renesas.com>
---
drivers/mmc/host/renesas_sdhi_core.c | 7 +------
1 file changed, 1 insertion(+), 6 deletions(-)
diff --git a/drivers/mmc/host/renesas_sdhi_core.c b/drivers/mmc/host/renesas_sdhi_core.c
index cb089997e4bb..725bd37b8c21 100644
--- a/drivers/mmc/host/renesas_sdhi_core.c
+++ b/drivers/mmc/host/renesas_sdhi_core.c
@@ -1164,12 +1164,7 @@ int renesas_sdhi_probe(struct platform_device *pdev,
if (ret)
goto efree;
- rcfg.of_node = of_get_child_by_name(dev->of_node, "vqmmc-regulator");
- if (!of_device_is_available(rcfg.of_node)) {
- of_node_put(rcfg.of_node);
- rcfg.of_node = NULL;
- }
-
+ rcfg.of_node = of_get_available_child_by_name(dev->of_node, "vqmmc-regulator");
if (rcfg.of_node) {
rcfg.driver_data = priv->host;
rdev = devm_regulator_register(dev, &renesas_sdhi_vqmmc_regulator, &rcfg);
--
2.43.0
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [PATCH 6.1.y-cip 13/17] arm64: dts: renesas: r9a09g047: Add SDHI0-SDHI2 nodes
2025-06-23 14:46 [PATCH 6.1.y-cip 00/17] Add support for RZ/G3E SDHI Tommaso Merciai
` (11 preceding siblings ...)
2025-06-23 14:46 ` [PATCH 6.1.y-cip 12/17] mmc: renesas_sdhi: Use of_get_available_child_by_name() Tommaso Merciai
@ 2025-06-23 14:46 ` Tommaso Merciai
2025-06-23 14:46 ` [PATCH 6.1.y-cip 14/17] arm64: dts: renesas: r9a09g057: Add support for enabling SDHI internal regulator Tommaso Merciai
` (4 subsequent siblings)
17 siblings, 0 replies; 21+ messages in thread
From: Tommaso Merciai @ 2025-06-23 14:46 UTC (permalink / raw)
To: cip-dev, Nobuhiro Iwamatsu, Pavel Machek
Cc: Biju Das, Lad Prabhakar, tomm.merciai
From: Biju Das <biju.das.jz@bp.renesas.com>
commit c4e4e22870acae3a3fe3fe0638f85175976dc906 upstream.
Add SDHI0-SDHI2 nodes to RZ/G3E ("R9A09G047") SoC DTSI.
Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
Reviewed-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Link: https://lore.kernel.org/20250206134047.67866-5-biju.das.jz@bp.renesas.com
Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
Signed-off-by: Tommaso Merciai <tommaso.merciai.xr@bp.renesas.com>
---
arch/arm64/boot/dts/renesas/r9a09g047.dtsi | 60 ++++++++++++++++++++++
1 file changed, 60 insertions(+)
diff --git a/arch/arm64/boot/dts/renesas/r9a09g047.dtsi b/arch/arm64/boot/dts/renesas/r9a09g047.dtsi
index 133aa3272d3a..928757b52b4a 100644
--- a/arch/arm64/boot/dts/renesas/r9a09g047.dtsi
+++ b/arch/arm64/boot/dts/renesas/r9a09g047.dtsi
@@ -403,6 +403,66 @@ gic: interrupt-controller@14900000 {
interrupt-controller;
interrupts = <GIC_PPI 9 IRQ_TYPE_LEVEL_LOW>;
};
+
+ sdhi0: mmc@15c00000 {
+ compatible = "renesas,sdhi-r9a09g047", "renesas,sdhi-r9a09g057";
+ reg = <0x0 0x15c00000 0 0x10000>;
+ interrupts = <GIC_SPI 735 IRQ_TYPE_LEVEL_HIGH>,
+ <GIC_SPI 736 IRQ_TYPE_LEVEL_HIGH>;
+ clocks = <&cpg CPG_MOD 0xa3>, <&cpg CPG_MOD 0xa5>,
+ <&cpg CPG_MOD 0xa4>, <&cpg CPG_MOD 0xa6>;
+ clock-names = "core", "clkh", "cd", "aclk";
+ resets = <&cpg 0xa7>;
+ power-domains = <&cpg>;
+ status = "disabled";
+
+ sdhi0_vqmmc: vqmmc-regulator {
+ regulator-name = "SDHI0-VQMMC";
+ regulator-min-microvolt = <1800000>;
+ regulator-max-microvolt = <3300000>;
+ status = "disabled";
+ };
+ };
+
+ sdhi1: mmc@15c10000 {
+ compatible = "renesas,sdhi-r9a09g047", "renesas,sdhi-r9a09g057";
+ reg = <0x0 0x15c10000 0 0x10000>;
+ interrupts = <GIC_SPI 737 IRQ_TYPE_LEVEL_HIGH>,
+ <GIC_SPI 738 IRQ_TYPE_LEVEL_HIGH>;
+ clocks = <&cpg CPG_MOD 0xa7>, <&cpg CPG_MOD 0xa9>,
+ <&cpg CPG_MOD 0xa8>, <&cpg CPG_MOD 0xaa>;
+ clock-names = "core", "clkh", "cd", "aclk";
+ resets = <&cpg 0xa8>;
+ power-domains = <&cpg>;
+ status = "disabled";
+
+ sdhi1_vqmmc: vqmmc-regulator {
+ regulator-name = "SDHI1-VQMMC";
+ regulator-min-microvolt = <1800000>;
+ regulator-max-microvolt = <3300000>;
+ status = "disabled";
+ };
+ };
+
+ sdhi2: mmc@15c20000 {
+ compatible = "renesas,sdhi-r9a09g047", "renesas,sdhi-r9a09g057";
+ reg = <0x0 0x15c20000 0 0x10000>;
+ interrupts = <GIC_SPI 739 IRQ_TYPE_LEVEL_HIGH>,
+ <GIC_SPI 740 IRQ_TYPE_LEVEL_HIGH>;
+ clocks = <&cpg CPG_MOD 0xab>, <&cpg CPG_MOD 0xad>,
+ <&cpg CPG_MOD 0xac>, <&cpg CPG_MOD 0xae>;
+ clock-names = "core", "clkh", "cd", "aclk";
+ resets = <&cpg 0xa9>;
+ power-domains = <&cpg>;
+ status = "disabled";
+
+ sdhi2_vqmmc: vqmmc-regulator {
+ regulator-name = "SDHI2-VQMMC";
+ regulator-min-microvolt = <1800000>;
+ regulator-max-microvolt = <3300000>;
+ status = "disabled";
+ };
+ };
};
timer {
--
2.43.0
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [PATCH 6.1.y-cip 14/17] arm64: dts: renesas: r9a09g057: Add support for enabling SDHI internal regulator
2025-06-23 14:46 [PATCH 6.1.y-cip 00/17] Add support for RZ/G3E SDHI Tommaso Merciai
` (12 preceding siblings ...)
2025-06-23 14:46 ` [PATCH 6.1.y-cip 13/17] arm64: dts: renesas: r9a09g047: Add SDHI0-SDHI2 nodes Tommaso Merciai
@ 2025-06-23 14:46 ` Tommaso Merciai
2025-06-23 14:46 ` [PATCH 6.1.y-cip 15/17] arm64: dts: renesas: rzg3e-smarc-som: Enable SDHI{0,2} Tommaso Merciai
` (3 subsequent siblings)
17 siblings, 0 replies; 21+ messages in thread
From: Tommaso Merciai @ 2025-06-23 14:46 UTC (permalink / raw)
To: cip-dev, Nobuhiro Iwamatsu, Pavel Machek
Cc: Biju Das, Lad Prabhakar, tomm.merciai
From: Biju Das <biju.das.jz@bp.renesas.com>
commit 674080a22768dd4c30f2272acbe03fe94c7387cf upstream.
Add support for enabling SDHI internal regulator, by overriding the
status on the board DTS, when needed.
Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
Reviewed-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Link: https://lore.kernel.org/20250206134047.67866-6-biju.das.jz@bp.renesas.com
Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
Signed-off-by: Tommaso Merciai <tommaso.merciai.xr@bp.renesas.com>
---
arch/arm64/boot/dts/renesas/r9a09g057.dtsi | 21 +++++++++++++++++++++
1 file changed, 21 insertions(+)
diff --git a/arch/arm64/boot/dts/renesas/r9a09g057.dtsi b/arch/arm64/boot/dts/renesas/r9a09g057.dtsi
index 3a433f1e940c..0f8a769f1cbc 100644
--- a/arch/arm64/boot/dts/renesas/r9a09g057.dtsi
+++ b/arch/arm64/boot/dts/renesas/r9a09g057.dtsi
@@ -512,6 +512,13 @@ sdhi0: mmc@15c00000 {
resets = <&cpg 0xa7>;
power-domains = <&cpg>;
status = "disabled";
+
+ sdhi0_vqmmc: vqmmc-regulator {
+ regulator-name = "SDHI0-VQMMC";
+ regulator-min-microvolt = <1800000>;
+ regulator-max-microvolt = <3300000>;
+ status = "disabled";
+ };
};
sdhi1: mmc@15c10000 {
@@ -525,6 +532,13 @@ sdhi1: mmc@15c10000 {
resets = <&cpg 0xa8>;
power-domains = <&cpg>;
status = "disabled";
+
+ sdhi1_vqmmc: vqmmc-regulator {
+ regulator-name = "SDHI1-VQMMC";
+ regulator-min-microvolt = <1800000>;
+ regulator-max-microvolt = <3300000>;
+ status = "disabled";
+ };
};
sdhi2: mmc@15c20000 {
@@ -538,6 +552,13 @@ sdhi2: mmc@15c20000 {
resets = <&cpg 0xa9>;
power-domains = <&cpg>;
status = "disabled";
+
+ sdhi2_vqmmc: vqmmc-regulator {
+ regulator-name = "SDHI2-VQMMC";
+ regulator-min-microvolt = <1800000>;
+ regulator-max-microvolt = <3300000>;
+ status = "disabled";
+ };
};
};
--
2.43.0
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [PATCH 6.1.y-cip 15/17] arm64: dts: renesas: rzg3e-smarc-som: Enable SDHI{0,2}
2025-06-23 14:46 [PATCH 6.1.y-cip 00/17] Add support for RZ/G3E SDHI Tommaso Merciai
` (13 preceding siblings ...)
2025-06-23 14:46 ` [PATCH 6.1.y-cip 14/17] arm64: dts: renesas: r9a09g057: Add support for enabling SDHI internal regulator Tommaso Merciai
@ 2025-06-23 14:46 ` Tommaso Merciai
2025-06-23 14:46 ` [PATCH 6.1.y-cip 16/17] arm64: dts: renesas: rzg3e-smarc-som: Add support to enable SD on SDHI0 Tommaso Merciai
` (2 subsequent siblings)
17 siblings, 0 replies; 21+ messages in thread
From: Tommaso Merciai @ 2025-06-23 14:46 UTC (permalink / raw)
To: cip-dev, Nobuhiro Iwamatsu, Pavel Machek
Cc: Biju Das, Lad Prabhakar, tomm.merciai
From: Biju Das <biju.das.jz@bp.renesas.com>
commit 16bce534a391487c56aa266dff2ac5733b207f5c upstream.
Enable eMMC on SDHI0 and SD on SDHI2 on RZ/G3E SMARC SoM.
Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
Link: https://lore.kernel.org/20250206134047.67866-7-biju.das.jz@bp.renesas.com
Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
Signed-off-by: Tommaso Merciai <tommaso.merciai.xr@bp.renesas.com>
---
.../boot/dts/renesas/rzg3e-smarc-som.dtsi | 100 ++++++++++++++++++
1 file changed, 100 insertions(+)
diff --git a/arch/arm64/boot/dts/renesas/rzg3e-smarc-som.dtsi b/arch/arm64/boot/dts/renesas/rzg3e-smarc-som.dtsi
index f4ba050beb0d..fcbabe2cb003 100644
--- a/arch/arm64/boot/dts/renesas/rzg3e-smarc-som.dtsi
+++ b/arch/arm64/boot/dts/renesas/rzg3e-smarc-som.dtsi
@@ -8,17 +8,86 @@
/ {
compatible = "renesas,rzg3e-smarcm", "renesas,r9a09g047e57", "renesas,r9a09g047";
+ aliases {
+ mmc0 = &sdhi0;
+ mmc2 = &sdhi2;
+ };
+
memory@48000000 {
device_type = "memory";
/* First 128MB is reserved for secure area. */
reg = <0x0 0x48000000 0x0 0xf8000000>;
};
+
+ reg_1p8v: regulator-1p8v {
+ compatible = "regulator-fixed";
+ regulator-name = "fixed-1.8V";
+ regulator-min-microvolt = <1800000>;
+ regulator-max-microvolt = <1800000>;
+ regulator-boot-on;
+ regulator-always-on;
+ };
+
+ reg_3p3v: regulator-3p3v {
+ compatible = "regulator-fixed";
+ regulator-name = "fixed-3.3V";
+ regulator-min-microvolt = <3300000>;
+ regulator-max-microvolt = <3300000>;
+ regulator-boot-on;
+ regulator-always-on;
+ };
};
&audio_extal_clk {
clock-frequency = <48000000>;
};
+&pinctrl {
+ sdhi0_emmc_pins: sd0-emmc {
+ sd0-ctrl {
+ pins = "SD0CLK", "SD0CMD";
+ renesas,output-impedance = <3>;
+ };
+
+ sd0-data {
+ pins = "SD0DAT0", "SD0DAT1", "SD0DAT2", "SD0DAT3",
+ "SD0DAT4", "SD0DAT5", "SD0DAT6", "SD0DAT7";
+ renesas,output-impedance = <3>;
+ };
+
+ sd0-rst {
+ pins = "SD0RSTN";
+ renesas,output-impedance = <3>;
+ };
+ };
+
+ sdhi2_pins: sd2 {
+ sd2-cd {
+ pinmux = <RZG3E_PORT_PINMUX(K, 0, 1)>; /* SD2CD */
+ };
+
+ sd2-ctrl {
+ pinmux = <RZG3E_PORT_PINMUX(H, 0, 1)>, /* SD2CLK */
+ <RZG3E_PORT_PINMUX(H, 1, 1)>; /* SD2CMD */
+ };
+
+ sd2-data {
+ pinmux = <RZG3E_PORT_PINMUX(H, 2, 1)>, /* SD2DAT0 */
+ <RZG3E_PORT_PINMUX(H, 3, 1)>, /* SD2DAT1 */
+ <RZG3E_PORT_PINMUX(H, 4, 1)>, /* SD2DAT2 */
+ <RZG3E_PORT_PINMUX(H, 5, 1)>; /* SD2DAT3 */
+ };
+
+ sd2-iovs {
+ pinmux = <RZG3E_PORT_PINMUX(K, 1, 1)>; /* SD2IOVS */
+ };
+
+ sd2-pwen {
+ pinmux = <RZG3E_PORT_PINMUX(K, 2, 1)>; /* SD2PWEN */
+ };
+ };
+};
+
&qextal_clk {
clock-frequency = <24000000>;
};
@@ -27,6 +96,37 @@ &rtxin_clk {
clock-frequency = <32768>;
};
+&sdhi0 {
+ pinctrl-0 = <&sdhi0_emmc_pins>;
+ pinctrl-1 = <&sdhi0_emmc_pins>;
+ pinctrl-names = "default", "state_uhs";
+
+ vmmc-supply = <®_3p3v>;
+ vqmmc-supply = <®_1p8v>;
+ bus-width = <8>;
+ mmc-hs200-1_8v;
+ non-removable;
+ fixed-emmc-driver-type = <1>;
+ status = "okay";
+};
+
+&sdhi2 {
+ pinctrl-0 = <&sdhi2_pins>;
+ pinctrl-1 = <&sdhi2_pins>;
+ pinctrl-names = "default", "state_uhs";
+
+ vmmc-supply = <®_3p3v>;
+ vqmmc-supply = <&sdhi2_vqmmc>;
+ bus-width = <4>;
+ sd-uhs-sdr50;
+ sd-uhs-sdr104;
+ status = "okay";
+};
+
+&sdhi2_vqmmc {
+ status = "okay";
+};
+
&wdt1 {
status = "okay";
};
--
2.43.0
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [PATCH 6.1.y-cip 16/17] arm64: dts: renesas: rzg3e-smarc-som: Add support to enable SD on SDHI0
2025-06-23 14:46 [PATCH 6.1.y-cip 00/17] Add support for RZ/G3E SDHI Tommaso Merciai
` (14 preceding siblings ...)
2025-06-23 14:46 ` [PATCH 6.1.y-cip 15/17] arm64: dts: renesas: rzg3e-smarc-som: Enable SDHI{0,2} Tommaso Merciai
@ 2025-06-23 14:46 ` Tommaso Merciai
2025-06-23 14:46 ` [PATCH 6.1.y-cip 17/17] arm64: dts: renesas: r9a09g047e57-smarc: Enable SDHI1 Tommaso Merciai
2025-06-24 7:24 ` [PATCH 6.1.y-cip 00/17] Add support for RZ/G3E SDHI nobuhiro1.iwamatsu
17 siblings, 0 replies; 21+ messages in thread
From: Tommaso Merciai @ 2025-06-23 14:46 UTC (permalink / raw)
To: cip-dev, Nobuhiro Iwamatsu, Pavel Machek
Cc: Biju Das, Lad Prabhakar, tomm.merciai
From: Biju Das <biju.das.jz@bp.renesas.com>
commit 4c85281bed1732693f2f2e32cf60e0e30722d06e upstream.
Add support for enabling SD on SDHI0 on RZ/G3E SMARC SoM. It is enabled
by setting the macro SW_SD0_DEV_SEL to 1 in board DTS and setting the
switch SYS.1 to ON position on the SoM.
Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
Link: https://lore.kernel.org/20250206134047.67866-8-biju.das.jz@bp.renesas.com
Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
Signed-off-by: Tommaso Merciai <tommaso.merciai.xr@bp.renesas.com>
---
.../boot/dts/renesas/r9a09g047e57-smarc.dts | 3 ++
.../boot/dts/renesas/rzg3e-smarc-som.dtsi | 54 +++++++++++++++++++
2 files changed, 57 insertions(+)
diff --git a/arch/arm64/boot/dts/renesas/r9a09g047e57-smarc.dts b/arch/arm64/boot/dts/renesas/r9a09g047e57-smarc.dts
index c063d47e2952..152a00aa354b 100644
--- a/arch/arm64/boot/dts/renesas/r9a09g047e57-smarc.dts
+++ b/arch/arm64/boot/dts/renesas/r9a09g047e57-smarc.dts
@@ -7,6 +7,9 @@
/dts-v1/;
+/* Switch selection settings */
+#define SW_SD0_DEV_SEL 0
+
#include <dt-bindings/pinctrl/renesas,r9a09g047-pinctrl.h>
#include "r9a09g047e57.dtsi"
#include "rzg3e-smarc-som.dtsi"
diff --git a/arch/arm64/boot/dts/renesas/rzg3e-smarc-som.dtsi b/arch/arm64/boot/dts/renesas/rzg3e-smarc-som.dtsi
index fcbabe2cb003..72b42a81bcf3 100644
--- a/arch/arm64/boot/dts/renesas/rzg3e-smarc-som.dtsi
+++ b/arch/arm64/boot/dts/renesas/rzg3e-smarc-som.dtsi
@@ -5,6 +5,15 @@
* Copyright (C) 2024 Renesas Electronics Corp.
*/
+/*
+ * Please set the switch position SYS.1 on the SoM and the corresponding macro
+ * SW_SD0_DEV_SEL on the board DTS:
+ *
+ * SW_SD0_DEV_SEL:
+ * 0 - SD0 is connected to eMMC (default)
+ * 1 - SD0 is connected to uSD0 card
+ */
+
/ {
compatible = "renesas,rzg3e-smarcm", "renesas,r9a09g047e57", "renesas,r9a09g047";
@@ -61,6 +70,32 @@ sd0-rst {
};
};
+ sdhi0_usd_pins: sd0-usd {
+ sd0-cd {
+ pinmux = <RZG3E_PORT_PINMUX(5, 0, 8)>;
+ };
+
+ sd0-ctrl {
+ pins = "SD0CLK", "SD0CMD";
+ renesas,output-impedance = <3>;
+ };
+
+ sd0-data {
+ pins = "SD0DAT0", "SD0DAT1", "SD0DAT2", "SD0DAT3";
+ renesas,output-impedance = <3>;
+ };
+
+ sd0-iovs {
+ pins = "SD0IOVS";
+ renesas,output-impedance = <3>;
+ };
+
+ sd0-pwen {
+ pins = "SD0PWEN";
+ renesas,output-impedance = <3>;
+ };
+ };
+
sdhi2_pins: sd2 {
sd2-cd {
pinmux = <RZG3E_PORT_PINMUX(K, 0, 1)>; /* SD2CD */
@@ -96,6 +131,24 @@ &rtxin_clk {
clock-frequency = <32768>;
};
+#if (SW_SD0_DEV_SEL)
+&sdhi0 {
+ pinctrl-0 = <&sdhi0_usd_pins>;
+ pinctrl-1 = <&sdhi0_usd_pins>;
+ pinctrl-names = "default", "state_uhs";
+
+ vmmc-supply = <®_3p3v>;
+ vqmmc-supply = <&sdhi0_vqmmc>;
+ bus-width = <4>;
+ sd-uhs-sdr50;
+ sd-uhs-sdr104;
+ status = "okay";
+};
+
+&sdhi0_vqmmc {
+ status = "okay";
+};
+#else
&sdhi0 {
pinctrl-0 = <&sdhi0_emmc_pins>;
pinctrl-1 = <&sdhi0_emmc_pins>;
@@ -109,6 +162,7 @@ &sdhi0 {
fixed-emmc-driver-type = <1>;
status = "okay";
};
+#endif
&sdhi2 {
pinctrl-0 = <&sdhi2_pins>;
--
2.43.0
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [PATCH 6.1.y-cip 17/17] arm64: dts: renesas: r9a09g047e57-smarc: Enable SDHI1
2025-06-23 14:46 [PATCH 6.1.y-cip 00/17] Add support for RZ/G3E SDHI Tommaso Merciai
` (15 preceding siblings ...)
2025-06-23 14:46 ` [PATCH 6.1.y-cip 16/17] arm64: dts: renesas: rzg3e-smarc-som: Add support to enable SD on SDHI0 Tommaso Merciai
@ 2025-06-23 14:46 ` Tommaso Merciai
2025-06-24 7:24 ` [PATCH 6.1.y-cip 00/17] Add support for RZ/G3E SDHI nobuhiro1.iwamatsu
17 siblings, 0 replies; 21+ messages in thread
From: Tommaso Merciai @ 2025-06-23 14:46 UTC (permalink / raw)
To: cip-dev, Nobuhiro Iwamatsu, Pavel Machek
Cc: Biju Das, Lad Prabhakar, tomm.merciai
From: Biju Das <biju.das.jz@bp.renesas.com>
commit ae9edcbc712249832beb3f5457cb03cc809f72c4 upstream.
Enable SDHI1 on the RZ/G3E SMARC EVK platform using gpio regulator for
voltage switching.
Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
Link: https://lore.kernel.org/20250206134047.67866-9-biju.das.jz@bp.renesas.com
Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
Signed-off-by: Tommaso Merciai <tommaso.merciai.xr@bp.renesas.com>
---
.../boot/dts/renesas/r9a09g047e57-smarc.dts | 46 +++++++++++++++++++
.../boot/dts/renesas/renesas-smarc2.dtsi | 18 ++++++++
2 files changed, 64 insertions(+)
diff --git a/arch/arm64/boot/dts/renesas/r9a09g047e57-smarc.dts b/arch/arm64/boot/dts/renesas/r9a09g047e57-smarc.dts
index 152a00aa354b..5d7983812c70 100644
--- a/arch/arm64/boot/dts/renesas/r9a09g047e57-smarc.dts
+++ b/arch/arm64/boot/dts/renesas/r9a09g047e57-smarc.dts
@@ -9,7 +9,9 @@
/* Switch selection settings */
#define SW_SD0_DEV_SEL 0
+#define SW_SDIO_M2E 0
+#include <dt-bindings/gpio/gpio.h>
#include <dt-bindings/pinctrl/renesas,r9a09g047-pinctrl.h>
#include "r9a09g047e57.dtsi"
#include "rzg3e-smarc-som.dtsi"
@@ -19,6 +21,16 @@ / {
model = "Renesas SMARC EVK version 2 based on r9a09g047e57";
compatible = "renesas,smarc2-evk", "renesas,rzg3e-smarcm",
"renesas,r9a09g047e57", "renesas,r9a09g047";
+
+ vqmmc_sd1_pvdd: regulator-vqmmc-sd1-pvdd {
+ compatible = "regulator-gpio";
+ regulator-name = "SD1_PVDD";
+ regulator-min-microvolt = <1800000>;
+ regulator-max-microvolt = <3300000>;
+ gpios = <&pinctrl RZG3E_GPIO(1, 5) GPIO_ACTIVE_HIGH>;
+ gpios-states = <0>;
+ states = <3300000 0>, <1800000 1>;
+ };
};
&pinctrl {
@@ -26,9 +38,43 @@ scif_pins: scif {
pins = "SCIF_TXD", "SCIF_RXD";
renesas,output-impedance = <1>;
};
+
+ sd1-pwr-en-hog {
+ gpio-hog;
+ gpios = <RZG3E_GPIO(1, 6) GPIO_ACTIVE_HIGH>;
+ output-high;
+ line-name = "sd1_pwr_en";
+ };
+
+ sdhi1_pins: sd1 {
+ sd1-cd {
+ pinmux = <RZG3E_PORT_PINMUX(1, 4, 8)>; /* SD1CD */
+ };
+
+ sd1-ctrl {
+ pinmux = <RZG3E_PORT_PINMUX(G, 0, 1)>, /* SD1CLK */
+ <RZG3E_PORT_PINMUX(G, 1, 1)>; /* SD1CMD */
+ };
+
+ sd1-data {
+ pinmux = <RZG3E_PORT_PINMUX(G, 2, 1)>, /* SD1DAT0 */
+ <RZG3E_PORT_PINMUX(G, 3, 1)>, /* SD1DAT1 */
+ <RZG3E_PORT_PINMUX(G, 4, 1)>, /* SD1DAT2 */
+ <RZG3E_PORT_PINMUX(G, 5, 1)>; /* SD1DAT3 */
+ };
+ };
};
&scif0 {
pinctrl-0 = <&scif_pins>;
pinctrl-names = "default";
};
+
+&sdhi1 {
+ pinctrl-0 = <&sdhi1_pins>;
+ pinctrl-1 = <&sdhi1_pins>;
+ pinctrl-names = "default", "state_uhs";
+
+ vmmc-supply = <®_3p3v>;
+ vqmmc-supply = <&vqmmc_sd1_pvdd>;
+};
diff --git a/arch/arm64/boot/dts/renesas/renesas-smarc2.dtsi b/arch/arm64/boot/dts/renesas/renesas-smarc2.dtsi
index e378d55e6e9b..fd82df8adc1e 100644
--- a/arch/arm64/boot/dts/renesas/renesas-smarc2.dtsi
+++ b/arch/arm64/boot/dts/renesas/renesas-smarc2.dtsi
@@ -5,6 +5,15 @@
* Copyright (C) 2024 Renesas Electronics Corp.
*/
+/*
+ * Please set the switch position SW_OPT_MUX.1 on the carrier board and the
+ * corresponding macro SW_SDIO_M2E on the board DTS:
+ *
+ * SW_SDIO_M2E:
+ * 0 - SMARC SDIO signal is connected to uSD1
+ * 1 - SMARC SDIO signal is connected to M.2 Key E connector
+ */
+
/ {
model = "Renesas RZ SMARC Carrier-II Board";
compatible = "renesas,smarc2-evk";
@@ -16,9 +25,18 @@ chosen {
aliases {
serial3 = &scif0;
+ mmc1 = &sdhi1;
};
};
&scif0 {
status = "okay";
};
+
+&sdhi1 {
+ bus-width = <4>;
+ sd-uhs-sdr50;
+ sd-uhs-sdr104;
+
+ status = "okay";
+};
--
2.43.0
^ permalink raw reply related [flat|nested] 21+ messages in thread
* RE: [PATCH 6.1.y-cip 00/17] Add support for RZ/G3E SDHI
2025-06-23 14:46 [PATCH 6.1.y-cip 00/17] Add support for RZ/G3E SDHI Tommaso Merciai
` (16 preceding siblings ...)
2025-06-23 14:46 ` [PATCH 6.1.y-cip 17/17] arm64: dts: renesas: r9a09g047e57-smarc: Enable SDHI1 Tommaso Merciai
@ 2025-06-24 7:24 ` nobuhiro1.iwamatsu
2025-06-24 15:34 ` Pavel Machek
17 siblings, 1 reply; 21+ messages in thread
From: nobuhiro1.iwamatsu @ 2025-06-24 7:24 UTC (permalink / raw)
To: tommaso.merciai.xr, cip-dev, pavel
Cc: biju.das.jz, prabhakar.mahadev-lad.rj, tomm.merciai
Hi,
> -----Original Message-----
> From: Tommaso Merciai <tommaso.merciai.xr@bp.renesas.com>
> Sent: Monday, June 23, 2025 11:46 PM
> To: cip-dev@lists.cip-project.org; iwamatsu nobuhiro(岩松 信洋 □DITC○
> CPT) <nobuhiro1.iwamatsu@toshiba.co.jp>; Pavel Machek
> <pavel@denx.de>
> Cc: Biju Das <biju.das.jz@bp.renesas.com>; Lad Prabhakar
> <prabhakar.mahadev-lad.rj@bp.renesas.com>; tomm.merciai@gmail.com
> Subject: [PATCH 6.1.y-cip 00/17] Add support for RZ/G3E SDHI
>
> Hi All,
>
> This patch series aims to add SDHI support for the Renesas RZ/G3E SoCs into
> the linux-6.1.y-cip kernel.
>
> The SD/MMC block on the RZ/G3E ("R9A09G047") SoC is similar to that of the
> RZ/V2H, but the SD0 channel has only dedicated pins, so we must use
> SD_STATUS register to control voltage and power enable (internal regulator).
>
> For SD1 and SD2 channel we can either use gpio regulator or internal regulator
> (using SD_STATUS register) for voltage switching.
>
> This patchset applies on top of [1]
>
> [1] https://patchwork.kernel.org/project/cip-dev/list/?series=974771
>
> Thanks & Regards,
> Tommaso
> Biju Das (10):
> clk: renesas: r9a09g047: Add SDHI clocks/resets
> dt-bindings: mmc: renesas,sdhi: Document RZ/G3E support
> of: base: Add of_get_available_child_by_name()
> mmc: renesas_sdhi: Add support for RZ/G3E SoC
> mmc: renesas_sdhi: Use of_get_available_child_by_name()
> arm64: dts: renesas: r9a09g047: Add SDHI0-SDHI2 nodes
> arm64: dts: renesas: r9a09g057: Add support for enabling SDHI internal
> regulator
> arm64: dts: renesas: rzg3e-smarc-som: Enable SDHI{0,2}
> arm64: dts: renesas: rzg3e-smarc-som: Add support to enable SD on
> SDHI0
> arm64: dts: renesas: r9a09g047e57-smarc: Enable SDHI1
>
> Krzysztof Kozlowski (1):
> mmc: renesas_sdhi: use typedef for dma_filter_fn
>
> Wolfram Sang (6):
> mmc: tmio: add callback for dma irq
> mmc: renesas_sdhi: improve naming of DMA struct
> mmc: renesas_sdhi: remove accessor function for internal_dmac
> mmc: renesas_sdhi: take DMA end interrupts into account
> mmc: renesas_sdhi: add helper to access quirks
> mmc: renesas_sdhi: use plain numbers for end_flags
>
> .../devicetree/bindings/mmc/renesas,sdhi.yaml | 16 ++
> arch/arm64/boot/dts/renesas/r9a09g047.dtsi | 60 +++++++
> .../boot/dts/renesas/r9a09g047e57-smarc.dts | 49 ++++++
> arch/arm64/boot/dts/renesas/r9a09g057.dtsi | 21 +++
> .../boot/dts/renesas/renesas-smarc2.dtsi | 18 ++
> .../boot/dts/renesas/rzg3e-smarc-som.dtsi | 154
> ++++++++++++++++++
> drivers/clk/renesas/r9a09g047-cpg.c | 31 ++++
> drivers/mmc/host/Kconfig | 2 +-
> drivers/mmc/host/renesas_sdhi.h | 20 ++-
> drivers/mmc/host/renesas_sdhi_core.c | 148
> +++++++++++++++--
> drivers/mmc/host/renesas_sdhi_internal_dmac.c | 82 ++++++----
> drivers/mmc/host/tmio_mmc.h | 11 ++
> drivers/mmc/host/tmio_mmc_core.c | 3 +
> drivers/of/base.c | 27 +++
> include/linux/of.h | 9 +
> 15 files changed, 605 insertions(+), 46 deletions(-)
>
I reviewed this series, looks good to me. I can apply, if there are no other comments.
Test: https://gitlab.com/cip-project/cip-kernel/linux-cip/-/pipelines/1885943849
Reviewed-by: Nobuhiro Iwamatsu <nobuhiro1.iwamatsu@toshiba.co.jp>
Best regards,
Nobuhiro
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH 6.1.y-cip 07/17] mmc: renesas_sdhi: take DMA end interrupts into account
2025-06-23 14:46 ` [PATCH 6.1.y-cip 07/17] mmc: renesas_sdhi: take DMA end interrupts into account Tommaso Merciai
@ 2025-06-24 8:44 ` Pavel Machek
0 siblings, 0 replies; 21+ messages in thread
From: Pavel Machek @ 2025-06-24 8:44 UTC (permalink / raw)
To: Tommaso Merciai
Cc: cip-dev, Nobuhiro Iwamatsu, Biju Das, Lad Prabhakar, tomm.merciai
[-- Attachment #1: Type: text/plain, Size: 980 bytes --]
Hi!
> commit c330601c9c93392000c077d973b182cc0164b9ac upstream.
>
> So far, we have been relying on access_end interrupts only to mark DMA
> transfers as done implying that DMA end interrupts have occurred by then
> anyhow. On some SoCs under some conditions, this turned out to be not
> enough. So, we enable DMA interrupts as well and make sure that both
> events, DMA irq and access_end irq, have happened before finishing the
> DMA transfer.
> + u32 dma_irqs = INFO1_DTRANEND0 |
> + (priv->quirks && priv->quirks->old_info1_layout ?
> + INFO1_DTRANEND1_OLD : INFO1_DTRANEND1);
>
This expression is ... fun enough to deserve macro or inline
function. It got better in follow up patches, but may be still worth
macro/inline.
Anyway, this is nothing to block the merge.
Best regards,
Pavel
--
DENX Software Engineering GmbH, Managing Director: Erika Unter
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 195 bytes --]
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH 6.1.y-cip 00/17] Add support for RZ/G3E SDHI
2025-06-24 7:24 ` [PATCH 6.1.y-cip 00/17] Add support for RZ/G3E SDHI nobuhiro1.iwamatsu
@ 2025-06-24 15:34 ` Pavel Machek
0 siblings, 0 replies; 21+ messages in thread
From: Pavel Machek @ 2025-06-24 15:34 UTC (permalink / raw)
To: nobuhiro1.iwamatsu
Cc: tommaso.merciai.xr, cip-dev, biju.das.jz,
prabhakar.mahadev-lad.rj, tomm.merciai
[-- Attachment #1: Type: text/plain, Size: 3354 bytes --]
Hi!
> > This patch series aims to add SDHI support for the Renesas RZ/G3E SoCs into
> > the linux-6.1.y-cip kernel.
> >
> > The SD/MMC block on the RZ/G3E ("R9A09G047") SoC is similar to that of the
> > RZ/V2H, but the SD0 channel has only dedicated pins, so we must use
> > SD_STATUS register to control voltage and power enable (internal regulator).
> >
> > For SD1 and SD2 channel we can either use gpio regulator or internal regulator
> > (using SD_STATUS register) for voltage switching.
> >
> > This patchset applies on top of [1]
> >
> > [1] https://patchwork.kernel.org/project/cip-dev/list/?series=974771
> >
> > Thanks & Regards,
> > Tommaso
> > Biju Das (10):
> > clk: renesas: r9a09g047: Add SDHI clocks/resets
> > dt-bindings: mmc: renesas,sdhi: Document RZ/G3E support
> > of: base: Add of_get_available_child_by_name()
> > mmc: renesas_sdhi: Add support for RZ/G3E SoC
> > mmc: renesas_sdhi: Use of_get_available_child_by_name()
> > arm64: dts: renesas: r9a09g047: Add SDHI0-SDHI2 nodes
> > arm64: dts: renesas: r9a09g057: Add support for enabling SDHI internal
> > regulator
> > arm64: dts: renesas: rzg3e-smarc-som: Enable SDHI{0,2}
> > arm64: dts: renesas: rzg3e-smarc-som: Add support to enable SD on
> > SDHI0
> > arm64: dts: renesas: r9a09g047e57-smarc: Enable SDHI1
> >
> > Krzysztof Kozlowski (1):
> > mmc: renesas_sdhi: use typedef for dma_filter_fn
> >
> > Wolfram Sang (6):
> > mmc: tmio: add callback for dma irq
> > mmc: renesas_sdhi: improve naming of DMA struct
> > mmc: renesas_sdhi: remove accessor function for internal_dmac
> > mmc: renesas_sdhi: take DMA end interrupts into account
> > mmc: renesas_sdhi: add helper to access quirks
> > mmc: renesas_sdhi: use plain numbers for end_flags
> >
> > .../devicetree/bindings/mmc/renesas,sdhi.yaml | 16 ++
> > arch/arm64/boot/dts/renesas/r9a09g047.dtsi | 60 +++++++
> > .../boot/dts/renesas/r9a09g047e57-smarc.dts | 49 ++++++
> > arch/arm64/boot/dts/renesas/r9a09g057.dtsi | 21 +++
> > .../boot/dts/renesas/renesas-smarc2.dtsi | 18 ++
> > .../boot/dts/renesas/rzg3e-smarc-som.dtsi | 154
> > ++++++++++++++++++
> > drivers/clk/renesas/r9a09g047-cpg.c | 31 ++++
> > drivers/mmc/host/Kconfig | 2 +-
> > drivers/mmc/host/renesas_sdhi.h | 20 ++-
> > drivers/mmc/host/renesas_sdhi_core.c | 148
> > +++++++++++++++--
> > drivers/mmc/host/renesas_sdhi_internal_dmac.c | 82 ++++++----
> > drivers/mmc/host/tmio_mmc.h | 11 ++
> > drivers/mmc/host/tmio_mmc_core.c | 3 +
> > drivers/of/base.c | 27 +++
> > include/linux/of.h | 9 +
> > 15 files changed, 605 insertions(+), 46 deletions(-)
> >
> I reviewed this series, looks good to me. I can apply, if there are no other comments.
> Test: https://gitlab.com/cip-project/cip-kernel/linux-cip/-/pipelines/1885943849
>
> Reviewed-by: Nobuhiro Iwamatsu <nobuhiro1.iwamatsu@toshiba.co.jp>
Thank you, I added the reviewed-by tag and pushed the series.
Best regards,
Pavel
--
DENX Software Engineering GmbH, Managing Director: Erika Unter
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 195 bytes --]
^ permalink raw reply [flat|nested] 21+ messages in thread
end of thread, other threads:[~2025-06-24 15:34 UTC | newest]
Thread overview: 21+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-06-23 14:46 [PATCH 6.1.y-cip 00/17] Add support for RZ/G3E SDHI Tommaso Merciai
2025-06-23 14:46 ` [PATCH 6.1.y-cip 01/17] clk: renesas: r9a09g047: Add SDHI clocks/resets Tommaso Merciai
2025-06-23 14:46 ` [PATCH 6.1.y-cip 02/17] dt-bindings: mmc: renesas,sdhi: Document RZ/G3E support Tommaso Merciai
2025-06-23 14:46 ` [PATCH 6.1.y-cip 03/17] of: base: Add of_get_available_child_by_name() Tommaso Merciai
2025-06-23 14:46 ` [PATCH 6.1.y-cip 04/17] mmc: tmio: add callback for dma irq Tommaso Merciai
2025-06-23 14:46 ` [PATCH 6.1.y-cip 05/17] mmc: renesas_sdhi: improve naming of DMA struct Tommaso Merciai
2025-06-23 14:46 ` [PATCH 6.1.y-cip 06/17] mmc: renesas_sdhi: remove accessor function for internal_dmac Tommaso Merciai
2025-06-23 14:46 ` [PATCH 6.1.y-cip 07/17] mmc: renesas_sdhi: take DMA end interrupts into account Tommaso Merciai
2025-06-24 8:44 ` Pavel Machek
2025-06-23 14:46 ` [PATCH 6.1.y-cip 08/17] mmc: renesas_sdhi: add helper to access quirks Tommaso Merciai
2025-06-23 14:46 ` [PATCH 6.1.y-cip 09/17] mmc: renesas_sdhi: use plain numbers for end_flags Tommaso Merciai
2025-06-23 14:46 ` [PATCH 6.1.y-cip 10/17] mmc: renesas_sdhi: use typedef for dma_filter_fn Tommaso Merciai
2025-06-23 14:46 ` [PATCH 6.1.y-cip 11/17] mmc: renesas_sdhi: Add support for RZ/G3E SoC Tommaso Merciai
2025-06-23 14:46 ` [PATCH 6.1.y-cip 12/17] mmc: renesas_sdhi: Use of_get_available_child_by_name() Tommaso Merciai
2025-06-23 14:46 ` [PATCH 6.1.y-cip 13/17] arm64: dts: renesas: r9a09g047: Add SDHI0-SDHI2 nodes Tommaso Merciai
2025-06-23 14:46 ` [PATCH 6.1.y-cip 14/17] arm64: dts: renesas: r9a09g057: Add support for enabling SDHI internal regulator Tommaso Merciai
2025-06-23 14:46 ` [PATCH 6.1.y-cip 15/17] arm64: dts: renesas: rzg3e-smarc-som: Enable SDHI{0,2} Tommaso Merciai
2025-06-23 14:46 ` [PATCH 6.1.y-cip 16/17] arm64: dts: renesas: rzg3e-smarc-som: Add support to enable SD on SDHI0 Tommaso Merciai
2025-06-23 14:46 ` [PATCH 6.1.y-cip 17/17] arm64: dts: renesas: r9a09g047e57-smarc: Enable SDHI1 Tommaso Merciai
2025-06-24 7:24 ` [PATCH 6.1.y-cip 00/17] Add support for RZ/G3E SDHI nobuhiro1.iwamatsu
2025-06-24 15:34 ` Pavel Machek
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox