power: supply: gpio-charger: Support to disable charger
Subsystems (2)
cover power: supply: gpio-charger: Support to disable charger
From: Stefan Raufhake <[email protected]>
Hello,
We have a device with a simple built-in UPS, which is controlled by GPIOs. For the control of the UPS, we used the “gpio-charger” driver module from the power-supply. For our usecase we want to support enabing and disabling the ups. When the UPS is disabled, the device turns off immediately if the supply power is switched off. When the UPS is enabled, the device has power as long as the UPS has enough energy for the device. Now, we are looking for the best way to implement this function. This patch contains our first proposal.
Stefan Raufhake (1):
power: supply: gpio-charger: Support to disable charger
.../bindings/power/supply/gpio-charger.yaml | 6 +++ drivers/power/supply/gpio-charger.c | 43 +++++++++++++++++++ 2 files changed, 49 insertions(+)
Signature · 1 line
2.25.1
PATCH 1/1 power: supply: gpio-charger: Support to disable charger
From: Stefan Raufhake <[email protected]>
We want to disable the built-in UPS in our device
so that we can switch off the supply power of the device with and without the support of the UPS.
This commit will allow us to disable the ups by
using the command echo 1 > /sys/class/power_supply/xxx/charge_type (1 = POWER_SUPPLY_CHARGE_TYPE_NONE) and enable the charger by setting it to 4 (POWER_SUPPLY_CHARGE_TYPE_STANDARD).
--- .../bindings/power/supply/gpio-charger.yaml | 6 +++ drivers/power/supply/gpio-charger.c | 43 +++++++++++++++++++ 2 files changed, 49 insertions(+)
Documentation/devicetree/bindings/power/supply/gpio-charger.yaml +6 -0
@@ -44,6 +44,10 @@ properties: maxItems: 32 description: GPIOs used for current limiting + charge-disable-gpios: + maxItems: 1 + description: GPIO to disable the charger + charge-current-limit-mapping: description: List of tuples with current in uA and a GPIO bitmap (in this order). The tuples must be provided in descending order of the
@@ -68,6 +72,8 @@ anyOf: - charge-status-gpios - required: - charge-current-limit-gpios + - required: + - charge-type-gpios dependencies: charge-current-limit-gpios: [ charge-current-limit-mapping ]
drivers/power/supply/gpio-charger.c +43 -0
91 lines not on this page · raw message
Signature · 1 line
2.25.1
Quoted 3 lines · Stefan Raufhake
From: Stefan Raufhake <[email protected]>
We want to disable the built-in UPS in our device
Thank you for your patch. There is something to discuss/improve.
Quoted 2 lines
so that we can switch off the supply power of the
device with and without the support of the UPS.
Please wrap commit message according to Linux coding style / submission process (neither too early nor over the limit):
https://elixir.bootlin.com/linux/v6.4-rc1/source/Documentation/process/submitting-patches.rst#L597
Quoted 4 lines
This commit will allow us to disable the ups by
using the command echo 1 >/sys/class/power_supply/xxx/charge_type(1 =POWER_SUPPLY_CHARGE_TYPE_NONE) and enable the charger by setting it to 4 (POWER_SUPPLY_CHARGE_TYPE_STANDARD).
Please describe the hardware, not OS.
Quoted 5 lines
Signed-off-by Stefan Raufhake <[email protected]>--- .../bindings/power/supply/gpio-charger.yaml | 6 +++ drivers/power/supply/gpio-charger.c | 43 +++++++++++++++++++
Please run scripts/checkpatch.pl and fix reported warnings. Then please run scripts/checkpatch.pl --strict and (probably) fix more warnings. Some warnings can be ignored, especially from --strict run, but the code here looks like it needs a fix. Feel free to get in touch if the warning is not clear.
Documentation/devicetree/bindings/power/supply/gpio-charger.yaml properties: · line 49
Quoted 13 lines
2 files changed, 49 insertions(+)Documentation/devicetree/bindings/power/supply/gpio-charger.yaml +3
-0@@ -44,6 +44,10 @@ properties: maxItems: 32 description: GPIOs used for current limiting + charge-disable-gpios: + maxItems: 1 + description: GPIO to disable the charger
You just inverted existing "gpios" property, so no.
Best regards,
Krzysztof