2 * Copyright (C) 2014-2015 Masahiro Yamada <yamada.masahiro@socionext.com>
4 * SPDX-License-Identifier: GPL-2.0+
11 #include <../drivers/mtd/nand/denali.h>
13 static void nand_denali_wp_disable(void)
15 #ifdef CONFIG_NAND_DENALI
17 * Since the boot rom enables the write protection for NAND boot mode,
18 * it must be disabled somewhere for "nand write", "nand erase", etc.
19 * The workaround is here to not disturb the Denali NAND controller
20 * driver just for a really SoC-specific thing.
22 void __iomem *denali_reg = (void __iomem *)CONFIG_SYS_NAND_REGS_BASE;
24 writel(WRITE_PROTECT__FLAG, denali_reg + WRITE_PROTECT);
28 int board_late_init(void)
32 switch (spl_boot_device()) {
33 case BOOT_DEVICE_MMC1:
34 printf("eMMC Boot\n");
35 setenv("bootmode", "emmcboot");
37 case BOOT_DEVICE_NAND:
38 printf("NAND Boot\n");
39 setenv("bootmode", "nandboot");
40 nand_denali_wp_disable();
44 setenv("bootmode", "norboot");
47 printf("Unsupported Boot Mode\n");