Merge tag 'u-boot-atmel-fixes-2020.07-a' of https://gitlab.denx.de/u-boot/custodians...
[oweals/u-boot.git] / board / firefly / roc-pc-rk3399 / roc-pc-rk3399.c
1 // SPDX-License-Identifier: GPL-2.0+
2 /*
3  * (C) Copyright 2016 Rockchip Electronics Co., Ltd
4  */
5
6 #include <common.h>
7 #include <dm.h>
8 #include <log.h>
9 #include <asm/arch-rockchip/periph.h>
10 #include <power/regulator.h>
11 #include <spl_gpio.h>
12 #include <asm/io.h>
13 #include <asm/arch-rockchip/gpio.h>
14
15 #ifndef CONFIG_SPL_BUILD
16 int board_early_init_f(void)
17 {
18         struct udevice *regulator;
19         int ret;
20
21         ret = regulator_get_by_platname("vcc5v0_host", &regulator);
22         if (ret) {
23                 debug("%s vcc5v0_host init fail! ret %d\n", __func__, ret);
24                 goto out;
25         }
26
27         ret = regulator_set_enable(regulator, true);
28         if (ret)
29                 debug("%s vcc5v0-host-en set fail! ret %d\n", __func__, ret);
30 out:
31         return 0;
32 }
33 #endif
34
35 #if defined(CONFIG_TPL_BUILD)
36
37 #define GPIO0_BASE      0xff720000
38
39 int board_early_init_f(void)
40 {
41         struct rockchip_gpio_regs * const gpio0 = (void *)GPIO0_BASE;
42
43         /* Turn on red LED, indicating full power mode */
44         spl_gpio_output(gpio0, GPIO(BANK_B, 5), 1);
45
46         return 0;
47 }
48 #endif