blob: 468c2faf674582fefaf91dc58a282ff077fd7ba9 [file] [log] [blame]
Tom Rini10e47792018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
Jason Liu83aa8fe2011-11-25 00:18:01 +00002/*
3 * (C) Copyright 2007
4 * Sascha Hauer, Pengutronix
5 *
6 * (C) Copyright 2009 Freescale Semiconductor, Inc.
Jason Liu83aa8fe2011-11-25 00:18:01 +00007 */
8
Jeroen Hofstee1abf3a12014-10-08 22:57:52 +02009#include <bootm.h>
Jason Liu83aa8fe2011-11-25 00:18:01 +000010#include <common.h>
Simon Glass274e0b02020-05-10 11:39:56 -060011#include <net.h>
Jeroen Hofstee1abf3a12014-10-08 22:57:52 +020012#include <netdev.h>
Masahiro Yamada56a931c2016-09-21 11:28:55 +090013#include <linux/errno.h>
Jason Liu83aa8fe2011-11-25 00:18:01 +000014#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 Estevam6479f512012-04-29 08:11:13 +000018#include <asm/arch/crm_regs.h>
Peng Fand64a3c52018-01-10 13:20:34 +080019#include <asm/mach-imx/boot_mode.h>
Tim Harvey27f90592015-05-18 06:56:46 -070020#include <imx_thermal.h>
Eric Nelson54b3f3b2012-09-23 07:30:55 +000021#include <ipu_pixfmt.h>
Ye.Lif19692c2014-11-20 21:14:14 +080022#include <thermal.h>
Nikita Kiryanovb5c9ed32014-11-21 12:47:26 +020023#include <sata.h>
Jason Liu83aa8fe2011-11-25 00:18:01 +000024
Yangbo Lu73340382019-06-21 11:42:28 +080025#ifdef CONFIG_FSL_ESDHC_IMX
26#include <fsl_esdhc_imx.h>
Jason Liu83aa8fe2011-11-25 00:18:01 +000027#endif
28
Eric Nelson25e02302015-02-15 14:37:21 -070029static u32 reset_cause = -1;
30
Max Krummenachercb2c8fd2019-02-01 16:04:51 +010031u32 get_imx_reset_cause(void)
Jason Liu83aa8fe2011-11-25 00:18:01 +000032{
Jason Liu83aa8fe2011-11-25 00:18:01 +000033 struct src *src_regs = (struct src *)SRC_BASE_ADDR;
34
Max Krummenachercb2c8fd2019-02-01 16:04:51 +010035 if (reset_cause == -1) {
36 reset_cause = readl(&src_regs->srsr);
37/* preserve the value for U-Boot proper */
38#if !defined(CONFIG_SPL_BUILD)
39 writel(reset_cause, &src_regs->srsr);
40#endif
41 }
42
43 return reset_cause;
44}
Jason Liu83aa8fe2011-11-25 00:18:01 +000045
Max Krummenachercb2c8fd2019-02-01 16:04:51 +010046#if defined(CONFIG_DISPLAY_CPUINFO) && !defined(CONFIG_SPL_BUILD)
47static char *get_reset_cause(void)
48{
49 switch (get_imx_reset_cause()) {
Jason Liu83aa8fe2011-11-25 00:18:01 +000050 case 0x00001:
Fabio Estevam9af122b2012-03-13 07:26:48 +000051 case 0x00011:
Jason Liu83aa8fe2011-11-25 00:18:01 +000052 return "POR";
53 case 0x00004:
54 return "CSU";
55 case 0x00008:
56 return "IPP USER";
57 case 0x00010:
Adrian Alonso9f883e02015-09-02 13:54:23 -050058#ifdef CONFIG_MX7
59 return "WDOG1";
60#else
Jason Liu83aa8fe2011-11-25 00:18:01 +000061 return "WDOG";
Adrian Alonso9f883e02015-09-02 13:54:23 -050062#endif
Jason Liu83aa8fe2011-11-25 00:18:01 +000063 case 0x00020:
64 return "JTAG HIGH-Z";
65 case 0x00040:
66 return "JTAG SW";
Adrian Alonso9f883e02015-09-02 13:54:23 -050067 case 0x00080:
68 return "WDOG3";
69#ifdef CONFIG_MX7
70 case 0x00100:
71 return "WDOG4";
72 case 0x00200:
73 return "TEMPSENSE";
Peng Fan39945c12018-11-20 10:19:25 +000074#elif defined(CONFIG_IMX8M)
Peng Fana78e0ac2018-01-10 13:20:25 +080075 case 0x00100:
76 return "WDOG2";
77 case 0x00200:
78 return "TEMPSENSE";
Adrian Alonso9f883e02015-09-02 13:54:23 -050079#else
80 case 0x00100:
81 return "TEMPSENSE";
Jason Liu83aa8fe2011-11-25 00:18:01 +000082 case 0x10000:
83 return "WARM BOOT";
Adrian Alonso9f883e02015-09-02 13:54:23 -050084#endif
Jason Liu83aa8fe2011-11-25 00:18:01 +000085 default:
86 return "unknown reset";
87 }
88}
Prabhakar Kushwahaf2c19de2015-05-18 17:13:52 +053089#endif
Eric Nelson25e02302015-02-15 14:37:21 -070090
Anatolij Gustschin03dd9862017-08-28 21:46:26 +020091#if defined(CONFIG_DISPLAY_CPUINFO) && !defined(CONFIG_SPL_BUILD)
Fabio Estevam46e97332012-03-20 04:21:45 +000092
Troy Kisky58394932012-10-23 10:57:46 +000093const char *get_imx_type(u32 imxtype)
Fabio Estevam46e97332012-03-20 04:21:45 +000094{
95 switch (imxtype) {
Peng Fan69cec072019-12-27 10:14:02 +080096 case MXC_CPU_IMX8MP:
97 return "8MP"; /* Quad-core version of the imx8mp */
Peng Fan5d2f2062019-06-27 17:23:49 +080098 case MXC_CPU_IMX8MN:
Peng Fan1a07d912020-02-05 17:39:27 +080099 return "8MNano Quad"; /* Quad-core version */
100 case MXC_CPU_IMX8MND:
101 return "8MNano Dual"; /* Dual-core version */
102 case MXC_CPU_IMX8MNS:
103 return "8MNano Solo"; /* Single-core version */
104 case MXC_CPU_IMX8MNL:
105 return "8MNano QuadLite"; /* Quad-core Lite version */
106 case MXC_CPU_IMX8MNDL:
107 return "8MNano DualLite"; /* Dual-core Lite version */
108 case MXC_CPU_IMX8MNSL:
109 return "8MNano SoloLite"; /* Single-core Lite version */
Peng Fan2d22a992019-08-27 06:25:04 +0000110 case MXC_CPU_IMX8MM:
111 return "8MMQ"; /* Quad-core version of the imx8mm */
112 case MXC_CPU_IMX8MML:
113 return "8MMQL"; /* Quad-core Lite version of the imx8mm */
114 case MXC_CPU_IMX8MMD:
115 return "8MMD"; /* Dual-core version of the imx8mm */
116 case MXC_CPU_IMX8MMDL:
117 return "8MMDL"; /* Dual-core Lite version of the imx8mm */
118 case MXC_CPU_IMX8MMS:
119 return "8MMS"; /* Single-core version of the imx8mm */
120 case MXC_CPU_IMX8MMSL:
121 return "8MMSL"; /* Single-core Lite version of the imx8mm */
Peng Fan39945c12018-11-20 10:19:25 +0000122 case MXC_CPU_IMX8MQ:
Peng Fan67815082020-02-05 17:34:54 +0800123 return "8MQ"; /* Quad-core version of the imx8mq */
124 case MXC_CPU_IMX8MQL:
125 return "8MQLite"; /* Quad-core Lite version of the imx8mq */
126 case MXC_CPU_IMX8MD:
127 return "8MD"; /* Dual-core version of the imx8mq */
Fabio Estevamf6ced1b2016-02-28 12:33:17 -0300128 case MXC_CPU_MX7S:
Stefan Agnerf19a8e42016-05-06 11:21:50 -0700129 return "7S"; /* Single-core version of the mx7 */
Adrian Alonso9f883e02015-09-02 13:54:23 -0500130 case MXC_CPU_MX7D:
131 return "7D"; /* Dual-core version of the mx7 */
Peng Fan5f247922015-07-11 11:38:42 +0800132 case MXC_CPU_MX6QP:
133 return "6QP"; /* Quad-Plus version of the mx6 */
134 case MXC_CPU_MX6DP:
135 return "6DP"; /* Dual-Plus version of the mx6 */
Troy Kisky58394932012-10-23 10:57:46 +0000136 case MXC_CPU_MX6Q:
Fabio Estevam46e97332012-03-20 04:21:45 +0000137 return "6Q"; /* Quad-core version of the mx6 */
Fabio Estevamf3d5a2c2014-01-26 15:06:41 -0200138 case MXC_CPU_MX6D:
139 return "6D"; /* Dual-core version of the mx6 */
Troy Kisky58394932012-10-23 10:57:46 +0000140 case MXC_CPU_MX6DL:
141 return "6DL"; /* Dual Lite version of the mx6 */
142 case MXC_CPU_MX6SOLO:
143 return "6SOLO"; /* Solo version of the mx6 */
144 case MXC_CPU_MX6SL:
Fabio Estevam46e97332012-03-20 04:21:45 +0000145 return "6SL"; /* Solo-Lite version of the mx6 */
Peng Fan4cfd7972016-12-11 19:24:20 +0800146 case MXC_CPU_MX6SLL:
147 return "6SLL"; /* SLL version of the mx6 */
Fabio Estevam712ab882014-06-24 17:40:58 -0300148 case MXC_CPU_MX6SX:
149 return "6SX"; /* SoloX version of the mx6 */
Peng Faneaa53a12015-07-20 19:28:21 +0800150 case MXC_CPU_MX6UL:
151 return "6UL"; /* Ultra-Lite version of the mx6 */
Peng Fan3b33e3f2016-08-11 14:02:38 +0800152 case MXC_CPU_MX6ULL:
153 return "6ULL"; /* ULL version of the mx6 */
Peng Fanc53d0c92019-08-08 09:55:52 +0000154 case MXC_CPU_MX6ULZ:
155 return "6ULZ"; /* ULZ version of the mx6 */
Troy Kisky58394932012-10-23 10:57:46 +0000156 case MXC_CPU_MX51:
Fabio Estevam46e97332012-03-20 04:21:45 +0000157 return "51";
Troy Kisky58394932012-10-23 10:57:46 +0000158 case MXC_CPU_MX53:
Fabio Estevam46e97332012-03-20 04:21:45 +0000159 return "53";
160 default:
Otavio Salvador8567d7d2012-06-30 05:07:32 +0000161 return "??";
Fabio Estevam46e97332012-03-20 04:21:45 +0000162 }
163}
164
Jason Liu83aa8fe2011-11-25 00:18:01 +0000165int print_cpuinfo(void)
166{
Stefano Babic40adacc2015-05-26 19:53:41 +0200167 u32 cpurev;
168 __maybe_unused u32 max_freq;
Jason Liu83aa8fe2011-11-25 00:18:01 +0000169
Adrian Alonsoce08c362015-09-02 13:54:13 -0500170 cpurev = get_cpu_rev();
171
Peng Fan0df2e032020-05-03 22:19:57 +0800172#if defined(CONFIG_IMX_THERMAL) || defined(CONFIG_IMX_TMU)
Ye.Lif19692c2014-11-20 21:14:14 +0800173 struct udevice *thermal_dev;
Tim Harvey27f90592015-05-18 06:56:46 -0700174 int cpu_tmp, minc, maxc, ret;
Ye.Lif19692c2014-11-20 21:14:14 +0800175
Tim Harveyd792ede2015-05-18 07:02:25 -0700176 printf("CPU: Freescale i.MX%s rev%d.%d",
Peng Fan41b517212019-12-30 17:57:10 +0800177 get_imx_type((cpurev & 0x1FF000) >> 12),
Tim Harveyd792ede2015-05-18 07:02:25 -0700178 (cpurev & 0x000F0) >> 4,
179 (cpurev & 0x0000F) >> 0);
180 max_freq = get_cpu_speed_grade_hz();
181 if (!max_freq || max_freq == mxc_get_clock(MXC_ARM_CLK)) {
182 printf(" at %dMHz\n", mxc_get_clock(MXC_ARM_CLK) / 1000000);
183 } else {
184 printf(" %d MHz (running at %d MHz)\n", max_freq / 1000000,
185 mxc_get_clock(MXC_ARM_CLK) / 1000000);
186 }
187#else
Fabio Estevam46e97332012-03-20 04:21:45 +0000188 printf("CPU: Freescale i.MX%s rev%d.%d at %d MHz\n",
Peng Fan41b517212019-12-30 17:57:10 +0800189 get_imx_type((cpurev & 0x1FF000) >> 12),
Jason Liu83aa8fe2011-11-25 00:18:01 +0000190 (cpurev & 0x000F0) >> 4,
191 (cpurev & 0x0000F) >> 0,
192 mxc_get_clock(MXC_ARM_CLK) / 1000000);
Tim Harveyd792ede2015-05-18 07:02:25 -0700193#endif
Ye.Lif19692c2014-11-20 21:14:14 +0800194
Peng Fan0df2e032020-05-03 22:19:57 +0800195#if defined(CONFIG_IMX_THERMAL) || defined(CONFIG_IMX_TMU)
Tim Harvey27f90592015-05-18 06:56:46 -0700196 puts("CPU: ");
197 switch (get_cpu_temp_grade(&minc, &maxc)) {
198 case TEMP_AUTOMOTIVE:
199 puts("Automotive temperature grade ");
200 break;
201 case TEMP_INDUSTRIAL:
202 puts("Industrial temperature grade ");
203 break;
204 case TEMP_EXTCOMMERCIAL:
205 puts("Extended Commercial temperature grade ");
206 break;
207 default:
208 puts("Commercial temperature grade ");
209 break;
210 }
211 printf("(%dC to %dC)", minc, maxc);
Ye.Lif19692c2014-11-20 21:14:14 +0800212 ret = uclass_get_device(UCLASS_THERMAL, 0, &thermal_dev);
213 if (!ret) {
214 ret = thermal_get_temp(thermal_dev, &cpu_tmp);
215
216 if (!ret)
Tim Harvey27f90592015-05-18 06:56:46 -0700217 printf(" at %dC\n", cpu_tmp);
Ye.Lif19692c2014-11-20 21:14:14 +0800218 else
Fabio Estevamf62604d2015-09-08 14:43:10 -0300219 debug(" - invalid sensor data\n");
Ye.Lif19692c2014-11-20 21:14:14 +0800220 } else {
Fabio Estevamf62604d2015-09-08 14:43:10 -0300221 debug(" - invalid sensor device\n");
Ye.Lif19692c2014-11-20 21:14:14 +0800222 }
223#endif
224
Jason Liu83aa8fe2011-11-25 00:18:01 +0000225 printf("Reset cause: %s\n", get_reset_cause());
226 return 0;
227}
228#endif
229
230int cpu_eth_init(bd_t *bis)
231{
232 int rc = -ENODEV;
233
234#if defined(CONFIG_FEC_MXC)
235 rc = fecmxc_initialize(bis);
236#endif
237
238 return rc;
239}
240
Yangbo Lu73340382019-06-21 11:42:28 +0800241#ifdef CONFIG_FSL_ESDHC_IMX
Jason Liu83aa8fe2011-11-25 00:18:01 +0000242/*
243 * Initializes on-chip MMC controllers.
244 * to override, implement board_mmc_init()
245 */
246int cpu_mmc_init(bd_t *bis)
247{
Jason Liu83aa8fe2011-11-25 00:18:01 +0000248 return fsl_esdhc_mmc_init(bis);
Jason Liu83aa8fe2011-11-25 00:18:01 +0000249}
Benoît Thébaudeau58d22322012-08-17 10:42:55 +0000250#endif
Jason Liu83aa8fe2011-11-25 00:18:01 +0000251
Peng Fan39945c12018-11-20 10:19:25 +0000252#if !(defined(CONFIG_MX7) || defined(CONFIG_IMX8M))
Fabio Estevam6479f512012-04-29 08:11:13 +0000253u32 get_ahb_clk(void)
254{
255 struct mxc_ccm_reg *imx_ccm = (struct mxc_ccm_reg *)CCM_BASE_ADDR;
256 u32 reg, ahb_podf;
257
258 reg = __raw_readl(&imx_ccm->cbcdr);
259 reg &= MXC_CCM_CBCDR_AHB_PODF_MASK;
260 ahb_podf = reg >> MXC_CCM_CBCDR_AHB_PODF_OFFSET;
261
262 return get_periph_clk() / (ahb_podf + 1);
263}
Adrian Alonso9f883e02015-09-02 13:54:23 -0500264#endif
Eric Nelson54b3f3b2012-09-23 07:30:55 +0000265
Eric Nelson54b3f3b2012-09-23 07:30:55 +0000266void arch_preboot_os(void)
267{
Marek Vasut81647a32019-06-09 03:50:51 +0200268#if defined(CONFIG_PCIE_IMX) && !CONFIG_IS_ENABLED(DM_PCI)
Tim Harveyc22f2ea2017-05-12 12:58:41 -0700269 imx_pcie_remove();
270#endif
Simon Glassab3055a2017-06-14 21:28:25 -0600271#if defined(CONFIG_SATA)
Ludwig Zenzeb15ce22019-07-02 15:10:52 +0200272 if (!is_mx6sdl()) {
273 sata_remove(0);
Soeren Mocha517d022014-11-27 10:11:41 +0100274#if defined(CONFIG_MX6)
Ludwig Zenzeb15ce22019-07-02 15:10:52 +0200275 disable_sata_clock();
Soeren Mocha517d022014-11-27 10:11:41 +0100276#endif
Ludwig Zenzeb15ce22019-07-02 15:10:52 +0200277 }
Nikita Kiryanovb5c9ed32014-11-21 12:47:26 +0200278#endif
279#if defined(CONFIG_VIDEO_IPUV3)
Eric Nelson54b3f3b2012-09-23 07:30:55 +0000280 /* disable video before launching O/S */
281 ipuv3_fb_shutdown();
Eric Nelson54b3f3b2012-09-23 07:30:55 +0000282#endif
Igor Opaniukf5abe402019-06-04 00:05:59 +0300283#if defined(CONFIG_VIDEO_MXS) && !defined(CONFIG_DM_VIDEO)
Peng Fanf2c39922015-10-29 15:54:51 +0800284 lcdif_power_down();
285#endif
Nikita Kiryanovb5c9ed32014-11-21 12:47:26 +0200286}
Fabio Estevam16e65f62014-11-14 11:27:21 -0200287
Peng Fan39945c12018-11-20 10:19:25 +0000288#ifndef CONFIG_IMX8M
Fabio Estevam16e65f62014-11-14 11:27:21 -0200289void set_chipselect_size(int const cs_size)
290{
291 unsigned int reg;
292 struct iomuxc *iomuxc_regs = (struct iomuxc *)IOMUXC_BASE_ADDR;
293 reg = readl(&iomuxc_regs->gpr[1]);
294
295 switch (cs_size) {
296 case CS0_128:
297 reg &= ~0x7; /* CS0=128MB, CS1=0, CS2=0, CS3=0 */
298 reg |= 0x5;
299 break;
300 case CS0_64M_CS1_64M:
301 reg &= ~0x3F; /* CS0=64MB, CS1=64MB, CS2=0, CS3=0 */
302 reg |= 0x1B;
303 break;
304 case CS0_64M_CS1_32M_CS2_32M:
305 reg &= ~0x1FF; /* CS0=64MB, CS1=32MB, CS2=32MB, CS3=0 */
306 reg |= 0x4B;
307 break;
308 case CS0_32M_CS1_32M_CS2_32M_CS3_32M:
309 reg &= ~0xFFF; /* CS0=32MB, CS1=32MB, CS2=32MB, CS3=32MB */
310 reg |= 0x249;
311 break;
312 default:
313 printf("Unknown chip select size: %d\n", cs_size);
314 break;
315 }
316
317 writel(reg, &iomuxc_regs->gpr[1]);
318}
Peng Fana78e0ac2018-01-10 13:20:25 +0800319#endif
Fabio Estevam49bcdd72017-11-27 10:25:09 -0200320
Peng Fan39945c12018-11-20 10:19:25 +0000321#if defined(CONFIG_MX7) || defined(CONFIG_IMX8M)
Peng Fan7753bc72018-01-10 13:20:29 +0800322/*
323 * OCOTP_TESTER3[9:8] (see Fusemap Description Table offset 0x440)
324 * defines a 2-bit SPEED_GRADING
325 */
326#define OCOTP_TESTER3_SPEED_SHIFT 8
Peng Fana12bf3c2018-01-10 13:20:30 +0800327enum cpu_speed {
328 OCOTP_TESTER3_SPEED_GRADE0,
329 OCOTP_TESTER3_SPEED_GRADE1,
330 OCOTP_TESTER3_SPEED_GRADE2,
331 OCOTP_TESTER3_SPEED_GRADE3,
Peng Fan6a5f9c92018-12-12 02:47:58 -0800332 OCOTP_TESTER3_SPEED_GRADE4,
Peng Fana12bf3c2018-01-10 13:20:30 +0800333};
Peng Fan7753bc72018-01-10 13:20:29 +0800334
335u32 get_cpu_speed_grade_hz(void)
336{
337 struct ocotp_regs *ocotp = (struct ocotp_regs *)OCOTP_BASE_ADDR;
338 struct fuse_bank *bank = &ocotp->bank[1];
339 struct fuse_bank1_regs *fuse =
340 (struct fuse_bank1_regs *)bank->fuse_regs;
341 uint32_t val;
342
343 val = readl(&fuse->tester3);
344 val >>= OCOTP_TESTER3_SPEED_SHIFT;
Peng Fan6a5f9c92018-12-12 02:47:58 -0800345
Peng Fan0599e5e2020-01-17 16:11:29 +0800346 if (is_imx8mn() || is_imx8mp()) {
Peng Fan6a5f9c92018-12-12 02:47:58 -0800347 val &= 0xf;
348 return 2300000000 - val * 100000000;
349 }
350
351 if (is_imx8mm())
352 val &= 0x7;
353 else
354 val &= 0x3;
Peng Fan7753bc72018-01-10 13:20:29 +0800355
356 switch(val) {
Peng Fana12bf3c2018-01-10 13:20:30 +0800357 case OCOTP_TESTER3_SPEED_GRADE0:
Peng Fan7753bc72018-01-10 13:20:29 +0800358 return 800000000;
Peng Fana12bf3c2018-01-10 13:20:30 +0800359 case OCOTP_TESTER3_SPEED_GRADE1:
Ye Lic9c1f9c2018-10-16 23:12:37 -0700360 return (is_mx7() ? 500000000 : (is_imx8mq() ? 1000000000 : 1200000000));
Peng Fana12bf3c2018-01-10 13:20:30 +0800361 case OCOTP_TESTER3_SPEED_GRADE2:
Ye Lic9c1f9c2018-10-16 23:12:37 -0700362 return (is_mx7() ? 1000000000 : (is_imx8mq() ? 1300000000 : 1600000000));
Peng Fana12bf3c2018-01-10 13:20:30 +0800363 case OCOTP_TESTER3_SPEED_GRADE3:
Ye Lic9c1f9c2018-10-16 23:12:37 -0700364 return (is_mx7() ? 1200000000 : (is_imx8mq() ? 1500000000 : 1800000000));
Peng Fan6a5f9c92018-12-12 02:47:58 -0800365 case OCOTP_TESTER3_SPEED_GRADE4:
366 return 2000000000;
Peng Fan7753bc72018-01-10 13:20:29 +0800367 }
Peng Fana12bf3c2018-01-10 13:20:30 +0800368
Peng Fan7753bc72018-01-10 13:20:29 +0800369 return 0;
370}
371
372/*
373 * OCOTP_TESTER3[7:6] (see Fusemap Description Table offset 0x440)
374 * defines a 2-bit SPEED_GRADING
375 */
376#define OCOTP_TESTER3_TEMP_SHIFT 6
377
378u32 get_cpu_temp_grade(int *minc, int *maxc)
379{
380 struct ocotp_regs *ocotp = (struct ocotp_regs *)OCOTP_BASE_ADDR;
381 struct fuse_bank *bank = &ocotp->bank[1];
382 struct fuse_bank1_regs *fuse =
383 (struct fuse_bank1_regs *)bank->fuse_regs;
384 uint32_t val;
385
386 val = readl(&fuse->tester3);
387 val >>= OCOTP_TESTER3_TEMP_SHIFT;
388 val &= 0x3;
389
390 if (minc && maxc) {
391 if (val == TEMP_AUTOMOTIVE) {
392 *minc = -40;
393 *maxc = 125;
394 } else if (val == TEMP_INDUSTRIAL) {
395 *minc = -40;
396 *maxc = 105;
397 } else if (val == TEMP_EXTCOMMERCIAL) {
398 *minc = -20;
399 *maxc = 105;
400 } else {
401 *minc = 0;
402 *maxc = 95;
403 }
404 }
405 return val;
406}
407#endif
408
Peng Fan88c41fd2019-09-16 03:09:34 +0000409#if defined(CONFIG_MX7) || defined(CONFIG_IMX8MQ) || defined(CONFIG_IMX8MM)
Peng Fand64a3c52018-01-10 13:20:34 +0800410enum boot_device get_boot_device(void)
411{
412 struct bootrom_sw_info **p =
413 (struct bootrom_sw_info **)(ulong)ROM_SW_INFO_ADDR;
414
415 enum boot_device boot_dev = SD1_BOOT;
416 u8 boot_type = (*p)->boot_dev_type;
417 u8 boot_instance = (*p)->boot_dev_instance;
418
419 switch (boot_type) {
420 case BOOT_TYPE_SD:
421 boot_dev = boot_instance + SD1_BOOT;
422 break;
423 case BOOT_TYPE_MMC:
424 boot_dev = boot_instance + MMC1_BOOT;
425 break;
426 case BOOT_TYPE_NAND:
427 boot_dev = NAND_BOOT;
428 break;
429 case BOOT_TYPE_QSPI:
430 boot_dev = QSPI_BOOT;
431 break;
432 case BOOT_TYPE_WEIM:
433 boot_dev = WEIM_NOR_BOOT;
434 break;
435 case BOOT_TYPE_SPINOR:
436 boot_dev = SPI_NOR_BOOT;
437 break;
Peng Fan39945c12018-11-20 10:19:25 +0000438#ifdef CONFIG_IMX8M
Peng Fan24d3fbc2018-01-10 13:20:35 +0800439 case BOOT_TYPE_USB:
440 boot_dev = USB_BOOT;
441 break;
442#endif
Peng Fand64a3c52018-01-10 13:20:34 +0800443 default:
444 break;
445 }
446
447 return boot_dev;
448}
449#endif
450
Fabio Estevam49bcdd72017-11-27 10:25:09 -0200451#ifdef CONFIG_NXP_BOARD_REVISION
452int nxp_board_rev(void)
453{
454 /*
455 * Get Board ID information from OCOTP_GP1[15:8]
456 * RevA: 0x1
457 * RevB: 0x2
458 * RevC: 0x3
459 */
460 struct ocotp_regs *ocotp = (struct ocotp_regs *)OCOTP_BASE_ADDR;
461 struct fuse_bank *bank = &ocotp->bank[4];
462 struct fuse_bank4_regs *fuse =
463 (struct fuse_bank4_regs *)bank->fuse_regs;
464
465 return (readl(&fuse->gp1) >> 8 & 0x0F);
466}
467
468char nxp_board_rev_string(void)
469{
470 const char *rev = "A";
471
472 return (*rev + nxp_board_rev() - 1);
473}
474#endif