Commit b1821376ee19635127c505bbb94cd3c186f702e8
Committed by
Stefano Babic
1 parent
b890c4aede
Exists in
smarc_8mq_lf_v2020.04
and in
9 other branches
imx8mn: add get_boot_device
No ROM INFO structure on iMX8MN, use new ROM API to get boot device from ROM. Signed-off-by: Peng Fan <peng.fan@nxp.com>
Showing 1 changed file with 48 additions and 0 deletions Side-by-side Diff
arch/arm/mach-imx/imx8m/soc.c
... | ... | @@ -283,6 +283,54 @@ |
283 | 283 | return 0; |
284 | 284 | } |
285 | 285 | |
286 | +#if defined(CONFIG_IMX8MN) || defined(CONFIG_IMX8MP) | |
287 | +struct rom_api *g_rom_api = (struct rom_api *)0x980; | |
288 | + | |
289 | +enum boot_device get_boot_device(void) | |
290 | +{ | |
291 | + volatile gd_t *pgd = gd; | |
292 | + int ret; | |
293 | + u32 boot; | |
294 | + u16 boot_type; | |
295 | + u8 boot_instance; | |
296 | + enum boot_device boot_dev = SD1_BOOT; | |
297 | + | |
298 | + ret = g_rom_api->query_boot_infor(QUERY_BT_DEV, &boot, | |
299 | + ((uintptr_t)&boot) ^ QUERY_BT_DEV); | |
300 | + gd = pgd; | |
301 | + | |
302 | + if (ret != ROM_API_OKAY) { | |
303 | + puts("ROMAPI: failure at query_boot_info\n"); | |
304 | + return -1; | |
305 | + } | |
306 | + | |
307 | + boot_type = boot >> 16; | |
308 | + boot_instance = (boot >> 8) & 0xff; | |
309 | + | |
310 | + switch (boot_type) { | |
311 | + case BT_DEV_TYPE_SD: | |
312 | + boot_dev = boot_instance + SD1_BOOT; | |
313 | + break; | |
314 | + case BT_DEV_TYPE_MMC: | |
315 | + boot_dev = boot_instance + MMC1_BOOT; | |
316 | + break; | |
317 | + case BT_DEV_TYPE_NAND: | |
318 | + boot_dev = NAND_BOOT; | |
319 | + break; | |
320 | + case BT_DEV_TYPE_FLEXSPINOR: | |
321 | + boot_dev = QSPI_BOOT; | |
322 | + break; | |
323 | + case BT_DEV_TYPE_USB: | |
324 | + boot_dev = USB_BOOT; | |
325 | + break; | |
326 | + default: | |
327 | + break; | |
328 | + } | |
329 | + | |
330 | + return boot_dev; | |
331 | +} | |
332 | +#endif | |
333 | + | |
286 | 334 | bool is_usb_boot(void) |
287 | 335 | { |
288 | 336 | return get_boot_device() == USB_BOOT; |