1 // SPDX-License-Identifier: GPL-2.0+
2 /*
3  * Copyright (C) 2015-2017 Socionext Inc.
4  *   Author: Masahiro Yamada <yamada.masahiro@socionext.com>
5  */
6 
7 #include <common.h>
8 #include <spl.h>
9 #include <linux/io.h>
10 #include <linux/kernel.h>
11 
12 #include "boot-device.h"
13 
14 const struct uniphier_boot_device uniphier_pxs2_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 16, EraseSize 128KB, Addr 4)"},
23 	{BOOT_DEVICE_NAND, "NAND (Mirror 1, ECC  8, EraseSize 128KB, Addr 5)"},
24 	{BOOT_DEVICE_NAND, "NAND (Mirror 1, ECC 16, EraseSize 128KB, Addr 5)"},
25 	{BOOT_DEVICE_NAND, "NAND (Mirror 1, ECC  8, EraseSize 256KB, Addr 5)"},
26 	{BOOT_DEVICE_NAND, "NAND (Mirror 1, ECC 16, EraseSize 256KB, Addr 5)"},
27 	{BOOT_DEVICE_NAND, "NAND (Mirror 1, ECC  8, EraseSize 512KB, Addr 5)"},
28 	{BOOT_DEVICE_NAND, "NAND (Mirror 1, ECC 16, EraseSize 512KB, Addr 5)"},
29 	{BOOT_DEVICE_NAND, "NAND (Mirror 1, ECC  8, EraseSize 128KB, Addr 4)"},
30 	{BOOT_DEVICE_NAND, "NAND (Mirror 1, ECC 16, EraseSize 128KB, Addr 4)"},
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 16, ONFI,            Addr 4)"},
35 	{BOOT_DEVICE_MMC1, "eMMC (1.8V)"},
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  8, ONFI,            Addr 4)"},
39 	{BOOT_DEVICE_NAND, "NAND (Mirror 1, ECC 16, ONFI,            Addr 4)"},
40 	{BOOT_DEVICE_SPI,  "SPI  (3Byte CS0)"},
41 	{BOOT_DEVICE_SPI,  "SPI  (4Byte CS0)"},
42 	{BOOT_DEVICE_SPI,  "SPI  (3Byte CS1)"},
43 	{BOOT_DEVICE_SPI,  "SPI  (4Byte CS1)"},
44 	{BOOT_DEVICE_SPI,  "SPI  (4Byte CS0)"},
45 	{BOOT_DEVICE_SPI,  "SPI  (3Byte CS0)"},
46 	{BOOT_DEVICE_NONE, "Reserved"},
47 };
48 
49 const unsigned uniphier_pxs2_boot_device_count =
50 				ARRAY_SIZE(uniphier_pxs2_boot_device_table);
51 
uniphier_pxs2_boot_device_is_usb(u32 pinmon)52 int uniphier_pxs2_boot_device_is_usb(u32 pinmon)
53 {
54 	return !!(pinmon & 0x00000040);
55 }
56 
uniphier_pxs2_boot_device_fixup(unsigned int mode)57 unsigned int uniphier_pxs2_boot_device_fixup(unsigned int mode)
58 {
59 	if (mode == BOOT_DEVICE_USB)
60 		return BOOT_DEVICE_NOR;
61 
62 	return mode;
63 }
64