blob: 5f535e2782770690c1de56a37e091a7c8c9bbca6 [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
14#include <common.h>
15#include <asm/io.h>
16#include <asm/arch/mem.h> /* get mem tables */
17#include <asm/arch/sys_proto.h>
Jeroen Hofstee2b562202014-10-08 22:57:57 +020018#include <asm/bootm.h>
Semen Protsenkoa8cb0222017-06-02 18:00:00 +030019#include <asm/omap_common.h>
Jeroen Hofstee2b562202014-10-08 22:57:57 +020020
Dirk Behmee0e49fe2008-12-14 09:47:15 +010021#include <i2c.h>
Nikita Kiryanov275c05a2012-01-05 02:03:22 +000022#include <linux/compiler.h>
Dirk Behmee0e49fe2008-12-14 09:47:15 +010023
24extern omap3_sysinfo sysinfo;
Dirk Behmedc7af202009-08-08 09:30:21 +020025static struct ctrl *ctrl_base = (struct ctrl *)OMAP34XX_CTRL_BASE;
Sanjeev Premi9659e3f2011-07-18 09:12:24 -040026
27#ifdef CONFIG_DISPLAY_CPUINFO
Sanjeev Premifcbb44f2009-04-27 21:27:54 +053028static char *rev_s[CPU_3XX_MAX_REV] = {
29 "1.0",
30 "2.0",
31 "2.1",
32 "3.0",
Steve Sakomanad74ace2010-08-17 14:39:34 -070033 "3.1",
34 "UNKNOWN",
35 "UNKNOWN",
36 "3.1.2"};
Dirk Behmee0e49fe2008-12-14 09:47:15 +010037
Howard D. Gray3082bc62011-09-04 14:11:17 -040038/* this is the revision table for 37xx CPUs */
39static char *rev_s_37xx[CPU_37XX_MAX_REV] = {
40 "1.0",
41 "1.1",
42 "1.2"};
Sanjeev Premi21614962011-09-23 05:29:45 +000043#endif /* CONFIG_DISPLAY_CPUINFO */
Howard D. Gray3082bc62011-09-04 14:11:17 -040044
Paul Kocialkowski290ba6d2015-08-27 19:37:09 +020045void omap_die_id(unsigned int *die_id)
Nishanth Menon346e34f2014-03-28 11:00:05 -050046{
47 struct ctrl_id *id_base = (struct ctrl_id *)OMAP34XX_ID_L4_IO_BASE;
48
Paul Kocialkowski290ba6d2015-08-27 19:37:09 +020049 die_id[0] = readl(&id_base->die_id_0);
50 die_id[1] = readl(&id_base->die_id_1);
51 die_id[2] = readl(&id_base->die_id_2);
52 die_id[3] = readl(&id_base->die_id_3);
Nishanth Menon346e34f2014-03-28 11:00:05 -050053}
54
Dirk Behmee0e49fe2008-12-14 09:47:15 +010055/******************************************
Dirk Behme2d0d4fa2009-02-12 18:55:42 +010056 * get_cpu_type(void) - extract cpu info
57 ******************************************/
Adam Forda9bcef72022-02-12 06:12:40 -060058static u32 get_cpu_type(void)
Dirk Behme2d0d4fa2009-02-12 18:55:42 +010059{
60 return readl(&ctrl_base->ctrl_omap_stat);
61}
62
63/******************************************
Steve Sakomanad74ace2010-08-17 14:39:34 -070064 * get_cpu_id(void) - extract cpu id
65 * returns 0 for ES1.0, cpuid otherwise
Dirk Behmee0e49fe2008-12-14 09:47:15 +010066 ******************************************/
Adam Forda9bcef72022-02-12 06:12:40 -060067static u32 get_cpu_id(void)
Dirk Behmee0e49fe2008-12-14 09:47:15 +010068{
Dirk Behmedc7af202009-08-08 09:30:21 +020069 struct ctrl_id *id_base;
Steve Sakomanad74ace2010-08-17 14:39:34 -070070 u32 cpuid = 0;
Dirk Behmee0e49fe2008-12-14 09:47:15 +010071
72 /*
73 * On ES1.0 the IDCODE register is not exposed on L4
Sanjeev Premifcbb44f2009-04-27 21:27:54 +053074 * so using CPU ID to differentiate between ES1.0 and > ES1.0.
Dirk Behmee0e49fe2008-12-14 09:47:15 +010075 */
76 __asm__ __volatile__("mrc p15, 0, %0, c0, c0, 0":"=r"(cpuid));
Steve Sakomanad74ace2010-08-17 14:39:34 -070077 if ((cpuid & 0xf) == 0x0) {
78 return 0;
79 } else {
Sanjeev Premifcbb44f2009-04-27 21:27:54 +053080 /* Decode the IDs on > ES1.0 */
Dirk Behmedc7af202009-08-08 09:30:21 +020081 id_base = (struct ctrl_id *) OMAP34XX_ID_L4_IO_BASE;
Dirk Behmee0e49fe2008-12-14 09:47:15 +010082
Steve Sakomanad74ace2010-08-17 14:39:34 -070083 cpuid = readl(&id_base->idcode);
84 }
85
86 return cpuid;
87}
88
89/******************************************
90 * get_cpu_family(void) - extract cpu info
91 ******************************************/
Adam Forda9bcef72022-02-12 06:12:40 -060092__used u32 get_cpu_family(void)
Steve Sakomanad74ace2010-08-17 14:39:34 -070093{
94 u16 hawkeye;
95 u32 cpu_family;
96 u32 cpuid = get_cpu_id();
Sanjeev Premifcbb44f2009-04-27 21:27:54 +053097
Steve Sakomanad74ace2010-08-17 14:39:34 -070098 if (cpuid == 0)
99 return CPU_OMAP34XX;
Sanjeev Premifcbb44f2009-04-27 21:27:54 +0530100
Steve Sakomanad74ace2010-08-17 14:39:34 -0700101 hawkeye = (cpuid >> HAWKEYE_SHIFT) & 0xffff;
102 switch (hawkeye) {
103 case HAWKEYE_OMAP34XX:
104 cpu_family = CPU_OMAP34XX;
105 break;
106 case HAWKEYE_AM35XX:
107 cpu_family = CPU_AM35XX;
108 break;
109 case HAWKEYE_OMAP36XX:
110 cpu_family = CPU_OMAP36XX;
111 break;
112 default:
113 cpu_family = CPU_OMAP34XX;
Sanjeev Premifcbb44f2009-04-27 21:27:54 +0530114 }
Steve Sakomanad74ace2010-08-17 14:39:34 -0700115
116 return cpu_family;
Dirk Behmee0e49fe2008-12-14 09:47:15 +0100117}
118
Steve Sakomanad74ace2010-08-17 14:39:34 -0700119/******************************************
120 * get_cpu_rev(void) - extract version info
121 ******************************************/
Adam Forda9bcef72022-02-12 06:12:40 -0600122__used u32 get_cpu_rev(void)
Steve Sakomanad74ace2010-08-17 14:39:34 -0700123{
124 u32 cpuid = get_cpu_id();
125
126 if (cpuid == 0)
127 return CPU_3XX_ES10;
128 else
129 return (cpuid >> CPU_3XX_ID_SHIFT) & 0xf;
130}
131
132/*****************************************************************
133 * get_sku_id(void) - read sku_id to get info on max clock rate
134 *****************************************************************/
Adam Forda9bcef72022-02-12 06:12:40 -0600135static u32 get_sku_id(void)
Steve Sakomanad74ace2010-08-17 14:39:34 -0700136{
137 struct ctrl_id *id_base = (struct ctrl_id *)OMAP34XX_ID_L4_IO_BASE;
138 return readl(&id_base->sku_id) & SKUID_CLK_MASK;
139}
140
Dirk Behmee0e49fe2008-12-14 09:47:15 +0100141/*************************************************************************
142 * get_board_rev() - setup to pass kernel board revision information
143 * returns:(bit[0-3] sub version, higher bit[7-4] is higher version)
144 *************************************************************************/
Paul Kocialkowski90553782015-07-16 15:10:20 +0200145#ifdef CONFIG_REVISION_TAG
Nikita Kiryanov275c05a2012-01-05 02:03:22 +0000146u32 __weak get_board_rev(void)
Dirk Behmee0e49fe2008-12-14 09:47:15 +0100147{
148 return 0x20;
149}
Paul Kocialkowski90553782015-07-16 15:10:20 +0200150#endif
Dirk Behmee0e49fe2008-12-14 09:47:15 +0100151
Dirk Behmee0e49fe2008-12-14 09:47:15 +0100152/********************************************************
153 * get_base(); get upper addr of current execution
154 *******************************************************/
Jeroen Hofsteecbc75622014-10-08 22:57:41 +0200155static u32 get_base(void)
Dirk Behmee0e49fe2008-12-14 09:47:15 +0100156{
157 u32 val;
158
159 __asm__ __volatile__("mov %0, pc \n":"=r"(val)::"memory");
160 val &= 0xF0000000;
161 val >>= 28;
162 return val;
163}
164
165/********************************************************
166 * is_running_in_flash() - tell if currently running in
167 * FLASH.
168 *******************************************************/
169u32 is_running_in_flash(void)
170{
171 if (get_base() < 4)
172 return 1; /* in FLASH */
173
174 return 0; /* running in SRAM or SDRAM */
175}
176
177/********************************************************
178 * is_running_in_sram() - tell if currently running in
179 * SRAM.
180 *******************************************************/
181u32 is_running_in_sram(void)
182{
183 if (get_base() == 4)
184 return 1; /* in SRAM */
185
186 return 0; /* running in FLASH or SDRAM */
187}
188
189/********************************************************
190 * is_running_in_sdram() - tell if currently running in
191 * SDRAM.
192 *******************************************************/
193u32 is_running_in_sdram(void)
194{
195 if (get_base() > 4)
196 return 1; /* in SDRAM */
197
198 return 0; /* running in SRAM or FLASH */
199}
200
201/***************************************************************
202 * get_boot_type() - Is this an XIP type device or a stream one
203 * bits 4-0 specify type. Bit 5 says mem/perif
204 ***************************************************************/
205u32 get_boot_type(void)
206{
207 return (readl(&ctrl_base->status) & SYSBOOT_MASK);
208}
209
Sanjeev Premie32ef2e2009-04-27 21:27:27 +0530210#ifdef CONFIG_DISPLAY_CPUINFO
211/**
212 * Print CPU information
213 */
214int print_cpuinfo (void)
215{
Steve Sakomanad74ace2010-08-17 14:39:34 -0700216 char *cpu_family_s, *cpu_s, *sec_s, *max_clk;
Sanjeev Premie32ef2e2009-04-27 21:27:27 +0530217
Steve Sakomanad74ace2010-08-17 14:39:34 -0700218 switch (get_cpu_family()) {
219 case CPU_OMAP34XX:
220 cpu_family_s = "OMAP";
221 switch (get_cpu_type()) {
222 case OMAP3503:
223 cpu_s = "3503";
224 break;
225 case OMAP3515:
226 cpu_s = "3515";
227 break;
228 case OMAP3525:
229 cpu_s = "3525";
230 break;
231 case OMAP3530:
232 cpu_s = "3530";
233 break;
234 default:
235 cpu_s = "35XX";
236 break;
237 }
238 if ((get_cpu_rev() >= CPU_3XX_ES31) &&
239 (get_sku_id() == SKUID_CLK_720MHZ))
man.huber@arcor.deb709cd12013-04-10 12:12:17 +0000240 max_clk = "720 MHz";
Steve Sakomanad74ace2010-08-17 14:39:34 -0700241 else
man.huber@arcor.deb709cd12013-04-10 12:12:17 +0000242 max_clk = "600 MHz";
Steve Sakomanad74ace2010-08-17 14:39:34 -0700243
Sanjeev Premie32ef2e2009-04-27 21:27:27 +0530244 break;
Steve Sakomanad74ace2010-08-17 14:39:34 -0700245 case CPU_AM35XX:
246 cpu_family_s = "AM";
247 switch (get_cpu_type()) {
248 case AM3505:
249 cpu_s = "3505";
250 break;
251 case AM3517:
252 cpu_s = "3517";
253 break;
254 default:
255 cpu_s = "35XX";
256 break;
257 }
Ladislav Michl120dbb22017-01-20 14:03:15 +0100258 max_clk = "600 MHz";
Sanjeev Premie32ef2e2009-04-27 21:27:27 +0530259 break;
Steve Sakomanad74ace2010-08-17 14:39:34 -0700260 case CPU_OMAP36XX:
Steve Sakomanad74ace2010-08-17 14:39:34 -0700261 switch (get_cpu_type()) {
Adam Forddbb9fda2017-01-20 14:03:52 +0100262 case AM3703:
263 cpu_family_s = "AM";
264 cpu_s = "3703";
265 max_clk = "800 MHz";
266 break;
267 case AM3703_1GHZ:
268 cpu_family_s = "AM";
269 cpu_s = "3703";
270 max_clk = "1 GHz";
271 break;
272 case AM3715:
273 cpu_family_s = "AM";
274 cpu_s = "3715";
275 max_clk = "800 MHz";
276 break;
277 case AM3715_1GHZ:
278 cpu_family_s = "AM";
279 cpu_s = "3715";
280 max_clk = "1 GHz";
281 break;
282 case OMAP3725:
283 cpu_family_s = "OMAP";
284 cpu_s = "3625/3725";
285 max_clk = "800 MHz";
286 break;
287 case OMAP3725_1GHZ:
288 cpu_family_s = "OMAP";
289 cpu_s = "3625/3725";
290 max_clk = "1 GHz";
291 break;
Steve Sakomanad74ace2010-08-17 14:39:34 -0700292 case OMAP3730:
Adam Forddbb9fda2017-01-20 14:03:52 +0100293 cpu_family_s = "OMAP";
Steve Sakomanad74ace2010-08-17 14:39:34 -0700294 cpu_s = "3630/3730";
Adam Forddbb9fda2017-01-20 14:03:52 +0100295 max_clk = "800 MHz";
296 break;
297 case OMAP3730_1GHZ:
298 cpu_family_s = "OMAP";
299 cpu_s = "3630/3730";
300 max_clk = "1 GHz";
Steve Sakomanad74ace2010-08-17 14:39:34 -0700301 break;
302 default:
Adam Forddbb9fda2017-01-20 14:03:52 +0100303 cpu_family_s = "OMAP/AM";
Steve Sakomanad74ace2010-08-17 14:39:34 -0700304 cpu_s = "36XX/37XX";
Adam Forddbb9fda2017-01-20 14:03:52 +0100305 max_clk = "1 GHz";
Steve Sakomanad74ace2010-08-17 14:39:34 -0700306 break;
307 }
Adam Forddbb9fda2017-01-20 14:03:52 +0100308
Sanjeev Premie32ef2e2009-04-27 21:27:27 +0530309 break;
310 default:
Steve Sakomanad74ace2010-08-17 14:39:34 -0700311 cpu_family_s = "OMAP";
Sanjeev Premie32ef2e2009-04-27 21:27:27 +0530312 cpu_s = "35XX";
Ladislav Michl120dbb22017-01-20 14:03:15 +0100313 max_clk = "600 MHz";
Sanjeev Premie32ef2e2009-04-27 21:27:27 +0530314 }
315
316 switch (get_device_type()) {
317 case TST_DEVICE:
318 sec_s = "TST";
319 break;
320 case EMU_DEVICE:
321 sec_s = "EMU";
322 break;
323 case HS_DEVICE:
324 sec_s = "HS";
325 break;
326 case GP_DEVICE:
327 sec_s = "GP";
328 break;
329 default:
330 sec_s = "?";
331 }
332
Howard D. Gray3082bc62011-09-04 14:11:17 -0400333 if (CPU_OMAP36XX == get_cpu_family())
Andreas Bießmann4738e362013-07-08 15:21:34 +0200334 printf("%s%s-%s ES%s, CPU-OPP2, L3-200MHz, Max CPU Clock %s\n",
335 cpu_family_s, cpu_s, sec_s,
336 rev_s_37xx[get_cpu_rev()], max_clk);
Howard D. Gray3082bc62011-09-04 14:11:17 -0400337 else
338 printf("%s%s-%s ES%s, CPU-OPP2, L3-165MHz, Max CPU Clock %s\n",
Steve Sakomanad74ace2010-08-17 14:39:34 -0700339 cpu_family_s, cpu_s, sec_s,
340 rev_s[get_cpu_rev()], max_clk);
Sanjeev Premie32ef2e2009-04-27 21:27:27 +0530341
342 return 0;
343}
344#endif /* CONFIG_DISPLAY_CPUINFO */