blob: 6e9a17521097744abe3666c62a716cb0d4178e2c [file] [log] [blame]
Tom Rini83d290c2018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
Jason Liu18936ee2011-11-25 00:18:01 +00002/*
3 * (C) Copyright 2007
4 * Sascha Hauer, Pengutronix
5 *
6 * (C) Copyright 2009 Freescale Semiconductor, Inc.
Jason Liu18936ee2011-11-25 00:18:01 +00007 */
8
Jeroen Hofstee5624c6b2014-10-08 22:57:52 +02009#include <bootm.h>
Jason Liu18936ee2011-11-25 00:18:01 +000010#include <common.h>
Jeroen Hofstee5624c6b2014-10-08 22:57:52 +020011#include <netdev.h>
Masahiro Yamada1221ce42016-09-21 11:28:55 +090012#include <linux/errno.h>
Jason Liu18936ee2011-11-25 00:18:01 +000013#include <asm/io.h>
14#include <asm/arch/imx-regs.h>
15#include <asm/arch/clock.h>
16#include <asm/arch/sys_proto.h>
Fabio Estevam6a376042012-04-29 08:11:13 +000017#include <asm/arch/crm_regs.h>
Peng Fan770611f2018-01-10 13:20:34 +080018#include <asm/mach-imx/boot_mode.h>
Tim Harvey70caa8e2015-05-18 06:56:46 -070019#include <imx_thermal.h>
Eric Nelsone1eb75b2012-09-23 07:30:55 +000020#include <ipu_pixfmt.h>
Ye.Li7a264162014-11-20 21:14:14 +080021#include <thermal.h>
Nikita Kiryanov44b98412014-11-21 12:47:26 +020022#include <sata.h>
Jason Liu18936ee2011-11-25 00:18:01 +000023
Yangbo Lue37ac712019-06-21 11:42:28 +080024#ifdef CONFIG_FSL_ESDHC_IMX
25#include <fsl_esdhc_imx.h>
Jason Liu18936ee2011-11-25 00:18:01 +000026#endif
27
Eric Nelson11c2e502015-02-15 14:37:21 -070028static u32 reset_cause = -1;
29
Max Krummenacher6ed4d262019-02-01 16:04:51 +010030u32 get_imx_reset_cause(void)
Jason Liu18936ee2011-11-25 00:18:01 +000031{
Jason Liu18936ee2011-11-25 00:18:01 +000032 struct src *src_regs = (struct src *)SRC_BASE_ADDR;
33
Max Krummenacher6ed4d262019-02-01 16:04:51 +010034 if (reset_cause == -1) {
35 reset_cause = readl(&src_regs->srsr);
36/* preserve the value for U-Boot proper */
37#if !defined(CONFIG_SPL_BUILD)
38 writel(reset_cause, &src_regs->srsr);
39#endif
40 }
Jason Liu18936ee2011-11-25 00:18:01 +000041
Max Krummenacher6ed4d262019-02-01 16:04:51 +010042 return reset_cause;
43}
44
45#if defined(CONFIG_DISPLAY_CPUINFO) && !defined(CONFIG_SPL_BUILD)
46static char *get_reset_cause(void)
47{
48 switch (get_imx_reset_cause()) {
Jason Liu18936ee2011-11-25 00:18:01 +000049 case 0x00001:
Fabio Estevamcece2622012-03-13 07:26:48 +000050 case 0x00011:
Jason Liu18936ee2011-11-25 00:18:01 +000051 return "POR";
52 case 0x00004:
53 return "CSU";
54 case 0x00008:
55 return "IPP USER";
56 case 0x00010:
Adrian Alonsocd562c82015-09-02 13:54:23 -050057#ifdef CONFIG_MX7
58 return "WDOG1";
59#else
Jason Liu18936ee2011-11-25 00:18:01 +000060 return "WDOG";
Adrian Alonsocd562c82015-09-02 13:54:23 -050061#endif
Jason Liu18936ee2011-11-25 00:18:01 +000062 case 0x00020:
63 return "JTAG HIGH-Z";
64 case 0x00040:
65 return "JTAG SW";
Adrian Alonsocd562c82015-09-02 13:54:23 -050066 case 0x00080:
67 return "WDOG3";
68#ifdef CONFIG_MX7
69 case 0x00100:
70 return "WDOG4";
71 case 0x00200:
72 return "TEMPSENSE";
Peng Fancd357ad2018-11-20 10:19:25 +000073#elif defined(CONFIG_IMX8M)
Peng Fan7537e932018-01-10 13:20:25 +080074 case 0x00100:
75 return "WDOG2";
76 case 0x00200:
77 return "TEMPSENSE";
Adrian Alonsocd562c82015-09-02 13:54:23 -050078#else
79 case 0x00100:
80 return "TEMPSENSE";
Jason Liu18936ee2011-11-25 00:18:01 +000081 case 0x10000:
82 return "WARM BOOT";
Adrian Alonsocd562c82015-09-02 13:54:23 -050083#endif
Jason Liu18936ee2011-11-25 00:18:01 +000084 default:
85 return "unknown reset";
86 }
87}
Prabhakar Kushwaha28420e72015-05-18 17:13:52 +053088#endif
Eric Nelson11c2e502015-02-15 14:37:21 -070089
Troy Kiskyeb0344d2012-10-23 10:57:48 +000090#if defined(CONFIG_MX53) || defined(CONFIG_MX6)
91#if defined(CONFIG_MX53)
Eric Nelson3e9cbbb2013-11-08 16:50:53 -070092#define MEMCTL_BASE ESDCTL_BASE_ADDR
Troy Kiskyeb0344d2012-10-23 10:57:48 +000093#else
Eric Nelson3e9cbbb2013-11-08 16:50:53 -070094#define MEMCTL_BASE MMDC_P0_BASE_ADDR
Troy Kiskyeb0344d2012-10-23 10:57:48 +000095#endif
96static const unsigned char col_lookup[] = {9, 10, 11, 8, 12, 9, 9, 9};
97static const unsigned char bank_lookup[] = {3, 2};
98
Tim Harveyb07161c2014-06-02 16:13:21 -070099/* these MMDC registers are common to the IMX53 and IMX6 */
Troy Kiskyeb0344d2012-10-23 10:57:48 +0000100struct esd_mmdc_regs {
101 uint32_t ctl;
102 uint32_t pdc;
103 uint32_t otc;
104 uint32_t cfg0;
105 uint32_t cfg1;
106 uint32_t cfg2;
107 uint32_t misc;
Troy Kiskyeb0344d2012-10-23 10:57:48 +0000108};
109
110#define ESD_MMDC_CTL_GET_ROW(mdctl) ((ctl >> 24) & 7)
111#define ESD_MMDC_CTL_GET_COLUMN(mdctl) ((ctl >> 20) & 7)
112#define ESD_MMDC_CTL_GET_WIDTH(mdctl) ((ctl >> 16) & 3)
113#define ESD_MMDC_CTL_GET_CS1(mdctl) ((ctl >> 30) & 1)
114#define ESD_MMDC_MISC_GET_BANK(mdmisc) ((misc >> 5) & 1)
115
Tim Harveyb07161c2014-06-02 16:13:21 -0700116/*
117 * imx_ddr_size - return size in bytes of DRAM according MMDC config
118 * The MMDC MDCTL register holds the number of bits for row, col, and data
119 * width and the MMDC MDMISC register holds the number of banks. Combine
120 * all these bits to determine the meme size the MMDC has been configured for
121 */
Troy Kiskyeb0344d2012-10-23 10:57:48 +0000122unsigned imx_ddr_size(void)
123{
124 struct esd_mmdc_regs *mem = (struct esd_mmdc_regs *)MEMCTL_BASE;
125 unsigned ctl = readl(&mem->ctl);
126 unsigned misc = readl(&mem->misc);
127 int bits = 11 + 0 + 0 + 1; /* row + col + bank + width */
128
129 bits += ESD_MMDC_CTL_GET_ROW(ctl);
130 bits += col_lookup[ESD_MMDC_CTL_GET_COLUMN(ctl)];
131 bits += bank_lookup[ESD_MMDC_MISC_GET_BANK(misc)];
132 bits += ESD_MMDC_CTL_GET_WIDTH(ctl);
133 bits += ESD_MMDC_CTL_GET_CS1(ctl);
Marek Vasutfcfdfdd2014-08-04 01:47:09 +0200134
135 /* The MX6 can do only 3840 MiB of DRAM */
136 if (bits == 32)
137 return 0xf0000000;
138
Troy Kiskyeb0344d2012-10-23 10:57:48 +0000139 return 1 << bits;
140}
141#endif
142
Anatolij Gustschin38df3702017-08-28 21:46:26 +0200143#if defined(CONFIG_DISPLAY_CPUINFO) && !defined(CONFIG_SPL_BUILD)
Fabio Estevama7683862012-03-20 04:21:45 +0000144
Troy Kisky20332a02012-10-23 10:57:46 +0000145const char *get_imx_type(u32 imxtype)
Fabio Estevama7683862012-03-20 04:21:45 +0000146{
147 switch (imxtype) {
Peng Fancd357ad2018-11-20 10:19:25 +0000148 case MXC_CPU_IMX8MQ:
149 return "8MQ"; /* Quad-core version of the imx8m */
Fabio Estevame25a0652016-02-28 12:33:17 -0300150 case MXC_CPU_MX7S:
Stefan Agner249092f2016-05-06 11:21:50 -0700151 return "7S"; /* Single-core version of the mx7 */
Adrian Alonsocd562c82015-09-02 13:54:23 -0500152 case MXC_CPU_MX7D:
153 return "7D"; /* Dual-core version of the mx7 */
Peng Fand0acd992015-07-11 11:38:42 +0800154 case MXC_CPU_MX6QP:
155 return "6QP"; /* Quad-Plus version of the mx6 */
156 case MXC_CPU_MX6DP:
157 return "6DP"; /* Dual-Plus version of the mx6 */
Troy Kisky20332a02012-10-23 10:57:46 +0000158 case MXC_CPU_MX6Q:
Fabio Estevama7683862012-03-20 04:21:45 +0000159 return "6Q"; /* Quad-core version of the mx6 */
Fabio Estevam94db6652014-01-26 15:06:41 -0200160 case MXC_CPU_MX6D:
161 return "6D"; /* Dual-core version of the mx6 */
Troy Kisky20332a02012-10-23 10:57:46 +0000162 case MXC_CPU_MX6DL:
163 return "6DL"; /* Dual Lite version of the mx6 */
164 case MXC_CPU_MX6SOLO:
165 return "6SOLO"; /* Solo version of the mx6 */
166 case MXC_CPU_MX6SL:
Fabio Estevama7683862012-03-20 04:21:45 +0000167 return "6SL"; /* Solo-Lite version of the mx6 */
Peng Fan7ce6d3c2016-12-11 19:24:20 +0800168 case MXC_CPU_MX6SLL:
169 return "6SLL"; /* SLL version of the mx6 */
Fabio Estevam05d54b82014-06-24 17:40:58 -0300170 case MXC_CPU_MX6SX:
171 return "6SX"; /* SoloX version of the mx6 */
Peng Fan8631c062015-07-20 19:28:21 +0800172 case MXC_CPU_MX6UL:
173 return "6UL"; /* Ultra-Lite version of the mx6 */
Peng Fan65ce54b2016-08-11 14:02:38 +0800174 case MXC_CPU_MX6ULL:
175 return "6ULL"; /* ULL version of the mx6 */
Troy Kisky20332a02012-10-23 10:57:46 +0000176 case MXC_CPU_MX51:
Fabio Estevama7683862012-03-20 04:21:45 +0000177 return "51";
Troy Kisky20332a02012-10-23 10:57:46 +0000178 case MXC_CPU_MX53:
Fabio Estevama7683862012-03-20 04:21:45 +0000179 return "53";
180 default:
Otavio Salvadore972d722012-06-30 05:07:32 +0000181 return "??";
Fabio Estevama7683862012-03-20 04:21:45 +0000182 }
183}
184
Jason Liu18936ee2011-11-25 00:18:01 +0000185int print_cpuinfo(void)
186{
Stefano Babic943a3f22015-05-26 19:53:41 +0200187 u32 cpurev;
188 __maybe_unused u32 max_freq;
Jason Liu18936ee2011-11-25 00:18:01 +0000189
190 cpurev = get_cpu_rev();
Fabio Estevama7683862012-03-20 04:21:45 +0000191
Adrian Alonso1368f992015-09-02 13:54:13 -0500192#if defined(CONFIG_IMX_THERMAL)
193 struct udevice *thermal_dev;
194 int cpu_tmp, minc, maxc, ret;
195
Tim Harveyb83ddac2015-05-18 07:02:25 -0700196 printf("CPU: Freescale i.MX%s rev%d.%d",
197 get_imx_type((cpurev & 0xFF000) >> 12),
198 (cpurev & 0x000F0) >> 4,
199 (cpurev & 0x0000F) >> 0);
200 max_freq = get_cpu_speed_grade_hz();
201 if (!max_freq || max_freq == mxc_get_clock(MXC_ARM_CLK)) {
202 printf(" at %dMHz\n", mxc_get_clock(MXC_ARM_CLK) / 1000000);
203 } else {
204 printf(" %d MHz (running at %d MHz)\n", max_freq / 1000000,
205 mxc_get_clock(MXC_ARM_CLK) / 1000000);
206 }
207#else
Fabio Estevama7683862012-03-20 04:21:45 +0000208 printf("CPU: Freescale i.MX%s rev%d.%d at %d MHz\n",
209 get_imx_type((cpurev & 0xFF000) >> 12),
Jason Liu18936ee2011-11-25 00:18:01 +0000210 (cpurev & 0x000F0) >> 4,
211 (cpurev & 0x0000F) >> 0,
212 mxc_get_clock(MXC_ARM_CLK) / 1000000);
Tim Harveyb83ddac2015-05-18 07:02:25 -0700213#endif
Ye.Li7a264162014-11-20 21:14:14 +0800214
Adrian Alonso1368f992015-09-02 13:54:13 -0500215#if defined(CONFIG_IMX_THERMAL)
Tim Harvey70caa8e2015-05-18 06:56:46 -0700216 puts("CPU: ");
217 switch (get_cpu_temp_grade(&minc, &maxc)) {
218 case TEMP_AUTOMOTIVE:
219 puts("Automotive temperature grade ");
220 break;
221 case TEMP_INDUSTRIAL:
222 puts("Industrial temperature grade ");
223 break;
224 case TEMP_EXTCOMMERCIAL:
225 puts("Extended Commercial temperature grade ");
226 break;
227 default:
228 puts("Commercial temperature grade ");
229 break;
230 }
231 printf("(%dC to %dC)", minc, maxc);
Ye.Li7a264162014-11-20 21:14:14 +0800232 ret = uclass_get_device(UCLASS_THERMAL, 0, &thermal_dev);
233 if (!ret) {
234 ret = thermal_get_temp(thermal_dev, &cpu_tmp);
235
236 if (!ret)
Tim Harvey70caa8e2015-05-18 06:56:46 -0700237 printf(" at %dC\n", cpu_tmp);
Ye.Li7a264162014-11-20 21:14:14 +0800238 else
Fabio Estevam3a384b42015-09-08 14:43:10 -0300239 debug(" - invalid sensor data\n");
Ye.Li7a264162014-11-20 21:14:14 +0800240 } else {
Fabio Estevam3a384b42015-09-08 14:43:10 -0300241 debug(" - invalid sensor device\n");
Ye.Li7a264162014-11-20 21:14:14 +0800242 }
243#endif
244
Jason Liu18936ee2011-11-25 00:18:01 +0000245 printf("Reset cause: %s\n", get_reset_cause());
246 return 0;
247}
248#endif
249
250int cpu_eth_init(bd_t *bis)
251{
252 int rc = -ENODEV;
253
254#if defined(CONFIG_FEC_MXC)
255 rc = fecmxc_initialize(bis);
256#endif
257
258 return rc;
259}
260
Yangbo Lue37ac712019-06-21 11:42:28 +0800261#ifdef CONFIG_FSL_ESDHC_IMX
Jason Liu18936ee2011-11-25 00:18:01 +0000262/*
263 * Initializes on-chip MMC controllers.
264 * to override, implement board_mmc_init()
265 */
266int cpu_mmc_init(bd_t *bis)
267{
Jason Liu18936ee2011-11-25 00:18:01 +0000268 return fsl_esdhc_mmc_init(bis);
Jason Liu18936ee2011-11-25 00:18:01 +0000269}
Benoît Thébaudeauecb0f312012-08-17 10:42:55 +0000270#endif
Jason Liu18936ee2011-11-25 00:18:01 +0000271
Peng Fancd357ad2018-11-20 10:19:25 +0000272#if !(defined(CONFIG_MX7) || defined(CONFIG_IMX8M))
Fabio Estevam6a376042012-04-29 08:11:13 +0000273u32 get_ahb_clk(void)
274{
275 struct mxc_ccm_reg *imx_ccm = (struct mxc_ccm_reg *)CCM_BASE_ADDR;
276 u32 reg, ahb_podf;
277
278 reg = __raw_readl(&imx_ccm->cbcdr);
279 reg &= MXC_CCM_CBCDR_AHB_PODF_MASK;
280 ahb_podf = reg >> MXC_CCM_CBCDR_AHB_PODF_OFFSET;
281
282 return get_periph_clk() / (ahb_podf + 1);
283}
Adrian Alonsocd562c82015-09-02 13:54:23 -0500284#endif
Eric Nelsone1eb75b2012-09-23 07:30:55 +0000285
Eric Nelsone1eb75b2012-09-23 07:30:55 +0000286void arch_preboot_os(void)
287{
Marek Vasut42dc1232019-06-09 03:50:51 +0200288#if defined(CONFIG_PCIE_IMX) && !CONFIG_IS_ENABLED(DM_PCI)
Tim Harvey6ecbe132017-05-12 12:58:41 -0700289 imx_pcie_remove();
290#endif
Simon Glass10e40d52017-06-14 21:28:25 -0600291#if defined(CONFIG_SATA)
Ludwig Zenz86e59532019-07-02 15:10:52 +0200292 if (!is_mx6sdl()) {
293 sata_remove(0);
Soeren Mochdd1c8f12014-11-27 10:11:41 +0100294#if defined(CONFIG_MX6)
Ludwig Zenz86e59532019-07-02 15:10:52 +0200295 disable_sata_clock();
Soeren Mochdd1c8f12014-11-27 10:11:41 +0100296#endif
Ludwig Zenz86e59532019-07-02 15:10:52 +0200297 }
Nikita Kiryanov44b98412014-11-21 12:47:26 +0200298#endif
299#if defined(CONFIG_VIDEO_IPUV3)
Eric Nelsone1eb75b2012-09-23 07:30:55 +0000300 /* disable video before launching O/S */
301 ipuv3_fb_shutdown();
Eric Nelsone1eb75b2012-09-23 07:30:55 +0000302#endif
Igor Opaniuk8c1df092019-06-04 00:05:59 +0300303#if defined(CONFIG_VIDEO_MXS) && !defined(CONFIG_DM_VIDEO)
Peng Fan623787f2015-10-29 15:54:51 +0800304 lcdif_power_down();
305#endif
Nikita Kiryanov44b98412014-11-21 12:47:26 +0200306}
Fabio Estevam32c81ea2014-11-14 11:27:21 -0200307
Peng Fancd357ad2018-11-20 10:19:25 +0000308#ifndef CONFIG_IMX8M
Fabio Estevam32c81ea2014-11-14 11:27:21 -0200309void set_chipselect_size(int const cs_size)
310{
311 unsigned int reg;
312 struct iomuxc *iomuxc_regs = (struct iomuxc *)IOMUXC_BASE_ADDR;
313 reg = readl(&iomuxc_regs->gpr[1]);
314
315 switch (cs_size) {
316 case CS0_128:
317 reg &= ~0x7; /* CS0=128MB, CS1=0, CS2=0, CS3=0 */
318 reg |= 0x5;
319 break;
320 case CS0_64M_CS1_64M:
321 reg &= ~0x3F; /* CS0=64MB, CS1=64MB, CS2=0, CS3=0 */
322 reg |= 0x1B;
323 break;
324 case CS0_64M_CS1_32M_CS2_32M:
325 reg &= ~0x1FF; /* CS0=64MB, CS1=32MB, CS2=32MB, CS3=0 */
326 reg |= 0x4B;
327 break;
328 case CS0_32M_CS1_32M_CS2_32M_CS3_32M:
329 reg &= ~0xFFF; /* CS0=32MB, CS1=32MB, CS2=32MB, CS3=32MB */
330 reg |= 0x249;
331 break;
332 default:
333 printf("Unknown chip select size: %d\n", cs_size);
334 break;
335 }
336
337 writel(reg, &iomuxc_regs->gpr[1]);
338}
Peng Fan7537e932018-01-10 13:20:25 +0800339#endif
Fabio Estevam4555c262017-11-27 10:25:09 -0200340
Peng Fancd357ad2018-11-20 10:19:25 +0000341#if defined(CONFIG_MX7) || defined(CONFIG_IMX8M)
Peng Fan423e84b2018-01-10 13:20:29 +0800342/*
343 * OCOTP_TESTER3[9:8] (see Fusemap Description Table offset 0x440)
344 * defines a 2-bit SPEED_GRADING
345 */
346#define OCOTP_TESTER3_SPEED_SHIFT 8
Peng Fane56d9d72018-01-10 13:20:30 +0800347enum cpu_speed {
348 OCOTP_TESTER3_SPEED_GRADE0,
349 OCOTP_TESTER3_SPEED_GRADE1,
350 OCOTP_TESTER3_SPEED_GRADE2,
351 OCOTP_TESTER3_SPEED_GRADE3,
352};
Peng Fan423e84b2018-01-10 13:20:29 +0800353
354u32 get_cpu_speed_grade_hz(void)
355{
356 struct ocotp_regs *ocotp = (struct ocotp_regs *)OCOTP_BASE_ADDR;
357 struct fuse_bank *bank = &ocotp->bank[1];
358 struct fuse_bank1_regs *fuse =
359 (struct fuse_bank1_regs *)bank->fuse_regs;
360 uint32_t val;
361
362 val = readl(&fuse->tester3);
363 val >>= OCOTP_TESTER3_SPEED_SHIFT;
364 val &= 0x3;
365
366 switch(val) {
Peng Fane56d9d72018-01-10 13:20:30 +0800367 case OCOTP_TESTER3_SPEED_GRADE0:
Peng Fan423e84b2018-01-10 13:20:29 +0800368 return 800000000;
Peng Fane56d9d72018-01-10 13:20:30 +0800369 case OCOTP_TESTER3_SPEED_GRADE1:
370 return is_mx7() ? 500000000 : 1000000000;
371 case OCOTP_TESTER3_SPEED_GRADE2:
372 return is_mx7() ? 1000000000 : 1300000000;
373 case OCOTP_TESTER3_SPEED_GRADE3:
374 return is_mx7() ? 1200000000 : 1500000000;
Peng Fan423e84b2018-01-10 13:20:29 +0800375 }
Peng Fane56d9d72018-01-10 13:20:30 +0800376
Peng Fan423e84b2018-01-10 13:20:29 +0800377 return 0;
378}
379
380/*
381 * OCOTP_TESTER3[7:6] (see Fusemap Description Table offset 0x440)
382 * defines a 2-bit SPEED_GRADING
383 */
384#define OCOTP_TESTER3_TEMP_SHIFT 6
385
386u32 get_cpu_temp_grade(int *minc, int *maxc)
387{
388 struct ocotp_regs *ocotp = (struct ocotp_regs *)OCOTP_BASE_ADDR;
389 struct fuse_bank *bank = &ocotp->bank[1];
390 struct fuse_bank1_regs *fuse =
391 (struct fuse_bank1_regs *)bank->fuse_regs;
392 uint32_t val;
393
394 val = readl(&fuse->tester3);
395 val >>= OCOTP_TESTER3_TEMP_SHIFT;
396 val &= 0x3;
397
398 if (minc && maxc) {
399 if (val == TEMP_AUTOMOTIVE) {
400 *minc = -40;
401 *maxc = 125;
402 } else if (val == TEMP_INDUSTRIAL) {
403 *minc = -40;
404 *maxc = 105;
405 } else if (val == TEMP_EXTCOMMERCIAL) {
406 *minc = -20;
407 *maxc = 105;
408 } else {
409 *minc = 0;
410 *maxc = 95;
411 }
412 }
413 return val;
414}
415#endif
416
Peng Fancd357ad2018-11-20 10:19:25 +0000417#if defined(CONFIG_MX7) || defined(CONFIG_IMX8M)
Peng Fan770611f2018-01-10 13:20:34 +0800418enum boot_device get_boot_device(void)
419{
420 struct bootrom_sw_info **p =
421 (struct bootrom_sw_info **)(ulong)ROM_SW_INFO_ADDR;
422
423 enum boot_device boot_dev = SD1_BOOT;
424 u8 boot_type = (*p)->boot_dev_type;
425 u8 boot_instance = (*p)->boot_dev_instance;
426
427 switch (boot_type) {
428 case BOOT_TYPE_SD:
429 boot_dev = boot_instance + SD1_BOOT;
430 break;
431 case BOOT_TYPE_MMC:
432 boot_dev = boot_instance + MMC1_BOOT;
433 break;
434 case BOOT_TYPE_NAND:
435 boot_dev = NAND_BOOT;
436 break;
437 case BOOT_TYPE_QSPI:
438 boot_dev = QSPI_BOOT;
439 break;
440 case BOOT_TYPE_WEIM:
441 boot_dev = WEIM_NOR_BOOT;
442 break;
443 case BOOT_TYPE_SPINOR:
444 boot_dev = SPI_NOR_BOOT;
445 break;
Peng Fancd357ad2018-11-20 10:19:25 +0000446#ifdef CONFIG_IMX8M
Peng Fan80ebf862018-01-10 13:20:35 +0800447 case BOOT_TYPE_USB:
448 boot_dev = USB_BOOT;
449 break;
450#endif
Peng Fan770611f2018-01-10 13:20:34 +0800451 default:
452 break;
453 }
454
455 return boot_dev;
456}
457#endif
458
Fabio Estevam4555c262017-11-27 10:25:09 -0200459#ifdef CONFIG_NXP_BOARD_REVISION
460int nxp_board_rev(void)
461{
462 /*
463 * Get Board ID information from OCOTP_GP1[15:8]
464 * RevA: 0x1
465 * RevB: 0x2
466 * RevC: 0x3
467 */
468 struct ocotp_regs *ocotp = (struct ocotp_regs *)OCOTP_BASE_ADDR;
469 struct fuse_bank *bank = &ocotp->bank[4];
470 struct fuse_bank4_regs *fuse =
471 (struct fuse_bank4_regs *)bank->fuse_regs;
472
473 return (readl(&fuse->gp1) >> 8 & 0x0F);
474}
475
476char nxp_board_rev_string(void)
477{
478 const char *rev = "A";
479
480 return (*rev + nxp_board_rev() - 1);
481}
482#endif