Klaus Goger | 8103993 | 2017-04-07 19:13:38 +0200 | [diff] [blame] | 1 | /* |
| 2 | * (C) Copyright 2017 Theobroma Systems Design und Consulting GmbH |
| 3 | * |
| 4 | * SPDX-License-Identifier: GPL-2.0+ |
| 5 | */ |
| 6 | #include <common.h> |
| 7 | #include <dm.h> |
| 8 | #include <dm/pinctrl.h> |
| 9 | #include <dm/uclass-internal.h> |
| 10 | #include <asm/arch/periph.h> |
| 11 | #include <power/regulator.h> |
| 12 | |
| 13 | DECLARE_GLOBAL_DATA_PTR; |
| 14 | |
| 15 | int board_init(void) |
| 16 | { |
| 17 | struct udevice *pinctrl, *regulator; |
| 18 | int ret; |
| 19 | |
| 20 | /* |
| 21 | * The PWM does 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 regulators. |
| 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 | /* rk3399 need to init vdd_center to get the correct output voltage */ |
| 38 | ret = regulator_get_by_platname("vdd_center", ®ulator); |
| 39 | if (ret) |
| 40 | debug("%s: Cannot get vdd_center regulator\n", __func__); |
| 41 | |
| 42 | ret = regulator_get_by_platname("vcc5v0_host", ®ulator); |
| 43 | if (ret) { |
| 44 | debug("%s vcc5v0_host init fail! ret %d\n", __func__, ret); |
| 45 | goto out; |
| 46 | } |
| 47 | |
| 48 | ret = regulator_set_enable(regulator, true); |
| 49 | if (ret) { |
| 50 | debug("%s vcc5v0-host-en set fail!\n", __func__); |
| 51 | goto out; |
| 52 | } |
| 53 | |
| 54 | out: |
| 55 | return 0; |
| 56 | } |
| 57 | |
| 58 | int dram_init(void) |
| 59 | { |
| 60 | gd->ram_size = 0x80000000; |
| 61 | return 0; |
| 62 | } |
| 63 | |
| 64 | int dram_init_banksize(void) |
| 65 | { |
| 66 | /* Reserve 0x200000 for ATF bl31 */ |
| 67 | gd->bd->bi_dram[0].start = 0x200000; |
| 68 | gd->bd->bi_dram[0].size = 0x7e000000; |
| 69 | |
| 70 | return 0; |
| 71 | } |