1*a13110a9SKlaus Goger /* 2*a13110a9SKlaus Goger * (C) Copyright 2017 Theobroma Systems Design und Consulting GmbH 3*a13110a9SKlaus Goger * 4*a13110a9SKlaus Goger * SPDX-License-Identifier: GPL-2.0+ 5*a13110a9SKlaus Goger */ 6*a13110a9SKlaus Goger #include <common.h> 7*a13110a9SKlaus Goger #include <dm.h> 8*a13110a9SKlaus Goger #include <dm/pinctrl.h> 9*a13110a9SKlaus Goger #include <dm/uclass-internal.h> 10*a13110a9SKlaus Goger #include <asm/arch/periph.h> 11*a13110a9SKlaus Goger #include <power/regulator.h> 12*a13110a9SKlaus Goger 13*a13110a9SKlaus Goger DECLARE_GLOBAL_DATA_PTR; 14*a13110a9SKlaus Goger 15*a13110a9SKlaus Goger int board_init(void) 16*a13110a9SKlaus Goger { 17*a13110a9SKlaus Goger struct udevice *pinctrl, *regulator; 18*a13110a9SKlaus Goger int ret; 19*a13110a9SKlaus Goger 20*a13110a9SKlaus Goger /* 21*a13110a9SKlaus Goger * The PWM does not have decicated interrupt number in dts and can 22*a13110a9SKlaus Goger * not get periph_id by pinctrl framework, so let's init them here. 23*a13110a9SKlaus Goger * The PWM2 and PWM3 are for pwm regulators. 24*a13110a9SKlaus Goger */ 25*a13110a9SKlaus Goger ret = uclass_get_device(UCLASS_PINCTRL, 0, &pinctrl); 26*a13110a9SKlaus Goger if (ret) { 27*a13110a9SKlaus Goger debug("%s: Cannot find pinctrl device\n", __func__); 28*a13110a9SKlaus Goger goto out; 29*a13110a9SKlaus Goger } 30*a13110a9SKlaus Goger 31*a13110a9SKlaus Goger ret = pinctrl_request_noflags(pinctrl, PERIPH_ID_PWM2); 32*a13110a9SKlaus Goger if (ret) { 33*a13110a9SKlaus Goger debug("%s PWM2 pinctrl init fail!\n", __func__); 34*a13110a9SKlaus Goger goto out; 35*a13110a9SKlaus Goger } 36*a13110a9SKlaus Goger 37*a13110a9SKlaus Goger /* rk3399 need to init vdd_center to get the correct output voltage */ 38*a13110a9SKlaus Goger ret = regulator_get_by_platname("vdd_center", ®ulator); 39*a13110a9SKlaus Goger if (ret) 40*a13110a9SKlaus Goger debug("%s: Cannot get vdd_center regulator\n", __func__); 41*a13110a9SKlaus Goger 42*a13110a9SKlaus Goger ret = regulator_get_by_platname("vcc5v0_host", ®ulator); 43*a13110a9SKlaus Goger if (ret) { 44*a13110a9SKlaus Goger debug("%s vcc5v0_host init fail! ret %d\n", __func__, ret); 45*a13110a9SKlaus Goger goto out; 46*a13110a9SKlaus Goger } 47*a13110a9SKlaus Goger 48*a13110a9SKlaus Goger ret = regulator_set_enable(regulator, true); 49*a13110a9SKlaus Goger if (ret) { 50*a13110a9SKlaus Goger debug("%s vcc5v0-host-en set fail!\n", __func__); 51*a13110a9SKlaus Goger goto out; 52*a13110a9SKlaus Goger } 53*a13110a9SKlaus Goger 54*a13110a9SKlaus Goger out: 55*a13110a9SKlaus Goger return 0; 56*a13110a9SKlaus Goger } 57*a13110a9SKlaus Goger 58*a13110a9SKlaus Goger int dram_init(void) 59*a13110a9SKlaus Goger { 60*a13110a9SKlaus Goger gd->ram_size = 0x80000000; 61*a13110a9SKlaus Goger return 0; 62*a13110a9SKlaus Goger } 63*a13110a9SKlaus Goger 64*a13110a9SKlaus Goger int dram_init_banksize(void) 65*a13110a9SKlaus Goger { 66*a13110a9SKlaus Goger /* Reserve 0x200000 for ATF bl31 */ 67*a13110a9SKlaus Goger gd->bd->bi_dram[0].start = 0x200000; 68*a13110a9SKlaus Goger gd->bd->bi_dram[0].size = 0x7e000000; 69*a13110a9SKlaus Goger 70*a13110a9SKlaus Goger return 0; 71*a13110a9SKlaus Goger } 72