[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20240121014057.1042466-7-aren@peacevolution.org>
Date: Sat, 20 Jan 2024 20:40:04 -0500
From: Aren Moynihan <aren@...cevolution.org>
To: linux-pm@...r.kernel.org,
linux-kernel@...r.kernel.org
Cc: Aidan MacDonald <aidanmacdonald.0x0@...il.com>,
Ondřej Jirman <megi@....cz>,
Aren Moynihan <aren@...cevolution.org>,
Chen-Yu Tsai <wens@...e.org>,
Quentin Schulz <quentin.schulz@...tlin.com>,
Sebastian Reichel <sre@...nel.org>
Subject: [PATCH 3/3] power: supply: axp20x_usb_power: set input current limit in probe
axp803 sets the current limit to 3A by default if it doesn't detect a
battery. The datasheet says that reg 0x2D bit 6 is used to indicate
first power on status. According to it, if that bit is 0 and the
battery is not detected, it will set the input current limit to 3A,
however setting that bit to 1 doesn't to prevent the pmic from setting
the current limit to 3A.
Fixes: c279adafe6ab ("power: supply: axp20x_usb_power: add support for AXP813")
Signed-off-by: Aren Moynihan <aren@...cevolution.org>
---
I'm not sure if the pmic simply ignores the first power on field, or if
it needs to be set in a specific way / at a specific time. I tried
setting it in arm-trusted-firmware, and the pmic still set the input
current limit to 3A.
The datasheet for axp813 says it has the same first power on bit, but I
don't have hardware to test if it behaves the same way. This driver uses
the same platform data for axp803 and axp813.
drivers/power/supply/axp20x_usb_power.c | 13 +++++++++++++
1 file changed, 13 insertions(+)
diff --git a/drivers/power/supply/axp20x_usb_power.c b/drivers/power/supply/axp20x_usb_power.c
index 5656f6e57d54..95b136ee20f2 100644
--- a/drivers/power/supply/axp20x_usb_power.c
+++ b/drivers/power/supply/axp20x_usb_power.c
@@ -52,6 +52,7 @@ struct axp_data {
const int *curr_lim_table;
int input_curr_lim_table_size;
const int *input_curr_lim_table;
+ int force_input_curr_lim;
struct reg_field curr_lim_fld;
struct reg_field input_curr_lim_fld;
struct reg_field vbus_valid_bit;
@@ -599,6 +600,7 @@ static const struct axp_data axp813_data = {
.input_curr_lim_table_size = ARRAY_SIZE(axp_813_usb_input_curr_lim_table),
.input_curr_lim_table = axp_813_usb_input_curr_lim_table,
.input_curr_lim_fld = REG_FIELD(AXP22X_CHRG_CTRL3, 4, 7),
+ .force_input_curr_lim = 500000,
.usb_bc_en_bit = REG_FIELD(AXP288_BC_GLOBAL, 0, 0),
.usb_bc_det_fld = REG_FIELD(AXP288_BC_DET_STAT, 5, 7),
.vbus_disable_bit = REG_FIELD(AXP20X_VBUS_IPSOUT_MGMT, 7, 7),
@@ -786,6 +788,17 @@ static int axp20x_usb_power_probe(struct platform_device *pdev)
return ret;
}
+ if (power->axp_data->force_input_curr_lim) {
+ /*
+ * Certain chips set the input current limit to 3A when there is
+ * no battery connected. Normally the default is 500mA.
+ */
+ ret = axp20x_usb_power_set_input_current_limit(power,
+ power->axp_data->force_input_curr_lim);
+ if (ret)
+ return ret;
+ }
+
if (power->usb_bc_en_bit) {
/* Enable USB Battery Charging specification detection */
ret = regmap_field_write(power->usb_bc_en_bit, 1);
--
2.43.0
Powered by blists - more mailing lists