rockchip: use 'arch-rockchip' as header file path
[project/bcm63xx/u-boot.git] / board / rockchip / evb_rk3399 / evb-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 <dm/pinctrl.h>
9 #include <dm/uclass-internal.h>
10 #include <asm/arch-rockchip/periph.h>
11 #include <power/regulator.h>
12 #include <spl.h>
13
14 int board_init(void)
15 {
16 struct udevice *pinctrl, *regulator;
17 int ret;
18
19 /*
20 * The PWM do not have decicated interrupt number in dts and can
21 * not get periph_id by pinctrl framework, so let's init them here.
22 * The PWM2 and PWM3 are for pwm regulater.
23 */
24 ret = uclass_get_device(UCLASS_PINCTRL, 0, &pinctrl);
25 if (ret) {
26 debug("%s: Cannot find pinctrl device\n", __func__);
27 goto out;
28 }
29
30 /* Enable pwm0 for panel backlight */
31 ret = pinctrl_request_noflags(pinctrl, PERIPH_ID_PWM0);
32 if (ret) {
33 debug("%s PWM0 pinctrl init fail! (ret=%d)\n", __func__, ret);
34 goto out;
35 }
36
37 ret = pinctrl_request_noflags(pinctrl, PERIPH_ID_PWM2);
38 if (ret) {
39 debug("%s PWM2 pinctrl init fail!\n", __func__);
40 goto out;
41 }
42
43 ret = pinctrl_request_noflags(pinctrl, PERIPH_ID_PWM3);
44 if (ret) {
45 debug("%s PWM3 pinctrl init fail!\n", __func__);
46 goto out;
47 }
48
49 ret = regulators_enable_boot_on(false);
50 if (ret)
51 debug("%s: Cannot enable boot on regulator\n", __func__);
52
53 ret = regulator_get_by_platname("vcc5v0_host", &regulator);
54 if (ret) {
55 debug("%s vcc5v0_host init fail! ret %d\n", __func__, ret);
56 goto out;
57 }
58
59 ret = regulator_set_enable(regulator, true);
60 if (ret) {
61 debug("%s vcc5v0-host-en set fail!\n", __func__);
62 goto out;
63 }
64
65 out:
66 return 0;
67 }
68
69 void spl_board_init(void)
70 {
71 struct udevice *pinctrl;
72 int ret;
73
74 ret = uclass_get_device(UCLASS_PINCTRL, 0, &pinctrl);
75 if (ret) {
76 debug("%s: Cannot find pinctrl device\n", __func__);
77 goto err;
78 }
79
80 /* Enable debug UART */
81 ret = pinctrl_request_noflags(pinctrl, PERIPH_ID_UART_DBG);
82 if (ret) {
83 debug("%s: Failed to set up console UART\n", __func__);
84 goto err;
85 }
86
87 preloader_console_init();
88 return;
89 err:
90 printf("%s: Error %d\n", __func__, ret);
91
92 /* No way to report error here */
93 hang();
94 }