Merge tag 'u-boot-rockchip-20200501' 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 <asm/arch-rockchip/periph.h>
9 #include <power/regulator.h>
10 #include <spl_gpio.h>
11 #include <asm/io.h>
12 #include <asm/arch-rockchip/gpio.h>
13
14 #ifndef CONFIG_SPL_BUILD
15 int board_early_init_f(void)
16 {
17         struct udevice *regulator;
18         int ret;
19
20         ret = regulator_get_by_platname("vcc5v0_host", &regulator);
21         if (ret) {
22                 debug("%s vcc5v0_host init fail! ret %d\n", __func__, ret);
23                 goto out;
24         }
25
26         ret = regulator_set_enable(regulator, true);
27         if (ret)
28                 debug("%s vcc5v0-host-en set fail! ret %d\n", __func__, ret);
29 out:
30         return 0;
31 }
32 #endif
33
34 #if defined(CONFIG_TPL_BUILD)
35
36 #define GPIO0_BASE      0xff720000
37
38 int board_early_init_f(void)
39 {
40         struct rockchip_gpio_regs * const gpio0 = (void *)GPIO0_BASE;
41
42         /* Turn on red LED, indicating full power mode */
43         spl_gpio_output(gpio0, GPIO(BANK_B, 5), 1);
44
45         return 0;
46 }
47 #endif