Kever Yang | a381bcf | 2016-07-19 21:16:59 +0800 | [diff] [blame] | 1 | /* |
| 2 | * (C) Copyright 2016 Rockchip Electronics Co., Ltd |
| 3 | * |
| 4 | * SPDX-License-Identifier: GPL-2.0+ |
| 5 | */ |
| 6 | #include <common.h> |
Kever Yang | ad05138 | 2016-08-16 17:58:13 +0800 | [diff] [blame] | 7 | #include <dm.h> |
| 8 | #include <dm/pinctrl.h> |
Kever Yang | be3fcd0 | 2016-09-23 15:57:20 +0800 | [diff] [blame] | 9 | #include <dm/uclass-internal.h> |
Kever Yang | ad05138 | 2016-08-16 17:58:13 +0800 | [diff] [blame] | 10 | #include <asm/arch/periph.h> |
Kever Yang | 05c6e30 | 2016-08-24 12:02:22 +0800 | [diff] [blame] | 11 | #include <power/regulator.h> |
Kever Yang | a381bcf | 2016-07-19 21:16:59 +0800 | [diff] [blame] | 12 | |
| 13 | DECLARE_GLOBAL_DATA_PTR; |
| 14 | |
| 15 | int board_init(void) |
| 16 | { |
Kever Yang | 05c6e30 | 2016-08-24 12:02:22 +0800 | [diff] [blame] | 17 | struct udevice *pinctrl, *regulator; |
Kever Yang | ad05138 | 2016-08-16 17:58:13 +0800 | [diff] [blame] | 18 | 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 Yang | be3fcd0 | 2016-09-23 15:57:20 +0800 | [diff] [blame] | 43 | /* rk3399 need init vdd_center to get correct output voltage */ |
| 44 | ret = regulator_get_by_platname("vdd_center", ®ulator); |
| 45 | if (ret) |
| 46 | debug("%s: Cannot get vdd_center regulator\n", __func__); |
| 47 | |
Kever Yang | 05c6e30 | 2016-08-24 12:02:22 +0800 | [diff] [blame] | 48 | ret = regulator_get_by_platname("vcc5v0_host", ®ulator); |
| 49 | if (ret) { |
| 50 | debug("%s vcc5v0_host init fail! ret %d\n", __func__, ret); |
| 51 | goto out; |
| 52 | } |
| 53 | |
| 54 | ret = regulator_set_enable(regulator, true); |
| 55 | if (ret) { |
| 56 | debug("%s vcc5v0-host-en set fail!\n", __func__); |
| 57 | goto out; |
| 58 | } |
| 59 | |
Kever Yang | ad05138 | 2016-08-16 17:58:13 +0800 | [diff] [blame] | 60 | out: |
Kever Yang | a381bcf | 2016-07-19 21:16:59 +0800 | [diff] [blame] | 61 | return 0; |
| 62 | } |
| 63 | |
| 64 | int dram_init(void) |
| 65 | { |
| 66 | gd->ram_size = 0x80000000; |
| 67 | return 0; |
| 68 | } |
| 69 | |
| 70 | void dram_init_banksize(void) |
| 71 | { |
Kever Yang | 633fdab | 2016-07-25 11:45:54 +0800 | [diff] [blame] | 72 | /* Reserve 0x200000 for ATF bl31 */ |
| 73 | gd->bd->bi_dram[0].start = 0x200000; |
Kever Yang | 8aea45a | 2016-11-07 16:30:34 +0800 | [diff] [blame^] | 74 | gd->bd->bi_dram[0].size = 0x7e000000; |
Kever Yang | a381bcf | 2016-07-19 21:16:59 +0800 | [diff] [blame] | 75 | } |