Skip to contentSkip to conversation

omapl138_lcdk: fix MMC boot

PATCH New Bartosz Golaszewski 3 participants 15 messages Nov 14, 2019 – Jan 3, 2020

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

cover omapl138_lcdk: fix MMC boot

From: Bartosz Golaszewski <[email protected]>

Booting from MMC on omapl138-lcdk is currently broken after we enabled driver-model in SPL. While I know what's wrong - the bind() callback not being called - I can't for the life of me figure out how to fix it.

I'm still working on proper changes, but for now, I'd like to propose this series which fixes MMC boot with a workaround in which we call mmc_boot() manually from probe.

First two patches drop some legacy code that's no longer needed. The third patch adds a U_BOOT_DEVICE() for mmc as we don't yet have full DT support (also in-progress). The last patch adds the workaround to the davinci mmc driver.

This series depends on Adam Ford's patch increasing the pre-reloc malloc pool.

[1] https://patchwork.ozlabs.org/patch/1192574/

Bartosz Golaszewski (4):
mmc: davinci: drop support for ti,dm6441-mmc
mmc: davinci: drop struct davinci_mmc_plat
board: omapl138_lcdk: add the mmc device to SPL
mmc: davinci: fix mmc boot in SPL

 arch/arm/mach-davinci/Kconfig                 |  1 +
 .../mach-davinci/include/mach/sdmmc_defs.h    |  6 --
 board/davinci/da8xxevm/omapl138_lcdk.c        | 10 ++-
 drivers/mmc/davinci_mmc.c                     | 73 +++++++------------
 4 files changed, 36 insertions(+), 54 deletions(-)
Signature · 1 line
2.23.0
#1 lore raw

PATCH 1/4 mmc: davinci: drop support for ti,dm6441-mmc

From: Bartosz Golaszewski <[email protected]>

The DM family of DaVinci SoCs is no longer supported. Drop the irrelevant code from the driver.

---
 .../mach-davinci/include/mach/sdmmc_defs.h    |  6 ---
 board/davinci/da8xxevm/omapl138_lcdk.c        |  1 -
 drivers/mmc/davinci_mmc.c                     | 42 +++----------------
 3 files changed, 5 insertions(+), 44 deletions(-)
arch/arm/mach-davinci/include/mach/sdmmc_defs.h +0 -6
index 5755c45f91..46f6391aa2 100644
@@ -149,15 +149,9 @@ struct davinci_mmc {
 	uint input_clk;		/* Input clock to MMC controller */
 	uint host_caps;		/* Host capabilities */
 	uint voltages;		/* Host supported voltages */
-	uint version;		/* MMC Controller version */
 	struct mmc_config cfg;
 };
 
-enum {
-	MMC_CTLR_VERSION_1 = 0,	/* DM644x and DM355 */
-	MMC_CTLR_VERSION_2,	/* DA830 */
-};
-
 int davinci_mmc_init(bd_t *bis, struct davinci_mmc *host);
 
 #endif /* _SDMMC_DEFS_H */
board/davinci/da8xxevm/omapl138_lcdk.c +0 -1
index 27a51d6a78..d4cda0a8a7 100644
@@ -342,7 +342,6 @@ static struct davinci_mmc mmc_sd0 = {
 	.reg_base = (struct davinci_mmc_regs *)DAVINCI_MMC_SD0_BASE,
 	.host_caps = MMC_MODE_4BIT,     /* DA850 supports only 4-bit SD/MMC */
 	.voltages = MMC_VDD_32_33 | MMC_VDD_33_34,
-	.version = MMC_CTLR_VERSION_2,
 };
 
 int board_mmc_init(bd_t *bis)
drivers/mmc/davinci_mmc.c +5 -37

82 lines not on this page · raw message

Signature · 1 line
2.23.0
#3 lore raw

PATCH 2/4 mmc: davinci: drop struct davinci_mmc_plat

In reply to Bartosz Golaszewski

From: Bartosz Golaszewski <[email protected]>

struct mmc_config & struct mmc don't need to be exported over platform data, but can instead be private in the driver.

Remove struct davinci_mmc_plat.

---
 drivers/mmc/davinci_mmc.c | 14 ++++----------
 1 file changed, 4 insertions(+), 10 deletions(-)
drivers/mmc/davinci_mmc.c +4 -10
index 370b18cc78..a27a039f9b 100644
@@ -32,10 +32,6 @@ struct davinci_mmc_priv {
 	uint input_clk;		/* Input clock to MMC controller */
 	struct gpio_desc cd_gpio;       /* Card Detect GPIO */
 	struct gpio_desc wp_gpio;       /* Write Protect GPIO */
-};
-
-struct davinci_mmc_plat
-{
 	struct mmc_config cfg;
 	struct mmc mmc;
 };
@@ -484,9 +480,8 @@ int davinci_mmc_init(bd_t *bis, struct davinci_mmc *host)
 static int davinci_mmc_probe(struct udevice *dev)
 {
 	struct mmc_uclass_priv *upriv = dev_get_uclass_priv(dev);
-	struct davinci_mmc_plat *plat = dev_get_platdata(dev);
 	struct davinci_mmc_priv *priv = dev_get_priv(dev);
-	struct mmc_config *cfg = &plat->cfg;
+	struct mmc_config *cfg = &priv->cfg;
 
 	cfg->f_min = 200000;
 	cfg->f_max = 25000000;
@@ -504,16 +499,16 @@ static int davinci_mmc_probe(struct udevice *dev)
 	gpio_request_by_name(dev, "wp-gpios", 0, &priv->wp_gpio, GPIOD_IS_IN);
 #endif
 
-	upriv->mmc = &plat->mmc;
+	upriv->mmc = &priv->mmc;
 
 	return davinci_dm_mmc_init(dev);
 }
 
 static int davinci_mmc_bind(struct udevice *dev)
 {
-	struct davinci_mmc_plat *plat = dev_get_platdata(dev);
+	struct davinci_mmc_priv *priv = dev_get_priv(dev);
 
-	return mmc_bind(dev, &plat->mmc, &plat->cfg);
+	return mmc_bind(dev, &priv->mmc, &priv->cfg);
 }
 
 static const struct udevice_id davinci_mmc_ids[] = {
@@ -530,7 +525,6 @@ U_BOOT_DRIVER(davinci_mmc_drv) = {
 #endif
 	.probe = davinci_mmc_probe,
 	.ops = &davinci_mmc_ops,
-	.platdata_auto_alloc_size = sizeof(struct davinci_mmc_plat),
 	.priv_auto_alloc_size = sizeof(struct davinci_mmc_priv),
 };
 #endif
Signature · 1 line
2.23.0
#9 lore raw

PATCH 3/4 board: omapl138_lcdk: add the mmc device to SPL

In reply to Bartosz Golaszewski

From: Bartosz Golaszewski <[email protected]>

We don't have full device-tree support in SPL yet - add an appropriate U_BOOT_DEVICE() to the board file.

---
 arch/arm/mach-davinci/Kconfig          | 1 +
 board/davinci/da8xxevm/omapl138_lcdk.c | 9 +++++++++
 2 files changed, 10 insertions(+)
arch/arm/mach-davinci/Kconfig +1 -0
index adc50922c8..8a81c07881 100644
@@ -14,6 +14,7 @@ config TARGET_OMAPL138_LCDK
 	bool "OMAPL138 LCDK"
 	select SOC_DA8XX
 	select SUPPORT_SPL
+	select SPL_BOARD_INIT
 
 config TARGET_LEGOEV3
 	bool "LEGO MINDSTORMS EV3"
board/davinci/da8xxevm/omapl138_lcdk.c +9 -0
index d4cda0a8a7..608a7f28eb 100644
@@ -366,4 +366,13 @@ U_BOOT_DEVICE(omapl138_uart) = {
 	.name = "ns16550_serial",
 	.platdata = &serial_pdata,
 };
+
+U_BOOT_DEVICE(omapl138_mmc) = {
+	.name = "davinci_mmc",
+};
+
+void spl_board_init(void)
+{
+	davinci_configure_pin_mux(mmc0_pins, ARRAY_SIZE(mmc0_pins));
+}
 #endif
Signature · 1 line
2.23.0
#11 lore raw

PATCH 4/4 mmc: davinci: fix mmc boot in SPL

In reply to Bartosz Golaszewski

From: Bartosz Golaszewski <[email protected]>

The MMC boot is currently broken on omapl138-lcdk after enabling the driver model in SPL. The main problem is the driver's bind callback not being called after probe in SPL (even with the DM_FLAG_PRE_RELOC flag specified).

While a proper fix is still being worked on, this hacky changeset at least fixes the MMC boot on this platform by calling mmc_bind() manually from probe().

---
 drivers/mmc/davinci_mmc.c | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)
drivers/mmc/davinci_mmc.c +17 -0
index a27a039f9b..c3f7b57665 100644
@@ -482,6 +482,9 @@ static int davinci_mmc_probe(struct udevice *dev)
 	struct mmc_uclass_priv *upriv = dev_get_uclass_priv(dev);
 	struct davinci_mmc_priv *priv = dev_get_priv(dev);
 	struct mmc_config *cfg = &priv->cfg;
+#ifdef CONFIG_SPL_BUILD
+	int ret;
+#endif
 
 	cfg->f_min = 200000;
 	cfg->f_max = 25000000;
@@ -501,6 +504,20 @@ static int davinci_mmc_probe(struct udevice *dev)
 
 	upriv->mmc = &priv->mmc;
 
+#ifdef CONFIG_SPL_BUILD
+	/*
+	 * FIXME This is a temporary workaround to enable the driver model in
+	 * SPL on omapl138-lcdk. For some reason the bind() callback is not
+	 * being called in SPL for MMC which breaks the mmc boot - the hack
+	 * is to call mmc_bind() from probe(). We also don't have full DT
+	 * support in SPL, hence the hard-coded base register address.
+	 */
+	priv->reg_base = (struct davinci_mmc_regs *)DAVINCI_MMC_SD0_BASE;
+	ret = mmc_bind(dev, &priv->mmc, &priv->cfg);
+	if (ret)
+		return ret;
+#endif
+
 	return davinci_dm_mmc_init(dev);
 }
 
Signature · 1 line
2.23.0
#13 lore raw

cover omapl138_lcdk: fix MMC boot

In reply to Bartosz Golaszewski

czw., 14 lis 2019 o 16:10 Bartosz Golaszewski <[email protected]> napisaÅ‚(a):

Quoted 27 lines

From: Bartosz Golaszewski <[email protected]>

Booting from MMC on omapl138-lcdk is currently broken after we enabled driver-model in SPL. While I know what's wrong - the bind() callback not being called - I can't for the life of me figure out how to fix it.

I'm still working on proper changes, but for now, I'd like to propose this series which fixes MMC boot with a workaround in which we call mmc_boot() manually from probe.

First two patches drop some legacy code that's no longer needed. The third patch adds a U_BOOT_DEVICE() for mmc as we don't yet have full DT support (also in-progress). The last patch adds the workaround to the davinci mmc driver.

This series depends on Adam Ford's patch increasing the pre-reloc malloc pool.

[1] https://patchwork.ozlabs.org/patch/1192574/

Bartosz Golaszewski (4):
mmc: davinci: drop support for ti,dm6441-mmc
mmc: davinci: drop struct davinci_mmc_plat
board: omapl138_lcdk: add the mmc device to SPL
mmc: davinci: fix mmc boot in SPL

Quoted 9 lines
 arch/arm/mach-davinci/Kconfig                 |  1 +
 .../mach-davinci/include/mach/sdmmc_defs.h    |  6 --
 board/davinci/da8xxevm/omapl138_lcdk.c        | 10 ++-
 drivers/mmc/davinci_mmc.c                     | 73 +++++++------------
 4 files changed, 36 insertions(+), 54 deletions(-)

--
2.23.0

Gentle ping.

Bart

#14 lore raw

cover omapl138_lcdk: fix MMC boot

Quoted 35 lines · Bartosz Golaszewski

czw., 14 lis 2019 o 16:10 Bartosz Golaszewski <[email protected]> napisaÅ‚(a):

Quoted 33 lines

From: Bartosz Golaszewski <[email protected]>

Booting from MMC on omapl138-lcdk is currently broken after we enabled driver-model in SPL. While I know what's wrong - the bind() callback not being called - I can't for the life of me figure out how to fix it.

I'm still working on proper changes, but for now, I'd like to propose this series which fixes MMC boot with a workaround in which we call mmc_boot() manually from probe.

First two patches drop some legacy code that's no longer needed. The third patch adds a U_BOOT_DEVICE() for mmc as we don't yet have full DT support (also in-progress). The last patch adds the workaround to the davinci mmc driver.

This series depends on Adam Ford's patch increasing the pre-reloc malloc pool.

[1] https://patchwork.ozlabs.org/patch/1192574/

Bartosz Golaszewski (4):
mmc: davinci: drop support for ti,dm6441-mmc
mmc: davinci: drop struct davinci_mmc_plat
board: omapl138_lcdk: add the mmc device to SPL
mmc: davinci: fix mmc boot in SPL

 arch/arm/mach-davinci/Kconfig                 |  1 +
 .../mach-davinci/include/mach/sdmmc_defs.h    |  6 --
 board/davinci/da8xxevm/omapl138_lcdk.c        | 10 ++-
 drivers/mmc/davinci_mmc.c                     | 73 +++++++------------
 4 files changed, 36 insertions(+), 54 deletions(-)
Quoted 5 lines
Quoted 3 lines

--
2.23.0

Gentle ping.

I wonder if having a 'fixes:' tag would help move things along.

adam

Quoted 2 lines

Bart

#2 lore raw

PATCH 1/4 mmc: davinci: drop support for ti, dm6441-mmc

In reply to Bartosz Golaszewski
Quoted 6 lines · Bartosz Golaszewski

From: Bartosz Golaszewski <[email protected]>

The DM family of DaVinci SoCs is no longer supported. Drop the irrelevant code from the driver.

Applied to u-boot/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <https://lists.denx.de/pipermail/u-boot/attachments/20191203/72714ed1/attachment.sig>
#4 lore raw

PATCH 2/4 mmc: davinci: drop struct davinci_mmc_plat

In reply to Bartosz Golaszewski
Quoted 8 lines · Bartosz Golaszewski

From: Bartosz Golaszewski <[email protected]>

struct mmc_config & struct mmc don't need to be exported over platform data, but can instead be private in the driver.

Remove struct davinci_mmc_plat.

Applied to u-boot/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <https://lists.denx.de/pipermail/u-boot/attachments/20191203/50210d26/attachment.sig>
#10 lore raw

PATCH 3/4 board: omapl138_lcdk: add the mmc device to SPL

In reply to Bartosz Golaszewski
Quoted 6 lines · Bartosz Golaszewski

From: Bartosz Golaszewski <[email protected]>

We don't have full device-tree support in SPL yet - add an appropriate U_BOOT_DEVICE() to the board file.

Applied to u-boot/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <https://lists.denx.de/pipermail/u-boot/attachments/20191203/e413335a/attachment.sig>
#12 lore raw

PATCH 4/4 mmc: davinci: fix mmc boot in SPL

In reply to Bartosz Golaszewski
Quoted 7 lines · Bartosz Golaszewski

From: Bartosz Golaszewski <[email protected]>

The MMC boot is currently broken on omapl138-lcdk after enabling the driver model in SPL. The main problem is the driver's bind callback not being called after probe in SPL (even with the DM_FLAG_PRE_RELOC flag specified).

Quoted 5 lines

While a proper fix is still being worked on, this hacky changeset at least fixes the MMC boot on this platform by calling mmc_bind() manually from probe().

Applied to u-boot/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <https://lists.denx.de/pipermail/u-boot/attachments/20191203/fe846305/attachment.sig>
#5 lore raw

PATCH 2/4 mmc: davinci: drop struct davinci_mmc_plat

In reply to Bartosz Golaszewski
Quoted 7 lines · Bartosz Golaszewski

From: Bartosz Golaszewski <[email protected]>

struct mmc_config & struct mmc don't need to be exported over platform data, but can instead be private in the driver.

Remove struct davinci_mmc_plat.

This patch appears to break the da850-evm.

With the pending release of 2020.01, is there any way we can revert before release and try to apply this going forward with more time to test?

As of now, the da850-evm cannot read/write from the MMC card from U-Boot which includes MMC booting.

adam

Quoted 63 lines
---
 drivers/mmc/davinci_mmc.c | 14 ++++----------
 1 file changed, 4 insertions(+), 10 deletions(-)
drivers/mmc/davinci_mmc.c +4 -11
index 370b18cc78..a27a039f9b 100644
@@ -32,10 +32,6 @@ struct davinci_mmc_priv {
        uint input_clk;         /* Input clock to MMC controller */
        struct gpio_desc cd_gpio;       /* Card Detect GPIO */
        struct gpio_desc wp_gpio;       /* Write Protect GPIO */
-};
-
-struct davinci_mmc_plat
-{
        struct mmc_config cfg;
        struct mmc mmc;
 };
@@ -484,9 +480,8 @@ int davinci_mmc_init(bd_t *bis, struct davinci_mmc *host)
 static int davinci_mmc_probe(struct udevice *dev)
 {
        struct mmc_uclass_priv *upriv = dev_get_uclass_priv(dev);
-       struct davinci_mmc_plat *plat = dev_get_platdata(dev);
        struct davinci_mmc_priv *priv = dev_get_priv(dev);
-       struct mmc_config *cfg = &plat->cfg;
+       struct mmc_config *cfg = &priv->cfg;
 
        cfg->f_min = 200000;
        cfg->f_max = 25000000;
@@ -504,16 +499,16 @@ static int davinci_mmc_probe(struct udevice *dev)
        gpio_request_by_name(dev, "wp-gpios", 0, &priv->wp_gpio, GPIOD_IS_IN);
 #endif
 
-       upriv->mmc = &plat->mmc;
+       upriv->mmc = &priv->mmc;
 
        return davinci_dm_mmc_init(dev);
 }
 
 static int davinci_mmc_bind(struct udevice *dev)
 {
-       struct davinci_mmc_plat *plat = dev_get_platdata(dev);
+       struct davinci_mmc_priv *priv = dev_get_priv(dev);
 
-       return mmc_bind(dev, &plat->mmc, &plat->cfg);
+       return mmc_bind(dev, &priv->mmc, &priv->cfg);
 }
 
 static const struct udevice_id davinci_mmc_ids[] = {
@@ -530,7 +525,6 @@ U_BOOT_DRIVER(davinci_mmc_drv) = {
 #endif
        .probe = davinci_mmc_probe,
        .ops = &davinci_mmc_ops,
-       .platdata_auto_alloc_size = sizeof(struct davinci_mmc_plat),
        .priv_auto_alloc_size = sizeof(struct davinci_mmc_priv),
 };
 #endif
--

2.23.0

#6 lore raw

PATCH 2/4 mmc: davinci: drop struct davinci_mmc_plat

pt., 3 sty 2020 o 17:01 Adam Ford <[email protected]> napisaÅ‚(a):

Quoted 10 lines · Bartosz Golaszewski
Quoted 7 lines

From: Bartosz Golaszewski <[email protected]>

struct mmc_config & struct mmc don't need to be exported over platform data, but can instead be private in the driver.

Remove struct davinci_mmc_plat.

Quoted 9 lines

This patch appears to break the da850-evm.

With the pending release of 2020.01, is there any way we can revert before release and try to apply this going forward with more time to test?

As of now, the da850-evm cannot read/write from the MMC card from U-Boot which includes MMC booting.

This is strange, this change doesn't seem to affect the logic.

This isn't revertible automatically anymore, due to other patches that came before and after. We can probably try to revert it manually.

Bart

#7 lore raw

PATCH 2/4 mmc: davinci: drop struct davinci_mmc_plat

Quoted 17 lines · Bartosz Golaszewski

pt., 3 sty 2020 o 17:01 Adam Ford <[email protected]> napisaÅ‚(a):

Quoted 16 lines · Bartosz Golaszewski
Quoted 7 lines

From: Bartosz Golaszewski <[email protected]>

struct mmc_config & struct mmc don't need to be exported over platform data, but can instead be private in the driver.

Remove struct davinci_mmc_plat.

This patch appears to break the da850-evm.

With the pending release of 2020.01, is there any way we can revert before release and try to apply this going forward with more time to test?

Quoted 8 lines
Quoted 3 lines

As of now, the da850-evm cannot read/write from the MMC card from U-Boot which includes MMC booting.

This is strange, this change doesn't seem to affect the logic.

This isn't revertible automatically anymore, due to other patches that came before and after. We can probably try to revert it manually.

Doing a git revert and fixing up the one hunk that didn't go cleanly is easy, should I push that?

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <https://lists.denx.de/pipermail/u-boot/attachments/20200103/216cd8b3/attachment.sig>
#8 lore raw

PATCH 2/4 mmc: davinci: drop struct davinci_mmc_plat

Quoted 23 lines · Tom Rini
Quoted 21 lines · Bartosz Golaszewski

pt., 3 sty 2020 o 17:01 Adam Ford <[email protected]> napisaÅ‚(a):

Quoted 19 lines · Bartosz Golaszewski
Quoted 7 lines

From: Bartosz Golaszewski <[email protected]>

struct mmc_config & struct mmc don't need to be exported over platform data, but can instead be private in the driver.

Remove struct davinci_mmc_plat.

This patch appears to break the da850-evm.

With the pending release of 2020.01, is there any way we can revert before release and try to apply this going forward with more time to test?

As of now, the da850-evm cannot read/write from the MMC card from U-Boot which includes MMC booting.

Quoted 7 lines
Quoted 4 lines

This is strange, this change doesn't seem to affect the logic.

This isn't revertible automatically anymore, due to other patches that came before and after. We can probably try to revert it manually.

Doing a git revert and fixing up the one hunk that didn't go cleanly is easy, should I push that?

That would make me happy. :-) I don't know about Bartosz.

If you have a patch, I can quickly test it today.

adam

Quoted 3 lines

--
Tom