[PATCH 1/3] dt-bindings: power: supply: Add Richtek RT9756 smart cap divider charger

cy_huang@richtek.com posted 3 patches 2 months, 1 week ago
[PATCH 1/3] dt-bindings: power: supply: Add Richtek RT9756 smart cap divider charger
Posted by cy_huang@richtek.com 2 months, 1 week ago
From: ChiYuan Huang <cy_huang@richtek.com>

Add the document for Richtek RT9756 smart cap divider charger.

Signed-off-by: ChiYuan Huang <cy_huang@richtek.com>
---
 .../bindings/power/supply/richtek,rt9756.yaml | 70 +++++++++++++++++++
 1 file changed, 70 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/power/supply/richtek,rt9756.yaml

diff --git a/Documentation/devicetree/bindings/power/supply/richtek,rt9756.yaml b/Documentation/devicetree/bindings/power/supply/richtek,rt9756.yaml
new file mode 100644
index 000000000000..e81668b43fba
--- /dev/null
+++ b/Documentation/devicetree/bindings/power/supply/richtek,rt9756.yaml
@@ -0,0 +1,70 @@
+# 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 <cy_huang@richtek.com>
+
+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.
+
+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
+  - wakeup-source
+  - interrupts
+
+additionalProperties: 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>;
+      };
+    };
-- 
2.34.1
Re: [PATCH 1/3] dt-bindings: power: supply: Add Richtek RT9756 smart cap divider charger
Posted by Krzysztof Kozlowski 2 months, 1 week ago
On 29/07/2025 06:21, cy_huang@richtek.com wrote:
> +
> +  shunt-resistor-micro-ohms:
> +    description: Battery current sense resistor mounted.
> +    default: 2000
> +
> +required:
> +  - compatible
> +  - reg
> +  - wakeup-source

Why do you require this? I cannot find any use of it, so maybe I missed
some change in Linux code (and that's second question like that for
Richtek, so refer to your other patchsets for contexr).

> +  - interrupts
> +

Missing ref to power supply.

> +additionalProperties: false
> +

unevaluated instead


Best regards,
Krzysztof
Re: [PATCH 1/3] dt-bindings: power: supply: Add Richtek RT9756 smart cap divider charger
Posted by ChiYuan Huang 2 months, 1 week ago
On Tue, Jul 29, 2025 at 05:40:32PM +0200, Krzysztof Kozlowski wrote:
> On 29/07/2025 06:21, cy_huang@richtek.com wrote:
> > +
> > +  shunt-resistor-micro-ohms:
> > +    description: Battery current sense resistor mounted.
> > +    default: 2000
> > +
> > +required:
> > +  - compatible
> > +  - reg
> > +  - wakeup-source
> 
> Why do you require this? I cannot find any use of it, so maybe I missed
> some change in Linux code (and that's second question like that for
> Richtek, so refer to your other patchsets for contexr).
> 

This will mark the interrupt as wakeup capable.
https://elixir.bootlin.com/linux/v6.16/source/drivers/i2c/i2c-core-of.c#L57
https://elixir.bootlin.com/linux/v6.16/source/drivers/i2c/i2c-core-base.c#L547
> > +  - interrupts
> > +
> 
> Missing ref to power supply.
> 
> > +additionalProperties: false
> > +
> 
Ack, will add the below lines to the document for next revision.

allOf:
  - $ref: power-supply.yaml#
> unevaluated instead
> 
Ack.

Thx.
Re: [PATCH 1/3] dt-bindings: power: supply: Add Richtek RT9756 smart cap divider charger
Posted by Krzysztof Kozlowski 2 months, 1 week ago
On Wed, Jul 30, 2025 at 10:07:16AM +0800, ChiYuan Huang wrote:
> On Tue, Jul 29, 2025 at 05:40:32PM +0200, Krzysztof Kozlowski wrote:
> > On 29/07/2025 06:21, cy_huang@richtek.com wrote:
> > > +
> > > +  shunt-resistor-micro-ohms:
> > > +    description: Battery current sense resistor mounted.
> > > +    default: 2000
> > > +
> > > +required:
> > > +  - compatible
> > > +  - reg
> > > +  - wakeup-source
> > 
> > Why do you require this? I cannot find any use of it, so maybe I missed
> > some change in Linux code (and that's second question like that for
> > Richtek, so refer to your other patchsets for contexr).
> > 
> 
> This will mark the interrupt as wakeup capable.
> https://elixir.bootlin.com/linux/v6.16/source/drivers/i2c/i2c-core-of.c#L57
> https://elixir.bootlin.com/linux/v6.16/source/drivers/i2c/i2c-core-base.c#L547

OK, but this does not explain why this is required. Why it is impossible
to make board which uses this PMIC and wires the interrupt in a way it
is not waking up the system?

To my limited knowledge this should be possible, but what do I know
about hardware...

Best regards,
Krzysztof
Re: [PATCH 1/3] dt-bindings: power: supply: Add Richtek RT9756 smart cap divider charger
Posted by Krzysztof Kozlowski 2 months, 1 week ago
On Wed, Jul 30, 2025 at 09:39:38AM +0200, Krzysztof Kozlowski wrote:
> On Wed, Jul 30, 2025 at 10:07:16AM +0800, ChiYuan Huang wrote:
> > On Tue, Jul 29, 2025 at 05:40:32PM +0200, Krzysztof Kozlowski wrote:
> > > On 29/07/2025 06:21, cy_huang@richtek.com wrote:
> > > > +
> > > > +  shunt-resistor-micro-ohms:
> > > > +    description: Battery current sense resistor mounted.
> > > > +    default: 2000
> > > > +
> > > > +required:
> > > > +  - compatible
> > > > +  - reg
> > > > +  - wakeup-source
> > > 
> > > Why do you require this? I cannot find any use of it, so maybe I missed
> > > some change in Linux code (and that's second question like that for
> > > Richtek, so refer to your other patchsets for contexr).
> > > 
> > 
> > This will mark the interrupt as wakeup capable.
> > https://elixir.bootlin.com/linux/v6.16/source/drivers/i2c/i2c-core-of.c#L57
> > https://elixir.bootlin.com/linux/v6.16/source/drivers/i2c/i2c-core-base.c#L547
> 
> OK, but this does not explain why this is required. Why it is impossible
> to make board which uses this PMIC and wires the interrupt in a way it
> is not waking up the system?
> 
> To my limited knowledge this should be possible, but what do I know
> about hardware...

Another question is still valid, although you provided more context - if
the device is ALWAYS waking up, this is implied by compatible and you do
not need this property at all.

That would be the first usage of I2C client wakeup flag in drivers, but
maybe that is how it should be done? You can consult I2C folks on IRC.

Best regards,
Krzysztof
Re: [PATCH 1/3] dt-bindings: power: supply: Add Richtek RT9756 smart cap divider charger
Posted by cy_huang@richtek.com 2 months, 1 week ago
> On Wed, Jul 30, 2025 at 09:39:38AM +0200, Krzysztof Kozlowski wrote:
> > On Wed, Jul 30, 2025 at 10:07:16AM +0800, ChiYuan Huang wrote:
> > > On Tue, Jul 29, 2025 at 05:40:32PM +0200, Krzysztof Kozlowski wrote:
> > > > On 29/07/2025 06:21, cy_huang@richtek.com wrote:
> > > > > +
> > > > > +  shunt-resistor-micro-ohms:
> > > > > +    description: Battery current sense resistor mounted.
> > > > > +    default: 2000
> > > > > +
> > > > > +required:
> > > > > +  - compatible
> > > > > +  - reg
> > > > > +  - wakeup-source
> > > > 
> > > > Why do you require this? I cannot find any use of it, so maybe I missed
> > > > some change in Linux code (and that's second question like that for
> > > > Richtek, so refer to your other patchsets for contexr).
> > > > 
> > > 
> > > This will mark the interrupt as wakeup capable.
> > > https://elixir.bootlin.com/linux/v6.16/source/drivers/i2c/i2c-core-of.c#L57
> > > https://elixir.bootlin.com/linux/v6.16/source/drivers/i2c/i2c-core-base.c#L547
> > 
> > OK, but this does not explain why this is required. Why it is impossible
> > to make board which uses this PMIC and wires the interrupt in a way it
> > is not waking up the system?
> > 
> > To my limited knowledge this should be possible, but what do I know
> > about hardware...
> 
> Another question is still valid, although you provided more context - if
> the device is ALWAYS waking up, this is implied by compatible and you do
> not need this property at all.
> 
> That would be the first usage of I2C client wakeup flag in drivers, but
> maybe that is how it should be done? You can consult I2C folks on IRC.

Yap, like as your saying. If not declared 'wakeup-source', it only means
if the system supports sleep state, this interrupt won't on-time notify any
event. Actually, not affect its normal functionality.

If your question is should the property 'wakeup-source' be declared as
required, then the answer should be 'No'.

When system supports suspend, to declare this property is just a suggestion.

In next revision, I'll remove 'wakeup-source' from the required property list.

All questions are clarified.

Thx.