diff options
| author | Ognjen Galic <smclt30p@gmail.com> | 2018-02-07 09:58:13 -0500 |
|---|---|---|
| committer | Rafael J. Wysocki <rafael.j.wysocki@intel.com> | 2018-02-21 17:27:13 -0500 |
| commit | fa93854f7a7ed63d054405bf3779247d5300edd3 (patch) | |
| tree | fa4d31fbd9f2946d683a0534b456be3c68b6ad03 /include | |
| parent | 91ab883eb21325ad80f3473633f794c78ac87f51 (diff) | |
battery: Add the battery hooking API
This is a patch that implements a generic hooking API for the
generic ACPI battery driver.
With this new generic API, drivers can expose platform specific
behaviour via sysfs attributes in /sys/class/power_supply/BATn/
in a generic way.
A perfect example of the need for this API are Lenovo ThinkPads.
Lenovo ThinkPads have a ACPI extension that allows the setting of
start and stop charge thresholds in the EC and battery firmware
via ACPI. The thinkpad_acpi module can use this API to expose
sysfs attributes that it controls inside the ACPI battery driver
sysfs tree, under /sys/class/power_supply/BATN/.
The file drivers/acpi/battery.h has been moved to
include/acpi/battery.h and the includes inside ac.c, sbs.c, and
battery.c have been adjusted to reflect that.
When drivers hooks into the API, the API calls add_battery() for
each battery in the system that passes it a acpi_battery
struct. Then, the drivers can use device_create_file() to create
new sysfs attributes with that struct and identify the batteries
for per-battery attributes.
Signed-off-by: Ognjen Galic <smclt30p@gmail.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Diffstat (limited to 'include')
| -rw-r--r-- | include/acpi/battery.h | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/include/acpi/battery.h b/include/acpi/battery.h new file mode 100644 index 000000000000..5d8f5d910c82 --- /dev/null +++ b/include/acpi/battery.h | |||
| @@ -0,0 +1,21 @@ | |||
| 1 | /* SPDX-License-Identifier: GPL-2.0 */ | ||
| 2 | #ifndef __ACPI_BATTERY_H | ||
| 3 | #define __ACPI_BATTERY_H | ||
| 4 | |||
| 5 | #define ACPI_BATTERY_CLASS "battery" | ||
| 6 | |||
| 7 | #define ACPI_BATTERY_NOTIFY_STATUS 0x80 | ||
| 8 | #define ACPI_BATTERY_NOTIFY_INFO 0x81 | ||
| 9 | #define ACPI_BATTERY_NOTIFY_THRESHOLD 0x82 | ||
| 10 | |||
| 11 | struct acpi_battery_hook { | ||
| 12 | const char *name; | ||
| 13 | int (*add_battery)(struct power_supply *battery); | ||
| 14 | int (*remove_battery)(struct power_supply *battery); | ||
| 15 | struct list_head list; | ||
| 16 | }; | ||
| 17 | |||
| 18 | void battery_hook_register(struct acpi_battery_hook *hook); | ||
| 19 | void battery_hook_unregister(struct acpi_battery_hook *hook); | ||
| 20 | |||
| 21 | #endif | ||
