Add Richtek RT9471 3A battery charger support
Subsystems (2)
v5 cover Add Richtek RT9471 3A battery charger support
From: ChiYuan Huang <[email protected]>
This patch set is to add Richtek RT9471 charger support.
The RT9471/D is a highly-integrated 3A switch mode battery charge management and system power path management device for single cell Li-Ion and Li-polymer battery. The low impedance power path optimizes switch-mode operation efficiency, reduces battery charging time and extends battery life during discharging phase.
Since v5:
- Remove one line wrapper.
- Merge header content into source file, remove header file.
- Remove 'charge_term_enable' sysfs entry and merge it into 'charge_term_current' property control.
- Change MODULE_LICENSE from 'GPL v2' to 'GPL'. Following by the below discussion
https://lore.kernel.org/all/[email protected]/
- Recover all the change in sysfs-class-power.
- New a sysfs-class-power-rt9471 file.
- Remove 'charge_term_enable' sysfs entry, directly integrate it in 'charge_term_current' power supply property control.
Since v4:
- Remove the line for the owner field in driver.
- Add the documentation for sysfs entries.
Since v3:
- Move unevaluatedProperties line after $ref for binding patch.
- Add Reviewed-by tag for binding patch.
Since v2:
- Remove the properties for interrupt controller things in the binding documentation.
- Fix dtc error for typo, it's 'regulator-name', not 'regulator-compatible'.
- Add regulator min/max microamp to allow otg vbus current adjustable in example.
- Specify the active-level for charge-enable-gpios in binding example.
- Fix checkpatch error about 'foo * bar' to 'foo *bar' in psy_device_to_chip function.
- Specify the member name directly for the use of linear range.
ChiYuan Huang (3):
dt-bindings: power: supply: Add Richtek RT9471 battery charger
power: supply: rt9471: Add Richtek RT9471 charger driver
Documentation: power: rt9471: Document exported sysfs entries
Documentation/ABI/testing/sysfs-class-power-rt9471 | 29 + .../bindings/power/supply/richtek,rt9471.yaml | 73 ++ drivers/power/supply/Kconfig | 16 + drivers/power/supply/Makefile | 1 + drivers/power/supply/rt9471.c | 937 +++++++++++++++++++++ 5 files changed, 1056 insertions(+) create mode 100644 Documentation/ABI/testing/sysfs-class-power-rt9471 create mode 100644 Documentation/devicetree/bindings/power/supply/richtek,rt9471.yaml create mode 100644 drivers/power/supply/rt9471.c
Signature · 1 line
2.7.4
PATCH v5 1/3 dt-bindings: power: supply: Add Richtek RT9471 battery charger
From: ChiYuan Huang <[email protected]>
Add bindings for the Richtek RT9471 I2C controlled battery charger.
---
Since v3
- Move unevaluatedProperties line after $ref for binding patch.
- Add Reviewed-by tag for binding patch.
Since v2
- Remove the properties for interrupt controller things in the binding documentation.
- Fix dtc error for typo, it's 'regulator-name', not 'regulator-compatible'.
- Add regulator min/max microamp to allow otg vbus current adjustable in example.
- Specify the active-level for charge-enable-gpios in binding example.
--- .../bindings/power/supply/richtek,rt9471.yaml | 73 ++++++++++++++++++++++ 1 file changed, 73 insertions(+) create mode 100644 Documentation/devicetree/bindings/power/supply/richtek,rt9471.yaml
Documentation/devicetree/bindings/power/supply/richtek,rt9471.yaml new file +73 -0
@@ -0,0 +1,73 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/power/supply/richtek,rt9471.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Richtek RT9471 3A Single Cell Switching Battery charger + +maintainers: + - Alina Yu <[email protected]> + - ChiYuan Huang <[email protected]> + +description: | + RT9471 is a switch-mode single cell Li-Ion/Li-Polymer battery charger for + portable applications. It supports USB BC1.2 port detection, current and + voltage regulations in both charging and boost mode. + + Datasheet is available at + https://www.richtek.com/assets/product_file/RT9471=RT9471D/DS9471D-02.pdf + +properties: + compatible: + const: richtek,rt9471 + + reg: + maxItems: 1 + + charge-enable-gpios: + description: GPIO used to turn on and off charging. + maxItems: 1 + + wakeup-source: true + + interrupts: + maxItems: 1 + + usb-otg-vbus-regulator: + type: object + $ref: /schemas/regulator/regulator.yaml# + unevaluatedProperties: false + +required: + - compatible + - reg + - wakeup-source + - interrupts + +additionalProperties: false + +examples: + - | + #include <dt-bindings/interrupt-controller/irq.h> + #include <dt-bindings/gpio/gpio.h> + i2c { + #address-cells = <1>; + #size-cells = <0>; + + charger@53 { + compatible = "richtek,rt9471"; + reg = <0x53>; + charge-enable-gpios = <&gpio26 1 GPIO_ACTIVE_LOW>; + wakeup-source; + interrupts-extended = <&gpio_intc 32 IRQ_TYPE_EDGE_FALLING>; + + usb-otg-vbus-regulator { + regulator-name = "usb-otg-vbus"; + regulator-min-microvolt = <4850000>; + regulator-max-microvolt = <5300000>; + regulator-min-microamp = <500000>; + regulator-max-microamp = <1200000>; + }; + }; + };
Signature · 1 line
2.7.4
Re: [PATCH v5 1/3] dt-bindings: power: supply: Add Richtek RT9471 battery charger
Quoted 19 lines · cy_huang
From: ChiYuan Huang <[email protected]>
Add bindings for the Richtek RT9471 I2C controlled battery charger.
Reviewed-by Krzysztof Kozlowski <[email protected]>Co-developed-by Alina Yu <[email protected]>Signed-off-by Alina Yu <[email protected]>Signed-off-by ChiYuan Huang <[email protected]>---
Since v3
- Move unevaluatedProperties line after $ref for binding patch.
- Add Reviewed-by tag for binding patch.Since v2
- Remove the properties for interrupt controller things in the binding documentation.
- Fix dtc error for typo, it's 'regulator-name', not 'regulator-compatible'.
- Add regulator min/max microamp to allow otg vbus current adjustable in example.
- Specify the active-level for charge-enable-gpios in binding example.
Quoted 5 lines
--- .../bindings/power/supply/richtek,rt9471.yaml | 73 ++++++++++++++++++++++ 1 file changed, 73 insertions(+) create mode 100644 Documentation/devicetree/bindings/power/supply/richtek,rt9471.yaml
My bot found errors running 'make DT_CHECKER_FLAGS=-m dt_binding_check' on your patch (DT_CHECKER_FLAGS is new in v5.13):
yamllint warnings/errors:
dtschema/dtc warnings/errors:
/builds/robherring/dt-review-ci/linux/Documentation/devicetree/bindings/dma/renesas,rzn1-dmamux.example.dtb: dma-router@a0: dma-masters:0: [4294967295, 4294967295] is too long
From schema: /builds/robherring/dt-review-ci/linux/Documentation/devicetree/bindings/dma/renesas,rzn1-dmamux.yaml
/builds/robherring/dt-review-ci/linux/Documentation/devicetree/bindings/dma/renesas,rzn1-dmamux.example.dtb: dma-router@a0: dma-masters:0: [4294967295, 4294967295] is too long
From schema: /builds/robherring/dt-review-ci/linux/Documentation/devicetree/bindings/dma/dma-router.yaml
/builds/robherring/dt-review-ci/linux/Documentation/devicetree/bindings/dma/st,stm32-dmamux.example.dtb: dma-router@40020800: dma-masters:0: [4294967295, 4294967295] is too long
From schema: /builds/robherring/dt-review-ci/linux/Documentation/devicetree/bindings/dma/dma-router.yaml
/builds/robherring/dt-review-ci/linux/Documentation/devicetree/bindings/dma/st,stm32-dmamux.example.dtb: dma-router@40020800: dma-masters:0: [4294967295, 4294967295] is too long
From schema: /builds/robherring/dt-review-ci/linux/Documentation/devicetree/bindings/dma/st,stm32-dmamux.yaml
/builds/robherring/dt-review-ci/linux/Documentation/devicetree/bindings/dma/st,stm32-dmamux.example.dtb: dma-router@40020800: Unevaluated properties are not allowed ('dma-channels', 'dma-masters', 'dma-requests' were unexpected)
From schema: /builds/robherring/dt-review-ci/linux/Documentation/devicetree/bindings/dma/st,stm32-dmamux.yaml
doc reference errors (make refcheckdocs):
See https://patchwork.ozlabs.org/patch/
This check can fail if there are any dependencies. The base for a patch series is generally the most recent rc1.
If you already ran 'make dt_binding_check' and didn't see the above error(s), then make sure 'yamllint' is installed and dt-schema is up to date:
pip3 install dtschema --upgrade
Please check and re-submit.
Rob Herring
maintainerRe: [PATCH v5 1/3] dt-bindings: power: supply: Add Richtek RT9471 battery charger
Quoted 31 lines · Krzysztof Kozlowski
Quoted 19 lines · cy_huang
From: ChiYuan Huang <[email protected]>
Add bindings for the Richtek RT9471 I2C controlled battery charger.
Reviewed-by Krzysztof Kozlowski <[email protected]>Co-developed-by Alina Yu <[email protected]>Signed-off-by Alina Yu <[email protected]>Signed-off-by ChiYuan Huang <[email protected]>---
Since v3
- Move unevaluatedProperties line after $ref for binding patch.
- Add Reviewed-by tag for binding patch.Since v2
- Remove the properties for interrupt controller things in the binding documentation.
- Fix dtc error for typo, it's 'regulator-name', not 'regulator-compatible'.
- Add regulator min/max microamp to allow otg vbus current adjustable in example.
- Specify the active-level for charge-enable-gpios in binding example.Quoted 5 lines
--- .../bindings/power/supply/richtek,rt9471.yaml | 73 ++++++++++++++++++++++ 1 file changed, 73 insertions(+) create mode 100644 Documentation/devicetree/bindings/power/supply/richtek,rt9471.yamlMy bot found errors running 'make DT_CHECKER_FLAGS=-m
dt_binding_check' on your patch (DT_CHECKER_FLAGSis new in v5.13):yamllint warnings/errors:
Quoted 11 lines
dtschema/dtc warnings/errors:
/builds/robherring/dt-review-ci/linux/Documentation/devicetree/bindings/dma/renesas,rzn1-dmamux.example.dtb: dma-router@a0: dma-masters:0: [4294967295, 4294967295] is too long
From schema: /builds/robherring/dt-review-ci/linux/Documentation/devicetree/bindings/dma/renesas,rzn1-dmamux.yaml
/builds/robherring/dt-review-ci/linux/Documentation/devicetree/bindings/dma/renesas,rzn1-dmamux.example.dtb: dma-router@a0: dma-masters:0: [4294967295, 4294967295] is too long
From schema: /builds/robherring/dt-review-ci/linux/Documentation/devicetree/bindings/dma/dma-router.yaml
/builds/robherring/dt-review-ci/linux/Documentation/devicetree/bindings/dma/st,stm32-dmamux.example.dtb: dma-router@40020800: dma-masters:0: [4294967295, 4294967295] is too long
From schema: /builds/robherring/dt-review-ci/linux/Documentation/devicetree/bindings/dma/dma-router.yaml
/builds/robherring/dt-review-ci/linux/Documentation/devicetree/bindings/dma/st,stm32-dmamux.example.dtb: dma-router@40020800: dma-masters:0: [4294967295, 4294967295] is too long
From schema: /builds/robherring/dt-review-ci/linux/Documentation/devicetree/bindings/dma/st,stm32-dmamux.yaml
/builds/robherring/dt-review-ci/linux/Documentation/devicetree/bindings/dma/st,stm32-dmamux.example.dtb: dma-router@40020800: Unevaluated properties are not allowed ('dma-channels', 'dma-masters', 'dma-requests' were unexpected)
From schema: /builds/robherring/dt-review-ci/linux/Documentation/devicetree/bindings/dma/st,stm32-dmamux.yaml
Ignore this. Unrelated.
Rob
PATCH v5 2/3 power: supply: rt9471: Add Richtek RT9471 charger driver
In reply to cy_huangFrom: ChiYuan Huang <[email protected]>
Add support for the RT9471 3A 1-Cell Li+ battery charger.
The RT9471 is a highly-integrated 3A switch mode battery charger with low impedance power path to better optimize the charging efficiency.
---
Since v5:
- Remove one line wrapper.
- Merge header content into source file, remove header file.
- Remove 'charge_term_enable' sysfs entry and merge it into 'charge_term_current' property control.
- Change MODULE_LICENSE from 'GPL v2' to 'GPL'. Following by the below discussion
https://lore.kernel.org/all/[email protected]/
Since v4:
- Remove the line for the owner field in driver.
Since v2:
- Fix checkpatch error about 'foo * bar' to 'foo *bar' in psy_device_to_chip function.
- Specify the member name directly for the use of linear range.
--- drivers/power/supply/Kconfig | 16 + drivers/power/supply/Makefile | 1 + drivers/power/supply/rt9471.c | 937 ++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 954 insertions(+) create mode 100644 drivers/power/supply/rt9471.c
drivers/power/supply/Kconfig +16 -0
@@ -772,6 +772,22 @@ config CHARGER_RT9455 help Say Y to enable support for Richtek RT9455 battery charger. +config CHARGER_RT9471 + tristate "Richtek RT9471 battery charger driver" + depends on I2C && GPIOLIB && REGULATOR + select REGMAP_I2C + select REGMAP_IRQ + select LINEAR_RANGES + help + This adds support for Richtek RT9471 battery charger. RT9471 is + highly-integrated switch mode battery charger which is system power + patch manageable device for single cell Li-Ion and Li-polymer battery. + It can support BC12 detection on DPDM, and current and voltage + regulation on both charging and boost mode. + + This driver can also be built as a module. If so, the module will be + called rt9471. + config CHARGER_CROS_USBPD tristate "ChromeOS EC based USBPD charger" depends on CROS_USBPD_NOTIFY
drivers/power/supply/Makefile +1 -0
@@ -57,6 +57,7 @@ obj-$(CONFIG_BATTERY_MAX1721X) += max1721x_battery.o obj-$(CONFIG_BATTERY_Z2) += z2_battery.o obj-$(CONFIG_BATTERY_RT5033) += rt5033_battery.o obj-$(CONFIG_CHARGER_RT9455) += rt9455_charger.o +obj-$(CONFIG_CHARGER_RT9471) += rt9471.o obj-$(CONFIG_BATTERY_S3C_ADC) += s3c_adc_battery.o obj-$(CONFIG_BATTERY_TWL4030_MADC) += twl4030_madc_battery.o obj-$(CONFIG_CHARGER_88PM860X) += 88pm860x_charger.o
drivers/power/supply/rt9471.c new file +937 -0
937 lines not on this page · raw message
Signature · 1 line
2.7.4
Re: [PATCH v5 2/3] power: supply: rt9471: Add Richtek RT9471 charger driver
Hi,
Quoted 19 lines · cy_huang
From: ChiYuan Huang <[email protected]>
Add support for the RT9471 3A 1-Cell Li+ battery charger.
The RT9471 is a highly-integrated 3A switch mode battery charger with low impedance power path to better optimize the charging efficiency.
Co-developed-by Alina Yu <[email protected]>Signed-off-by Alina Yu <[email protected]>Signed-off-by ChiYuan Huang <[email protected]>---
[...]drivers/power/supply/rt9471.c new file +7
-0+static DEVICE_ATTR_RW (sysoff_enable); +static DEVICE_ATTR_RW (port_detect_enable); + +static struct attribute *rt9471_sysfs_entries[] = { + &dev_attr_sysoff_enable.attr, + &dev_attr_port_detect_enable.attr, +NULL
drivers/power/supply/rt9471.c line 717
Quoted 10 lines
drivers/power/supply/rt9471.c new file +10
-0+}; + +static const struct attribute_group rt9471_attr_group = { + .attrs = rt9471_sysfs_entries, +}; + +static const struct attribute_group *rt9471_attr_groups[] = { + &rt9471_attr_group, +NULL +};
Iff these custom properties are required (see response to the last patch), then 'ATTRIBUTE_GROUPS()' can be used to simplify this part a bit.
-- Sebastian
PATCH v5 3/3 Documentation: power: rt9471: Document exported sysfs entries
In reply to cy_huangFrom: ChiYuan Huang <[email protected]>
Document the settings exported by rt9471 charger driver through sysfs entries:
- sysoff_enable
- port_detect_enable
---
Since v5:
- Recover all the change in sysfs-class-power.
- New a sysfs-class-power-rt9471 file.
- Remove 'charge_term_enable' sysfs entry, directly integrate it in 'charge_term_current' power supply property control.
--- Documentation/ABI/testing/sysfs-class-power-rt9471 | 29 ++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 Documentation/ABI/testing/sysfs-class-power-rt9471
Documentation/ABI/testing/sysfs-class-power-rt9471 new file +29 -0
@@ -0,0 +1,29 @@ +What: /sys/class/power_supply/rt9471-*/sysoff_enable +Date: Oct 2022 +KernelVersion: 6.1 +Contact: ChiYuan Huang <[email protected]> +Description: + This entry allows enabling the sysoff mode of rt9471 charger devices. + If enabled and the input is removed, the internal battery FET is turned + off to reduce the leakage from the BAT pin. See device datasheet for details. + It's commonly used when the product enter shipping stage. + + Access: Read, Write + Valid values: + - 1: enabled + - 0: disabled + +What: /sys/class/power_supply/rt9471-*/port_detect_enable +Date: Oct 2022 +KernelVersion: 6.1 +Contact: ChiYuan Huang <[email protected]> +Description: + This entry allows enabling the USB BC12 port detect function of rt9471 charger + devices. If enabled and VBUS is inserted, device will start to do the BC12 + port detect and report the usb port type when port detect is done. See + datasheet for details. Normally controlled when TypeC/USBPD port integrated. + + Access: Read, Write + Valid values: + - 1: enabled + - 0: disabled
Signature · 1 line
2.7.4
Re: [PATCH v5 3/3] Documentation: power: rt9471: Document exported sysfs entries
Hi,
Quoted 29 lines · cy_huang
From: ChiYuan Huang <[email protected]>
Document the settings exported by rt9471 charger driver through sysfs entries:
-sysoff_enable
-port_detect_enableSigned-off-by ChiYuan Huang <[email protected]>---
Since v5:
- Recover all the change in sysfs-class-power.
- New a sysfs-class-power-rt9471 file.
- Remove 'charge_term_enable' sysfs entry, directly integrate it in 'charge_term_current' power supply property control.--- Documentation/ABI/testing/sysfs-class-power-rt9471 | 29 ++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 Documentation/ABI/testing/sysfs-class-power-rt9471Documentation/ABI/testing/sysfs-class-power-rt9471 new file +4
-0@@ -0,0 +1,29 @@ +What: /sys/class/power_supply/rt9471-*/sysoff_enable +Date: Oct 2022 +KernelVersion: 6.1 +Contact: ChiYuan Huang <[email protected]>
Documentation/ABI/testing/sysfs-class-power-rt9471 line 14
Quoted 10 lines
Documentation/ABI/testing/sysfs-class-power-rt9471 new file +10
-0+Description: + This entry allows enabling the sysoff mode of rt9471 charger devices. + If enabled and the input is removed, the internal battery FET is turned + off to reduce the leakage from the BAT pin. See device datasheet for details. + It's commonly used when the product enter shipping stage. + + Access: Read, Write + Valid values: + - 1: enabled + - 0: disabled
I still fail to see why this needs to be controllable at runtime. This looks like a hardware property. Are there any known products, which need this disabled?
Quoted 4 lines
Documentation/ABI/testing/sysfs-class-power-rt9471 new file +4
-0+What: /sys/class/power_supply/rt9471-*/port_detect_enable +Date: Oct 2022 +KernelVersion: 6.1 +Contact: ChiYuan Huang <[email protected]>
Documentation/ABI/testing/sysfs-class-power-rt9471 line 29
Quoted 10 lines
Documentation/ABI/testing/sysfs-class-power-rt9471 new file +10
-0+Description: + This entry allows enabling the USB BC12 port detect function of rt9471 charger + devices. If enabled and VBUS is inserted, device will start to do the BC12 + port detect and report the usb port type when port detect is done. See + datasheet for details. Normally controlled when TypeC/USBPD port integrated. + + Access: Read, Write + Valid values: + - 1: enabled + - 0: disabled
So basically this depends on the hardware integration (e.g. it should be disabled when power source is a DC barrel jack instead of USB) and is not supposed to change at all during runtime? Then the information wether it needs to be enabled should be derived from the device tree.
-- Sebastian
Re: [PATCH v5 3/3] Documentation: power: rt9471: Document exported sysfs entries
Sebastian Reichel <[email protected]> 於 2022年9月17日 週六 上午9:19寫道:
Quoted 39 lines
Hi,
Quoted 35 lines · cy_huang
From: ChiYuan Huang <[email protected]>
Document the settings exported by rt9471 charger driver through sysfs entries:
-sysoff_enable
-port_detect_enableSigned-off-by ChiYuan Huang <[email protected]>---
Since v5:
- Recover all the change in sysfs-class-power.
- New a sysfs-class-power-rt9471 file.
- Remove 'charge_term_enable' sysfs entry, directly integrate it in 'charge_term_current' power supply property control.--- Documentation/ABI/testing/sysfs-class-power-rt9471 | 29 ++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 Documentation/ABI/testing/sysfs-class-power-rt9471Documentation/ABI/testing/sysfs-class-power-rt9471 new file +10
-0@@ -0,0 +1,29 @@ +What: /sys/class/power_supply/rt9471-*/sysoff_enable +Date: Oct 2022 +KernelVersion: 6.1 +Contact: ChiYuan Huang <[email protected]> +Description: + This entry allows enabling the sysoff mode of rt9471 charger devices. + If enabled and the input is removed, the internal battery FET is turned + off to reduce the leakage from the BAT pin. See device datasheet for details. + It's commonly used when the product enter shipping stage. +
Quoted 8 lines
Documentation/ABI/testing/sysfs-class-power-rt9471 line 14
Quoted 4 lines
Documentation/ABI/testing/sysfs-class-power-rt9471 new file +4
-0+ Access: Read, Write + Valid values: + - 1: enabled + - 0: disabledI still fail to see why this needs to be controllable at runtime. This looks like a hardware property. Are there any known products, which need this disabled?
It's just a switch, actually 'disabled' is not needed.
For the enabled case, mostly used in below scenarios
1. Online testing, USB IN -> Factory testing -> write 1 to enable -> USB out -> immediately VSYS off -> pack
2. Offline testing no vbus -> Factory testing -> write 1 to enable -> immediately VSYS off -> pack
The 'disable" can use to cancel the shipping mode in case 1 before USB out. It's more like the testing.
Like as you said, shipping BATFET_OFF is all the hardware behavior. To leave this mode after VSYS off, there're three ways
1. power key pressed
2. VBUS IN
3. control BATFET_OFF to 0 (But it need SOC to be alive, at the time, VSYS off, no one can execute this I2C command)
If what you care is no need to mention 'disable', then just remove it. It's fine.
Quoted 13 lines
Quoted 13 lines
Documentation/ABI/testing/sysfs-class-power-rt9471 new file +12
-0+What: /sys/class/power_supply/rt9471-*/port_detect_enable +Date: Oct 2022 +KernelVersion: 6.1 +Contact: ChiYuan Huang <[email protected]> +Description: + This entry allows enabling the USB BC12 port detect function of rt9471 charger + devices. If enabled and VBUS is inserted, device will start to do the BC12 + port detect and report the usb port type when port detect is done. See + datasheet for details. Normally controlled when TypeC/USBPD port integrated. + + Access: Read, Write + Valid values:
Quoted 8 lines
Documentation/ABI/testing/sysfs-class-power-rt9471 line 28
Quoted 2 lines
Documentation/ABI/testing/sysfs-class-power-rt9471 new file +2
-0+ - 1: enabled + - 0: disabledSo basically this depends on the hardware integration (e.g. it should be disabled when power source is a DC barrel jack instead of USB) and is not supposed to change at all during runtime? Then the information wether it needs to be enabled should be derived from the device tree.
It's a switching charger integrates OTG boost.
For the case 'DC Jack', there's no need to use this kind of product.
With typec integration, at most time, it still need bc12 to be enabled by default.
Just in some case, like as power role swap (SNK -> SRC -> SNK), to automatically identify the USB port,
this may interrupt USB communication.
So as my understanding, keep it enabled by default, just in some case, it my need to control at runtime.
Quoted 2 lines
-- Sebastian
Re: [PATCH v5 3/3] Documentation: power: rt9471: Document exported sysfs entries
Hi,
Quoted 55 lines · ChiYuan Huang
Sebastian Reichel <[email protected]> 於 2022年9月17日 週六 上午9:19寫道:
Quoted 36 lines · cy_huang
Quoted 35 lines
From: ChiYuan Huang <[email protected]>
Document the settings exported by rt9471 charger driver through sysfs entries:
-sysoff_enable
-port_detect_enableSigned-off-by ChiYuan Huang <[email protected]>---
Since v5:
- Recover all the change in sysfs-class-power.
- New a sysfs-class-power-rt9471 file.
- Remove 'charge_term_enable' sysfs entry, directly integrate it in 'charge_term_current' power supply property control.--- Documentation/ABI/testing/sysfs-class-power-rt9471 | 29 ++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 Documentation/ABI/testing/sysfs-class-power-rt9471Documentation/ABI/testing/sysfs-class-power-rt9471 new file +10
-0@@ -0,0 +1,29 @@ +What: /sys/class/power_supply/rt9471-*/sysoff_enable +Date: Oct 2022 +KernelVersion: 6.1 +Contact: ChiYuan Huang <[email protected]> +Description: + This entry allows enabling the sysoff mode of rt9471 charger devices. + If enabled and the input is removed, the internal battery FET is turned + off to reduce the leakage from the BAT pin. See device datasheet for details. + It's commonly used when the product enter shipping stage. +Quoted 8 lines
Documentation/ABI/testing/sysfs-class-power-rt9471 line 14
Quoted 4 lines
Documentation/ABI/testing/sysfs-class-power-rt9471 new file +4
-0+ Access: Read, Write + Valid values: + - 1: enabled + - 0: disabledI still fail to see why this needs to be controllable at runtime. This looks like a hardware property. Are there any known products, which need this disabled?
It's just a switch, actually 'disabled' is not needed.
For the enabled case, mostly used in below scenarios
1. Online testing, USB IN -> Factory testing -> write 1 to enable -> USB out -> immediately VSYS off -> pack
2. Offline testing no vbus -> Factory testing -> write 1 to enable -> immediately VSYS off -> packThe 'disable" can use to cancel the shipping mode in case 1 before USB out. It's more like the testing.
Quoted 6 lines
Like as you said, shipping
BATFET_OFFis all the hardware behavior. To leave this mode after VSYS off, there're three ways
1. power key pressed
2. VBUS IN
3. controlBATFET_OFFto 0 (But it need SOC to be alive, at the time, VSYS off, no one can execute this I2C command)
If factory testing and preperation is the only use case, I don't think exposing this in sysfs and creating userspace ABI is worth it. Just tell factory to use i2c-dev and poke the correct registers.
Quoted 27 lines
If what you care is no need to mention 'disable', then just remove it. It's fine.
Quoted 13 lines
Quoted 13 lines
Documentation/ABI/testing/sysfs-class-power-rt9471 new file +12
-0+What: /sys/class/power_supply/rt9471-*/port_detect_enable +Date: Oct 2022 +KernelVersion: 6.1 +Contact: ChiYuan Huang <[email protected]> +Description: + This entry allows enabling the USB BC12 port detect function of rt9471 charger + devices. If enabled and VBUS is inserted, device will start to do the BC12 + port detect and report the usb port type when port detect is done. See + datasheet for details. Normally controlled when TypeC/USBPD port integrated. + + Access: Read, Write + Valid values:Quoted 8 lines
Documentation/ABI/testing/sysfs-class-power-rt9471 line 28
Quoted 2 lines
Documentation/ABI/testing/sysfs-class-power-rt9471 new file +2
-0+ - 1: enabled + - 0: disabledSo basically this depends on the hardware integration (e.g. it should be disabled when power source is a DC barrel jack instead of USB) and is not supposed to change at all during runtime? Then the information wether it needs to be enabled should be derived from the device tree.
It's a switching charger integrates OTG boost.
For the case 'DC Jack', there's no need to use this kind of product.
Quoted 6 lines
With typec integration, at most time, it still need bc12 to be enabled by default. Just in some case, like as power role swap (SNK -> SRC -> SNK), to automatically identify the USB port, this may interrupt USB communication.
So as my understanding, keep it enabled by default, just in some case, it my need to control at runtime.
This should be part of the description. You can drop the sentence "Normally controlled when TypeC/USBPD port integrated.", since that's hard to comprehend. Instead add the information that this is supposed to be always enabled, but can be disabled to avoid USB link loss (?) when doing a USB PD role swap.
-- Sebastian
Re: [PATCH v5 3/3] Documentation: power: rt9471: Document exported sysfs entries
Sebastian Reichel <[email protected]> 於 2022年10月2日 週日 凌晨4:58寫道:
Quoted 66 lines
Hi,
Quoted 55 lines · ChiYuan Huang
Sebastian Reichel <[email protected]> 於 2022年9月17日 週六 上午9:19寫道:
Quoted 36 lines · cy_huang
Quoted 35 lines
From: ChiYuan Huang <[email protected]>
Document the settings exported by rt9471 charger driver through sysfs entries:
-sysoff_enable
-port_detect_enableSigned-off-by ChiYuan Huang <[email protected]>---
Since v5:
- Recover all the change in sysfs-class-power.
- New a sysfs-class-power-rt9471 file.
- Remove 'charge_term_enable' sysfs entry, directly integrate it in 'charge_term_current' power supply property control.--- Documentation/ABI/testing/sysfs-class-power-rt9471 | 29 ++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 Documentation/ABI/testing/sysfs-class-power-rt9471Documentation/ABI/testing/sysfs-class-power-rt9471 new file +10
-0@@ -0,0 +1,29 @@ +What: /sys/class/power_supply/rt9471-*/sysoff_enable +Date: Oct 2022 +KernelVersion: 6.1 +Contact: ChiYuan Huang <[email protected]> +Description: + This entry allows enabling the sysoff mode of rt9471 charger devices. + If enabled and the input is removed, the internal battery FET is turned + off to reduce the leakage from the BAT pin. See device datasheet for details. + It's commonly used when the product enter shipping stage. +Quoted 8 lines
Documentation/ABI/testing/sysfs-class-power-rt9471 line 14
Quoted 4 lines
Documentation/ABI/testing/sysfs-class-power-rt9471 new file +4
-0+ Access: Read, Write + Valid values: + - 1: enabled + - 0: disabledI still fail to see why this needs to be controllable at runtime. This looks like a hardware property. Are there any known products, which need this disabled?
It's just a switch, actually 'disabled' is not needed.
For the enabled case, mostly used in below scenarios
1. Online testing, USB IN -> Factory testing -> write 1 to enable -> USB out -> immediately VSYS off -> pack
2. Offline testing no vbus -> Factory testing -> write 1 to enable -> immediately VSYS off -> packThe 'disable" can use to cancel the shipping mode in case 1 before USB out. It's more like the testing.
Quoted 6 lines
Like as you said, shipping
BATFET_OFFis all the hardware behavior. To leave this mode after VSYS off, there're three ways
1. power key pressed
2. VBUS IN
3. controlBATFET_OFFto 0 (But it need SOC to be alive, at the time, VSYS off, no one can execute this I2C command)
Quoted 4 lines
If factory testing and preperation is the only use case, I don't think exposing this in sysfs and creating userspace ABI is worth it. Just tell factory to use i2c-dev and poke the correct registers.
I agree your comment if there's only this case will use it.
So I ask our HW members about this.
They said there's still one case I didn't consider about. It's the dual charger scenario.
If the charging process is entering CV mode, the slave charger is no need to join the charging.
Then in common case, slave charger need to minimize the battery leakage. And the BATFET_OFF is needed to lower the battery leakage.
They think this sysfs entry is needed. Can this persuade you?
Quoted 31 lines
Quoted 31 lines
If what you care is no need to mention 'disable', then just remove it. It's fine.
Quoted 13 lines
Quoted 13 lines
Documentation/ABI/testing/sysfs-class-power-rt9471 new file +12
-0+What: /sys/class/power_supply/rt9471-*/port_detect_enable +Date: Oct 2022 +KernelVersion: 6.1 +Contact: ChiYuan Huang <[email protected]> +Description: + This entry allows enabling the USB BC12 port detect function of rt9471 charger + devices. If enabled and VBUS is inserted, device will start to do the BC12 + port detect and report the usb port type when port detect is done. See + datasheet for details. Normally controlled when TypeC/USBPD port integrated. + + Access: Read, Write + Valid values:Quoted 8 lines
Documentation/ABI/testing/sysfs-class-power-rt9471 line 28
Quoted 2 lines
Documentation/ABI/testing/sysfs-class-power-rt9471 new file +2
-0+ - 1: enabled + - 0: disabledSo basically this depends on the hardware integration (e.g. it should be disabled when power source is a DC barrel jack instead of USB) and is not supposed to change at all during runtime? Then the information wether it needs to be enabled should be derived from the device tree.
It's a switching charger integrates OTG boost.
For the case 'DC Jack', there's no need to use this kind of product.With typec integration, at most time, it still need bc12 to be enabled by default. Just in some case, like as power role swap (SNK -> SRC -> SNK), to automatically identify the USB port, this may interrupt USB communication.
Quoted 9 lines
Quoted 2 lines
So as my understanding, keep it enabled by default, just in some case, it my need to control at runtime.
This should be part of the description. You can drop the sentence "Normally controlled when TypeC/USBPD port integrated.", since that's hard to comprehend. Instead add the information that this is supposed to be always enabled, but can be disabled to avoid USB link loss (?) when doing a USB PD role swap.
Thanks for the comment.
I'll rewrite it as below
'It's supposed to be always enabled, but can be disabled to avoid usb link interruption especially when doing a USBPD 'power' role swap.'
Sorry, due to the long reply period, I already sent v6/v7/v8 to fix some coding like as missing header and irq wakeup check. Actually only missing header change is needed.
Please ignore these noise.
And after the sysfs reviewing is finished, you can just review the revision v9. Thanks.
Quoted 1 line
-- Sebastian
Re: [PATCH v5 3/3] Documentation: power: rt9471: Document exported sysfs entries
Hi,
ChiYuan Huang <[email protected]> 於 2022年10月3日 週一 上午10:00寫道:
Quoted 130 lines
Sebastian Reichel <[email protected]> 於 2022年10月2日 週日 凌晨4:58寫道:
Quoted 66 lines
Hi,
Quoted 55 lines · ChiYuan Huang
Sebastian Reichel <[email protected]> 於 2022年9月17日 週六 上午9:19寫道:
Quoted 36 lines · cy_huang
Quoted 35 lines
From: ChiYuan Huang <[email protected]>
Document the settings exported by rt9471 charger driver through sysfs entries:
-sysoff_enable
-port_detect_enableSigned-off-by ChiYuan Huang <[email protected]>---
Since v5:
- Recover all the change in sysfs-class-power.
- New a sysfs-class-power-rt9471 file.
- Remove 'charge_term_enable' sysfs entry, directly integrate it in 'charge_term_current' power supply property control.--- Documentation/ABI/testing/sysfs-class-power-rt9471 | 29 ++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 Documentation/ABI/testing/sysfs-class-power-rt9471Documentation/ABI/testing/sysfs-class-power-rt9471 new file +10
-0@@ -0,0 +1,29 @@ +What: /sys/class/power_supply/rt9471-*/sysoff_enable +Date: Oct 2022 +KernelVersion: 6.1 +Contact: ChiYuan Huang <[email protected]> +Description: + This entry allows enabling the sysoff mode of rt9471 charger devices. + If enabled and the input is removed, the internal battery FET is turned + off to reduce the leakage from the BAT pin. See device datasheet for details. + It's commonly used when the product enter shipping stage. +Quoted 8 lines
Documentation/ABI/testing/sysfs-class-power-rt9471 line 14
Quoted 4 lines
Documentation/ABI/testing/sysfs-class-power-rt9471 new file +4
-0+ Access: Read, Write + Valid values: + - 1: enabled + - 0: disabledI still fail to see why this needs to be controllable at runtime. This looks like a hardware property. Are there any known products, which need this disabled?
It's just a switch, actually 'disabled' is not needed.
For the enabled case, mostly used in below scenarios
1. Online testing, USB IN -> Factory testing -> write 1 to enable -> USB out -> immediately VSYS off -> pack
2. Offline testing no vbus -> Factory testing -> write 1 to enable -> immediately VSYS off -> packThe 'disable" can use to cancel the shipping mode in case 1 before USB out. It's more like the testing.
Quoted 6 lines
Like as you said, shipping
BATFET_OFFis all the hardware behavior. To leave this mode after VSYS off, there're three ways
1. power key pressed
2. VBUS IN
3. controlBATFET_OFFto 0 (But it need SOC to be alive, at the time, VSYS off, no one can execute this I2C command)Quoted 4 lines
If factory testing and preperation is the only use case, I don't think exposing this in sysfs and creating userspace ABI is worth it. Just tell factory to use i2c-dev and poke the correct registers.
I agree your comment if there's only this case will use it.
So I ask our HW members about this.
They said there's still one case I didn't consider about. It's the dual charger scenario.
If the charging process is entering CV mode, the slave charger is no need to join the charging.
Then in common case, slave charger need to minimize the battery leakage. And theBATFET_OFFis needed to lower the battery leakage.They think this sysfs entry is needed. Can this persuade you?
Quoted 31 lines
Quoted 31 lines
If what you care is no need to mention 'disable', then just remove it. It's fine.
Quoted 13 lines
Quoted 13 lines
Documentation/ABI/testing/sysfs-class-power-rt9471 new file +12
-0+What: /sys/class/power_supply/rt9471-*/port_detect_enable +Date: Oct 2022 +KernelVersion: 6.1 +Contact: ChiYuan Huang <[email protected]> +Description: + This entry allows enabling the USB BC12 port detect function of rt9471 charger + devices. If enabled and VBUS is inserted, device will start to do the BC12 + port detect and report the usb port type when port detect is done. See + datasheet for details. Normally controlled when TypeC/USBPD port integrated. + + Access: Read, Write + Valid values:Quoted 8 lines
Documentation/ABI/testing/sysfs-class-power-rt9471 line 28
Quoted 2 lines
Documentation/ABI/testing/sysfs-class-power-rt9471 new file +2
-0+ - 1: enabled + - 0: disabledSo basically this depends on the hardware integration (e.g. it should be disabled when power source is a DC barrel jack instead of USB) and is not supposed to change at all during runtime? Then the information wether it needs to be enabled should be derived from the device tree.
It's a switching charger integrates OTG boost.
For the case 'DC Jack', there's no need to use this kind of product.With typec integration, at most time, it still need bc12 to be enabled by default. Just in some case, like as power role swap (SNK -> SRC -> SNK), to automatically identify the USB port, this may interrupt USB communication.
Quoted 9 lines
Quoted 2 lines
So as my understanding, keep it enabled by default, just in some case, it my need to control at runtime.
This should be part of the description. You can drop the sentence "Normally controlled when TypeC/USBPD port integrated.", since that's hard to comprehend. Instead add the information that this is supposed to be always enabled, but can be disabled to avoid USB link loss (?) when doing a USB PD role swap.
Thanks for the comment.
I'll rewrite it as below
'It's supposed to be always enabled, but can be disabled to avoid usb link interruption especially when doing a USBPD 'power' role swap.'
Quoted 6 lines
Sorry, due to the long reply period, I already sent v6/v7/v8 to fix some coding like as missing header and irq wakeup check. Actually only missing header change is needed.
Please ignore these noise.And after the sysfs reviewing is finished, you can just review the revision v9.
I'm preparing the final patch.
2 more weeks past, now only one question is left for rt9471 ABI document. After my explanation, is 'to keep sysoff_enable" acceptible? Or no more discussion, just delete it?
Quoted 2 lines
Thanks.
Quoted 1 line
-- Sebastian