Skip to content

Commit 9d14cf1

Browse files
Ondrej Jirmansamueldr
authored andcommitted
pinephone-pro: Perform PMIC setup on boot (increase input current limit)
The limit needs to be raised to prevent bootloops on empty battery. (This is a bit too late for battery-less boot, it would need to be done in TPL very early on, for that) This is still slightly better than nothing, though. Signed-off-by: Ondrej Jirman <megi@xff.cz> Origin: https://xff.cz/git/u-boot/commit/?h=ppp&id=7f8238fd608290152b143322178a5be21a447dc1
1 parent a590418 commit 9d14cf1

4 files changed

Lines changed: 53 additions & 0 deletions

File tree

arch/arm/mach-rockchip/board.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,10 +187,16 @@ int board_late_init(void)
187187
return rk_board_late_init();
188188
}
189189

190+
void __weak pmic_setup(void)
191+
{
192+
}
193+
190194
int board_init(void)
191195
{
192196
int ret;
193197

198+
pmic_setup();
199+
194200
#ifdef CONFIG_DM_REGULATOR
195201
ret = regulators_enable_boot_on(false);
196202
if (ret)

board/pine64/pinephone-pro-rk3399/pinephone-pro-rk3399.c

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#include <asm/arch-rockchip/misc.h>
1818
#include <power/regulator.h>
1919
#include <linux/delay.h>
20+
#include <power/rk8xx_pmic.h>
2021

2122
#define GRF_IO_VSEL_BT565_GPIO2AB 1
2223
#define GRF_IO_VSEL_AUDIO_GPIO3D4A 2
@@ -108,3 +109,42 @@ void led_setup(void)
108109
}
109110

110111
#endif
112+
113+
static void pinephone_pro_init(void)
114+
{
115+
struct udevice *pmic;
116+
int ret;
117+
118+
printf("Initializing Pinephone Pro charger\n");
119+
120+
ret = uclass_first_device_err(UCLASS_PMIC, &pmic);
121+
if (ret) {
122+
printf("ERROR: PMIC not found! (%d)\n", ret);
123+
return;
124+
}
125+
126+
/*
127+
* Raise input current limit to 1.5A, which is a standard CDC charger
128+
* allowance.
129+
*/
130+
ret = rk818_spl_configure_usb_input_current(pmic, 1500);
131+
if (ret)
132+
printf("ERROR: Input current limit setup failed!\n");
133+
134+
/*
135+
* Close charger when USB lower then 3.26V
136+
*/
137+
rk818_spl_configure_usb_chrg_shutdown(pmic, 3260000);
138+
139+
/*
140+
* Check battery voltage and wait until it's in bootable state.
141+
*/
142+
//TODO:
143+
rk818_wait_battery(pmic);
144+
}
145+
146+
void pmic_setup(void)
147+
{
148+
if (of_machine_is_compatible("pine64,pinephone-pro"))
149+
pinephone_pro_init();
150+
}

drivers/power/pmic/rk8xx.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,11 @@ static int rk8xx_read(struct udevice *dev, uint reg, uint8_t *buff, int len)
129129
return 0;
130130
}
131131

132+
int rk818_wait_battery(struct udevice *dev)
133+
{
134+
return 0;
135+
}
136+
132137
#if CONFIG_IS_ENABLED(PMIC_CHILDREN)
133138
static int rk8xx_bind(struct udevice *dev)
134139
{

include/power/rk8xx_pmic.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -236,4 +236,6 @@ int rk8xx_spl_configure_buck(struct udevice *pmic, int buck, int uvolt);
236236
int rk818_spl_configure_usb_input_current(struct udevice *pmic, int current_ma);
237237
int rk818_spl_configure_usb_chrg_shutdown(struct udevice *pmic, int uvolt);
238238

239+
int rk818_wait_battery(struct udevice *dev);
240+
239241
#endif

0 commit comments

Comments
 (0)