power: supply: add Huawei Matebook E Go psy driver
Subsystems (2)
Pengyu Luo
maintainerPATCH RESEND v8 1/1 power: supply: add Huawei Matebook E Go psy driver
On the Huawei Matebook E Go tablet, the EC provides access to the adapter and battery status. Add the driver to read power supply status on the tablet.
This driver is inspired by the following drivers:
drivers/power/supply/lenovo_yoga_c630_battery.c drivers/platform/arm64/acer-aspire1-ec.c drivers/acpi/battery.c drivers/acpi/ac.c
---
base-commit: 2bdde620f7f2bff2ff1cb7dc166859eaa0c78a7c
---
Changes in v8 RESEND:
- rebased on tag next-20250407
- update KernelVersion in ABI
- Link to v8: https://lore.kernel.org/linux-pm/[email protected]
Changes in v8:
- since the base driver was mergerd by Ilpo, continue the PSY driver
- use correct power_supply_desc.type (Sebastian)
- use .set_property() to set start/end threshold (Sebastian)
- rework smart_charge sysfs and rename to smart_charge_delay, expose delay only (Sebastian)
- rename property smart_charge_enable to battery_adaptive_charge
- rebased on tag next-20250313
- Link to v7: https://lore.kernel.org/linux-arm-msm/[email protected]
Changes in v7:
- rebased on tag next-20250214
- fix Kconfig, this module depends on HWMON (kernel test robot)
- Link to v6: https://lore.kernel.org/linux-arm-msm/[email protected]
Changes in v6 RESEND:
- add Reviewed-by tag (Ilpo)
- remove extra line
- rebased on tag next-20250131
- Link to v6: https://lore.kernel.org/linux-arm-msm/[email protected]
Changes in v6:
- refactor one ternary operator expression (Ilpo)
- replace one expression with &= (Ilpo)
- use devm_mutex_init() instead of mutex_init() (Ilpo)
- add Reviewed-by tag for devicetree (Konrad)
- add explicit cast (void *) to fix warnings when compiling
- rebased on tag next-20250123
- Link to v5: https://lore.kernel.org/linux-arm-msm/[email protected]
Changes in v5 RESEND:
- rebased on tag next-20250120
- Link to v5: https://lore.kernel.org/linux-arm-msm/[email protected]
Changes in v5:
- handle return code of i2c_transfer() (Bryan)
- rename threshold validatition function (Bryan)
- add enumerates and defines for registers (Bryan)
- drop extra line in header (Heikki)
- add Reviewed-by tag for devicetree (Krzysztof)
- Link to v4: https://lore.kernel.org/linux-arm-msm/[email protected]
Changes in v4:
- use new API to register hwmon device instead of the deprecated one. (Guenter)
- add Reviewed-by tag for dt-binding (Krzysztof)
- drop unnecessary header (Ilpo)
- use guard mutex (Ilpo)
- improve comments and naming (Ilpo)
- add a shallow copy version of extr_resp() (Ilpo)
- add functions to handle resp and req whose size is 1
- drop PSY and UCSI subdrivers, commit them once the base driver is upstreamed
- Link to v3: https://lore.kernel.org/linux-arm-msm/[email protected]
Changes in v3:
- Link to v2: https://lore.kernel.org/linux-arm-msm/[email protected]
dt-binding:
- drop generic compatibles. (Krzysztof)
- remove '+' to use literal block style. (Krzysztof)
ec:
- take struct gaokun_ucsi_reg as parameter (Heikki)
- add almost all kernel doc comments (Krzysztof, Heikki)
ucsi:
- drop unnecessary ucsi quirks (Dmitry)
- add UCSI v1.0 to ucsi.h (Heikki)
- use gaokun_ucsi_read_cci() to read cci directly (Heikki)
- drop unnecessary gaokun_ucsi_get_port_num (Heikki)
- rename member port_num => num_ports (Heikki)
- fix completion, forgot to signal threads in previous version
dt:
- fix indentation (Konrad)
- add a link between role switch and connector
Changes in v2:
- Link to v1: https://lore.kernel.org/linux-arm-msm/[email protected]
global:
- drop qcom's products(i.e. sc8180x, sx8280xp) everywhere, use 'product'-based instead(Krzysztof, Bryan)
- drop Cc Nikita Travkin, we had discussed the device in PM.
- add myself to MAINTAINERS
dt-binding:
- fix building (Rob Herring (Arm))
- remove unnecessary code (Krzysztof)
- add bugzilla documentation, insights of gaokun(see [1] or patch[1/5]) (Krzysztof, Aiqun(Maria))
- explain the difference between PMIC GLink and gaokun EC (Aiqun(Maria))
ec:
- use Linux style comments (Krzysztof)
- add a comment for mutex lock (Krzysztof)
- add more kerneldoc for exported functions (Krzysztof)
- eliminate unnecessary conditions (Bryan)
- add a macro for check thresholds (Bryan)
- improve English (Bryan)
- use existing sysfs interface(hwmon, psy) whenever possible (Krzysztof)
- use __le16 and related endianess conversion function for temp data (Ilpo)
- drop alias for packet headers (Ilpo)
- avoid hardcoding i2c msgs size (Aiqun(Maria))
- add a comment for the sleep in critial region (Bryan, Aiqun(Maria))
- use macro to construct packet (Bryan, Aiqun(Maria))
wmi:
- dropped
ucsi:
- reorder headers (Bryan)
- a comment for the orientation map macro (Bryan)
- make mux mode map more explicit(minus six is very clear now) (Bryan, Dmitry)
- handle port update exceptions return (Bryan)
- a comment for the UCSI quirks (Dmitry)
- use the inline hint for the short register function (Dmitry)
- use the API with delay to handle register instead of a direct sleep (Bryan)
- handle unfinished initialization early
psy:
- add charging related sysfs to here (Krzysztof, Dmitry)
- document ABI for power_supply sysfs (Krzysztof)
- drop charging threshold, use smart charging instead
dts:
- correct indentation, properties' order. (Konrad)
--- .../ABI/testing/sysfs-class-power-gaokun | 27 + MAINTAINERS | 1 + drivers/power/supply/Kconfig | 10 + drivers/power/supply/Makefile | 1 + drivers/power/supply/huawei-gaokun-battery.c | 645 ++++++++++++++++++ 5 files changed, 684 insertions(+) create mode 100644 Documentation/ABI/testing/sysfs-class-power-gaokun create mode 100644 drivers/power/supply/huawei-gaokun-battery.c
Documentation/ABI/testing/sysfs-class-power-gaokun new file +27 -0
@@ -0,0 +1,27 @@ +What: /sys/class/power_supply/gaokun-ec-battery/smart_charge_delay +Date: March 2025 +KernelVersion: 6.16 +Contact: Pengyu Luo <[email protected]> +Description: + This entry allows configuration of smart charging delay. + + Smart charging behavior: when the power adapter is connected + for delay hours, battery charging will follow the rules of + charge_control_start_threshold and charge_control_end_threshold. + For more information about charge control, please refer to + sysfs-class-power. + + Access: Read, Write + + Valid values: In hours (non-negative) + +What: /sys/class/power_supply/gaokun-ec-battery/battery_adaptive_charge +Date: March 2025 +KernelVersion: 6.16 +Contact: Pengyu Luo <[email protected]> +Description: + This entry allows enabling battery adaptive charging. + + Access: Read, Write + + Valid values: 0 (disabled) or 1 (enabled)
MAINTAINERS +1 -0
@@ -10884,6 +10884,7 @@ M: Pengyu Luo <[email protected]> S: Maintained F: Documentation/devicetree/bindings/platform/huawei,gaokun-ec.yaml F: drivers/platform/arm64/huawei-gaokun-ec.c +F: drivers/power/supply/huawei-gaokun-battery.c F: include/linux/platform_data/huawei-gaokun-ec.h HUGETLB SUBSYSTEM
drivers/power/supply/Kconfig +10 -0
@@ -161,6 +161,16 @@ config BATTERY_DS2782 Say Y here to enable support for the DS2782/DS2786 standalone battery gas-gauge. +config BATTERY_HUAWEI_GAOKUN + tristate "Huawei Matebook E Go power supply" + depends on EC_HUAWEI_GAOKUN + help + This driver enables battery and adapter support on the Huawei Matebook + E Go, which is a sc8280xp-based 2-in-1 tablet. + + To compile the driver as a module, choose M here: the module will be + called huawei-gaokun-battery. + config BATTERY_LEGO_EV3 tristate "LEGO MINDSTORMS EV3 battery" depends on OF && IIO && GPIOLIB && (ARCH_DAVINCI_DA850 || COMPILE_TEST)
drivers/power/supply/Makefile +1 -0
@@ -31,6 +31,7 @@ obj-$(CONFIG_BATTERY_DS2781) += ds2781_battery.o obj-$(CONFIG_BATTERY_DS2782) += ds2782_battery.o obj-$(CONFIG_BATTERY_GAUGE_LTC2941) += ltc2941-battery-gauge.o obj-$(CONFIG_BATTERY_GOLDFISH) += goldfish_battery.o +obj-$(CONFIG_BATTERY_HUAWEI_GAOKUN) += huawei-gaokun-battery.o obj-$(CONFIG_BATTERY_LEGO_EV3) += lego_ev3_battery.o obj-$(CONFIG_BATTERY_LENOVO_YOGA_C630) += lenovo_yoga_c630_battery.o obj-$(CONFIG_BATTERY_PMU) += pmu_battery.o
drivers/power/supply/huawei-gaokun-battery.c new file +645 -0
645 lines not on this page · raw message
Signature · 1 line
2.48.1