Skip to contentSkip to conversation

dt-bindings: thermal: convert Mediatek Thermal to the json-schema

PATCH Superseded Rafał Miłecki 3 participants 3 messages Nov 16, 2023

Subsystems (3)

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 dt-bindings: thermal: convert Mediatek Thermal to the json-schema

From: Rafał Miłecki <[email protected]>

This helps validating DTS files.

---
 .../bindings/thermal/mediatek-thermal.txt     | 52 ----------
 .../bindings/thermal/mediatek-thermal.yaml    | 98 +++++++++++++++++++
 2 files changed, 98 insertions(+), 52 deletions(-)
 delete mode 100644 Documentation/devicetree/bindings/thermal/mediatek-thermal.txt
 create mode 100644 Documentation/devicetree/bindings/thermal/mediatek-thermal.yaml
Documentation/devicetree/bindings/thermal/mediatek-thermal.txt deleted +0 -52
deleted file mode 100644
index ac39c7156fde..000000000000
@@ -1,52 +0,0 @@
-* Mediatek Thermal
-
-This describes the device tree binding for the Mediatek thermal controller
-which measures the on-SoC temperatures. This device does not have its own ADC,
-instead it directly controls the AUXADC via AHB bus accesses. For this reason
-this device needs phandles to the AUXADC. Also it controls a mux in the
-apmixedsys register space via AHB bus accesses, so a phandle to the APMIXEDSYS
-is also needed.
-
-Required properties:
-- compatible:
-  - "mediatek,mt8173-thermal" : For MT8173 family of SoCs
-  - "mediatek,mt2701-thermal" : For MT2701 family of SoCs
-  - "mediatek,mt2712-thermal" : For MT2712 family of SoCs
-  - "mediatek,mt7622-thermal" : For MT7622 SoC
-  - "mediatek,mt7981-thermal", "mediatek,mt7986-thermal" : For MT7981 SoC
-  - "mediatek,mt7986-thermal" : For MT7986 SoC
-  - "mediatek,mt8183-thermal" : For MT8183 family of SoCs
-  - "mediatek,mt8365-thermal" : For MT8365 family of SoCs
-  - "mediatek,mt8516-thermal", "mediatek,mt2701-thermal : For MT8516 family of SoCs
-- reg: Address range of the thermal controller
-- interrupts: IRQ for the thermal controller
-- clocks, clock-names: Clocks needed for the thermal controller. required
-                       clocks are:
-		       "therm":	 Main clock needed for register access
-		       "auxadc": The AUXADC clock
-- mediatek,auxadc: A phandle to the AUXADC which the thermal controller uses
-- mediatek,apmixedsys: A phandle to the APMIXEDSYS controller.
-- #thermal-sensor-cells : Should be 0. See Documentation/devicetree/bindings/thermal/thermal-sensor.yaml for a description.
-
-Optional properties:
-- resets: Reference to the reset controller controlling the thermal controller.
-- nvmem-cells: A phandle to the calibration data provided by a nvmem device. If
-               unspecified default values shall be used.
-- nvmem-cell-names: Should be "calibration-data"
-
-Example:
-
-	thermal: thermal@1100b000 {
-		#thermal-sensor-cells = <1>;
-		compatible = "mediatek,mt8173-thermal";
-		reg = <0 0x1100b000 0 0x1000>;
-		interrupts = <0 70 IRQ_TYPE_LEVEL_LOW>;
-		clocks = <&pericfg CLK_PERI_THERM>, <&pericfg CLK_PERI_AUXADC>;
-		clock-names = "therm", "auxadc";
-		resets = <&pericfg MT8173_PERI_THERM_SW_RST>;
-		reset-names = "therm";
-		mediatek,auxadc = <&auxadc>;
-		mediatek,apmixedsys = <&apmixedsys>;
-		nvmem-cells = <&thermal_calibration_data>;
-		nvmem-cell-names = "calibration-data";
-	};
Documentation/devicetree/bindings/thermal/mediatek-thermal.yaml new file +98 -0

98 lines not on this page · raw message

Signature · 1 line
2.35.3
maintainer
#1 lore raw
Quoted 4 lines · Rafał Miłecki

From: Rafał Miłecki <[email protected]>

This helps validating DTS files.

Quoted 8 lines
---
 .../bindings/thermal/mediatek-thermal.txt     | 52 ----------
 .../bindings/thermal/mediatek-thermal.yaml    | 98 +++++++++++++++++++
 2 files changed, 98 insertions(+), 52 deletions(-)
 delete mode 100644 Documentation/devicetree/bindings/thermal/mediatek-thermal.txt
 create mode 100644 Documentation/devicetree/bindings/thermal/mediatek-thermal.yaml

My bot found errors running 'make DT_CHECKER_FLAGS=-m dt_binding_check' on your patch (DT_CHECKER_FLAGS is new in v5.13):

yamllint warnings/errors:

dtschema/dtc warnings/errors:
/builds/robherring/dt-review-ci/linux/Documentation/devicetree/bindings/thermal/mediatek-thermal.yaml: properties:resets: 'Reference to the reset controller controlling the thermal controller.' is not of type 'object', 'boolean'
from schema $id: http://json-schema.org/draft-07/schema#
/builds/robherring/dt-review-ci/linux/Documentation/devicetree/bindings/thermal/mediatek-thermal.yaml: properties:resets: 'Reference to the reset controller controlling the thermal controller.' is not of type 'object', 'boolean'
from schema $id: http://devicetree.org/meta-schemas/keywords.yaml#
/builds/robherring/dt-review-ci/linux/Documentation/devicetree/bindings/thermal/mediatek-thermal.yaml: 'maintainers' is a required property
hint: Metaschema for devicetree binding documentation
from schema $id: http://devicetree.org/meta-schemas/base.yaml#
Traceback (most recent call last):
File "/usr/local/bin/dt-validate", line 8, in <module>

    sys.exit(main())
             ^^^^^^
  File "/usr/local/lib/python3.11/dist-packages/dtschema/dtb_validate.py", line 144, in main
    sg.check_dtb(filename)
  File "/usr/local/lib/python3.11/dist-packages/dtschema/dtb_validate.py", line 89, in check_dtb
    self.check_subtree(dt, subtree, False, "/", "/", filename)
  File "/usr/local/lib/python3.11/dist-packages/dtschema/dtb_validate.py", line 82, in check_subtree
    self.check_subtree(tree, value, disabled, name, fullname + name, filename)
  File "/usr/local/lib/python3.11/dist-packages/dtschema/dtb_validate.py", line 82, in check_subtree
    self.check_subtree(tree, value, disabled, name, fullname + name, filename)
  File "/usr/local/lib/python3.11/dist-packages/dtschema/dtb_validate.py", line 77, in check_subtree
    self.check_node(tree, subtree, disabled, nodename, fullname, filename)
  File "/usr/local/lib/python3.11/dist-packages/dtschema/dtb_validate.py", line 33, in check_node
    for error in self.validator.iter_errors(node, filter=match_schema_file):
  File "/usr/local/lib/python3.11/dist-packages/dtschema/validator.py", line 393, in iter_errors
    for error in self.DtValidator(sch,
  File "/usr/local/lib/python3.11/dist-packages/jsonschema/validators.py", line 288, in iter_errors
    for error in errors:
  File "/usr/local/lib/python3.11/dist-packages/jsonschema/_validators.py", line 414, in if_
    yield from validator.descend(instance, then, schema_path="then")
  File "/usr/local/lib/python3.11/dist-packages/jsonschema/validators.py", line 305, in descend
    for error in self.evolve(schema=schema).iter_errors(instance):
  File "/usr/local/lib/python3.11/dist-packages/jsonschema/validators.py", line 288, in iter_errors
    for error in errors:
  File "/usr/local/lib/python3.11/dist-packages/jsonschema/_validators.py", line 332, in properties
    yield from validator.descend(
  File "/usr/local/lib/python3.11/dist-packages/jsonschema/validators.py", line 305, in descend
    for error in self.evolve(schema=schema).iter_errors(instance):
  File "/usr/local/lib/python3.11/dist-packages/jsonschema/validators.py", line 278, in iter_errors
    scope = id_of(_schema)
            ^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/dist-packages/jsonschema/validators.py", line 101, in _id_of
    return schema.get("$id", "")
           ^^^^^^^^^^

AttributeError: 'str' object has no attribute 'get'

doc reference errors (make refcheckdocs):

See https://patchwork.ozlabs.org/project/devicetree-bindings/patch/[email protected]

The base for the series is generally the latest rc1. A different dependency should be noted in *this* patch.

If you already ran 'make dt_binding_check' and didn't see the above error(s), then make sure 'yamllint' is installed and dt-schema is up to date:

pip3 install dtschema --upgrade

Please check and re-submit after running the above command yourself. Note that DT_SCHEMA_FILES can be set to your schema file to speed up checking your schema. However, it must be unset to test all examples with your schema.

#2 lore raw
In reply to Rafał Miłecki
Quoted 4 lines · Rafał Miłecki

From: Rafał Miłecki <[email protected]>

This helps validating DTS files.

...

mal.yaml b/Documentation/devicetree/bindings/thermal/mediatek-thermal.yaml

Documentation/devicetree/bindings/thermal/mediatek-thermal.yaml

Quoted 4 lines

new file mode 100644
index 000000000000..0e036b22b82b

Documentation/devicetree/bindings/thermal/mediatek-thermal.yaml new file +0 -0

mediatek,thermal.yaml

Documentation/devicetree/bindings/thermal/mediatek-thermal.yaml line 4

Quoted 5 lines
Documentation/devicetree/bindings/thermal/mediatek-thermal.yaml new file +4 -0
@@ -0,0 +1,98 @@
+# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/thermal/mediatek-thermal.yaml#

mediatek,thermal.yaml

Documentation/devicetree/bindings/thermal/mediatek-thermal.yaml line 7

Quoted 3 lines
Documentation/devicetree/bindings/thermal/mediatek-thermal.yaml new file +3 -0
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Mediatek Thermal

SoC? PMIC?

Documentation/devicetree/bindings/thermal/mediatek-thermal.yaml line 9

Quoted 2 lines
Documentation/devicetree/bindings/thermal/mediatek-thermal.yaml new file +2 -0
+
+description: >

Drop >

Documentation/devicetree/bindings/thermal/mediatek-thermal.yaml line 10

Quoted 1 line
Documentation/devicetree/bindings/thermal/mediatek-thermal.yaml new file +1 -0
+  This describes the device tree binding for the Mediatek thermal controller

Drop redundant part. Describe hardware, not the binding. There is no point to say that a binding describes a binding.

Quoted 7 lines
Documentation/devicetree/bindings/thermal/mediatek-thermal.yaml new file +7 -0
+  which measures the on-SoC temperatures. This device does not have its own ADC,
+  instead it directly controls the AUXADC via AHB bus accesses. For this reason
+  this device needs phandles to the AUXADC. Also it controls a mux in the
+  apmixedsys register space via AHB bus accesses, so a phandle to the APMIXEDSYS
+  is also needed.
+
+allOf:

...

Documentation/devicetree/bindings/thermal/mediatek-thermal.yaml line 58

Quoted 10 lines
Documentation/devicetree/bindings/thermal/mediatek-thermal.yaml new file +10 -0
+  mediatek,auxadc:
+    $ref: /schemas/types.yaml#/definitions/phandle
+    description: A phandle to the AUXADC which the thermal controller uses
+
+  mediatek,apmixedsys:
+    $ref: /schemas/types.yaml#/definitions/phandle
+    description: A phandle to the APMIXEDSYS controller
+
+  resets: Reference to the reset controller controlling the thermal controller.
+

Not tested. You miss constraints. Drop totally redundant description.

Documentation/devicetree/bindings/thermal/mediatek-thermal.yaml line 77

Quoted 10 lines
Documentation/devicetree/bindings/thermal/mediatek-thermal.yaml new file +10 -0
+
+unevaluatedProperties: false
+
+required:
+  - reg
+  - interrupts
+  - clocks
+  - clock-names
+  - mediatek,auxadc
+  - mediatek,apmixedsys

unevaluatedProperties go here.

Best regards,
Krzysztof