sun6i: Add sunxi_get_ss_bonding_id() function
[platform/kernel/u-boot.git] / arch / arm / cpu / armv7 / sunxi / cpu_info.c
index 41b9add..5146dc4 100644 (file)
@@ -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