xref: /freebsd/sys/contrib/device-tree/Bindings/power/supply/gpio-charger.yaml (revision a90b9d0159070121c221b966469c3e36d912bf82)
1# SPDX-License-Identifier: GPL-2.0
2%YAML 1.2
3---
4$id: http://devicetree.org/schemas/power/supply/gpio-charger.yaml#
5$schema: http://devicetree.org/meta-schemas/core.yaml#
6
7title: simple battery chargers only communicating through GPIOs
8
9maintainers:
10  - Sebastian Reichel <sre@kernel.org>
11
12description:
13  This binding is for all chargers, which are working more or less
14  autonomously, only providing some status GPIOs and possibly some
15  GPIOs for limited control over the charging process.
16
17properties:
18  compatible:
19    const: gpio-charger
20
21  charger-type:
22    enum:
23      - unknown
24      - battery
25      - ups
26      - mains
27      - usb-sdp                   # USB standard downstream port
28      - usb-dcp                   # USB dedicated charging port
29      - usb-cdp                   # USB charging downstream port
30      - usb-aca                   # USB accessory charger adapter
31    description:
32      Type of the charger, e.g. "mains" for a wall charger.
33
34  gpios:
35    maxItems: 1
36    description: GPIO indicating the charger presence
37
38  charge-status-gpios:
39    maxItems: 1
40    description: GPIO indicating the charging status
41
42  charge-current-limit-gpios:
43    minItems: 1
44    maxItems: 32
45    description: GPIOs used for current limiting
46
47  charge-current-limit-mapping:
48    description: List of tuples with current in uA and a GPIO bitmap (in
49      this order). The tuples must be provided in descending order of the
50      current limit.
51    $ref: /schemas/types.yaml#/definitions/uint32-matrix
52    items:
53      items:
54        - description:
55            Current limit in uA
56        - description:
57            Encoded GPIO setting. Bit 0 represents last GPIO from the
58            charge-current-limit-gpios property. Bit 1 second to last
59            GPIO and so on.
60
61required:
62  - compatible
63
64anyOf:
65  - required:
66      - gpios
67  - required:
68      - charge-status-gpios
69  - required:
70      - charge-current-limit-gpios
71
72dependencies:
73  charge-current-limit-gpios: [ charge-current-limit-mapping ]
74  charge-current-limit-mapping: [ charge-current-limit-gpios ]
75
76additionalProperties: false
77
78examples:
79  - |
80    #include <dt-bindings/gpio/gpio.h>
81
82    charger {
83      compatible = "gpio-charger";
84      charger-type = "usb-sdp";
85
86      gpios = <&gpd 28 GPIO_ACTIVE_LOW>;
87      charge-status-gpios = <&gpc 27 GPIO_ACTIVE_LOW>;
88
89      charge-current-limit-gpios = <&gpioA 11 GPIO_ACTIVE_HIGH>,
90                                   <&gpioA 12 GPIO_ACTIVE_HIGH>;
91      charge-current-limit-mapping = <2500000 0x00>, // 2.5 A => both GPIOs low
92                                     <700000 0x01>, // 700 mA => GPIO A.12 high
93                                     <0 0x02>; // 0 mA => GPIO A.11 high
94    };
95