Tom Rini | 10e4779 | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
Dirk Behme | e0e49fe | 2008-12-14 09:47:15 +0100 | [diff] [blame] | 2 | /* |
| 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 Behme | e0e49fe | 2008-12-14 09:47:15 +0100 | [diff] [blame] | 12 | */ |
| 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 Hofstee | 2b56220 | 2014-10-08 22:57:57 +0200 | [diff] [blame] | 18 | #include <asm/bootm.h> |
Semen Protsenko | a8cb022 | 2017-06-02 18:00:00 +0300 | [diff] [blame] | 19 | #include <asm/omap_common.h> |
Jeroen Hofstee | 2b56220 | 2014-10-08 22:57:57 +0200 | [diff] [blame] | 20 | |
Dirk Behme | e0e49fe | 2008-12-14 09:47:15 +0100 | [diff] [blame] | 21 | #include <i2c.h> |
Nikita Kiryanov | 275c05a | 2012-01-05 02:03:22 +0000 | [diff] [blame] | 22 | #include <linux/compiler.h> |
Dirk Behme | e0e49fe | 2008-12-14 09:47:15 +0100 | [diff] [blame] | 23 | |
| 24 | extern omap3_sysinfo sysinfo; |
Dirk Behme | dc7af20 | 2009-08-08 09:30:21 +0200 | [diff] [blame] | 25 | static struct ctrl *ctrl_base = (struct ctrl *)OMAP34XX_CTRL_BASE; |
Sanjeev Premi | 9659e3f | 2011-07-18 09:12:24 -0400 | [diff] [blame] | 26 | |
| 27 | #ifdef CONFIG_DISPLAY_CPUINFO |
Sanjeev Premi | fcbb44f | 2009-04-27 21:27:54 +0530 | [diff] [blame] | 28 | static char *rev_s[CPU_3XX_MAX_REV] = { |
| 29 | "1.0", |
| 30 | "2.0", |
| 31 | "2.1", |
| 32 | "3.0", |
Steve Sakoman | ad74ace | 2010-08-17 14:39:34 -0700 | [diff] [blame] | 33 | "3.1", |
| 34 | "UNKNOWN", |
| 35 | "UNKNOWN", |
| 36 | "3.1.2"}; |
Dirk Behme | e0e49fe | 2008-12-14 09:47:15 +0100 | [diff] [blame] | 37 | |
Howard D. Gray | 3082bc6 | 2011-09-04 14:11:17 -0400 | [diff] [blame] | 38 | /* this is the revision table for 37xx CPUs */ |
| 39 | static char *rev_s_37xx[CPU_37XX_MAX_REV] = { |
| 40 | "1.0", |
| 41 | "1.1", |
| 42 | "1.2"}; |
Sanjeev Premi | 2161496 | 2011-09-23 05:29:45 +0000 | [diff] [blame] | 43 | #endif /* CONFIG_DISPLAY_CPUINFO */ |
Howard D. Gray | 3082bc6 | 2011-09-04 14:11:17 -0400 | [diff] [blame] | 44 | |
Paul Kocialkowski | 290ba6d | 2015-08-27 19:37:09 +0200 | [diff] [blame] | 45 | void omap_die_id(unsigned int *die_id) |
Nishanth Menon | 346e34f | 2014-03-28 11:00:05 -0500 | [diff] [blame] | 46 | { |
| 47 | struct ctrl_id *id_base = (struct ctrl_id *)OMAP34XX_ID_L4_IO_BASE; |
| 48 | |
Paul Kocialkowski | 290ba6d | 2015-08-27 19:37:09 +0200 | [diff] [blame] | 49 | 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 Menon | 346e34f | 2014-03-28 11:00:05 -0500 | [diff] [blame] | 53 | } |
| 54 | |
Dirk Behme | e0e49fe | 2008-12-14 09:47:15 +0100 | [diff] [blame] | 55 | /****************************************** |
Dirk Behme | 2d0d4fa | 2009-02-12 18:55:42 +0100 | [diff] [blame] | 56 | * get_cpu_type(void) - extract cpu info |
| 57 | ******************************************/ |
Adam Ford | a9bcef7 | 2022-02-12 06:12:40 -0600 | [diff] [blame] | 58 | static u32 get_cpu_type(void) |
Dirk Behme | 2d0d4fa | 2009-02-12 18:55:42 +0100 | [diff] [blame] | 59 | { |
| 60 | return readl(&ctrl_base->ctrl_omap_stat); |
| 61 | } |
| 62 | |
| 63 | /****************************************** |
Steve Sakoman | ad74ace | 2010-08-17 14:39:34 -0700 | [diff] [blame] | 64 | * get_cpu_id(void) - extract cpu id |
| 65 | * returns 0 for ES1.0, cpuid otherwise |
Dirk Behme | e0e49fe | 2008-12-14 09:47:15 +0100 | [diff] [blame] | 66 | ******************************************/ |
Adam Ford | a9bcef7 | 2022-02-12 06:12:40 -0600 | [diff] [blame] | 67 | static u32 get_cpu_id(void) |
Dirk Behme | e0e49fe | 2008-12-14 09:47:15 +0100 | [diff] [blame] | 68 | { |
Dirk Behme | dc7af20 | 2009-08-08 09:30:21 +0200 | [diff] [blame] | 69 | struct ctrl_id *id_base; |
Steve Sakoman | ad74ace | 2010-08-17 14:39:34 -0700 | [diff] [blame] | 70 | u32 cpuid = 0; |
Dirk Behme | e0e49fe | 2008-12-14 09:47:15 +0100 | [diff] [blame] | 71 | |
| 72 | /* |
| 73 | * On ES1.0 the IDCODE register is not exposed on L4 |
Sanjeev Premi | fcbb44f | 2009-04-27 21:27:54 +0530 | [diff] [blame] | 74 | * so using CPU ID to differentiate between ES1.0 and > ES1.0. |
Dirk Behme | e0e49fe | 2008-12-14 09:47:15 +0100 | [diff] [blame] | 75 | */ |
| 76 | __asm__ __volatile__("mrc p15, 0, %0, c0, c0, 0":"=r"(cpuid)); |
Steve Sakoman | ad74ace | 2010-08-17 14:39:34 -0700 | [diff] [blame] | 77 | if ((cpuid & 0xf) == 0x0) { |
| 78 | return 0; |
| 79 | } else { |
Sanjeev Premi | fcbb44f | 2009-04-27 21:27:54 +0530 | [diff] [blame] | 80 | /* Decode the IDs on > ES1.0 */ |
Dirk Behme | dc7af20 | 2009-08-08 09:30:21 +0200 | [diff] [blame] | 81 | id_base = (struct ctrl_id *) OMAP34XX_ID_L4_IO_BASE; |
Dirk Behme | e0e49fe | 2008-12-14 09:47:15 +0100 | [diff] [blame] | 82 | |
Steve Sakoman | ad74ace | 2010-08-17 14:39:34 -0700 | [diff] [blame] | 83 | cpuid = readl(&id_base->idcode); |
| 84 | } |
| 85 | |
| 86 | return cpuid; |
| 87 | } |
| 88 | |
| 89 | /****************************************** |
| 90 | * get_cpu_family(void) - extract cpu info |
| 91 | ******************************************/ |
Adam Ford | a9bcef7 | 2022-02-12 06:12:40 -0600 | [diff] [blame] | 92 | __used u32 get_cpu_family(void) |
Steve Sakoman | ad74ace | 2010-08-17 14:39:34 -0700 | [diff] [blame] | 93 | { |
| 94 | u16 hawkeye; |
| 95 | u32 cpu_family; |
| 96 | u32 cpuid = get_cpu_id(); |
Sanjeev Premi | fcbb44f | 2009-04-27 21:27:54 +0530 | [diff] [blame] | 97 | |
Steve Sakoman | ad74ace | 2010-08-17 14:39:34 -0700 | [diff] [blame] | 98 | if (cpuid == 0) |
| 99 | return CPU_OMAP34XX; |
Sanjeev Premi | fcbb44f | 2009-04-27 21:27:54 +0530 | [diff] [blame] | 100 | |
Steve Sakoman | ad74ace | 2010-08-17 14:39:34 -0700 | [diff] [blame] | 101 | 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 Premi | fcbb44f | 2009-04-27 21:27:54 +0530 | [diff] [blame] | 114 | } |
Steve Sakoman | ad74ace | 2010-08-17 14:39:34 -0700 | [diff] [blame] | 115 | |
| 116 | return cpu_family; |
Dirk Behme | e0e49fe | 2008-12-14 09:47:15 +0100 | [diff] [blame] | 117 | } |
| 118 | |
Steve Sakoman | ad74ace | 2010-08-17 14:39:34 -0700 | [diff] [blame] | 119 | /****************************************** |
| 120 | * get_cpu_rev(void) - extract version info |
| 121 | ******************************************/ |
Adam Ford | a9bcef7 | 2022-02-12 06:12:40 -0600 | [diff] [blame] | 122 | __used u32 get_cpu_rev(void) |
Steve Sakoman | ad74ace | 2010-08-17 14:39:34 -0700 | [diff] [blame] | 123 | { |
| 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 Ford | a9bcef7 | 2022-02-12 06:12:40 -0600 | [diff] [blame] | 135 | static u32 get_sku_id(void) |
Steve Sakoman | ad74ace | 2010-08-17 14:39:34 -0700 | [diff] [blame] | 136 | { |
| 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 Behme | e0e49fe | 2008-12-14 09:47:15 +0100 | [diff] [blame] | 141 | /************************************************************************* |
| 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 Kocialkowski | 9055378 | 2015-07-16 15:10:20 +0200 | [diff] [blame] | 145 | #ifdef CONFIG_REVISION_TAG |
Nikita Kiryanov | 275c05a | 2012-01-05 02:03:22 +0000 | [diff] [blame] | 146 | u32 __weak get_board_rev(void) |
Dirk Behme | e0e49fe | 2008-12-14 09:47:15 +0100 | [diff] [blame] | 147 | { |
| 148 | return 0x20; |
| 149 | } |
Paul Kocialkowski | 9055378 | 2015-07-16 15:10:20 +0200 | [diff] [blame] | 150 | #endif |
Dirk Behme | e0e49fe | 2008-12-14 09:47:15 +0100 | [diff] [blame] | 151 | |
Dirk Behme | e0e49fe | 2008-12-14 09:47:15 +0100 | [diff] [blame] | 152 | /******************************************************** |
| 153 | * get_base(); get upper addr of current execution |
| 154 | *******************************************************/ |
Jeroen Hofstee | cbc7562 | 2014-10-08 22:57:41 +0200 | [diff] [blame] | 155 | static u32 get_base(void) |
Dirk Behme | e0e49fe | 2008-12-14 09:47:15 +0100 | [diff] [blame] | 156 | { |
| 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 | *******************************************************/ |
| 169 | u32 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 | *******************************************************/ |
| 181 | u32 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 | *******************************************************/ |
| 193 | u32 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 | ***************************************************************/ |
| 205 | u32 get_boot_type(void) |
| 206 | { |
| 207 | return (readl(&ctrl_base->status) & SYSBOOT_MASK); |
| 208 | } |
| 209 | |
Sanjeev Premi | e32ef2e | 2009-04-27 21:27:27 +0530 | [diff] [blame] | 210 | #ifdef CONFIG_DISPLAY_CPUINFO |
| 211 | /** |
| 212 | * Print CPU information |
| 213 | */ |
| 214 | int print_cpuinfo (void) |
| 215 | { |
Steve Sakoman | ad74ace | 2010-08-17 14:39:34 -0700 | [diff] [blame] | 216 | char *cpu_family_s, *cpu_s, *sec_s, *max_clk; |
Sanjeev Premi | e32ef2e | 2009-04-27 21:27:27 +0530 | [diff] [blame] | 217 | |
Steve Sakoman | ad74ace | 2010-08-17 14:39:34 -0700 | [diff] [blame] | 218 | 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.de | b709cd1 | 2013-04-10 12:12:17 +0000 | [diff] [blame] | 240 | max_clk = "720 MHz"; |
Steve Sakoman | ad74ace | 2010-08-17 14:39:34 -0700 | [diff] [blame] | 241 | else |
man.huber@arcor.de | b709cd1 | 2013-04-10 12:12:17 +0000 | [diff] [blame] | 242 | max_clk = "600 MHz"; |
Steve Sakoman | ad74ace | 2010-08-17 14:39:34 -0700 | [diff] [blame] | 243 | |
Sanjeev Premi | e32ef2e | 2009-04-27 21:27:27 +0530 | [diff] [blame] | 244 | break; |
Steve Sakoman | ad74ace | 2010-08-17 14:39:34 -0700 | [diff] [blame] | 245 | 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 Michl | 120dbb2 | 2017-01-20 14:03:15 +0100 | [diff] [blame] | 258 | max_clk = "600 MHz"; |
Sanjeev Premi | e32ef2e | 2009-04-27 21:27:27 +0530 | [diff] [blame] | 259 | break; |
Steve Sakoman | ad74ace | 2010-08-17 14:39:34 -0700 | [diff] [blame] | 260 | case CPU_OMAP36XX: |
Steve Sakoman | ad74ace | 2010-08-17 14:39:34 -0700 | [diff] [blame] | 261 | switch (get_cpu_type()) { |
Adam Ford | dbb9fda | 2017-01-20 14:03:52 +0100 | [diff] [blame] | 262 | 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 Sakoman | ad74ace | 2010-08-17 14:39:34 -0700 | [diff] [blame] | 292 | case OMAP3730: |
Adam Ford | dbb9fda | 2017-01-20 14:03:52 +0100 | [diff] [blame] | 293 | cpu_family_s = "OMAP"; |
Steve Sakoman | ad74ace | 2010-08-17 14:39:34 -0700 | [diff] [blame] | 294 | cpu_s = "3630/3730"; |
Adam Ford | dbb9fda | 2017-01-20 14:03:52 +0100 | [diff] [blame] | 295 | 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 Sakoman | ad74ace | 2010-08-17 14:39:34 -0700 | [diff] [blame] | 301 | break; |
| 302 | default: |
Adam Ford | dbb9fda | 2017-01-20 14:03:52 +0100 | [diff] [blame] | 303 | cpu_family_s = "OMAP/AM"; |
Steve Sakoman | ad74ace | 2010-08-17 14:39:34 -0700 | [diff] [blame] | 304 | cpu_s = "36XX/37XX"; |
Adam Ford | dbb9fda | 2017-01-20 14:03:52 +0100 | [diff] [blame] | 305 | max_clk = "1 GHz"; |
Steve Sakoman | ad74ace | 2010-08-17 14:39:34 -0700 | [diff] [blame] | 306 | break; |
| 307 | } |
Adam Ford | dbb9fda | 2017-01-20 14:03:52 +0100 | [diff] [blame] | 308 | |
Sanjeev Premi | e32ef2e | 2009-04-27 21:27:27 +0530 | [diff] [blame] | 309 | break; |
| 310 | default: |
Steve Sakoman | ad74ace | 2010-08-17 14:39:34 -0700 | [diff] [blame] | 311 | cpu_family_s = "OMAP"; |
Sanjeev Premi | e32ef2e | 2009-04-27 21:27:27 +0530 | [diff] [blame] | 312 | cpu_s = "35XX"; |
Ladislav Michl | 120dbb2 | 2017-01-20 14:03:15 +0100 | [diff] [blame] | 313 | max_clk = "600 MHz"; |
Sanjeev Premi | e32ef2e | 2009-04-27 21:27:27 +0530 | [diff] [blame] | 314 | } |
| 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. Gray | 3082bc6 | 2011-09-04 14:11:17 -0400 | [diff] [blame] | 333 | if (CPU_OMAP36XX == get_cpu_family()) |
Andreas Bießmann | 4738e36 | 2013-07-08 15:21:34 +0200 | [diff] [blame] | 334 | 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. Gray | 3082bc6 | 2011-09-04 14:11:17 -0400 | [diff] [blame] | 337 | else |
| 338 | printf("%s%s-%s ES%s, CPU-OPP2, L3-165MHz, Max CPU Clock %s\n", |
Steve Sakoman | ad74ace | 2010-08-17 14:39:34 -0700 | [diff] [blame] | 339 | cpu_family_s, cpu_s, sec_s, |
| 340 | rev_s[get_cpu_rev()], max_clk); |
Sanjeev Premi | e32ef2e | 2009-04-27 21:27:27 +0530 | [diff] [blame] | 341 | |
| 342 | return 0; |
| 343 | } |
| 344 | #endif /* CONFIG_DISPLAY_CPUINFO */ |