Masahiro Yamada | fa71441 | 2015-07-21 14:04:22 +0900 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2014-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> |
Masahiro Yamada | efdf340 | 2016-01-09 01:51:13 +0900 | [diff] [blame] | 10 | |
| 11 | #include "../sg-regs.h" |
| 12 | #include "boot-device.h" |
Masahiro Yamada | fa71441 | 2015-07-21 14:04:22 +0900 | [diff] [blame] | 13 | |
Masahiro Yamada | 75f16f8 | 2015-09-22 00:27:39 +0900 | [diff] [blame] | 14 | static struct boot_device_info boot_device_table[] = { |
Masahiro Yamada | fd9256d | 2016-05-24 21:13:58 +0900 | [diff] [blame] | 15 | {BOOT_DEVICE_NOR, "NOR (XECS0)"}, |
Masahiro Yamada | fa71441 | 2015-07-21 14:04:22 +0900 | [diff] [blame] | 16 | {BOOT_DEVICE_NONE, "External Master"}, |
| 17 | {BOOT_DEVICE_NONE, "Reserved"}, |
| 18 | {BOOT_DEVICE_NONE, "Reserved"}, |
| 19 | {BOOT_DEVICE_MMC1, "eMMC (3.3V, Boot Oparation)"}, |
| 20 | {BOOT_DEVICE_NONE, "Reserved"}, |
| 21 | {BOOT_DEVICE_MMC1, "eMMC (1.8V, Boot Oparation)"}, |
| 22 | {BOOT_DEVICE_NONE, "Reserved"}, |
| 23 | {BOOT_DEVICE_MMC1, "eMMC (3.3V, Normal)"}, |
| 24 | {BOOT_DEVICE_NONE, "Reserved"}, |
| 25 | {BOOT_DEVICE_MMC1, "eMMC (1.8V, Normal)"}, |
| 26 | {BOOT_DEVICE_NONE, "Reserved"}, |
| 27 | {BOOT_DEVICE_NAND, "NAND (Mirror 1, ECC 8, EraseSize 128KB, Addr 5)"}, |
| 28 | {BOOT_DEVICE_NONE, "Reserved"}, |
| 29 | {BOOT_DEVICE_NAND, "NAND (Mirror 1, ECC 8, EraseSize 256KB, Addr 5)"}, |
| 30 | {BOOT_DEVICE_NONE, "Reserved"}, |
| 31 | {BOOT_DEVICE_NAND, "NAND (Mirror 1, ECC 8, EraseSize 512KB, Addr 5)"}, |
| 32 | {BOOT_DEVICE_NONE, "Reserved"}, |
| 33 | {BOOT_DEVICE_NAND, "NAND (Mirror 1, ECC 16, EraseSize 128KB, Addr 5)"}, |
| 34 | {BOOT_DEVICE_NONE, "Reserved"}, |
| 35 | {BOOT_DEVICE_NAND, "NAND (Mirror 1, ECC 16, EraseSize 256KB, Addr 5)"}, |
| 36 | {BOOT_DEVICE_NONE, "Reserved"}, |
| 37 | {BOOT_DEVICE_NAND, "NAND (Mirror 1, ECC 16, EraseSize 512KB, Addr 5)"}, |
| 38 | {BOOT_DEVICE_NONE, "Reserved"}, |
| 39 | {BOOT_DEVICE_NAND, "NAND (Mirror 4, ECC 24, EraseSize 1MB, Addr 5)"}, |
| 40 | {BOOT_DEVICE_NONE, "Reserved"}, |
| 41 | {BOOT_DEVICE_NAND, "NAND (Mirror 8, ECC 8, EraseSize 128KB, Addr 5)"}, |
| 42 | {BOOT_DEVICE_NONE, "Reserved"}, |
| 43 | {BOOT_DEVICE_NAND, "NAND (Mirror 8, ECC 8, EraseSize 256KB, Addr 5)"}, |
| 44 | {BOOT_DEVICE_NONE, "Reserved"}, |
| 45 | {BOOT_DEVICE_NAND, "NAND (Mirror 8, ECC 8, EraseSize 512KB, Addr 5)"}, |
| 46 | {BOOT_DEVICE_NONE, "Reserved"}, |
| 47 | {BOOT_DEVICE_NAND, "NAND (Mirror 8, ECC 16, EraseSize 128KB, Addr 5)"}, |
| 48 | {BOOT_DEVICE_NONE, "Reserved"}, |
| 49 | {BOOT_DEVICE_NAND, "NAND (Mirror 8, ECC 16, EraseSize 256KB, Addr 5)"}, |
| 50 | {BOOT_DEVICE_NONE, "Reserved"}, |
| 51 | {BOOT_DEVICE_NAND, "NAND (Mirror 8, ECC 16, EraseSize 512KB, Addr 5)"}, |
| 52 | {BOOT_DEVICE_NONE, "Reserved"}, |
| 53 | {BOOT_DEVICE_NAND, "NAND (Mirror 8, ECC 24, EraseSize 1MB, Addr 5)"}, |
| 54 | {BOOT_DEVICE_NONE, "Reserved"}, |
| 55 | {BOOT_DEVICE_NONE, "Reserved"}, |
| 56 | {BOOT_DEVICE_NONE, "Reserved"}, |
| 57 | {BOOT_DEVICE_NONE, "Reserved"}, |
| 58 | {BOOT_DEVICE_NONE, "Reserved"}, |
| 59 | {BOOT_DEVICE_NAND, "NAND (Mirror 1, ECC 8, ONFI, Addr 5)"}, |
| 60 | {BOOT_DEVICE_NONE, "Reserved"}, |
| 61 | {BOOT_DEVICE_NAND, "NAND (Mirror 1, ECC 16, ONFI, Addr 5)"}, |
| 62 | {BOOT_DEVICE_NONE, "Reserved"}, |
| 63 | {BOOT_DEVICE_NAND, "NAND (Mirror 4, ECC 24, ONFI, Addr 5)"}, |
| 64 | {BOOT_DEVICE_NONE, "Reserved"}, |
| 65 | {BOOT_DEVICE_NAND, "NAND (Mirror 8, ECC 8, ONFI, Addr 5)"}, |
| 66 | {BOOT_DEVICE_NONE, "Reserved"}, |
| 67 | {BOOT_DEVICE_NAND, "NAND (Mirror 8, ECC 16, ONFI, Addr 5)"}, |
| 68 | {BOOT_DEVICE_NONE, "Reserved"}, |
| 69 | {BOOT_DEVICE_NAND, "NAND (Mirror 8, ECC 24, ONFI, Addr 5)"}, |
| 70 | {BOOT_DEVICE_NONE, "Reserved"}, |
| 71 | {BOOT_DEVICE_NONE, "Reserved"}, |
| 72 | {BOOT_DEVICE_NONE, "Reserved"}, |
| 73 | {BOOT_DEVICE_NONE, "Reserved"}, |
| 74 | {BOOT_DEVICE_NONE, "Reserved"}, |
| 75 | {BOOT_DEVICE_NONE, "Reserved"}, |
| 76 | {BOOT_DEVICE_NONE, "Reserved"}, |
| 77 | {BOOT_DEVICE_NONE, "Reserved"}, |
| 78 | {BOOT_DEVICE_NONE, "Reserved"}, |
Masahiro Yamada | fa71441 | 2015-07-21 14:04:22 +0900 | [diff] [blame] | 79 | }; |
| 80 | |
Masahiro Yamada | 75f16f8 | 2015-09-22 00:27:39 +0900 | [diff] [blame] | 81 | static int get_boot_mode_sel(void) |
Masahiro Yamada | fa71441 | 2015-07-21 14:04:22 +0900 | [diff] [blame] | 82 | { |
| 83 | return readl(SG_PINMON0) & 0x3f; |
| 84 | } |
| 85 | |
Masahiro Yamada | 9890569 | 2016-03-30 20:17:02 +0900 | [diff] [blame] | 86 | u32 uniphier_sld3_boot_device(void) |
Masahiro Yamada | fa71441 | 2015-07-21 14:04:22 +0900 | [diff] [blame] | 87 | { |
| 88 | int boot_mode; |
| 89 | |
Masahiro Yamada | fa71441 | 2015-07-21 14:04:22 +0900 | [diff] [blame] | 90 | boot_mode = get_boot_mode_sel(); |
| 91 | |
| 92 | return boot_device_table[boot_mode].type; |
| 93 | } |
Masahiro Yamada | 75f16f8 | 2015-09-22 00:27:39 +0900 | [diff] [blame] | 94 | |
Masahiro Yamada | 9890569 | 2016-03-30 20:17:02 +0900 | [diff] [blame] | 95 | void uniphier_sld3_boot_mode_show(void) |
Masahiro Yamada | 75f16f8 | 2015-09-22 00:27:39 +0900 | [diff] [blame] | 96 | { |
| 97 | int mode_sel, i; |
| 98 | |
| 99 | mode_sel = get_boot_mode_sel(); |
| 100 | |
| 101 | puts("Boot Mode Pin:\n"); |
| 102 | |
| 103 | for (i = 0; i < ARRAY_SIZE(boot_device_table); i++) |
| 104 | printf(" %c %02x %s\n", i == mode_sel ? '*' : ' ', i, |
| 105 | boot_device_table[i].info); |
| 106 | } |