diff mbox

[U-Boot,v3,02/11] board:samsung: add function boot_device() for checking boot medium

Message ID 1403792137-3113-3-git-send-email-p.marczak@samsung.com
State Changes Requested
Delegated to: Minkyu Kang
Headers show

Commit Message

Przemyslaw Marczak June 26, 2014, 2:15 p.m. UTC
It is possible to boot from a few media devices, especially
using a micro SD or eMMC slots. In this situation depends on
a boot device - some setup can be changeg.

This change adds function:
boot_device() - which returns an OM[1:5] bits value

This allows checking if boot device is SD(0x2).

Signed-off-by: Przemyslaw Marczak <p.marczak@samsung.com>

---
Changes v3:
- new commit after separate one into two
---
 board/samsung/common/board.c | 10 +++++++++-
 include/samsung/misc.h       |  7 +++++++
 2 files changed, 16 insertions(+), 1 deletion(-)

Comments

Minkyu Kang June 27, 2014, 9:40 a.m. UTC | #1
Dear Przemyslaw Marczak,

On 26/06/14 23:15, Przemyslaw Marczak wrote:
> It is possible to boot from a few media devices, especially
> using a micro SD or eMMC slots. In this situation depends on
> a boot device - some setup can be changeg.
> 
> This change adds function:
> boot_device() - which returns an OM[1:5] bits value
> 
> This allows checking if boot device is SD(0x2).
> 
> Signed-off-by: Przemyslaw Marczak <p.marczak@samsung.com>
> 
> ---
> Changes v3:
> - new commit after separate one into two
> ---
>  board/samsung/common/board.c | 10 +++++++++-
>  include/samsung/misc.h       |  7 +++++++
>  2 files changed, 16 insertions(+), 1 deletion(-)
> 
> diff --git a/board/samsung/common/board.c b/board/samsung/common/board.c
> index 9dc7c83..ecf3f76 100644
> --- a/board/samsung/common/board.c
> +++ b/board/samsung/common/board.c
> @@ -41,6 +41,13 @@ int __exynos_power_init(void)
>  int exynos_power_init(void)
>  	__attribute__((weak, alias("__exynos_power_init")));
>  
> +unsigned int boot_device(void)
> +{
> +	unsigned int om_stat = samsung_get_base_power();
> +
> +	return BOOT_DEVICE(readl(om_stat));
> +}
> +
>  #if defined CONFIG_EXYNOS_TMU
>  /* Boot Time Thermal Analysis for SoC temperature threshold breach */
>  static void boot_temp_check(void)
> @@ -243,19 +250,20 @@ int board_eth_init(bd_t *bis)
>  int board_mmc_init(bd_t *bis)
>  {
>  	int ret;
> +
>  #ifdef CONFIG_DWMMC
>  	/* dwmmc initializattion for available channels */
>  	ret = exynos_dwmmc_init(gd->fdt_blob);
>  	if (ret)
>  		debug("dwmmc init failed\n");
>  #endif
> -
>  #ifdef CONFIG_SDHCI
>  	/* mmc initializattion for available channels */
>  	ret = exynos_mmc_init(gd->fdt_blob);
>  	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..57bac7d 100644
> --- a/include/samsung/misc.h
> +++ b/include/samsung/misc.h
> @@ -28,4 +28,11 @@ void check_boot_mode(void);
>  void draw_logo(void);
>  #endif
>  
> +#define BOOT_DEVICE_SDMMC	0x2
> +#define BOOT_DEVICE_MASK	0x1f
> +#define BOOT_DEVICE_SHIFT	0x1
> +#define BOOT_DEVICE(x)		(((x) >> BOOT_DEVICE_SHIFT) & BOOT_DEVICE_MASK)
> +
> +unsigned int boot_device(void);

Hm, do we need to make this function to non-static?
If so, it should be placed in power.c - get_om_stat()?

Thanks,
Minkyu Kang.
Przemyslaw Marczak June 27, 2014, 11:33 a.m. UTC | #2
Dear Minkyu,

On 06/27/2014 11:40 AM, Minkyu Kang wrote:
> Dear Przemyslaw Marczak,
>
> On 26/06/14 23:15, Przemyslaw Marczak wrote:
>> It is possible to boot from a few media devices, especially
>> using a micro SD or eMMC slots. In this situation depends on
>> a boot device - some setup can be changeg.
>>
>> This change adds function:
>> boot_device() - which returns an OM[1:5] bits value
>>
>> This allows checking if boot device is SD(0x2).
>>
>> Signed-off-by: Przemyslaw Marczak <p.marczak@samsung.com>
>>
>> ---
>> Changes v3:
>> - new commit after separate one into two
>> ---
>>   board/samsung/common/board.c | 10 +++++++++-
>>   include/samsung/misc.h       |  7 +++++++
>>   2 files changed, 16 insertions(+), 1 deletion(-)
>>
>> diff --git a/board/samsung/common/board.c b/board/samsung/common/board.c
>> index 9dc7c83..ecf3f76 100644
>> --- a/board/samsung/common/board.c
>> +++ b/board/samsung/common/board.c
>> @@ -41,6 +41,13 @@ int __exynos_power_init(void)
>>   int exynos_power_init(void)
>>   	__attribute__((weak, alias("__exynos_power_init")));
>>
>> +unsigned int boot_device(void)
>> +{
>> +	unsigned int om_stat = samsung_get_base_power();
>> +
>> +	return BOOT_DEVICE(readl(om_stat));
>> +}
>> +
>>   #if defined CONFIG_EXYNOS_TMU
>>   /* Boot Time Thermal Analysis for SoC temperature threshold breach */
>>   static void boot_temp_check(void)
>> @@ -243,19 +250,20 @@ int board_eth_init(bd_t *bis)
>>   int board_mmc_init(bd_t *bis)
>>   {
>>   	int ret;
>> +
>>   #ifdef CONFIG_DWMMC
>>   	/* dwmmc initializattion for available channels */
>>   	ret = exynos_dwmmc_init(gd->fdt_blob);
>>   	if (ret)
>>   		debug("dwmmc init failed\n");
>>   #endif
>> -
>>   #ifdef CONFIG_SDHCI
>>   	/* mmc initializattion for available channels */
>>   	ret = exynos_mmc_init(gd->fdt_blob);
>>   	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..57bac7d 100644
>> --- a/include/samsung/misc.h
>> +++ b/include/samsung/misc.h
>> @@ -28,4 +28,11 @@ void check_boot_mode(void);
>>   void draw_logo(void);
>>   #endif
>>
>> +#define BOOT_DEVICE_SDMMC	0x2
>> +#define BOOT_DEVICE_MASK	0x1f
>> +#define BOOT_DEVICE_SHIFT	0x1
>> +#define BOOT_DEVICE(x)		(((x) >> BOOT_DEVICE_SHIFT) & BOOT_DEVICE_MASK)
>> +
>> +unsigned int boot_device(void);
>
> Hm, do we need to make this function to non-static?
> If so, it should be placed in power.c - get_om_stat()?
>
> Thanks,
> Minkyu Kang.
>

It is non-static because it is called also outside this file, so I will 
move it to power.c.

Thank you,
diff mbox

Patch

diff --git a/board/samsung/common/board.c b/board/samsung/common/board.c
index 9dc7c83..ecf3f76 100644
--- a/board/samsung/common/board.c
+++ b/board/samsung/common/board.c
@@ -41,6 +41,13 @@  int __exynos_power_init(void)
 int exynos_power_init(void)
 	__attribute__((weak, alias("__exynos_power_init")));
 
+unsigned int boot_device(void)
+{
+	unsigned int om_stat = samsung_get_base_power();
+
+	return BOOT_DEVICE(readl(om_stat));
+}
+
 #if defined CONFIG_EXYNOS_TMU
 /* Boot Time Thermal Analysis for SoC temperature threshold breach */
 static void boot_temp_check(void)
@@ -243,19 +250,20 @@  int board_eth_init(bd_t *bis)
 int board_mmc_init(bd_t *bis)
 {
 	int ret;
+
 #ifdef CONFIG_DWMMC
 	/* dwmmc initializattion for available channels */
 	ret = exynos_dwmmc_init(gd->fdt_blob);
 	if (ret)
 		debug("dwmmc init failed\n");
 #endif
-
 #ifdef CONFIG_SDHCI
 	/* mmc initializattion for available channels */
 	ret = exynos_mmc_init(gd->fdt_blob);
 	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..57bac7d 100644
--- a/include/samsung/misc.h
+++ b/include/samsung/misc.h
@@ -28,4 +28,11 @@  void check_boot_mode(void);
 void draw_logo(void);
 #endif
 
+#define BOOT_DEVICE_SDMMC	0x2
+#define BOOT_DEVICE_MASK	0x1f
+#define BOOT_DEVICE_SHIFT	0x1
+#define BOOT_DEVICE(x)		(((x) >> BOOT_DEVICE_SHIFT) & BOOT_DEVICE_MASK)
+
+unsigned int boot_device(void);
+
 #endif /* __SAMSUNG_MISC_COMMON_H__ */