[U-Boot] [PATCH v2 2/5] sun6i: Add sunxi_get_ss_bonding_id() function

Hans de Goede hdegoede at redhat.com
Sun Nov 23 14:43:12 CET 2014


Add a sunxi_get_ss_bonding_id() function, and use it to differentiate between
the A31s and the A31.

Signed-off-by: Hans de Goede <hdegoede at redhat.com>
Acked-by: Ian Campbell <ijc at hellion.org.uk>
---
 arch/arm/cpu/armv7/sunxi/cpu_info.c           | 38 ++++++++++++++++++++++++++-
 arch/arm/include/asm/arch-sunxi/clock_sun6i.h |  4 ++-
 arch/arm/include/asm/arch-sunxi/cpu.h         |  5 ++++
 3 files changed, 45 insertions(+), 2 deletions(-)

diff --git a/arch/arm/cpu/armv7/sunxi/cpu_info.c b/arch/arm/cpu/armv7/sunxi/cpu_info.c
index 41b9add..5146dc4 100644
--- a/arch/arm/cpu/armv7/sunxi/cpu_info.c
+++ b/arch/arm/cpu/armv7/sunxi/cpu_info.c
@@ -9,6 +9,32 @@
 #include <common.h>
 #include <asm/io.h>
 #include <asm/arch/cpu.h>
+#include <asm/arch/clock.h>
+
+#ifdef CONFIG_MACH_SUN6I
+int sunxi_get_ss_bonding_id(void)
+{
+	struct sunxi_ccm_reg * const ccm =
+		(struct sunxi_ccm_reg *)SUNXI_CCM_BASE;
+	static int bonding_id = -1;
+
+	if (bonding_id != -1)
+		return bonding_id;
+
+	/* Enable Security System */
+	setbits_le32(&ccm->ahb_reset0_cfg, 1 << AHB_RESET_OFFSET_SS);
+	setbits_le32(&ccm->ahb_gate0, 1 << AHB_GATE_OFFSET_SS);
+
+	bonding_id = readl(SUNXI_SS_BASE);
+	bonding_id = (bonding_id >> 16) & 0x7;
+
+	/* Disable Security System again */
+	clrbits_le32(&ccm->ahb_gate0, 1 << AHB_GATE_OFFSET_SS);
+	clrbits_le32(&ccm->ahb_reset0_cfg, 1 << AHB_RESET_OFFSET_SS);
+
+	return bonding_id;
+}
+#endif
 
 #ifdef CONFIG_DISPLAY_CPUINFO
 int print_cpuinfo(void)
@@ -24,7 +50,17 @@ int print_cpuinfo(void)
 	default: puts("CPU:   Allwinner A1X (SUN5I)\n");
 	}
 #elif defined CONFIG_MACH_SUN6I
-	puts("CPU:   Allwinner A31 (SUN6I)\n");
+	switch (sunxi_get_ss_bonding_id()) {
+	case SUNXI_SS_BOND_ID_A31:
+		puts("CPU:   Allwinner A31 (SUN6I)\n");
+		break;
+	case SUNXI_SS_BOND_ID_A31S:
+		puts("CPU:   Allwinner A31s (SUN6I)\n");
+		break;
+	default:
+		printf("CPU:   Allwinner A31? (SUN6I, id: %d)\n",
+		       sunxi_get_ss_bonding_id());
+	}
 #elif defined CONFIG_MACH_SUN7I
 	puts("CPU:   Allwinner A20 (SUN7I)\n");
 #elif defined CONFIG_MACH_SUN8I
diff --git a/arch/arm/include/asm/arch-sunxi/clock_sun6i.h b/arch/arm/include/asm/arch-sunxi/clock_sun6i.h
index 50a4b69..7e810bb 100644
--- a/arch/arm/include/asm/arch-sunxi/clock_sun6i.h
+++ b/arch/arm/include/asm/arch-sunxi/clock_sun6i.h
@@ -209,6 +209,7 @@ struct sunxi_ccm_reg {
 #define AHB_GATE_OFFSET_MMC1		9
 #define AHB_GATE_OFFSET_MMC0		8
 #define AHB_GATE_OFFSET_MMC(n)		(AHB_GATE_OFFSET_MMC0 + (n))
+#define AHB_GATE_OFFSET_SS		5
 
 /* ahb_gate1 offsets */
 #define AHB_GATE_OFFSET_DRC0		25
@@ -270,8 +271,9 @@ struct sunxi_ccm_reg {
 #define AHB_RESET_OFFSET_MMC1		9
 #define AHB_RESET_OFFSET_MMC0		8
 #define AHB_RESET_OFFSET_MMC(n)		(AHB_RESET_OFFSET_MMC0 + (n))
+#define AHB_RESET_OFFSET_SS		5
 
-/* ahb_reset0 offsets */
+/* ahb_reset1 offsets */
 #define AHB_RESET_OFFSET_DRC0		25
 #define AHB_RESET_OFFSET_DE_BE0		12
 #define AHB_RESET_OFFSET_HDMI		11
diff --git a/arch/arm/include/asm/arch-sunxi/cpu.h b/arch/arm/include/asm/arch-sunxi/cpu.h
index bdee89e..90e06c0 100644
--- a/arch/arm/include/asm/arch-sunxi/cpu.h
+++ b/arch/arm/include/asm/arch-sunxi/cpu.h
@@ -135,9 +135,14 @@
 
 #define SUNXI_CPU_CFG			(SUNXI_TIMER_BASE + 0x13c)
 
+/* SS bonding ids used for cpu identification */
+#define SUNXI_SS_BOND_ID_A31		4
+#define SUNXI_SS_BOND_ID_A31S		5
+
 #ifndef __ASSEMBLY__
 void sunxi_board_init(void);
 void sunxi_reset(void);
+int sunxi_get_ss_bonding_id(void);
 #endif /* __ASSEMBLY__ */
 
 #endif /* _CPU_H */
-- 
2.1.0



More information about the U-Boot mailing list