Add Richtek RT9471 3A battery charger support
Subsystems (2)
v4 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 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 | 44 + .../bindings/power/supply/richtek,rt9471.yaml | 73 ++ drivers/power/supply/Kconfig | 16 + drivers/power/supply/Makefile | 1 + drivers/power/supply/rt9471.c | 952 +++++++++++++++++++++ drivers/power/supply/rt9471.h | 76 ++ 6 files changed, 1162 insertions(+) create mode 100644 Documentation/devicetree/bindings/power/supply/richtek,rt9471.yaml create mode 100644 drivers/power/supply/rt9471.c create mode 100644 drivers/power/supply/rt9471.h
Signature · 1 line
2.7.4
PATCH v4 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
PATCH v4 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 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 | 952 ++++++++++++++++++++++++++++++++++++++++++ drivers/power/supply/rt9471.h | 76 ++++ 4 files changed, 1045 insertions(+) create mode 100644 drivers/power/supply/rt9471.c create mode 100644 drivers/power/supply/rt9471.h
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 +952 -0
952 lines not on this page · raw message
drivers/power/supply/rt9471.h new file +76 -0
76 lines not on this page · raw message
Signature · 1 line
2.7.4
Re: [PATCH v4 2/3] power: supply: rt9471: Add Richtek RT9471 charger driver
Hi,
Quoted 14 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]>---
Since v4:
- Remove the line for the owner field in driver.
Quoted 5 lines
Since v2:
- Fix checkpatch error about 'foo * bar' to 'foo *bar' inpsy_device_to_chipfunction.
- Specify the member name directly for the use of linear range.---
Thanks, driver looks mostly good.
Quoted 80 lines
drivers/power/supply/Kconfig | 16 + drivers/power/supply/Makefile | 1 + drivers/power/supply/rt9471.c | 952 ++++++++++++++++++++++++++++++++++++++++++ drivers/power/supply/rt9471.h | 76 ++++ 4 files changed, 1045 insertions(+) create mode 100644 drivers/power/supply/rt9471.c create mode 100644 drivers/power/supply/rt9471.h[...]
drivers/power/supply/rt9471.c new file +71
-0+static inline int rt9471_set_hiz (struct rt9471_chip *chip,int enable) +{ +return regmap_field_write (chip->rm_fields[F_HZ ], enable); +} + +static inline int rt9471_set_ichg (struct rt9471_chip *chip,int microamp) +{ +return rt9471_set_value_by_field_range (chip,F_ICHG_REG , +RT9471_RANGE_ICHG , microamp); +} + +static inline int rt9471_get_ichg (struct rt9471_chip *chip,int *microamp) +{ +return rt9471_get_value_by_field_range (chip,F_ICHG_REG , +RT9471_RANGE_ICHG , microamp); +} + +static inline int rt9471_set_cv (struct rt9471_chip *chip,int microvolt) +{ +return rt9471_set_value_by_field_range (chip,F_VBAT_REG , +RT9471_RANGE_VCHG , microvolt); +} + +static inline int rt9471_get_cv (struct rt9471_chip *chip,int *microamp) +{ +return rt9471_get_value_by_field_range (chip,F_VBAT_REG , +RT9471_RANGE_VCHG , microamp); +} + +static inline int rt9471_set_mivr (struct rt9471_chip *chip,int microvolt) +{ +return rt9471_set_value_by_field_range (chip,F_MIVR , +RT9471_RANGE_MIVR , microvolt); +} + +static inline int rt9471_get_mivr (struct rt9471_chip *chip,int *microvolt) +{ +return rt9471_get_value_by_field_range (chip,F_MIVR , +RT9471_RANGE_MIVR , microvolt); +} + +static inline int rt9471_set_aicr (struct rt9471_chip *chip,int microamp) +{ +return rt9471_set_value_by_field_range (chip,F_AICR ,RT9471_RANGE_AICR , + microamp); +} + +static inline int rt9471_get_aicr (struct rt9471_chip *chip,int *microamp) +{ +return rt9471_get_value_by_field_range (chip,F_AICR ,RT9471_RANGE_AICR , + microamp); +} + +static inline int rt9471_set_iprechg (struct rt9471_chip *chip,int microamp) +{ +return rt9471_set_value_by_field_range (chip,F_IPRE_CHG , +RT9471_RANGE_IPRE , microamp); +} + +static inline int rt9471_get_iprechg (struct rt9471_chip *chip,int *microamp) +{ +return rt9471_get_value_by_field_range (chip,F_IPRE_CHG , +RT9471_RANGE_IPRE , microamp); +} + +static inline int rt9471_set_ieoc (struct rt9471_chip *chip,int microamp) +{ +return rt9471_set_value_by_field_range (chip,F_IEOC_CHG , +RT9471_RANGE_IEOC , microamp); +} +
drivers/power/supply/rt9471.c line 236
Quoted 10 lines
drivers/power/supply/rt9471.c new file +10
-0+static inline int rt9471_get_ieoc (struct rt9471_chip *chip,int *microamp) +{ +return rt9471_get_value_by_field_range (chip,F_IEOC_CHG , +RT9471_RANGE_IEOC , microamp); +} + +static inline int rt9471_set_chg_enable (struct rt9471_chip *chip,int enable) +{ +return regmap_field_write (chip->rm_fields[F_CHG_EN ], !!enable); +}
Please drop these one line wrappers.
Quoted 73 lines
[...]
drivers/power/supply/rt9471.h new file +66
-0@@ -0,0 +1,76 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* Copyright (C) 2022 Richtek Technology Corp. */ + +#ifndef __RT9471_CHARGER_H +#define __RT9471_CHARGER_H + +#define RT9471_IRQ_BC12_DONE 0 +#define RT9471_IRQ_DETACH 1 +#define RT9471_IRQ_RECHG 2 +#define RT9471_IRQ_CHG_DONE 3 +#define RT9471_IRQ_BG_CHG 4 +#define RT9471_IRQ_IE0C 5 +#define RT9471_IRQ_CHG_RDY 6 +#define RT9471_IRQ_VBUS_GD 7 +#define RT9471_IRQ_CHG_BATOV 9 +#define RT9471_IRQ_CHG_SYSOV 10 +#define RT9471_IRQ_CHG_TOUT 11 +#define RT9471_IRQ_CHG_BUSUV 12 +#define RT9471_IRQ_CHG_THREG 13 +#define RT9471_IRQ_CHG_AICR 14 +#define RT9471_IRQ_CHG_MIVR 15 +#define RT9471_IRQ_SYS_SHORT 16 +#define RT9471_IRQ_SYS_MIN 17 +#define RT9471_IRQ_AICC_DONE 18 +#define RT9471_IRQ_PE_DONE 19 +#define RT9471_IRQ_JEITA_COLD 20 +#define RT9471_IRQ_JEITA_COOL 21 +#define RT9471_IRQ_JEITA_WARM 22 +#define RT9471_IRQ_JEITA_HOT 23 +#define RT9471_IRQ_OTG_FAULT 24 +#define RT9471_IRQ_OTG_LBP 25 +#define RT9471_IRQ_OTG_CC 26 +#define RT9471_IRQ_WDT 29 +#define RT9471_IRQ_VAC_OV 30 +#define RT9471_IRQ_OTP 31 + +#define RT9471_REG_OTGCFG 0x00 +#define RT9471_REG_TOP 0x01 +#define RT9471_REG_FUNC 0x02 +#define RT9471_REG_IBUS 0x03 +#define RT9471_REG_VBUS 0x04 +#define RT9471_REG_PRECHG 0x05 +#define RT9471_REG_VCHG 0x07 +#define RT9471_REG_ICHG 0x08 +#define RT9471_REG_CHGTMR 0x09 +#define RT9471_REG_EOC 0x0A +#define RT9471_REG_INFO 0x0B +#define RT9471_REG_JEITA 0x0C +#define RT9471_REG_PUMP_EXP 0x0D +#define RT9471_REG_DPDMDET 0x0E +#define RT9471_REG_ICSTAT 0x0F +#define RT9471_REG_STAT0 0x10 +#define RT9471_REG_STAT1 0x11 +#define RT9471_REG_STAT2 0x12 +#define RT9471_REG_IRQ0 0x20 +#define RT9471_REG_MASK0 0x30 + +#define RT9471_OTGCV_MASK GENMASK(7, 6) +#define RT9471_OTGCC_MASK BIT(0) +#define RT9471_OTGEN_MASK BIT(1) +#define RT9471_CHGFAULT_MASK GENMASK(4, 1) + +/* Device ID */ +#define RT9470_DEVID 0x09 +#define RT9470D_DEVID 0x0A +#define RT9471_DEVID 0x0D
drivers/power/supply/rt9471.h line 76
Quoted 10 lines
drivers/power/supply/rt9471.h new file +10
-0+#define RT9471D_DEVID 0x0E + +#define RT9471_NUM_IRQ_REGS 4 +#define RT9471_OTGCV_MINUV 4850000 +#define RT9471_OTGCV_STEPUV 150000 +#define RT9471_NUM_VOTG 4 +#define RT9471_VCHG_MAXUV 4700000 +#define RT9471_ICHG_MAXUA 3150000 + +#endif /* __RT9471_CHARGER_H */
Please merge this into rt9471.c
Quoted 3 lines
Signature · 1 line
2.7.4
Re: [PATCH v4 2/3] power: supply: rt9471: Add Richtek RT9471 charger driver
Sebastian Reichel <[email protected]> 於 2022年9月12日 週一 晚上7:26寫道:
Quoted 110 lines
Hi,
Quoted 14 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]>---
Since v4:
- Remove the line for the owner field in driver.Quoted 5 lines
Since v2:
- Fix checkpatch error about 'foo * bar' to 'foo *bar' inpsy_device_to_chipfunction.
- Specify the member name directly for the use of linear range.---
Thanks, driver looks mostly good.
Quoted 84 lines
drivers/power/supply/Kconfig | 16 + drivers/power/supply/Makefile | 1 + drivers/power/supply/rt9471.c | 952 ++++++++++++++++++++++++++++++++++++++++++ drivers/power/supply/rt9471.h | 76 ++++ 4 files changed, 1045 insertions(+) create mode 100644 drivers/power/supply/rt9471.c create mode 100644 drivers/power/supply/rt9471.h[...]
drivers/power/supply/rt9471.c new file +75
-0+static inline int rt9471_set_hiz (struct rt9471_chip *chip,int enable) +{ +return regmap_field_write (chip->rm_fields[F_HZ ], enable); +} + +static inline int rt9471_set_ichg (struct rt9471_chip *chip,int microamp) +{ +return rt9471_set_value_by_field_range (chip,F_ICHG_REG , +RT9471_RANGE_ICHG , microamp); +} + +static inline int rt9471_get_ichg (struct rt9471_chip *chip,int *microamp) +{ +return rt9471_get_value_by_field_range (chip,F_ICHG_REG , +RT9471_RANGE_ICHG , microamp); +} + +static inline int rt9471_set_cv (struct rt9471_chip *chip,int microvolt) +{ +return rt9471_set_value_by_field_range (chip,F_VBAT_REG , +RT9471_RANGE_VCHG , microvolt); +} + +static inline int rt9471_get_cv (struct rt9471_chip *chip,int *microamp) +{ +return rt9471_get_value_by_field_range (chip,F_VBAT_REG , +RT9471_RANGE_VCHG , microamp); +} + +static inline int rt9471_set_mivr (struct rt9471_chip *chip,int microvolt) +{ +return rt9471_set_value_by_field_range (chip,F_MIVR , +RT9471_RANGE_MIVR , microvolt); +} + +static inline int rt9471_get_mivr (struct rt9471_chip *chip,int *microvolt) +{ +return rt9471_get_value_by_field_range (chip,F_MIVR , +RT9471_RANGE_MIVR , microvolt); +} + +static inline int rt9471_set_aicr (struct rt9471_chip *chip,int microamp) +{ +return rt9471_set_value_by_field_range (chip,F_AICR ,RT9471_RANGE_AICR , + microamp); +} + +static inline int rt9471_get_aicr (struct rt9471_chip *chip,int *microamp) +{ +return rt9471_get_value_by_field_range (chip,F_AICR ,RT9471_RANGE_AICR , + microamp); +} + +static inline int rt9471_set_iprechg (struct rt9471_chip *chip,int microamp) +{ +return rt9471_set_value_by_field_range (chip,F_IPRE_CHG , +RT9471_RANGE_IPRE , microamp); +} + +static inline int rt9471_get_iprechg (struct rt9471_chip *chip,int *microamp) +{ +return rt9471_get_value_by_field_range (chip,F_IPRE_CHG , +RT9471_RANGE_IPRE , microamp); +} + +static inline int rt9471_set_ieoc (struct rt9471_chip *chip,int microamp) +{ +return rt9471_set_value_by_field_range (chip,F_IEOC_CHG , +RT9471_RANGE_IEOC , microamp); +} + +static inline int rt9471_get_ieoc (struct rt9471_chip *chip,int *microamp) +{ +return rt9471_get_value_by_field_range (chip,F_IEOC_CHG , +RT9471_RANGE_IEOC , microamp);
Quoted 8 lines
drivers/power/supply/rt9471.c line 236
Quoted 6 lines
drivers/power/supply/rt9471.c new file +6
-0+} + +static inline int rt9471_set_chg_enable (struct rt9471_chip *chip,int enable) +{ +return regmap_field_write (chip->rm_fields[F_CHG_EN ], !!enable); +}Please drop these one line wrappers.
Will only keep set_ieoc/get_ieoc function, remove 'inline' declaration, and integrate CHG_TE switch state.
Quoted 90 lines
Quoted 74 lines
[...]
drivers/power/supply/rt9471.h new file +66
-0@@ -0,0 +1,76 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* Copyright (C) 2022 Richtek Technology Corp. */ + +#ifndef __RT9471_CHARGER_H +#define __RT9471_CHARGER_H + +#define RT9471_IRQ_BC12_DONE 0 +#define RT9471_IRQ_DETACH 1 +#define RT9471_IRQ_RECHG 2 +#define RT9471_IRQ_CHG_DONE 3 +#define RT9471_IRQ_BG_CHG 4 +#define RT9471_IRQ_IE0C 5 +#define RT9471_IRQ_CHG_RDY 6 +#define RT9471_IRQ_VBUS_GD 7 +#define RT9471_IRQ_CHG_BATOV 9 +#define RT9471_IRQ_CHG_SYSOV 10 +#define RT9471_IRQ_CHG_TOUT 11 +#define RT9471_IRQ_CHG_BUSUV 12 +#define RT9471_IRQ_CHG_THREG 13 +#define RT9471_IRQ_CHG_AICR 14 +#define RT9471_IRQ_CHG_MIVR 15 +#define RT9471_IRQ_SYS_SHORT 16 +#define RT9471_IRQ_SYS_MIN 17 +#define RT9471_IRQ_AICC_DONE 18 +#define RT9471_IRQ_PE_DONE 19 +#define RT9471_IRQ_JEITA_COLD 20 +#define RT9471_IRQ_JEITA_COOL 21 +#define RT9471_IRQ_JEITA_WARM 22 +#define RT9471_IRQ_JEITA_HOT 23 +#define RT9471_IRQ_OTG_FAULT 24 +#define RT9471_IRQ_OTG_LBP 25 +#define RT9471_IRQ_OTG_CC 26 +#define RT9471_IRQ_WDT 29 +#define RT9471_IRQ_VAC_OV 30 +#define RT9471_IRQ_OTP 31 + +#define RT9471_REG_OTGCFG 0x00 +#define RT9471_REG_TOP 0x01 +#define RT9471_REG_FUNC 0x02 +#define RT9471_REG_IBUS 0x03 +#define RT9471_REG_VBUS 0x04 +#define RT9471_REG_PRECHG 0x05 +#define RT9471_REG_VCHG 0x07 +#define RT9471_REG_ICHG 0x08 +#define RT9471_REG_CHGTMR 0x09 +#define RT9471_REG_EOC 0x0A +#define RT9471_REG_INFO 0x0B +#define RT9471_REG_JEITA 0x0C +#define RT9471_REG_PUMP_EXP 0x0D +#define RT9471_REG_DPDMDET 0x0E +#define RT9471_REG_ICSTAT 0x0F +#define RT9471_REG_STAT0 0x10 +#define RT9471_REG_STAT1 0x11 +#define RT9471_REG_STAT2 0x12 +#define RT9471_REG_IRQ0 0x20 +#define RT9471_REG_MASK0 0x30 + +#define RT9471_OTGCV_MASK GENMASK(7, 6) +#define RT9471_OTGCC_MASK BIT(0) +#define RT9471_OTGEN_MASK BIT(1) +#define RT9471_CHGFAULT_MASK GENMASK(4, 1) + +/* Device ID */ +#define RT9470_DEVID 0x09 +#define RT9470D_DEVID 0x0A +#define RT9471_DEVID 0x0Ddrivers/power/supply/rt9471.h line 76
Quoted 10 lines
drivers/power/supply/rt9471.h new file +10
-0+#define RT9471D_DEVID 0x0E + +#define RT9471_NUM_IRQ_REGS 4 +#define RT9471_OTGCV_MINUV 4850000 +#define RT9471_OTGCV_STEPUV 150000 +#define RT9471_NUM_VOTG 4 +#define RT9471_VCHG_MAXUV 4700000 +#define RT9471_ICHG_MAXUA 3150000 + +#endif /* __RT9471_CHARGER_H */ Please merge this into
rt9471.cQuoted 3 lines
--
2.7.4
PATCH v4 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
- charge_term_enable
- port_detect_enable
--- Documentation/ABI/testing/sysfs-class-power | 44 +++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+)
Documentation/ABI/testing/sysfs-class-power +44 -0
@@ -768,3 +768,47 @@ Description: Access: Read Valid values: 1-31 + +What: /sys/class/power_supply/rt9471-*/sysoff_enable +Date: Sep 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. + + Access: Read, Write + Valid values: + - 1: enabled + - 0: disabled + +What: /sys/class/power_supply/rt9471-*/charge_term_enable +Date: Sep 2022 +KernelVersion: 6.1 +Contact: ChiYuan Huang <[email protected]> +Description: + This entry allows enabling the charge termination function of rt9471 charger + devices. If enabled, the battery charging current, and the battery voltage + reachs charge termination condition, the internal battery FET will be turned off + to optimize the battery life. See device datasheet for details. + + Access: Read, Write + Valid values: + - 1: enabled + - 0: disabled + +What: /sys/class/power_supply/rt9471-*/port_detect_enable +Date: Sep 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. + + Access: Read, Write + Valid values: + - 1: enabled + - 0: disabled
Signature · 1 line
2.7.4
Re: [PATCH v4 3/3] Documentation: power: rt9471: Document exported sysfs entries
Hi,
Quoted 24 lines · cy_huang
From: ChiYuan Huang <[email protected]>
Document the settings exported by rt9471 charger driver through sysfs entries:
-sysoff_enable
-charge_term_enable
-port_detect_enableSigned-off-by ChiYuan Huang <[email protected]>--- Documentation/ABI/testing/sysfs-class-power | 44 +++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+)Documentation/ABI/testing/sysfs-class-power +4
-0@@ -768,3 +768,47 @@ Description: Access: Read Valid values: 1-31 + +What: /sys/class/power_supply/rt9471-*/sysoff_enable +Date: Sep 2022 +KernelVersion: 6.1
Documentation/ABI/testing/sysfs-class-power Description: · line 784
Quoted 10 lines
Documentation/ABI/testing/sysfs-class-power +10
-0+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. + + Access: Read, Write + Valid values: + - 1: enabled + - 0: disabled
This is not a very good description of what the control does. When do you expect users to control this?
Quoted 4 lines
Documentation/ABI/testing/sysfs-class-power +4
-0+What: /sys/class/power_supply/rt9471-*/charge_term_enable +Date: Sep 2022 +KernelVersion: 6.1 +Contact: ChiYuan Huang <[email protected]>
Documentation/ABI/testing/sysfs-class-power Description: · line 799
Quoted 10 lines
Documentation/ABI/testing/sysfs-class-power +10
-0+Description: + This entry allows enabling the charge termination function of rt9471 charger + devices. If enabled, the battery charging current, and the battery voltage + reachs charge termination condition, the internal battery FET will be turned off + to optimize the battery life. See device datasheet for details. + + Access: Read, Write + Valid values: + - 1: enabled + - 0: disabled
Just write 0 to .../charge_term_current to disable it. No need for a custom property.
Quoted 4 lines
Documentation/ABI/testing/sysfs-class-power +4
-0+What: /sys/class/power_supply/rt9471-*/port_detect_enable +Date: Sep 2022 +KernelVersion: 6.1 +Contact: ChiYuan Huang <[email protected]>
Documentation/ABI/testing/sysfs-class-power Description: · line 814
Quoted 10 lines
Documentation/ABI/testing/sysfs-class-power +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. + + Access: Read, Write + Valid values: + - 1: enabled + - 0: disabled
Why would one want to disable this?
Can't the driver just enable it unconditionally?
-- Sebastian
Re: [PATCH v4 3/3] Documentation: power: rt9471: Document exported sysfs entries
Hi,
Quoted 8 lines · Sebastian Reichel
Quoted 7 lines · cy_huang
From: ChiYuan Huang <[email protected]>
Document the settings exported by rt9471 charger driver through sysfs entries:
-sysoff_enable
-charge_term_enable
-port_detect_enable
Quoted 4 lines
Quoted 4 lines
Signed-off-by ChiYuan Huang <[email protected]>--- Documentation/ABI/testing/sysfs-class-power | 44 +++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+)
I forgot to mention: custom driver properties are described in their own files, see Documentation/ABI/testing/sysfs-class-power-*. But are to be avoided if possible. So first of all I want to make sure you actually need any of these.
-- Sebastian
Quoted 64 lines
Quoted 13 lines
Documentation/ABI/testing/sysfs-class-power +4
-0@@ -768,3 +768,47 @@ Description: Access: Read Valid values: 1-31 + +What: /sys/class/power_supply/rt9471-*/sysoff_enable +Date: Sep 2022 +KernelVersion: 6.1Documentation/ABI/testing/sysfs-class-power Description: · line 784
Quoted 10 lines
Documentation/ABI/testing/sysfs-class-power +10
-0+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. + + Access: Read, Write + Valid values: + - 1: enabled + - 0: disabledThis is not a very good description of what the control does. When do you expect users to control this?
Quoted 4 lines
Documentation/ABI/testing/sysfs-class-power +4
-0+What: /sys/class/power_supply/rt9471-*/charge_term_enable +Date: Sep 2022 +KernelVersion: 6.1 +Contact: ChiYuan Huang <[email protected]>Documentation/ABI/testing/sysfs-class-power Description: · line 799
Quoted 10 lines
Documentation/ABI/testing/sysfs-class-power +10
-0+Description: + This entry allows enabling the charge termination function of rt9471 charger + devices. If enabled, the battery charging current, and the battery voltage + reachs charge termination condition, the internal battery FET will be turned off + to optimize the battery life. See device datasheet for details. + + Access: Read, Write + Valid values: + - 1: enabled + - 0: disabledJust write 0 to .../charge_term_current to disable it. No need for a custom property.
Quoted 4 lines
Documentation/ABI/testing/sysfs-class-power +4
-0+What: /sys/class/power_supply/rt9471-*/port_detect_enable +Date: Sep 2022 +KernelVersion: 6.1 +Contact: ChiYuan Huang <[email protected]>Documentation/ABI/testing/sysfs-class-power Description: · line 814
Quoted 10 lines
Documentation/ABI/testing/sysfs-class-power +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. + + Access: Read, Write + Valid values: + - 1: enabled + - 0: disabledWhy would one want to disable this?
Can't the driver just enable it unconditionally?-- Sebastian
Re: [PATCH v4 3/3] Documentation: power: rt9471: Document exported sysfs entries
Sebastian Reichel <[email protected]> 於 2022年9月12日 週一 晚上7:29寫道:
Quoted 17 lines
Hi,
Quoted 8 lines · Sebastian Reichel
Quoted 7 lines · cy_huang
From: ChiYuan Huang <[email protected]>
Document the settings exported by rt9471 charger driver through sysfs entries:
-sysoff_enable
-charge_term_enable
-port_detect_enableQuoted 4 lines
Quoted 4 lines
Signed-off-by ChiYuan Huang <[email protected]>--- Documentation/ABI/testing/sysfs-class-power | 44 +++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+)
Quoted 5 lines
I forgot to mention: custom driver properties are described in their own files, see
Documentation/ABI/testing/sysfs-class-power-*. But are to be avoided if possible. So first of all I want to make sure you actually need any of these.
OK, it means I need to new a file sysfs-class-power-rt9471.
Quoted 28 lines
-- Sebastian
Quoted 26 lines
Quoted 13 lines
Documentation/ABI/testing/sysfs-class-power +4
-0@@ -768,3 +768,47 @@ Description: Access: Read Valid values: 1-31 + +What: /sys/class/power_supply/rt9471-*/sysoff_enable +Date: Sep 2022 +KernelVersion: 6.1Documentation/ABI/testing/sysfs-class-power Description: · line 784
Quoted 10 lines
Documentation/ABI/testing/sysfs-class-power +10
-0+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. + + Access: Read, Write + Valid values: + - 1: enabled + - 0: disabledThis is not a very good description of what the control does. When do you expect users to control this?
When products leaves the factory and enter shipping stage.
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Documentation/ABI/testing/sysfs-class-power +9
-0+What: /sys/class/power_supply/rt9471-*/charge_term_enable +Date: Sep 2022 +KernelVersion: 6.1 +Contact: ChiYuan Huang <[email protected]> +Description: + This entry allows enabling the charge termination function of rt9471 charger + devices. If enabled, the battery charging current, and the battery voltage + reachs charge termination condition, the internal battery FET will be turned off + to optimize the battery life. See device datasheet for details.
Quoted 8 lines
Quoted 8 lines
Documentation/ABI/testing/sysfs-class-power Description: · line 784
Quoted 5 lines
Documentation/ABI/testing/sysfs-class-power +5
-0+ + Access: Read, Write + Valid values: + - 1: enabled + - 0: disabledJust write 0 to .../charge_term_current to disable it. No need for a custom property.
OK, I will merge this 'TE' switch directly into 'charge_term_current' property.
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Documentation/ABI/testing/sysfs-class-power +9
-0+What: /sys/class/power_supply/rt9471-*/port_detect_enable +Date: Sep 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.
Quoted 8 lines
Quoted 8 lines
Documentation/ABI/testing/sysfs-class-power Description: · line 784
Quoted 5 lines
Documentation/ABI/testing/sysfs-class-power +5
-0+ + Access: Read, Write + Valid values: + - 1: enabled + - 0: disabledWhy would one want to disable this?
Can't the driver just enable it unconditionally?
The current product may use the typec port.
This make the user can control bc12 port detection switch. If bc12 port detect always on, for some cases like as power role swap or hard reset, it will cause bc12 port detect be retriggered. USB communication will be affected.
Quoted 4 lines
Quoted 2 lines
-- Sebastian