Masahiro Yamada | bb2ff9d | 2014-10-03 19:21:06 +0900 | [diff] [blame] | 1 | /* |
Masahiro Yamada | 663a23f | 2015-05-29 17:30:00 +0900 | [diff] [blame] | 2 | * Copyright (C) 2014-2015 Masahiro Yamada <yamada.masahiro@socionext.com> |
Masahiro Yamada | bb2ff9d | 2014-10-03 19:21:06 +0900 | [diff] [blame] | 3 | * |
| 4 | * SPDX-License-Identifier: GPL-2.0+ |
| 5 | */ |
| 6 | |
| 7 | #include <common.h> |
| 8 | #include <spl.h> |
| 9 | #include <nand.h> |
Masahiro Yamada | 663a23f | 2015-05-29 17:30:00 +0900 | [diff] [blame] | 10 | #include <linux/io.h> |
Masahiro Yamada | bb2ff9d | 2014-10-03 19:21:06 +0900 | [diff] [blame] | 11 | #include <../drivers/mtd/nand/denali.h> |
| 12 | |
| 13 | static 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 Yamada | bb2ff9d | 2014-10-03 19:21:06 +0900 | [diff] [blame] | 28 | int 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 Yamada | bb2ff9d | 2014-10-03 19:21:06 +0900 | [diff] [blame] | 36 | 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 Yamada | bb2ff9d | 2014-10-03 19:21:06 +0900 | [diff] [blame] | 45 | break; |
| 46 | default: |
| 47 | printf("Unsupported Boot Mode\n"); |
| 48 | return -1; |
| 49 | } |
| 50 | |
| 51 | return 0; |
| 52 | } |