1 // SPDX-License-Identifier: GPL-2.0+
5 * Copyright (C) 2015 Paul Kocialkowski <contact@paulk.fr>
10 #include <asm/arch/sys_proto.h>
13 static u32 boot_devices[] = {
45 u32 omap_sys_boot_device(void)
47 struct ctrl *ctrl_base = (struct ctrl *)OMAP34XX_CTRL_BASE;
50 /* Grab the first 5 bits of the status register for SYS_BOOT. */
51 sys_boot = readl(&ctrl_base->status) & ((1 << 5) - 1);
53 if (sys_boot >= (sizeof(boot_devices) / sizeof(u32)))
54 return BOOT_DEVICE_NONE;
56 return boot_devices[sys_boot];
59 int omap_reboot_mode(char *mode, unsigned int length)
67 reboot_mode = readl((u32 *)(OMAP34XX_SCRATCHPAD +
68 OMAP_REBOOT_REASON_OFFSET));
70 c = (reboot_mode >> 24) & 0xff;
74 c = (reboot_mode >> 16) & 0xff;
78 c = reboot_mode & 0xff;
86 int omap_reboot_mode_clear(void)
88 writel(0, (u32 *)(OMAP34XX_SCRATCHPAD + OMAP_REBOOT_REASON_OFFSET));
93 int omap_reboot_mode_store(char *mode)
97 reboot_mode = 'B' << 24 | 'M' << 16 | mode[0];
99 writel(reboot_mode, (u32 *)(OMAP34XX_SCRATCHPAD +
100 OMAP_REBOOT_REASON_OFFSET));