Ian Campbell | 6efe369 | 2014-05-05 11:52:26 +0100 | [diff] [blame] | 1 | /* |
| 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 Goede | 07be6d6 | 2014-11-15 22:55:53 +0100 | [diff] [blame] | 12 | #include <asm/arch/clock.h> |
Hans de Goede | d9ee84b | 2015-10-03 15:18:33 +0200 | [diff] [blame] | 13 | #include <axp_pmic.h> |
Hans de Goede | 7bfe2bb | 2015-01-13 19:25:06 +0100 | [diff] [blame] | 14 | #include <errno.h> |
Hans de Goede | 07be6d6 | 2014-11-15 22:55:53 +0100 | [diff] [blame] | 15 | |
| 16 | #ifdef CONFIG_MACH_SUN6I |
| 17 | int sunxi_get_ss_bonding_id(void) |
| 18 | { |
| 19 | struct sunxi_ccm_reg * const ccm = |
| 20 | (struct sunxi_ccm_reg *)SUNXI_CCM_BASE; |
| 21 | static int bonding_id = -1; |
| 22 | |
| 23 | if (bonding_id != -1) |
| 24 | return bonding_id; |
| 25 | |
| 26 | /* Enable Security System */ |
| 27 | setbits_le32(&ccm->ahb_reset0_cfg, 1 << AHB_RESET_OFFSET_SS); |
| 28 | setbits_le32(&ccm->ahb_gate0, 1 << AHB_GATE_OFFSET_SS); |
| 29 | |
| 30 | bonding_id = readl(SUNXI_SS_BASE); |
| 31 | bonding_id = (bonding_id >> 16) & 0x7; |
| 32 | |
| 33 | /* Disable Security System again */ |
| 34 | clrbits_le32(&ccm->ahb_gate0, 1 << AHB_GATE_OFFSET_SS); |
| 35 | clrbits_le32(&ccm->ahb_reset0_cfg, 1 << AHB_RESET_OFFSET_SS); |
| 36 | |
| 37 | return bonding_id; |
| 38 | } |
| 39 | #endif |
Ian Campbell | 6efe369 | 2014-05-05 11:52:26 +0100 | [diff] [blame] | 40 | |
| 41 | #ifdef CONFIG_DISPLAY_CPUINFO |
| 42 | int print_cpuinfo(void) |
| 43 | { |
Ian Campbell | 8f32aaa | 2014-10-24 21:20:47 +0100 | [diff] [blame] | 44 | #ifdef CONFIG_MACH_SUN4I |
Hans de Goede | 3ab9c23 | 2014-06-09 11:36:57 +0200 | [diff] [blame] | 45 | puts("CPU: Allwinner A10 (SUN4I)\n"); |
Ian Campbell | 8f32aaa | 2014-10-24 21:20:47 +0100 | [diff] [blame] | 46 | #elif defined CONFIG_MACH_SUN5I |
Hans de Goede | 8c1c782 | 2014-06-09 11:36:58 +0200 | [diff] [blame] | 47 | u32 val = readl(SUNXI_SID_BASE + 0x08); |
| 48 | switch ((val >> 12) & 0xf) { |
| 49 | case 0: puts("CPU: Allwinner A12 (SUN5I)\n"); break; |
| 50 | case 3: puts("CPU: Allwinner A13 (SUN5I)\n"); break; |
| 51 | case 7: puts("CPU: Allwinner A10s (SUN5I)\n"); break; |
| 52 | default: puts("CPU: Allwinner A1X (SUN5I)\n"); |
| 53 | } |
Ian Campbell | 8f32aaa | 2014-10-24 21:20:47 +0100 | [diff] [blame] | 54 | #elif defined CONFIG_MACH_SUN6I |
Hans de Goede | 07be6d6 | 2014-11-15 22:55:53 +0100 | [diff] [blame] | 55 | switch (sunxi_get_ss_bonding_id()) { |
| 56 | case SUNXI_SS_BOND_ID_A31: |
| 57 | puts("CPU: Allwinner A31 (SUN6I)\n"); |
| 58 | break; |
| 59 | case SUNXI_SS_BOND_ID_A31S: |
| 60 | puts("CPU: Allwinner A31s (SUN6I)\n"); |
| 61 | break; |
| 62 | default: |
| 63 | printf("CPU: Allwinner A31? (SUN6I, id: %d)\n", |
| 64 | sunxi_get_ss_bonding_id()); |
| 65 | } |
Ian Campbell | 8f32aaa | 2014-10-24 21:20:47 +0100 | [diff] [blame] | 66 | #elif defined CONFIG_MACH_SUN7I |
Ian Campbell | 6efe369 | 2014-05-05 11:52:26 +0100 | [diff] [blame] | 67 | puts("CPU: Allwinner A20 (SUN7I)\n"); |
Hans de Goede | f055ed6 | 2015-04-06 20:55:39 +0200 | [diff] [blame] | 68 | #elif defined CONFIG_MACH_SUN8I_A23 |
Chen-Yu Tsai | 848c263 | 2014-10-22 16:47:44 +0800 | [diff] [blame] | 69 | puts("CPU: Allwinner A23 (SUN8I)\n"); |
Vishnu Patekar | 3702f14 | 2015-03-01 23:47:48 +0530 | [diff] [blame] | 70 | #elif defined CONFIG_MACH_SUN8I_A33 |
| 71 | puts("CPU: Allwinner A33 (SUN8I)\n"); |
Jens Kuske | f977072 | 2015-11-17 15:12:58 +0100 | [diff] [blame^] | 72 | #elif defined CONFIG_MACH_SUN8I_H3 |
| 73 | puts("CPU: Allwinner H3 (SUN8I)\n"); |
Hans de Goede | 7bfe2bb | 2015-01-13 19:25:06 +0100 | [diff] [blame] | 74 | #elif defined CONFIG_MACH_SUN9I |
| 75 | puts("CPU: Allwinner A80 (SUN9I)\n"); |
Hans de Goede | 3ab9c23 | 2014-06-09 11:36:57 +0200 | [diff] [blame] | 76 | #else |
| 77 | #warning Please update cpu_info.c with correct CPU information |
| 78 | puts("CPU: SUNXI Family\n"); |
| 79 | #endif |
Ian Campbell | 6efe369 | 2014-05-05 11:52:26 +0100 | [diff] [blame] | 80 | return 0; |
| 81 | } |
| 82 | #endif |
Hans de Goede | 11d7098 | 2014-11-26 00:04:24 +0100 | [diff] [blame] | 83 | |
| 84 | int sunxi_get_sid(unsigned int *sid) |
| 85 | { |
Hans de Goede | 11d7098 | 2014-11-26 00:04:24 +0100 | [diff] [blame] | 86 | #ifdef CONFIG_AXP221_POWER |
Hans de Goede | d9ee84b | 2015-10-03 15:18:33 +0200 | [diff] [blame] | 87 | return axp_get_sid(sid); |
Hans de Goede | 0d70914 | 2015-05-19 23:34:00 +0200 | [diff] [blame] | 88 | #elif defined SUNXI_SID_BASE |
Hans de Goede | 11d7098 | 2014-11-26 00:04:24 +0100 | [diff] [blame] | 89 | int i; |
| 90 | |
| 91 | for (i = 0; i< 4; i++) |
| 92 | sid[i] = readl(SUNXI_SID_BASE + 4 * i); |
| 93 | |
| 94 | return 0; |
Hans de Goede | 0d70914 | 2015-05-19 23:34:00 +0200 | [diff] [blame] | 95 | #else |
| 96 | return -ENODEV; |
Hans de Goede | 11d7098 | 2014-11-26 00:04:24 +0100 | [diff] [blame] | 97 | #endif |
| 98 | } |