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