blob: 7a3a4ca81bf6b048adaeb7157fcb4f9271269aaa [file] [log] [blame]
Ian Campbell6efe3692014-05-05 11:52:26 +01001/*
2 * (C) Copyright 2007-2011
3 * Allwinner Technology Co., Ltd. <www.allwinnertech.com>
4 * Tom Cubie <tangliang@allwinnertech.com>
5 *
6 * SPDX-License-Identifier: GPL-2.0+
7 */
8
9#include <common.h>
10#include <asm/io.h>
11#include <asm/arch/cpu.h>
Hans de Goede07be6d62014-11-15 22:55:53 +010012#include <asm/arch/clock.h>
Hans de Goede11d70982014-11-26 00:04:24 +010013#include <axp221.h>
Hans de Goede07be6d62014-11-15 22:55:53 +010014
15#ifdef CONFIG_MACH_SUN6I
16int sunxi_get_ss_bonding_id(void)
17{
18 struct sunxi_ccm_reg * const ccm =
19 (struct sunxi_ccm_reg *)SUNXI_CCM_BASE;
20 static int bonding_id = -1;
21
22 if (bonding_id != -1)
23 return bonding_id;
24
25 /* Enable Security System */
26 setbits_le32(&ccm->ahb_reset0_cfg, 1 << AHB_RESET_OFFSET_SS);
27 setbits_le32(&ccm->ahb_gate0, 1 << AHB_GATE_OFFSET_SS);
28
29 bonding_id = readl(SUNXI_SS_BASE);
30 bonding_id = (bonding_id >> 16) & 0x7;
31
32 /* Disable Security System again */
33 clrbits_le32(&ccm->ahb_gate0, 1 << AHB_GATE_OFFSET_SS);
34 clrbits_le32(&ccm->ahb_reset0_cfg, 1 << AHB_RESET_OFFSET_SS);
35
36 return bonding_id;
37}
38#endif
Ian Campbell6efe3692014-05-05 11:52:26 +010039
40#ifdef CONFIG_DISPLAY_CPUINFO
41int print_cpuinfo(void)
42{
Ian Campbell8f32aaa2014-10-24 21:20:47 +010043#ifdef CONFIG_MACH_SUN4I
Hans de Goede3ab9c232014-06-09 11:36:57 +020044 puts("CPU: Allwinner A10 (SUN4I)\n");
Ian Campbell8f32aaa2014-10-24 21:20:47 +010045#elif defined CONFIG_MACH_SUN5I
Hans de Goede8c1c7822014-06-09 11:36:58 +020046 u32 val = readl(SUNXI_SID_BASE + 0x08);
47 switch ((val >> 12) & 0xf) {
48 case 0: puts("CPU: Allwinner A12 (SUN5I)\n"); break;
49 case 3: puts("CPU: Allwinner A13 (SUN5I)\n"); break;
50 case 7: puts("CPU: Allwinner A10s (SUN5I)\n"); break;
51 default: puts("CPU: Allwinner A1X (SUN5I)\n");
52 }
Ian Campbell8f32aaa2014-10-24 21:20:47 +010053#elif defined CONFIG_MACH_SUN6I
Hans de Goede07be6d62014-11-15 22:55:53 +010054 switch (sunxi_get_ss_bonding_id()) {
55 case SUNXI_SS_BOND_ID_A31:
56 puts("CPU: Allwinner A31 (SUN6I)\n");
57 break;
58 case SUNXI_SS_BOND_ID_A31S:
59 puts("CPU: Allwinner A31s (SUN6I)\n");
60 break;
61 default:
62 printf("CPU: Allwinner A31? (SUN6I, id: %d)\n",
63 sunxi_get_ss_bonding_id());
64 }
Ian Campbell8f32aaa2014-10-24 21:20:47 +010065#elif defined CONFIG_MACH_SUN7I
Ian Campbell6efe3692014-05-05 11:52:26 +010066 puts("CPU: Allwinner A20 (SUN7I)\n");
Ian Campbell8f32aaa2014-10-24 21:20:47 +010067#elif defined CONFIG_MACH_SUN8I
Chen-Yu Tsai848c2632014-10-22 16:47:44 +080068 puts("CPU: Allwinner A23 (SUN8I)\n");
Hans de Goede3ab9c232014-06-09 11:36:57 +020069#else
70#warning Please update cpu_info.c with correct CPU information
71 puts("CPU: SUNXI Family\n");
72#endif
Ian Campbell6efe3692014-05-05 11:52:26 +010073 return 0;
74}
75#endif
Hans de Goede11d70982014-11-26 00:04:24 +010076
77int sunxi_get_sid(unsigned int *sid)
78{
79#ifdef CONFIG_MACH_SUN6I
80#ifdef CONFIG_AXP221_POWER
81 return axp221_get_sid(sid);
82#else
83 return -ENODEV;
84#endif
85#else
86 int i;
87
88 for (i = 0; i< 4; i++)
89 sid[i] = readl(SUNXI_SID_BASE + 4 * i);
90
91 return 0;
92#endif
93}