blob: 677470cdc6497fd3eb35f961544c8a1075d1561f [file] [log] [blame]
Tom Rini10e47792018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
Masahiro Yamada1fe65d32015-09-22 00:27:41 +09002/*
Masahiro Yamadafb092032017-02-14 01:24:26 +09003 * Copyright (C) 2015-2017 Socionext Inc.
4 * Author: Masahiro Yamada <yamada.masahiro@socionext.com>
Masahiro Yamada1fe65d32015-09-22 00:27:41 +09005 */
6
Masahiro Yamada1fe65d32015-09-22 00:27:41 +09007#include <spl.h>
8#include <linux/io.h>
Masahiro Yamadafb092032017-02-14 01:24:26 +09009#include <linux/kernel.h>
Masahiro Yamadaefdf3402016-01-09 01:51:13 +090010
Masahiro Yamadaefdf3402016-01-09 01:51:13 +090011#include "boot-device.h"
Masahiro Yamada1fe65d32015-09-22 00:27:41 +090012
Masahiro Yamadafb092032017-02-14 01:24:26 +090013const struct uniphier_boot_device uniphier_pxs2_boot_device_table[] = {
Masahiro Yamada1fe65d32015-09-22 00:27:41 +090014 {BOOT_DEVICE_NAND, "NAND (Mirror 8, ECC 8, EraseSize 128KB, Addr 4)"},
15 {BOOT_DEVICE_NAND, "NAND (Mirror 8, ECC 8, EraseSize 128KB, Addr 5)"},
16 {BOOT_DEVICE_NAND, "NAND (Mirror 8, ECC 16, EraseSize 128KB, Addr 5)"},
17 {BOOT_DEVICE_NAND, "NAND (Mirror 8, ECC 8, EraseSize 256KB, Addr 5)"},
18 {BOOT_DEVICE_NAND, "NAND (Mirror 8, ECC 16, EraseSize 256KB, Addr 5)"},
19 {BOOT_DEVICE_NAND, "NAND (Mirror 8, ECC 8, EraseSize 512KB, Addr 5)"},
20 {BOOT_DEVICE_NAND, "NAND (Mirror 8, ECC 16, EraseSize 512KB, Addr 5)"},
21 {BOOT_DEVICE_NAND, "NAND (Mirror 8, ECC 16, EraseSize 128KB, Addr 4)"},
22 {BOOT_DEVICE_NAND, "NAND (Mirror 1, ECC 8, EraseSize 128KB, Addr 5)"},
23 {BOOT_DEVICE_NAND, "NAND (Mirror 1, ECC 16, EraseSize 128KB, Addr 5)"},
24 {BOOT_DEVICE_NAND, "NAND (Mirror 1, ECC 8, EraseSize 256KB, Addr 5)"},
25 {BOOT_DEVICE_NAND, "NAND (Mirror 1, ECC 16, EraseSize 256KB, Addr 5)"},
26 {BOOT_DEVICE_NAND, "NAND (Mirror 1, ECC 8, EraseSize 512KB, Addr 5)"},
27 {BOOT_DEVICE_NAND, "NAND (Mirror 1, ECC 16, EraseSize 512KB, Addr 5)"},
28 {BOOT_DEVICE_NAND, "NAND (Mirror 1, ECC 8, EraseSize 128KB, Addr 4)"},
29 {BOOT_DEVICE_NAND, "NAND (Mirror 1, ECC 16, EraseSize 128KB, Addr 4)"},
30 {BOOT_DEVICE_NAND, "NAND (Mirror 8, ECC 8, ONFI, Addr 4)"},
31 {BOOT_DEVICE_NAND, "NAND (Mirror 8, ECC 8, ONFI, Addr 5)"},
32 {BOOT_DEVICE_NAND, "NAND (Mirror 8, ECC 16, ONFI, Addr 5)"},
33 {BOOT_DEVICE_NAND, "NAND (Mirror 8, ECC 16, ONFI, Addr 4)"},
Masahiro Yamadafd9256d2016-05-24 21:13:58 +090034 {BOOT_DEVICE_MMC1, "eMMC (1.8V)"},
Masahiro Yamada1fe65d32015-09-22 00:27:41 +090035 {BOOT_DEVICE_NAND, "NAND (Mirror 1, ECC 8, ONFI, Addr 5)"},
36 {BOOT_DEVICE_NAND, "NAND (Mirror 1, ECC 16, ONFI, Addr 5)"},
37 {BOOT_DEVICE_NAND, "NAND (Mirror 1, ECC 8, ONFI, Addr 4)"},
38 {BOOT_DEVICE_NAND, "NAND (Mirror 1, ECC 16, ONFI, Addr 4)"},
Masahiro Yamadafd9256d2016-05-24 21:13:58 +090039 {BOOT_DEVICE_SPI, "SPI (3Byte CS0)"},
40 {BOOT_DEVICE_SPI, "SPI (4Byte CS0)"},
41 {BOOT_DEVICE_SPI, "SPI (3Byte CS1)"},
42 {BOOT_DEVICE_SPI, "SPI (4Byte CS1)"},
43 {BOOT_DEVICE_SPI, "SPI (4Byte CS0)"},
44 {BOOT_DEVICE_SPI, "SPI (3Byte CS0)"},
Masahiro Yamada1fe65d32015-09-22 00:27:41 +090045 {BOOT_DEVICE_NONE, "Reserved"},
46};
47
Masahiro Yamadafb092032017-02-14 01:24:26 +090048const unsigned uniphier_pxs2_boot_device_count =
49 ARRAY_SIZE(uniphier_pxs2_boot_device_table);
Masahiro Yamada1fe65d32015-09-22 00:27:41 +090050
Masahiro Yamadafb092032017-02-14 01:24:26 +090051int uniphier_pxs2_boot_device_is_usb(u32 pinmon)
Masahiro Yamada1fe65d32015-09-22 00:27:41 +090052{
Masahiro Yamadafb092032017-02-14 01:24:26 +090053 return !!(pinmon & 0x00000040);
Masahiro Yamada1fe65d32015-09-22 00:27:41 +090054}
55
Masahiro Yamadafb092032017-02-14 01:24:26 +090056unsigned int uniphier_pxs2_boot_device_fixup(unsigned int mode)
Masahiro Yamada1fe65d32015-09-22 00:27:41 +090057{
Masahiro Yamadafb092032017-02-14 01:24:26 +090058 if (mode == BOOT_DEVICE_USB)
59 return BOOT_DEVICE_NOR;
Masahiro Yamada1fe65d32015-09-22 00:27:41 +090060
Masahiro Yamadafb092032017-02-14 01:24:26 +090061 return mode;
Masahiro Yamada1fe65d32015-09-22 00:27:41 +090062}