[U-Boot] [PATCH 00/20] dm: rockchip: Move rockchip boards to to use CONFIG_BLK

This series expands the CONFIG_BLK support to SPL, fixes up the EFI boot code and adds a few other tweaks so that all rockchip boards can move to using driver model for block devices.
It also introduces snprintf() in the tiny-printf code and tidies up the mmc code a little.
Overall the code size for firefly-rk3288 drops by 1KB. This is mostly due to removing GPIO support and cutting down on unnecessary strings. The move to CONFIG_BLK unfortunately adds 0.5KB, or the improvement would be greater.
Simon Glass (20): tiny-printf: Tidy up a few nits tiny-printf: Support snprintf() reset: Drop the reset failure message mmc: Drop mmc_register() mmc: Drop dead mmc code for non-generic MMC mmc: Use byte array for multipliers arm: Avoid error messages in cache_v7 rockchip: Check image name for the rksd image rockchip: Drop unnecessary SPL properties rockchip: video: Flush the cache when the display is updated rockchip: Drop SPL GPIO support for rk3288 dm: env: mmc: Convert env_mmc to support CONFIG_BLK dm: mmc: Convert sdhci to support CONFIG_BLK dm: efi: Update for CONFIG_BLK dm: mmc: spl: Add support for CONFIG_BLK dm: mmc: dwmmc: Support CONFIG_BLK dm: rockchip: mmc: Allow use of CONFIG_BLK dm: mmc: Fix up mmc_bread/bwrite() prototypes for SPL dm: mmc: Use cfg directly in mmc_bind() dm: rockchip: Enable CONFIG_BLK
arch/arm/cpu/armv7/cache_v7.c | 8 +++--- arch/arm/mach-rockchip/Kconfig | 3 ++ cmd/mmc.c | 62 ---------------------------------------- common/env_mmc.c | 8 +++--- common/spl/spl_mmc.c | 9 +++--- configs/firefly-rk3288_defconfig | 2 +- drivers/misc/reset-uclass.c | 2 +- drivers/mmc/dw_mmc.c | 42 ++++++++++++++++++--------- drivers/mmc/mmc.c | 13 ++------- drivers/mmc/mmc_private.h | 14 +++++++++ drivers/mmc/rockchip_dw_mmc.c | 31 ++++++++++++++++++++ drivers/mmc/sdhci.c | 2 +- drivers/video/rockchip/rk_vop.c | 1 + include/configs/rk3288_common.h | 1 - include/dwmmc.h | 7 ++++- include/efi_loader.h | 2 +- include/mmc.h | 5 ---- lib/efi_loader/efi_disk.c | 61 +++++++++++++++++++++++++++++---------- lib/tiny-printf.c | 43 +++++++++++++++++++++------- tools/rkimage.c | 7 +---- 20 files changed, 181 insertions(+), 142 deletions(-)

- Rename 'w' to 'width' to make it more obvious what it is used for - Use bool and int types instead of char to avoid register-masking on 32-bit machines
Signed-off-by: Simon Glass sjg@chromium.org ---
lib/tiny-printf.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-)
diff --git a/lib/tiny-printf.c b/lib/tiny-printf.c index a06abed..fbd5368 100644 --- a/lib/tiny-printf.c +++ b/lib/tiny-printf.c @@ -52,8 +52,8 @@ int vprintf(const char *fmt, va_list va) if (ch != '%') { putc(ch); } else { - char lz = 0; - char w = 0; + bool lz = false; + int width = 0;
ch = *(fmt++); if (ch == '0') { @@ -62,9 +62,9 @@ int vprintf(const char *fmt, va_list va) }
if (ch >= '0' && ch <= '9') { - w = 0; + width = 0; while (ch >= '0' && ch <= '9') { - w = (w * 10) + ch - '0'; + width = (width * 10) + ch - '0'; ch = *fmt++; } } @@ -73,7 +73,7 @@ int vprintf(const char *fmt, va_list va) zs = 0;
switch (ch) { - case 0: + case '\0': goto abort; case 'u': case 'd': @@ -112,9 +112,9 @@ int vprintf(const char *fmt, va_list va)
*bf = 0; bf = p; - while (*bf++ && w > 0) - w--; - while (w-- > 0) + while (*bf++ && width > 0) + width--; + while (width-- > 0) putc(lz ? '0' : ' '); if (p) { while ((ch = *p++))

On 14.05.2016 22:02, Simon Glass wrote:
- Rename 'w' to 'width' to make it more obvious what it is used for
- Use bool and int types instead of char to avoid register-masking on
32-bit machines
Signed-off-by: Simon Glass sjg@chromium.org
Reviewed-by: Stefan Roese sr@denx.de
Thanks, Stefan

On 16 May 2016 at 03:29, Stefan Roese sr@denx.de wrote:
On 14.05.2016 22:02, Simon Glass wrote:
- Rename 'w' to 'width' to make it more obvious what it is used for
- Use bool and int types instead of char to avoid register-masking on
32-bit machines
Signed-off-by: Simon Glass sjg@chromium.org
Reviewed-by: Stefan Roese sr@denx.de
Thanks, Stefan
Applied to u-boot-dm.

Add a simple version of this function for SPL. It does not check the buffer size as this would add to the code size.
Signed-off-by: Simon Glass sjg@chromium.org ---
lib/tiny-printf.c | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-)
diff --git a/lib/tiny-printf.c b/lib/tiny-printf.c index fbd5368..4b70263 100644 --- a/lib/tiny-printf.c +++ b/lib/tiny-printf.c @@ -16,6 +16,9 @@ static char *bf; static char zs;
+/* Current position in sprintf() output string */ +static char *outstr; + static void out(char c) { *bf++ = c; @@ -40,7 +43,7 @@ static void div_out(unsigned int *num, unsigned int div) out_dgt(dgt); }
-int vprintf(const char *fmt, va_list va) +int _vprintf(const char *fmt, va_list va, void (*putc)(const char ch)) { char ch; char *p; @@ -133,8 +136,28 @@ int printf(const char *fmt, ...) int ret;
va_start(va, fmt); - ret = vprintf(fmt, va); + ret = _vprintf(fmt, va, putc); + va_end(va); + + return ret; +} + +static void putc_outstr(char ch) +{ + *outstr++ = ch; +} + +/* Note that size is ignored */ +int snprintf(char *buf, size_t size, const char *fmt, ...) +{ + va_list va; + int ret; + + va_start(va, fmt); + outstr = buf; + ret = _vprintf(fmt, va, putc_outstr); va_end(va); + *outstr = '\0';
return ret; }

On 14.05.2016 22:02, Simon Glass wrote:
Add a simple version of this function for SPL. It does not check the buffer size as this would add to the code size.
Signed-off-by: Simon Glass sjg@chromium.org
Reviewed-by: Stefan Roese sr@denx.de
Thanks, Stefan

On 16 May 2016 at 03:31, Stefan Roese sr@denx.de wrote:
On 14.05.2016 22:02, Simon Glass wrote:
Add a simple version of this function for SPL. It does not check the buffer size as this would add to the code size.
Signed-off-by: Simon Glass sjg@chromium.org
Reviewed-by: Stefan Roese sr@denx.de
Thanks, Stefan
Applied to u-boot-dm.

This adds to code size and is not needed, since hang() will print a message.
Signed-off-by: Simon Glass sjg@chromium.org ---
drivers/misc/reset-uclass.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/misc/reset-uclass.c b/drivers/misc/reset-uclass.c index fdb5c6f..52b9e7e 100644 --- a/drivers/misc/reset-uclass.c +++ b/drivers/misc/reset-uclass.c @@ -55,7 +55,7 @@ void reset_walk_halt(enum reset_t type) mdelay(100);
/* Still no reset? Give up */ - printf("Reset not supported on this platform\n"); + debug("Reset not supported on this platform\n"); hang(); }

On 14 May 2016 at 14:02, Simon Glass sjg@chromium.org wrote:
This adds to code size and is not needed, since hang() will print a message.
Signed-off-by: Simon Glass sjg@chromium.org
drivers/misc/reset-uclass.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Applied to u-boot-dm.

This function is no longer used.
Signed-off-by: Simon Glass sjg@chromium.org ---
drivers/mmc/mmc.c | 9 --------- include/mmc.h | 1 - 2 files changed, 10 deletions(-)
diff --git a/drivers/mmc/mmc.c b/drivers/mmc/mmc.c index 74b3d68..1ddeff4 100644 --- a/drivers/mmc/mmc.c +++ b/drivers/mmc/mmc.c @@ -1531,15 +1531,6 @@ static int mmc_send_if_cond(struct mmc *mmc) return 0; }
-/* not used any more */ -int __deprecated mmc_register(struct mmc *mmc) -{ -#if !defined(CONFIG_SPL_BUILD) || defined(CONFIG_SPL_LIBCOMMON_SUPPORT) - printf("%s is deprecated! use mmc_create() instead.\n", __func__); -#endif - return -1; -} - #ifdef CONFIG_BLK int mmc_bind(struct udevice *dev, struct mmc *mmc, const struct mmc_config *cfg) { diff --git a/include/mmc.h b/include/mmc.h index a5c6573..056296e 100644 --- a/include/mmc.h +++ b/include/mmc.h @@ -411,7 +411,6 @@ enum mmc_hwpart_conf_mode { MMC_HWPART_CONF_COMPLETE, };
-int mmc_register(struct mmc *mmc); struct mmc *mmc_create(const struct mmc_config *cfg, void *priv);
/**

On 14 May 2016 at 14:02, Simon Glass sjg@chromium.org wrote:
This function is no longer used.
Signed-off-by: Simon Glass sjg@chromium.org
drivers/mmc/mmc.c | 9 --------- include/mmc.h | 1 - 2 files changed, 10 deletions(-)
Applied to u-boot-dm.

All boards that use MMC define CONFIG_GENERIC_MMC now, so we can drop this old code.
Signed-off-by: Simon Glass sjg@chromium.org ---
cmd/mmc.c | 62 ----------------------------------------------------------- include/mmc.h | 4 ---- 2 files changed, 66 deletions(-)
diff --git a/cmd/mmc.c b/cmd/mmc.c index eb4a547..b2761e9 100644 --- a/cmd/mmc.c +++ b/cmd/mmc.c @@ -11,66 +11,6 @@ #include <mmc.h>
static int curr_device = -1; -#ifndef CONFIG_GENERIC_MMC -int do_mmc (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) -{ - int dev; - - if (argc < 2) - return CMD_RET_USAGE; - - if (strcmp(argv[1], "init") == 0) { - if (argc == 2) { - if (curr_device < 0) - dev = 1; - else - dev = curr_device; - } else if (argc == 3) { - dev = (int)simple_strtoul(argv[2], NULL, 10); - } else { - return CMD_RET_USAGE; - } - - if (mmc_legacy_init(dev) != 0) { - puts("No MMC card found\n"); - return 1; - } - - curr_device = dev; - printf("mmc%d is available\n", curr_device); - } else if (strcmp(argv[1], "device") == 0) { - if (argc == 2) { - if (curr_device < 0) { - puts("No MMC device available\n"); - return 1; - } - } else if (argc == 3) { - dev = (int)simple_strtoul(argv[2], NULL, 10); - -#ifdef CONFIG_SYS_MMC_SET_DEV - if (mmc_set_dev(dev) != 0) - return 1; -#endif - curr_device = dev; - } else { - return CMD_RET_USAGE; - } - - printf("mmc%d is current device\n", curr_device); - } else { - return CMD_RET_USAGE; - } - - return 0; -} - -U_BOOT_CMD( - mmc, 3, 1, do_mmc, - "MMC sub-system", - "init [dev] - init MMC sub system\n" - "mmc device [dev] - show or set current device" -); -#else /* !CONFIG_GENERIC_MMC */
static void print_mmcinfo(struct mmc *mmc) { @@ -881,5 +821,3 @@ U_BOOT_CMD( "display MMC info", "- display info of the current MMC device" ); - -#endif /* !CONFIG_GENERIC_MMC */ diff --git a/include/mmc.h b/include/mmc.h index 056296e..7fdfc32 100644 --- a/include/mmc.h +++ b/include/mmc.h @@ -491,16 +491,12 @@ int mmc_start_init(struct mmc *mmc); */ void mmc_set_preinit(struct mmc *mmc, int preinit);
-#ifdef CONFIG_GENERIC_MMC #ifdef CONFIG_MMC_SPI #define mmc_host_is_spi(mmc) ((mmc)->cfg->host_caps & MMC_MODE_SPI) #else #define mmc_host_is_spi(mmc) 0 #endif struct mmc *mmc_spi_init(uint bus, uint cs, uint speed, uint mode); -#else -int mmc_legacy_init(int verbose); -#endif
void board_mmc_power_init(void); int board_mmc_init(bd_t *bis);

On 14 May 2016 at 14:02, Simon Glass sjg@chromium.org wrote:
All boards that use MMC define CONFIG_GENERIC_MMC now, so we can drop this old code.
Signed-off-by: Simon Glass sjg@chromium.org
cmd/mmc.c | 62 ----------------------------------------------------------- include/mmc.h | 4 ---- 2 files changed, 66 deletions(-)
Applied to u-boot-dm.

We don't need an int since no value is over 80. This saves a small amount of SPL space (about 44 bytes).
Signed-off-by: Simon Glass sjg@chromium.org ---
drivers/mmc/mmc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/mmc/mmc.c b/drivers/mmc/mmc.c index 1ddeff4..b7c936c 100644 --- a/drivers/mmc/mmc.c +++ b/drivers/mmc/mmc.c @@ -984,7 +984,7 @@ static const int fbase[] = { /* Multiplier values for TRAN_SPEED. Multiplied by 10 to be nice * to platforms without floating point. */ -static const int multipliers[] = { +static const u8 multipliers[] = { 0, /* reserved */ 10, 12,

On 14 May 2016 at 14:02, Simon Glass sjg@chromium.org wrote:
We don't need an int since no value is over 80. This saves a small amount of SPL space (about 44 bytes).
Signed-off-by: Simon Glass sjg@chromium.org
drivers/mmc/mmc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Applied to u-boot-dm.

Move these to debug() like the one in check_cache range(), to save SPL space.
Signed-off-by: Simon Glass sjg@chromium.org ---
arch/arm/cpu/armv7/cache_v7.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/arch/arm/cpu/armv7/cache_v7.c b/arch/arm/cpu/armv7/cache_v7.c index dc309da..68cf62e 100644 --- a/arch/arm/cpu/armv7/cache_v7.c +++ b/arch/arm/cpu/armv7/cache_v7.c @@ -66,8 +66,8 @@ static void v7_dcache_inval_range(u32 start, u32 stop, u32 line_len) * invalidate the first cache-line */ if (start & (line_len - 1)) { - printf("ERROR: %s - start address is not aligned - 0x%08x\n", - __func__, start); + debug("ERROR: %s - start address is not aligned - 0x%08x\n", + __func__, start); /* move to next cache line */ start = (start + line_len - 1) & ~(line_len - 1); } @@ -77,8 +77,8 @@ static void v7_dcache_inval_range(u32 start, u32 stop, u32 line_len) * invalidate the last cache-line */ if (stop & (line_len - 1)) { - printf("ERROR: %s - stop address is not aligned - 0x%08x\n", - __func__, stop); + debug("ERROR: %s - stop address is not aligned - 0x%08x\n", + __func__, stop); /* align to the beginning of this cache line */ stop &= ~(line_len - 1); }

On 05/14/2016 10:02 PM, Simon Glass wrote:
Move these to debug() like the one in check_cache range(), to save SPL space.
This hides cache problems, which were visibly reported so far. I am opposed to this patch.
Wouldn't it make more sense to completely disable printf() and co. in SPL if you're after saving space?
Signed-off-by: Simon Glass sjg@chromium.org
arch/arm/cpu/armv7/cache_v7.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/arch/arm/cpu/armv7/cache_v7.c b/arch/arm/cpu/armv7/cache_v7.c index dc309da..68cf62e 100644 --- a/arch/arm/cpu/armv7/cache_v7.c +++ b/arch/arm/cpu/armv7/cache_v7.c @@ -66,8 +66,8 @@ static void v7_dcache_inval_range(u32 start, u32 stop, u32 line_len) * invalidate the first cache-line */ if (start & (line_len - 1)) {
printf("ERROR: %s - start address is not aligned - 0x%08x\n",
__func__, start);
debug("ERROR: %s - start address is not aligned - 0x%08x\n",
/* move to next cache line */ start = (start + line_len - 1) & ~(line_len - 1); }__func__, start);
@@ -77,8 +77,8 @@ static void v7_dcache_inval_range(u32 start, u32 stop, u32 line_len) * invalidate the last cache-line */ if (stop & (line_len - 1)) {
printf("ERROR: %s - stop address is not aligned - 0x%08x\n",
__func__, stop);
debug("ERROR: %s - stop address is not aligned - 0x%08x\n",
/* align to the beginning of this cache line */ stop &= ~(line_len - 1); }__func__, stop);

Hi Marek,
On 14 May 2016 at 14:23, Marek Vasut marex@denx.de wrote:
On 05/14/2016 10:02 PM, Simon Glass wrote:
Move these to debug() like the one in check_cache range(), to save SPL space.
This hides cache problems, which were visibly reported so far. I am opposed to this patch.
Sure, but see check_cache_range(). It uses debug(). In fact I found the at91 cache problem only after trying #define DEBUG in the code there.
Wouldn't it make more sense to completely disable printf() and co. in SPL if you're after saving space?
Or maybe we need something that prints a message in U-Boot proper, but not SPL? I'll take a look.
Signed-off-by: Simon Glass sjg@chromium.org
arch/arm/cpu/armv7/cache_v7.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/arch/arm/cpu/armv7/cache_v7.c b/arch/arm/cpu/armv7/cache_v7.c index dc309da..68cf62e 100644 --- a/arch/arm/cpu/armv7/cache_v7.c +++ b/arch/arm/cpu/armv7/cache_v7.c @@ -66,8 +66,8 @@ static void v7_dcache_inval_range(u32 start, u32 stop, u32 line_len) * invalidate the first cache-line */ if (start & (line_len - 1)) {
printf("ERROR: %s - start address is not aligned - 0x%08x\n",
__func__, start);
debug("ERROR: %s - start address is not aligned - 0x%08x\n",
__func__, start); /* move to next cache line */ start = (start + line_len - 1) & ~(line_len - 1); }
@@ -77,8 +77,8 @@ static void v7_dcache_inval_range(u32 start, u32 stop, u32 line_len) * invalidate the last cache-line */ if (stop & (line_len - 1)) {
printf("ERROR: %s - stop address is not aligned - 0x%08x\n",
__func__, stop);
debug("ERROR: %s - stop address is not aligned - 0x%08x\n",
__func__, stop); /* align to the beginning of this cache line */ stop &= ~(line_len - 1); }
-- Best regards, Marek Vasut
Regards, Simon

On 05/14/2016 11:22 PM, Simon Glass wrote:
Hi Marek,
Hi!
On 14 May 2016 at 14:23, Marek Vasut marex@denx.de wrote:
On 05/14/2016 10:02 PM, Simon Glass wrote:
Move these to debug() like the one in check_cache range(), to save SPL space.
This hides cache problems, which were visibly reported so far. I am opposed to this patch.
Sure, but see check_cache_range(). It uses debug(). In fact I found the at91 cache problem only after trying #define DEBUG in the code there.
Which is the reason we should really be vocal about such cache misuse. I had a few of such cache problems bite me too, which is why I would like to avoid silencing this warning with debug() by default.
I think check_cache_range() should also be fixed and should use printf() by default.
Wouldn't it make more sense to completely disable printf() and co. in SPL if you're after saving space?
Or maybe we need something that prints a message in U-Boot proper, but not SPL? I'll take a look.
But what if you trigger the issue only in SPL ?
Signed-off-by: Simon Glass sjg@chromium.org
arch/arm/cpu/armv7/cache_v7.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/arch/arm/cpu/armv7/cache_v7.c b/arch/arm/cpu/armv7/cache_v7.c index dc309da..68cf62e 100644 --- a/arch/arm/cpu/armv7/cache_v7.c +++ b/arch/arm/cpu/armv7/cache_v7.c @@ -66,8 +66,8 @@ static void v7_dcache_inval_range(u32 start, u32 stop, u32 line_len) * invalidate the first cache-line */ if (start & (line_len - 1)) {
printf("ERROR: %s - start address is not aligned - 0x%08x\n",
__func__, start);
debug("ERROR: %s - start address is not aligned - 0x%08x\n",
__func__, start); /* move to next cache line */ start = (start + line_len - 1) & ~(line_len - 1); }
@@ -77,8 +77,8 @@ static void v7_dcache_inval_range(u32 start, u32 stop, u32 line_len) * invalidate the last cache-line */ if (stop & (line_len - 1)) {
printf("ERROR: %s - stop address is not aligned - 0x%08x\n",
__func__, stop);
debug("ERROR: %s - stop address is not aligned - 0x%08x\n",
__func__, stop); /* align to the beginning of this cache line */ stop &= ~(line_len - 1); }
-- Best regards, Marek Vasut
Regards, Simon

Hi Marek,
On 14 May 2016 at 15:41, Marek Vasut marex@denx.de wrote:
On 05/14/2016 11:22 PM, Simon Glass wrote:
Hi Marek,
Hi!
On 14 May 2016 at 14:23, Marek Vasut marex@denx.de wrote:
On 05/14/2016 10:02 PM, Simon Glass wrote:
Move these to debug() like the one in check_cache range(), to save SPL space.
This hides cache problems, which were visibly reported so far. I am opposed to this patch.
Sure, but see check_cache_range(). It uses debug(). In fact I found the at91 cache problem only after trying #define DEBUG in the code there.
Which is the reason we should really be vocal about such cache misuse. I had a few of such cache problems bite me too, which is why I would like to avoid silencing this warning with debug() by default.
I think check_cache_range() should also be fixed and should use printf() by default.
Wouldn't it make more sense to completely disable printf() and co. in SPL if you're after saving space?
Or maybe we need something that prints a message in U-Boot proper, but not SPL? I'll take a look.
But what if you trigger the issue only in SPL ?
Yes, but is that likely? So far I don't think the cache is enabled in SPL...
Signed-off-by: Simon Glass sjg@chromium.org
arch/arm/cpu/armv7/cache_v7.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/arch/arm/cpu/armv7/cache_v7.c b/arch/arm/cpu/armv7/cache_v7.c index dc309da..68cf62e 100644 --- a/arch/arm/cpu/armv7/cache_v7.c +++ b/arch/arm/cpu/armv7/cache_v7.c @@ -66,8 +66,8 @@ static void v7_dcache_inval_range(u32 start, u32 stop, u32 line_len) * invalidate the first cache-line */ if (start & (line_len - 1)) {
printf("ERROR: %s - start address is not aligned - 0x%08x\n",
__func__, start);
debug("ERROR: %s - start address is not aligned - 0x%08x\n",
__func__, start); /* move to next cache line */ start = (start + line_len - 1) & ~(line_len - 1); }
@@ -77,8 +77,8 @@ static void v7_dcache_inval_range(u32 start, u32 stop, u32 line_len) * invalidate the last cache-line */ if (stop & (line_len - 1)) {
printf("ERROR: %s - stop address is not aligned - 0x%08x\n",
__func__, stop);
debug("ERROR: %s - stop address is not aligned - 0x%08x\n",
__func__, stop); /* align to the beginning of this cache line */ stop &= ~(line_len - 1); }
Regards, Simon

On 05/19/2016 06:02 AM, Simon Glass wrote:
Hi Marek,
On 14 May 2016 at 15:41, Marek Vasut marex@denx.de wrote:
On 05/14/2016 11:22 PM, Simon Glass wrote:
Hi Marek,
Hi!
On 14 May 2016 at 14:23, Marek Vasut marex@denx.de wrote:
On 05/14/2016 10:02 PM, Simon Glass wrote:
Move these to debug() like the one in check_cache range(), to save SPL space.
This hides cache problems, which were visibly reported so far. I am opposed to this patch.
Sure, but see check_cache_range(). It uses debug(). In fact I found the at91 cache problem only after trying #define DEBUG in the code there.
Which is the reason we should really be vocal about such cache misuse. I had a few of such cache problems bite me too, which is why I would like to avoid silencing this warning with debug() by default.
I think check_cache_range() should also be fixed and should use printf() by default.
Wouldn't it make more sense to completely disable printf() and co. in SPL if you're after saving space?
Or maybe we need something that prints a message in U-Boot proper, but not SPL? I'll take a look.
But what if you trigger the issue only in SPL ?
Yes, but is that likely? So far I don't think the cache is enabled in SPL...
Yeah, it's probably unlikely.
btw have you tried patching away all console IO support in SPL? Does it save space?
Signed-off-by: Simon Glass sjg@chromium.org
arch/arm/cpu/armv7/cache_v7.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/arch/arm/cpu/armv7/cache_v7.c b/arch/arm/cpu/armv7/cache_v7.c index dc309da..68cf62e 100644 --- a/arch/arm/cpu/armv7/cache_v7.c +++ b/arch/arm/cpu/armv7/cache_v7.c @@ -66,8 +66,8 @@ static void v7_dcache_inval_range(u32 start, u32 stop, u32 line_len) * invalidate the first cache-line */ if (start & (line_len - 1)) {
printf("ERROR: %s - start address is not aligned - 0x%08x\n",
__func__, start);
debug("ERROR: %s - start address is not aligned - 0x%08x\n",
__func__, start); /* move to next cache line */ start = (start + line_len - 1) & ~(line_len - 1); }
@@ -77,8 +77,8 @@ static void v7_dcache_inval_range(u32 start, u32 stop, u32 line_len) * invalidate the last cache-line */ if (stop & (line_len - 1)) {
printf("ERROR: %s - stop address is not aligned - 0x%08x\n",
__func__, stop);
debug("ERROR: %s - stop address is not aligned - 0x%08x\n",
__func__, stop); /* align to the beginning of this cache line */ stop &= ~(line_len - 1); }
Regards, Simon

Hi Marek,
On 19 May 2016 at 08:22, Marek Vasut marex@denx.de wrote:
On 05/19/2016 06:02 AM, Simon Glass wrote:
Hi Marek,
On 14 May 2016 at 15:41, Marek Vasut marex@denx.de wrote:
On 05/14/2016 11:22 PM, Simon Glass wrote:
Hi Marek,
Hi!
On 14 May 2016 at 14:23, Marek Vasut marex@denx.de wrote:
On 05/14/2016 10:02 PM, Simon Glass wrote:
Move these to debug() like the one in check_cache range(), to save SPL space.
This hides cache problems, which were visibly reported so far. I am opposed to this patch.
Sure, but see check_cache_range(). It uses debug(). In fact I found the at91 cache problem only after trying #define DEBUG in the code there.
Which is the reason we should really be vocal about such cache misuse. I had a few of such cache problems bite me too, which is why I would like to avoid silencing this warning with debug() by default.
I think check_cache_range() should also be fixed and should use printf() by default.
Wouldn't it make more sense to completely disable printf() and co. in SPL if you're after saving space?
Or maybe we need something that prints a message in U-Boot proper, but not SPL? I'll take a look.
But what if you trigger the issue only in SPL ?
Yes, but is that likely? So far I don't think the cache is enabled in SPL...
Yeah, it's probably unlikely.
btw have you tried patching away all console IO support in SPL? Does it save space?
No I have not. I imagine it would, though. There is also the option now of using the debug UART, which avoids the small amount of serial/console overhead.
[snip]
Regards, Simon

We need a correct name (rk3288, rk3036) so check this to avoid a crash later.
Signed-off-by: Simon Glass sjg@chromium.org ---
tools/rkimage.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-)
diff --git a/tools/rkimage.c b/tools/rkimage.c index f9fdcfa..ef31cb6 100644 --- a/tools/rkimage.c +++ b/tools/rkimage.c @@ -13,11 +13,6 @@
static uint32_t header;
-static int rkimage_check_params(struct image_tool_params *params) -{ - return 0; -} - static int rkimage_verify_header(unsigned char *buf, int size, struct image_tool_params *params) { @@ -56,7 +51,7 @@ U_BOOT_IMAGE_TYPE( "Rockchip Boot Image support", 4, &header, - rkimage_check_params, + rkcommon_check_params, rkimage_verify_header, rkimage_print_header, rkimage_set_header,

On 14 May 2016 at 14:02, Simon Glass sjg@chromium.org wrote:
We need a correct name (rk3288, rk3036) so check this to avoid a crash later.
Signed-off-by: Simon Glass sjg@chromium.org
tools/rkimage.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-)
Applied to u-boot-dm.

While we consider whether to drop use of DT in SPL, remove some unwanted properties. This reduces SPL size by about 250 bytes.
Signed-off-by: Simon Glass sjg@chromium.org ---
configs/firefly-rk3288_defconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/configs/firefly-rk3288_defconfig b/configs/firefly-rk3288_defconfig index 0995f9b..0d566c7 100644 --- a/configs/firefly-rk3288_defconfig +++ b/configs/firefly-rk3288_defconfig @@ -28,7 +28,7 @@ CONFIG_CMD_EXT4=y CONFIG_CMD_FAT=y CONFIG_CMD_FS_GENERIC=y CONFIG_SPL_OF_CONTROL=y -CONFIG_OF_SPL_REMOVE_PROPS="pinctrl-0 pinctrl-names clock-names interrupt-parent" +CONFIG_OF_SPL_REMOVE_PROPS="pinctrl-0 pinctrl-names clock-names interrupt-parent assigned-clocks assigned-clock-rates assigned-clock-parents" CONFIG_REGMAP=y CONFIG_SPL_REGMAP=y CONFIG_SYSCON=y

On 14 May 2016 at 14:03, Simon Glass sjg@chromium.org wrote:
While we consider whether to drop use of DT in SPL, remove some unwanted properties. This reduces SPL size by about 250 bytes.
Signed-off-by: Simon Glass sjg@chromium.org
configs/firefly-rk3288_defconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Applied to u-boot-dm.

Enable this option to correct display artifacts when a write-back cache is in use.
Signed-off-by: Simon Glass sjg@chromium.org ---
drivers/video/rockchip/rk_vop.c | 1 + 1 file changed, 1 insertion(+)
diff --git a/drivers/video/rockchip/rk_vop.c b/drivers/video/rockchip/rk_vop.c index a54af17..db09d9a 100644 --- a/drivers/video/rockchip/rk_vop.c +++ b/drivers/video/rockchip/rk_vop.c @@ -326,6 +326,7 @@ static int rk_vop_probe(struct udevice *dev) if (!ret) break; } + video_set_flush_dcache(dev, 1);
return ret; }

On 14 May 2016 at 14:03, Simon Glass sjg@chromium.org wrote:
Enable this option to correct display artifacts when a write-back cache is in use.
Signed-off-by: Simon Glass sjg@chromium.org
drivers/video/rockchip/rk_vop.c | 1 + 1 file changed, 1 insertion(+)
Applied to u-boot-dm.

This is not currently used and saves a little over 1KB of SPL image size.
Signed-off-by: Simon Glass sjg@chromium.org ---
include/configs/rk3288_common.h | 1 - 1 file changed, 1 deletion(-)
diff --git a/include/configs/rk3288_common.h b/include/configs/rk3288_common.h index 8a81397..9d50d83 100644 --- a/include/configs/rk3288_common.h +++ b/include/configs/rk3288_common.h @@ -69,7 +69,6 @@ #define CONFIG_SPL_FS_LOAD_PAYLOAD_NAME "u-boot.img"
#define CONFIG_SPL_PINCTRL_SUPPORT -#define CONFIG_SPL_GPIO_SUPPORT #define CONFIG_SPL_RAM_SUPPORT #define CONFIG_SPL_DRIVERS_MISC_SUPPORT

On 14 May 2016 at 14:03, Simon Glass sjg@chromium.org wrote:
This is not currently used and saves a little over 1KB of SPL image size.
Signed-off-by: Simon Glass sjg@chromium.org
include/configs/rk3288_common.h | 1 - 1 file changed, 1 deletion(-)
Applied to u-boot-dm.

Update the MMC environment code so that it works with driver-model enabled for block devices.
Signed-off-by: Simon Glass sjg@chromium.org ---
common/env_mmc.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/common/env_mmc.c b/common/env_mmc.c index c7fef18..16f6a17 100644 --- a/common/env_mmc.c +++ b/common/env_mmc.c @@ -128,12 +128,12 @@ static inline int write_env(struct mmc *mmc, unsigned long size, unsigned long offset, const void *buffer) { uint blk_start, blk_cnt, n; + struct blk_desc *desc = mmc_get_blk_desc(mmc);
blk_start = ALIGN(offset, mmc->write_bl_len) / mmc->write_bl_len; blk_cnt = ALIGN(size, mmc->write_bl_len) / mmc->write_bl_len;
- n = mmc->block_dev.block_write(&mmc->block_dev, blk_start, - blk_cnt, (u_char *)buffer); + n = blk_dwrite(desc, blk_start, blk_cnt, (u_char *)buffer);
return (n == blk_cnt) ? 0 : -1; } @@ -197,12 +197,12 @@ static inline int read_env(struct mmc *mmc, unsigned long size, unsigned long offset, const void *buffer) { uint blk_start, blk_cnt, n; + struct blk_desc *desc = mmc_get_blk_desc(mmc);
blk_start = ALIGN(offset, mmc->read_bl_len) / mmc->read_bl_len; blk_cnt = ALIGN(size, mmc->read_bl_len) / mmc->read_bl_len;
- n = mmc->block_dev.block_read(&mmc->block_dev, blk_start, blk_cnt, - (uchar *)buffer); + n = blk_dread(desc, blk_start, blk_cnt, (uchar *)buffer);
return (n == blk_cnt) ? 0 : -1; }

On 14 May 2016 at 14:03, Simon Glass sjg@chromium.org wrote:
Update the MMC environment code so that it works with driver-model enabled for block devices.
Signed-off-by: Simon Glass sjg@chromium.org
common/env_mmc.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
Applied to u-boot-dm.

Update sdhci.c so that it works with driver model enabled for block devices.
Signed-off-by: Simon Glass sjg@chromium.org ---
drivers/mmc/sdhci.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/mmc/sdhci.c b/drivers/mmc/sdhci.c index ef7e615..5c71ab8 100644 --- a/drivers/mmc/sdhci.c +++ b/drivers/mmc/sdhci.c @@ -137,7 +137,7 @@ static int sdhci_send_command(struct mmc *mmc, struct mmc_cmd *cmd, int trans_bytes = 0, is_aligned = 1; u32 mask, flags, mode; unsigned int time = 0, start_addr = 0; - int mmc_dev = mmc->block_dev.devnum; + int mmc_dev = mmc_get_blk_desc(mmc)->devnum; unsigned start = get_timer(0);
/* Timeout unit - ms */

On 14 May 2016 at 14:03, Simon Glass sjg@chromium.org wrote:
Update sdhci.c so that it works with driver model enabled for block devices.
Signed-off-by: Simon Glass sjg@chromium.org
drivers/mmc/sdhci.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Applied to u-boot-dm.

This code does not currently build with driver model enabled for block devices. Update it to correct this.
Signed-off-by: Simon Glass sjg@chromium.org ---
include/efi_loader.h | 2 +- lib/efi_loader/efi_disk.c | 61 +++++++++++++++++++++++++++++++++++------------ 2 files changed, 47 insertions(+), 16 deletions(-)
diff --git a/include/efi_loader.h b/include/efi_loader.h index 88b8149..44a950f 100644 --- a/include/efi_loader.h +++ b/include/efi_loader.h @@ -134,7 +134,7 @@ uint64_t efi_add_memory_map(uint64_t start, uint64_t pages, int memory_type, int efi_memory_init(void);
/* Convert strings from normal C strings to uEFI strings */ -static inline void ascii2unicode(u16 *unicode, char *ascii) +static inline void ascii2unicode(u16 *unicode, const char *ascii) { while (*ascii) *(unicode++) = *(ascii++); diff --git a/lib/efi_loader/efi_disk.c b/lib/efi_loader/efi_disk.c index 075fd34..3095bcf 100644 --- a/lib/efi_loader/efi_disk.c +++ b/lib/efi_loader/efi_disk.c @@ -8,6 +8,7 @@
#include <common.h> #include <blk.h> +#include <dm.h> #include <efi_loader.h> #include <inttypes.h> #include <part.h> @@ -96,9 +97,9 @@ static efi_status_t EFIAPI efi_disk_rw_blocks(struct efi_block_io *this, return EFI_EXIT(EFI_DEVICE_ERROR);
if (direction == EFI_DISK_READ) - n = desc->block_read(desc, lba, blocks, buffer); + n = blk_dread(desc, lba, blocks, buffer); else - n = desc->block_write(desc, lba, blocks, buffer); + n = blk_dwrite(desc, lba, blocks, buffer);
/* We don't do interrupts, so check for timers cooperatively */ efi_timer_check(); @@ -142,8 +143,8 @@ static const struct efi_block_io block_io_disk_template = { .flush_blocks = &efi_disk_flush_blocks, };
-static void efi_disk_add_dev(char *name, - const struct blk_driver *cur_drvr, +static void efi_disk_add_dev(const char *name, + const char *if_typename, const struct blk_desc *desc, int dev_index, lbaint_t offset) @@ -161,7 +162,7 @@ static void efi_disk_add_dev(char *name, diskobj->parent.protocols[1].open = efi_disk_open_dp; diskobj->parent.handle = diskobj; diskobj->ops = block_io_disk_template; - diskobj->ifname = cur_drvr->if_typename; + diskobj->ifname = if_typename; diskobj->dev_index = dev_index; diskobj->offset = offset;
@@ -190,7 +191,7 @@ static void efi_disk_add_dev(char *name, }
static int efi_disk_create_eltorito(struct blk_desc *desc, - const struct blk_driver *cur_drvr, + const char *if_typename, int diskid) { int disks = 0; @@ -203,9 +204,10 @@ static int efi_disk_create_eltorito(struct blk_desc *desc, return 0;
while (!part_get_info(desc, part, &info)) { - snprintf(devname, sizeof(devname), "%s%d:%d", - cur_drvr->if_typename, diskid, part); - efi_disk_add_dev(devname, cur_drvr, desc, diskid, info.start); + snprintf(devname, sizeof(devname), "%s%d:%d", if_typename, + diskid, part); + efi_disk_add_dev(devname, if_typename, desc, diskid, + info.start); part++; disks++; } @@ -219,21 +221,49 @@ static int efi_disk_create_eltorito(struct blk_desc *desc, * EFI payload, we scan through all of the potentially available ones and * store them in our object pool. * + * TODO(sjg@chromium.org): Actually with CONFIG_BLK, U-Boot does have this. + * Consider converting the code to look up devices as needed. The EFI device + * could be a child of the UCLASS_BLK block device, perhaps. + * * This gets called from do_bootefi_exec(). */ int efi_disk_register(void) { - const struct blk_driver *cur_drvr; - int i, if_type; int disks = 0; +#ifdef CONFIG_BLK + struct udevice *dev; + + for (uclass_first_device(UCLASS_BLK, &dev); + dev; + uclass_next_device(&dev)) { + struct blk_desc *desc = dev_get_uclass_platdata(dev); + const char *if_typename = dev->driver->name; + + printf("Scanning disk %s...\n", dev->name); + efi_disk_add_dev(dev->name, if_typename, desc, desc->devnum, 0); + disks++; + + /* + * El Torito images show up as block devices in an EFI world, + * so let's create them here + */ + disks += efi_disk_create_eltorito(desc, if_typename, + desc->devnum); + } +#else + int i, if_type;
/* Search for all available disk devices */ for (if_type = 0; if_type < IF_TYPE_COUNT; if_type++) { + const struct blk_driver *cur_drvr; + const char *if_typename; + cur_drvr = blk_driver_lookup_type(if_type); if (!cur_drvr) continue;
- printf("Scanning disks on %s...\n", cur_drvr->if_typename); + if_typename = cur_drvr->if_typename; + printf("Scanning disks on %s...\n", if_typename); for (i = 0; i < 4; i++) { struct blk_desc *desc; char devname[32] = { 0 }; /* dp->str is u16[32] long */ @@ -245,17 +275,18 @@ int efi_disk_register(void) continue;
snprintf(devname, sizeof(devname), "%s%d", - cur_drvr->if_typename, i); - efi_disk_add_dev(devname, cur_drvr, desc, i, 0); + if_typename, i); + efi_disk_add_dev(devname, if_typename, desc, i, 0); disks++;
/* * El Torito images show up as block devices * in an EFI world, so let's create them here */ - disks += efi_disk_create_eltorito(desc, cur_drvr, i); + disks += efi_disk_create_eltorito(desc, if_typename, i); } } +#endif printf("Found %d disks\n", disks);
return 0;

On 14.05.16 22:03, Simon Glass wrote:
This code does not currently build with driver model enabled for block devices. Update it to correct this.
Signed-off-by: Simon Glass sjg@chromium.org
Reviewed-by: Alexander Graf agraf@suse.de
Alex

On 15 May 2016 at 02:21, Alexander Graf agraf@suse.de wrote:
On 14.05.16 22:03, Simon Glass wrote:
This code does not currently build with driver model enabled for block devices. Update it to correct this.
Signed-off-by: Simon Glass sjg@chromium.org
Reviewed-by: Alexander Graf agraf@suse.de
Alex
Applied to u-boot-dm.

Allow driver model to be used for block devices in SPL.
Signed-off-by: Simon Glass sjg@chromium.org ---
common/spl/spl_mmc.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-)
diff --git a/common/spl/spl_mmc.c b/common/spl/spl_mmc.c index cf527da..5d0c9f9 100644 --- a/common/spl/spl_mmc.c +++ b/common/spl/spl_mmc.c @@ -30,9 +30,8 @@ static int mmc_load_legacy(struct mmc *mmc, ulong sector, mmc->read_bl_len;
/* Read the header too to avoid extra memcpy */ - count = mmc->block_dev.block_read(&mmc->block_dev, sector, - image_size_sectors, - (void *)(ulong)spl_image.load_addr); + count = blk_dread(mmc_get_blk_desc(mmc), sector, image_size_sectors, + (void *)(ulong)spl_image.load_addr); debug("read %x sectors to %x\n", image_size_sectors, spl_image.load_addr); if (count != image_size_sectors) @@ -46,7 +45,7 @@ static ulong h_spl_load_read(struct spl_load_info *load, ulong sector, { struct mmc *mmc = load->dev;
- return mmc->block_dev.block_read(&mmc->block_dev, sector, count, buf); + return blk_dread(mmc_get_blk_desc(mmc), sector, count, buf); }
static int mmc_load_image_raw_sector(struct mmc *mmc, unsigned long sector) @@ -59,7 +58,7 @@ static int mmc_load_image_raw_sector(struct mmc *mmc, unsigned long sector) sizeof(struct image_header));
/* read image header to find the image size & load address */ - count = mmc->block_dev.block_read(&mmc->block_dev, sector, 1, header); + count = blk_dread(mmc_get_blk_desc(mmc), sector, 1, header); debug("hdr read sector %lx, count=%lu\n", sector, count); if (count == 0) { ret = -EIO;

On 14 May 2016 at 14:03, Simon Glass sjg@chromium.org wrote:
Allow driver model to be used for block devices in SPL.
Signed-off-by: Simon Glass sjg@chromium.org
common/spl/spl_mmc.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-)
Applied to u-boot-dm.

Add support for using driver model for block devices in this driver.
Signed-off-by: Simon Glass sjg@chromium.org ---
drivers/mmc/dw_mmc.c | 42 ++++++++++++++++++++++++++++-------------- include/dwmmc.h | 7 ++++++- 2 files changed, 34 insertions(+), 15 deletions(-)
diff --git a/drivers/mmc/dw_mmc.c b/drivers/mmc/dw_mmc.c index 7329f40..74a2663 100644 --- a/drivers/mmc/dw_mmc.c +++ b/drivers/mmc/dw_mmc.c @@ -454,27 +454,40 @@ static const struct mmc_ops dwmci_ops = { .init = dwmci_init, };
-int add_dwmci(struct dwmci_host *host, u32 max_clk, u32 min_clk) +void dwmci_setup_cfg(struct mmc_config *cfg, const char *name, int buswidth, + uint caps, u32 max_clk, u32 min_clk) { - host->cfg.name = host->name; - host->cfg.ops = &dwmci_ops; - host->cfg.f_min = min_clk; - host->cfg.f_max = max_clk; + cfg->name = name; + cfg->ops = &dwmci_ops; + cfg->f_min = min_clk; + cfg->f_max = max_clk;
- host->cfg.voltages = MMC_VDD_32_33 | MMC_VDD_33_34 | MMC_VDD_165_195; + cfg->voltages = MMC_VDD_32_33 | MMC_VDD_33_34 | MMC_VDD_165_195;
- host->cfg.host_caps = host->caps; + cfg->host_caps = caps;
- if (host->buswidth == 8) { - host->cfg.host_caps |= MMC_MODE_8BIT; - host->cfg.host_caps &= ~MMC_MODE_4BIT; + if (buswidth == 8) { + cfg->host_caps |= MMC_MODE_8BIT; + cfg->host_caps &= ~MMC_MODE_4BIT; } else { - host->cfg.host_caps |= MMC_MODE_4BIT; - host->cfg.host_caps &= ~MMC_MODE_8BIT; + cfg->host_caps |= MMC_MODE_4BIT; + cfg->host_caps &= ~MMC_MODE_8BIT; } - host->cfg.host_caps |= MMC_MODE_HS | MMC_MODE_HS_52MHz; + cfg->host_caps |= MMC_MODE_HS | MMC_MODE_HS_52MHz; + + cfg->b_max = CONFIG_SYS_MMC_MAX_BLK_COUNT; +}
- host->cfg.b_max = CONFIG_SYS_MMC_MAX_BLK_COUNT; +#ifdef CONFIG_BLK +int dwmci_bind(struct udevice *dev, struct mmc *mmc, struct mmc_config *cfg) +{ + return mmc_bind(dev, mmc, cfg); +} +#else +int add_dwmci(struct dwmci_host *host, u32 max_clk, u32 min_clk) +{ + dwmci_setup_cfg(&host->cfg, host->name, host->buswidth, host->caps, + max_clk, min_clk);
host->mmc = mmc_create(&host->cfg, host); if (host->mmc == NULL) @@ -482,3 +495,4 @@ int add_dwmci(struct dwmci_host *host, u32 max_clk, u32 min_clk)
return 0; } +#endif diff --git a/include/dwmmc.h b/include/dwmmc.h index 05b0817..335af51 100644 --- a/include/dwmmc.h +++ b/include/dwmmc.h @@ -180,8 +180,9 @@ struct dwmci_host { * @freq: Frequency the host is trying to achieve */ unsigned int (*get_mmc_clk)(struct dwmci_host *host, uint freq); - +#ifndef CONFIG_BLK struct mmc_config cfg; +#endif
/* use fifo mode to read and write data */ bool fifo_mode; @@ -223,5 +224,9 @@ static inline u8 dwmci_readb(struct dwmci_host *host, int reg) return readb(host->ioaddr + reg); }
+void dwmci_setup_cfg(struct mmc_config *cfg, const char *name, int buswidth, + uint caps, u32 max_clk, u32 min_clk); +int dwmci_bind(struct udevice *dev, struct mmc *mmc, struct mmc_config *cfg); + int add_dwmci(struct dwmci_host *host, u32 max_clk, u32 min_clk); #endif /* __DWMMC_HW_H */

On 14 May 2016 at 14:03, Simon Glass sjg@chromium.org wrote:
Add support for using driver model for block devices in this driver.
Signed-off-by: Simon Glass sjg@chromium.org
drivers/mmc/dw_mmc.c | 42 ++++++++++++++++++++++++++++-------------- include/dwmmc.h | 7 ++++++- 2 files changed, 34 insertions(+), 15 deletions(-)
Applied to u-boot-dm.

Allow driver model to be used for block devices in the rockchip mmc driver.
Signed-off-by: Simon Glass sjg@chromium.org ---
drivers/mmc/rockchip_dw_mmc.c | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+)
diff --git a/drivers/mmc/rockchip_dw_mmc.c b/drivers/mmc/rockchip_dw_mmc.c index 0a261c5..750ab9f 100644 --- a/drivers/mmc/rockchip_dw_mmc.c +++ b/drivers/mmc/rockchip_dw_mmc.c @@ -18,6 +18,11 @@
DECLARE_GLOBAL_DATA_PTR;
+struct rockchip_mmc_plat { + struct mmc_config cfg; + struct mmc mmc; +}; + struct rockchip_dwmmc_priv { struct udevice *clk; int periph; @@ -62,6 +67,9 @@ static int rockchip_dwmmc_ofdata_to_platdata(struct udevice *dev)
static int rockchip_dwmmc_probe(struct udevice *dev) { +#ifdef CONFIG_BLK + struct rockchip_mmc_plat *plat = dev_get_platdata(dev); +#endif struct mmc_uclass_priv *upriv = dev_get_uclass_priv(dev); struct rockchip_dwmmc_priv *priv = dev_get_priv(dev); struct dwmci_host *host = &priv->host; @@ -100,16 +108,37 @@ static int rockchip_dwmmc_probe(struct udevice *dev) return ret; } #endif +#ifdef CONFIG_BLK + dwmci_setup_cfg(&plat->cfg, dev->name, host->buswidth, host->caps, + minmax[1], minmax[0]); + host->mmc = &plat->mmc; +#else ret = add_dwmci(host, minmax[1], minmax[0]); if (ret) return ret;
+#endif + host->mmc->priv = &priv->host; host->mmc->dev = dev; upriv->mmc = host->mmc;
return 0; }
+static int rockchip_dwmmc_bind(struct udevice *dev) +{ +#ifdef CONFIG_BLK + struct rockchip_mmc_plat *plat = dev_get_platdata(dev); + int ret; + + ret = dwmci_bind(dev, &plat->mmc, &plat->cfg); + if (ret) + return ret; +#endif + + return 0; +} + static const struct udevice_id rockchip_dwmmc_ids[] = { { .compatible = "rockchip,rk3288-dw-mshc" }, { } @@ -120,8 +149,10 @@ U_BOOT_DRIVER(rockchip_dwmmc_drv) = { .id = UCLASS_MMC, .of_match = rockchip_dwmmc_ids, .ofdata_to_platdata = rockchip_dwmmc_ofdata_to_platdata, + .bind = rockchip_dwmmc_bind, .probe = rockchip_dwmmc_probe, .priv_auto_alloc_size = sizeof(struct rockchip_dwmmc_priv), + .platdata_auto_alloc_size = sizeof(struct rockchip_mmc_plat), };
#ifdef CONFIG_PWRSEQ

On 14 May 2016 at 14:03, Simon Glass sjg@chromium.org wrote:
Allow driver model to be used for block devices in the rockchip mmc driver.
Signed-off-by: Simon Glass sjg@chromium.org
drivers/mmc/rockchip_dw_mmc.c | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+)
Applied to u-boot-dm.

When these functions are not compiled in, we still need to declare the correct function signature to avoid a build warnings in SPL. Fix this.
Signed-off-by: Simon Glass sjg@chromium.org ---
drivers/mmc/mmc_private.h | 14 ++++++++++++++ 1 file changed, 14 insertions(+)
diff --git a/drivers/mmc/mmc_private.h b/drivers/mmc/mmc_private.h index 27b9e5f..9f0d5c2 100644 --- a/drivers/mmc/mmc_private.h +++ b/drivers/mmc/mmc_private.h @@ -37,6 +37,19 @@ ulong mmc_bwrite(struct blk_desc *block_dev, lbaint_t start, lbaint_t blkcnt,
/* SPL will never write or erase, declare dummies to reduce code size. */
+#ifdef CONFIG_BLK +static inline unsigned long mmc_berase(struct udevice *dev, + lbaint_t start, lbaint_t blkcnt) +{ + return 0; +} + +static inline ulong mmc_bwrite(struct udevice *dev, lbaint_t start, + lbaint_t blkcnt, const void *src) +{ + return 0; +} +#else static inline unsigned long mmc_berase(struct blk_desc *block_dev, lbaint_t start, lbaint_t blkcnt) { @@ -48,6 +61,7 @@ static inline ulong mmc_bwrite(struct blk_desc *block_dev, lbaint_t start, { return 0; } +#endif
#endif /* CONFIG_SPL_BUILD */

On 14 May 2016 at 14:03, Simon Glass sjg@chromium.org wrote:
When these functions are not compiled in, we still need to declare the correct function signature to avoid a build warnings in SPL. Fix this.
Signed-off-by: Simon Glass sjg@chromium.org
drivers/mmc/mmc_private.h | 14 ++++++++++++++ 1 file changed, 14 insertions(+)
Applied to u-boot-dm.

This small change tidies up the code slightly.
Signed-off-by: Simon Glass sjg@chromium.org ---
drivers/mmc/mmc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/mmc/mmc.c b/drivers/mmc/mmc.c index b7c936c..94f19ad 100644 --- a/drivers/mmc/mmc.c +++ b/drivers/mmc/mmc.c @@ -1557,7 +1557,7 @@ int mmc_bind(struct udevice *dev, struct mmc *mmc, const struct mmc_config *cfg) bdesc->removable = 1;
/* setup initial part type */ - bdesc->part_type = mmc->cfg->part_type; + bdesc->part_type = cfg->part_type; mmc->dev = dev;
return 0;

On 14 May 2016 at 14:03, Simon Glass sjg@chromium.org wrote:
This small change tidies up the code slightly.
Signed-off-by: Simon Glass sjg@chromium.org
drivers/mmc/mmc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Applied to u-boot-dm.

Enable CONFIG_BLK to move to using driver model for block devices. This affects MMC booting in SPL, as well as MMC access in U-Boot proper.
Signed-off-by: Simon Glass sjg@chromium.org ---
arch/arm/mach-rockchip/Kconfig | 3 +++ 1 file changed, 3 insertions(+)
diff --git a/arch/arm/mach-rockchip/Kconfig b/arch/arm/mach-rockchip/Kconfig index d3bddb7..2a8afac 100644 --- a/arch/arm/mach-rockchip/Kconfig +++ b/arch/arm/mach-rockchip/Kconfig @@ -41,6 +41,9 @@ config DM_I2C config DM_GPIO default y
+config BLK + default y + source "arch/arm/mach-rockchip/rk3288/Kconfig" source "arch/arm/mach-rockchip/rk3036/Kconfig" endif

On 14 May 2016 at 14:03, Simon Glass sjg@chromium.org wrote:
Enable CONFIG_BLK to move to using driver model for block devices. This affects MMC booting in SPL, as well as MMC access in U-Boot proper.
Signed-off-by: Simon Glass sjg@chromium.org
arch/arm/mach-rockchip/Kconfig | 3 +++ 1 file changed, 3 insertions(+)
Applied to u-boot-dm.

Hi,
On 14 May 2016 at 14:02, Simon Glass sjg@chromium.org wrote:
This series expands the CONFIG_BLK support to SPL, fixes up the EFI boot code and adds a few other tweaks so that all rockchip boards can move to using driver model for block devices.
It also introduces snprintf() in the tiny-printf code and tidies up the mmc code a little.
Overall the code size for firefly-rk3288 drops by 1KB. This is mostly due to removing GPIO support and cutting down on unnecessary strings. The move to CONFIG_BLK unfortunately adds 0.5KB, or the improvement would be greater.
Simon Glass (20): tiny-printf: Tidy up a few nits tiny-printf: Support snprintf() reset: Drop the reset failure message mmc: Drop mmc_register() mmc: Drop dead mmc code for non-generic MMC mmc: Use byte array for multipliers arm: Avoid error messages in cache_v7 rockchip: Check image name for the rksd image rockchip: Drop unnecessary SPL properties rockchip: video: Flush the cache when the display is updated rockchip: Drop SPL GPIO support for rk3288 dm: env: mmc: Convert env_mmc to support CONFIG_BLK dm: mmc: Convert sdhci to support CONFIG_BLK dm: efi: Update for CONFIG_BLK dm: mmc: spl: Add support for CONFIG_BLK dm: mmc: dwmmc: Support CONFIG_BLK dm: rockchip: mmc: Allow use of CONFIG_BLK dm: mmc: Fix up mmc_bread/bwrite() prototypes for SPL dm: mmc: Use cfg directly in mmc_bind() dm: rockchip: Enable CONFIG_BLK
arch/arm/cpu/armv7/cache_v7.c | 8 +++--- arch/arm/mach-rockchip/Kconfig | 3 ++ cmd/mmc.c | 62 ---------------------------------------- common/env_mmc.c | 8 +++--- common/spl/spl_mmc.c | 9 +++--- configs/firefly-rk3288_defconfig | 2 +- drivers/misc/reset-uclass.c | 2 +- drivers/mmc/dw_mmc.c | 42 ++++++++++++++++++--------- drivers/mmc/mmc.c | 13 ++------- drivers/mmc/mmc_private.h | 14 +++++++++ drivers/mmc/rockchip_dw_mmc.c | 31 ++++++++++++++++++++ drivers/mmc/sdhci.c | 2 +- drivers/video/rockchip/rk_vop.c | 1 + include/configs/rk3288_common.h | 1 - include/dwmmc.h | 7 ++++- include/efi_loader.h | 2 +- include/mmc.h | 5 ---- lib/efi_loader/efi_disk.c | 61 +++++++++++++++++++++++++++++---------- lib/tiny-printf.c | 43 +++++++++++++++++++++------- tools/rkimage.c | 7 +---- 20 files changed, 181 insertions(+), 142 deletions(-)
Are there any more comments on this series please? I'd like to apply it soon to provide for plenty of test time on the MMC side.
Regards, Simon
participants (4)
-
Alexander Graf
-
Marek Vasut
-
Simon Glass
-
Stefan Roese