diff mbox series

[v2,4/8] dt-bindings: timer: Add schema for realtek,otto-timer

Message ID 20240624012300.1713290-5-chris.packham@alliedtelesis.co.nz (mailing list archive)
State Superseded
Headers show
Series mips: Support for RTL9302C | expand

Commit Message

Chris Packham June 24, 2024, 1:22 a.m. UTC
Add the devicetree schema for the realtek,otto-timer present on a number
of Realtek SoCs.

Signed-off-by: Chris Packham <chris.packham@alliedtelesis.co.nz>
---

Notes:
    Changes in v2:
    - Use specific compatible
    - Remove unnecessary label
    - Remove unused irq flags (interrupt controller is one-cell)
    - Set minItems for reg and interrupts based on compatible

 .../bindings/timer/realtek,otto-timer.yaml    | 66 +++++++++++++++++++
 1 file changed, 66 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/timer/realtek,otto-timer.yaml

Comments

Krzysztof Kozlowski June 24, 2024, 4:49 a.m. UTC | #1
On 24/06/2024 03:22, Chris Packham wrote:
> Add the devicetree schema for the realtek,otto-timer present on a number
> of Realtek SoCs.
> 
> Signed-off-by: Chris Packham <chris.packham@alliedtelesis.co.nz>
> ---
> 
> Notes:
>     Changes in v2:
>     - Use specific compatible

Where? I do not see changes.

>     - Remove unnecessary label
>     - Remove unused irq flags (interrupt controller is one-cell)
>     - Set minItems for reg and interrupts based on compatible
> 
>  .../bindings/timer/realtek,otto-timer.yaml    | 66 +++++++++++++++++++
>  1 file changed, 66 insertions(+)
>  create mode 100644 Documentation/devicetree/bindings/timer/realtek,otto-timer.yaml
> 
> diff --git a/Documentation/devicetree/bindings/timer/realtek,otto-timer.yaml b/Documentation/devicetree/bindings/timer/realtek,otto-timer.yaml
> new file mode 100644
> index 000000000000..13ea7aa946fe
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/timer/realtek,otto-timer.yaml
> @@ -0,0 +1,66 @@
> +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
> +%YAML 1.2
> +---
> +$id: http://devicetree.org/schemas/timer/realtek,otto-timer.yaml#
> +$schema: http://devicetree.org/meta-schemas/core.yaml#
> +
> +title: Realtek Otto SoCs Timer/Counter
> +
> +description:
> +  Realtek SoCs support a number of timers/counters. These are used
> +  as a per CPU clock event generator and an overall CPU clocksource.
> +
> +maintainers:
> +  - Chris Packham <chris.packham@alliedtelesis.co.nz>
> +
> +properties:
> +  $nodename:
> +    pattern: "^timer@[0-9a-f]+$"
> +
> +  compatible:
> +    items:
> +      - enum:
> +          - realtek,rtl9302-timer
> +      - const: realtek,otto-timer
> +
> +  reg:
> +    maxItems: 5

Nothing improved.

> +
> +  clocks:
> +    maxItems: 1
> +
> +  interrupts:
> +    maxItems: 5

Nothing improved.

> +
> +allOf:
> +  - if:
> +      properties:
> +        compatible:
> +          contains:
> +            const: realtek,rtl9302-timer
> +    then:
> +      properties:
> +        reg:
> +          minItems: 2
> +        interrupts:
> +          minItems: 2

No, that's just incorrect. You do not have more than one variant, so it
is just 2 items. Or 5 items, not 2-5.


Best regards,
Krzysztof
Chris Packham June 24, 2024, 5:21 a.m. UTC | #2
On 24/06/24 16:49, Krzysztof Kozlowski wrote:
> On 24/06/2024 03:22, Chris Packham wrote:
>> Add the devicetree schema for the realtek,otto-timer present on a number
>> of Realtek SoCs.
>>
>> Signed-off-by: Chris Packham <chris.packham@alliedtelesis.co.nz>
>> ---
>>
>> Notes:
>>      Changes in v2:
>>      - Use specific compatible
> Where? I do not see changes.

In v1 it was rtl930x-timer, I've updated it to rtl9302-timer

>>      - Remove unnecessary label
>>      - Remove unused irq flags (interrupt controller is one-cell)
>>      - Set minItems for reg and interrupts based on compatible
>>
>>   .../bindings/timer/realtek,otto-timer.yaml    | 66 +++++++++++++++++++
>>   1 file changed, 66 insertions(+)
>>   create mode 100644 Documentation/devicetree/bindings/timer/realtek,otto-timer.yaml
>>
>> diff --git a/Documentation/devicetree/bindings/timer/realtek,otto-timer.yaml b/Documentation/devicetree/bindings/timer/realtek,otto-timer.yaml
>> new file mode 100644
>> index 000000000000..13ea7aa946fe
>> --- /dev/null
>> +++ b/Documentation/devicetree/bindings/timer/realtek,otto-timer.yaml
>> @@ -0,0 +1,66 @@
>> +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
>> +%YAML 1.2
>> +---
>> +$id: http://devicetree.org/schemas/timer/realtek,otto-timer.yaml#
>> +$schema: http://devicetree.org/meta-schemas/core.yaml#
>> +
>> +title: Realtek Otto SoCs Timer/Counter
>> +
>> +description:
>> +  Realtek SoCs support a number of timers/counters. These are used
>> +  as a per CPU clock event generator and an overall CPU clocksource.
>> +
>> +maintainers:
>> +  - Chris Packham <chris.packham@alliedtelesis.co.nz>
>> +
>> +properties:
>> +  $nodename:
>> +    pattern: "^timer@[0-9a-f]+$"
>> +
>> +  compatible:
>> +    items:
>> +      - enum:
>> +          - realtek,rtl9302-timer
>> +      - const: realtek,otto-timer
>> +
>> +  reg:
>> +    maxItems: 5
> Nothing improved.
>
>> +
>> +  clocks:
>> +    maxItems: 1
>> +
>> +  interrupts:
>> +    maxItems: 5
> Nothing improved.
>
>> +
>> +allOf:
>> +  - if:
>> +      properties:
>> +        compatible:
>> +          contains:
>> +            const: realtek,rtl9302-timer
>> +    then:
>> +      properties:
>> +        reg:
>> +          minItems: 2
>> +        interrupts:
>> +          minItems: 2
> No, that's just incorrect. You do not have more than one variant, so it
> is just 2 items. Or 5 items, not 2-5.

I've been told in the past that the device-tree should describe the 
hardware. Which in this case has 5 timers. But I'm also told to give 
them names which I struggle to do because some of them aren't used.

So do you want something like this:

clocks:
     items:
         - description: CPU0 event clock
         - description: system clock source
         - description: unused
         - description: unused
         - description: unused

interrupts:
     items:
         - description: CPU0 event clock interrupt
         - description: system clock source interrupt
         - description: unused
         - description: unused
         - description: unused

>
>
> Best regards,
> Krzysztof
>
>
Krzysztof Kozlowski June 26, 2024, 7:13 a.m. UTC | #3
On 24/06/2024 07:21, Chris Packham wrote:
> 
> On 24/06/24 16:49, Krzysztof Kozlowski wrote:
>> On 24/06/2024 03:22, Chris Packham wrote:
>>> Add the devicetree schema for the realtek,otto-timer present on a number
>>> of Realtek SoCs.
>>>
>>> Signed-off-by: Chris Packham <chris.packham@alliedtelesis.co.nz>
>>> ---
>>>
>>> Notes:
>>>      Changes in v2:
>>>      - Use specific compatible
>> Where? I do not see changes.
> 
> In v1 it was rtl930x-timer, I've updated it to rtl9302-timer

Ah, I thought you wanted to switch from generic fallback to specific
compatible... fine.

> 
>>>      - Remove unnecessary label
>>>      - Remove unused irq flags (interrupt controller is one-cell)
>>>      - Set minItems for reg and interrupts based on compatible
>>>
>>>   .../bindings/timer/realtek,otto-timer.yaml    | 66 +++++++++++++++++++
>>>   1 file changed, 66 insertions(+)
>>>   create mode 100644 Documentation/devicetree/bindings/timer/realtek,otto-timer.yaml
>>>
>>> diff --git a/Documentation/devicetree/bindings/timer/realtek,otto-timer.yaml b/Documentation/devicetree/bindings/timer/realtek,otto-timer.yaml
>>> new file mode 100644
>>> index 000000000000..13ea7aa946fe
>>> --- /dev/null
>>> +++ b/Documentation/devicetree/bindings/timer/realtek,otto-timer.yaml
>>> @@ -0,0 +1,66 @@
>>> +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
>>> +%YAML 1.2
>>> +---
>>> +$id: http://devicetree.org/schemas/timer/realtek,otto-timer.yaml#
>>> +$schema: http://devicetree.org/meta-schemas/core.yaml#
>>> +
>>> +title: Realtek Otto SoCs Timer/Counter
>>> +
>>> +description:
>>> +  Realtek SoCs support a number of timers/counters. These are used
>>> +  as a per CPU clock event generator and an overall CPU clocksource.
>>> +
>>> +maintainers:
>>> +  - Chris Packham <chris.packham@alliedtelesis.co.nz>
>>> +
>>> +properties:
>>> +  $nodename:
>>> +    pattern: "^timer@[0-9a-f]+$"
>>> +
>>> +  compatible:
>>> +    items:
>>> +      - enum:
>>> +          - realtek,rtl9302-timer
>>> +      - const: realtek,otto-timer
>>> +
>>> +  reg:
>>> +    maxItems: 5
>> Nothing improved.
>>
>>> +
>>> +  clocks:
>>> +    maxItems: 1
>>> +
>>> +  interrupts:
>>> +    maxItems: 5
>> Nothing improved.
>>
>>> +
>>> +allOf:
>>> +  - if:
>>> +      properties:
>>> +        compatible:
>>> +          contains:
>>> +            const: realtek,rtl9302-timer
>>> +    then:
>>> +      properties:
>>> +        reg:
>>> +          minItems: 2
>>> +        interrupts:
>>> +          minItems: 2
>> No, that's just incorrect. You do not have more than one variant, so it
>> is just 2 items. Or 5 items, not 2-5.
> 
> I've been told in the past that the device-tree should describe the 
> hardware. Which in this case has 5 timers. But I'm also told to give 
> them names which I struggle to do because some of them aren't used.

Used as in Linux driver? Does not matter.

> 
> So do you want something like this:
> 
> clocks:
>      items:
>          - description: CPU0 event clock
>          - description: system clock source
>          - description: unused
>          - description: unused
>          - description: unused

No, if your datasheet or any other source of information (e.g.
downstream sources) mention 5 items, then name properly 5 items.
Otherwise how do you know that there are 5, not 2, clocks/interrupts/reg?

Best regards,
Krzysztof
Chris Packham June 26, 2024, 9:07 p.m. UTC | #4
On 26/06/24 19:13, Krzysztof Kozlowski wrote:
> On 24/06/2024 07:21, Chris Packham wrote:
>> On 24/06/24 16:49, Krzysztof Kozlowski wrote:
>>> On 24/06/2024 03:22, Chris Packham wrote:
>>>> Add the devicetree schema for the realtek,otto-timer present on a number
>>>> of Realtek SoCs.
>>>>
>>>> Signed-off-by: Chris Packham <chris.packham@alliedtelesis.co.nz>
>>>> ---
>>>>
>>>> Notes:
>>>>       Changes in v2:
>>>>       - Use specific compatible
>>> Where? I do not see changes.
>> In v1 it was rtl930x-timer, I've updated it to rtl9302-timer
> Ah, I thought you wanted to switch from generic fallback to specific
> compatible... fine.
>
>>>>       - Remove unnecessary label
>>>>       - Remove unused irq flags (interrupt controller is one-cell)
>>>>       - Set minItems for reg and interrupts based on compatible
>>>>
>>>>    .../bindings/timer/realtek,otto-timer.yaml    | 66 +++++++++++++++++++
>>>>    1 file changed, 66 insertions(+)
>>>>    create mode 100644 Documentation/devicetree/bindings/timer/realtek,otto-timer.yaml
>>>>
>>>> diff --git a/Documentation/devicetree/bindings/timer/realtek,otto-timer.yaml b/Documentation/devicetree/bindings/timer/realtek,otto-timer.yaml
>>>> new file mode 100644
>>>> index 000000000000..13ea7aa946fe
>>>> --- /dev/null
>>>> +++ b/Documentation/devicetree/bindings/timer/realtek,otto-timer.yaml
>>>> @@ -0,0 +1,66 @@
>>>> +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
>>>> +%YAML 1.2
>>>> +---
>>>> +$id: http://devicetree.org/schemas/timer/realtek,otto-timer.yaml#
>>>> +$schema: http://devicetree.org/meta-schemas/core.yaml#
>>>> +
>>>> +title: Realtek Otto SoCs Timer/Counter
>>>> +
>>>> +description:
>>>> +  Realtek SoCs support a number of timers/counters. These are used
>>>> +  as a per CPU clock event generator and an overall CPU clocksource.
>>>> +
>>>> +maintainers:
>>>> +  - Chris Packham <chris.packham@alliedtelesis.co.nz>
>>>> +
>>>> +properties:
>>>> +  $nodename:
>>>> +    pattern: "^timer@[0-9a-f]+$"
>>>> +
>>>> +  compatible:
>>>> +    items:
>>>> +      - enum:
>>>> +          - realtek,rtl9302-timer
>>>> +      - const: realtek,otto-timer
>>>> +
>>>> +  reg:
>>>> +    maxItems: 5
>>> Nothing improved.
>>>
>>>> +
>>>> +  clocks:
>>>> +    maxItems: 1
>>>> +
>>>> +  interrupts:
>>>> +    maxItems: 5
>>> Nothing improved.
>>>
>>>> +
>>>> +allOf:
>>>> +  - if:
>>>> +      properties:
>>>> +        compatible:
>>>> +          contains:
>>>> +            const: realtek,rtl9302-timer
>>>> +    then:
>>>> +      properties:
>>>> +        reg:
>>>> +          minItems: 2
>>>> +        interrupts:
>>>> +          minItems: 2
>>> No, that's just incorrect. You do not have more than one variant, so it
>>> is just 2 items. Or 5 items, not 2-5.
>> I've been told in the past that the device-tree should describe the
>> hardware. Which in this case has 5 timers. But I'm also told to give
>> them names which I struggle to do because some of them aren't used.
> Used as in Linux driver? Does not matter.
>
>> So do you want something like this:
>>
>> clocks:
>>       items:
>>           - description: CPU0 event clock
>>           - description: system clock source
>>           - description: unused
>>           - description: unused
>>           - description: unused
> No, if your datasheet or any other source of information (e.g.
> downstream sources) mention 5 items, then name properly 5 items.
> Otherwise how do you know that there are 5, not 2, clocks/interrupts/reg?

So just timer0, timer2, ... timer5?
diff mbox series

Patch

diff --git a/Documentation/devicetree/bindings/timer/realtek,otto-timer.yaml b/Documentation/devicetree/bindings/timer/realtek,otto-timer.yaml
new file mode 100644
index 000000000000..13ea7aa946fe
--- /dev/null
+++ b/Documentation/devicetree/bindings/timer/realtek,otto-timer.yaml
@@ -0,0 +1,66 @@ 
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/timer/realtek,otto-timer.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Realtek Otto SoCs Timer/Counter
+
+description:
+  Realtek SoCs support a number of timers/counters. These are used
+  as a per CPU clock event generator and an overall CPU clocksource.
+
+maintainers:
+  - Chris Packham <chris.packham@alliedtelesis.co.nz>
+
+properties:
+  $nodename:
+    pattern: "^timer@[0-9a-f]+$"
+
+  compatible:
+    items:
+      - enum:
+          - realtek,rtl9302-timer
+      - const: realtek,otto-timer
+
+  reg:
+    maxItems: 5
+
+  clocks:
+    maxItems: 1
+
+  interrupts:
+    maxItems: 5
+
+allOf:
+  - if:
+      properties:
+        compatible:
+          contains:
+            const: realtek,rtl9302-timer
+    then:
+      properties:
+        reg:
+          minItems: 2
+        interrupts:
+          minItems: 2
+
+required:
+  - compatible
+  - reg
+  - clocks
+  - interrupts
+
+additionalProperties: false
+
+examples:
+  - |
+    timer@3200 {
+      compatible = "realtek,rtl9302-timer", "realtek,otto-timer";
+      reg = <0x3200 0x10>, <0x3210 0x10>, <0x3220 0x10>,
+            <0x3230 0x10>, <0x3240 0x10>;
+
+      interrupt-parent = <&intc>;
+      interrupts = <7>, <8>, <9>, <10>, <11>;
+      clocks = <&lx_clk>;
+    };