Skip to contentSkip to conversation

mmc: omap_hsmmc: convert to use dm block devies

RFC PATCH New Grygorii Strashko 5 participants 7 messages Feb 2, 2017 – Feb 13, 2017

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

RFC PATCH 1/1 mmc: omap_hsmmc: convert to use dm block devies

Convert OMAP hsmmc driver to use driver-model block devices.

---
Hi All,

First of all, sorry if my questions/problems are looks dumb, I'm very new with u-boot.

This is my attampt to enable CONFIG_BLK on OMAP platforms which is blocked now by omap_hsmmc driver. omap_hsmmc required to be updated to use driver-model block devices at minimum (and max to use dm_mmc_ops). Also, as per my understanding, CONFIG_BLK is blocker for other tasks like enabling driver model for OMAP sata devices.

With this patch I can boot from mmc on am335x-evm, but there are two problems I need help with:
1) My changes in Makefiles looks really ugly, but without them SPL build will fail because undef'ing in include/configs/am335x_evm.h does not take effect in Makefile (thanks Vignesh for the information [1]) and I, honestly, do not know how to fix it in better way, so I'd be appreciated for any help. Comparing to Vignesh's case, files which need to be excluded from build are generic and I worry that there can be dependecy from CONFIG_SPL_DM.

2) with this patch I can see error message in log "** Bad device size - mmc 0 **":
U-Boot 2017.03-rc1-00020-g1a3b11a-dirty (Feb 02 2017 - 12:04:01 -0600)

CPU  : AM335X-GP rev 2.0
Model: TI AM335x EVM
DRAM:  1 GiB
NAND:  256 MiB
MMC:   mmc at 48060000mmc@47810000OMAP SD/MMC: 0, OMAP SD/MMC: 1

** Bad device size - mmc 0 **
Using default environment

this message is triggered from:
board_r.c: initr_env()
- env_common.c: env_relocate()
- env_fat.c: env_relocate_spec()
- part.c: blk_get_device_part_str()
because partitions are not initialized yet, as i understood,

Seems there are should be additional call to mmc_init():mmc_startup():part_init(), but I'm not sure where/how to add it correctly.

Thanks.

[1] http://lists.denx.de/pipermail/u-boot/2016-August/262447.html

 configs/am335x_evm_defconfig |  1 -
 drivers/block/Makefile       |  6 ++++-
 drivers/mmc/Makefile         |  8 ++++---
 drivers/mmc/omap_hsmmc.c     | 55 ++++++++++++++++++++++++++++++++------------
 include/configs/am335x_evm.h |  1 +
 5 files changed, 51 insertions(+), 20 deletions(-)
configs/am335x_evm_defconfig +0 -1
index 6f624e9..d36e7d4 100644
@@ -30,7 +30,6 @@ CONFIG_CMD_GPIO=y
 CONFIG_CMD_EXT4_WRITE=y
 CONFIG_OF_CONTROL=y
 CONFIG_OF_LIST="am335x-evm am335x-bone am335x-boneblack am335x-evmsk am335x-bonegreen am335x-icev2"
-# CONFIG_BLK is not set
 CONFIG_DFU_MMC=y
 CONFIG_DFU_NAND=y
 CONFIG_DFU_RAM=y
drivers/block/Makefile +5 -1
index 41217c1..44baee3 100644
@@ -5,12 +5,16 @@
 # SPDX-License-Identifier:	GPL-2.0+
 #
 
-obj-$(CONFIG_BLK) += blk-uclass.o
+obj-$(CONFIG_$(SPL_)BLK) += blk-uclass.o
 
 ifndef CONFIG_BLK
 obj-y += blk_legacy.o
 endif
 
+ifdef SPL_
+obj-y += blk_legacy.o
+endif
+
 obj-$(CONFIG_AHCI) += ahci-uclass.o
 obj-$(CONFIG_DM_SCSI) += scsi-uclass.o
 
drivers/mmc/Makefile +5 -3
index 6af7f79..bc16c78 100644
@@ -5,14 +5,16 @@
 # SPDX-License-Identifier:	GPL-2.0+
 #
 
-ifdef CONFIG_DM_MMC
-obj-$(CONFIG_GENERIC_MMC) += mmc-uclass.o
-endif
+obj-$(CONFIG_$(SPL_)DM_MMC) += mmc-uclass.o
 
 ifndef CONFIG_BLK
 obj-$(CONFIG_GENERIC_MMC) += mmc_legacy.o
 endif
 
+ifdef SPL_
+obj-$(CONFIG_GENERIC_MMC) += mmc_legacy.o
+endif
+
 obj-$(CONFIG_ARM_PL180_MMCI) += arm_pl180_mmci.o
 obj-$(CONFIG_ATMEL_SDHCI) += atmel_sdhci.o
 obj-$(CONFIG_BFIN_SDH) += bfin_sdh.o
drivers/mmc/omap_hsmmc.c +40 -15

156 lines not on this page · raw message

include/configs/am335x_evm.h +1 -0
index 7390015..6368fb8 100644
@@ -285,6 +285,7 @@
  */
 #ifdef CONFIG_SPL_BUILD
 #undef CONFIG_DM_MMC
+#undef CONFIG_BLK
 #undef CONFIG_TIMER
 #undef CONFIG_DM_USB
 #undef CONFIG_DM_NAND
Signature · 1 line
2.10.1.dirty
#1 lore raw

RFC PATCH 1/1 mmc: omap_hsmmc: convert to use dm block devies

Quoted 44 lines · Grygorii

Convert OMAP hsmmc driver to use driver-model block devices.

---
Hi All,

First of all, sorry if my questions/problems are looks dumb, I'm very new with u-boot.

This is my attampt to enable CONFIG_BLK on OMAP platforms which is blocked now by omap_hsmmc driver. omap_hsmmc required to be updated to use driver-model block devices at minimum (and max to use dm_mmc_ops). Also, as per my understanding, CONFIG_BLK is blocker for other tasks like enabling driver model for OMAP sata devices.

With this patch I can boot from mmc on am335x-evm, but there are two problems I need help with:
1) My changes in Makefiles looks really ugly, but without them SPL build will fail because undef'ing in include/configs/am335x_evm.h does not take effect in Makefile (thanks Vignesh for the information [1]) and I, honestly, do not know how to fix it in better way, so I'd be appreciated for any help. Comparing to Vignesh's case, files which need to be excluded from build are generic and I worry that there can be dependecy from CONFIG_SPL_DM.

configs/am335x_evm_defconfig +0 -1
index 6f624e9..d36e7d4 100644
@@ -30,7 +30,6 @@ CONFIG_CMD_GPIO=y
 CONFIG_CMD_EXT4_WRITE=y
 CONFIG_OF_CONTROL=y
 CONFIG_OF_LIST="am335x-evm am335x-bone am335x-boneblack am335x-evmsk am335x-bonegreen am335x-icev2"
-# CONFIG_BLK is not set
 CONFIG_DFU_MMC=y
 CONFIG_DFU_NAND=y
 CONFIG_DFU_RAM=y
drivers/block/Makefile +0 -0
index 41217c1..44baee3 100644
@@ -5,12 +5,16 @@
 # SPDX-License-Identifier:	GPL-2.0+
 #
 

drivers/block/Makefile line 16

Quoted 10 lines
drivers/block/Makefile +4 -1
-obj-$(CONFIG_BLK) += blk-uclass.o
+obj-$(CONFIG_$(SPL_)BLK) += blk-uclass.o
 
 ifndef CONFIG_BLK
 obj-y += blk_legacy.o
 endif
 
+ifdef SPL_
+obj-y += blk_legacy.o
+endif

I am facing a same problem with DM_ETH as well.
How about something like:

ifeq ($(CONFIG_$(SPL_)DM)$(CONFIG_BLK),yy)
obj-y += blk_uclass.o
else
obj-y += blk_legacy.o
endif

Is this an acceptable solution?

Signature · 2 lines
Regards
Vignesh
#2 lore raw

RFC PATCH 1/1 mmc: omap_hsmmc: convert to use dm block devies

Quoted 62 lines · Vignesh R
Quoted 44 lines · Grygorii

Convert OMAP hsmmc driver to use driver-model block devices.

---
Hi All,

First of all, sorry if my questions/problems are looks dumb, I'm very new with u-boot.

This is my attampt to enable CONFIG_BLK on OMAP platforms which is blocked now by omap_hsmmc driver. omap_hsmmc required to be updated to use driver-model block devices at minimum (and max to use dm_mmc_ops). Also, as per my understanding, CONFIG_BLK is blocker for other tasks like enabling driver model for OMAP sata devices.

With this patch I can boot from mmc on am335x-evm, but there are two problems I need help with:
1) My changes in Makefiles looks really ugly, but without them SPL build will fail because undef'ing in include/configs/am335x_evm.h does not take effect in Makefile (thanks Vignesh for the information [1]) and I, honestly, do not know how to fix it in better way, so I'd be appreciated for any help. Comparing to Vignesh's case, files which need to be excluded from build are generic and I worry that there can be dependecy from CONFIG_SPL_DM.

configs/am335x_evm_defconfig +0 -1
index 6f624e9..d36e7d4 100644
@@ -30,7 +30,6 @@ CONFIG_CMD_GPIO=y
 CONFIG_CMD_EXT4_WRITE=y
 CONFIG_OF_CONTROL=y
 CONFIG_OF_LIST="am335x-evm am335x-bone am335x-boneblack am335x-evmsk am335x-bonegreen am335x-icev2"
-# CONFIG_BLK is not set
 CONFIG_DFU_MMC=y
 CONFIG_DFU_NAND=y
 CONFIG_DFU_RAM=y
drivers/block/Makefile +0 -0
index 41217c1..44baee3 100644
@@ -5,12 +5,16 @@
 # SPDX-License-Identifier:	GPL-2.0+
 #
 

drivers/block/Makefile line 16

Quoted 10 lines
drivers/block/Makefile +4 -1
-obj-$(CONFIG_BLK) += blk-uclass.o
+obj-$(CONFIG_$(SPL_)BLK) += blk-uclass.o
 
 ifndef CONFIG_BLK
 obj-y += blk_legacy.o
 endif
 
+ifdef SPL_
+obj-y += blk_legacy.o
+endif

I am facing a same problem with DM_ETH as well.
How about something like:

Quoted 8 lines

ifeq ($(CONFIG_$(SPL_)DM)$(CONFIG_BLK),yy)
obj-y += blk_uclass.o
else
obj-y += blk_legacy.o
endif

Is this an acceptable solution?

No, I think this is really highlighting that we need to figure out a solution to using DM inside of SPL on these classes of devices. I think the last time I started to think out loud about how to solve this my suggestion was to make a "dummy" board dts file that is correct enough for SPL needs and that we can bring up full U-Boot on. Off the top of my head, the differences between BBB/BBW/GP-EVM/EVM-SK/BBG are not things we would see inside of SPL. In a similar manner we should be able to get am43xx going, and dra7xx/am57xx going.

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20170203/5e9c8cee/attachment.sig>
#3 lore raw

RFC PATCH 1/1 mmc: omap_hsmmc: convert to use dm block devies

Quoted 72 lines · Tom Rini
Quoted 62 lines · Vignesh R
Quoted 44 lines · Grygorii

Convert OMAP hsmmc driver to use driver-model block devices.

---
Hi All,

First of all, sorry if my questions/problems are looks dumb, I'm very new with u-boot.

This is my attampt to enable CONFIG_BLK on OMAP platforms which is blocked now by omap_hsmmc driver. omap_hsmmc required to be updated to use driver-model block devices at minimum (and max to use dm_mmc_ops). Also, as per my understanding, CONFIG_BLK is blocker for other tasks like enabling driver model for OMAP sata devices.

With this patch I can boot from mmc on am335x-evm, but there are two problems I need help with:
1) My changes in Makefiles looks really ugly, but without them SPL build will fail because undef'ing in include/configs/am335x_evm.h does not take effect in Makefile (thanks Vignesh for the information [1]) and I, honestly, do not know how to fix it in better way, so I'd be appreciated for any help. Comparing to Vignesh's case, files which need to be excluded from build are generic and I worry that there can be dependecy from CONFIG_SPL_DM.

configs/am335x_evm_defconfig +0 -1
index 6f624e9..d36e7d4 100644
@@ -30,7 +30,6 @@ CONFIG_CMD_GPIO=y
 CONFIG_CMD_EXT4_WRITE=y
 CONFIG_OF_CONTROL=y
 CONFIG_OF_LIST="am335x-evm am335x-bone am335x-boneblack am335x-evmsk am335x-bonegreen am335x-icev2"
-# CONFIG_BLK is not set
 CONFIG_DFU_MMC=y
 CONFIG_DFU_NAND=y
 CONFIG_DFU_RAM=y
drivers/block/Makefile +0 -0
index 41217c1..44baee3 100644
@@ -5,12 +5,16 @@
 # SPDX-License-Identifier:	GPL-2.0+
 #
 

drivers/block/Makefile line 16

Quoted 10 lines
drivers/block/Makefile +4 -1
-obj-$(CONFIG_BLK) += blk-uclass.o
+obj-$(CONFIG_$(SPL_)BLK) += blk-uclass.o
 
 ifndef CONFIG_BLK
 obj-y += blk_legacy.o
 endif
 
+ifdef SPL_
+obj-y += blk_legacy.o
+endif

I am facing a same problem with DM_ETH as well.
How about something like:

Quoted 8 lines

ifeq ($(CONFIG_$(SPL_)DM)$(CONFIG_BLK),yy)
obj-y += blk_uclass.o
else
obj-y += blk_legacy.o
endif

Is this an acceptable solution?

Quoted 10 lines

No, I think this is really highlighting that we need to figure out a solution to using DM inside of SPL on these classes of devices. I think the last time I started to think out loud about how to solve this my suggestion was to make a "dummy" board dts file that is correct enough for SPL needs and that we can bring up full U-Boot on. Off the top of my head, the differences between BBB/BBW/GP-EVM/EVM-SK/BBG are not things we would see inside of SPL. In a similar manner we should be able to get am43xx going, and dra7xx/am57xx going.

We don't really need DT support in SPL for using DM, we could statically instantiate device drivers using a board file type system, platform_add_device(device_data) etc..

My biggest objection is in SPL bloat. What do we get by adding DM to SPL? Code re-use is nice, but SPL had hard needs in speed and size that will continue to be eroded by these changes.

Perhaps it is time to re-consider adding separate defconfigs/Makefiles for SPL?

Quoted 6 lines

_______________________________________________
U-Boot mailing list
U-Boot at lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot

#4 lore raw

RFC PATCH 1/1 mmc: omap_hsmmc: convert to use dm block devies

Quoted 88 lines · Andrew F. Davis
Quoted 72 lines · Tom Rini
Quoted 62 lines · Vignesh R
Quoted 44 lines · Grygorii

Convert OMAP hsmmc driver to use driver-model block devices.

---
Hi All,

First of all, sorry if my questions/problems are looks dumb, I'm very new with u-boot.

This is my attampt to enable CONFIG_BLK on OMAP platforms which is blocked now by omap_hsmmc driver. omap_hsmmc required to be updated to use driver-model block devices at minimum (and max to use dm_mmc_ops). Also, as per my understanding, CONFIG_BLK is blocker for other tasks like enabling driver model for OMAP sata devices.

With this patch I can boot from mmc on am335x-evm, but there are two problems I need help with:
1) My changes in Makefiles looks really ugly, but without them SPL build will fail because undef'ing in include/configs/am335x_evm.h does not take effect in Makefile (thanks Vignesh for the information [1]) and I, honestly, do not know how to fix it in better way, so I'd be appreciated for any help. Comparing to Vignesh's case, files which need to be excluded from build are generic and I worry that there can be dependecy from CONFIG_SPL_DM.

configs/am335x_evm_defconfig +0 -1
index 6f624e9..d36e7d4 100644
@@ -30,7 +30,6 @@ CONFIG_CMD_GPIO=y
 CONFIG_CMD_EXT4_WRITE=y
 CONFIG_OF_CONTROL=y
 CONFIG_OF_LIST="am335x-evm am335x-bone am335x-boneblack am335x-evmsk am335x-bonegreen am335x-icev2"
-# CONFIG_BLK is not set
 CONFIG_DFU_MMC=y
 CONFIG_DFU_NAND=y
 CONFIG_DFU_RAM=y
drivers/block/Makefile +0 -0
index 41217c1..44baee3 100644
@@ -5,12 +5,16 @@
 # SPDX-License-Identifier:	GPL-2.0+
 #
 

drivers/block/Makefile line 16

Quoted 10 lines
drivers/block/Makefile +4 -1
-obj-$(CONFIG_BLK) += blk-uclass.o
+obj-$(CONFIG_$(SPL_)BLK) += blk-uclass.o
 
 ifndef CONFIG_BLK
 obj-y += blk_legacy.o
 endif
 
+ifdef SPL_
+obj-y += blk_legacy.o
+endif

I am facing a same problem with DM_ETH as well.
How about something like:

Quoted 8 lines

ifeq ($(CONFIG_$(SPL_)DM)$(CONFIG_BLK),yy)
obj-y += blk_uclass.o
else
obj-y += blk_legacy.o
endif

Is this an acceptable solution?

Quoted 10 lines

No, I think this is really highlighting that we need to figure out a solution to using DM inside of SPL on these classes of devices. I think the last time I started to think out loud about how to solve this my suggestion was to make a "dummy" board dts file that is correct enough for SPL needs and that we can bring up full U-Boot on. Off the top of my head, the differences between BBB/BBW/GP-EVM/EVM-SK/BBG are not things we would see inside of SPL. In a similar manner we should be able to get am43xx going, and dra7xx/am57xx going.

We don't really need DT support in SPL for using DM, we could statically instantiate device drivers using a board file type system, platform_add_device(device_data) etc..

Quoted 6 lines

My biggest objection is in SPL bloat. What do we get by adding DM to SPL? Code re-use is nice, but SPL had hard needs in speed and size that will continue to be eroded by these changes.

Perhaps it is time to re-consider adding separate defconfigs/Makefiles for SPL?

The problem we need to solve is to also clean up the code and keep it clean. The fine line we need to walk is the ability to fit into both reasonably small and still reasonably supported SoCs and the need to continue to be able to re-use code and unify code. And part of the answer here may be to say that newer compilers will be the required minimum in some platforms too. For example with am335x_hs:
gcc-6.1.1 (Debian 6.1.1-9):

$ size am335x_hs_evm/u-boot-spl
   text    data     bss     dec     hex filename
  37810    2452  198920  239182   3a64e am335x_hs_evm/u-boot-spl
gcc-4.9.0:
$ size am335x_hs_evm/u-boot-spl
   text    data     bss     dec     hex filename
  42082    2452  198980  243514   3b73a am335x_hs_evm/u-boot-spl

Since we're just talking text my assumption is that the fix for
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=54303 being available vs not (it's also not fixed in gcc-5) is what is making up that large difference. And going from 698 bytes headroom to 4970 bytes headroom will make things a little easier to deal with.

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20170207/a6bd3293/attachment.sig>
#5 lore raw

RFC PATCH 1/1 mmc: omap_hsmmc: convert to use dm block devies

In reply to Grygorii Strashko

Hi,

Quoted 14 lines · Grygorii Strashko

Convert OMAP hsmmc driver to use driver-model block devices.

---
Hi All,

First of all, sorry if my questions/problems are looks dumb, I'm very new with u-boot.

This is my attampt to enable CONFIG_BLK on OMAP platforms which is blocked now by omap_hsmmc driver. omap_hsmmc required to be updated to use driver-model block devices at minimum (and max to use dm_mmc_ops). Also, as per my understanding, CONFIG_BLK is blocker for other tasks like enabling driver model for OMAP sata devices.

Quoted 8 lines

With this patch I can boot from mmc on am335x-evm, but there are two problems I need help with:
1) My changes in Makefiles looks really ugly, but without them SPL build will fail because undef'ing in include/configs/am335x_evm.h does not take effect in Makefile (thanks Vignesh for the information [1]) and I, honestly, do not know how to fix it in better way, so I'd be appreciated for any help. Comparing to Vignesh's case, files which need to be excluded from build are generic and I worry that there can be dependecy from CONFIG_SPL_DM.

It would be great to enable CONFIG_BLK and CONFIG_DM_MMC in SPL. Perhaps Tom's message (later in this thread) about the gcc bug might help. The size difference is small, but not 0 unfortunately.

Quoted 19 lines

2) with this patch I can see error message in log "** Bad device size - mmc 0 **":
U-Boot 2017.03-rc1-00020-g1a3b11a-dirty (Feb 02 2017 - 12:04:01 -0600)

CPU  : AM335X-GP rev 2.0
Model: TI AM335x EVM
DRAM:  1 GiB
NAND:  256 MiB
MMC:   mmc at 48060000mmc@47810000OMAP SD/MMC: 0, OMAP SD/MMC: 1

** Bad device size - mmc 0 **
Using default environment

this message is triggered from:
board_r.c: initr_env()
- env_common.c: env_relocate()
- env_fat.c: env_relocate_spec()
- part.c: blk_get_device_part_str()
because partitions are not initialized yet, as i understood,

Quoted 2 lines

Seems there are should be additional call to mmc_init():mmc_startup():part_init(), but I'm not sure where/how to add it correctly.

Does this help?

http://patchwork.ozlabs.org/patch/717710/

Regards,
Simon

Quoted 256 lines

Thanks.

[1] http://lists.denx.de/pipermail/u-boot/2016-August/262447.html

 configs/am335x_evm_defconfig |  1 -
 drivers/block/Makefile       |  6 ++++-
 drivers/mmc/Makefile         |  8 ++++---
 drivers/mmc/omap_hsmmc.c     | 55 ++++++++++++++++++++++++++++++++------------
 include/configs/am335x_evm.h |  1 +
 5 files changed, 51 insertions(+), 20 deletions(-)
configs/am335x_evm_defconfig +0 -1
index 6f624e9..d36e7d4 100644
@@ -30,7 +30,6 @@ CONFIG_CMD_GPIO=y
 CONFIG_CMD_EXT4_WRITE=y
 CONFIG_OF_CONTROL=y
 CONFIG_OF_LIST="am335x-evm am335x-bone am335x-boneblack am335x-evmsk am335x-bonegreen am335x-icev2"
-# CONFIG_BLK is not set
 CONFIG_DFU_MMC=y
 CONFIG_DFU_NAND=y
 CONFIG_DFU_RAM=y
drivers/block/Makefile +5 -1
index 41217c1..44baee3 100644
@@ -5,12 +5,16 @@
 # SPDX-License-Identifier:     GPL-2.0+
 #
 
-obj-$(CONFIG_BLK) += blk-uclass.o
+obj-$(CONFIG_$(SPL_)BLK) += blk-uclass.o
 
 ifndef CONFIG_BLK
 obj-y += blk_legacy.o
 endif
 
+ifdef SPL_
+obj-y += blk_legacy.o
+endif
+
 obj-$(CONFIG_AHCI) += ahci-uclass.o
 obj-$(CONFIG_DM_SCSI) += scsi-uclass.o
 
drivers/mmc/Makefile +5 -3
index 6af7f79..bc16c78 100644
@@ -5,14 +5,16 @@
 # SPDX-License-Identifier:     GPL-2.0+
 #
 
-ifdef CONFIG_DM_MMC
-obj-$(CONFIG_GENERIC_MMC) += mmc-uclass.o
-endif
+obj-$(CONFIG_$(SPL_)DM_MMC) += mmc-uclass.o
 
 ifndef CONFIG_BLK
 obj-$(CONFIG_GENERIC_MMC) += mmc_legacy.o
 endif
 
+ifdef SPL_
+obj-$(CONFIG_GENERIC_MMC) += mmc_legacy.o
+endif
+
 obj-$(CONFIG_ARM_PL180_MMCI) += arm_pl180_mmci.o
 obj-$(CONFIG_ATMEL_SDHCI) += atmel_sdhci.o
 obj-$(CONFIG_BFIN_SDH) += bfin_sdh.o
drivers/mmc/omap_hsmmc.c +40 -15
index b326846..fa5d72b 100644
@@ -53,9 +53,16 @@ DECLARE_GLOBAL_DATA_PTR;
 #define SYSCTL_SRC     (1 << 25)
 #define SYSCTL_SRD     (1 << 26)
 
+struct omap_hsmmc_plat {
+       struct mmc_config cfg;
+       struct mmc mmc;
+};
+
 struct omap_hsmmc_data {
        struct hsmmc *base_addr;
+#ifndef CONFIG_DM_MMC
        struct mmc_config cfg;
+#endif
 #ifdef OMAP_HSMMC_USE_GPIO
 #ifdef CONFIG_DM_MMC
        struct gpio_desc cd_gpio;       /* Change Detect GPIO */
@@ -137,7 +144,7 @@ static unsigned char mmc_board_init(struct mmc *mmc)
 
 #if defined(CONFIG_OMAP54XX) || defined(CONFIG_OMAP44XX)
        /* PBIAS config needed for MMC1 only */
-       if (mmc->block_dev.devnum == 0)
+       if (mmc_get_blk_desc(mmc)->devnum == 0)
                vmmc_pbias_config(LDO_VOLT_3V0);
 #endif
 
@@ -171,15 +178,24 @@ void mmc_init_stream(struct hsmmc *mmc_base)
        }
        writel(readl(&mmc_base->con) & ~INIT_INITSTREAM, &mmc_base->con);
 }
+struct omap_hsmmc_data *omap_hsmmc_get_data(struct mmc *mmc)
+{
+#ifdef CONFIG_DM_MMC
+       return dev_get_priv(mmc->dev);
+#else
+       return (struct omap_hsmmc_data *)mmc->priv;
+#endif
+}
 
 static int omap_hsmmc_init_setup(struct mmc *mmc)
 {
+       struct omap_hsmmc_data *priv = omap_hsmmc_get_data(mmc);
        struct hsmmc *mmc_base;
        unsigned int reg_val;
        unsigned int dsor;
        ulong start;
 
-       mmc_base = ((struct omap_hsmmc_data *)mmc->priv)->base_addr;
+       mmc_base = priv->base_addr;
        mmc_board_init(mmc);
 
        writel(readl(&mmc_base->sysconfig) | MMC_SOFTRESET,
@@ -284,11 +300,12 @@ static void mmc_reset_controller_fsm(struct hsmmc *mmc_base, u32 bit)
 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);
        struct hsmmc *mmc_base;
        unsigned int flags, mmc_stat;
        ulong start;
 
-       mmc_base = ((struct omap_hsmmc_data *)mmc->priv)->base_addr;
+       mmc_base = priv->base_addr;
        start = get_timer(0);
        while ((readl(&mmc_base->pstate) & (DATI_MASK | CMDI_MASK)) != 0) {
                if (get_timer(0) - start > MAX_RETRY_MS) {
@@ -513,11 +530,12 @@ static int mmc_write_data(struct hsmmc *mmc_base, const char *buf,
 
 static int omap_hsmmc_set_ios(struct mmc *mmc)
 {
+       struct omap_hsmmc_data *priv = omap_hsmmc_get_data(mmc);
        struct hsmmc *mmc_base;
        unsigned int dsor = 0;
        ulong start;
 
-       mmc_base = ((struct omap_hsmmc_data *)mmc->priv)->base_addr;
+       mmc_base = priv->base_addr;
        /* configue bus width */
        switch (mmc->bus_width) {
        case 8:
@@ -571,7 +589,7 @@ static int omap_hsmmc_set_ios(struct mmc *mmc)
 #ifdef CONFIG_DM_MMC
 static int omap_hsmmc_getcd(struct mmc *mmc)
 {
-       struct omap_hsmmc_data *priv = mmc->priv;
+       struct omap_hsmmc_data *priv = omap_hsmmc_get_data(mmc);
        int value;
 
        value = dm_gpio_get_value(&priv->cd_gpio);
@@ -586,7 +604,7 @@ static int omap_hsmmc_getcd(struct mmc *mmc)
 
 static int omap_hsmmc_getwp(struct mmc *mmc)
 {
-       struct omap_hsmmc_data *priv = mmc->priv;
+       struct omap_hsmmc_data *priv = omap_hsmmc_get_data(mmc);
        int value;
 
        value = dm_gpio_get_value(&priv->wp_gpio);
@@ -727,6 +745,7 @@ int omap_mmc_init(int dev_index, uint host_caps_mask, uint f_max, int cd_gpio,
 static int omap_hsmmc_ofdata_to_platdata(struct udevice *dev)
 {
        struct omap_hsmmc_data *priv = dev_get_priv(dev);
+       struct omap_hsmmc_plat *plat = dev_get_platdata(dev);
        const void *fdt = gd->fdt_blob;
        int node = dev->of_offset;
        struct mmc_config *cfg;
@@ -734,7 +753,7 @@ static int omap_hsmmc_ofdata_to_platdata(struct udevice *dev)
 
        priv->base_addr = map_physmem(dev_get_addr(dev), sizeof(struct hsmmc *),
                                      MAP_NOCACHE);
-       cfg = &priv->cfg;
+       cfg = &plat->cfg;
 
        cfg->host_caps = MMC_MODE_HS_52MHz | MMC_MODE_HS;
        val = fdtdec_get_int(fdt, node, "bus-width", -1);
@@ -766,29 +785,33 @@ static int omap_hsmmc_ofdata_to_platdata(struct udevice *dev)
        return 0;
 }
 
+static int omap_hsmmc_bind(struct udevice *dev)
+{
+       struct omap_hsmmc_plat *plat = dev_get_platdata(dev);
+
+       return mmc_bind(dev, &plat->mmc, &plat->cfg);
+}
+
+
 static int omap_hsmmc_probe(struct udevice *dev)
 {
+       struct omap_hsmmc_plat *plat = dev_get_platdata(dev);
        struct mmc_uclass_priv *upriv = dev_get_uclass_priv(dev);
        struct omap_hsmmc_data *priv = dev_get_priv(dev);
        struct mmc_config *cfg;
-       struct mmc *mmc;
 
-       cfg = &priv->cfg;
+       cfg = &plat->cfg;
        cfg->name = "OMAP SD/MMC";
        cfg->ops = &omap_hsmmc_ops;
 
-       mmc = mmc_create(cfg, priv);
-       if (mmc == NULL)
-               return -1;
-
 #ifdef OMAP_HSMMC_USE_GPIO
        gpio_request_by_name(dev, "cd-gpios", 0, &priv->cd_gpio, GPIOD_IS_IN);
        gpio_request_by_name(dev, "wp-gpios", 0, &priv->wp_gpio, GPIOD_IS_IN);
 #endif
 
-       mmc->dev = dev;
-       upriv->mmc = mmc;
+       upriv->mmc = &plat->mmc;
 
+       printf("%s", plat->mmc.dev->name);
        return 0;
 }
 
@@ -804,7 +827,9 @@ U_BOOT_DRIVER(omap_hsmmc) = {
        .id     = UCLASS_MMC,
        .of_match = omap_hsmmc_ids,
        .ofdata_to_platdata = omap_hsmmc_ofdata_to_platdata,
+       .bind = omap_hsmmc_bind,
        .probe  = omap_hsmmc_probe,
        .priv_auto_alloc_size = sizeof(struct omap_hsmmc_data),
+       .platdata_auto_alloc_size = sizeof(struct omap_hsmmc_plat),
 };
 #endif
include/configs/am335x_evm.h +1 -1
index 7390015..6368fb8 100644
@@ -285,6 +285,7 @@
  */
 #ifdef CONFIG_SPL_BUILD
 #undef CONFIG_DM_MMC
+#undef CONFIG_BLK
 #undef CONFIG_TIMER
 #undef CONFIG_DM_USB
 #undef CONFIG_DM_NAND
--

2.10.1.dirty

#6 lore raw

RFC PATCH 1/1 mmc: omap_hsmmc: convert to use dm block devies

Quoted 49 lines · Simon Glass

Hi,

Quoted 14 lines · Grygorii Strashko

Convert OMAP hsmmc driver to use driver-model block devices.

---
Hi All,

First of all, sorry if my questions/problems are looks dumb, I'm very new with u-boot.

This is my attampt to enable CONFIG_BLK on OMAP platforms which is blocked now by omap_hsmmc driver. omap_hsmmc required to be updated to use driver-model block devices at minimum (and max to use dm_mmc_ops). Also, as per my understanding, CONFIG_BLK is blocker for other tasks like enabling driver model for OMAP sata devices.

Quoted 8 lines

With this patch I can boot from mmc on am335x-evm, but there are two problems I need help with:
1) My changes in Makefiles looks really ugly, but without them SPL build will fail because undef'ing in include/configs/am335x_evm.h does not take effect in Makefile (thanks Vignesh for the information [1]) and I, honestly, do not know how to fix it in better way, so I'd be appreciated for any help. Comparing to Vignesh's case, files which need to be excluded from build are generic and I worry that there can be dependecy from CONFIG_SPL_DM.

It would be great to enable CONFIG_BLK and CONFIG_DM_MMC in SPL. Perhaps Tom's message (later in this thread) about the gcc bug might help. The size difference is small, but not 0 unfortunately.

Quoted 19 lines

2) with this patch I can see error message in log "** Bad device size - mmc 0 **":
U-Boot 2017.03-rc1-00020-g1a3b11a-dirty (Feb 02 2017 - 12:04:01 -0600)

CPU  : AM335X-GP rev 2.0
Model: TI AM335x EVM
DRAM:  1 GiB
NAND:  256 MiB
MMC:   mmc at 48060000mmc@47810000OMAP SD/MMC: 0, OMAP SD/MMC: 1

** Bad device size - mmc 0 **
Using default environment

this message is triggered from:
board_r.c: initr_env()
- env_common.c: env_relocate()
- env_fat.c: env_relocate_spec()
- part.c: blk_get_device_part_str()
because partitions are not initialized yet, as i understood,

Quoted 7 lines
Quoted 2 lines

Seems there are should be additional call to mmc_init():mmc_startup():part_init(), but I'm not sure where/how to add it correctly.

Does this help?

http://patchwork.ozlabs.org/patch/717710/

It seems like issue with "Bad device size..." was fixed by patch "mmc: init mmc block devices on probe" [1].

This patch (my patch) with your patch [2] cause boot hang on am335x-evm when mmc1 (mmc3 in DT) is probed (i've tried to revert [1] - result is the same).

[1] https://patchwork.ozlabs.org/patch/719652/
[2] http://patchwork.ozlabs.org/patch/717710/

Signature · 2 lines
regards,
-grygorii