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