blob: a7530eb23b5292fe8a59abc1b2b6d67ffb415e31 [file] [log] [blame]
Masahiro Yamada5894ca02014-10-03 19:21:06 +09001/*
Masahiro Yamadaf6e7f072015-05-29 17:30:00 +09002 * Copyright (C) 2014-2015 Masahiro Yamada <yamada.masahiro@socionext.com>
Masahiro Yamada5894ca02014-10-03 19:21:06 +09003 *
4 * SPDX-License-Identifier: GPL-2.0+
5 */
6
7#include <common.h>
8#include <spl.h>
9#include <nand.h>
Masahiro Yamadaf6e7f072015-05-29 17:30:00 +090010#include <linux/io.h>
Masahiro Yamada5894ca02014-10-03 19:21:06 +090011#include <../drivers/mtd/nand/denali.h>
12
13static void nand_denali_wp_disable(void)
14{
15#ifdef CONFIG_NAND_DENALI
16 /*
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.
21 */
22 void __iomem *denali_reg = (void __iomem *)CONFIG_SYS_NAND_REGS_BASE;
23
24 writel(WRITE_PROTECT__FLAG, denali_reg + WRITE_PROTECT);
25#endif
26}
27
Masahiro Yamada5894ca02014-10-03 19:21:06 +090028int board_late_init(void)
29{
30 puts("MODE: ");
31
32 switch (spl_boot_device()) {
33 case BOOT_DEVICE_MMC1:
34 printf("eMMC Boot\n");
35 setenv("bootmode", "emmcboot");
Masahiro Yamada5894ca02014-10-03 19:21:06 +090036 break;
37 case BOOT_DEVICE_NAND:
38 printf("NAND Boot\n");
39 setenv("bootmode", "nandboot");
40 nand_denali_wp_disable();
41 break;
42 case BOOT_DEVICE_NOR:
43 printf("NOR Boot\n");
44 setenv("bootmode", "norboot");
Masahiro Yamada5894ca02014-10-03 19:21:06 +090045 break;
46 default:
47 printf("Unsupported Boot Mode\n");
48 return -1;
49 }
50
51 return 0;
52}