[PATCH 03/11] ARM: i.MX6: add function to get bootsource in pbl

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



In the pbl the regular bootsource_get cannot be used. Add a function
which returns the bootsource directly with values from the hardware.

Signed-off-by: Sascha Hauer <s.hauer@xxxxxxxxxxxxxx>
---
 arch/arm/mach-imx/boot.c                 | 38 ++++++++++++++++++--------------
 arch/arm/mach-imx/include/mach/generic.h |  2 ++
 2 files changed, 24 insertions(+), 16 deletions(-)

diff --git a/arch/arm/mach-imx/boot.c b/arch/arm/mach-imx/boot.c
index 4416011..376e370 100644
--- a/arch/arm/mach-imx/boot.c
+++ b/arch/arm/mach-imx/boot.c
@@ -21,6 +21,7 @@
 #include <mach/generic.h>
 #include <mach/imx25-regs.h>
 #include <mach/imx35-regs.h>
+#include <mach/imx6-regs.h>
 
 /* [CTRL][TYPE] */
 static const enum bootsource locations[4][4] = {
@@ -214,10 +215,9 @@ void imx53_boot_save_loc(void __iomem *src_base)
 #define IMX6_SRC_SBMR1	0x04
 #define IMX6_SRC_SBMR2	0x1c
 
-void imx6_boot_save_loc(void __iomem *src_base)
+void imx6_get_boot_source(enum bootsource *src, int *instance)
 {
-	enum bootsource src = BOOTSOURCE_UNKNOWN;
-	int instance = BOOTSOURCE_INSTANCE_UNKNOWN;
+	void __iomem *src_base = IOMEM(MX6_SRC_BASE_ADDR);
 	uint32_t sbmr1 = readl(src_base + IMX6_SRC_SBMR1);
 	uint32_t sbmr2 = readl(src_base + IMX6_SRC_SBMR2);
 	uint32_t boot_cfg_4_2_0;
@@ -231,14 +231,12 @@ void imx6_boot_save_loc(void __iomem *src_base)
 	case 2: /* internal boot */
 		goto internal_boot;
 	case 1: /* Serial Downloader */
-		src = BOOTSOURCE_SERIAL;
+		*src = BOOTSOURCE_SERIAL;
 		break;
 	case 3: /* reserved */
 		break;
 	};
 
-	bootsource_set(src);
-
 	return;
 
 internal_boot:
@@ -246,28 +244,28 @@ internal_boot:
 	/* BOOT_CFG1[7:4] */
 	switch ((sbmr1 >> 4) & 0xf) {
 	case 2:
-		src = BOOTSOURCE_HD;
+		*src = BOOTSOURCE_HD;
 		break;
 	case 3:
 		/* BOOT_CFG4[2:0] */
 		boot_cfg_4_2_0 = (sbmr1 >> 24) & 0x7;
 
 		if (boot_cfg_4_2_0 > 4) {
-			src = BOOTSOURCE_I2C;
-			instance = boot_cfg_4_2_0 - 5;
+			*src = BOOTSOURCE_I2C;
+			*instance = boot_cfg_4_2_0 - 5;
 		} else {
-			src = BOOTSOURCE_SPI;
-			instance = boot_cfg_4_2_0;
+			*src = BOOTSOURCE_SPI;
+			*instance = boot_cfg_4_2_0;
 		}
 		break;
 	case 4:
 	case 5:
 	case 6:
 	case 7:
-		src = BOOTSOURCE_MMC;
+		*src = BOOTSOURCE_MMC;
 
 		/* BOOT_CFG2[4:3] */
-		instance = (sbmr1 >> 11) & 0x3;
+		*instance = (sbmr1 >> 11) & 0x3;
 		break;
 	default:
 		break;
@@ -275,10 +273,18 @@ internal_boot:
 
 	/* BOOT_CFG1[7:0] */
 	if (sbmr1 & (1 << 7))
-		src = BOOTSOURCE_NAND;
+		*src = BOOTSOURCE_NAND;
+
+	return;
+}
+
+void imx6_boot_save_loc(void __iomem *src_base)
+{
+	enum bootsource src = BOOTSOURCE_UNKNOWN;
+	int instance = BOOTSOURCE_INSTANCE_UNKNOWN;
+
+	imx6_get_boot_source(&src, &instance);
 
 	bootsource_set(src);
 	bootsource_set_instance(instance);
-
-	return;
 }
diff --git a/arch/arm/mach-imx/include/mach/generic.h b/arch/arm/mach-imx/include/mach/generic.h
index d4b6a1f..46fe388 100644
--- a/arch/arm/mach-imx/include/mach/generic.h
+++ b/arch/arm/mach-imx/include/mach/generic.h
@@ -3,6 +3,7 @@
 
 #include <linux/compiler.h>
 #include <linux/types.h>
+#include <bootsource.h>
 
 u64 imx_uid(void);
 
@@ -12,6 +13,7 @@ void imx27_boot_save_loc(void __iomem *sysctrl_base);
 void imx51_boot_save_loc(void __iomem *src_base);
 void imx53_boot_save_loc(void __iomem *src_base);
 void imx6_boot_save_loc(void __iomem *src_base);
+void imx6_get_boot_source(enum bootsource *src, int *instance);
 
 int imx1_init(void);
 int imx21_init(void);
-- 
2.1.4


_______________________________________________
barebox mailing list
barebox@xxxxxxxxxxxxxxxxxxx
http://lists.infradead.org/mailman/listinfo/barebox



[Index of Archives]     [Linux Embedded]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux