power: supply: Add battery and AC drivers for Surface devices
Maximilian Luz
maintainerv2 cover power: supply: Add battery and AC drivers for Surface devices
This series provides battery and AC drivers for Microsoft Surface devices, where this information is provided via an embedded controller (the Surface System Aggregator Module, SSAM) instead of the usual ACPI interface.
Specifically, 7th generation Surface devices, i.e. Surface Pro 7, Surface Book 3, Surface Laptop 3, as well as the Surface Laptop Go use this new interface.
Note: This series depends on the
platform/surface: Add Surface Aggregator device registry
series. More specifically patch
platform/surface: Set up Surface Aggregator device registry
The full series has been merged into the for-next branch of the platform-drivers-x86 tree and is available as immutable tag at
git://git.kernel.org/pub/scm/linux/kernel/git/pdx86/platform-drivers-x86.git tags/platform-drivers-x86-surface-aggregator-v5.13-1
Maximilian Luz (2):
power: supply: Add battery driver for Surface Aggregator Module
power: supply: Add AC driver for Surface Aggregator Module
.../ABI/testing/sysfs-class-power-surface | 15 + MAINTAINERS | 8 + drivers/power/supply/Kconfig | 32 + drivers/power/supply/Makefile | 2 + drivers/power/supply/surface_battery.c | 865 ++++++++++++++++++ drivers/power/supply/surface_charger.c | 282 ++++++ 6 files changed, 1204 insertions(+) create mode 100644 Documentation/ABI/testing/sysfs-class-power-surface create mode 100644 drivers/power/supply/surface_battery.c create mode 100644 drivers/power/supply/surface_charger.c
Signature · 1 line
2.31.1
Maximilian Luz
maintainerPATCH v2 1/2 power: supply: Add battery driver for Surface Aggregator Module
On newer Microsoft Surface models (specifically 7th-generation, i.e. Surface Pro 7, Surface Book 3, Surface Laptop 3, and Surface Laptop Go), battery and AC status/information is no longer handled via standard ACPI devices, but instead directly via the Surface System Aggregator Module (SSAM), i.e. the embedded controller on those devices.
While on previous generation models, battery status is also handled via SSAM, an ACPI shim was present to translate the standard ACPI battery interface to SSAM requests. The SSAM interface itself, which is modeled closely after the ACPI interface, has not changed.
This commit introduces a new SSAM client device driver to support battery status/information via the aforementioned interface on said Surface models. It is in parts based on the standard ACPI battery driver.
---
Changes in v2:
- Use devm_power_supply_register()
- Use .external_power_changed() callback instead of adapter event
- Use DEVICE_ATTR_RW() instead of manually specifying attribute
- Don't create device attribute manually, let psy take care of that
- Change return values for non-available properties to -ENODATA
- Fix constness of property arrays
- Drop mutex_destroy() call
- Inline spwr_battery_unregister()
--- .../ABI/testing/sysfs-class-power-surface | 15 + MAINTAINERS | 7 + drivers/power/supply/Kconfig | 16 + drivers/power/supply/Makefile | 1 + drivers/power/supply/surface_battery.c | 865 ++++++++++++++++++ 5 files changed, 904 insertions(+) create mode 100644 Documentation/ABI/testing/sysfs-class-power-surface create mode 100644 drivers/power/supply/surface_battery.c
Documentation/ABI/testing/sysfs-class-power-surface new file +15 -0
@@ -0,0 +1,15 @@ +What: /sys/class/power_supply/<supply_name>/alarm +Date: April 2021 +KernelVersion: 5.13 +Contact: Maximilian Luz <[email protected]> +Description: + Battery trip point. When the remaining battery capacity crosses this + value in either direction, the system will be notified and if + necessary woken. + + Set to zero to clear/disable. + + Access: Read, Write + + Valid values: In micro-Wh or micro-Ah, depending on the power unit + of the battery
MAINTAINERS +7 -0
@@ -11861,6 +11861,13 @@ F: drivers/scsi/smartpqi/smartpqi*.[ch] F: include/linux/cciss*.h F: include/uapi/linux/cciss*.h +MICROSOFT SURFACE BATTERY AND AC DRIVERS +M: Maximilian Luz <[email protected]> +L: [email protected] +L: [email protected] +S: Maintained +F: drivers/power/supply/surface_battery.c + MICROSOFT SURFACE GPE LID SUPPORT DRIVER M: Maximilian Luz <[email protected]> L: [email protected]
drivers/power/supply/Kconfig +16 -0
@@ -801,4 +801,20 @@ config BATTERY_ACER_A500 help Say Y to include support for Acer Iconia Tab A500 battery fuel gauge. +config BATTERY_SURFACE + tristate "Battery driver for 7th-generation Microsoft Surface devices" + depends on SURFACE_AGGREGATOR_REGISTRY + help + Driver for battery devices connected via/managed by the Surface System + Aggregator Module (SSAM). + + This driver provides battery-information and -status support for + Surface devices where said data is not exposed via the standard ACPI + devices. On those models (7th-generation), battery-information is + instead handled directly via SSAM client devices and this driver. + + Say M or Y here to include battery status support for 7th-generation + Microsoft Surface devices, i.e. Surface Pro 7, Surface Laptop 3, + Surface Book 3, and Surface Laptop Go. + endif # POWER_SUPPLY
drivers/power/supply/Makefile +1 -0
@@ -101,3 +101,4 @@ obj-$(CONFIG_CHARGER_BD99954) += bd99954-charger.o obj-$(CONFIG_CHARGER_WILCO) += wilco-charger.o obj-$(CONFIG_RN5T618_POWER) += rn5t618_power.o obj-$(CONFIG_BATTERY_ACER_A500) += acer_a500_battery.o +obj-$(CONFIG_BATTERY_SURFACE) += surface_battery.o
drivers/power/supply/surface_battery.c new file +865 -0
865 lines not on this page · raw message
Signature · 1 line
2.31.1
Maximilian Luz
maintainerPATCH v2 2/2 power: supply: Add AC driver for Surface Aggregator Module
In reply to Maximilian LuzOn newer Microsoft Surface models (specifically 7th-generation, i.e. Surface Pro 7, Surface Book 3, Surface Laptop 3, and Surface Laptop Go), battery and AC status/information is no longer handled via standard ACPI devices, but instead directly via the Surface System Aggregator Module (SSAM), i.e. the embedded controller on those devices.
While on previous generation models, AC status is also handled via SSAM, an ACPI shim was present to translate the standard ACPI AC interface to SSAM requests. The SSAM interface itself, which is modeled closely after the ACPI interface, has not changed.
This commit introduces a new SSAM client device driver to support AC status/information via the aforementioned interface on said Surface models.
---
Changes in v2:
- Use devm_power_supply_register()
- Specify .supplied_to
- Fix constness of property arrays
- Drop mutex_destroy() call
- Inline spwr_ac_unregister()
--- MAINTAINERS | 1 + drivers/power/supply/Kconfig | 16 ++ drivers/power/supply/Makefile | 1 + drivers/power/supply/surface_charger.c | 282 +++++++++++++++++++++++++ 4 files changed, 300 insertions(+) create mode 100644 drivers/power/supply/surface_charger.c
MAINTAINERS +1 -0
@@ -11867,6 +11867,7 @@ L: [email protected] L: [email protected] S: Maintained F: drivers/power/supply/surface_battery.c +F: drivers/power/supply/surface_charger.c MICROSOFT SURFACE GPE LID SUPPORT DRIVER M: Maximilian Luz <[email protected]>
drivers/power/supply/Kconfig +16 -0
@@ -817,4 +817,20 @@ config BATTERY_SURFACE Microsoft Surface devices, i.e. Surface Pro 7, Surface Laptop 3, Surface Book 3, and Surface Laptop Go. +config CHARGER_SURFACE + tristate "AC driver for 7th-generation Microsoft Surface devices" + depends on SURFACE_AGGREGATOR_REGISTRY + help + Driver for AC devices connected via/managed by the Surface System + Aggregator Module (SSAM). + + This driver provides AC-information and -status support for Surface + devices where said data is not exposed via the standard ACPI devices. + On those models (7th-generation), AC-information is instead handled + directly via a SSAM client device and this driver. + + Say M or Y here to include AC status support for 7th-generation + Microsoft Surface devices, i.e. Surface Pro 7, Surface Laptop 3, + Surface Book 3, and Surface Laptop Go. + endif # POWER_SUPPLY
drivers/power/supply/Makefile +1 -0
@@ -102,3 +102,4 @@ obj-$(CONFIG_CHARGER_WILCO) += wilco-charger.o 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
drivers/power/supply/surface_charger.c new file +282 -0
282 lines not on this page · raw message
Signature · 1 line
2.31.1
Hi,
Quoted 26 lines · Maximilian Luz
This series provides battery and AC drivers for Microsoft Surface devices, where this information is provided via an embedded controller (the Surface System Aggregator Module, SSAM) instead of the usual ACPI interface.
Specifically, 7th generation Surface devices, i.e. Surface Pro 7, Surface Book 3, Surface Laptop 3, as well as the Surface Laptop Go use this new interface.
Note: This series depends on the
platform/surface: Add Surface Aggregator device registry
series. More specifically patch
platform/surface: Set up Surface Aggregator device registry
The full series has been merged into the for-next branch of the platform-drivers-x86 tree and is available as immutable tag at
git://git.kernel.org/pub/scm/linux/kernel/git/pdx86/platform-drivers-x86.gittags/platform-drivers-x86-surface-aggregator-v5.13-1Maximilian Luz (2):
power: supply: Add battery driver for Surface Aggregator Module
power: supply: Add AC driver for Surface Aggregator Module
Quoted 10 lines
.../ABI/testing/sysfs-class-power-surface | 15 + MAINTAINERS | 8 + drivers/power/supply/Kconfig | 32 + drivers/power/supply/Makefile | 2 + drivers/power/supply/surface_battery.c | 865 ++++++++++++++++++ drivers/power/supply/surface_charger.c | 282 ++++++ 6 files changed, 1204 insertions(+) create mode 100644 Documentation/ABI/testing/sysfs-class-power-surface create mode 100644 drivers/power/supply/surface_battery.c create mode 100644 drivers/power/supply/surface_charger.c
Thanks, queued to power-supply's for-next branch using referenced immutable tag.
-- Sebastian