Masahiro Yamada | 063eb1e | 2016-04-21 14:43:18 +0900 | [diff] [blame] | 1 | /* |
Masahiro Yamada | 3164905 | 2017-01-21 18:05:26 +0900 | [diff] [blame] | 2 | * Copyright (C) 2016-2017 Socionext Inc. |
| 3 | * Author: Masahiro Yamada <yamada.masahiro@socionext.com> |
Masahiro Yamada | 063eb1e | 2016-04-21 14:43:18 +0900 | [diff] [blame] | 4 | * |
| 5 | * SPDX-License-Identifier: GPL-2.0+ |
| 6 | */ |
| 7 | |
| 8 | #include <common.h> |
| 9 | #include <spl.h> |
| 10 | #include <linux/io.h> |
Masahiro Yamada | fb09203 | 2017-02-14 01:24:26 +0900 | [diff] [blame] | 11 | #include <linux/kernel.h> |
Masahiro Yamada | 063eb1e | 2016-04-21 14:43:18 +0900 | [diff] [blame] | 12 | |
Masahiro Yamada | 063eb1e | 2016-04-21 14:43:18 +0900 | [diff] [blame] | 13 | #include "boot-device.h" |
| 14 | |
Masahiro Yamada | fb09203 | 2017-02-14 01:24:26 +0900 | [diff] [blame] | 15 | const struct uniphier_boot_device uniphier_ld11_boot_device_table[] = { |
Masahiro Yamada | 063eb1e | 2016-04-21 14:43:18 +0900 | [diff] [blame] | 16 | {BOOT_DEVICE_NAND, "NAND (Mirror 8, ECC 8, EraseSize 128KB, Addr 4)"}, |
| 17 | {BOOT_DEVICE_NAND, "NAND (Mirror 8, ECC 16, EraseSize 128KB, Addr 4)"}, |
| 18 | {BOOT_DEVICE_NAND, "NAND (Mirror 8, ECC 8, EraseSize 128KB, Addr 5)"}, |
| 19 | {BOOT_DEVICE_NAND, "NAND (Mirror 8, ECC 16, EraseSize 128KB, Addr 5)"}, |
| 20 | {BOOT_DEVICE_NAND, "NAND (Mirror 8, ECC 8, EraseSize 256KB, Addr 5)"}, |
| 21 | {BOOT_DEVICE_NAND, "NAND (Mirror 8, ECC 16, EraseSize 256KB, Addr 5)"}, |
| 22 | {BOOT_DEVICE_NAND, "NAND (Mirror 8, ECC 8, EraseSize 512KB, Addr 5)"}, |
| 23 | {BOOT_DEVICE_NAND, "NAND (Mirror 8, ECC 16, EraseSize 512KB, Addr 5)"}, |
| 24 | {BOOT_DEVICE_NAND, "NAND (Mirror 1, ECC 8, EraseSize 128KB, Addr 4)"}, |
| 25 | {BOOT_DEVICE_NAND, "NAND (Mirror 1, ECC 16, EraseSize 128KB, Addr 4)"}, |
| 26 | {BOOT_DEVICE_NAND, "NAND (Mirror 1, ECC 8, EraseSize 128KB, Addr 5)"}, |
| 27 | {BOOT_DEVICE_NAND, "NAND (Mirror 1, ECC 16, EraseSize 128KB, Addr 5)"}, |
| 28 | {BOOT_DEVICE_NAND, "NAND (Mirror 1, ECC 8, EraseSize 256KB, Addr 5)"}, |
| 29 | {BOOT_DEVICE_NAND, "NAND (Mirror 1, ECC 16, EraseSize 256KB, Addr 5)"}, |
| 30 | {BOOT_DEVICE_NAND, "NAND (Mirror 1, ECC 8, EraseSize 512KB, Addr 5)"}, |
| 31 | {BOOT_DEVICE_NAND, "NAND (Mirror 1, ECC 16, EraseSize 512KB, Addr 5)"}, |
| 32 | {BOOT_DEVICE_NAND, "NAND (Mirror 8, ECC 8, ONFI, Addr 4)"}, |
| 33 | {BOOT_DEVICE_NAND, "NAND (Mirror 8, ECC 16, ONFI, Addr 4)"}, |
| 34 | {BOOT_DEVICE_NAND, "NAND (Mirror 8, ECC 8, ONFI, Addr 5)"}, |
| 35 | {BOOT_DEVICE_NAND, "NAND (Mirror 8, ECC 16, ONFI, Addr 5)"}, |
| 36 | {BOOT_DEVICE_NAND, "NAND (Mirror 1, ECC 8, ONFI Addr 4)"}, |
| 37 | {BOOT_DEVICE_NAND, "NAND (Mirror 1, ECC 16, ONFI Addr 4)"}, |
| 38 | {BOOT_DEVICE_NAND, "NAND (Mirror 1, ECC 8, ONFI Addr 5)"}, |
| 39 | {BOOT_DEVICE_NAND, "NAND (Mirror 1, ECC 16, ONFI Addr 5)"}, |
| 40 | {BOOT_DEVICE_MMC1, "eMMC (Legacy, 4bit, 1.8V, Training Off)"}, |
| 41 | {BOOT_DEVICE_MMC1, "eMMC (Legacy, 4bit, 1.8V, Training On)"}, |
| 42 | {BOOT_DEVICE_MMC1, "eMMC (Legacy, 8bit, 1.8V, Training Off)"}, |
| 43 | {BOOT_DEVICE_MMC1, "eMMC (Legacy, 8bit, 1.8V, Training On)"}, |
| 44 | {BOOT_DEVICE_MMC1, "eMMC (High Speed SDR, 8bit, 1.8V, Training Off)"}, |
| 45 | {BOOT_DEVICE_MMC1, "eMMC (High Speed SDR, 8bit, 1.8V, Training On)"}, |
| 46 | {BOOT_DEVICE_MMC1, "eMMC (Legacy, 4bit, 1.8V, Training Off)"}, |
Masahiro Yamada | fd9256d | 2016-05-24 21:13:58 +0900 | [diff] [blame] | 47 | {BOOT_DEVICE_NOR, "NOR (XECS1)"}, |
Masahiro Yamada | 063eb1e | 2016-04-21 14:43:18 +0900 | [diff] [blame] | 48 | }; |
| 49 | |
Masahiro Yamada | fb09203 | 2017-02-14 01:24:26 +0900 | [diff] [blame] | 50 | const unsigned uniphier_ld11_boot_device_count = |
| 51 | ARRAY_SIZE(uniphier_ld11_boot_device_table); |
| 52 | |
| 53 | int uniphier_ld11_boot_device_is_usb(u32 pinmon) |
Masahiro Yamada | 063eb1e | 2016-04-21 14:43:18 +0900 | [diff] [blame] | 54 | { |
Masahiro Yamada | fb09203 | 2017-02-14 01:24:26 +0900 | [diff] [blame] | 55 | return !!(~pinmon & 0x00000080); |
Masahiro Yamada | 063eb1e | 2016-04-21 14:43:18 +0900 | [diff] [blame] | 56 | } |
| 57 | |
Masahiro Yamada | fb09203 | 2017-02-14 01:24:26 +0900 | [diff] [blame] | 58 | int uniphier_ld20_boot_device_is_usb(u32 pinmon) |
Masahiro Yamada | 063eb1e | 2016-04-21 14:43:18 +0900 | [diff] [blame] | 59 | { |
Masahiro Yamada | fb09203 | 2017-02-14 01:24:26 +0900 | [diff] [blame] | 60 | return !!(~pinmon & 0x00000780); |
Masahiro Yamada | 063eb1e | 2016-04-21 14:43:18 +0900 | [diff] [blame] | 61 | } |
| 62 | |
Masahiro Yamada | fb09203 | 2017-02-14 01:24:26 +0900 | [diff] [blame] | 63 | unsigned int uniphier_ld11_boot_device_fixup(unsigned int mode) |
Masahiro Yamada | 063eb1e | 2016-04-21 14:43:18 +0900 | [diff] [blame] | 64 | { |
Masahiro Yamada | fb09203 | 2017-02-14 01:24:26 +0900 | [diff] [blame] | 65 | if (mode == BOOT_DEVICE_MMC1 || mode == BOOT_DEVICE_USB) |
| 66 | mode = BOOT_DEVICE_BOARD; |
Masahiro Yamada | 063eb1e | 2016-04-21 14:43:18 +0900 | [diff] [blame] | 67 | |
Masahiro Yamada | fb09203 | 2017-02-14 01:24:26 +0900 | [diff] [blame] | 68 | return mode; |
Masahiro Yamada | 063eb1e | 2016-04-21 14:43:18 +0900 | [diff] [blame] | 69 | } |