blob: 6561c4fbd3de5d4fbb83d66d5682739c92a4fe66 [file] [log] [blame]
Kever Yang0d3d7832016-07-19 21:16:59 +08001/*
2 * (C) Copyright 2016 Rockchip Electronics Co., Ltd
3 *
4 * SPDX-License-Identifier: GPL-2.0+
5 */
6#include <common.h>
Kever Yang6d26c062016-08-16 17:58:13 +08007#include <dm.h>
8#include <dm/pinctrl.h>
Kever Yang11c21c52016-09-23 15:57:20 +08009#include <dm/uclass-internal.h>
Kever Yang6d26c062016-08-16 17:58:13 +080010#include <asm/arch/periph.h>
Kever Yangb1395292016-08-24 12:02:22 +080011#include <power/regulator.h>
Kever Yang0d3d7832016-07-19 21:16:59 +080012
13DECLARE_GLOBAL_DATA_PTR;
14
15int board_init(void)
16{
Kever Yangb1395292016-08-24 12:02:22 +080017 struct udevice *pinctrl, *regulator;
Kever Yang6d26c062016-08-16 17:58:13 +080018 int ret;
19
20 /*
21 * The PWM do not have decicated interrupt number in dts and can
22 * not get periph_id by pinctrl framework, so let's init them here.
23 * The PWM2 and PWM3 are for pwm regulater.
24 */
25 ret = uclass_get_device(UCLASS_PINCTRL, 0, &pinctrl);
26 if (ret) {
27 debug("%s: Cannot find pinctrl device\n", __func__);
28 goto out;
29 }
30
31 ret = pinctrl_request_noflags(pinctrl, PERIPH_ID_PWM2);
32 if (ret) {
33 debug("%s PWM2 pinctrl init fail!\n", __func__);
34 goto out;
35 }
36
37 ret = pinctrl_request_noflags(pinctrl, PERIPH_ID_PWM3);
38 if (ret) {
39 debug("%s PWM3 pinctrl init fail!\n", __func__);
40 goto out;
41 }
42
Kever Yang9988df72017-04-12 12:00:06 +080043 ret = regulators_enable_boot_on(false);
Kever Yang11c21c52016-09-23 15:57:20 +080044 if (ret)
Kever Yang9988df72017-04-12 12:00:06 +080045 debug("%s: Cannot enable boot on regulator\n", __func__);
Kever Yang11c21c52016-09-23 15:57:20 +080046
Kever Yangb1395292016-08-24 12:02:22 +080047 ret = regulator_get_by_platname("vcc5v0_host", &regulator);
48 if (ret) {
49 debug("%s vcc5v0_host init fail! ret %d\n", __func__, ret);
50 goto out;
51 }
52
53 ret = regulator_set_enable(regulator, true);
54 if (ret) {
55 debug("%s vcc5v0-host-en set fail!\n", __func__);
56 goto out;
57 }
58
Kever Yang6d26c062016-08-16 17:58:13 +080059out:
Kever Yang0d3d7832016-07-19 21:16:59 +080060 return 0;
61}
62
63int dram_init(void)
64{
65 gd->ram_size = 0x80000000;
66 return 0;
67}
68
Simon Glass2f949c32017-03-31 08:40:32 -060069int dram_init_banksize(void)
Kever Yang0d3d7832016-07-19 21:16:59 +080070{
Kever Yange6181f52016-07-25 11:45:54 +080071 /* Reserve 0x200000 for ATF bl31 */
72 gd->bd->bi_dram[0].start = 0x200000;
Kever Yangb6eda402016-11-07 16:30:34 +080073 gd->bd->bi_dram[0].size = 0x7e000000;
Simon Glass2f949c32017-03-31 08:40:32 -060074
75 return 0;
Kever Yang0d3d7832016-07-19 21:16:59 +080076}