blob: 1e3fcd5979680d5324d00ab5bce9abb47ab5a5a0 [file] [log] [blame]
Tom Rini10e47792018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
Dirk Behmee0e49fe2008-12-14 09:47:15 +01002/*
3 * (C) Copyright 2008
4 * Texas Instruments, <www.ti.com>
5 *
6 * Author :
7 * Manikandan Pillai <mani.pillai@ti.com>
8 *
9 * Derived from Beagle Board and 3430 SDP code by
10 * Richard Woodruff <r-woodruff2@ti.com>
11 * Syed Mohammed Khasim <khasim@ti.com>
Dirk Behmee0e49fe2008-12-14 09:47:15 +010012 */
13
Tom Riniefd9f332024-04-30 07:35:39 -060014#include <config.h>
Dirk Behmee0e49fe2008-12-14 09:47:15 +010015#include <asm/io.h>
16#include <asm/arch/mem.h> /* get mem tables */
Tom Riniefd9f332024-04-30 07:35:39 -060017#include <asm/arch/omap.h>
Dirk Behmee0e49fe2008-12-14 09:47:15 +010018#include <asm/arch/sys_proto.h>
Jeroen Hofstee2b562202014-10-08 22:57:57 +020019#include <asm/bootm.h>
Semen Protsenkoa8cb0222017-06-02 18:00:00 +030020#include <asm/omap_common.h>
Jeroen Hofstee2b562202014-10-08 22:57:57 +020021
Dirk Behmee0e49fe2008-12-14 09:47:15 +010022#include <i2c.h>
Nikita Kiryanov275c05a2012-01-05 02:03:22 +000023#include <linux/compiler.h>
Dirk Behmee0e49fe2008-12-14 09:47:15 +010024
25extern omap3_sysinfo sysinfo;
Dirk Behmedc7af202009-08-08 09:30:21 +020026static struct ctrl *ctrl_base = (struct ctrl *)OMAP34XX_CTRL_BASE;
Sanjeev Premi9659e3f2011-07-18 09:12:24 -040027
28#ifdef CONFIG_DISPLAY_CPUINFO
Sanjeev Premifcbb44f2009-04-27 21:27:54 +053029static char *rev_s[CPU_3XX_MAX_REV] = {
30 "1.0",
31 "2.0",
32 "2.1",
33 "3.0",
Steve Sakomanad74ace2010-08-17 14:39:34 -070034 "3.1",
35 "UNKNOWN",
36 "UNKNOWN",
37 "3.1.2"};
Dirk Behmee0e49fe2008-12-14 09:47:15 +010038
Howard D. Gray3082bc62011-09-04 14:11:17 -040039/* this is the revision table for 37xx CPUs */
40static char *rev_s_37xx[CPU_37XX_MAX_REV] = {
41 "1.0",
42 "1.1",
43 "1.2"};
Sanjeev Premi21614962011-09-23 05:29:45 +000044#endif /* CONFIG_DISPLAY_CPUINFO */
Howard D. Gray3082bc62011-09-04 14:11:17 -040045
Paul Kocialkowski290ba6d2015-08-27 19:37:09 +020046void omap_die_id(unsigned int *die_id)
Nishanth Menon346e34f2014-03-28 11:00:05 -050047{
48 struct ctrl_id *id_base = (struct ctrl_id *)OMAP34XX_ID_L4_IO_BASE;
49
Paul Kocialkowski290ba6d2015-08-27 19:37:09 +020050 die_id[0] = readl(&id_base->die_id_0);
51 die_id[1] = readl(&id_base->die_id_1);
52 die_id[2] = readl(&id_base->die_id_2);
53 die_id[3] = readl(&id_base->die_id_3);
Nishanth Menon346e34f2014-03-28 11:00:05 -050054}
55
Dirk Behmee0e49fe2008-12-14 09:47:15 +010056/******************************************
Dirk Behme2d0d4fa2009-02-12 18:55:42 +010057 * get_cpu_type(void) - extract cpu info
58 ******************************************/
Adam Forda9bcef72022-02-12 06:12:40 -060059static u32 get_cpu_type(void)
Dirk Behme2d0d4fa2009-02-12 18:55:42 +010060{
61 return readl(&ctrl_base->ctrl_omap_stat);
62}
63
64/******************************************
Steve Sakomanad74ace2010-08-17 14:39:34 -070065 * get_cpu_id(void) - extract cpu id
66 * returns 0 for ES1.0, cpuid otherwise
Dirk Behmee0e49fe2008-12-14 09:47:15 +010067 ******************************************/
Adam Forda9bcef72022-02-12 06:12:40 -060068static u32 get_cpu_id(void)
Dirk Behmee0e49fe2008-12-14 09:47:15 +010069{
Dirk Behmedc7af202009-08-08 09:30:21 +020070 struct ctrl_id *id_base;
Steve Sakomanad74ace2010-08-17 14:39:34 -070071 u32 cpuid = 0;
Dirk Behmee0e49fe2008-12-14 09:47:15 +010072
73 /*
74 * On ES1.0 the IDCODE register is not exposed on L4
Sanjeev Premifcbb44f2009-04-27 21:27:54 +053075 * so using CPU ID to differentiate between ES1.0 and > ES1.0.
Dirk Behmee0e49fe2008-12-14 09:47:15 +010076 */
77 __asm__ __volatile__("mrc p15, 0, %0, c0, c0, 0":"=r"(cpuid));
Steve Sakomanad74ace2010-08-17 14:39:34 -070078 if ((cpuid & 0xf) == 0x0) {
79 return 0;
80 } else {
Sanjeev Premifcbb44f2009-04-27 21:27:54 +053081 /* Decode the IDs on > ES1.0 */
Dirk Behmedc7af202009-08-08 09:30:21 +020082 id_base = (struct ctrl_id *) OMAP34XX_ID_L4_IO_BASE;
Dirk Behmee0e49fe2008-12-14 09:47:15 +010083
Steve Sakomanad74ace2010-08-17 14:39:34 -070084 cpuid = readl(&id_base->idcode);
85 }
86
87 return cpuid;
88}
89
90/******************************************
91 * get_cpu_family(void) - extract cpu info
92 ******************************************/
Adam Forda9bcef72022-02-12 06:12:40 -060093__used u32 get_cpu_family(void)
Steve Sakomanad74ace2010-08-17 14:39:34 -070094{
95 u16 hawkeye;
96 u32 cpu_family;
97 u32 cpuid = get_cpu_id();
Sanjeev Premifcbb44f2009-04-27 21:27:54 +053098
Steve Sakomanad74ace2010-08-17 14:39:34 -070099 if (cpuid == 0)
100 return CPU_OMAP34XX;
Sanjeev Premifcbb44f2009-04-27 21:27:54 +0530101
Steve Sakomanad74ace2010-08-17 14:39:34 -0700102 hawkeye = (cpuid >> HAWKEYE_SHIFT) & 0xffff;
103 switch (hawkeye) {
104 case HAWKEYE_OMAP34XX:
105 cpu_family = CPU_OMAP34XX;
106 break;
107 case HAWKEYE_AM35XX:
108 cpu_family = CPU_AM35XX;
109 break;
110 case HAWKEYE_OMAP36XX:
111 cpu_family = CPU_OMAP36XX;
112 break;
113 default:
114 cpu_family = CPU_OMAP34XX;
Sanjeev Premifcbb44f2009-04-27 21:27:54 +0530115 }
Steve Sakomanad74ace2010-08-17 14:39:34 -0700116
117 return cpu_family;
Dirk Behmee0e49fe2008-12-14 09:47:15 +0100118}
119
Steve Sakomanad74ace2010-08-17 14:39:34 -0700120/******************************************
121 * get_cpu_rev(void) - extract version info
122 ******************************************/
Adam Forda9bcef72022-02-12 06:12:40 -0600123__used u32 get_cpu_rev(void)
Steve Sakomanad74ace2010-08-17 14:39:34 -0700124{
125 u32 cpuid = get_cpu_id();
126
127 if (cpuid == 0)
128 return CPU_3XX_ES10;
129 else
130 return (cpuid >> CPU_3XX_ID_SHIFT) & 0xf;
131}
132
133/*****************************************************************
134 * get_sku_id(void) - read sku_id to get info on max clock rate
135 *****************************************************************/
Adam Forda9bcef72022-02-12 06:12:40 -0600136static u32 get_sku_id(void)
Steve Sakomanad74ace2010-08-17 14:39:34 -0700137{
138 struct ctrl_id *id_base = (struct ctrl_id *)OMAP34XX_ID_L4_IO_BASE;
139 return readl(&id_base->sku_id) & SKUID_CLK_MASK;
140}
141
Dirk Behmee0e49fe2008-12-14 09:47:15 +0100142/*************************************************************************
143 * get_board_rev() - setup to pass kernel board revision information
144 * returns:(bit[0-3] sub version, higher bit[7-4] is higher version)
145 *************************************************************************/
Paul Kocialkowski90553782015-07-16 15:10:20 +0200146#ifdef CONFIG_REVISION_TAG
Nikita Kiryanov275c05a2012-01-05 02:03:22 +0000147u32 __weak get_board_rev(void)
Dirk Behmee0e49fe2008-12-14 09:47:15 +0100148{
149 return 0x20;
150}
Paul Kocialkowski90553782015-07-16 15:10:20 +0200151#endif
Dirk Behmee0e49fe2008-12-14 09:47:15 +0100152
Dirk Behmee0e49fe2008-12-14 09:47:15 +0100153/********************************************************
154 * get_base(); get upper addr of current execution
155 *******************************************************/
Jeroen Hofsteecbc75622014-10-08 22:57:41 +0200156static u32 get_base(void)
Dirk Behmee0e49fe2008-12-14 09:47:15 +0100157{
158 u32 val;
159
160 __asm__ __volatile__("mov %0, pc \n":"=r"(val)::"memory");
161 val &= 0xF0000000;
162 val >>= 28;
163 return val;
164}
165
166/********************************************************
167 * is_running_in_flash() - tell if currently running in
168 * FLASH.
169 *******************************************************/
170u32 is_running_in_flash(void)
171{
172 if (get_base() < 4)
173 return 1; /* in FLASH */
174
175 return 0; /* running in SRAM or SDRAM */
176}
177
178/********************************************************
179 * is_running_in_sram() - tell if currently running in
180 * SRAM.
181 *******************************************************/
182u32 is_running_in_sram(void)
183{
184 if (get_base() == 4)
185 return 1; /* in SRAM */
186
187 return 0; /* running in FLASH or SDRAM */
188}
189
190/********************************************************
191 * is_running_in_sdram() - tell if currently running in
192 * SDRAM.
193 *******************************************************/
194u32 is_running_in_sdram(void)
195{
196 if (get_base() > 4)
197 return 1; /* in SDRAM */
198
199 return 0; /* running in SRAM or FLASH */
200}
201
202/***************************************************************
203 * get_boot_type() - Is this an XIP type device or a stream one
204 * bits 4-0 specify type. Bit 5 says mem/perif
205 ***************************************************************/
206u32 get_boot_type(void)
207{
208 return (readl(&ctrl_base->status) & SYSBOOT_MASK);
209}
210
Sanjeev Premie32ef2e2009-04-27 21:27:27 +0530211#ifdef CONFIG_DISPLAY_CPUINFO
212/**
213 * Print CPU information
214 */
215int print_cpuinfo (void)
216{
Steve Sakomanad74ace2010-08-17 14:39:34 -0700217 char *cpu_family_s, *cpu_s, *sec_s, *max_clk;
Sanjeev Premie32ef2e2009-04-27 21:27:27 +0530218
Steve Sakomanad74ace2010-08-17 14:39:34 -0700219 switch (get_cpu_family()) {
220 case CPU_OMAP34XX:
221 cpu_family_s = "OMAP";
222 switch (get_cpu_type()) {
223 case OMAP3503:
224 cpu_s = "3503";
225 break;
226 case OMAP3515:
227 cpu_s = "3515";
228 break;
229 case OMAP3525:
230 cpu_s = "3525";
231 break;
232 case OMAP3530:
233 cpu_s = "3530";
234 break;
235 default:
236 cpu_s = "35XX";
237 break;
238 }
239 if ((get_cpu_rev() >= CPU_3XX_ES31) &&
240 (get_sku_id() == SKUID_CLK_720MHZ))
man.huber@arcor.deb709cd12013-04-10 12:12:17 +0000241 max_clk = "720 MHz";
Steve Sakomanad74ace2010-08-17 14:39:34 -0700242 else
man.huber@arcor.deb709cd12013-04-10 12:12:17 +0000243 max_clk = "600 MHz";
Steve Sakomanad74ace2010-08-17 14:39:34 -0700244
Sanjeev Premie32ef2e2009-04-27 21:27:27 +0530245 break;
Steve Sakomanad74ace2010-08-17 14:39:34 -0700246 case CPU_AM35XX:
247 cpu_family_s = "AM";
248 switch (get_cpu_type()) {
249 case AM3505:
250 cpu_s = "3505";
251 break;
252 case AM3517:
253 cpu_s = "3517";
254 break;
255 default:
256 cpu_s = "35XX";
257 break;
258 }
Ladislav Michl120dbb22017-01-20 14:03:15 +0100259 max_clk = "600 MHz";
Sanjeev Premie32ef2e2009-04-27 21:27:27 +0530260 break;
Steve Sakomanad74ace2010-08-17 14:39:34 -0700261 case CPU_OMAP36XX:
Steve Sakomanad74ace2010-08-17 14:39:34 -0700262 switch (get_cpu_type()) {
Adam Forddbb9fda2017-01-20 14:03:52 +0100263 case AM3703:
264 cpu_family_s = "AM";
265 cpu_s = "3703";
266 max_clk = "800 MHz";
267 break;
268 case AM3703_1GHZ:
269 cpu_family_s = "AM";
270 cpu_s = "3703";
271 max_clk = "1 GHz";
272 break;
273 case AM3715:
274 cpu_family_s = "AM";
275 cpu_s = "3715";
276 max_clk = "800 MHz";
277 break;
278 case AM3715_1GHZ:
279 cpu_family_s = "AM";
280 cpu_s = "3715";
281 max_clk = "1 GHz";
282 break;
283 case OMAP3725:
284 cpu_family_s = "OMAP";
285 cpu_s = "3625/3725";
286 max_clk = "800 MHz";
287 break;
288 case OMAP3725_1GHZ:
289 cpu_family_s = "OMAP";
290 cpu_s = "3625/3725";
291 max_clk = "1 GHz";
292 break;
Steve Sakomanad74ace2010-08-17 14:39:34 -0700293 case OMAP3730:
Adam Forddbb9fda2017-01-20 14:03:52 +0100294 cpu_family_s = "OMAP";
Steve Sakomanad74ace2010-08-17 14:39:34 -0700295 cpu_s = "3630/3730";
Adam Forddbb9fda2017-01-20 14:03:52 +0100296 max_clk = "800 MHz";
297 break;
298 case OMAP3730_1GHZ:
299 cpu_family_s = "OMAP";
300 cpu_s = "3630/3730";
301 max_clk = "1 GHz";
Steve Sakomanad74ace2010-08-17 14:39:34 -0700302 break;
303 default:
Adam Forddbb9fda2017-01-20 14:03:52 +0100304 cpu_family_s = "OMAP/AM";
Steve Sakomanad74ace2010-08-17 14:39:34 -0700305 cpu_s = "36XX/37XX";
Adam Forddbb9fda2017-01-20 14:03:52 +0100306 max_clk = "1 GHz";
Steve Sakomanad74ace2010-08-17 14:39:34 -0700307 break;
308 }
Adam Forddbb9fda2017-01-20 14:03:52 +0100309
Sanjeev Premie32ef2e2009-04-27 21:27:27 +0530310 break;
311 default:
Steve Sakomanad74ace2010-08-17 14:39:34 -0700312 cpu_family_s = "OMAP";
Sanjeev Premie32ef2e2009-04-27 21:27:27 +0530313 cpu_s = "35XX";
Ladislav Michl120dbb22017-01-20 14:03:15 +0100314 max_clk = "600 MHz";
Sanjeev Premie32ef2e2009-04-27 21:27:27 +0530315 }
316
317 switch (get_device_type()) {
318 case TST_DEVICE:
319 sec_s = "TST";
320 break;
321 case EMU_DEVICE:
322 sec_s = "EMU";
323 break;
324 case HS_DEVICE:
325 sec_s = "HS";
326 break;
327 case GP_DEVICE:
328 sec_s = "GP";
329 break;
330 default:
331 sec_s = "?";
332 }
333
Howard D. Gray3082bc62011-09-04 14:11:17 -0400334 if (CPU_OMAP36XX == get_cpu_family())
Andreas Bießmann4738e362013-07-08 15:21:34 +0200335 printf("%s%s-%s ES%s, CPU-OPP2, L3-200MHz, Max CPU Clock %s\n",
336 cpu_family_s, cpu_s, sec_s,
337 rev_s_37xx[get_cpu_rev()], max_clk);
Howard D. Gray3082bc62011-09-04 14:11:17 -0400338 else
339 printf("%s%s-%s ES%s, CPU-OPP2, L3-165MHz, Max CPU Clock %s\n",
Steve Sakomanad74ace2010-08-17 14:39:34 -0700340 cpu_family_s, cpu_s, sec_s,
341 rev_s[get_cpu_rev()], max_clk);
Sanjeev Premie32ef2e2009-04-27 21:27:27 +0530342
343 return 0;
344}
345#endif /* CONFIG_DISPLAY_CPUINFO */