diff mbox series

[v2,1/9] dt-bindings: power: supply: Add device-tree binding for Summit SMB3xx

Message ID 20200607144113.10202-2-digetx@gmail.com (mailing list archive)
State Superseded
Headers show
Series Summit SMB3xx driver & device-tree | expand

Commit Message

Dmitry Osipenko June 7, 2020, 2:41 p.m. UTC
From: David Heidelberg <david@ixit.cz>

Summit SMB3xx series is a Programmable Switching Li+ Battery Charger.
This patch adds device-tree binding for Summit SMB345, SMB347 and SMB358
chargers.

Signed-off-by: David Heidelberg <david@ixit.cz>
Signed-off-by: Dmitry Osipenko <digetx@gmail.com>
---
 .../power/supply/summit,smb347-charger.yaml   | 165 ++++++++++++++++++
 .../dt-bindings/power/summit,smb347-charger.h |  19 ++
 2 files changed, 184 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/power/supply/summit,smb347-charger.yaml
 create mode 100644 include/dt-bindings/power/summit,smb347-charger.h

Comments

Rob Herring (Arm) July 13, 2020, 11:39 p.m. UTC | #1
On Sun, Jun 07, 2020 at 05:41:05PM +0300, Dmitry Osipenko wrote:
> From: David Heidelberg <david@ixit.cz>
> 
> Summit SMB3xx series is a Programmable Switching Li+ Battery Charger.
> This patch adds device-tree binding for Summit SMB345, SMB347 and SMB358
> chargers.
> 
> Signed-off-by: David Heidelberg <david@ixit.cz>
> Signed-off-by: Dmitry Osipenko <digetx@gmail.com>
> ---
>  .../power/supply/summit,smb347-charger.yaml   | 165 ++++++++++++++++++
>  .../dt-bindings/power/summit,smb347-charger.h |  19 ++
>  2 files changed, 184 insertions(+)
>  create mode 100644 Documentation/devicetree/bindings/power/supply/summit,smb347-charger.yaml
>  create mode 100644 include/dt-bindings/power/summit,smb347-charger.h
> 
> diff --git a/Documentation/devicetree/bindings/power/supply/summit,smb347-charger.yaml b/Documentation/devicetree/bindings/power/supply/summit,smb347-charger.yaml
> new file mode 100644
> index 000000000000..eea0a6398c95
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/power/supply/summit,smb347-charger.yaml
> @@ -0,0 +1,165 @@
> +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
> +%YAML 1.2
> +---
> +$id: "http://devicetree.org/schemas/power/supply/summit,smb347-charger.yaml#"
> +$schema: "http://devicetree.org/meta-schemas/core.yaml#"
> +
> +title: Battery charger driver for SMB345, SMB347 and SMB358
> +
> +maintainers:
> +  - David Heidelberg <david@ixit.cz>
> +  - Dmitry Osipenko <digetx@gmail.com>
> +
> +properties:
> +  compatible:
> +    enum:
> +      - summit,smb345
> +      - summit,smb347
> +      - summit,smb358
> +
> +  reg:
> +    maxItems: 1
> +
> +  interrupts:
> +    maxItems: 1
> +
> +  monitored-battery:
> +    description: phandle to the battery node
> +    $ref: /schemas/types.yaml#/definitions/phandle
> +
> +  summit,enable-usb-charging:
> +    type: boolean
> +    description: Enable charging through USB.
> +
> +  summit,enable-otg-charging:
> +    type: boolean
> +    description: Provide power for USB OTG
> +
> +  summit,enable-mains-charging:
> +    type: boolean
> +    description: Enable charging through mains
> +
> +  summit,enable-charge-control:
> +    description: Enable charging control
> +    allOf:
> +      - $ref: /schemas/types.yaml#/definitions/uint32
> +      - enum:
> +          - 0 # SMB3XX_CHG_ENABLE_SW SW (I2C interface)
> +          - 1 # SMB3XX_CHG_ENABLE_PIN_ACTIVE_LOW Pin control (Active Low)
> +          - 2 # SMB3XX_CHG_ENABLE_PIN_ACTIVE_HIGH Pin control (Active High)
> +
> +  summit,fast-voltage-threshold-microvolt:
> +    description: Voltage threshold to transit to fast charge mode (in uV)
> +    allOf:
> +      - $ref: /schemas/types.yaml#/definitions/uint32

Anything with a standard unit suffix already has a type, so drop.

> +    minimum: 2400000
> +    maximum: 3000000
> +
> +  summit,mains-current-limit-microamp:
> +    description: Maximum input current from AC/DC input (in uA)
> +    allOf:
> +      - $ref: /schemas/types.yaml#/definitions/uint32
> +
> +  summit,usb-current-limit-microamp:
> +    description: Maximum input current from USB input (in uA)
> +    allOf:
> +      - $ref: /schemas/types.yaml#/definitions/uint32
> +
> +  summit,charge-current-compensation-microamp:
> +    description: Charge current compensation (in uA)
> +    allOf:
> +      - $ref: /schemas/types.yaml#/definitions/uint32
> +
> +  summit,chip-temperature-threshold-celsius:
> +    description: Chip temperature for thermal regulation in °C.
> +    allOf:
> +      - $ref: /schemas/types.yaml#/definitions/uint32
> +    enum: [100, 110, 120, 130]
> +
> +  summit,soft-compensation-method:
> +    description: Soft temperature limit compensation method
> +    allOf:
> +      - $ref: /schemas/types.yaml#/definitions/uint32
> +      - enum:
> +          - 0 # SMB3XX_SOFT_TEMP_COMPENSATE_NONE Compensation none
> +          - 1 # SMB3XX_SOFT_TEMP_COMPENSATE_CURRENT Current compensation
> +          - 2 # SMB3XX_SOFT_TEMP_COMPENSATE_VOLTAGE Voltage compensation
> +
> +allOf:
> +  - if:
> +      properties:
> +        compatible:
> +          enum:
> +            - summit,smb345
> +            - summit,smb358
> +
> +    then:
> +      properties:
> +        summit,mains-current-limit-microamp:
> +          enum: [ 300000,  500000,  700000, 1000000,
> +                 1500000, 1800000, 2000000]
> +
> +        summit,usb-current-limit-microamp:
> +          enum: [ 300000,  500000,  700000, 1000000,
> +                 1500000, 1800000, 2000000]
> +
> +        summit,charge-current-compensation-microamp:
> +          enum: [200000, 450000, 600000, 900000]
> +
> +    else:
> +      properties:
> +        summit,mains-current-limit-microamp:
> +          enum: [ 300000,  500000,  700000,  900000, 1200000,
> +                 1500000, 1800000, 2000000, 2200000, 2500000]
> +
> +        summit,usb-current-limit-microamp:
> +          enum: [ 300000,  500000,  700000,  900000, 1200000,
> +                 1500000, 1800000, 2000000, 2200000, 2500000]
> +
> +        summit,charge-current-compensation-microamp:
> +          enum: [250000, 700000, 900000, 1200000]
> +
> +required:
> +  - compatible
> +  - reg
> +
> +anyOf:
> +  - required:
> +      - summit,enable-usb-charging
> +  - required:
> +      - summit,enable-otg-charging
> +  - required:
> +      - summit,enable-mains-charging
> +
> +additionalProperties: false
> +
> +examples:
> +  - |
> +    #include <dt-bindings/power/summit,smb347-charger.h>
> +
> +    i2c {
> +        #address-cells = <1>;
> +        #size-cells = <0>;
> +
> +        charger@7f {
> +            compatible = "summit,smb347";
> +            reg = <0x7f>;
> +            status = "okay";
> +
> +            summit,enable-charge-control = <SMB3XX_CHG_ENABLE_PIN_ACTIVE_HIGH>;
> +            summit,chip-temperature-threshold-celsius = <110>;
> +            summit,mains-current-limit-microamp = <2000000>;
> +            summit,usb-current-limit-microamp = <500000>;
> +            summit,enable-usb-charging;
> +            summit,enable-mains-charging;
> +
> +            monitored-battery = <&battery>;
> +        };
> +    };
> +
> +    battery: battery-cell {
> +        compatible = "simple-battery";
> +        constant-charge-current-max-microamp = <1800000>;
> +        temperature-min-alert-celsius = <5>;
> +        temperature-max-alert-celsius = <40>;
> +    };
> diff --git a/include/dt-bindings/power/summit,smb347-charger.h b/include/dt-bindings/power/summit,smb347-charger.h
> new file mode 100644
> index 000000000000..d918bf321a71
> --- /dev/null
> +++ b/include/dt-bindings/power/summit,smb347-charger.h
> @@ -0,0 +1,19 @@
> +/* SPDX-License-Identifier: (GPL-2.0-or-later or MIT) */
> +/*
> + * Author: David Heidelberg <david@ixit.cz>
> + */
> +
> +#ifndef _DT_BINDINGS_SMB347_CHARGER_H
> +#define _DT_BINDINGS_SMB347_CHARGER_H
> +
> +/* Charging compensation method */
> +#define SMB3XX_SOFT_TEMP_COMPENSATE_NONE	0
> +#define SMB3XX_SOFT_TEMP_COMPENSATE_CURRENT	1
> +#define SMB3XX_SOFT_TEMP_COMPENSATE_VOLTAGE	2
> +
> +/* Charging enable control */
> +#define SMB3XX_CHG_ENABLE_SW			0
> +#define SMB3XX_CHG_ENABLE_PIN_ACTIVE_LOW	1
> +#define SMB3XX_CHG_ENABLE_PIN_ACTIVE_HIGH	2
> +
> +#endif
> -- 
> 2.26.0
>
Dmitry Osipenko July 16, 2020, 5:24 p.m. UTC | #2
14.07.2020 02:39, Rob Herring пишет:
> On Sun, Jun 07, 2020 at 05:41:05PM +0300, Dmitry Osipenko wrote:
>> From: David Heidelberg <david@ixit.cz>
>>
>> Summit SMB3xx series is a Programmable Switching Li+ Battery Charger.
>> This patch adds device-tree binding for Summit SMB345, SMB347 and SMB358
>> chargers.
>>
>> Signed-off-by: David Heidelberg <david@ixit.cz>
>> Signed-off-by: Dmitry Osipenko <digetx@gmail.com>
>> ---
>>  .../power/supply/summit,smb347-charger.yaml   | 165 ++++++++++++++++++
>>  .../dt-bindings/power/summit,smb347-charger.h |  19 ++
>>  2 files changed, 184 insertions(+)
>>  create mode 100644 Documentation/devicetree/bindings/power/supply/summit,smb347-charger.yaml
>>  create mode 100644 include/dt-bindings/power/summit,smb347-charger.h
>>
>> diff --git a/Documentation/devicetree/bindings/power/supply/summit,smb347-charger.yaml b/Documentation/devicetree/bindings/power/supply/summit,smb347-charger.yaml
>> new file mode 100644
>> index 000000000000..eea0a6398c95
>> --- /dev/null
>> +++ b/Documentation/devicetree/bindings/power/supply/summit,smb347-charger.yaml
>> @@ -0,0 +1,165 @@
>> +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
>> +%YAML 1.2
>> +---
>> +$id: "http://devicetree.org/schemas/power/supply/summit,smb347-charger.yaml#"
>> +$schema: "http://devicetree.org/meta-schemas/core.yaml#"
>> +
>> +title: Battery charger driver for SMB345, SMB347 and SMB358
>> +
>> +maintainers:
>> +  - David Heidelberg <david@ixit.cz>
>> +  - Dmitry Osipenko <digetx@gmail.com>
>> +
>> +properties:
>> +  compatible:
>> +    enum:
>> +      - summit,smb345
>> +      - summit,smb347
>> +      - summit,smb358
>> +
>> +  reg:
>> +    maxItems: 1
>> +
>> +  interrupts:
>> +    maxItems: 1
>> +
>> +  monitored-battery:
>> +    description: phandle to the battery node
>> +    $ref: /schemas/types.yaml#/definitions/phandle
>> +
>> +  summit,enable-usb-charging:
>> +    type: boolean
>> +    description: Enable charging through USB.
>> +
>> +  summit,enable-otg-charging:
>> +    type: boolean
>> +    description: Provide power for USB OTG
>> +
>> +  summit,enable-mains-charging:
>> +    type: boolean
>> +    description: Enable charging through mains
>> +
>> +  summit,enable-charge-control:
>> +    description: Enable charging control
>> +    allOf:
>> +      - $ref: /schemas/types.yaml#/definitions/uint32
>> +      - enum:
>> +          - 0 # SMB3XX_CHG_ENABLE_SW SW (I2C interface)
>> +          - 1 # SMB3XX_CHG_ENABLE_PIN_ACTIVE_LOW Pin control (Active Low)
>> +          - 2 # SMB3XX_CHG_ENABLE_PIN_ACTIVE_HIGH Pin control (Active High)
>> +
>> +  summit,fast-voltage-threshold-microvolt:
>> +    description: Voltage threshold to transit to fast charge mode (in uV)
>> +    allOf:
>> +      - $ref: /schemas/types.yaml#/definitions/uint32
> 
> Anything with a standard unit suffix already has a type, so drop.

I'll correct it in the next revision, thanks!
diff mbox series

Patch

diff --git a/Documentation/devicetree/bindings/power/supply/summit,smb347-charger.yaml b/Documentation/devicetree/bindings/power/supply/summit,smb347-charger.yaml
new file mode 100644
index 000000000000..eea0a6398c95
--- /dev/null
+++ b/Documentation/devicetree/bindings/power/supply/summit,smb347-charger.yaml
@@ -0,0 +1,165 @@ 
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: "http://devicetree.org/schemas/power/supply/summit,smb347-charger.yaml#"
+$schema: "http://devicetree.org/meta-schemas/core.yaml#"
+
+title: Battery charger driver for SMB345, SMB347 and SMB358
+
+maintainers:
+  - David Heidelberg <david@ixit.cz>
+  - Dmitry Osipenko <digetx@gmail.com>
+
+properties:
+  compatible:
+    enum:
+      - summit,smb345
+      - summit,smb347
+      - summit,smb358
+
+  reg:
+    maxItems: 1
+
+  interrupts:
+    maxItems: 1
+
+  monitored-battery:
+    description: phandle to the battery node
+    $ref: /schemas/types.yaml#/definitions/phandle
+
+  summit,enable-usb-charging:
+    type: boolean
+    description: Enable charging through USB.
+
+  summit,enable-otg-charging:
+    type: boolean
+    description: Provide power for USB OTG
+
+  summit,enable-mains-charging:
+    type: boolean
+    description: Enable charging through mains
+
+  summit,enable-charge-control:
+    description: Enable charging control
+    allOf:
+      - $ref: /schemas/types.yaml#/definitions/uint32
+      - enum:
+          - 0 # SMB3XX_CHG_ENABLE_SW SW (I2C interface)
+          - 1 # SMB3XX_CHG_ENABLE_PIN_ACTIVE_LOW Pin control (Active Low)
+          - 2 # SMB3XX_CHG_ENABLE_PIN_ACTIVE_HIGH Pin control (Active High)
+
+  summit,fast-voltage-threshold-microvolt:
+    description: Voltage threshold to transit to fast charge mode (in uV)
+    allOf:
+      - $ref: /schemas/types.yaml#/definitions/uint32
+    minimum: 2400000
+    maximum: 3000000
+
+  summit,mains-current-limit-microamp:
+    description: Maximum input current from AC/DC input (in uA)
+    allOf:
+      - $ref: /schemas/types.yaml#/definitions/uint32
+
+  summit,usb-current-limit-microamp:
+    description: Maximum input current from USB input (in uA)
+    allOf:
+      - $ref: /schemas/types.yaml#/definitions/uint32
+
+  summit,charge-current-compensation-microamp:
+    description: Charge current compensation (in uA)
+    allOf:
+      - $ref: /schemas/types.yaml#/definitions/uint32
+
+  summit,chip-temperature-threshold-celsius:
+    description: Chip temperature for thermal regulation in °C.
+    allOf:
+      - $ref: /schemas/types.yaml#/definitions/uint32
+    enum: [100, 110, 120, 130]
+
+  summit,soft-compensation-method:
+    description: Soft temperature limit compensation method
+    allOf:
+      - $ref: /schemas/types.yaml#/definitions/uint32
+      - enum:
+          - 0 # SMB3XX_SOFT_TEMP_COMPENSATE_NONE Compensation none
+          - 1 # SMB3XX_SOFT_TEMP_COMPENSATE_CURRENT Current compensation
+          - 2 # SMB3XX_SOFT_TEMP_COMPENSATE_VOLTAGE Voltage compensation
+
+allOf:
+  - if:
+      properties:
+        compatible:
+          enum:
+            - summit,smb345
+            - summit,smb358
+
+    then:
+      properties:
+        summit,mains-current-limit-microamp:
+          enum: [ 300000,  500000,  700000, 1000000,
+                 1500000, 1800000, 2000000]
+
+        summit,usb-current-limit-microamp:
+          enum: [ 300000,  500000,  700000, 1000000,
+                 1500000, 1800000, 2000000]
+
+        summit,charge-current-compensation-microamp:
+          enum: [200000, 450000, 600000, 900000]
+
+    else:
+      properties:
+        summit,mains-current-limit-microamp:
+          enum: [ 300000,  500000,  700000,  900000, 1200000,
+                 1500000, 1800000, 2000000, 2200000, 2500000]
+
+        summit,usb-current-limit-microamp:
+          enum: [ 300000,  500000,  700000,  900000, 1200000,
+                 1500000, 1800000, 2000000, 2200000, 2500000]
+
+        summit,charge-current-compensation-microamp:
+          enum: [250000, 700000, 900000, 1200000]
+
+required:
+  - compatible
+  - reg
+
+anyOf:
+  - required:
+      - summit,enable-usb-charging
+  - required:
+      - summit,enable-otg-charging
+  - required:
+      - summit,enable-mains-charging
+
+additionalProperties: false
+
+examples:
+  - |
+    #include <dt-bindings/power/summit,smb347-charger.h>
+
+    i2c {
+        #address-cells = <1>;
+        #size-cells = <0>;
+
+        charger@7f {
+            compatible = "summit,smb347";
+            reg = <0x7f>;
+            status = "okay";
+
+            summit,enable-charge-control = <SMB3XX_CHG_ENABLE_PIN_ACTIVE_HIGH>;
+            summit,chip-temperature-threshold-celsius = <110>;
+            summit,mains-current-limit-microamp = <2000000>;
+            summit,usb-current-limit-microamp = <500000>;
+            summit,enable-usb-charging;
+            summit,enable-mains-charging;
+
+            monitored-battery = <&battery>;
+        };
+    };
+
+    battery: battery-cell {
+        compatible = "simple-battery";
+        constant-charge-current-max-microamp = <1800000>;
+        temperature-min-alert-celsius = <5>;
+        temperature-max-alert-celsius = <40>;
+    };
diff --git a/include/dt-bindings/power/summit,smb347-charger.h b/include/dt-bindings/power/summit,smb347-charger.h
new file mode 100644
index 000000000000..d918bf321a71
--- /dev/null
+++ b/include/dt-bindings/power/summit,smb347-charger.h
@@ -0,0 +1,19 @@ 
+/* SPDX-License-Identifier: (GPL-2.0-or-later or MIT) */
+/*
+ * Author: David Heidelberg <david@ixit.cz>
+ */
+
+#ifndef _DT_BINDINGS_SMB347_CHARGER_H
+#define _DT_BINDINGS_SMB347_CHARGER_H
+
+/* Charging compensation method */
+#define SMB3XX_SOFT_TEMP_COMPENSATE_NONE	0
+#define SMB3XX_SOFT_TEMP_COMPENSATE_CURRENT	1
+#define SMB3XX_SOFT_TEMP_COMPENSATE_VOLTAGE	2
+
+/* Charging enable control */
+#define SMB3XX_CHG_ENABLE_SW			0
+#define SMB3XX_CHG_ENABLE_PIN_ACTIVE_LOW	1
+#define SMB3XX_CHG_ENABLE_PIN_ACTIVE_HIGH	2
+
+#endif