Skip to contentSkip to conversation

power/supply: Add ltc4162-l-charger

PATCH Superseded Mike Looijmans 2 participants 3 messages Jan 6, 2021 – Jan 7, 2021 1 message not in the archive Power supply

v4 of 5 Superseded Latest is v5 →

lore
Share & tools
lore
#0 lore raw

PATCH v4 1/1 power/supply: Add ltc4162-l-charger

Add support for the LTC4162-L Li-Ion battery charger. The driver allows reading back telemetry and to set some charging options like the input current limit.

---
v2: Use microohm units instead of milliohm
Add interrupt support using smbalert
Support obtaining cell-count from devicetree
v3: Fix overflows in calculations involving resistor values
v4: Use attr_grp member to register attributes
Report input current/voltage for charger and make battery voltage and current into sysfs attributes

 drivers/power/supply/Kconfig             |   8 +
 drivers/power/supply/Makefile            |   1 +
 drivers/power/supply/ltc4162-l-charger.c | 941 +++++++++++++++++++++++
 3 files changed, 950 insertions(+)
 create mode 100644 drivers/power/supply/ltc4162-l-charger.c
drivers/power/supply/Kconfig +8 -0
index eec646c568b7..23000976cb42 100644
@@ -513,6 +513,14 @@ config CHARGER_LT3651
 	  Say Y to include support for the Analog Devices (Linear Technology)
 	  LT3651 battery charger which reports its status via GPIO lines.
 
+config CHARGER_LTC4162L
+	tristate "LTC4162-L charger"
+	depends on I2C
+	select REGMAP_I2C
+	help
+	  Say Y to include support for the Analog Devices (Linear Technology)
+	  LTC4162-L battery charger connected to I2C.
+
 config CHARGER_MAX14577
 	tristate "Maxim MAX14577/77836 battery charger driver"
 	depends on MFD_MAX14577
drivers/power/supply/Makefile +1 -0
index dd4b86318cd9..17b1cf921c44 100644
@@ -70,6 +70,7 @@ obj-$(CONFIG_CHARGER_LP8788)	+= lp8788-charger.o
 obj-$(CONFIG_CHARGER_GPIO)	+= gpio-charger.o
 obj-$(CONFIG_CHARGER_MANAGER)	+= charger-manager.o
 obj-$(CONFIG_CHARGER_LT3651)	+= lt3651-charger.o
+obj-$(CONFIG_CHARGER_LTC4162L)	+= ltc4162-l-charger.o
 obj-$(CONFIG_CHARGER_MAX14577)	+= max14577_charger.o
 obj-$(CONFIG_CHARGER_DETECTOR_MAX14656)	+= max14656_charger_detector.o
 obj-$(CONFIG_CHARGER_MAX77650)	+= max77650-charger.o
drivers/power/supply/ltc4162-l-charger.c new file +941 -0

941 lines not on this page · raw message

Signature · 1 line
2.17.1
#1 lore raw

Hi,

Quoted 5 lines · Mike Looijmans

Add support for the LTC4162-L Li-Ion battery charger. The driver allows reading back telemetry and to set some charging options like the input current limit.

Quoted 8 lines

---
v2: Use microohm units instead of milliohm
Add interrupt support using smbalert
Support obtaining cell-count from devicetree
v3: Fix overflows in calculations involving resistor values
v4: Use attr_grp member to register attributes
Report input current/voltage for charger and make battery voltage and current into sysfs attributes

Fine with me until we have a better way to solve the problem. IIUIC you no longer have access to the hardware anyways? But you need to document the custom sysfs nodes: Please document them in the following file:

Documentation/ABI/testing/sysfs-class-power-ltc4162l

[...]

drivers/power/supply/ltc4162-l-charger.c line 901

Quoted 8 lines
drivers/power/supply/ltc4162-l-charger.c new file +8 -0
+static int ltc4162l_remove(struct i2c_client *client)
+{
+	struct ltc4162l_info *info = i2c_get_clientdata(client);
+
+	sysfs_remove_group(&info->charger->dev.kobj, &ltc4162l_attr_group);
+
+	return 0;
+}

power-supply core automatically removes the sysfs groups specified in power_supply_config.attr_grp.

-- Sebastian

#2 lore raw

Met vriendelijke groet / kind regards,

Mike Looijmans
System Expert

TOPIC Embedded Products B.V.
Materiaalweg 4, 5681 RJ Best
The Netherlands

T: +31 (0) 499 33 69 69
E: [email protected]
W: www.topicproducts.com

Please consider the environment before printing this e-mail

Quoted 16 lines · Sebastian Reichel

Hi,

Quoted 5 lines · Mike Looijmans

Add support for the LTC4162-L Li-Ion battery charger. The driver allows reading back telemetry and to set some charging options like the input current limit.

Quoted 8 lines

---
v2: Use microohm units instead of milliohm
Add interrupt support using smbalert
Support obtaining cell-count from devicetree
v3: Fix overflows in calculations involving resistor values
v4: Use attr_grp member to register attributes
Report input current/voltage for charger and make battery voltage and current into sysfs attributes

Quoted 6 lines

Fine with me until we have a better way to solve the problem. IIUIC you no longer have access to the hardware anyways? But you need to document the custom sysfs nodes: Please document them in the following file:

Documentation/ABI/testing/sysfs-class-power-ltc4162l

v5 is on its way with a description.

I currently don't have access to the hardware, so these changes were only compile-tested.

Quoted 12 lines

[...]

drivers/power/supply/ltc4162-l-charger.c line 901

Quoted 8 lines
drivers/power/supply/ltc4162-l-charger.c new file +8 -0
+static int ltc4162l_remove(struct i2c_client *client)
+{
+	struct ltc4162l_info *info = i2c_get_clientdata(client);
+
+	sysfs_remove_group(&info->charger->dev.kobj, &ltc4162l_attr_group);
+
+	return 0;
+}

power-supply core automatically removes the sysfs groups specified in power_supply_config.attr_grp.

Ah, good catch, missed that.

Quoted 2 lines

-- Sebastian

Signature · 1 line
Mike Looijmans