blob: 9005705db108213265294b3a9416e66b290196ef [file] [log] [blame]
Heiko Stübner0b3c26a2017-02-18 19:46:38 +01001/*
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übner015f69a2017-04-06 00:19:36 +020014#include <asm/arch/grf_rk3188.h>
Heiko Stübner0b3c26a2017-02-18 19:46:38 +010015#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
Heiko Stübner015f69a2017-04-06 00:19:36 +020021int board_late_init(void)
22{
23 struct rk3188_grf *grf;
24
Andy Yan70378cb2017-10-11 15:00:16 +080025 setup_boot_mode();
Heiko Stübner015f69a2017-04-06 00:19:36 +020026 grf = syscon_get_first_range(ROCKCHIP_SYSCON_GRF);
27 if (IS_ERR(grf)) {
Masahiro Yamada81e10422017-09-16 14:10:41 +090028 pr_err("grf syscon returned %ld\n", PTR_ERR(grf));
Heiko Stübner015f69a2017-04-06 00:19:36 +020029 } else {
30 /* enable noc remap to mimic legacy loaders */
31 rk_clrsetreg(&grf->soc_con0,
32 NOC_REMAP_MASK << NOC_REMAP_SHIFT,
33 NOC_REMAP_MASK << NOC_REMAP_SHIFT);
34 }
35
36 return 0;
37}
38
Heiko Stübner0b3c26a2017-02-18 19:46:38 +010039int board_init(void)
40{
Philipp Tomsich798370f2017-06-29 11:21:15 +020041#if CONFIG_IS_ENABLED(ROCKCHIP_BACK_TO_BROM)
Heiko Stübner0b3c26a2017-02-18 19:46:38 +010042 struct udevice *pinctrl;
43 int ret;
44
45 /*
46 * We need to implement sdcard iomux here for the further
47 * initialization, otherwise, it'll hit sdcard command sending
48 * timeout exception.
49 */
50 ret = uclass_get_device(UCLASS_PINCTRL, 0, &pinctrl);
51 if (ret) {
52 debug("%s: Cannot find pinctrl device\n", __func__);
53 goto err;
54 }
55 ret = pinctrl_request_noflags(pinctrl, PERIPH_ID_SDCARD);
56 if (ret) {
57 debug("%s: Failed to set up SD card\n", __func__);
58 goto err;
59 }
60
61 return 0;
62err:
63 printf("board_init: Error %d\n", ret);
64
65 /* No way to report error here */
66 hang();
67
68 return -1;
69#else
70 return 0;
71#endif
72}
73
Heiko Stübner0b3c26a2017-02-18 19:46:38 +010074#ifndef CONFIG_SYS_DCACHE_OFF
75void enable_caches(void)
76{
77 /* Enable D-cache. I-cache is already enabled in start.S */
78 dcache_enable();
79}
80#endif