power: supply: PCHG: Peripheral device charger
Subsystems (3)
PATCH v7 1/2 power: supply: PCHG: Peripheral device charger
This patch adds a driver for PCHG (Peripheral CHarGer). PCHG is a framework managing power supplies for peripheral devices.
This driver creates a sysfs node for each peripheral charge port:
/sys/class/power_supply/peripheral<n>
where <n> is the index of a charge port.
For example, when a stylus is connected to a NFC/WLC port, the node returns:
/sys/class/power_supply/peripheral0/ capacity=50 charge_type=Standard scope=Device status=Charging type=Battery
---
v2
* Separate mfd/cros_ec_dev.c
* Make CONFIG_CHARGER_CROS_PCHG default to CONFIG_MFD_CROS_EC_DEV v3
* Return POWER_SUPPLY_SCOPE_DEVICE for POWER_SUPPLY_PROP_SCOPE
* POWER_SUPPLY_TYPE_WIRELESS -> POWER_SUPPLY_TYPE_BATTERY
v4
* Return NOTIFY_DONE when a non-host event is notified.
v5
* Change sysfs node prefix from PCHG to peripheral.
* Update EC_CMD_PCHG to v1 and make probe fail if EC doesn't support it.
* Call power_supply_changed if status or battery percentage changed.
* Add PCHG_STATE_FULL. It's sent from EC explicitly for fully charged battery.
* Register each port as a wakeup source.
v6
* Add POWER_SUPPLY_PROP_CHARGE_TYPE support.
v7
* Make cros_pchg_probe return EOPNOTSUPP (instead of ENOTSUPP).
--- drivers/power/supply/Kconfig | 10 + drivers/power/supply/Makefile | 1 + .../power/supply/cros_peripheral_charger.c | 396 ++++++++++++++++++ .../linux/platform_data/cros_ec_commands.h | 67 +++ 4 files changed, 474 insertions(+) create mode 100644 drivers/power/supply/cros_peripheral_charger.c
drivers/power/supply/Kconfig +10 -0
@@ -735,6 +735,16 @@ config CHARGER_CROS_USBPD what is connected to USB PD ports from the EC and converts that into power_supply properties. +config CHARGER_CROS_PCHG + tristate "ChromeOS EC based peripheral charger" + depends on MFD_CROS_EC_DEV + default MFD_CROS_EC_DEV + help + Say Y here to enable ChromeOS EC based peripheral charge driver. + This driver gets various information about the devices connected to + the peripheral charge ports from the EC and converts that into + power_supply properties. + config CHARGER_SC2731 tristate "Spreadtrum SC2731 charger driver" depends on MFD_SC27XX_PMIC || COMPILE_TEST
drivers/power/supply/Makefile +1 -0
@@ -93,6 +93,7 @@ obj-$(CONFIG_CHARGER_TPS65217) += tps65217_charger.o obj-$(CONFIG_AXP288_FUEL_GAUGE) += axp288_fuel_gauge.o obj-$(CONFIG_AXP288_CHARGER) += axp288_charger.o obj-$(CONFIG_CHARGER_CROS_USBPD) += cros_usbpd-charger.o +obj-$(CONFIG_CHARGER_CROS_PCHG) += cros_peripheral_charger.o obj-$(CONFIG_CHARGER_SC2731) += sc2731_charger.o obj-$(CONFIG_FUEL_GAUGE_SC27XX) += sc27xx_fuel_gauge.o obj-$(CONFIG_CHARGER_UCS1002) += ucs1002_power.o
drivers/power/supply/cros_peripheral_charger.c new file +396 -0
396 lines not on this page · raw message
include/linux/platform_data/cros_ec_commands.h +67 -0
79 lines not on this page · raw message
Signature · 1 line
2.31.0
PATCH v7 2/2 mfd: cros_ec: Add peripheral device charger
This patch adds a cell entry for PCHG (Peripheral CHarGer). PCHG is a framework managing power supplies for peripheral devices.
---
v2
* None
v3
* None
v4
* None
V5
* None
V6
* None
v7
* Rebase on torvalds/master.
--- drivers/mfd/cros_ec_dev.c | 1 + 1 file changed, 1 insertion(+)
drivers/mfd/cros_ec_dev.c +1 -0
@@ -114,6 +114,7 @@ static const struct mfd_cell cros_ec_platform_cells[] = { { .name = "cros-ec-debugfs", }, { .name = "cros-ec-lightbar", }, { .name = "cros-ec-sysfs", }, + { .name = "cros-ec-pchg", }, }; static const struct mfd_cell cros_ec_vbc_cells[] = {
Signature · 1 line
2.31.0
Lee Jones
AppliedRe: [PATCH v7 2/2] mfd: cros_ec: Add peripheral device charger
Quoted 18 lines · Daisuke Nojiri
This patch adds a cell entry for PCHG (Peripheral CHarGer). PCHG is a framework managing power supplies for peripheral devices.
Signed-off-by Daisuke Nojiri <[email protected]>Acked-for-mfd-by Lee Jones <[email protected]>---
v2
* None
v3
* None
v4
* None
V5
* None
V6
* None
v7
* Rebase on torvalds/master.
Quoted 3 lines
--- drivers/mfd/cros_ec_dev.c | 1 + 1 file changed, 1 insertion(+)
Applied, thanks.
Signature · 4 lines
Lee Jones [李琼斯] Senior Technical Lead - Developer Services Linaro.org │ Open source software for Arm SoCs Follow Linaro: Facebook | Twitter | Blog
Hi,
Quoted 29 lines · Daisuke Nojiri
This patch adds a driver for PCHG (Peripheral CHarGer). PCHG is a framework managing power supplies for peripheral devices.
This driver creates a sysfs node for each peripheral charge port:
/sys/class/power_supply/peripheral<n>
where <n> is the index of a charge port.
For example, when a stylus is connected to a NFC/WLC port, the node returns:
/sys/class/power_supply/peripheral0/ capacity=50 charge_type=Standard scope=Device status=Charging type=BatterySigned-off-by Daisuke Nojiri <[email protected]>---
[...]drivers/power/supply/cros_peripheral_charger.c new file +7
-0+static enum power_supply_property cros_pchg_props[] = { +POWER_SUPPLY_PROP_STATUS , +POWER_SUPPLY_PROP_CHARGE_TYPE , +POWER_SUPPLY_PROP_CAPACITY , +POWER_SUPPLY_PROP_SCOPE , +/* +* todo: Add the following.
drivers/power/supply/cros_peripheral_charger.c line 61
Quoted 10 lines
drivers/power/supply/cros_peripheral_charger.c new file +9
-0+* +* POWER_SUPPLY_PROP_TECHNOLOGY, +* POWER_SUPPLY_PROP_ERROR, +* POWER_SUPPLY_PROP_SERIAL_NUMBER, +* +* POWER_SUPPLY_PROP_ONLINE can't be used because it indicates the +* system is powered by AC. +*/ +};
Thanks, I queued the driver with the above TODO removed. Please track this downstream, the note is not useful in mainline kernel, since we do not have (AFAIK) the necessary documentation to add more features.
-- Sebastian