From c63955ee32203ba766c4766f961c14413896e9a7 Mon Sep 17 00:00:00 2001 From: MCC45TR Date: Sat, 29 Aug 2026 13:07:49 +0300 Subject: [PATCH 51/64] power: supply: ln8000: disable unwired Nabu input NTC --- arch/arm64/boot/dts/qcom/sm8150-xiaomi-nabu.dts | 1 + drivers/power/supply/ln8000_charger.c | 17 +++++++++++++---- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/arch/arm64/boot/dts/qcom/sm8150-xiaomi-nabu.dts b/arch/arm64/boot/dts/qcom/sm8150-xiaomi-nabu.dts index 75daa6a3839e..41406ed9f3d1 100644 --- a/arch/arm64/boot/dts/qcom/sm8150-xiaomi-nabu.dts +++ b/arch/arm64/boot/dts/qcom/sm8150-xiaomi-nabu.dts @@ -528,6 +528,7 @@ ln8000_charger: charger@51 { lionsemi,input-ocp-alarm-microamp = <3500000>; lionsemi,ntc-alarm-code = <226>; lionsemi,min-input-microvolt = <8000000>; + lionsemi,input-ntc-unwired; }; typec-mux@43 { diff --git a/drivers/power/supply/ln8000_charger.c b/drivers/power/supply/ln8000_charger.c index 511850af61f9..e04dc99d32e9 100644 --- a/drivers/power/supply/ln8000_charger.c +++ b/drivers/power/supply/ln8000_charger.c @@ -264,6 +264,7 @@ struct ln8000_platform_data { unsigned int ntc_alarm_cfg; /* input/battery NTC voltage threshold code: 0~1023 */ unsigned int min_input_uv; /* minimum safe voltage for 2:1 switching */ + bool input_ntc_unwired; /* board has no thermistor on the TSBUS input */ }; struct ln8000_info { @@ -967,14 +968,19 @@ static int ln8000_init_device(struct ln8000_info *info) LN8000_INIT_STEP(ln8000_change_opmode(info, LN8000_OPMODE_STANDBY)); LN8000_INIT_STEP(ln8000_enable_vac_ov(info, true)); - /* Keep the hardware watchdog and every ADC-backed protection active. */ + /* Keep the hardware watchdog and every populated ADC protection active. */ LN8000_INIT_STEP(ln8000_update_reg(info, LN8000_REG_TIMER_CTRL, 0x3 << 5, LN8000_WATCHDOG_40SEC << 5)); LN8000_INIT_STEP(ln8000_enable_wdt(info, true)); LN8000_INIT_STEP(ln8000_set_adc_hib_delay(info, ADC_HIBERNATE_4S)); LN8000_INIT_STEP(ln8000_set_adc_ch(info, LN8000_ADC_CH_ALL, true)); - LN8000_INIT_STEP(ln8000_enable_tbus_monitor(info, true)); + if (info->pdata->input_ntc_unwired) { + LN8000_INIT_STEP(ln8000_enable_tbus_monitor(info, false)); + LN8000_INIT_STEP(ln8000_set_adc_ch(info, LN8000_ADC_CH_TSBUS, false)); + } else { + LN8000_INIT_STEP(ln8000_enable_tbus_monitor(info, true)); + } LN8000_INIT_STEP(ln8000_enable_tbat_monitor(info, true)); LN8000_INIT_STEP(ln8000_set_adc_mode(info, ADC_AUTO_HIB_MODE)); @@ -984,7 +990,8 @@ static int ln8000_init_device(struct ln8000_info *info) ln8000_write_reg(info, LN8000_REG_THRESHOLD_CTRL, 0x0e)); ln8000_print_regmap(info); - ln_info("initialization complete with all protections enabled\n"); + ln_info("initialization complete; input NTC %s, all populated protections enabled\n", + info->pdata->input_ntc_unwired ? "not populated" : "enabled"); #undef LN8000_INIT_STEP return 0; @@ -1285,7 +1292,7 @@ static irqreturn_t ln8000_interrupt_handler(int irq, void *data) u8 masked_int; int ret; - ln_err("ln8000_interrupt_handler enter!\n"); + ln_info("enter\n"); ret = ln8000_read_int_value(info, &int_reg); if (IS_ERR_VALUE((unsigned long)ret)) { ln_err("fail to read INT reg (ret=%d)\n", ret); @@ -1472,6 +1479,8 @@ static int ln8000_parse_dt(struct ln8000_info *info) &pdata->min_input_uv); if (ret) return dev_err_probe(dev, ret, "missing minimum input voltage\n"); + pdata->input_ntc_unwired = + device_property_read_bool(dev, "lionsemi,input-ntc-unwired"); if (pdata->bat_ovp_alarm_th >= pdata->bat_ovp_th || pdata->bus_ovp_alarm_th >= pdata->bus_ovp_th ||