Masahiro Yamada | bb2ff9d | 2014-10-03 19:21:06 +0900 | [diff] [blame] | 1 | /* |
Masahiro Yamada | 663a23f | 2015-05-29 17:30:00 +0900 | [diff] [blame] | 2 | * Copyright (C) 2014-2015 Masahiro Yamada <yamada.masahiro@socionext.com> |
Masahiro Yamada | bb2ff9d | 2014-10-03 19:21:06 +0900 | [diff] [blame] | 3 | * |
| 4 | * SPDX-License-Identifier: GPL-2.0+ |
| 5 | */ |
| 6 | |
| 7 | #include <common.h> |
| 8 | #include <spl.h> |
Masahiro Yamada | 663a23f | 2015-05-29 17:30:00 +0900 | [diff] [blame] | 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 | bb2ff9d | 2014-10-03 19:21:06 +0900 | [diff] [blame] | 13 | |
| 14 | struct boot_device_info boot_device_table[] = { |
| 15 | {BOOT_DEVICE_NAND, "NAND (Mirror 8, ECC 8, EraseSize 128KB, Addr 4)"}, |
| 16 | {BOOT_DEVICE_NAND, "NAND (Mirror 8, ECC 8, EraseSize 128KB, Addr 5)"}, |
| 17 | {BOOT_DEVICE_NAND, "NAND (Mirror 8, ECC 16, EraseSize 128KB, Addr 5)"}, |
| 18 | {BOOT_DEVICE_NAND, "NAND (Mirror 8, ECC 8, EraseSize 256KB, Addr 5)"}, |
| 19 | {BOOT_DEVICE_NAND, "NAND (Mirror 8, ECC 16, EraseSize 256KB, Addr 5)"}, |
| 20 | {BOOT_DEVICE_NAND, "NAND (Mirror 8, ECC 8, EraseSize 512KB, Addr 5)"}, |
| 21 | {BOOT_DEVICE_NAND, "NAND (Mirror 8, ECC 16, EraseSize 512KB, Addr 5)"}, |
| 22 | {BOOT_DEVICE_NAND, "NAND (Mirror 8, ECC 24, EraseSize 1MB, Addr 5)"}, |
| 23 | {BOOT_DEVICE_NAND, "NAND (Mirror 4, ECC 24, EraseSize 1MB, Addr 5)"}, |
| 24 | {BOOT_DEVICE_NAND, "NAND (Mirror 1, ECC 8, EraseSize 128KB, Addr 5)"}, |
| 25 | {BOOT_DEVICE_NAND, "NAND (Mirror 1, ECC 16, EraseSize 128KB, Addr 5)"}, |
| 26 | {BOOT_DEVICE_NAND, "NAND (Mirror 1, ECC 8, EraseSize 256KB, Addr 5)"}, |
| 27 | {BOOT_DEVICE_NAND, "NAND (Mirror 1, ECC 16, EraseSize 256KB, Addr 5)"}, |
| 28 | {BOOT_DEVICE_NAND, "NAND (Mirror 1, ECC 8, EraseSize 512KB, Addr 5)"}, |
| 29 | {BOOT_DEVICE_NAND, "NAND (Mirror 1, ECC 16, EraseSize 512KB, Addr 5)"}, |
| 30 | {BOOT_DEVICE_NAND, "NAND (Mirror 1, ECC 24, EraseSize 512KB, Addr 5)"}, |
| 31 | {BOOT_DEVICE_NAND, "NAND (Mirror 8, ECC 8, ONFI, Addr 4)"}, |
| 32 | {BOOT_DEVICE_NAND, "NAND (Mirror 8, ECC 8, ONFI, Addr 5)"}, |
| 33 | {BOOT_DEVICE_NAND, "NAND (Mirror 8, ECC 16, ONFI, Addr 5)"}, |
| 34 | {BOOT_DEVICE_NAND, "NAND (Mirror 8, ECC 24, ONFI, Addr 5)"}, |
| 35 | {BOOT_DEVICE_NAND, "NAND (Mirror 4, ECC 24, ONFI, Addr 5)"}, |
| 36 | {BOOT_DEVICE_NAND, "NAND (Mirror 1, ECC 8, ONFI, Addr 5)"}, |
| 37 | {BOOT_DEVICE_NAND, "NAND (Mirror 1, ECC 16, ONFI, Addr 5)"}, |
| 38 | {BOOT_DEVICE_NAND, "NAND (Mirror 1, ECC 24, ONFI, Addr 5)"}, |
| 39 | {BOOT_DEVICE_MMC1, "eMMC Boot (3.3V)"}, |
| 40 | {BOOT_DEVICE_MMC1, "eMMC Boot (1.8V)"}, |
| 41 | {BOOT_DEVICE_NONE, "Reserved"}, |
| 42 | {BOOT_DEVICE_NONE, "Reserved"}, |
| 43 | {BOOT_DEVICE_NONE, "Reserved"}, |
| 44 | {BOOT_DEVICE_NONE, "Reserved"}, |
| 45 | {BOOT_DEVICE_NONE, "Reserved"}, |
Masahiro Yamada | e97f27c | 2016-03-23 01:40:04 +0900 | [diff] [blame] | 46 | {BOOT_DEVICE_NOR, "NOR Boot"}, |
Masahiro Yamada | bb2ff9d | 2014-10-03 19:21:06 +0900 | [diff] [blame] | 47 | }; |
| 48 | |
Masahiro Yamada | 75f16f8 | 2015-09-22 00:27:39 +0900 | [diff] [blame] | 49 | static int get_boot_mode_sel(void) |
Masahiro Yamada | bb2ff9d | 2014-10-03 19:21:06 +0900 | [diff] [blame] | 50 | { |
| 51 | return (readl(SG_PINMON0) >> 1) & 0x1f; |
| 52 | } |
| 53 | |
Masahiro Yamada | 9890569 | 2016-03-30 20:17:02 +0900 | [diff] [blame] | 54 | u32 uniphier_ld4_boot_device(void) |
Masahiro Yamada | bb2ff9d | 2014-10-03 19:21:06 +0900 | [diff] [blame] | 55 | { |
Masahiro Yamada | b2bff68 | 2015-02-05 20:56:23 +0900 | [diff] [blame] | 56 | int boot_mode; |
Masahiro Yamada | bb2ff9d | 2014-10-03 19:21:06 +0900 | [diff] [blame] | 57 | |
Masahiro Yamada | bb2ff9d | 2014-10-03 19:21:06 +0900 | [diff] [blame] | 58 | boot_mode = get_boot_mode_sel(); |
| 59 | |
| 60 | return boot_device_table[boot_mode].type; |
| 61 | } |
Masahiro Yamada | 75f16f8 | 2015-09-22 00:27:39 +0900 | [diff] [blame] | 62 | |
Masahiro Yamada | 9890569 | 2016-03-30 20:17:02 +0900 | [diff] [blame] | 63 | void uniphier_ld4_boot_mode_show(void) |
Masahiro Yamada | 75f16f8 | 2015-09-22 00:27:39 +0900 | [diff] [blame] | 64 | { |
| 65 | int mode_sel, i; |
| 66 | |
| 67 | mode_sel = get_boot_mode_sel(); |
| 68 | |
| 69 | puts("Boot Mode Pin:\n"); |
| 70 | |
| 71 | for (i = 0; i < ARRAY_SIZE(boot_device_table); i++) |
| 72 | printf(" %c %02x %s\n", i == mode_sel ? '*' : ' ', i, |
| 73 | boot_device_table[i].info); |
| 74 | } |