4 * Copyright (C) 2015 Paul Kocialkowski <contact@paulk.fr>
6 * SPDX-License-Identifier: GPL-2.0+
11 #include <asm/arch/sys_proto.h>
14 static u32 boot_devices[] = {
46 u32 omap_sys_boot_device(void)
48 struct ctrl *ctrl_base = (struct ctrl *)OMAP34XX_CTRL_BASE;
51 /* Grab the first 5 bits of the status register for SYS_BOOT. */
52 sys_boot = readl(&ctrl_base->status) & ((1 << 5) - 1);
54 if (sys_boot >= (sizeof(boot_devices) / sizeof(u32)))
55 return BOOT_DEVICE_NONE;
57 return boot_devices[sys_boot];
60 int omap_reboot_mode(char *mode, unsigned int length)
68 reboot_mode = readl((u32 *)(OMAP34XX_SCRATCHPAD +
69 OMAP_REBOOT_REASON_OFFSET));
71 c = (reboot_mode >> 24) & 0xff;
75 c = (reboot_mode >> 16) & 0xff;
79 c = reboot_mode & 0xff;
87 int omap_reboot_mode_clear(void)
89 writel(0, (u32 *)(OMAP34XX_SCRATCHPAD + OMAP_REBOOT_REASON_OFFSET));
94 int omap_reboot_mode_store(char *mode)
98 reboot_mode = 'B' << 24 | 'M' << 16 | mode[0];
100 writel(reboot_mode, (u32 *)(OMAP34XX_SCRATCHPAD +
101 OMAP_REBOOT_REASON_OFFSET));