Skip to content

Commit a70eaa5

Browse files
jasr93nashif
authored andcommitted
drivers: sensor: npm1300: Added charging support without NTC
Current nPM1300 charger driver does not work with batteries without NTC thermistor. Added supported for this feature. Signed-off-by: Javier Santos <[email protected]>
1 parent 953436b commit a70eaa5

File tree

2 files changed

+17
-5
lines changed

2 files changed

+17
-5
lines changed

drivers/sensor/nordic/npm1300_charger/npm1300_charger.c

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,9 @@ int npm1300_charger_channel_get(const struct device *dev, enum sensor_channel ch
223223
valp->val2 = (tmp % 1000) * 1000;
224224
break;
225225
case SENSOR_CHAN_GAUGE_TEMP:
226+
if (config->thermistor_idx == 0) {
227+
return -ENOTSUP;
228+
}
226229
calc_temp(config, data->temp, valp);
227230
break;
228231
case SENSOR_CHAN_GAUGE_AVG_CURRENT:
@@ -456,6 +459,7 @@ int npm1300_charger_init(const struct device *dev)
456459
{
457460
const struct npm1300_charger_config *const config = dev->config;
458461
uint16_t idx;
462+
uint8_t byte = 0U;
459463
int ret;
460464

461465
if (!device_is_ready(config->mfd)) {
@@ -464,7 +468,7 @@ int npm1300_charger_init(const struct device *dev)
464468

465469
/* Configure temperature thresholds */
466470
ret = mfd_npm1300_reg_write(config->mfd, ADC_BASE, ADC_OFFSET_NTCR_SEL,
467-
config->thermistor_idx + 1U);
471+
config->thermistor_idx);
468472
if (ret != 0) {
469473
return ret;
470474
}
@@ -590,10 +594,17 @@ int npm1300_charger_init(const struct device *dev)
590594

591595
/* Disable automatic recharging if configured */
592596
if (config->disable_recharge) {
593-
ret = mfd_npm1300_reg_write(config->mfd, CHGR_BASE, CHGR_OFFSET_DIS_SET, 1U);
594-
if (ret != 0) {
595-
return ret;
596-
}
597+
WRITE_BIT(byte, 0U, true);
598+
}
599+
600+
/* Disable NTC if configured */
601+
if (config->thermistor_idx == 0U) {
602+
WRITE_BIT(byte, 1U, true);
603+
}
604+
605+
ret = mfd_npm1300_reg_write(config->mfd, CHGR_BASE, CHGR_OFFSET_DIS_SET, byte);
606+
if (ret != 0) {
607+
return ret;
597608
}
598609

599610
/* Enable charging if configured */

dts/bindings/sensor/nordic,npm1300-charger.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ properties:
5252
type: int
5353
required: true
5454
enum:
55+
- 0
5556
- 10000
5657
- 47000
5758
- 100000

0 commit comments

Comments
 (0)