[U-Boot] [PATCH 0/2] drivers: omap_hsmmc: move to DM_MMC_OPS

This series adapts the omap_hsmmc driver to DM_MMC_OPS. To reduce the number of #idef/#else/#endif, I voluntarily did not use CONFIG_DM_MMC_OPS in the driver. It's supposed to go away at one point anyway. The consequence is that DM_MMC_OPS must be selected if DM_MMC is selected. This is handled in the Kconfig.
The first patch disables DM_MMC_OPS when DM_MMC is manually disabled in the plaform configuration header file (am335x_evm.h for example). This is done on some platforms when building the SPL. Those #undef could probably haven been removed but it requires some testing that I haven't done yet. The second patch implements the real DM_MMC_OPS support.
This has been tested on DRA7 boards. buildman has been run for dra7 am43 am33 am57.
Jean-Jacques Hiblot (2): include: config: am335x: disable DM_MMC_OPS if DM_MMC is disabled drivers: omap_hsmmc: move to DM_MMC_OPS
drivers/mmc/Kconfig | 1 + drivers/mmc/omap_hsmmc.c | 39 ++++++++++++++++++++++++++++++++------- include/configs/am335x_evm.h | 1 + include/configs/am335x_shc.h | 1 + include/configs/chiliboard.h | 1 + 5 files changed, 36 insertions(+), 7 deletions(-)

Signed-off-by: Jean-Jacques Hiblot jjhiblot@ti.com --- include/configs/am335x_evm.h | 1 + include/configs/am335x_shc.h | 1 + include/configs/chiliboard.h | 1 + 3 files changed, 3 insertions(+)
diff --git a/include/configs/am335x_evm.h b/include/configs/am335x_evm.h index 2712687..d7787a1 100644 --- a/include/configs/am335x_evm.h +++ b/include/configs/am335x_evm.h @@ -284,6 +284,7 @@ */ #ifdef CONFIG_SPL_BUILD #undef CONFIG_DM_MMC +#undef CONFIG_DM_MMC_OPS #undef CONFIG_TIMER #undef CONFIG_DM_USB #endif diff --git a/include/configs/am335x_shc.h b/include/configs/am335x_shc.h index c100fbc..2f35a2c 100644 --- a/include/configs/am335x_shc.h +++ b/include/configs/am335x_shc.h @@ -262,6 +262,7 @@ */ #ifdef CONFIG_SPL_BUILD #undef CONFIG_DM_MMC +#undef CONFIG_DM_MMC_OPS #undef CONFIG_TIMER #endif
diff --git a/include/configs/chiliboard.h b/include/configs/chiliboard.h index c1669fa..0577c57 100644 --- a/include/configs/chiliboard.h +++ b/include/configs/chiliboard.h @@ -188,6 +188,7 @@ */ #ifdef CONFIG_SPL_BUILD #undef CONFIG_DM_MMC +#undef CONFIG_DM_MMC_OPS #undef CONFIG_TIMER #undef CONFIG_DM_USB #endif

Hi,
On 14 April 2017 at 11:50, Jean-Jacques Hiblot jjhiblot@ti.com wrote:
Signed-off-by: Jean-Jacques Hiblot jjhiblot@ti.com
include/configs/am335x_evm.h | 1 + include/configs/am335x_shc.h | 1 + include/configs/chiliboard.h | 1 + 3 files changed, 3 insertions(+)
Reviewed-by: Simon Glass sjg@chromium.org
This seems unfortunate. Is there not enough space in SPL?

On 16/04/2017 21:33, Simon Glass wrote:
Hi,
On 14 April 2017 at 11:50, Jean-Jacques Hiblot jjhiblot@ti.com wrote:
Signed-off-by: Jean-Jacques Hiblot jjhiblot@ti.com
include/configs/am335x_evm.h | 1 + include/configs/am335x_shc.h | 1 + include/configs/chiliboard.h | 1 + 3 files changed, 3 insertions(+)
Reviewed-by: Simon Glass sjg@chromium.org
This seems unfortunate. Is there not enough space in SPL?*
I guess it would work. It adds about 11kB to the MLO. I'll do the test on a am335x evm but won't be able to test on the other two platforms.

Hi,
On 04/15/2017 02:50 AM, Jean-Jacques Hiblot wrote:
Signed-off-by: Jean-Jacques Hiblot jjhiblot@ti.com Reviewed-by: Simon Glass sjg@chromium.org
Applied to u-boot-mmc. Thanks!
Best Regards, Jaehoon Chung
include/configs/am335x_evm.h | 1 + include/configs/am335x_shc.h | 1 + include/configs/chiliboard.h | 1 + 3 files changed, 3 insertions(+)
diff --git a/include/configs/am335x_evm.h b/include/configs/am335x_evm.h index 2712687..d7787a1 100644 --- a/include/configs/am335x_evm.h +++ b/include/configs/am335x_evm.h @@ -284,6 +284,7 @@ */ #ifdef CONFIG_SPL_BUILD #undef CONFIG_DM_MMC +#undef CONFIG_DM_MMC_OPS #undef CONFIG_TIMER #undef CONFIG_DM_USB #endif diff --git a/include/configs/am335x_shc.h b/include/configs/am335x_shc.h index c100fbc..2f35a2c 100644 --- a/include/configs/am335x_shc.h +++ b/include/configs/am335x_shc.h @@ -262,6 +262,7 @@ */ #ifdef CONFIG_SPL_BUILD #undef CONFIG_DM_MMC +#undef CONFIG_DM_MMC_OPS #undef CONFIG_TIMER #endif
diff --git a/include/configs/chiliboard.h b/include/configs/chiliboard.h index c1669fa..0577c57 100644 --- a/include/configs/chiliboard.h +++ b/include/configs/chiliboard.h @@ -188,6 +188,7 @@ */ #ifdef CONFIG_SPL_BUILD #undef CONFIG_DM_MMC +#undef CONFIG_DM_MMC_OPS #undef CONFIG_TIMER #undef CONFIG_DM_USB #endif

Signed-off-by: Jean-Jacques Hiblot jjhiblot@ti.com --- drivers/mmc/Kconfig | 1 + drivers/mmc/omap_hsmmc.c | 39 ++++++++++++++++++++++++++++++++------- 2 files changed, 33 insertions(+), 7 deletions(-)
diff --git a/drivers/mmc/Kconfig b/drivers/mmc/Kconfig index 560391f..caa3c3c 100644 --- a/drivers/mmc/Kconfig +++ b/drivers/mmc/Kconfig @@ -132,6 +132,7 @@ config MMC_PCI
config MMC_OMAP_HS bool "TI OMAP High Speed Multimedia Card Interface support" + select DM_MMC_OPS if DM_MMC help This selects the TI OMAP High Speed Multimedia card Interface. If you have an omap2plus board with a Multimedia Card slot, diff --git a/drivers/mmc/omap_hsmmc.c b/drivers/mmc/omap_hsmmc.c index 83dda09..f18f19b 100644 --- a/drivers/mmc/omap_hsmmc.c +++ b/drivers/mmc/omap_hsmmc.c @@ -327,11 +327,17 @@ static void mmc_reset_controller_fsm(struct hsmmc *mmc_base, u32 bit) } } } - +#ifndef CONFIG_DM_MMC static int omap_hsmmc_send_cmd(struct mmc *mmc, struct mmc_cmd *cmd, struct mmc_data *data) { struct omap_hsmmc_data *priv = omap_hsmmc_get_data(mmc); +#else +static int omap_hsmmc_send_cmd(struct udevice *dev, struct mmc_cmd *cmd, + struct mmc_data *data) +{ + struct omap_hsmmc_data *priv = dev_get_priv(dev); +#endif struct hsmmc *mmc_base; unsigned int flags, mmc_stat; ulong start; @@ -559,9 +565,17 @@ static int mmc_write_data(struct hsmmc *mmc_base, const char *buf, return 0; }
+#ifndef CONFIG_DM_MMC static int omap_hsmmc_set_ios(struct mmc *mmc) { struct omap_hsmmc_data *priv = omap_hsmmc_get_data(mmc); +#else +static int omap_hsmmc_set_ios(struct udevice *dev) +{ + struct omap_hsmmc_data *priv = dev_get_priv(dev); + struct mmc_uclass_priv *upriv = dev_get_uclass_priv(dev); + struct mmc *mmc = upriv->mmc; +#endif struct hsmmc *mmc_base; unsigned int dsor = 0; ulong start; @@ -618,9 +632,9 @@ static int omap_hsmmc_set_ios(struct mmc *mmc)
#ifdef OMAP_HSMMC_USE_GPIO #ifdef CONFIG_DM_MMC -static int omap_hsmmc_getcd(struct mmc *mmc) +static int omap_hsmmc_getcd(struct udevice *dev) { - struct omap_hsmmc_data *priv = omap_hsmmc_get_data(mmc); + struct omap_hsmmc_data *priv = dev_get_priv(dev); int value;
value = dm_gpio_get_value(&priv->cd_gpio); @@ -633,9 +647,9 @@ static int omap_hsmmc_getcd(struct mmc *mmc) return value; }
-static int omap_hsmmc_getwp(struct mmc *mmc) +static int omap_hsmmc_getwp(struct udevice *dev) { - struct omap_hsmmc_data *priv = omap_hsmmc_get_data(mmc); + struct omap_hsmmc_data *priv = dev_get_priv(dev); int value;
value = dm_gpio_get_value(&priv->wp_gpio); @@ -675,6 +689,16 @@ static int omap_hsmmc_getwp(struct mmc *mmc) #endif #endif
+#ifdef CONFIG_DM_MMC +static const struct dm_mmc_ops omap_hsmmc_ops = { + .send_cmd = omap_hsmmc_send_cmd, + .set_ios = omap_hsmmc_set_ios, +#ifdef OMAP_HSMMC_USE_GPIO + .get_cd = omap_hsmmc_getcd, + .get_wp = omap_hsmmc_getwp, +#endif +}; +#else static const struct mmc_ops omap_hsmmc_ops = { .send_cmd = omap_hsmmc_send_cmd, .set_ios = omap_hsmmc_set_ios, @@ -684,6 +708,7 @@ static const struct mmc_ops omap_hsmmc_ops = { .getwp = omap_hsmmc_getwp, #endif }; +#endif
#ifndef CONFIG_DM_MMC int omap_mmc_init(int dev_index, uint host_caps_mask, uint f_max, int cd_gpio, @@ -833,7 +858,6 @@ static int omap_hsmmc_probe(struct udevice *dev) struct mmc *mmc;
cfg->name = "OMAP SD/MMC"; - cfg->ops = &omap_hsmmc_ops;
#ifdef CONFIG_BLK mmc = &plat->mmc; @@ -851,7 +875,7 @@ static int omap_hsmmc_probe(struct udevice *dev) mmc->dev = dev; upriv->mmc = mmc;
- return 0; + return omap_hsmmc_init_setup(mmc); }
static const struct udevice_id omap_hsmmc_ids[] = { @@ -869,6 +893,7 @@ U_BOOT_DRIVER(omap_hsmmc) = { #ifdef CONFIG_BLK .bind = omap_hsmmc_bind, #endif + .ops = &omap_hsmmc_ops, .probe = omap_hsmmc_probe, .priv_auto_alloc_size = sizeof(struct omap_hsmmc_data), .platdata_auto_alloc_size = sizeof(struct omap_hsmmc_plat),

On 14 April 2017 at 11:50, Jean-Jacques Hiblot jjhiblot@ti.com wrote:
Signed-off-by: Jean-Jacques Hiblot jjhiblot@ti.com
drivers/mmc/Kconfig | 1 + drivers/mmc/omap_hsmmc.c | 39 ++++++++++++++++++++++++++++++++------- 2 files changed, 33 insertions(+), 7 deletions(-)
Reviewed-by: Simon Glass sjg@chromium.org

Hi,
On 04/15/2017 02:50 AM, Jean-Jacques Hiblot wrote:
Signed-off-by: Jean-Jacques Hiblot jjhiblot@ti.com Reviewed-by: Simon Glass sjg@chromium.org
Applied to u-boot-mmc. Thanks!
Best Regards, Jaehoon Chung
drivers/mmc/Kconfig | 1 + drivers/mmc/omap_hsmmc.c | 39 ++++++++++++++++++++++++++++++++------- 2 files changed, 33 insertions(+), 7 deletions(-)
diff --git a/drivers/mmc/Kconfig b/drivers/mmc/Kconfig index 560391f..caa3c3c 100644 --- a/drivers/mmc/Kconfig +++ b/drivers/mmc/Kconfig @@ -132,6 +132,7 @@ config MMC_PCI
config MMC_OMAP_HS bool "TI OMAP High Speed Multimedia Card Interface support"
- select DM_MMC_OPS if DM_MMC help This selects the TI OMAP High Speed Multimedia card Interface. If you have an omap2plus board with a Multimedia Card slot,
diff --git a/drivers/mmc/omap_hsmmc.c b/drivers/mmc/omap_hsmmc.c index 83dda09..f18f19b 100644 --- a/drivers/mmc/omap_hsmmc.c +++ b/drivers/mmc/omap_hsmmc.c @@ -327,11 +327,17 @@ static void mmc_reset_controller_fsm(struct hsmmc *mmc_base, u32 bit) } } }
+#ifndef CONFIG_DM_MMC static int omap_hsmmc_send_cmd(struct mmc *mmc, struct mmc_cmd *cmd, struct mmc_data *data) { struct omap_hsmmc_data *priv = omap_hsmmc_get_data(mmc); +#else +static int omap_hsmmc_send_cmd(struct udevice *dev, struct mmc_cmd *cmd,
struct mmc_data *data)
+{
- struct omap_hsmmc_data *priv = dev_get_priv(dev);
+#endif struct hsmmc *mmc_base; unsigned int flags, mmc_stat; ulong start; @@ -559,9 +565,17 @@ static int mmc_write_data(struct hsmmc *mmc_base, const char *buf, return 0; }
+#ifndef CONFIG_DM_MMC static int omap_hsmmc_set_ios(struct mmc *mmc) { struct omap_hsmmc_data *priv = omap_hsmmc_get_data(mmc); +#else +static int omap_hsmmc_set_ios(struct udevice *dev) +{
- struct omap_hsmmc_data *priv = dev_get_priv(dev);
- struct mmc_uclass_priv *upriv = dev_get_uclass_priv(dev);
- struct mmc *mmc = upriv->mmc;
+#endif struct hsmmc *mmc_base; unsigned int dsor = 0; ulong start; @@ -618,9 +632,9 @@ static int omap_hsmmc_set_ios(struct mmc *mmc)
#ifdef OMAP_HSMMC_USE_GPIO #ifdef CONFIG_DM_MMC -static int omap_hsmmc_getcd(struct mmc *mmc) +static int omap_hsmmc_getcd(struct udevice *dev) {
- struct omap_hsmmc_data *priv = omap_hsmmc_get_data(mmc);
struct omap_hsmmc_data *priv = dev_get_priv(dev); int value;
value = dm_gpio_get_value(&priv->cd_gpio);
@@ -633,9 +647,9 @@ static int omap_hsmmc_getcd(struct mmc *mmc) return value; }
-static int omap_hsmmc_getwp(struct mmc *mmc) +static int omap_hsmmc_getwp(struct udevice *dev) {
- struct omap_hsmmc_data *priv = omap_hsmmc_get_data(mmc);
struct omap_hsmmc_data *priv = dev_get_priv(dev); int value;
value = dm_gpio_get_value(&priv->wp_gpio);
@@ -675,6 +689,16 @@ static int omap_hsmmc_getwp(struct mmc *mmc) #endif #endif
+#ifdef CONFIG_DM_MMC +static const struct dm_mmc_ops omap_hsmmc_ops = {
- .send_cmd = omap_hsmmc_send_cmd,
- .set_ios = omap_hsmmc_set_ios,
+#ifdef OMAP_HSMMC_USE_GPIO
- .get_cd = omap_hsmmc_getcd,
- .get_wp = omap_hsmmc_getwp,
+#endif +}; +#else static const struct mmc_ops omap_hsmmc_ops = { .send_cmd = omap_hsmmc_send_cmd, .set_ios = omap_hsmmc_set_ios, @@ -684,6 +708,7 @@ static const struct mmc_ops omap_hsmmc_ops = { .getwp = omap_hsmmc_getwp, #endif }; +#endif
#ifndef CONFIG_DM_MMC int omap_mmc_init(int dev_index, uint host_caps_mask, uint f_max, int cd_gpio, @@ -833,7 +858,6 @@ static int omap_hsmmc_probe(struct udevice *dev) struct mmc *mmc;
cfg->name = "OMAP SD/MMC";
- cfg->ops = &omap_hsmmc_ops;
#ifdef CONFIG_BLK mmc = &plat->mmc; @@ -851,7 +875,7 @@ static int omap_hsmmc_probe(struct udevice *dev) mmc->dev = dev; upriv->mmc = mmc;
- return 0;
- return omap_hsmmc_init_setup(mmc);
}
static const struct udevice_id omap_hsmmc_ids[] = { @@ -869,6 +893,7 @@ U_BOOT_DRIVER(omap_hsmmc) = { #ifdef CONFIG_BLK .bind = omap_hsmmc_bind, #endif
- .ops = &omap_hsmmc_ops, .probe = omap_hsmmc_probe, .priv_auto_alloc_size = sizeof(struct omap_hsmmc_data), .platdata_auto_alloc_size = sizeof(struct omap_hsmmc_plat),
participants (3)
-
Jaehoon Chung
-
Jean-Jacques Hiblot
-
Simon Glass