From cd340ba466532e1d07ae7a61f342703cf20a128f Mon Sep 17 00:00:00 2001 From: Zain Wang Date: Mon, 16 May 2022 14:49:47 +0800 Subject: [PATCH] power: supply: sc8886: stop probe when battery was no found SC8886 will shutdown the output off in these cases when battery was removed: 1. INPUT CRRENT is set to 0. In Battery system, battery would take over system supply, but in no battery system, it would restart due to system poweroff. 2. VBat is higher than VSysmin, sc8886 would switch system supply to VBat, But in no battery system, there is just a capacitance, the voltage of capacitance would be pull down quickly when supply switch and it make system restart. Signed-off-by: Zain Wang Change-Id: I0398d55d511254821744c4e7d4448ef4605af509 --- drivers/power/supply/bq25700_charger.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/drivers/power/supply/bq25700_charger.c b/drivers/power/supply/bq25700_charger.c index 3a4c487b4e1a..33106746a4c4 100644 --- a/drivers/power/supply/bq25700_charger.c +++ b/drivers/power/supply/bq25700_charger.c @@ -2014,6 +2014,20 @@ static int bq25700_probe(struct i2c_client *client, return -ENODEV; } + /* + * Make sure battery online, otherwise, writing INPUT_CURRENT and + * CHARGE_CURRENT would make system power off + */ + if (of_parse_phandle(charger->dev->of_node, "ti,battery", 0)) { + if (IS_ERR_OR_NULL(power_supply_get_by_phandle( + charger->dev->of_node, + "ti,battery"))) { + dev_info(charger->dev, "No battery found\n"); + return -EPROBE_DEFER; + } + dev_info(charger->dev, "Battery found\n"); + } + ret = bq25700_hw_init(charger); if (ret < 0) { dev_err(dev, "Cannot initialize the chip.\n");