rockchip: spl: support low power detect
Signed-off-by: Jason Zhu <jason.zhu@rock-chips.com> Change-Id: Ibcb5996369348d31248596dcdb5018ad6526786e
This commit is contained in:
parent
c056ffb327
commit
c90ee5c73d
|
|
@ -14,6 +14,7 @@
|
||||||
#include <ram.h>
|
#include <ram.h>
|
||||||
#include <spl.h>
|
#include <spl.h>
|
||||||
#include <optee_include/OpteeClientInterface.h>
|
#include <optee_include/OpteeClientInterface.h>
|
||||||
|
#include <power/fuel_gauge.h>
|
||||||
#include <asm/arch/bootrom.h>
|
#include <asm/arch/bootrom.h>
|
||||||
#ifdef CONFIG_ROCKCHIP_PRELOADER_ATAGS
|
#ifdef CONFIG_ROCKCHIP_PRELOADER_ATAGS
|
||||||
#include <asm/arch/rk_atags.h>
|
#include <asm/arch/rk_atags.h>
|
||||||
|
|
@ -316,6 +317,26 @@ static int spl_rockchip_dnl_key_pressed(void)
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef CONFIG_SPL_DM_FUEL_GAUGE
|
||||||
|
bool spl_is_low_power(void)
|
||||||
|
{
|
||||||
|
struct udevice *dev;
|
||||||
|
int ret, voltage;
|
||||||
|
|
||||||
|
ret = uclass_get_device(UCLASS_FG, 0, &dev);
|
||||||
|
if (ret) {
|
||||||
|
debug("Get charge display failed, ret=%d\n", ret);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
voltage = fuel_gauge_get_voltage(dev);
|
||||||
|
if (voltage >= CONFIG_SPL_POWER_LOW_VOLTAGE_THRESHOLD)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
void spl_next_stage(struct spl_image_info *spl)
|
void spl_next_stage(struct spl_image_info *spl)
|
||||||
{
|
{
|
||||||
uint32_t reg_boot_mode;
|
uint32_t reg_boot_mode;
|
||||||
|
|
@ -324,6 +345,12 @@ void spl_next_stage(struct spl_image_info *spl)
|
||||||
spl->next_stage = SPL_NEXT_STAGE_UBOOT;
|
spl->next_stage = SPL_NEXT_STAGE_UBOOT;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
#ifdef CONFIG_SPL_DM_FUEL_GAUGE
|
||||||
|
if (spl_is_low_power()) {
|
||||||
|
spl->next_stage = SPL_NEXT_STAGE_UBOOT;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
reg_boot_mode = readl((void *)CONFIG_ROCKCHIP_BOOT_MODE_REG);
|
reg_boot_mode = readl((void *)CONFIG_ROCKCHIP_BOOT_MODE_REG);
|
||||||
switch (reg_boot_mode) {
|
switch (reg_boot_mode) {
|
||||||
|
|
|
||||||
|
|
@ -57,3 +57,13 @@ config SPL_POWER_FG_RK816
|
||||||
depends on DM_FUEL_GAUGE && PMIC_RK8XX
|
depends on DM_FUEL_GAUGE && PMIC_RK8XX
|
||||||
help
|
help
|
||||||
This adds support for RK816 fuel gauge support.
|
This adds support for RK816 fuel gauge support.
|
||||||
|
|
||||||
|
config SPL_POWER_LOW_VOLTAGE_THRESHOLD
|
||||||
|
int "Set the low voltage threshold"
|
||||||
|
default 3400
|
||||||
|
depends on SPL_DM_FUEL_GAUGE
|
||||||
|
help
|
||||||
|
Set the low voltage threshold. If the voltage, which is detected,
|
||||||
|
is lower than the low voltage threshold, load and boot the U-Boot
|
||||||
|
and goto charge the power.
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@
|
||||||
# SPDX-License-Identifier: GPL-2.0+
|
# SPDX-License-Identifier: GPL-2.0+
|
||||||
#
|
#
|
||||||
|
|
||||||
obj-$(CONFIG_DM_FUEL_GAUGE) += fuel_gauge_uclass.o
|
obj-$(CONFIG_$(SPL_)DM_FUEL_GAUGE) += fuel_gauge_uclass.o
|
||||||
|
|
||||||
obj-$(CONFIG_POWER_FG_CW201X) += fg_cw201x.o
|
obj-$(CONFIG_POWER_FG_CW201X) += fg_cw201x.o
|
||||||
obj-$(CONFIG_POWER_FG_MAX17042) += fg_max17042.o
|
obj-$(CONFIG_POWER_FG_MAX17042) += fg_max17042.o
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue