blob: c68cb59fc0cd869dcd79b353640f547d17dcf26a [file] [log] [blame]
Masahiro Yamadad5167d52015-09-22 00:27:40 +09001/*
2 * Copyright (C) 2015 Masahiro Yamada <yamada.masahiro@socionext.com>
3 *
4 * SPDX-License-Identifier: GPL-2.0+
5 */
6
7#include <common.h>
8#include <spl.h>
9#include <linux/io.h>
10#include <mach/boot-device.h>
11#include <mach/sbc-regs.h>
12#include <mach/sg-regs.h>
13
14static struct boot_device_info boot_device_table[] = {
15 {BOOT_DEVICE_NAND, "NAND (Mirror 1, ECC 8, EraseSize 128KB, Addr 5)"},
16 {BOOT_DEVICE_NAND, "NAND (Mirror 1, ECC 16, EraseSize 128KB, Addr 5)"},
17 {BOOT_DEVICE_NAND, "NAND (Mirror 1, ECC 8, EraseSize 256KB, Addr 5)"},
18 {BOOT_DEVICE_NAND, "NAND (Mirror 1, ECC 16, EraseSize 256KB, Addr 5)"},
19 {BOOT_DEVICE_NAND, "NAND (Mirror 1, ECC 8, EraseSize 512KB, Addr 5)"},
20 {BOOT_DEVICE_NAND, "NAND (Mirror 1, ECC 16, EraseSize 512KB, Addr 5)"},
21 {BOOT_DEVICE_NAND, "NAND (Mirror 1, ECC 8, EraseSize 128KB, Addr 4)"},
22 {BOOT_DEVICE_NAND, "NAND (Mirror 1, ECC 16, EraseSize 128MB, Addr 4)"},
23 {BOOT_DEVICE_NONE, "Reserved"},
24 {BOOT_DEVICE_NONE, "Reserved"},
25 {BOOT_DEVICE_NONE, "Reserved"},
26 {BOOT_DEVICE_NONE, "Reserved"},
27 {BOOT_DEVICE_NAND, "NAND (Mirror 8, ECC 8, EraseSize 512MB, Addr 5)"},
28 {BOOT_DEVICE_NAND, "NAND (Mirror 8, ECC 16, EraseSize 512KB, Addr 5)"},
29 {BOOT_DEVICE_NAND, "NAND (Mirror 8, ECC 8, EraseSize 128KB, Addr 4)"},
30 {BOOT_DEVICE_NAND, "NAND (Mirror 8, ECC 16, EraseSize 128KB, Addr 4)"},
31 {BOOT_DEVICE_NAND, "NAND (Mirror 1, ECC 8, ONFI, Addr 5)"},
32 {BOOT_DEVICE_NAND, "NAND (Mirror 1, ECC 16, ONFI, Addr 5)"},
33 {BOOT_DEVICE_NAND, "NAND (Mirror 1, ECC 8, ONFI, Addr 4)"},
34 {BOOT_DEVICE_NAND, "NAND (Mirror 1, ECC 16, ONFI, Addr 4)"},
35 {BOOT_DEVICE_NAND, "NAND (Mirror 8, ECC 8, ONFI, Addr 5)"},
36 {BOOT_DEVICE_NAND, "NAND (Mirror 8, ECC 16, ONFI, Addr 5)"},
37 {BOOT_DEVICE_NAND, "NAND (Mirror 8, ECC 8, ONFI, Addr 4)"},
38 {BOOT_DEVICE_NAND, "NAND (Mirror 8, ECC 16, ONFI, Addr 4)"},
39 {BOOT_DEVICE_NONE, "Reserved"},
40 {BOOT_DEVICE_MMC1, "eMMC Boot (1.8V)"},
41 {BOOT_DEVICE_NONE, "Reserved"},
42 {BOOT_DEVICE_NONE, "Reserved"},
43 {BOOT_DEVICE_NAND, "NAND (Mirror 8, ECC 8, EraseSize 128MB, Addr 5)"},
44 {BOOT_DEVICE_NAND, "NAND (Mirror 8, ECC 16, EraseSize 128KB, Addr 5)"},
45 {BOOT_DEVICE_NAND, "NAND (Mirror 8, ECC 8, EraseSize 256KB, Addr 5)"},
46 {BOOT_DEVICE_NAND, "NAND (Mirror 8, ECC 16, EraseSize 256KB, Addr 5)"},
47 { /* sentinel */ }
48};
49
50static int get_boot_mode_sel(void)
51{
52 return (readl(SG_PINMON0) >> 1) & 0x1f;
53}
54
55u32 ph1_pro5_boot_device(void)
56{
57 int boot_mode;
58
59 boot_mode = get_boot_mode_sel();
60
61 return boot_device_table[boot_mode].type;
62}
63
64void ph1_pro5_boot_mode_show(void)
65{
66 int mode_sel, i;
67
68 mode_sel = get_boot_mode_sel();
69
70 puts("Boot Mode Pin:\n");
71
72 for (i = 0; i < ARRAY_SIZE(boot_device_table); i++)
73 printf(" %c %02x %s\n", i == mode_sel ? '*' : ' ', i,
74 boot_device_table[i].info);
75}