Add Richtek RT9756 Smart-Cap divider charger
Subsystems (2)
v3 cover Add Richtek RT9756 Smart-Cap divider charger
From: ChiYuan Huang <[email protected]>
This patch series adds support for RT9756 charger.
V3
- Instead using customized attribute to report battery voltage and current, create a battery psy to report it
RESEND V2
- Add 'Reviewed-by' tag in dt-binding patch
V2
- Add reference to 'power-supply.yaml'
- Remove 'wakeup-source' from required property list
- Use 'unevaluatedProperties' to replace 'additionalProperties'
ChiYuan Huang (3):
dt-bindings: power: supply: Add Richtek RT9756 smart cap divider
charger
power: supply: rt9756: Add Richtek RT9756 smart cap divider charger
Documentation: power: rt9756: Document exported sysfs entries
.../ABI/testing/sysfs-class-power-rt9756 | 30 + .../bindings/power/supply/richtek,rt9756.yaml | 72 ++ drivers/power/supply/Kconfig | 15 + drivers/power/supply/Makefile | 1 + drivers/power/supply/rt9756.c | 955 ++++++++++++++++++ 5 files changed, 1073 insertions(+) create mode 100644 Documentation/ABI/testing/sysfs-class-power-rt9756 create mode 100644 Documentation/devicetree/bindings/power/supply/richtek,rt9756.yaml create mode 100644 drivers/power/supply/rt9756.c
Signature · 1 line
2.34.1
PATCH v3 1/3 dt-bindings: power: supply: Add Richtek RT9756 smart cap divider charger
From: ChiYuan Huang <[email protected]>
Add the document for Richtek RT9756 smart cap divider charger.
---
V2
- Add reference to 'power-supply.yaml'
- Remove 'wakeup-source' from required property list
- Use 'unevaluatedProperties' to replace 'additionalProperties'
--- .../bindings/power/supply/richtek,rt9756.yaml | 72 +++++++++++++++++++ 1 file changed, 72 insertions(+) create mode 100644 Documentation/devicetree/bindings/power/supply/richtek,rt9756.yaml
Documentation/devicetree/bindings/power/supply/richtek,rt9756.yaml new file +72 -0
@@ -0,0 +1,72 @@ +# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/power/supply/richtek,rt9756.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Richtek RT9756 Smart Cap Divider Charger + +maintainers: + - ChiYuan Huang <[email protected]> + +description: | + The RT9756/RT9757 is a high efficiency and high charge current charger. + + The efficiency is up to 98.2% when VBAT = 4V, IBAT = 2A in DIV2 mode and 99.1% + when VBAT=4V, IBAT=1A in bypass mode. The maximum charger current is up to 8A + in DIV2 mode and 5A in bypass mode. The device integrates smart cap divider + topology, direct charging mode, external over-voltage protection control, an + input reverse blocking NFET and 2-way regulation, a dual phase charge pump + core, 8-Channel high speed ADCs and USB BC 1.2 detection. + + RT9770 is almost the same with RT9756/57, only BC 1.2 detection function is + removed to shrink the die size. + +allOf: + - $ref: power-supply.yaml# + +properties: + compatible: + oneOf: + - enum: + - richtek,rt9756 + - richtek,rt9770 + - items: + - enum: + - richtek,rt9757 + - const: richtek,rt9756 + + reg: + maxItems: 1 + + wakeup-source: true + + interrupts: + maxItems: 1 + + shunt-resistor-micro-ohms: + description: Battery current sense resistor mounted. + default: 2000 + +required: + - compatible + - reg + - interrupts + +unevaluatedProperties: false + +examples: + - | + #include <dt-bindings/interrupt-controller/irq.h> + i2c { + #address-cells = <1>; + #size-cells = <0>; + + charger@6f { + compatible = "richtek,rt9756"; + reg = <0x6f>; + wakeup-source; + interrupts-extended = <&gpio_intc 32 IRQ_TYPE_EDGE_FALLING>; + shunt-resistor-micro-ohms = <5000>; + }; + };
Signature · 1 line
2.34.1
PATCH v3 2/3 power: supply: rt9756: Add Richtek RT9756 smart cap divider charger
In reply to [email protected]From: ChiYuan Huang <[email protected]>
Add support for RT9756 smart cap divider charger.
The RT9759 is a high efficiency and high charge current charger. The maximum charge current is up to 8A. It integrates a dual-phase charge pump core with ADC monitoring.
---
V3
- Remove customized attribute for battery voltage and current
- Add a battery power supply to report battery voltage andr current
--- drivers/power/supply/Kconfig | 15 + drivers/power/supply/Makefile | 1 + drivers/power/supply/rt9756.c | 955 ++++++++++++++++++++++++++++++++++ 3 files changed, 971 insertions(+) create mode 100644 drivers/power/supply/rt9756.c
drivers/power/supply/Kconfig +15 -0
@@ -931,6 +931,21 @@ config CHARGER_RT9471 This driver can also be built as a module. If so, the module will be called rt9471. +config CHARGER_RT9756 + tristate "Richtek RT9756 smart cap divider charger driver" + depends on I2C + select REGMAP_I2C + select LINEAR_RANGES + help + This adds support for Richtek RT9756 smart cap divider charger driver. + It's a high efficiency and high charge current charger. the device + integrates smart cap divider topology with 9-channel high speed + ADCs that can provide input and output voltage, current and + temperature monitoring. + + This driver can also be built as a module. If so, the module will be + called rt9756. + config CHARGER_CROS_USBPD tristate "ChromeOS EC based USBPD charger" depends on CROS_USBPD_NOTIFY
drivers/power/supply/Makefile +1 -0
@@ -64,6 +64,7 @@ obj-$(CONFIG_CHARGER_RT5033) += rt5033_charger.o obj-$(CONFIG_CHARGER_RT9455) += rt9455_charger.o obj-$(CONFIG_CHARGER_RT9467) += rt9467-charger.o obj-$(CONFIG_CHARGER_RT9471) += rt9471.o +obj-$(CONFIG_CHARGER_RT9756) += rt9756.o obj-$(CONFIG_BATTERY_TWL4030_MADC) += twl4030_madc_battery.o obj-$(CONFIG_CHARGER_88PM860X) += 88pm860x_charger.o obj-$(CONFIG_BATTERY_RX51) += rx51_battery.o
drivers/power/supply/rt9756.c new file +955 -0
955 lines not on this page · raw message
Signature · 1 line
2.34.1
kernel test robot
build botRe: [PATCH v3 2/3] power: supply: rt9756: Add Richtek RT9756 smart cap divider charger
kernel test robot noticed the following build warnings:
Hi,
kernel test robot noticed the following build warnings:
[auto build test WARNING on sre-power-supply/for-next]
[also build test WARNING on krzk-dt/for-next robh/for-next linus/master v6.18-rc3 next-20251030] [If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/cy_huang-richtek-com/dt-bindings-power-supply-Add-Richtek-RT9756-smart-cap-divider-charger/20251029-091554 base: https://git.kernel.org/pub/scm/linux/kernel/git/sre/linux-power-supply.git for-next patch link: https://lore.kernel.org/r/5eab51e111b092329519dd2c200858a522780626.1761699952.git.cy_huang%40richtek.com patch subject: [PATCH v3 2/3] power: supply: rt9756: Add Richtek RT9756 smart cap divider charger config: nios2-randconfig-r112-20251031 (https://download.01.org/0day-ci/archive/20251031/[email protected]/config) compiler: nios2-linux-gcc (GCC) 9.5.0 reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20251031/[email protected]/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
sparse warnings: (new ones prefixed by >>)
>> drivers/power/supply/rt9756.c:645:41: sparse: sparse: incorrect type in argument 2 (different base types) @@ expected unsigned int [usertype] size @@ got restricted gfp_t @@ drivers/power/supply/rt9756.c:645:41: sparse: expected unsigned int [usertype] size drivers/power/supply/rt9756.c:645:41: sparse: got restricted gfp_t >> drivers/power/supply/rt9756.c:645:53: sparse: sparse: incorrect type in argument 3 (different base types) @@ expected restricted gfp_t [usertype] gfp @@ got unsigned int @@
drivers/power/supply/rt9756.c:645:53: sparse: expected restricted gfp_t [usertype] gfp
drivers/power/supply/rt9756.c:645:53: sparse: got unsigned int
drivers/power/supply/rt9756.c: note: in included file (through include/uapi/linux/swab.h, include/linux/swab.h, include/uapi/linux/byteorder/little_endian.h, ...):
arch/nios2/include/uapi/asm/swab.h:25:24: sparse: sparse: too many arguments for function __builtin_custom_ini
vim +645 drivers/power/supply/rt9756.c
619
620 static int rt9756_register_psy(struct rt9756_data *data)
621 {
622 struct power_supply_desc *desc = &data->psy_desc;
623 struct power_supply_desc *bat_desc = &data->bat_psy_desc;
624 struct power_supply_config cfg = {}, bat_cfg = {};
625 struct device *dev = data->dev;
626 char *psy_name, *bat_psy_name, **supplied_to;
627
628 bat_cfg.drv_data = data;
629 bat_cfg.fwnode = dev_fwnode(dev);
630
631 bat_psy_name = devm_kasprintf(dev, GFP_KERNEL, "rt9756-%s-battery", dev_name(dev));
632 if (!bat_psy_name)
633 return -ENOMEM;
634
635 bat_desc->name = bat_psy_name;
636 bat_desc->type = POWER_SUPPLY_TYPE_BATTERY;
637 bat_desc->properties = rt9756_bat_psy_properties;
638 bat_desc->num_properties = ARRAY_SIZE(rt9756_bat_psy_properties);
639 bat_desc->get_property = rt9756_bat_psy_get_property;
640
641 data->bat_psy = devm_power_supply_register(dev, bat_desc, &bat_cfg);
642 if (IS_ERR(data->bat_psy))
643 return dev_err_probe(dev, PTR_ERR(data->bat_psy), "Failed to register battery\n");
644
> 645 supplied_to = devm_kzalloc(dev, GFP_KERNEL, sizeof(*supplied_to));
646 if (!supplied_to)
647 return -ENOMEM;
648
649 /* Link charger psy to battery psy */
650 supplied_to[0] = bat_psy_name;
651
652 cfg.drv_data = data;
653 cfg.fwnode = dev_fwnode(dev);
654 cfg.attr_grp = rt9756_sysfs_groups;
655 cfg.supplied_to = supplied_to;
656 cfg.num_supplicants = 1;
657
658 psy_name = devm_kasprintf(dev, GFP_KERNEL, "rt9756-%s", dev_name(dev));
659 if (!psy_name)
660 return -ENOMEM;
661
662 desc->name = psy_name;
663 desc->type = POWER_SUPPLY_TYPE_USB;
664 desc->usb_types = BIT(POWER_SUPPLY_USB_TYPE_UNKNOWN) | BIT(POWER_SUPPLY_USB_TYPE_SDP) |
665 BIT(POWER_SUPPLY_USB_TYPE_DCP) | BIT(POWER_SUPPLY_USB_TYPE_CDP);
666 desc->properties = rt9756_psy_properties;
667 desc->num_properties = ARRAY_SIZE(rt9756_psy_properties);
668 desc->property_is_writeable = rt9756_psy_property_is_writeable;
669 desc->get_property = rt9756_psy_get_property;
670 desc->set_property = rt9756_psy_set_property;
671
672 data->psy = devm_power_supply_register(dev, desc, &cfg);
673
674 return PTR_ERR_OR_ZERO(data->psy);
675 }
676
Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki
kernel test robot
build botRe: [PATCH v3 2/3] power: supply: rt9756: Add Richtek RT9756 smart cap divider charger
In reply to [email protected]kernel test robot noticed the following build warnings:
Hi,
kernel test robot noticed the following build warnings:
[auto build test WARNING on sre-power-supply/for-next]
[also build test WARNING on krzk-dt/for-next robh/for-next linus/master v6.18-rc3 next-20251030] [If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/cy_huang-richtek-com/dt-bindings-power-supply-Add-Richtek-RT9756-smart-cap-divider-charger/20251029-091554 base: https://git.kernel.org/pub/scm/linux/kernel/git/sre/linux-power-supply.git for-next patch link: https://lore.kernel.org/r/5eab51e111b092329519dd2c200858a522780626.1761699952.git.cy_huang%40richtek.com patch subject: [PATCH v3 2/3] power: supply: rt9756: Add Richtek RT9756 smart cap divider charger config: alpha-randconfig-r122-20251031 (https://download.01.org/0day-ci/archive/20251031/[email protected]/config) compiler: alpha-linux-gcc (GCC) 12.5.0 reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20251031/[email protected]/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
sparse warnings: (new ones prefixed by >>)
>> drivers/power/supply/rt9756.c:645:41: sparse: sparse: incorrect type in argument 2 (different base types) @@ expected unsigned long [usertype] size @@ got restricted gfp_t @@ drivers/power/supply/rt9756.c:645:41: sparse: expected unsigned long [usertype] size drivers/power/supply/rt9756.c:645:41: sparse: got restricted gfp_t >> drivers/power/supply/rt9756.c:645:53: sparse: sparse: incorrect type in argument 3 (different base types) @@ expected restricted gfp_t [usertype] gfp @@ got unsigned long @@
drivers/power/supply/rt9756.c:645:53: sparse: expected restricted gfp_t [usertype] gfp
drivers/power/supply/rt9756.c:645:53: sparse: got unsigned long
vim +645 drivers/power/supply/rt9756.c
619
620 static int rt9756_register_psy(struct rt9756_data *data)
621 {
622 struct power_supply_desc *desc = &data->psy_desc;
623 struct power_supply_desc *bat_desc = &data->bat_psy_desc;
624 struct power_supply_config cfg = {}, bat_cfg = {};
625 struct device *dev = data->dev;
626 char *psy_name, *bat_psy_name, **supplied_to;
627
628 bat_cfg.drv_data = data;
629 bat_cfg.fwnode = dev_fwnode(dev);
630
631 bat_psy_name = devm_kasprintf(dev, GFP_KERNEL, "rt9756-%s-battery", dev_name(dev));
632 if (!bat_psy_name)
633 return -ENOMEM;
634
635 bat_desc->name = bat_psy_name;
636 bat_desc->type = POWER_SUPPLY_TYPE_BATTERY;
637 bat_desc->properties = rt9756_bat_psy_properties;
638 bat_desc->num_properties = ARRAY_SIZE(rt9756_bat_psy_properties);
639 bat_desc->get_property = rt9756_bat_psy_get_property;
640
641 data->bat_psy = devm_power_supply_register(dev, bat_desc, &bat_cfg);
642 if (IS_ERR(data->bat_psy))
643 return dev_err_probe(dev, PTR_ERR(data->bat_psy), "Failed to register battery\n");
644
> 645 supplied_to = devm_kzalloc(dev, GFP_KERNEL, sizeof(*supplied_to));
646 if (!supplied_to)
647 return -ENOMEM;
648
649 /* Link charger psy to battery psy */
650 supplied_to[0] = bat_psy_name;
651
652 cfg.drv_data = data;
653 cfg.fwnode = dev_fwnode(dev);
654 cfg.attr_grp = rt9756_sysfs_groups;
655 cfg.supplied_to = supplied_to;
656 cfg.num_supplicants = 1;
657
658 psy_name = devm_kasprintf(dev, GFP_KERNEL, "rt9756-%s", dev_name(dev));
659 if (!psy_name)
660 return -ENOMEM;
661
662 desc->name = psy_name;
663 desc->type = POWER_SUPPLY_TYPE_USB;
664 desc->usb_types = BIT(POWER_SUPPLY_USB_TYPE_UNKNOWN) | BIT(POWER_SUPPLY_USB_TYPE_SDP) |
665 BIT(POWER_SUPPLY_USB_TYPE_DCP) | BIT(POWER_SUPPLY_USB_TYPE_CDP);
666 desc->properties = rt9756_psy_properties;
667 desc->num_properties = ARRAY_SIZE(rt9756_psy_properties);
668 desc->property_is_writeable = rt9756_psy_property_is_writeable;
669 desc->get_property = rt9756_psy_get_property;
670 desc->set_property = rt9756_psy_set_property;
671
672 data->psy = devm_power_supply_register(dev, desc, &cfg);
673
674 return PTR_ERR_OR_ZERO(data->psy);
675 }
676
Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki
PATCH v3 3/3 Documentation: power: rt9756: Document exported sysfs entries
In reply to [email protected]From: ChiYuan Huang <[email protected]>
Document the settings exported by rt9756 charger driver through sysfs entries:
- watchdog_timer
- operation_mode
---
V3
- Remove customized description for battery voltage and current
--- .../ABI/testing/sysfs-class-power-rt9756 | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 Documentation/ABI/testing/sysfs-class-power-rt9756
Documentation/ABI/testing/sysfs-class-power-rt9756 new file +30 -0
@@ -0,0 +1,30 @@ +What: /sys/class/power_supply/rt9756-*/watchdog_timer +Date: Dec 2025 +KernelVersion: 6.19 +Contact: ChiYuan Huang <[email protected]> +Description: + This entry shows and sets the watchdog timer when rt9756 charger + operates in charging mode. When the timer expires, the device + will disable the charging. To prevent the timer expires, any + host communication can make the timer restarted. + + Access: Read, Write + + Valid values: + - 500, 1000, 5000, 30000, 40000, 80000, 128000 or 255000 (milliseconds), + - 0: disabled + +What: /sys/class/power_supply/rt9756-*/operation_mode +Date: Dec 2025 +KernelVersion: 6.19 +Contact: ChiYuan Huang <[email protected]> +Description: + This entry shows and set the operation mode when rt9756 charger + operates in charging phase. If 'bypass' mode is used, internal + path will connect vbus directly to vbat. Else, default 'div2' + mode for the switch-cap charging. + + Access: Read, Write + + Valid values: + - 'bypass' or 'div2'
Signature · 1 line
2.34.1