4 * SPDX-License-Identifier: GPL-2.0+
12 #include <../drivers/mtd/nand/denali.h>
14 #include "boot-mode/boot-device.h"
16 static void nand_denali_wp_disable(void)
18 #ifdef CONFIG_NAND_DENALI
20 * Since the boot rom enables the write protection for NAND boot mode,
21 * it must be disabled somewhere for "nand write", "nand erase", etc.
22 * The workaround is here to not disturb the Denali NAND controller
23 * driver just for a really SoC-specific thing.
25 void __iomem *denali_reg = (void __iomem *)CONFIG_SYS_NAND_REGS_BASE;
27 writel(WRITE_PROTECT__FLAG, denali_reg + WRITE_PROTECT);
31 struct uniphier_fdt_file {
32 const char *compatible;
33 const char *file_name;
36 static const struct uniphier_fdt_file uniphier_fdt_files[] = {
37 { "socionext,ph1-ld4-ref", "uniphier-ph1-ld4-ref.dtb", },
38 { "socionext,ph1-ld6b-ref", "uniphier-ph1-ld6b-ref.dtb", },
39 { "socionext,ph1-ld10-ref", "uniphier-ph1-ld10-ref.dtb", },
40 { "socionext,ph1-pro4-ref", "uniphier-ph1-pro4-ref.dtb", },
41 { "socionext,ph1-pro5-4kbox", "uniphier-ph1-pro5-4kbox.dtb", },
42 { "socionext,ph1-sld3-ref", "uniphier-ph1-sld3-ref.dtb", },
43 { "socionext,ph1-sld8-ref", "uniphier-ph1-sld8-ref.dtb", },
44 { "socionext,proxstream2-gentil", "uniphier-proxstream2-gentil.dtb", },
45 { "socionext,proxstream2-vodka", "uniphier-proxstream2-vodka.dtb", },
48 static void uniphier_set_fdt_file(void)
50 DECLARE_GLOBAL_DATA_PTR;
53 /* lookup DTB file name based on the compatible string */
54 for (i = 0; i < ARRAY_SIZE(uniphier_fdt_files); i++) {
55 if (!fdt_node_check_compatible(gd->fdt_blob, 0,
56 uniphier_fdt_files[i].compatible)) {
57 setenv("fdt_file", uniphier_fdt_files[i].file_name);
63 int board_late_init(void)
67 switch (spl_boot_device_raw()) {
68 case BOOT_DEVICE_MMC1:
69 printf("eMMC Boot\n");
70 setenv("bootmode", "emmcboot");
72 case BOOT_DEVICE_NAND:
73 printf("NAND Boot\n");
74 setenv("bootmode", "nandboot");
75 nand_denali_wp_disable();
79 setenv("bootmode", "norboot");
83 setenv("bootmode", "usbboot");
86 printf("Unsupported Boot Mode\n");
90 uniphier_set_fdt_file();