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