Skip to contentSkip to conversation

power: supply: Add support for Surface RT battery and charger

PATCH Applied Svyatoslav Ryhel 3 participants 5 messages May 7 – Jun 4

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

v4 cover power: supply: Add support for Surface RT battery and charger

Add support for Embedded Controller found in the Microsoft Surface RT and used to monitor battery cell and charger input status and properties. Controller works both for UEFI and APX booting.

---
Changes in v4:
- fixed REGS_TECHNOLOGY read size

Changes in v3:
- fixed i2c_smbus_read_i2c_block_data read size

Changes in v2:
- srt_bat_get_string > i2c_smbus_read_i2c_block_data
- added devm_kasprintf return check
---

Jonas Schwöbel (1):
power: supply: Add support for Surface RT battery and charger

Svyatoslav Ryhel (1):
dt-bindings: embedded-controller: Document Surface RT EC

 .../microsoft,surface-rt-ec.yaml              |  63 +++
 drivers/power/supply/Kconfig                  |  11 +
 drivers/power/supply/Makefile                 |   1 +
 drivers/power/supply/surface-rt-ec.c          | 389 ++++++++++++++++++
 4 files changed, 464 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/embedded-controller/microsoft,surface-rt-ec.yaml
 create mode 100644 drivers/power/supply/surface-rt-ec.c
Signature · 1 line
2.51.0
#1 lore raw

PATCH v4 1/2 dt-bindings: embedded-controller: Document Surface RT EC

Document Embedded Controller used in Microsoft Surface RT tablets for monitoring battery properties and charger status.

---
 .../microsoft,surface-rt-ec.yaml              | 63 +++++++++++++++++++
 1 file changed, 63 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/embedded-controller/microsoft,surface-rt-ec.yaml
Documentation/devicetree/bindings/embedded-controller/microsoft,surface-rt-ec.yaml new file +63 -0
new file mode 100644
index 000000000000..0fee574a3015
@@ -0,0 +1,63 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/embedded-controller/microsoft,surface-rt-ec.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Microsoft Surface RT fuel gauge and charger EC
+
+maintainers:
+  - Jonas Schwöbel <[email protected]>
+  - Svyatoslav Ryhel <[email protected]>
+
+description:
+  An Embedded Controller used in Microsoft Surface RT for monitoring
+  battery properties and charger status.
+
+allOf:
+  - $ref: /schemas/power/supply/power-supply.yaml#
+
+properties:
+  compatible:
+    const: microsoft,surface-rt-ec
+
+  reg:
+    maxItems: 1
+
+  interrupts:
+    maxItems: 1
+
+  enable-gpios:
+    maxItems: 1
+
+  monitored-battery: true
+
+required:
+  - compatible
+  - reg
+  - interrupts
+  - enable-gpios
+
+additionalProperties: false
+
+examples:
+  - |
+    #include <dt-bindings/gpio/gpio.h>
+    #include <dt-bindings/interrupt-controller/irq.h>
+
+    i2c {
+        #address-cells = <1>;
+        #size-cells = <0>;
+
+        embedded-controller@a {
+            compatible = "microsoft,surface-rt-ec";
+            reg = <0x0a>;
+
+            interrupt-parent = <&gpio>;
+            interrupts = <74 IRQ_TYPE_EDGE_RISING>;
+
+            enable-gpios = <&gpio 88 GPIO_ACTIVE_HIGH>;
+            monitored-battery = <&battery>;
+        };
+    };
+...
Signature · 1 line
2.51.0
#3 lore raw

PATCH v4 2/2 power: supply: Add support for Surface RT battery and charger

In reply to Svyatoslav Ryhel

From: Jonas Schwöbel <[email protected]>

Add support for Embedded Controller found in the Microsoft Surface RT and used to monitor battery cell and charger input status and properties. Controller works both for UEFI and APX booting.

[wmjb: added POWER_SUPPLY_PROP_CHARGE_NOW support]
---
 drivers/power/supply/Kconfig         |  11 +
 drivers/power/supply/Makefile        |   1 +
 drivers/power/supply/surface-rt-ec.c | 389 +++++++++++++++++++++++++++
 3 files changed, 401 insertions(+)
 create mode 100644 drivers/power/supply/surface-rt-ec.c
drivers/power/supply/Kconfig +11 -0
index 4d04de6586ae..13661d3d39b4 100644
@@ -1168,6 +1168,17 @@ config BATTERY_UG3105
 	  device is off or suspended, the functionality of this driver is
 	  limited to reporting capacity only.
 
+config BATTERY_CHARGER_SURFACE_RT
+	tristate "Battery & Charger driver for Microsoft Surface RT"
+	depends on I2C && GPIOLIB
+	help
+	  UEFI/APX driver for the 1st-generation Microsoft Surface RT
+	  battery. Driver supports reading battery properties and
+	  charger status.
+
+	  This driver can also be built as a module. If so, the module
+	  will be called surface-rt-ec.
+
 config CHARGER_QCOM_SMB2
 	tristate "Qualcomm PMI8998 PMIC charger driver"
 	depends on MFD_SPMI_PMIC
drivers/power/supply/Makefile +1 -0
index 3959b974ec84..ebd3beef4c84 100644
@@ -129,6 +129,7 @@ obj-$(CONFIG_RN5T618_POWER)	+= rn5t618_power.o
 obj-$(CONFIG_BATTERY_ACER_A500)	+= acer_a500_battery.o
 obj-$(CONFIG_BATTERY_SURFACE)	+= surface_battery.o
 obj-$(CONFIG_CHARGER_SURFACE)	+= surface_charger.o
+obj-$(CONFIG_BATTERY_CHARGER_SURFACE_RT) += surface-rt-ec.o
 obj-$(CONFIG_BATTERY_UG3105)	+= ug3105_battery.o
 obj-$(CONFIG_CHARGER_QCOM_SMB2)	+= qcom_smbx.o
 obj-$(CONFIG_FUEL_GAUGE_MM8013)	+= mm8013.o
drivers/power/supply/surface-rt-ec.c new file +389 -0

389 lines not on this page · raw message

Signature · 1 line
2.51.0
maintainer Reviewed-by on v4 1/2
#2 lore raw

Re: [PATCH v4 1/2] dt-bindings: embedded-controller: Document Surface RT EC

In reply to Svyatoslav Ryhel
Quoted 9 lines · Svyatoslav Ryhel

Document Embedded Controller used in Microsoft Surface RT tablets for monitoring battery properties and charger status.

---
 .../microsoft,surface-rt-ec.yaml              | 63 +++++++++++++++++++
 1 file changed, 63 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/embedded-controller/microsoft,surface-rt-ec.yaml
#4 lore raw
In reply to Svyatoslav Ryhel
Quoted 4 lines · Svyatoslav Ryhel

Add support for Embedded Controller found in the Microsoft Surface RT and used to monitor battery cell and charger input status and properties. Controller works both for UEFI and APX booting.

Applied, thanks!

[1/2] dt-bindings: embedded-controller: Document Surface RT EC

      commit: de296b53775cd1ccb6b448b4cc8d843c8858e1df
[2/2] power: supply: Add support for Surface RT battery and charger
      commit: 3d6529b837de49294cea0d4600144353f5f084dd

Best regards,

Signature · 1 line
Sebastian Reichel <[email protected]>