]> git.kernelconcepts.de Git - karo-tx-uboot.git/blob - arch/arm/cpu/armv7/uniphier/board_late_init.c
Merge branch 'master' of git://git.denx.de/u-boot-usb
[karo-tx-uboot.git] / arch / arm / cpu / armv7 / uniphier / board_late_init.c
1 /*
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
14 static 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
29 int 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");
37                 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");
46                 break;
47         default:
48                 printf("Unsupported Boot Mode\n");
49                 return -1;
50         }
51
52         return 0;
53 }