[PATCH v2 18/21] ARM: Layerscape: LS1028a: implement bootsource detection

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

 



Detecting the bootsource is just a matter of decoding the porsr1
register. Implement it.

Signed-off-by: Sascha Hauer <s.hauer@xxxxxxxxxxxxxx>
---
 arch/arm/mach-layerscape/boot.c      | 40 ++++++++++++++++++++++++++++
 arch/arm/mach-layerscape/soc.c       |  1 +
 include/mach/layerscape/layerscape.h |  1 +
 3 files changed, 42 insertions(+)

diff --git a/arch/arm/mach-layerscape/boot.c b/arch/arm/mach-layerscape/boot.c
index 26a7a1434a..4d074205cc 100644
--- a/arch/arm/mach-layerscape/boot.c
+++ b/arch/arm/mach-layerscape/boot.c
@@ -3,8 +3,10 @@
 #include <common.h>
 #include <init.h>
 #include <bootsource.h>
+#include <linux/bitfield.h>
 #include <mach/layerscape/layerscape.h>
 #include <soc/fsl/immap_lsch2.h>
+#include <soc/fsl/immap_lsch3.h>
 
 enum bootsource ls1046a_bootsource_get(void)
 {
@@ -41,3 +43,41 @@ void ls1046a_bootsource_init(void)
 {
 	bootsource_set_raw(ls1046a_bootsource_get(), BOOTSOURCE_INSTANCE_UNKNOWN);
 }
+
+#define PORSR1_RCW_SRC	GENMASK(26, 23)
+
+static enum bootsource ls1028a_bootsource_get(int *instance)
+{
+	void __iomem *porsr1 = IOMEM(LSCH3_DCFG_BASE);
+	uint32_t rcw_src;
+
+	rcw_src = FIELD_GET(PORSR1_RCW_SRC, readl(porsr1));
+
+	printf("%s: 0x%08x\n", __func__, rcw_src);
+
+	switch (rcw_src) {
+	case 8:
+		*instance = 0;
+		return BOOTSOURCE_MMC;
+	case 9:
+		*instance = 1;
+		return BOOTSOURCE_MMC;
+	case 0xa:
+		return BOOTSOURCE_I2C;
+	case 0xd:
+	case 0xc:
+		return BOOTSOURCE_NAND;
+	case 0xf:
+		return BOOTSOURCE_SPI_NOR;
+	}
+
+	return BOOTSOURCE_UNKNOWN;
+}
+
+void ls1028a_bootsource_init(void)
+{
+	int instance = BOOTSOURCE_INSTANCE_UNKNOWN;
+	enum bootsource source = ls1028a_bootsource_get(&instance);
+
+	bootsource_set_raw(source, instance);
+}
diff --git a/arch/arm/mach-layerscape/soc.c b/arch/arm/mach-layerscape/soc.c
index a50aafc954..462405ea87 100644
--- a/arch/arm/mach-layerscape/soc.c
+++ b/arch/arm/mach-layerscape/soc.c
@@ -92,6 +92,7 @@ static int ls1028a_init(void)
 	if (!cpu_is_ls1028a())
 		return -EINVAL;
 
+	ls1028a_bootsource_init();
 	layerscape_register_pbl_image_handler();
 	ls1028a_setup_icids();
 
diff --git a/include/mach/layerscape/layerscape.h b/include/mach/layerscape/layerscape.h
index a9037125c8..bf4a751b92 100644
--- a/include/mach/layerscape/layerscape.h
+++ b/include/mach/layerscape/layerscape.h
@@ -54,6 +54,7 @@ struct dram_regions_info {
 };
 
 void ls1021a_bootsource_init(void);
+void ls1028a_bootsource_init(void);
 void ls1046a_bootsource_init(void);
 void layerscape_register_pbl_image_handler(void);
 void ls102xa_smmu_stream_id_init(void);
-- 
2.39.2





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

  Powered by Linux