blob: f42eee166b6c44634089378ee0c64b1ce5488c5c [file] [log] [blame]
Chandan Nath1c959692011-10-14 02:58:22 +00001/*
2 * sys_info.c
3 *
4 * System information functions
5 *
6 * Copyright (C) 2011, Texas Instruments, Incorporated - http://www.ti.com/
7 *
8 * Derived from Beagle Board and 3430 SDP code by
9 * Richard Woodruff <r-woodruff2@ti.com>
10 * Syed Mohammed Khasim <khasim@ti.com>
11 *
Wolfgang Denkd79de1d2013-07-08 09:37:19 +020012 * SPDX-License-Identifier: GPL-2.0+
Chandan Nath1c959692011-10-14 02:58:22 +000013 */
14
15#include <common.h>
16#include <asm/io.h>
17#include <asm/arch/sys_proto.h>
18#include <asm/arch/cpu.h>
19#include <asm/arch/clock.h>
Tom Rini52437072013-08-30 16:28:46 -040020#include <power/tps65910.h>
Igor Grinbergd5e635e2014-11-05 13:29:54 +020021#include <linux/compiler.h>
Chandan Nath1c959692011-10-14 02:58:22 +000022
23struct ctrl_stat *cstat = (struct ctrl_stat *)CTRL_BASE;
24
25/**
26 * get_cpu_rev(void) - extract rev info
27 */
28u32 get_cpu_rev(void)
29{
30 u32 id;
31 u32 rev;
32
33 id = readl(DEVICE_ID);
34 rev = (id >> 28) & 0xff;
35
36 return rev;
37}
38
39/**
40 * get_cpu_type(void) - extract cpu info
41 */
42u32 get_cpu_type(void)
43{
44 u32 id = 0;
45 u32 partnum;
46
47 id = readl(DEVICE_ID);
48 partnum = (id >> 12) & 0xffff;
49
50 return partnum;
51}
52
53/**
Chandan Nath1c959692011-10-14 02:58:22 +000054 * get_device_type(): tell if GP/HS/EMU/TST
55 */
56u32 get_device_type(void)
57{
58 int mode;
59 mode = readl(&cstat->statusreg) & (DEVICE_MASK);
60 return mode >>= 8;
61}
62
63/**
64 * get_sysboot_value(void) - return SYS_BOOT[4:0]
65 */
66u32 get_sysboot_value(void)
67{
Masahiro Yamada04cfea52016-09-06 22:17:38 +090068 return readl(&cstat->statusreg) & SYSBOOT_MASK;
Chandan Nath1c959692011-10-14 02:58:22 +000069}
70
71#ifdef CONFIG_DISPLAY_CPUINFO
Sergey Alyoshin8e796c42014-05-22 11:56:03 +040072static char *cpu_revs[] = {
73 "1.0",
74 "2.0",
75 "2.1"};
76
77
78static char *dev_types[] = {
79 "TST",
80 "EMU",
81 "HS",
82 "GP"};
83
Chandan Nath1c959692011-10-14 02:58:22 +000084/**
85 * Print CPU information
86 */
87int print_cpuinfo(void)
88{
Sergey Alyoshin8e796c42014-05-22 11:56:03 +040089 char *cpu_s, *sec_s, *rev_s;
Chandan Nath1c959692011-10-14 02:58:22 +000090
91 switch (get_cpu_type()) {
92 case AM335X:
93 cpu_s = "AM335X";
94 break;
Matt Porter691fbe32013-03-15 10:07:06 +000095 case TI81XX:
96 cpu_s = "TI81XX";
97 break;
Chandan Nath1c959692011-10-14 02:58:22 +000098 default:
Sergey Alyoshin8e796c42014-05-22 11:56:03 +040099 cpu_s = "Unknown CPU type";
Chandan Nath1c959692011-10-14 02:58:22 +0000100 break;
101 }
102
Sergey Alyoshin8e796c42014-05-22 11:56:03 +0400103 if (get_cpu_rev() < ARRAY_SIZE(cpu_revs))
104 rev_s = cpu_revs[get_cpu_rev()];
105 else
106 rev_s = "?";
107
108 if (get_device_type() < ARRAY_SIZE(dev_types))
109 sec_s = dev_types[get_device_type()];
110 else
Chandan Nath1c959692011-10-14 02:58:22 +0000111 sec_s = "?";
Chandan Nath1c959692011-10-14 02:58:22 +0000112
Sergey Alyoshin8e796c42014-05-22 11:56:03 +0400113 printf("%s-%s rev %s\n", cpu_s, sec_s, rev_s);
Chandan Nath1c959692011-10-14 02:58:22 +0000114
115 return 0;
116}
117#endif /* CONFIG_DISPLAY_CPUINFO */
Tom Rini52437072013-08-30 16:28:46 -0400118
119#ifdef CONFIG_AM33XX
120int am335x_get_efuse_mpu_max_freq(struct ctrl_dev *cdev)
121{
122 int sil_rev;
123
124 sil_rev = readl(&cdev->deviceid) >> 28;
125
126 if (sil_rev == 1)
127 /* PG 2.0, efuse may not be set. */
128 return MPUPLL_M_800;
129 else if (sil_rev >= 2) {
130 /* Check what the efuse says our max speed is. */
131 int efuse_arm_mpu_max_freq;
132 efuse_arm_mpu_max_freq = readl(&cdev->efuse_sma);
133 switch ((efuse_arm_mpu_max_freq & DEVICE_ID_MASK)) {
134 case AM335X_ZCZ_1000:
135 return MPUPLL_M_1000;
136 case AM335X_ZCZ_800:
137 return MPUPLL_M_800;
138 case AM335X_ZCZ_720:
139 return MPUPLL_M_720;
140 case AM335X_ZCZ_600:
141 case AM335X_ZCE_600:
142 return MPUPLL_M_600;
143 case AM335X_ZCZ_300:
144 case AM335X_ZCE_300:
145 return MPUPLL_M_300;
146 }
147 }
148
149 /* PG 1.0 or otherwise unknown, use the PG1.0 max */
150 return MPUPLL_M_720;
151}
152
153int am335x_get_tps65910_mpu_vdd(int sil_rev, int frequency)
154{
155 /* For PG2.1 and later, we have one set of values. */
156 if (sil_rev >= 2) {
157 switch (frequency) {
158 case MPUPLL_M_1000:
159 return TPS65910_OP_REG_SEL_1_3_2_5;
160 case MPUPLL_M_800:
161 return TPS65910_OP_REG_SEL_1_2_6;
162 case MPUPLL_M_720:
163 return TPS65910_OP_REG_SEL_1_2_0;
164 case MPUPLL_M_600:
165 case MPUPLL_M_300:
166 return TPS65910_OP_REG_SEL_1_1_3;
167 }
168 }
169
170 /* Default to PG1.0/PG2.0 values. */
171 return TPS65910_OP_REG_SEL_1_1_3;
172}
173#endif