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