Jason Liu | 18936ee | 2011-11-25 00:18:01 +0000 | [diff] [blame] | 1 | /* |
| 2 | * (C) Copyright 2007 |
| 3 | * Sascha Hauer, Pengutronix |
| 4 | * |
| 5 | * (C) Copyright 2009 Freescale Semiconductor, Inc. |
| 6 | * |
Wolfgang Denk | 1a45966 | 2013-07-08 09:37:19 +0200 | [diff] [blame] | 7 | * SPDX-License-Identifier: GPL-2.0+ |
Jason Liu | 18936ee | 2011-11-25 00:18:01 +0000 | [diff] [blame] | 8 | */ |
| 9 | |
Jeroen Hofstee | 5624c6b | 2014-10-08 22:57:52 +0200 | [diff] [blame] | 10 | #include <bootm.h> |
Jason Liu | 18936ee | 2011-11-25 00:18:01 +0000 | [diff] [blame] | 11 | #include <common.h> |
Jeroen Hofstee | 5624c6b | 2014-10-08 22:57:52 +0200 | [diff] [blame] | 12 | #include <netdev.h> |
Masahiro Yamada | 1221ce4 | 2016-09-21 11:28:55 +0900 | [diff] [blame] | 13 | #include <linux/errno.h> |
Jason Liu | 18936ee | 2011-11-25 00:18:01 +0000 | [diff] [blame] | 14 | #include <asm/io.h> |
| 15 | #include <asm/arch/imx-regs.h> |
| 16 | #include <asm/arch/clock.h> |
| 17 | #include <asm/arch/sys_proto.h> |
Fabio Estevam | 6a37604 | 2012-04-29 08:11:13 +0000 | [diff] [blame] | 18 | #include <asm/arch/crm_regs.h> |
Peng Fan | 770611f | 2018-01-10 13:20:34 +0800 | [diff] [blame] | 19 | #include <asm/mach-imx/boot_mode.h> |
Tim Harvey | 70caa8e | 2015-05-18 06:56:46 -0700 | [diff] [blame] | 20 | #include <imx_thermal.h> |
Eric Nelson | e1eb75b | 2012-09-23 07:30:55 +0000 | [diff] [blame] | 21 | #include <ipu_pixfmt.h> |
Ye.Li | 7a26416 | 2014-11-20 21:14:14 +0800 | [diff] [blame] | 22 | #include <thermal.h> |
Nikita Kiryanov | 44b9841 | 2014-11-21 12:47:26 +0200 | [diff] [blame] | 23 | #include <sata.h> |
Jason Liu | 18936ee | 2011-11-25 00:18:01 +0000 | [diff] [blame] | 24 | |
| 25 | #ifdef CONFIG_FSL_ESDHC |
| 26 | #include <fsl_esdhc.h> |
| 27 | #endif |
| 28 | |
Anatolij Gustschin | 38df370 | 2017-08-28 21:46:26 +0200 | [diff] [blame] | 29 | #if defined(CONFIG_DISPLAY_CPUINFO) && !defined(CONFIG_SPL_BUILD) |
Eric Nelson | 11c2e50 | 2015-02-15 14:37:21 -0700 | [diff] [blame] | 30 | static u32 reset_cause = -1; |
| 31 | |
| 32 | static char *get_reset_cause(void) |
Jason Liu | 18936ee | 2011-11-25 00:18:01 +0000 | [diff] [blame] | 33 | { |
| 34 | u32 cause; |
| 35 | struct src *src_regs = (struct src *)SRC_BASE_ADDR; |
| 36 | |
| 37 | cause = readl(&src_regs->srsr); |
| 38 | writel(cause, &src_regs->srsr); |
Eric Nelson | 11c2e50 | 2015-02-15 14:37:21 -0700 | [diff] [blame] | 39 | reset_cause = cause; |
Jason Liu | 18936ee | 2011-11-25 00:18:01 +0000 | [diff] [blame] | 40 | |
| 41 | switch (cause) { |
| 42 | case 0x00001: |
Fabio Estevam | cece262 | 2012-03-13 07:26:48 +0000 | [diff] [blame] | 43 | case 0x00011: |
Jason Liu | 18936ee | 2011-11-25 00:18:01 +0000 | [diff] [blame] | 44 | return "POR"; |
| 45 | case 0x00004: |
| 46 | return "CSU"; |
| 47 | case 0x00008: |
| 48 | return "IPP USER"; |
| 49 | case 0x00010: |
Adrian Alonso | cd562c8 | 2015-09-02 13:54:23 -0500 | [diff] [blame] | 50 | #ifdef CONFIG_MX7 |
| 51 | return "WDOG1"; |
| 52 | #else |
Jason Liu | 18936ee | 2011-11-25 00:18:01 +0000 | [diff] [blame] | 53 | return "WDOG"; |
Adrian Alonso | cd562c8 | 2015-09-02 13:54:23 -0500 | [diff] [blame] | 54 | #endif |
Jason Liu | 18936ee | 2011-11-25 00:18:01 +0000 | [diff] [blame] | 55 | case 0x00020: |
| 56 | return "JTAG HIGH-Z"; |
| 57 | case 0x00040: |
| 58 | return "JTAG SW"; |
Adrian Alonso | cd562c8 | 2015-09-02 13:54:23 -0500 | [diff] [blame] | 59 | case 0x00080: |
| 60 | return "WDOG3"; |
| 61 | #ifdef CONFIG_MX7 |
| 62 | case 0x00100: |
| 63 | return "WDOG4"; |
| 64 | case 0x00200: |
| 65 | return "TEMPSENSE"; |
Peng Fan | 7537e93 | 2018-01-10 13:20:25 +0800 | [diff] [blame] | 66 | #elif defined(CONFIG_MX8M) |
| 67 | case 0x00100: |
| 68 | return "WDOG2"; |
| 69 | case 0x00200: |
| 70 | return "TEMPSENSE"; |
Adrian Alonso | cd562c8 | 2015-09-02 13:54:23 -0500 | [diff] [blame] | 71 | #else |
| 72 | case 0x00100: |
| 73 | return "TEMPSENSE"; |
Jason Liu | 18936ee | 2011-11-25 00:18:01 +0000 | [diff] [blame] | 74 | case 0x10000: |
| 75 | return "WARM BOOT"; |
Adrian Alonso | cd562c8 | 2015-09-02 13:54:23 -0500 | [diff] [blame] | 76 | #endif |
Jason Liu | 18936ee | 2011-11-25 00:18:01 +0000 | [diff] [blame] | 77 | default: |
| 78 | return "unknown reset"; |
| 79 | } |
| 80 | } |
| 81 | |
Eric Nelson | 11c2e50 | 2015-02-15 14:37:21 -0700 | [diff] [blame] | 82 | u32 get_imx_reset_cause(void) |
| 83 | { |
| 84 | return reset_cause; |
| 85 | } |
Prabhakar Kushwaha | 28420e7 | 2015-05-18 17:13:52 +0530 | [diff] [blame] | 86 | #endif |
Eric Nelson | 11c2e50 | 2015-02-15 14:37:21 -0700 | [diff] [blame] | 87 | |
Troy Kisky | eb0344d | 2012-10-23 10:57:48 +0000 | [diff] [blame] | 88 | #if defined(CONFIG_MX53) || defined(CONFIG_MX6) |
| 89 | #if defined(CONFIG_MX53) |
Eric Nelson | 3e9cbbb | 2013-11-08 16:50:53 -0700 | [diff] [blame] | 90 | #define MEMCTL_BASE ESDCTL_BASE_ADDR |
Troy Kisky | eb0344d | 2012-10-23 10:57:48 +0000 | [diff] [blame] | 91 | #else |
Eric Nelson | 3e9cbbb | 2013-11-08 16:50:53 -0700 | [diff] [blame] | 92 | #define MEMCTL_BASE MMDC_P0_BASE_ADDR |
Troy Kisky | eb0344d | 2012-10-23 10:57:48 +0000 | [diff] [blame] | 93 | #endif |
| 94 | static const unsigned char col_lookup[] = {9, 10, 11, 8, 12, 9, 9, 9}; |
| 95 | static const unsigned char bank_lookup[] = {3, 2}; |
| 96 | |
Tim Harvey | b07161c | 2014-06-02 16:13:21 -0700 | [diff] [blame] | 97 | /* these MMDC registers are common to the IMX53 and IMX6 */ |
Troy Kisky | eb0344d | 2012-10-23 10:57:48 +0000 | [diff] [blame] | 98 | struct esd_mmdc_regs { |
| 99 | uint32_t ctl; |
| 100 | uint32_t pdc; |
| 101 | uint32_t otc; |
| 102 | uint32_t cfg0; |
| 103 | uint32_t cfg1; |
| 104 | uint32_t cfg2; |
| 105 | uint32_t misc; |
Troy Kisky | eb0344d | 2012-10-23 10:57:48 +0000 | [diff] [blame] | 106 | }; |
| 107 | |
| 108 | #define ESD_MMDC_CTL_GET_ROW(mdctl) ((ctl >> 24) & 7) |
| 109 | #define ESD_MMDC_CTL_GET_COLUMN(mdctl) ((ctl >> 20) & 7) |
| 110 | #define ESD_MMDC_CTL_GET_WIDTH(mdctl) ((ctl >> 16) & 3) |
| 111 | #define ESD_MMDC_CTL_GET_CS1(mdctl) ((ctl >> 30) & 1) |
| 112 | #define ESD_MMDC_MISC_GET_BANK(mdmisc) ((misc >> 5) & 1) |
| 113 | |
Tim Harvey | b07161c | 2014-06-02 16:13:21 -0700 | [diff] [blame] | 114 | /* |
| 115 | * imx_ddr_size - return size in bytes of DRAM according MMDC config |
| 116 | * The MMDC MDCTL register holds the number of bits for row, col, and data |
| 117 | * width and the MMDC MDMISC register holds the number of banks. Combine |
| 118 | * all these bits to determine the meme size the MMDC has been configured for |
| 119 | */ |
Troy Kisky | eb0344d | 2012-10-23 10:57:48 +0000 | [diff] [blame] | 120 | unsigned imx_ddr_size(void) |
| 121 | { |
| 122 | struct esd_mmdc_regs *mem = (struct esd_mmdc_regs *)MEMCTL_BASE; |
| 123 | unsigned ctl = readl(&mem->ctl); |
| 124 | unsigned misc = readl(&mem->misc); |
| 125 | int bits = 11 + 0 + 0 + 1; /* row + col + bank + width */ |
| 126 | |
| 127 | bits += ESD_MMDC_CTL_GET_ROW(ctl); |
| 128 | bits += col_lookup[ESD_MMDC_CTL_GET_COLUMN(ctl)]; |
| 129 | bits += bank_lookup[ESD_MMDC_MISC_GET_BANK(misc)]; |
| 130 | bits += ESD_MMDC_CTL_GET_WIDTH(ctl); |
| 131 | bits += ESD_MMDC_CTL_GET_CS1(ctl); |
Marek Vasut | fcfdfdd | 2014-08-04 01:47:09 +0200 | [diff] [blame] | 132 | |
| 133 | /* The MX6 can do only 3840 MiB of DRAM */ |
| 134 | if (bits == 32) |
| 135 | return 0xf0000000; |
| 136 | |
Troy Kisky | eb0344d | 2012-10-23 10:57:48 +0000 | [diff] [blame] | 137 | return 1 << bits; |
| 138 | } |
| 139 | #endif |
| 140 | |
Anatolij Gustschin | 38df370 | 2017-08-28 21:46:26 +0200 | [diff] [blame] | 141 | #if defined(CONFIG_DISPLAY_CPUINFO) && !defined(CONFIG_SPL_BUILD) |
Fabio Estevam | a768386 | 2012-03-20 04:21:45 +0000 | [diff] [blame] | 142 | |
Troy Kisky | 20332a0 | 2012-10-23 10:57:46 +0000 | [diff] [blame] | 143 | const char *get_imx_type(u32 imxtype) |
Fabio Estevam | a768386 | 2012-03-20 04:21:45 +0000 | [diff] [blame] | 144 | { |
| 145 | switch (imxtype) { |
Peng Fan | 7537e93 | 2018-01-10 13:20:25 +0800 | [diff] [blame] | 146 | case MXC_CPU_MX8MQ: |
| 147 | return "8MQ"; /* Quad-core version of the mx8m */ |
Fabio Estevam | e25a065 | 2016-02-28 12:33:17 -0300 | [diff] [blame] | 148 | case MXC_CPU_MX7S: |
Stefan Agner | 249092f | 2016-05-06 11:21:50 -0700 | [diff] [blame] | 149 | return "7S"; /* Single-core version of the mx7 */ |
Adrian Alonso | cd562c8 | 2015-09-02 13:54:23 -0500 | [diff] [blame] | 150 | case MXC_CPU_MX7D: |
| 151 | return "7D"; /* Dual-core version of the mx7 */ |
Peng Fan | d0acd99 | 2015-07-11 11:38:42 +0800 | [diff] [blame] | 152 | case MXC_CPU_MX6QP: |
| 153 | return "6QP"; /* Quad-Plus version of the mx6 */ |
| 154 | case MXC_CPU_MX6DP: |
| 155 | return "6DP"; /* Dual-Plus version of the mx6 */ |
Troy Kisky | 20332a0 | 2012-10-23 10:57:46 +0000 | [diff] [blame] | 156 | case MXC_CPU_MX6Q: |
Fabio Estevam | a768386 | 2012-03-20 04:21:45 +0000 | [diff] [blame] | 157 | return "6Q"; /* Quad-core version of the mx6 */ |
Fabio Estevam | 94db665 | 2014-01-26 15:06:41 -0200 | [diff] [blame] | 158 | case MXC_CPU_MX6D: |
| 159 | return "6D"; /* Dual-core version of the mx6 */ |
Troy Kisky | 20332a0 | 2012-10-23 10:57:46 +0000 | [diff] [blame] | 160 | case MXC_CPU_MX6DL: |
| 161 | return "6DL"; /* Dual Lite version of the mx6 */ |
| 162 | case MXC_CPU_MX6SOLO: |
| 163 | return "6SOLO"; /* Solo version of the mx6 */ |
| 164 | case MXC_CPU_MX6SL: |
Fabio Estevam | a768386 | 2012-03-20 04:21:45 +0000 | [diff] [blame] | 165 | return "6SL"; /* Solo-Lite version of the mx6 */ |
Peng Fan | 7ce6d3c | 2016-12-11 19:24:20 +0800 | [diff] [blame] | 166 | case MXC_CPU_MX6SLL: |
| 167 | return "6SLL"; /* SLL version of the mx6 */ |
Fabio Estevam | 05d54b8 | 2014-06-24 17:40:58 -0300 | [diff] [blame] | 168 | case MXC_CPU_MX6SX: |
| 169 | return "6SX"; /* SoloX version of the mx6 */ |
Peng Fan | 8631c06 | 2015-07-20 19:28:21 +0800 | [diff] [blame] | 170 | case MXC_CPU_MX6UL: |
| 171 | return "6UL"; /* Ultra-Lite version of the mx6 */ |
Peng Fan | 65ce54b | 2016-08-11 14:02:38 +0800 | [diff] [blame] | 172 | case MXC_CPU_MX6ULL: |
| 173 | return "6ULL"; /* ULL version of the mx6 */ |
Troy Kisky | 20332a0 | 2012-10-23 10:57:46 +0000 | [diff] [blame] | 174 | case MXC_CPU_MX51: |
Fabio Estevam | a768386 | 2012-03-20 04:21:45 +0000 | [diff] [blame] | 175 | return "51"; |
Troy Kisky | 20332a0 | 2012-10-23 10:57:46 +0000 | [diff] [blame] | 176 | case MXC_CPU_MX53: |
Fabio Estevam | a768386 | 2012-03-20 04:21:45 +0000 | [diff] [blame] | 177 | return "53"; |
| 178 | default: |
Otavio Salvador | e972d72 | 2012-06-30 05:07:32 +0000 | [diff] [blame] | 179 | return "??"; |
Fabio Estevam | a768386 | 2012-03-20 04:21:45 +0000 | [diff] [blame] | 180 | } |
| 181 | } |
| 182 | |
Jason Liu | 18936ee | 2011-11-25 00:18:01 +0000 | [diff] [blame] | 183 | int print_cpuinfo(void) |
| 184 | { |
Stefano Babic | 943a3f2 | 2015-05-26 19:53:41 +0200 | [diff] [blame] | 185 | u32 cpurev; |
| 186 | __maybe_unused u32 max_freq; |
Jason Liu | 18936ee | 2011-11-25 00:18:01 +0000 | [diff] [blame] | 187 | |
| 188 | cpurev = get_cpu_rev(); |
Fabio Estevam | a768386 | 2012-03-20 04:21:45 +0000 | [diff] [blame] | 189 | |
Adrian Alonso | 1368f99 | 2015-09-02 13:54:13 -0500 | [diff] [blame] | 190 | #if defined(CONFIG_IMX_THERMAL) |
| 191 | struct udevice *thermal_dev; |
| 192 | int cpu_tmp, minc, maxc, ret; |
| 193 | |
Tim Harvey | b83ddac | 2015-05-18 07:02:25 -0700 | [diff] [blame] | 194 | printf("CPU: Freescale i.MX%s rev%d.%d", |
| 195 | get_imx_type((cpurev & 0xFF000) >> 12), |
| 196 | (cpurev & 0x000F0) >> 4, |
| 197 | (cpurev & 0x0000F) >> 0); |
| 198 | max_freq = get_cpu_speed_grade_hz(); |
| 199 | if (!max_freq || max_freq == mxc_get_clock(MXC_ARM_CLK)) { |
| 200 | printf(" at %dMHz\n", mxc_get_clock(MXC_ARM_CLK) / 1000000); |
| 201 | } else { |
| 202 | printf(" %d MHz (running at %d MHz)\n", max_freq / 1000000, |
| 203 | mxc_get_clock(MXC_ARM_CLK) / 1000000); |
| 204 | } |
| 205 | #else |
Fabio Estevam | a768386 | 2012-03-20 04:21:45 +0000 | [diff] [blame] | 206 | printf("CPU: Freescale i.MX%s rev%d.%d at %d MHz\n", |
| 207 | get_imx_type((cpurev & 0xFF000) >> 12), |
Jason Liu | 18936ee | 2011-11-25 00:18:01 +0000 | [diff] [blame] | 208 | (cpurev & 0x000F0) >> 4, |
| 209 | (cpurev & 0x0000F) >> 0, |
| 210 | mxc_get_clock(MXC_ARM_CLK) / 1000000); |
Tim Harvey | b83ddac | 2015-05-18 07:02:25 -0700 | [diff] [blame] | 211 | #endif |
Ye.Li | 7a26416 | 2014-11-20 21:14:14 +0800 | [diff] [blame] | 212 | |
Adrian Alonso | 1368f99 | 2015-09-02 13:54:13 -0500 | [diff] [blame] | 213 | #if defined(CONFIG_IMX_THERMAL) |
Tim Harvey | 70caa8e | 2015-05-18 06:56:46 -0700 | [diff] [blame] | 214 | puts("CPU: "); |
| 215 | switch (get_cpu_temp_grade(&minc, &maxc)) { |
| 216 | case TEMP_AUTOMOTIVE: |
| 217 | puts("Automotive temperature grade "); |
| 218 | break; |
| 219 | case TEMP_INDUSTRIAL: |
| 220 | puts("Industrial temperature grade "); |
| 221 | break; |
| 222 | case TEMP_EXTCOMMERCIAL: |
| 223 | puts("Extended Commercial temperature grade "); |
| 224 | break; |
| 225 | default: |
| 226 | puts("Commercial temperature grade "); |
| 227 | break; |
| 228 | } |
| 229 | printf("(%dC to %dC)", minc, maxc); |
Ye.Li | 7a26416 | 2014-11-20 21:14:14 +0800 | [diff] [blame] | 230 | ret = uclass_get_device(UCLASS_THERMAL, 0, &thermal_dev); |
| 231 | if (!ret) { |
| 232 | ret = thermal_get_temp(thermal_dev, &cpu_tmp); |
| 233 | |
| 234 | if (!ret) |
Tim Harvey | 70caa8e | 2015-05-18 06:56:46 -0700 | [diff] [blame] | 235 | printf(" at %dC\n", cpu_tmp); |
Ye.Li | 7a26416 | 2014-11-20 21:14:14 +0800 | [diff] [blame] | 236 | else |
Fabio Estevam | 3a384b4 | 2015-09-08 14:43:10 -0300 | [diff] [blame] | 237 | debug(" - invalid sensor data\n"); |
Ye.Li | 7a26416 | 2014-11-20 21:14:14 +0800 | [diff] [blame] | 238 | } else { |
Fabio Estevam | 3a384b4 | 2015-09-08 14:43:10 -0300 | [diff] [blame] | 239 | debug(" - invalid sensor device\n"); |
Ye.Li | 7a26416 | 2014-11-20 21:14:14 +0800 | [diff] [blame] | 240 | } |
| 241 | #endif |
| 242 | |
Jason Liu | 18936ee | 2011-11-25 00:18:01 +0000 | [diff] [blame] | 243 | printf("Reset cause: %s\n", get_reset_cause()); |
| 244 | return 0; |
| 245 | } |
| 246 | #endif |
| 247 | |
| 248 | int cpu_eth_init(bd_t *bis) |
| 249 | { |
| 250 | int rc = -ENODEV; |
| 251 | |
| 252 | #if defined(CONFIG_FEC_MXC) |
| 253 | rc = fecmxc_initialize(bis); |
| 254 | #endif |
| 255 | |
| 256 | return rc; |
| 257 | } |
| 258 | |
Benoît Thébaudeau | ecb0f31 | 2012-08-17 10:42:55 +0000 | [diff] [blame] | 259 | #ifdef CONFIG_FSL_ESDHC |
Jason Liu | 18936ee | 2011-11-25 00:18:01 +0000 | [diff] [blame] | 260 | /* |
| 261 | * Initializes on-chip MMC controllers. |
| 262 | * to override, implement board_mmc_init() |
| 263 | */ |
| 264 | int cpu_mmc_init(bd_t *bis) |
| 265 | { |
Jason Liu | 18936ee | 2011-11-25 00:18:01 +0000 | [diff] [blame] | 266 | return fsl_esdhc_mmc_init(bis); |
Jason Liu | 18936ee | 2011-11-25 00:18:01 +0000 | [diff] [blame] | 267 | } |
Benoît Thébaudeau | ecb0f31 | 2012-08-17 10:42:55 +0000 | [diff] [blame] | 268 | #endif |
Jason Liu | 18936ee | 2011-11-25 00:18:01 +0000 | [diff] [blame] | 269 | |
Peng Fan | 7537e93 | 2018-01-10 13:20:25 +0800 | [diff] [blame] | 270 | #if !(defined(CONFIG_MX7) || defined(CONFIG_MX8M)) |
Fabio Estevam | 6a37604 | 2012-04-29 08:11:13 +0000 | [diff] [blame] | 271 | u32 get_ahb_clk(void) |
| 272 | { |
| 273 | struct mxc_ccm_reg *imx_ccm = (struct mxc_ccm_reg *)CCM_BASE_ADDR; |
| 274 | u32 reg, ahb_podf; |
| 275 | |
| 276 | reg = __raw_readl(&imx_ccm->cbcdr); |
| 277 | reg &= MXC_CCM_CBCDR_AHB_PODF_MASK; |
| 278 | ahb_podf = reg >> MXC_CCM_CBCDR_AHB_PODF_OFFSET; |
| 279 | |
| 280 | return get_periph_clk() / (ahb_podf + 1); |
| 281 | } |
Adrian Alonso | cd562c8 | 2015-09-02 13:54:23 -0500 | [diff] [blame] | 282 | #endif |
Eric Nelson | e1eb75b | 2012-09-23 07:30:55 +0000 | [diff] [blame] | 283 | |
Eric Nelson | e1eb75b | 2012-09-23 07:30:55 +0000 | [diff] [blame] | 284 | void arch_preboot_os(void) |
| 285 | { |
Tim Harvey | 6ecbe13 | 2017-05-12 12:58:41 -0700 | [diff] [blame] | 286 | #if defined(CONFIG_PCIE_IMX) |
| 287 | imx_pcie_remove(); |
| 288 | #endif |
Simon Glass | 10e40d5 | 2017-06-14 21:28:25 -0600 | [diff] [blame] | 289 | #if defined(CONFIG_SATA) |
Simon Glass | 7e0712b | 2017-07-29 11:35:14 -0600 | [diff] [blame] | 290 | sata_remove(0); |
Soeren Moch | dd1c8f1 | 2014-11-27 10:11:41 +0100 | [diff] [blame] | 291 | #if defined(CONFIG_MX6) |
| 292 | disable_sata_clock(); |
| 293 | #endif |
Nikita Kiryanov | 44b9841 | 2014-11-21 12:47:26 +0200 | [diff] [blame] | 294 | #endif |
| 295 | #if defined(CONFIG_VIDEO_IPUV3) |
Eric Nelson | e1eb75b | 2012-09-23 07:30:55 +0000 | [diff] [blame] | 296 | /* disable video before launching O/S */ |
| 297 | ipuv3_fb_shutdown(); |
Eric Nelson | e1eb75b | 2012-09-23 07:30:55 +0000 | [diff] [blame] | 298 | #endif |
Peng Fan | 623787f | 2015-10-29 15:54:51 +0800 | [diff] [blame] | 299 | #if defined(CONFIG_VIDEO_MXS) |
| 300 | lcdif_power_down(); |
| 301 | #endif |
Nikita Kiryanov | 44b9841 | 2014-11-21 12:47:26 +0200 | [diff] [blame] | 302 | } |
Fabio Estevam | 32c81ea | 2014-11-14 11:27:21 -0200 | [diff] [blame] | 303 | |
Peng Fan | 7537e93 | 2018-01-10 13:20:25 +0800 | [diff] [blame] | 304 | #ifndef CONFIG_MX8M |
Fabio Estevam | 32c81ea | 2014-11-14 11:27:21 -0200 | [diff] [blame] | 305 | void set_chipselect_size(int const cs_size) |
| 306 | { |
| 307 | unsigned int reg; |
| 308 | struct iomuxc *iomuxc_regs = (struct iomuxc *)IOMUXC_BASE_ADDR; |
| 309 | reg = readl(&iomuxc_regs->gpr[1]); |
| 310 | |
| 311 | switch (cs_size) { |
| 312 | case CS0_128: |
| 313 | reg &= ~0x7; /* CS0=128MB, CS1=0, CS2=0, CS3=0 */ |
| 314 | reg |= 0x5; |
| 315 | break; |
| 316 | case CS0_64M_CS1_64M: |
| 317 | reg &= ~0x3F; /* CS0=64MB, CS1=64MB, CS2=0, CS3=0 */ |
| 318 | reg |= 0x1B; |
| 319 | break; |
| 320 | case CS0_64M_CS1_32M_CS2_32M: |
| 321 | reg &= ~0x1FF; /* CS0=64MB, CS1=32MB, CS2=32MB, CS3=0 */ |
| 322 | reg |= 0x4B; |
| 323 | break; |
| 324 | case CS0_32M_CS1_32M_CS2_32M_CS3_32M: |
| 325 | reg &= ~0xFFF; /* CS0=32MB, CS1=32MB, CS2=32MB, CS3=32MB */ |
| 326 | reg |= 0x249; |
| 327 | break; |
| 328 | default: |
| 329 | printf("Unknown chip select size: %d\n", cs_size); |
| 330 | break; |
| 331 | } |
| 332 | |
| 333 | writel(reg, &iomuxc_regs->gpr[1]); |
| 334 | } |
Peng Fan | 7537e93 | 2018-01-10 13:20:25 +0800 | [diff] [blame] | 335 | #endif |
Fabio Estevam | 4555c26 | 2017-11-27 10:25:09 -0200 | [diff] [blame] | 336 | |
Peng Fan | e56d9d7 | 2018-01-10 13:20:30 +0800 | [diff] [blame] | 337 | #if defined(CONFIG_MX7) || defined(CONFIG_MX8M) |
Peng Fan | 423e84b | 2018-01-10 13:20:29 +0800 | [diff] [blame] | 338 | /* |
| 339 | * OCOTP_TESTER3[9:8] (see Fusemap Description Table offset 0x440) |
| 340 | * defines a 2-bit SPEED_GRADING |
| 341 | */ |
| 342 | #define OCOTP_TESTER3_SPEED_SHIFT 8 |
Peng Fan | e56d9d7 | 2018-01-10 13:20:30 +0800 | [diff] [blame] | 343 | enum cpu_speed { |
| 344 | OCOTP_TESTER3_SPEED_GRADE0, |
| 345 | OCOTP_TESTER3_SPEED_GRADE1, |
| 346 | OCOTP_TESTER3_SPEED_GRADE2, |
| 347 | OCOTP_TESTER3_SPEED_GRADE3, |
| 348 | }; |
Peng Fan | 423e84b | 2018-01-10 13:20:29 +0800 | [diff] [blame] | 349 | |
| 350 | u32 get_cpu_speed_grade_hz(void) |
| 351 | { |
| 352 | struct ocotp_regs *ocotp = (struct ocotp_regs *)OCOTP_BASE_ADDR; |
| 353 | struct fuse_bank *bank = &ocotp->bank[1]; |
| 354 | struct fuse_bank1_regs *fuse = |
| 355 | (struct fuse_bank1_regs *)bank->fuse_regs; |
| 356 | uint32_t val; |
| 357 | |
| 358 | val = readl(&fuse->tester3); |
| 359 | val >>= OCOTP_TESTER3_SPEED_SHIFT; |
| 360 | val &= 0x3; |
| 361 | |
| 362 | switch(val) { |
Peng Fan | e56d9d7 | 2018-01-10 13:20:30 +0800 | [diff] [blame] | 363 | case OCOTP_TESTER3_SPEED_GRADE0: |
Peng Fan | 423e84b | 2018-01-10 13:20:29 +0800 | [diff] [blame] | 364 | return 800000000; |
Peng Fan | e56d9d7 | 2018-01-10 13:20:30 +0800 | [diff] [blame] | 365 | case OCOTP_TESTER3_SPEED_GRADE1: |
| 366 | return is_mx7() ? 500000000 : 1000000000; |
| 367 | case OCOTP_TESTER3_SPEED_GRADE2: |
| 368 | return is_mx7() ? 1000000000 : 1300000000; |
| 369 | case OCOTP_TESTER3_SPEED_GRADE3: |
| 370 | return is_mx7() ? 1200000000 : 1500000000; |
Peng Fan | 423e84b | 2018-01-10 13:20:29 +0800 | [diff] [blame] | 371 | } |
Peng Fan | e56d9d7 | 2018-01-10 13:20:30 +0800 | [diff] [blame] | 372 | |
Peng Fan | 423e84b | 2018-01-10 13:20:29 +0800 | [diff] [blame] | 373 | return 0; |
| 374 | } |
| 375 | |
| 376 | /* |
| 377 | * OCOTP_TESTER3[7:6] (see Fusemap Description Table offset 0x440) |
| 378 | * defines a 2-bit SPEED_GRADING |
| 379 | */ |
| 380 | #define OCOTP_TESTER3_TEMP_SHIFT 6 |
| 381 | |
| 382 | u32 get_cpu_temp_grade(int *minc, int *maxc) |
| 383 | { |
| 384 | struct ocotp_regs *ocotp = (struct ocotp_regs *)OCOTP_BASE_ADDR; |
| 385 | struct fuse_bank *bank = &ocotp->bank[1]; |
| 386 | struct fuse_bank1_regs *fuse = |
| 387 | (struct fuse_bank1_regs *)bank->fuse_regs; |
| 388 | uint32_t val; |
| 389 | |
| 390 | val = readl(&fuse->tester3); |
| 391 | val >>= OCOTP_TESTER3_TEMP_SHIFT; |
| 392 | val &= 0x3; |
| 393 | |
| 394 | if (minc && maxc) { |
| 395 | if (val == TEMP_AUTOMOTIVE) { |
| 396 | *minc = -40; |
| 397 | *maxc = 125; |
| 398 | } else if (val == TEMP_INDUSTRIAL) { |
| 399 | *minc = -40; |
| 400 | *maxc = 105; |
| 401 | } else if (val == TEMP_EXTCOMMERCIAL) { |
| 402 | *minc = -20; |
| 403 | *maxc = 105; |
| 404 | } else { |
| 405 | *minc = 0; |
| 406 | *maxc = 95; |
| 407 | } |
| 408 | } |
| 409 | return val; |
| 410 | } |
| 411 | #endif |
| 412 | |
Peng Fan | 80ebf86 | 2018-01-10 13:20:35 +0800 | [diff] [blame] | 413 | #if defined(CONFIG_MX7) || defined(CONFIG_MX8M) |
Peng Fan | 770611f | 2018-01-10 13:20:34 +0800 | [diff] [blame] | 414 | enum boot_device get_boot_device(void) |
| 415 | { |
| 416 | struct bootrom_sw_info **p = |
| 417 | (struct bootrom_sw_info **)(ulong)ROM_SW_INFO_ADDR; |
| 418 | |
| 419 | enum boot_device boot_dev = SD1_BOOT; |
| 420 | u8 boot_type = (*p)->boot_dev_type; |
| 421 | u8 boot_instance = (*p)->boot_dev_instance; |
| 422 | |
| 423 | switch (boot_type) { |
| 424 | case BOOT_TYPE_SD: |
| 425 | boot_dev = boot_instance + SD1_BOOT; |
| 426 | break; |
| 427 | case BOOT_TYPE_MMC: |
| 428 | boot_dev = boot_instance + MMC1_BOOT; |
| 429 | break; |
| 430 | case BOOT_TYPE_NAND: |
| 431 | boot_dev = NAND_BOOT; |
| 432 | break; |
| 433 | case BOOT_TYPE_QSPI: |
| 434 | boot_dev = QSPI_BOOT; |
| 435 | break; |
| 436 | case BOOT_TYPE_WEIM: |
| 437 | boot_dev = WEIM_NOR_BOOT; |
| 438 | break; |
| 439 | case BOOT_TYPE_SPINOR: |
| 440 | boot_dev = SPI_NOR_BOOT; |
| 441 | break; |
Peng Fan | 80ebf86 | 2018-01-10 13:20:35 +0800 | [diff] [blame] | 442 | #ifdef CONFIG_MX8M |
| 443 | case BOOT_TYPE_USB: |
| 444 | boot_dev = USB_BOOT; |
| 445 | break; |
| 446 | #endif |
Peng Fan | 770611f | 2018-01-10 13:20:34 +0800 | [diff] [blame] | 447 | default: |
| 448 | break; |
| 449 | } |
| 450 | |
| 451 | return boot_dev; |
| 452 | } |
| 453 | #endif |
| 454 | |
Fabio Estevam | 4555c26 | 2017-11-27 10:25:09 -0200 | [diff] [blame] | 455 | #ifdef CONFIG_NXP_BOARD_REVISION |
| 456 | int nxp_board_rev(void) |
| 457 | { |
| 458 | /* |
| 459 | * Get Board ID information from OCOTP_GP1[15:8] |
| 460 | * RevA: 0x1 |
| 461 | * RevB: 0x2 |
| 462 | * RevC: 0x3 |
| 463 | */ |
| 464 | struct ocotp_regs *ocotp = (struct ocotp_regs *)OCOTP_BASE_ADDR; |
| 465 | struct fuse_bank *bank = &ocotp->bank[4]; |
| 466 | struct fuse_bank4_regs *fuse = |
| 467 | (struct fuse_bank4_regs *)bank->fuse_regs; |
| 468 | |
| 469 | return (readl(&fuse->gp1) >> 8 & 0x0F); |
| 470 | } |
| 471 | |
| 472 | char nxp_board_rev_string(void) |
| 473 | { |
| 474 | const char *rev = "A"; |
| 475 | |
| 476 | return (*rev + nxp_board_rev() - 1); |
| 477 | } |
| 478 | #endif |