Tom Rini | 10e4779 | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
Heiko Stübner | 0b3c26a | 2017-02-18 19:46:38 +0100 | [diff] [blame] | 2 | /* |
| 3 | * (C) Copyright 2015 Google, Inc |
Heiko Stübner | 0b3c26a | 2017-02-18 19:46:38 +0100 | [diff] [blame] | 4 | */ |
| 5 | |
| 6 | #include <common.h> |
| 7 | #include <clk.h> |
| 8 | #include <dm.h> |
| 9 | #include <ram.h> |
| 10 | #include <syscon.h> |
| 11 | #include <asm/io.h> |
| 12 | #include <asm/arch/clock.h> |
Heiko Stübner | 015f69a | 2017-04-06 00:19:36 +0200 | [diff] [blame] | 13 | #include <asm/arch/grf_rk3188.h> |
Heiko Stübner | 0b3c26a | 2017-02-18 19:46:38 +0100 | [diff] [blame] | 14 | #include <asm/arch/periph.h> |
| 15 | #include <asm/arch/pmu_rk3288.h> |
| 16 | #include <asm/arch/boot_mode.h> |
| 17 | #include <asm/gpio.h> |
| 18 | #include <dm/pinctrl.h> |
| 19 | |
Heiko Stübner | 015f69a | 2017-04-06 00:19:36 +0200 | [diff] [blame] | 20 | int board_late_init(void) |
| 21 | { |
| 22 | struct rk3188_grf *grf; |
| 23 | |
Andy Yan | 70378cb | 2017-10-11 15:00:16 +0800 | [diff] [blame] | 24 | setup_boot_mode(); |
Heiko Stübner | 015f69a | 2017-04-06 00:19:36 +0200 | [diff] [blame] | 25 | grf = syscon_get_first_range(ROCKCHIP_SYSCON_GRF); |
| 26 | if (IS_ERR(grf)) { |
Masahiro Yamada | 81e1042 | 2017-09-16 14:10:41 +0900 | [diff] [blame] | 27 | pr_err("grf syscon returned %ld\n", PTR_ERR(grf)); |
Heiko Stübner | 015f69a | 2017-04-06 00:19:36 +0200 | [diff] [blame] | 28 | } else { |
| 29 | /* enable noc remap to mimic legacy loaders */ |
| 30 | rk_clrsetreg(&grf->soc_con0, |
| 31 | NOC_REMAP_MASK << NOC_REMAP_SHIFT, |
| 32 | NOC_REMAP_MASK << NOC_REMAP_SHIFT); |
| 33 | } |
| 34 | |
| 35 | return 0; |
| 36 | } |
| 37 | |
Heiko Stübner | 0b3c26a | 2017-02-18 19:46:38 +0100 | [diff] [blame] | 38 | int board_init(void) |
| 39 | { |
Philipp Tomsich | 798370f | 2017-06-29 11:21:15 +0200 | [diff] [blame] | 40 | #if CONFIG_IS_ENABLED(ROCKCHIP_BACK_TO_BROM) |
Heiko Stübner | 0b3c26a | 2017-02-18 19:46:38 +0100 | [diff] [blame] | 41 | struct udevice *pinctrl; |
| 42 | int ret; |
| 43 | |
| 44 | /* |
| 45 | * We need to implement sdcard iomux here for the further |
| 46 | * initialization, otherwise, it'll hit sdcard command sending |
| 47 | * timeout exception. |
| 48 | */ |
| 49 | ret = uclass_get_device(UCLASS_PINCTRL, 0, &pinctrl); |
| 50 | if (ret) { |
| 51 | debug("%s: Cannot find pinctrl device\n", __func__); |
| 52 | goto err; |
| 53 | } |
| 54 | ret = pinctrl_request_noflags(pinctrl, PERIPH_ID_SDCARD); |
| 55 | if (ret) { |
| 56 | debug("%s: Failed to set up SD card\n", __func__); |
| 57 | goto err; |
| 58 | } |
| 59 | |
| 60 | return 0; |
| 61 | err: |
| 62 | printf("board_init: Error %d\n", ret); |
| 63 | |
| 64 | /* No way to report error here */ |
| 65 | hang(); |
| 66 | |
| 67 | return -1; |
| 68 | #else |
| 69 | return 0; |
| 70 | #endif |
| 71 | } |
| 72 | |
Heiko Stübner | 0b3c26a | 2017-02-18 19:46:38 +0100 | [diff] [blame] | 73 | #ifndef CONFIG_SYS_DCACHE_OFF |
| 74 | void enable_caches(void) |
| 75 | { |
| 76 | /* Enable D-cache. I-cache is already enabled in start.S */ |
| 77 | dcache_enable(); |
| 78 | } |
| 79 | #endif |