[U-Boot] [PATCH v2 03/11] board:samsung: check the mmc boot device and init the right mmc driver.

Przemyslaw Marczak
2014-06-18T10:47:49Z

Hello Minkyu,
On 06/18/2014 08:30 AM, Minkyu Kang wrote:
> Dear Przemyslaw Marczak,
>
> On 12/06/14 18:46, Przemyslaw Marczak wrote:
>> It is possible to boot from a few media devices, especially using a micro
>> SD or eMMC slots. In this situation, boot device should be registered
>> as block device 0 in the MMC framework, because CONFIG_SYS_MMC_ENV_DEV
>> is usually set to "0" in the most config cases.
>>
>> Signed-off-by: Przemyslaw Marczak <p.marczak@samsung.com>
>> Cc: Piotr Wilczek <p.wilczek@samsung.com>
>> Cc: Minkyu Kang <mk7.kang@samsung.com>
>> ---
>> board/samsung/common/board.c | 32 ++++++++++++++++++++++++--------
>> include/samsung/misc.h | 5 +++++
>> 2 files changed, 29 insertions(+), 8 deletions(-)
>>
>> diff --git a/board/samsung/common/board.c b/board/samsung/common/board.c
>> index 9dc7c83..2970340 100644
>> --- a/board/samsung/common/board.c
>> +++ b/board/samsung/common/board.c
>> @@ -25,6 +25,8 @@
>> #include <lcd.h>
>> #include <samsung/misc.h>
>>
>> +static int bootmode;
>> +
>> DECLARE_GLOBAL_DATA_PTR;
>>
>> int __exynos_early_init_f(void)
>> @@ -243,19 +245,33 @@ int board_eth_init(bd_t *bis)
>> int board_mmc_init(bd_t *bis)
>> {
>> int ret;
>> + struct exynos4_power *pwr = (struct exynos4_power *)
>> + samsung_get_base_power();
>
> Hm, no. This file is samsung common not only for exynos4.
> Although this code will not be made any problems for other SoCs (because om_stat is always first item of power), it looks weird.
> I think you can make new function for getting boot mode.
>
Yes, this was bad. What about that:
# unsigned int om_stat = samsung_get_base_power();
#
# bootmode = BOOT_MODE(readl(om_stat));

or maybe just

# bootmode = BOOT_MODE(readl(samsung_get_base_power()));

like in the Exynos spl code.

Simply and proper for every SOC.
And a function for this code will be added.

>> +
>> + bootmode = BOOT_MODE(readl(&pwr->om_stat));
>> + if (bootmode == BOOT_SDMMC) {
>> +#ifdef CONFIG_SDHCI
>> + /* mmc initializattion for available channels */
>> + ret = exynos_mmc_init(gd->fdt_blob);
>> +#endif
>> #ifdef CONFIG_DWMMC
>> - /* dwmmc initializattion for available channels */
>> - ret = exynos_dwmmc_init(gd->fdt_blob);
>> - if (ret)
>> - debug("dwmmc init failed\n");
>> + /* dwmmc initializattion for available channels */
>> + ret = exynos_dwmmc_init(gd->fdt_blob);
>> +#endif
>> + } else {
>> +#ifdef CONFIG_DWMMC
>> + /* dwmmc initializattion for available channels */
>> + ret = exynos_dwmmc_init(gd->fdt_blob);
>> #endif
>> -
>> #ifdef CONFIG_SDHCI
>> - /* mmc initializattion for available channels */
>> - ret = exynos_mmc_init(gd->fdt_blob);
>> + /* mmc initializattion for available channels */
>> + ret = exynos_mmc_init(gd->fdt_blob);
>> +#endif
>> + }
>> +
>> if (ret)
>> debug("mmc init failed\n");
>> -#endif
>> +
>> return ret;
>> }
>> #endif
>> diff --git a/include/samsung/misc.h b/include/samsung/misc.h
>> index 10653a1..87b53ec 100644
>> --- a/include/samsung/misc.h
>> +++ b/include/samsung/misc.h
>> @@ -28,4 +28,9 @@ void check_boot_mode(void);
>> void draw_logo(void);
>> #endif
>>
>> +#define BOOT_SDMMC 0x2
>> +#define BOOT_MODE_MASK (0x1f)
>> +#define BOOT_MODE_SHIFT (0x1)
>> +#define BOOT_MODE(x) ((x >> BOOT_MODE_SHIFT) & BOOT_MODE_MASK)
>
> ((x) >> BOOT_MODE_SHIFT)
>

Ok, will fix this.

>> +
>> #endif /* __SAMSUNG_MISC_COMMON_H__ */
>>
>
> Thanks,
> Minkyu Kang.
>

Thank you,
--
Przemyslaw Marczak
Samsung R&D Institute Poland
Samsung Electronics
p.marczak at samsung.com