Skip to contentSkip to conversation

Add support for Smart Battery System Manager

PATCH Superseded Karl-Heinz Schneider 2 participants 5 messages Jun 30, 2016 – Jul 1, 2016 1 message not in the archive

Subsystems (3)

v2 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#1 lore raw

v2 cover Add support for Smart Battery System Manager

In reply to a message not in the archive

This patch series adds support for Smart Battery System Manager. A SBSM is a device listening at I2C/SMBus address 0x0a and is capable of communicating up to four I2C smart battery devices. All smart battery devices are listening at address 0x0b, so the SBSM muliplexes between them. The driver makes use of the I2C-Mux framework to allow smart batteries to be bound via device tree, i.e. the sbs-battery driver.

Via sysfs interface the online state and charge type are presented. If the driver is bound as ltc1760 (a Dual Smart Battery System Manager) the charge type can also be changed from trickle to fast.

Changes:
V2:
* Fixed sample node names and compatible strings in binding documentaton.
* Removed optional property "sbsm,i2c-retry-count"
* Retry count hardcoded. Removed no longer needed OF readout function
* Rebased onto v4.7rc-5

Karl-Heinz Schneider (2):
Documentation: Add sbs-manager device tree node documentation
power: Adds support for Smart Battery System Manager

 .../devicetree/bindings/power/sbs,sbs-manager.txt  |  57 ++++
 drivers/power/Kconfig                              |  13 +
 drivers/power/Makefile                             |   1 +
 drivers/power/sbs-manager.c                        | 346 +++++++++++++++++++++
 4 files changed, 417 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/power/sbs,sbs-manager.txt
 create mode 100644 drivers/power/sbs-manager.c

--
1.9.1

#2 lore raw

PATCH v2 1/2 Documentation: Add sbs-manager device tree node documentation

This patch adds device tree documentation for the sbs-manager

---
 .../devicetree/bindings/power/sbs,sbs-manager.txt  | 52 ++++++++++++++++++++++
 1 file changed, 52 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/power/sbs,sbs-manager.txt
Documentation/devicetree/bindings/power/sbs,sbs-manager.txt new file +52 -0
new file mode 100644
index 0000000..1d7e5ee
@@ -0,0 +1,52 @@
+Binding for sbs-manager
+
+Required properties:
+- compatible: should be "lltc,ltc1760" or use "sbs,sbs-manager" as fallback.
+- reg: integer, i2c address of the device. Should be <0xa>.
+
+From OS view the device is basically an i2c-mux used to communicate with up to
+four smart battery devices at address 0xb. The driver actually implements this
+behaviour. So standard i2c-mux nodes can be used to register up to four slave
+batteries. Channels will be numerated as 1, 2, 4 and 8.
+
+Example:
+
+batman@0a {
+    compatible = "lltc,ltc1760";
+    reg = <0x0a>;
+    #address-cells = <1>;
+    #size-cells = <0>;
+
+    i2c@1 {
+        #address-cells = <1>;
+        #size-cells = <0>;
+        reg = <1>;
+
+        battery@0b {
+            compatible = "ti,bq2060", "sbs,sbs-battery";
+            reg = <0x0b>;
+        };
+    };
+
+    i2c@2 {
+        #address-cells = <1>;
+        #size-cells = <0>;
+        reg = <2>;
+
+        battery@0b {
+            compatible = "ti,bq2060", "sbs,sbs-battery";
+            reg = <0x0b>;
+        };
+    };
+
+    i2c@4 {
+        #address-cells = <1>;
+        #size-cells = <0>;
+        reg = <4>;
+
+        battery@0b {
+            compatible = "ti,bq2060", "sbs,sbs-battery";
+            reg = <0x0b>;
+        };
+    };
+};

--
1.9.1

#5 lore raw

PATCH v2 2/2 power: Adds support for Smart Battery System Manager

In reply to Karl-Heinz Schneider

This patch adds support for Smart Battery System Manager.
A SBSM is a device listening at I2C/SMBus address 0x0a and is capable of communicating up to four I2C smart battery devices. All smart battery devices are listening at address 0x0b, so the SBSM muliplexes between them. The driver makes use of the I2C-Mux framework to allow smart batteries to be bound via device tree, i.e. the sbs-battery driver.

Via sysfs interface the online state and charge type are presented. If the driver is bound as ltc1760 (an implementation of a Dual Smart Battery System Manager) the charge type can also be changed from trickle to fast.

---
 drivers/power/Kconfig       |  13 ++
 drivers/power/Makefile      |   1 +
 drivers/power/sbs-manager.c | 324 ++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 338 insertions(+)
 create mode 100644 drivers/power/sbs-manager.c
drivers/power/Kconfig +13 -0
index 421770d..7c561bf 100644
@@ -157,6 +157,19 @@ config BATTERY_WM97XX
 	help
 	  Say Y to enable support for battery measured by WM97xx aux port.
 
+config MANAGER_SBS
+	tristate "Smart Battery System Manager"
+	depends on I2C && I2C_MUX
+	help
+	  Say Y here to include support for Smart Battery System Manager
+	  ICs. The driver reports online and charging status via sysfs.
+	  It presents itself also as I2C mux which allows to bind
+	  smart battery driver to its ports.
+	  Supported is for example LTC1760.
+
+	  This driver can also be built as a module. If so, the module will be
+	  called sbs-manager.
+
 config BATTERY_SBS
         tristate "SBS Compliant gas gauge"
         depends on I2C
drivers/power/Makefile +1 -0
index e46b75d..5378e65 100644
@@ -22,6 +22,7 @@ obj-$(CONFIG_BATTERY_DS2760)	+= ds2760_battery.o
 obj-$(CONFIG_BATTERY_DS2780)	+= ds2780_battery.o
 obj-$(CONFIG_BATTERY_DS2781)	+= ds2781_battery.o
 obj-$(CONFIG_BATTERY_DS2782)	+= ds2782_battery.o
+obj-$(CONFIG_MANAGER_SBS)	+= sbs-manager.o
 obj-$(CONFIG_BATTERY_GAUGE_LTC2941)	+= ltc2941-battery-gauge.o
 obj-$(CONFIG_BATTERY_GOLDFISH)	+= goldfish_battery.o
 obj-$(CONFIG_BATTERY_PMU)	+= pmu_battery.o
drivers/power/sbs-manager.c new file +324 -0

324 lines not on this page · raw message

--
1.9.1

#3 lore raw

Re: [PATCH v2 1/2] Documentation: Add sbs-manager device tree node documentation

In reply to Karl-Heinz Schneider

Hi,

Quoted 15 lines · Karl-Heinz Schneider

This patch adds device tree documentation for the sbs-manager

---
 .../devicetree/bindings/power/sbs,sbs-manager.txt  | 52 ++++++++++++++++++++++
 1 file changed, 52 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/power/sbs,sbs-manager.txt
Documentation/devicetree/bindings/power/sbs,sbs-manager.txt new file +0 -0
new file mode 100644
index 0000000..1d7e5ee

Documentation/devicetree/bindings/power/sbs,sbs-manager.txt line 10

Quoted 10 lines
Documentation/devicetree/bindings/power/sbs,sbs-manager.txt new file +10 -0
@@ -0,0 +1,52 @@
+Binding for sbs-manager
+
+Required properties:
+- compatible: should be "lltc,ltc1760" or use "sbs,sbs-manager" as fallback.
+- reg: integer, i2c address of the device. Should be <0xa>.
+
+From OS view the device is basically an i2c-mux used to communicate with up to
+four smart battery devices at address 0xb. The driver actually implements this
+behaviour. So standard i2c-mux nodes can be used to register up to four slave
+batteries. Channels will be numerated as 1, 2, 4 and 8.

I think it's better to use channel 1-4 and do the translation in the driver's channel select method. It means one does not have to worry about anybody accidently configuring channel 3 and it also maps nicely to the datasheet talking about BAT1-BAT4.

-- Sebastian

#4 lore raw

Re: [PATCH v2 1/2] Documentation: Add sbs-manager device tree node documentation

Hi Sebastian,

Am Freitag, den 01.07.2016, 00:52 +0200 schrieb Sebastian Reichel:

Quoted 25 lines

Hi,

Quoted 22 lines · Karl-Heinz Schneider

This patch adds device tree documentation for the sbs-manager

---
 .../devicetree/bindings/power/sbs,sbs-manager.txt  | 52 ++++++++++++++++++++++
 1 file changed, 52 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/power/sbs,sbs-manager.txt
Documentation/devicetree/bindings/power/sbs,sbs-manager.txt new file +7 -0
new file mode 100644
index 0000000..1d7e5ee
@@ -0,0 +1,52 @@
+Binding for sbs-manager
+
+Required properties:
+- compatible: should be "lltc,ltc1760" or use "sbs,sbs-manager" as fallback.
+- reg: integer, i2c address of the device. Should be <0xa>.
+
+From OS view the device is basically an i2c-mux used to communicate with up to
Quoted 8 lines

Documentation/devicetree/bindings/power/sbs,sbs-manager.txt line 10

Quoted 3 lines
Documentation/devicetree/bindings/power/sbs,sbs-manager.txt new file +3 -0
+four smart battery devices at address 0xb. The driver actually implements this
+behaviour. So standard i2c-mux nodes can be used to register up to four slave
+batteries. Channels will be numerated as 1, 2, 4 and 8.

I think it's better to use channel 1-4 and do the translation in the driver's channel select method. It means one does not have to worry about anybody accidently configuring channel 3 and it also maps nicely to the datasheet talking about BAT1-BAT4.

You're not the first one pointing that out... Will fix that in the next revision.

Quoted 2 lines

-- Sebastian

Signature · 1 line
Greetings