All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v1 1/2] rockchip: mmc: rockchip_dw_mmc: fix ciu clock index
@ 2022-01-07 18:34 Johan Jonker
  2022-01-07 18:34 ` [PATCH v1 2/2] rockchip: mmc: rockchip_dw_mmc: add rk3066/rk3188 support Johan Jonker
  0 siblings, 1 reply; 4+ messages in thread
From: Johan Jonker @ 2022-01-07 18:34 UTC (permalink / raw)
  To: kever.yang; +Cc: sjg, philipp.tomsich, peng.fan, jh80.chung, u-boot

The document rockchip-dw-mshc.yaml decribes a maximum of 4 clocks.
In the rockchip_dw_mmc driver the clock name in use was "fixed"
to "ciu" with index 1, but later reverted back to index 0.
The clock drivers can handle both, but the calling driver
should submit correct data as a standard practice.
Fix the "ciu" clock index by setting it back to 1.

  clock-names:
    minItems: 2
    items:
      - const: biu
      - const: ciu
      - const: ciu-drive
      - const: ciu-sample

Signed-off-by: Johan Jonker <jbx6244@gmail.com>
---
 drivers/mmc/rockchip_dw_mmc.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/mmc/rockchip_dw_mmc.c b/drivers/mmc/rockchip_dw_mmc.c
index 7f8dea1e..be065ec0 100644
--- a/drivers/mmc/rockchip_dw_mmc.c
+++ b/drivers/mmc/rockchip_dw_mmc.c
@@ -123,11 +123,11 @@ static int rockchip_dwmmc_probe(struct udevice *dev)
 	priv->minmax[0] = 400000;  /*  400 kHz */
 	priv->minmax[1] = dtplat->max_frequency;
 
-	ret = clk_get_by_phandle(dev, dtplat->clocks, &priv->clk);
+	ret = clk_get_by_phandle(dev, &dtplat->clocks[1], &priv->clk);
 	if (ret < 0)
 		return ret;
 #else
-	ret = clk_get_by_index(dev, 0, &priv->clk);
+	ret = clk_get_by_index(dev, 1, &priv->clk);
 	if (ret < 0)
 		return ret;
 #endif
-- 
2.20.1


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

* [PATCH v1 2/2] rockchip: mmc: rockchip_dw_mmc: add rk3066/rk3188 support
  2022-01-07 18:34 [PATCH v1 1/2] rockchip: mmc: rockchip_dw_mmc: fix ciu clock index Johan Jonker
@ 2022-01-07 18:34 ` Johan Jonker
  2022-03-12  9:02   ` Jagan Teki
  0 siblings, 1 reply; 4+ messages in thread
From: Johan Jonker @ 2022-01-07 18:34 UTC (permalink / raw)
  To: kever.yang; +Cc: sjg, philipp.tomsich, peng.fan, jh80.chung, u-boot

The Rockchip SoCs rk3066/rk3188 have mmc DT nodes
with as compatible string "rockchip,rk2928-dw-mshc".
Add support to the existing driver with help of
a DM_DRIVER_ALIAS.

This type needs a permanent enabled fifo.
The other Rockchip SoCs not always have the property
"fifo-mode" in the TPL/SPL DT nodes, so dtplat structures
can't be used to switch it on.
Add a data structure linked to the compatible string
to enable.

Signed-off-by: Johan Jonker <jbx6244@gmail.com>
---
 drivers/mmc/rockchip_dw_mmc.c | 16 +++++++++++++---
 1 file changed, 13 insertions(+), 3 deletions(-)

diff --git a/drivers/mmc/rockchip_dw_mmc.c b/drivers/mmc/rockchip_dw_mmc.c
index be065ec0..5fdfcef2 100644
--- a/drivers/mmc/rockchip_dw_mmc.c
+++ b/drivers/mmc/rockchip_dw_mmc.c
@@ -19,6 +19,11 @@
 #include <linux/delay.h>
 #include <linux/err.h>
 
+enum rockchip_dwmmc_type {
+	RK2928_MSHC,
+	RK3288_MSHC,
+};
+
 struct rockchip_mmc_plat {
 #if CONFIG_IS_ENABLED(OF_PLATDATA)
 	struct dtd_rockchip_rk3288_dw_mshc dtplat;
@@ -111,6 +116,7 @@ static int rockchip_dwmmc_probe(struct udevice *dev)
 
 #if CONFIG_IS_ENABLED(OF_PLATDATA)
 	struct dtd_rockchip_rk3288_dw_mshc *dtplat = &plat->dtplat;
+	enum rockchip_dwmmc_type type = dev_get_driver_data(dev);
 
 	host->name = dev->name;
 	host->ioaddr = map_sysmem(dtplat->reg[0], dtplat->reg[1]);
@@ -119,7 +125,10 @@ static int rockchip_dwmmc_probe(struct udevice *dev)
 	host->priv = dev;
 	host->dev_index = 0;
 	priv->fifo_depth = dtplat->fifo_depth;
-	priv->fifo_mode = 0;
+	if (type == RK2928_MSHC)
+		priv->fifo_mode = 1;
+	else
+		priv->fifo_mode = 0;
 	priv->minmax[0] = 400000;  /*  400 kHz */
 	priv->minmax[1] = dtplat->max_frequency;
 
@@ -163,8 +172,8 @@ static int rockchip_dwmmc_bind(struct udevice *dev)
 }
 
 static const struct udevice_id rockchip_dwmmc_ids[] = {
-	{ .compatible = "rockchip,rk2928-dw-mshc" },
-	{ .compatible = "rockchip,rk3288-dw-mshc" },
+	{ .compatible = "rockchip,rk2928-dw-mshc", .data = RK2928_MSHC },
+	{ .compatible = "rockchip,rk3288-dw-mshc", .data = RK3288_MSHC },
 	{ }
 };
 
@@ -180,5 +189,6 @@ U_BOOT_DRIVER(rockchip_rk3288_dw_mshc) = {
 	.plat_auto	= sizeof(struct rockchip_mmc_plat),
 };
 
+DM_DRIVER_ALIAS(rockchip_rk3288_dw_mshc, rockchip_rk2928_dw_mshc)
 DM_DRIVER_ALIAS(rockchip_rk3288_dw_mshc, rockchip_rk3328_dw_mshc)
 DM_DRIVER_ALIAS(rockchip_rk3288_dw_mshc, rockchip_rk3368_dw_mshc)
-- 
2.20.1


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

* Re: [PATCH v1 2/2] rockchip: mmc: rockchip_dw_mmc: add rk3066/rk3188 support
  2022-01-07 18:34 ` [PATCH v1 2/2] rockchip: mmc: rockchip_dw_mmc: add rk3066/rk3188 support Johan Jonker
@ 2022-03-12  9:02   ` Jagan Teki
  2022-03-12  9:14     ` Johan Jonker
  0 siblings, 1 reply; 4+ messages in thread
From: Jagan Teki @ 2022-03-12  9:02 UTC (permalink / raw)
  To: Johan Jonker
  Cc: kever.yang, sjg, philipp.tomsich, peng.fan, jh80.chung, u-boot

On Sat, Jan 8, 2022 at 12:04 AM Johan Jonker <jbx6244@gmail.com> wrote:
>
> The Rockchip SoCs rk3066/rk3188 have mmc DT nodes
> with as compatible string "rockchip,rk2928-dw-mshc".
> Add support to the existing driver with help of
> a DM_DRIVER_ALIAS.
>
> This type needs a permanent enabled fifo.
> The other Rockchip SoCs not always have the property
> "fifo-mode" in the TPL/SPL DT nodes, so dtplat structures

No, it is not true. we have property for spl/tpl to enable that.
"u-boot,spl-fifo-mode"

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

* Re: [PATCH v1 2/2] rockchip: mmc: rockchip_dw_mmc: add rk3066/rk3188 support
  2022-03-12  9:02   ` Jagan Teki
@ 2022-03-12  9:14     ` Johan Jonker
  0 siblings, 0 replies; 4+ messages in thread
From: Johan Jonker @ 2022-03-12  9:14 UTC (permalink / raw)
  To: Jagan Teki; +Cc: kever.yang, sjg, philipp.tomsich, peng.fan, jh80.chung, u-boot

Hi Jagan,

On 3/12/22 10:02, Jagan Teki wrote:
> On Sat, Jan 8, 2022 at 12:04 AM Johan Jonker <jbx6244@gmail.com> wrote:
>>
>> The Rockchip SoCs rk3066/rk3188 have mmc DT nodes
>> with as compatible string "rockchip,rk2928-dw-mshc".
>> Add support to the existing driver with help of
>> a DM_DRIVER_ALIAS.
>>
>> This type needs a permanent enabled fifo.
>> The other Rockchip SoCs not always have the property
>> "fifo-mode" in the TPL/SPL DT nodes, so dtplat structures
> 

> No, it is not true. we have property for spl/tpl to enable that.
> "u-boot,spl-fifo-mode"

This is not usable for rk3066/rk3188 and OF_PLATDATA in combination with
c code as there's no guaranty that other models have this property in
the dtplat structure.

It's about finding a solution for disabling fifo-mode and OF_PLATDATA.

There's also a V2 with a more generic approach. Could you have a look at
it as well. Whatever which method is preferred.

#if CONFIG_IS_ENABLED(OF_PLATDATA)
	struct dtd_rockchip_rk3288_dw_mshc dtplat;
#endif

Johan

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

end of thread, other threads:[~2022-03-12  9:14 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-07 18:34 [PATCH v1 1/2] rockchip: mmc: rockchip_dw_mmc: fix ciu clock index Johan Jonker
2022-01-07 18:34 ` [PATCH v1 2/2] rockchip: mmc: rockchip_dw_mmc: add rk3066/rk3188 support Johan Jonker
2022-03-12  9:02   ` Jagan Teki
2022-03-12  9:14     ` Johan Jonker

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.