spl: dm_mmc: Initialize only the required mmc device
PATCH 1/1 spl: dm_mmc: Initialize only the required mmc device
In SPL, all the available mmc devices gets initialized during boot. This might not work in cases where clocks are not available for certain mmc devices(other than boot device) and the support for enabling device might not be ready.
Texas Instruments' K3 J721E device having a central system controller (dmsc) is one such example falling in this category. Below is the sequence for the failing scenario:
- ROM comes up in SD mode and loads SPL by just initialing SD card.
- SPL loads dmsc firmware from SD Card.
Since ROM has enabled SD, SPL need not enable the SD, just need to re initialize the card. But SPL is trying to initialize other MMC instances which are in disabled state. Since dmsc firmware is not yet available, devices cannot be enabled. So in SPL, initialize only the mmc device that is needed.
--- common/spl/spl_mmc.c | 14 ++++---------- drivers/mmc/mmc.c | 24 ++++++++++++++++++++++++ include/mmc.h | 1 + 3 files changed, 29 insertions(+), 10 deletions(-)
common/spl/spl_mmc.c +4 -10
@@ -113,31 +113,25 @@ static int spl_mmc_get_device_index(u32 boot_device)static int spl_mmc_find_device (struct mmc **mmcp,u32 boot_device) { -#if CONFIG_IS_ENABLED (DM_MMC ) -struct udevice *dev; -#endif int err, mmc_dev; mmc_dev =spl_mmc_get_device_index (boot_device);if (mmc_dev <0 )return mmc_dev; +#if CONFIG_IS_ENABLED (DM_MMC ) + err =mmc_init_device (mmc_dev); +#else err =mmc_initialize (NULL ); +#endif /* DM_MMC */ if (err) {#ifdef CONFIG_SPL_LIBCOMMON_SUPPORT printf ("spl: could not initialize mmc. error: %d\n" , err);#endif return err; } - -#if CONFIG_IS_ENABLED (DM_MMC ) - err =uclass_get_device (UCLASS_MMC , mmc_dev, &dev); -if (!err) - *mmcp =mmc_get_mmc_dev (dev); -#else *mmcp =find_mmc_device (mmc_dev); err = *mmcp ?0 : -ENODEV ; -#endif if (err) {#ifdef CONFIG_SPL_LIBCOMMON_SUPPORT printf("spl: could not find mmc device %d. error: %d\n",
drivers/mmc/mmc.c +24 -0
@@ -2998,6 +2998,30 @@ int mmc_initialize(bd_t *bis)return 0 ; } +#if CONFIG_IS_ENABLED (DM_MMC ) +int mmc_init_device (int num) +{ +struct udevice *dev; +struct mmc *m; +int ret; + + ret =uclass_get_device (UCLASS_MMC , num, &dev); +if (ret) +return ret; + + m =mmc_get_mmc_dev (dev); +if (!m) +return 0 ; +#ifdef CONFIG_FSL_ESDHC_ADAPTER_IDENT +mmc_set_preinit (m,1 ); +#endif +if (m->preinit) +mmc_start_init (m); + +return 0 ; +} +#endif +#ifdef CONFIG_CMD_BKOPS_ENABLE int mmc_set_bkops_enable (struct mmc *mmc) {
include/mmc.h +1 -0
@@ -698,6 +698,7 @@ void mmc_destroy(struct mmc *mmc);*/ int mmc_unbind (struct udevice *dev);int mmc_initialize (bd_t *bis); +int mmc_init_device (int num);int mmc_init (struct mmc *mmc);int mmc_send_tuning (struct mmc *mmc,u32 opcode,int *cmd_error);
Signature · 1 line
2.22.0
PATCH 1/1 spl: dm_mmc: Initialize only the required mmc device
Quoted 101 lines
Subject: [PATCH] spl:
dm_mmc: Initialize only the required mmc deviceIn SPL, all the available mmc devices gets initialized during boot. This might not work in cases where clocks are not available for certain mmc devices(other than boot device) and the support for enabling device might not be ready.
Texas Instruments' K3 J721E device having a central system controller (dmsc) is one such example falling in this category. Below is the sequence for the failing scenario:
- ROM comes up in SD mode and loads SPL by just initialing SD card.
- SPL loads dmsc firmware from SD Card.
Since ROM has enabled SD, SPL need not enable the SD, just need to re initialize the card. But SPL is trying to initialize other MMC instances which are in disabled state. Since dmsc firmware is not yet available, devices cannot be enabled. So in SPL, initialize only the mmc device that is needed.Signed-off-by Lokesh Vutla <[email protected]>--- common/spl/spl_mmc.c | 14 ++++---------- drivers/mmc/mmc.c | 24 ++++++++++++++++++++++++ include/mmc.h | 1 + 3 files changed, 29 insertions(+), 10 deletions(-)common/spl/spl_mmc.c index renamed from common/spl/spl_mmc.c +0
-0
b3619889f7..303f0f80bf100644common/spl/spl_mmc.c +4
-9@@ -113,31 +113,25 @@ static int spl_mmc_get_device_index(u32 boot_device) static int spl_mmc_find_device(struct mmc **mmcp, u32 boot_device) { -#if CONFIG_IS_ENABLED(DM_MMC) -struct udevice *dev; -#endif int err, mmc_dev; mmc_dev =spl_mmc_get_device_index (boot_device);if (mmc_dev <0 )return mmc_dev; +#if CONFIG_IS_ENABLED (DM_MMC ) + err =mmc_init_device (mmc_dev); +#else err =mmc_initialize (NULL ); +#endif /* DM_MMC */ if (err) {#ifdef CONFIG_SPL_LIBCOMMON_SUPPORT printf ("spl: could not initialize mmc. error: %d\n" , err);#endif return err; } - -#if CONFIG_IS_ENABLED (DM_MMC ) - err =uclass_get_device (UCLASS_MMC , mmc_dev, &dev); -if (!err) - *mmcp =mmc_get_mmc_dev (dev); -#else *mmcp =find_mmc_device (mmc_dev); err = *mmcp ?0 : -ENODEV ; -#endif if (err) {#ifdef CONFIG_SPL_LIBCOMMON_SUPPORT printf("spl: could not find mmc device %d. error: %d\n", diff --git
a/drivers/mmc/mmc.cb/drivers/mmc/mmc.cindexeecc7d687e..ec8f92ce8f100644drivers/mmc/mmc.c +24
-0@@ -2998,6 +2998,30 @@ int mmc_initialize(bd_t *bis)return 0 ; } +#if CONFIG_IS_ENABLED (DM_MMC ) +int mmc_init_device (int num) +{ +struct udevice *dev; +struct mmc *m; +int ret; + + ret =uclass_get_device (UCLASS_MMC , num, &dev); +if (ret) +return ret; + + m =mmc_get_mmc_dev (dev); +if (!m) +return 0 ; +#ifdef CONFIG_FSL_ESDHC_ADAPTER_IDENT +mmc_set_preinit (m,1 ); +#endif +if (m->preinit) +mmc_start_init (m); + +return 0 ; +} +#endif +#ifdef CONFIG_CMD_BKOPS_ENABLE int mmc_set_bkops_enable(struct mmc *mmc) { diff --git
a/include/mmc.hb/include/mmc.hindex46422f41a4..878b4c9e57100644
include/mmc.h void mmc_destroy(struct mmc *mmc); · line 703
Quoted 6 lines
include/mmc.h +1
-0@@ -698,6 +698,7 @@ void mmc_destroy(struct mmc *mmc);*/ int mmc_unbind (struct udevice *dev);int mmc_initialize (bd_t *bis); +int mmc_init_device (int num);int mmc_init (struct mmc *mmc);int mmc_send_tuning (struct mmc *mmc,u32 opcode,int *cmd_error);
Quoted 3 lines
include/mmc.h +0
-1--2.22.0
PATCH 1/1 spl: dm_mmc: Initialize only the required mmc device
Hi Peng,
Quoted 17 lines · Peng Fan
Quoted 17 lines
Subject: [PATCH] spl:
dm_mmc: Initialize only the required mmc deviceIn SPL, all the available mmc devices gets initialized during boot. This might not work in cases where clocks are not available for certain mmc devices(other than boot device) and the support for enabling device might not be ready.
Texas Instruments' K3 J721E device having a central system controller (dmsc) is one such example falling in this category. Below is the sequence for the failing scenario:
- ROM comes up in SD mode and loads SPL by just initialing SD card.
- SPL loads dmsc firmware from SD Card.
Since ROM has enabled SD, SPL need not enable the SD, just need to re initialize the card. But SPL is trying to initialize other MMC instances which are in disabled state. Since dmsc firmware is not yet available, devices cannot be enabled. So in SPL, initialize only the mmc device that is needed.
Quoted 1 line
Quoted 1 line
Signed-off-by Lokesh Vutla <[email protected]>
Gentle Ping. Are you planning to take this patch for this merge window?
Thanks and regards,
Lokesh
Quoted 96 lines
Quoted 83 lines
--- common/spl/spl_mmc.c | 14 ++++---------- drivers/mmc/mmc.c | 24 ++++++++++++++++++++++++ include/mmc.h | 1 + 3 files changed, 29 insertions(+), 10 deletions(-)common/spl/spl_mmc.c index renamed from common/spl/spl_mmc.c +0
-0
b3619889f7..303f0f80bf100644common/spl/spl_mmc.c +4
-9@@ -113,31 +113,25 @@ static int spl_mmc_get_device_index(u32 boot_device) static int spl_mmc_find_device(struct mmc **mmcp, u32 boot_device) { -#if CONFIG_IS_ENABLED(DM_MMC) -struct udevice *dev; -#endif int err, mmc_dev; mmc_dev =spl_mmc_get_device_index (boot_device);if (mmc_dev <0 )return mmc_dev; +#if CONFIG_IS_ENABLED (DM_MMC ) + err =mmc_init_device (mmc_dev); +#else err =mmc_initialize (NULL ); +#endif /* DM_MMC */ if (err) {#ifdef CONFIG_SPL_LIBCOMMON_SUPPORT printf ("spl: could not initialize mmc. error: %d\n" , err);#endif return err; } - -#if CONFIG_IS_ENABLED (DM_MMC ) - err =uclass_get_device (UCLASS_MMC , mmc_dev, &dev); -if (!err) - *mmcp =mmc_get_mmc_dev (dev); -#else *mmcp =find_mmc_device (mmc_dev); err = *mmcp ?0 : -ENODEV ; -#endif if (err) {#ifdef CONFIG_SPL_LIBCOMMON_SUPPORT printf("spl: could not find mmc device %d. error: %d\n", diff --git
a/drivers/mmc/mmc.cb/drivers/mmc/mmc.cindexeecc7d687e..ec8f92ce8f100644drivers/mmc/mmc.c +24
-0@@ -2998,6 +2998,30 @@ int mmc_initialize(bd_t *bis)return 0 ; } +#if CONFIG_IS_ENABLED (DM_MMC ) +int mmc_init_device (int num) +{ +struct udevice *dev; +struct mmc *m; +int ret; + + ret =uclass_get_device (UCLASS_MMC , num, &dev); +if (ret) +return ret; + + m =mmc_get_mmc_dev (dev); +if (!m) +return 0 ; +#ifdef CONFIG_FSL_ESDHC_ADAPTER_IDENT +mmc_set_preinit (m,1 ); +#endif +if (m->preinit) +mmc_start_init (m); + +return 0 ; +} +#endif +#ifdef CONFIG_CMD_BKOPS_ENABLE int mmc_set_bkops_enable(struct mmc *mmc) { diff --git
a/include/mmc.hb/include/mmc.hindex46422f41a4..878b4c9e57100644include/mmc.h void mmc_destroy(struct mmc *mmc); · line 703
Quoted 6 lines
include/mmc.h +1
-0@@ -698,6 +698,7 @@ void mmc_destroy(struct mmc *mmc);*/ int mmc_unbind (struct udevice *dev);int mmc_initialize (bd_t *bis); +int mmc_init_device (int num);int mmc_init (struct mmc *mmc);int mmc_send_tuning (struct mmc *mmc,u32 opcode,int *cmd_error);Reviewed-by Peng Fan <[email protected]>Quoted 3 lines
include/mmc.h +0
-1--2.22.0
PATCH 1/1 spl: dm_mmc: Initialize only the required mmc device
Quoted 21 lines
Subject: Re: [PATCH] spl:
dm_mmc: Initialize only the required mmc deviceHi Peng,
Quoted 7 lines · Peng Fan
Quoted 7 lines
Subject: [PATCH] spl:
dm_mmc: Initialize only the required mmc deviceIn SPL, all the available mmc devices gets initialized during boot. This might not work in cases where clocks are not available for certain mmc devices(other than boot device) and the support for enabling device might not be ready.
Quoted 9 lines
Quoted 9 lines
Texas Instruments' K3 J721E device having a central system controller (dmsc) is one such example falling in this category. Below is the sequence for the failing scenario:
- ROM comes up in SD mode and loads SPL by just initialing SD card.
- SPL loads dmsc firmware from SD Card.
Since ROM has enabled SD, SPL need not enable the SD, just need to re initialize the card. But SPL is trying to initialize other MMC instances which are in disabled state. Since dmsc firmware is not yet available, devices cannot be enabled. So in SPL, initialize only the mmc
Quoted 5 lines
device that is needed.
Quoted 2 lines
Quoted 2 lines
Signed-off-by Lokesh Vutla <[email protected]>Gentle Ping. Are you planning to take this patch for this merge window?
Just back from holiday. Yes, I'll pick it up and prepare PR to Tom.
Thanks,
Peng.
Quoted 101 lines
Thanks and regards,
LokeshQuoted 73 lines
Quoted 73 lines
--- common/spl/spl_mmc.c | 14 ++++---------- drivers/mmc/mmc.c | 24 ++++++++++++++++++++++++ include/mmc.h | 1 + 3 files changed, 29 insertions(+), 10 deletions(-)common/spl/spl_mmc.c index renamed from common/spl/spl_mmc.c +0
-0
b3619889f7..303f0f80bf100644common/spl/spl_mmc.c +4
-11@@ -113,31 +113,25 @@ static int spl_mmc_get_device_index(u32 boot_device) static int spl_mmc_find_device(struct mmc **mmcp, u32 boot_device) { -#if CONFIG_IS_ENABLED(DM_MMC) - struct udevice *dev; -#endifint err, mmc_dev; mmc_dev =spl_mmc_get_device_index (boot_device);if (mmc_dev <0 )return mmc_dev; +#if CONFIG_IS_ENABLED (DM_MMC ) + err =mmc_init_device (mmc_dev); +#else err =mmc_initialize (NULL ); +#endif /* DM_MMC */ if (err) {#ifdef CONFIG_SPL_LIBCOMMON_SUPPORT printf ("spl: could not initialize mmc. error: %d\n" , err);#endif return err; } - -#if CONFIG_IS_ENABLED(DM_MMC) - err = uclass_get_device(UCLASS_MMC, mmc_dev, &dev); - if (!err) - *mmcp = mmc_get_mmc_dev(dev); -#else *mmcp =find_mmc_device (mmc_dev); err = *mmcp ?0 : -ENODEV ; -#endifif (err) {#ifdef CONFIG_SPL_LIBCOMMON_SUPPORT printf("spl: could not find mmc device %d. error: %d\n", diff --git a/drivers/mmc/mmc.c b/drivers/mmc/mmc.c index
eecc7d687e..ec8f92ce8f
100644drivers/mmc/mmc.c +19
-0@@ -2998,6 +2998,30 @@ int mmc_initialize(bd_t *bis)return 0 ; } +#if CONFIG_IS_ENABLED (DM_MMC ) +int mmc_init_device (int num) +{ +struct udevice *dev; +struct mmc *m; +int ret; + + ret =uclass_get_device (UCLASS_MMC , num, &dev); +if (ret) +return ret; + + m =mmc_get_mmc_dev (dev); +if (!m) +return 0 ; +#ifdef CONFIG_FSL_ESDHC_ADAPTER_IDENT +mmc_set_preinit (m,1 ); +#endif +if (m->preinit) +mmc_start_init (m);Quoted 8 lines
Quoted 8 lines
drivers/mmc/mmc.c +5
-0+ +return 0 ; +} +#endif +#ifdef CONFIG_CMD_BKOPS_ENABLE int mmc_set_bkops_enable(struct mmc *mmc) { diff --git
a/include/mmc.hb/include/mmc.hindex46422f41a4..878b4c9e57100644
Quoted 15 lines
include/mmc.h void mmc_destroy(struct mmc *mmc); · line 702
Quoted 8 lines
include/mmc.h +1
-0@@ -698,6 +698,7 @@ void mmc_destroy(struct mmc *mmc);*/ int mmc_unbind (struct udevice *dev);int mmc_initialize (bd_t *bis); +int mmc_init_device (int num);int mmc_init (struct mmc *mmc);int mmc_send_tuning (struct mmc *mmc,u32 opcode,int *cmd_error);Reviewed-by Peng Fan <[email protected]>Quoted 3 lines
include/mmc.h +0
-1--2.22.0