blob: c1e42095935d7285c333c2891125ee1e8efe63d8 [file] [log] [blame]
Varun Wadekar28dcc212016-07-20 10:28:51 -07001/*
Anthony Zhou70262ef2017-03-22 14:37:04 +08002 * Copyright (c) 2016-2017, ARM Limited and Contributors. All rights reserved.
Varun Wadekar28dcc212016-07-20 10:28:51 -07003 *
dp-armfa3cf0b2017-05-03 09:38:09 +01004 * SPDX-License-Identifier: BSD-3-Clause
Varun Wadekar28dcc212016-07-20 10:28:51 -07005 */
6
7#include <arch_helpers.h>
Anthony Zhou70262ef2017-03-22 14:37:04 +08008#include <assert.h>
Antonio Nino Diaze0f90632018-12-14 00:18:21 +00009#include <lib/mmio.h>
Varun Wadekar28dcc212016-07-20 10:28:51 -070010#include <tegra_def.h>
11#include <tegra_platform.h>
12#include <tegra_private.h>
13
14/*******************************************************************************
15 * Tegra platforms
16 ******************************************************************************/
17typedef enum tegra_platform {
Anthony Zhou4408e882017-07-07 14:29:51 +080018 TEGRA_PLATFORM_SILICON = 0U,
Varun Wadekar28dcc212016-07-20 10:28:51 -070019 TEGRA_PLATFORM_QT,
20 TEGRA_PLATFORM_FPGA,
21 TEGRA_PLATFORM_EMULATION,
Anthony Zhou70262ef2017-03-22 14:37:04 +080022 TEGRA_PLATFORM_LINSIM,
23 TEGRA_PLATFORM_UNIT_FPGA,
24 TEGRA_PLATFORM_VIRT_DEV_KIT,
Varun Wadekar28dcc212016-07-20 10:28:51 -070025 TEGRA_PLATFORM_MAX,
26} tegra_platform_t;
27
28/*******************************************************************************
29 * Tegra macros defining all the SoC minor versions
30 ******************************************************************************/
Anthony Zhou70262ef2017-03-22 14:37:04 +080031#define TEGRA_MINOR_QT U(0)
32#define TEGRA_MINOR_FPGA U(1)
33#define TEGRA_MINOR_ASIM_QT U(2)
34#define TEGRA_MINOR_ASIM_LINSIM U(3)
35#define TEGRA_MINOR_DSIM_ASIM_LINSIM U(4)
36#define TEGRA_MINOR_UNIT_FPGA U(5)
37#define TEGRA_MINOR_VIRT_DEV_KIT U(6)
Varun Wadekar28dcc212016-07-20 10:28:51 -070038
39/*******************************************************************************
Anthony Zhou70262ef2017-03-22 14:37:04 +080040 * Tegra macros defining all the SoC pre_si_platform
41 ******************************************************************************/
42#define TEGRA_PRE_SI_QT U(1)
43#define TEGRA_PRE_SI_FPGA U(2)
44#define TEGRA_PRE_SI_UNIT_FPGA U(3)
45#define TEGRA_PRE_SI_ASIM_QT U(4)
46#define TEGRA_PRE_SI_ASIM_LINSIM U(5)
47#define TEGRA_PRE_SI_DSIM_ASIM_LINSIM U(6)
48#define TEGRA_PRE_SI_VDK U(8)
Varun Wadekar28dcc212016-07-20 10:28:51 -070049
Varun Wadekar28dcc212016-07-20 10:28:51 -070050/*
51 * Read the chip ID value
52 */
53static uint32_t tegra_get_chipid(void)
54{
55 return mmio_read_32(TEGRA_MISC_BASE + HARDWARE_REVISION_OFFSET);
56}
57
58/*
59 * Read the chip's major version from chip ID value
60 */
Varun Wadekarfc9b91e2017-03-10 09:53:37 -080061uint32_t tegra_get_chipid_major(void)
Varun Wadekar28dcc212016-07-20 10:28:51 -070062{
63 return (tegra_get_chipid() >> MAJOR_VERSION_SHIFT) & MAJOR_VERSION_MASK;
64}
65
66/*
67 * Read the chip's minor version from the chip ID value
68 */
Varun Wadekarfc9b91e2017-03-10 09:53:37 -080069uint32_t tegra_get_chipid_minor(void)
Varun Wadekar28dcc212016-07-20 10:28:51 -070070{
71 return (tegra_get_chipid() >> MINOR_VERSION_SHIFT) & MINOR_VERSION_MASK;
72}
73
Marvin Hsu589a7e12017-04-12 20:40:27 +080074/*
75 * Read the chip's pre_si_platform valus from the chip ID value
76 */
77static uint32_t tegra_get_chipid_pre_si_platform(void)
Varun Wadekar28dcc212016-07-20 10:28:51 -070078{
Marvin Hsu589a7e12017-04-12 20:40:27 +080079 return (tegra_get_chipid() >> PRE_SI_PLATFORM_SHIFT) & PRE_SI_PLATFORM_MASK;
80}
Varun Wadekar28dcc212016-07-20 10:28:51 -070081
Marvin Hsu589a7e12017-04-12 20:40:27 +080082bool tegra_chipid_is_t132(void)
83{
84 uint32_t chip_id = ((tegra_get_chipid() >> CHIP_ID_SHIFT) & CHIP_ID_MASK);
85
Anthony Zhou4408e882017-07-07 14:29:51 +080086 return (chip_id == TEGRA_CHIPID_TEGRA13);
Varun Wadekar28dcc212016-07-20 10:28:51 -070087}
88
Marvin Hsu589a7e12017-04-12 20:40:27 +080089bool tegra_chipid_is_t186(void)
Varun Wadekar28dcc212016-07-20 10:28:51 -070090{
91 uint32_t chip_id = (tegra_get_chipid() >> CHIP_ID_SHIFT) & CHIP_ID_MASK;
92
Marvin Hsu589a7e12017-04-12 20:40:27 +080093 return (chip_id == TEGRA_CHIPID_TEGRA18);
Varun Wadekar28dcc212016-07-20 10:28:51 -070094}
95
Marvin Hsu589a7e12017-04-12 20:40:27 +080096bool tegra_chipid_is_t210(void)
Varun Wadekarfdcdfe22017-04-13 14:12:49 -070097{
98 uint32_t chip_id = (tegra_get_chipid() >> CHIP_ID_SHIFT) & CHIP_ID_MASK;
99
Anthony Zhou4408e882017-07-07 14:29:51 +0800100 return (chip_id == TEGRA_CHIPID_TEGRA21);
Varun Wadekarfdcdfe22017-04-13 14:12:49 -0700101}
102
Marvin Hsu589a7e12017-04-12 20:40:27 +0800103bool tegra_chipid_is_t210_b01(void)
Anthony Zhou70262ef2017-03-22 14:37:04 +0800104{
Anthony Zhou4408e882017-07-07 14:29:51 +0800105 return (tegra_chipid_is_t210() && (tegra_get_chipid_major() == 0x2U));
Anthony Zhou70262ef2017-03-22 14:37:04 +0800106}
107
108/*
Varun Wadekar28dcc212016-07-20 10:28:51 -0700109 * Read the chip ID value and derive the platform
110 */
111static tegra_platform_t tegra_get_platform(void)
112{
Anthony Zhou70262ef2017-03-22 14:37:04 +0800113 uint32_t major, minor, pre_si_platform;
114 tegra_platform_t ret;
115
116 /* get the major/minor chip ID values */
117 major = tegra_get_chipid_major();
118 minor = tegra_get_chipid_minor();
119 pre_si_platform = tegra_get_chipid_pre_si_platform();
120
121 if (major == 0U) {
122 /*
123 * The minor version number is used by simulation platforms
124 */
125 switch (minor) {
126 /*
127 * Cadence's QuickTurn emulation system is a Solaris-based
128 * chip emulation system
129 */
130 case TEGRA_MINOR_QT:
131 case TEGRA_MINOR_ASIM_QT:
132 ret = TEGRA_PLATFORM_QT;
133 break;
134
135 /*
136 * FPGAs are used during early software/hardware development
137 */
138 case TEGRA_MINOR_FPGA:
139 ret = TEGRA_PLATFORM_FPGA;
140 break;
141 /*
142 * Linsim is a reconfigurable, clock-driven, mixed RTL/cmodel
143 * simulation framework.
144 */
145 case TEGRA_MINOR_ASIM_LINSIM:
146 case TEGRA_MINOR_DSIM_ASIM_LINSIM:
147 ret = TEGRA_PLATFORM_LINSIM;
148 break;
Varun Wadekar28dcc212016-07-20 10:28:51 -0700149
Anthony Zhou70262ef2017-03-22 14:37:04 +0800150 /*
151 * Unit FPGAs run the actual hardware block IP on the FPGA with
152 * the other parts of the system using Linsim.
153 */
154 case TEGRA_MINOR_UNIT_FPGA:
155 ret = TEGRA_PLATFORM_UNIT_FPGA;
156 break;
157 /*
158 * The Virtualizer Development Kit (VDK) is the standard chip
159 * development from Synopsis.
160 */
161 case TEGRA_MINOR_VIRT_DEV_KIT:
162 ret = TEGRA_PLATFORM_VIRT_DEV_KIT;
163 break;
Marvin Hsu589a7e12017-04-12 20:40:27 +0800164
Anthony Zhou70262ef2017-03-22 14:37:04 +0800165 default:
Anthony Zhou70262ef2017-03-22 14:37:04 +0800166 ret = TEGRA_PLATFORM_MAX;
167 break;
168 }
Varun Wadekar28dcc212016-07-20 10:28:51 -0700169
Anthony Zhou70262ef2017-03-22 14:37:04 +0800170 } else if (pre_si_platform > 0U) {
Varun Wadekar28dcc212016-07-20 10:28:51 -0700171
Anthony Zhou70262ef2017-03-22 14:37:04 +0800172 switch (pre_si_platform) {
173 /*
174 * Cadence's QuickTurn emulation system is a Solaris-based
175 * chip emulation system
176 */
177 case TEGRA_PRE_SI_QT:
178 case TEGRA_PRE_SI_ASIM_QT:
179 ret = TEGRA_PLATFORM_QT;
180 break;
Varun Wadekar28dcc212016-07-20 10:28:51 -0700181
Anthony Zhou70262ef2017-03-22 14:37:04 +0800182 /*
183 * FPGAs are used during early software/hardware development
184 */
185 case TEGRA_PRE_SI_FPGA:
186 ret = TEGRA_PLATFORM_FPGA;
187 break;
188 /*
189 * Linsim is a reconfigurable, clock-driven, mixed RTL/cmodel
190 * simulation framework.
191 */
192 case TEGRA_PRE_SI_ASIM_LINSIM:
193 case TEGRA_PRE_SI_DSIM_ASIM_LINSIM:
194 ret = TEGRA_PLATFORM_LINSIM;
195 break;
Varun Wadekar28dcc212016-07-20 10:28:51 -0700196
Anthony Zhou70262ef2017-03-22 14:37:04 +0800197 /*
198 * Unit FPGAs run the actual hardware block IP on the FPGA with
199 * the other parts of the system using Linsim.
200 */
201 case TEGRA_PRE_SI_UNIT_FPGA:
202 ret = TEGRA_PLATFORM_UNIT_FPGA;
203 break;
204 /*
205 * The Virtualizer Development Kit (VDK) is the standard chip
206 * development from Synopsis.
207 */
208 case TEGRA_PRE_SI_VDK:
209 ret = TEGRA_PLATFORM_VIRT_DEV_KIT;
210 break;
Varun Wadekar28dcc212016-07-20 10:28:51 -0700211
Anthony Zhou70262ef2017-03-22 14:37:04 +0800212 default:
Anthony Zhou70262ef2017-03-22 14:37:04 +0800213 ret = TEGRA_PLATFORM_MAX;
214 break;
215 }
216
217 } else {
218 /* Actual silicon platforms have a non-zero major version */
219 ret = TEGRA_PLATFORM_SILICON;
220 }
221
222 return ret;
223}
224
225bool tegra_platform_is_silicon(void)
226{
227 return ((tegra_get_platform() == TEGRA_PLATFORM_SILICON) ? true : false);
Varun Wadekar28dcc212016-07-20 10:28:51 -0700228}
229
Anthony Zhou70262ef2017-03-22 14:37:04 +0800230bool tegra_platform_is_qt(void)
Varun Wadekar28dcc212016-07-20 10:28:51 -0700231{
Anthony Zhou70262ef2017-03-22 14:37:04 +0800232 return ((tegra_get_platform() == TEGRA_PLATFORM_QT) ? true : false);
Varun Wadekar28dcc212016-07-20 10:28:51 -0700233}
234
Anthony Zhou70262ef2017-03-22 14:37:04 +0800235bool tegra_platform_is_linsim(void)
Varun Wadekar28dcc212016-07-20 10:28:51 -0700236{
Anthony Zhou70262ef2017-03-22 14:37:04 +0800237 tegra_platform_t plat = tegra_get_platform();
238
239 return (((plat == TEGRA_PLATFORM_LINSIM) ||
240 (plat == TEGRA_PLATFORM_UNIT_FPGA)) ? true : false);
Varun Wadekar28dcc212016-07-20 10:28:51 -0700241}
242
Anthony Zhou70262ef2017-03-22 14:37:04 +0800243bool tegra_platform_is_fpga(void)
Varun Wadekar28dcc212016-07-20 10:28:51 -0700244{
Anthony Zhou70262ef2017-03-22 14:37:04 +0800245 return ((tegra_get_platform() == TEGRA_PLATFORM_FPGA) ? true : false);
Varun Wadekar28dcc212016-07-20 10:28:51 -0700246}
247
Anthony Zhou70262ef2017-03-22 14:37:04 +0800248bool tegra_platform_is_emulation(void)
Varun Wadekar28dcc212016-07-20 10:28:51 -0700249{
250 return (tegra_get_platform() == TEGRA_PLATFORM_EMULATION);
251}
Anthony Zhou70262ef2017-03-22 14:37:04 +0800252
253bool tegra_platform_is_unit_fpga(void)
254{
255 return ((tegra_get_platform() == TEGRA_PLATFORM_UNIT_FPGA) ? true : false);
256}
257
258bool tegra_platform_is_virt_dev_kit(void)
259{
260 return ((tegra_get_platform() == TEGRA_PLATFORM_VIRT_DEV_KIT) ? true : false);
261}