blob: 20a9511549ff9c0efcd663cf6cd0e6ea3308b630 [file] [log] [blame]
Masahiro Yamada1fe65d32015-09-22 00:27:41 +09001/*
Masahiro Yamadafb092032017-02-14 01:24:26 +09002 * Copyright (C) 2015-2017 Socionext Inc.
3 * Author: Masahiro Yamada <yamada.masahiro@socionext.com>
Masahiro Yamada1fe65d32015-09-22 00:27:41 +09004 *
5 * SPDX-License-Identifier: GPL-2.0+
6 */
7
8#include <common.h>
9#include <spl.h>
10#include <linux/io.h>
Masahiro Yamadafb092032017-02-14 01:24:26 +090011#include <linux/kernel.h>
Masahiro Yamadaefdf3402016-01-09 01:51:13 +090012
Masahiro Yamadaefdf3402016-01-09 01:51:13 +090013#include "boot-device.h"
Masahiro Yamada1fe65d32015-09-22 00:27:41 +090014
Masahiro Yamadafb092032017-02-14 01:24:26 +090015const struct uniphier_boot_device uniphier_pxs2_boot_device_table[] = {
Masahiro Yamada1fe65d32015-09-22 00:27:41 +090016 {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 16, EraseSize 128KB, Addr 4)"},
24 {BOOT_DEVICE_NAND, "NAND (Mirror 1, ECC 8, EraseSize 128KB, Addr 5)"},
25 {BOOT_DEVICE_NAND, "NAND (Mirror 1, ECC 16, EraseSize 128KB, Addr 5)"},
26 {BOOT_DEVICE_NAND, "NAND (Mirror 1, ECC 8, EraseSize 256KB, Addr 5)"},
27 {BOOT_DEVICE_NAND, "NAND (Mirror 1, ECC 16, EraseSize 256KB, Addr 5)"},
28 {BOOT_DEVICE_NAND, "NAND (Mirror 1, ECC 8, EraseSize 512KB, Addr 5)"},
29 {BOOT_DEVICE_NAND, "NAND (Mirror 1, ECC 16, EraseSize 512KB, Addr 5)"},
30 {BOOT_DEVICE_NAND, "NAND (Mirror 1, ECC 8, EraseSize 128KB, Addr 4)"},
31 {BOOT_DEVICE_NAND, "NAND (Mirror 1, ECC 16, EraseSize 128KB, Addr 4)"},
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 16, ONFI, Addr 4)"},
Masahiro Yamadafd9256d2016-05-24 21:13:58 +090036 {BOOT_DEVICE_MMC1, "eMMC (1.8V)"},
Masahiro Yamada1fe65d32015-09-22 00:27:41 +090037 {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 8, ONFI, Addr 4)"},
40 {BOOT_DEVICE_NAND, "NAND (Mirror 1, ECC 16, ONFI, Addr 4)"},
Masahiro Yamadafd9256d2016-05-24 21:13:58 +090041 {BOOT_DEVICE_SPI, "SPI (3Byte CS0)"},
42 {BOOT_DEVICE_SPI, "SPI (4Byte CS0)"},
43 {BOOT_DEVICE_SPI, "SPI (3Byte CS1)"},
44 {BOOT_DEVICE_SPI, "SPI (4Byte CS1)"},
45 {BOOT_DEVICE_SPI, "SPI (4Byte CS0)"},
46 {BOOT_DEVICE_SPI, "SPI (3Byte CS0)"},
Masahiro Yamada1fe65d32015-09-22 00:27:41 +090047 {BOOT_DEVICE_NONE, "Reserved"},
48};
49
Masahiro Yamadafb092032017-02-14 01:24:26 +090050const unsigned uniphier_pxs2_boot_device_count =
51 ARRAY_SIZE(uniphier_pxs2_boot_device_table);
Masahiro Yamada1fe65d32015-09-22 00:27:41 +090052
Masahiro Yamadafb092032017-02-14 01:24:26 +090053int uniphier_pxs2_boot_device_is_usb(u32 pinmon)
Masahiro Yamada1fe65d32015-09-22 00:27:41 +090054{
Masahiro Yamadafb092032017-02-14 01:24:26 +090055 return !!(pinmon & 0x00000040);
Masahiro Yamada1fe65d32015-09-22 00:27:41 +090056}
57
Masahiro Yamadafb092032017-02-14 01:24:26 +090058unsigned int uniphier_pxs2_boot_device_fixup(unsigned int mode)
Masahiro Yamada1fe65d32015-09-22 00:27:41 +090059{
Masahiro Yamadafb092032017-02-14 01:24:26 +090060 if (mode == BOOT_DEVICE_USB)
61 return BOOT_DEVICE_NOR;
Masahiro Yamada1fe65d32015-09-22 00:27:41 +090062
Masahiro Yamadafb092032017-02-14 01:24:26 +090063 return mode;
Masahiro Yamada1fe65d32015-09-22 00:27:41 +090064}