Masahiro Yamada | bb2ff9d | 2014-10-03 19:21:06 +0900 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2014 Panasonic Corporation |
| 3 | * Author: Masahiro Yamada <yamada.m@jp.panasonic.com> |
| 4 | * |
| 5 | * SPDX-License-Identifier: GPL-2.0+ |
| 6 | */ |
| 7 | |
| 8 | #include <common.h> |
| 9 | #include <spl.h> |
| 10 | #include <asm/io.h> |
Masahiro Yamada | 95387e2 | 2015-02-27 02:26:44 +0900 | [diff] [blame] | 11 | #include <mach/boot-device.h> |
| 12 | #include <mach/sg-regs.h> |
| 13 | #include <mach/sbc-regs.h> |
Masahiro Yamada | bb2ff9d | 2014-10-03 19:21:06 +0900 | [diff] [blame] | 14 | |
| 15 | struct boot_device_info boot_device_table[] = { |
| 16 | {BOOT_DEVICE_NAND, "NAND (Mirror 8, ECC 8, EraseSize 128KB, Addr 4)"}, |
| 17 | {BOOT_DEVICE_NAND, "NAND (Mirror 8, ECC 8, EraseSize 128KB, Addr 5)"}, |
| 18 | {BOOT_DEVICE_NAND, "NAND (Mirror 8, ECC 16, EraseSize 128KB, Addr 5)"}, |
| 19 | {BOOT_DEVICE_NAND, "NAND (Mirror 8, ECC 8, EraseSize 256KB, Addr 5)"}, |
| 20 | {BOOT_DEVICE_NAND, "NAND (Mirror 8, ECC 16, EraseSize 256KB, Addr 5)"}, |
| 21 | {BOOT_DEVICE_NAND, "NAND (Mirror 8, ECC 8, EraseSize 512KB, Addr 5)"}, |
| 22 | {BOOT_DEVICE_NAND, "NAND (Mirror 8, ECC 16, EraseSize 512KB, Addr 5)"}, |
| 23 | {BOOT_DEVICE_NAND, "NAND (Mirror 8, ECC 24, EraseSize 1MB, Addr 5)"}, |
| 24 | {BOOT_DEVICE_NAND, "NAND (Mirror 4, ECC 24, EraseSize 1MB, Addr 5)"}, |
| 25 | {BOOT_DEVICE_NAND, "NAND (Mirror 1, ECC 8, EraseSize 128KB, Addr 5)"}, |
| 26 | {BOOT_DEVICE_NAND, "NAND (Mirror 1, ECC 16, EraseSize 128KB, Addr 5)"}, |
| 27 | {BOOT_DEVICE_NAND, "NAND (Mirror 1, ECC 8, EraseSize 256KB, Addr 5)"}, |
| 28 | {BOOT_DEVICE_NAND, "NAND (Mirror 1, ECC 16, EraseSize 256KB, Addr 5)"}, |
| 29 | {BOOT_DEVICE_NAND, "NAND (Mirror 1, ECC 8, EraseSize 512KB, Addr 5)"}, |
| 30 | {BOOT_DEVICE_NAND, "NAND (Mirror 1, ECC 16, EraseSize 512KB, Addr 5)"}, |
| 31 | {BOOT_DEVICE_NAND, "NAND (Mirror 1, ECC 24, EraseSize 512KB, Addr 5)"}, |
| 32 | {BOOT_DEVICE_NAND, "NAND (Mirror 8, ECC 8, ONFI, Addr 4)"}, |
| 33 | {BOOT_DEVICE_NAND, "NAND (Mirror 8, ECC 8, ONFI, Addr 5)"}, |
| 34 | {BOOT_DEVICE_NAND, "NAND (Mirror 8, ECC 16, ONFI, Addr 5)"}, |
| 35 | {BOOT_DEVICE_NAND, "NAND (Mirror 8, ECC 24, ONFI, Addr 5)"}, |
| 36 | {BOOT_DEVICE_NAND, "NAND (Mirror 4, ECC 24, ONFI, Addr 5)"}, |
| 37 | {BOOT_DEVICE_NAND, "NAND (Mirror 1, ECC 8, ONFI, Addr 5)"}, |
| 38 | {BOOT_DEVICE_NAND, "NAND (Mirror 1, ECC 16, ONFI, Addr 5)"}, |
| 39 | {BOOT_DEVICE_NAND, "NAND (Mirror 1, ECC 24, ONFI, Addr 5)"}, |
| 40 | {BOOT_DEVICE_MMC1, "eMMC Boot (3.3V)"}, |
| 41 | {BOOT_DEVICE_MMC1, "eMMC Boot (1.8V)"}, |
| 42 | {BOOT_DEVICE_NONE, "Reserved"}, |
| 43 | {BOOT_DEVICE_NONE, "Reserved"}, |
| 44 | {BOOT_DEVICE_NONE, "Reserved"}, |
| 45 | {BOOT_DEVICE_NONE, "Reserved"}, |
| 46 | {BOOT_DEVICE_NONE, "Reserved"}, |
| 47 | {BOOT_DEVICE_NONE, "Reserved"}, |
Masahiro Yamada | e3cfe8c | 2015-02-05 20:56:24 +0900 | [diff] [blame] | 48 | { /* sentinel */ } |
Masahiro Yamada | bb2ff9d | 2014-10-03 19:21:06 +0900 | [diff] [blame] | 49 | }; |
| 50 | |
Masahiro Yamada | b2bff68 | 2015-02-05 20:56:23 +0900 | [diff] [blame] | 51 | int get_boot_mode_sel(void) |
Masahiro Yamada | bb2ff9d | 2014-10-03 19:21:06 +0900 | [diff] [blame] | 52 | { |
| 53 | return (readl(SG_PINMON0) >> 1) & 0x1f; |
| 54 | } |
| 55 | |
| 56 | u32 spl_boot_device(void) |
| 57 | { |
Masahiro Yamada | b2bff68 | 2015-02-05 20:56:23 +0900 | [diff] [blame] | 58 | int boot_mode; |
Masahiro Yamada | bb2ff9d | 2014-10-03 19:21:06 +0900 | [diff] [blame] | 59 | |
| 60 | if (boot_is_swapped()) |
| 61 | return BOOT_DEVICE_NOR; |
| 62 | |
| 63 | boot_mode = get_boot_mode_sel(); |
| 64 | |
| 65 | return boot_device_table[boot_mode].type; |
| 66 | } |