blob: 0622a1e16e0dfc3a63b04fa46f962538958eca66 [file] [log] [blame]
Masahiro Yamadabb2ff9d2014-10-03 19:21:06 +09001/*
2 * Copyright (C) 2014 Panasonic Corporation
3 * Author: Masahiro Yamada <yamada.m@jp.panasonic.com>
4 *
5 * SPDX-License-Identifier: GPL-2.0+
6 */
7
8#include <common.h>
9#include <spl.h>
10#include <nand.h>
11#include <asm/io.h>
12#include <../drivers/mtd/nand/denali.h>
13
14static void nand_denali_wp_disable(void)
15{
16#ifdef CONFIG_NAND_DENALI
17 /*
18 * Since the boot rom enables the write protection for NAND boot mode,
19 * it must be disabled somewhere for "nand write", "nand erase", etc.
20 * The workaround is here to not disturb the Denali NAND controller
21 * driver just for a really SoC-specific thing.
22 */
23 void __iomem *denali_reg = (void __iomem *)CONFIG_SYS_NAND_REGS_BASE;
24
25 writel(WRITE_PROTECT__FLAG, denali_reg + WRITE_PROTECT);
26#endif
27}
28
Masahiro Yamadabb2ff9d2014-10-03 19:21:06 +090029int board_late_init(void)
30{
31 puts("MODE: ");
32
33 switch (spl_boot_device()) {
34 case BOOT_DEVICE_MMC1:
35 printf("eMMC Boot\n");
36 setenv("bootmode", "emmcboot");
Masahiro Yamadabb2ff9d2014-10-03 19:21:06 +090037 break;
38 case BOOT_DEVICE_NAND:
39 printf("NAND Boot\n");
40 setenv("bootmode", "nandboot");
41 nand_denali_wp_disable();
42 break;
43 case BOOT_DEVICE_NOR:
44 printf("NOR Boot\n");
45 setenv("bootmode", "norboot");
Masahiro Yamadabb2ff9d2014-10-03 19:21:06 +090046 break;
47 default:
48 printf("Unsupported Boot Mode\n");
49 return -1;
50 }
51
52 return 0;
53}