diff mbox series

[v1,2/4] dt-bindings: can: Add bindings for CAST CAN Controller

Message ID 20240129031239.17037-3-william.qiu@starfivetech.com (mailing list archive)
State Handled Elsewhere
Headers show
Series CAST Controller Area Network driver support | expand

Checks

Context Check Description
conchuod/vmtest-for-next-PR success PR summary
conchuod/patch-2-test-1 success .github/scripts/patches/tests/build_rv32_defconfig.sh
conchuod/patch-2-test-2 success .github/scripts/patches/tests/build_rv64_clang_allmodconfig.sh
conchuod/patch-2-test-3 success .github/scripts/patches/tests/build_rv64_gcc_allmodconfig.sh
conchuod/patch-2-test-4 success .github/scripts/patches/tests/build_rv64_nommu_k210_defconfig.sh
conchuod/patch-2-test-5 success .github/scripts/patches/tests/build_rv64_nommu_virt_defconfig.sh
conchuod/patch-2-test-6 warning .github/scripts/patches/tests/checkpatch.sh
conchuod/patch-2-test-7 success .github/scripts/patches/tests/dtb_warn_rv64.sh
conchuod/patch-2-test-8 success .github/scripts/patches/tests/header_inline.sh
conchuod/patch-2-test-9 success .github/scripts/patches/tests/kdoc.sh
conchuod/patch-2-test-10 success .github/scripts/patches/tests/module_param.sh
conchuod/patch-2-test-11 success .github/scripts/patches/tests/verify_fixes.sh
conchuod/patch-2-test-12 success .github/scripts/patches/tests/verify_signedoff.sh

Commit Message

William Qiu Jan. 29, 2024, 3:12 a.m. UTC
Add bindings for CAST CAN Controller

Signed-off-by: William Qiu <william.qiu@starfivetech.com>
---
 .../devicetree/bindings/net/can/cast,can.yaml | 95 +++++++++++++++++++
 1 file changed, 95 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/net/can/cast,can.yaml

Comments

Conor Dooley Jan. 29, 2024, 3:37 p.m. UTC | #1
Hey William,

On Mon, Jan 29, 2024 at 11:12:37AM +0800, William Qiu wrote:
> Add bindings for CAST CAN Controller
> 
> Signed-off-by: William Qiu <william.qiu@starfivetech.com>
> ---
>  .../devicetree/bindings/net/can/cast,can.yaml | 95 +++++++++++++++++++
>  1 file changed, 95 insertions(+)
>  create mode 100644 Documentation/devicetree/bindings/net/can/cast,can.yaml
> 
> diff --git a/Documentation/devicetree/bindings/net/can/cast,can.yaml b/Documentation/devicetree/bindings/net/can/cast,can.yaml
> new file mode 100644
> index 000000000000..ea52132d9b1c
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/net/can/cast,can.yaml
> @@ -0,0 +1,95 @@
> +# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause
> +%YAML 1.2
> +---
> +$id: http://devicetree.org/schemas/net/can/cast,can.yaml#
> +$schema: http://devicetree.org/meta-schemas/core.yaml#
> +
> +title: CAST CAN controller
> +
> +maintainers:
> +  - William Qiu <william.qiu@starfivetech.com>
> +
> +allOf:
> +  - $ref: can-controller.yaml#
> +  - if:
> +      properties:
> +        compatible:
> +          contains:
> +            const: starfive,can
> +    then:
> +      required:
> +        - starfive,syscon

If you've got property related stuff in the allOf, move it down after
the property definitions.

> +properties:
> +  compatible:
> +    enum:
> +      - cast,can
> +      - cast,canfd

I don't like these uber generic compatibles that have no users as a
fallback. Allowing them in the binding only really discourages people
from creating device specific compatibles.
Secondly, this is some purchased IP that I am sure has a versioning
scheme and the compatibles that you have created do not reflect that.
If they were being used as a fallback, I would request some versioning.
That's not going to really work though since the canfd features on the
jh7110 require setting u0_can_ctrl_can_fd_enable, so neither of these
compatibles really has a use right now.

> +      - starfive,can

Just "starfive,can"? Can you please add device specific compatibles for
the SoCs on which this is used?

> +
> +  reg:
> +    maxItems: 1
> +
> +  interrupts:
> +    maxItems: 1
> +
> +  clocks:
> +    minItems: 3
> +
> +  clock-names:
> +    items:
> +      - const: apb_clk
> +      - const: timer_clk
> +      - const: can_clk

Drop _clk, they're all clocks!

> +
> +  resets:
> +    minItems: 3
> +
> +  reset-names:
> +    items:
> +      - const: rst_apb
> +      - const: rst_core
> +      - const: rst_timer

Same here, drop rst_

> +
> +  starfive,syscon:
> +    $ref: /schemas/types.yaml#/definitions/phandle-array
> +    items:
> +      - items:
> +          - description: phandle to System Register Controller syscon node
> +          - description: offset of SYS_SYSCON_NE__SAIF__SYSCFG register for CAN controller

The docs I have call this register "SYS_SYSCONSAIF__SYSCFG". Did the
names change since the TRM I have was written?

> +          - description: shift of SYS_SYSCON_NE__SAIF__SYSCFG register for CAN controller
> +          - description: mask of SYS_SYSCON_NE__SAIF__SYSCFG register for CAN controller
> +    description:
> +      Should be four parameters, the phandle to System Register Controller
> +      syscon node and the offset/shift/mask of SYS_SYSCON_NE__SAIF__SYSCFG register
> +      for CAN controller.

Cheers,
Conor.
William Qiu Jan. 30, 2024, 6:30 a.m. UTC | #2
> -----Original Message-----
> From: Conor Dooley <conor@kernel.org>
> Sent: 2024年1月29日 23:37
> To: William Qiu <william.qiu@starfivetech.com>
> Cc: devicetree@vger.kernel.org; linux-kernel@vger.kernel.org;
> linux-riscv@lists.infradead.org; linux-can@vger.kernel.org; Emil Renner
> Berthing <kernel@esmil.dk>; Rob Herring <robh+dt@kernel.org>; Wolfgang
> Grandegger <wg@grandegger.com>; Philipp Zabel <p.zabel@pengutronix.de>;
> Krzysztof Kozlowski <krzysztof.kozlowski+dt@linaro.org>; Conor Dooley
> <conor+dt@kernel.org>; Marc Kleine-Budde <mkl@pengutronix.de>; David S .
> Miller <davem@davemloft.net>; Eric Dumazet <edumazet@google.com>;
> Jakub Kicinski <kuba@kernel.org>; Paolo Abeni <pabeni@redhat.com>; Paul
> Walmsley <paul.walmsley@sifive.com>; Palmer Dabbelt
> <palmer@dabbelt.com>; Albert Ou <aou@eecs.berkeley.edu>
> Subject: Re: [PATCH v1 2/4] dt-bindings: can: Add bindings for CAST CAN
> Controller
> 
> Hey William,
> 
> On Mon, Jan 29, 2024 at 11:12:37AM +0800, William Qiu wrote:
> > Add bindings for CAST CAN Controller
> >
> > Signed-off-by: William Qiu <william.qiu@starfivetech.com>
> > ---
> >  .../devicetree/bindings/net/can/cast,can.yaml | 95
> > +++++++++++++++++++
> >  1 file changed, 95 insertions(+)
> >  create mode 100644
> > Documentation/devicetree/bindings/net/can/cast,can.yaml
> >
> > diff --git a/Documentation/devicetree/bindings/net/can/cast,can.yaml
> > b/Documentation/devicetree/bindings/net/can/cast,can.yaml
> > new file mode 100644
> > index 000000000000..ea52132d9b1c
> > --- /dev/null
> > +++ b/Documentation/devicetree/bindings/net/can/cast,can.yaml
> > @@ -0,0 +1,95 @@
> > +# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause %YAML 1.2
> > +---
> > +$id: http://devicetree.org/schemas/net/can/cast,can.yaml#
> > +$schema: http://devicetree.org/meta-schemas/core.yaml#
> > +
> > +title: CAST CAN controller
> > +
> > +maintainers:
> > +  - William Qiu <william.qiu@starfivetech.com>
> > +
> > +allOf:
> > +  - $ref: can-controller.yaml#
> > +  - if:
> > +      properties:
> > +        compatible:
> > +          contains:
> > +            const: starfive,can
> > +    then:
> > +      required:
> > +        - starfive,syscon
> 
> If you've got property related stuff in the allOf, move it down after the property
> definitions.
> 
Will update
> > +properties:
> > +  compatible:
> > +    enum:
> > +      - cast,can
> > +      - cast,canfd
> 
> I don't like these uber generic compatibles that have no users as a fallback.
> Allowing them in the binding only really discourages people from creating device
> specific compatibles.
> Secondly, this is some purchased IP that I am sure has a versioning scheme and
> the compatibles that you have created do not reflect that.
> If they were being used as a fallback, I would request some versioning.
> That's not going to really work though since the canfd features on the
> jh7110 require setting u0_can_ctrl_can_fd_enable, so neither of these
> compatibles really has a use right now.
> 
I'll add some tag to do versioning.
> > +      - starfive,can
> 
> Just "starfive,can"? Can you please add device specific compatibles for the SoCs
> on which this is used?
> 
Will add.
> > +
> > +  reg:
> > +    maxItems: 1
> > +
> > +  interrupts:
> > +    maxItems: 1
> > +
> > +  clocks:
> > +    minItems: 3
> > +
> > +  clock-names:
> > +    items:
> > +      - const: apb_clk
> > +      - const: timer_clk
> > +      - const: can_clk
> 
> Drop _clk, they're all clocks!
> 
Will drop.
> > +
> > +  resets:
> > +    minItems: 3
> > +
> > +  reset-names:
> > +    items:
> > +      - const: rst_apb
> > +      - const: rst_core
> > +      - const: rst_timer
> 
> Same here, drop rst_
>Will drop.
> > +
> > +  starfive,syscon:
> > +    $ref: /schemas/types.yaml#/definitions/phandle-array
> > +    items:
> > +      - items:
> > +          - description: phandle to System Register Controller syscon node
> > +          - description: offset of SYS_SYSCON_NE__SAIF__SYSCFG
> > + register for CAN controller
> 
> The docs I have call this register "SYS_SYSCONSAIF__SYSCFG". Did the names
> change since the TRM I have was written?
> 
They do change on the 8100 SoC.
Other descriptions may be needed for compatibility. I'll think about it.

Thanks,
William
> > +          - description: shift of SYS_SYSCON_NE__SAIF__SYSCFG register
> for CAN controller
> > +          - description: mask of SYS_SYSCON_NE__SAIF__SYSCFG register
> for CAN controller
> > +    description:
> > +      Should be four parameters, the phandle to System Register Controller
> > +      syscon node and the offset/shift/mask of
> SYS_SYSCON_NE__SAIF__SYSCFG register
> > +      for CAN controller.
> 
> Cheers,
> Conor.
Conor Dooley Jan. 30, 2024, 5:02 p.m. UTC | #3
On Tue, Jan 30, 2024 at 06:30:54AM +0000, William Qiu wrote:
> > From: Conor Dooley <conor@kernel.org>
> > On Mon, Jan 29, 2024 at 11:12:37AM +0800, William Qiu wrote:

> > > +properties:
> > > +  compatible:
> > > +    enum:
> > > +      - cast,can
> > > +      - cast,canfd
> > 
> > I don't like these uber generic compatibles that have no users as a fallback.
> > Allowing them in the binding only really discourages people from creating device
> > specific compatibles.
> > Secondly, this is some purchased IP that I am sure has a versioning scheme and
> > the compatibles that you have created do not reflect that.
> > If they were being used as a fallback, I would request some versioning.
> > That's not going to really work though since the canfd features on the
> > jh7110 require setting u0_can_ctrl_can_fd_enable, so neither of these
> > compatibles really has a use right now.
> > 
> I'll add some tag to do versioning.

I don't want to see a "cast,can-<something>" compatible allowed in
isolation either as there is no user for it.
The generic compatibles like that should only be permitted in
combination with a device specific one - particularly since there are
bits in implementation defined registers that control whether or not
canfd is enabled.
diff mbox series

Patch

diff --git a/Documentation/devicetree/bindings/net/can/cast,can.yaml b/Documentation/devicetree/bindings/net/can/cast,can.yaml
new file mode 100644
index 000000000000..ea52132d9b1c
--- /dev/null
+++ b/Documentation/devicetree/bindings/net/can/cast,can.yaml
@@ -0,0 +1,95 @@ 
+# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/net/can/cast,can.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: CAST CAN controller
+
+maintainers:
+  - William Qiu <william.qiu@starfivetech.com>
+
+allOf:
+  - $ref: can-controller.yaml#
+  - if:
+      properties:
+        compatible:
+          contains:
+            const: starfive,can
+    then:
+      required:
+        - starfive,syscon
+
+properties:
+  compatible:
+    enum:
+      - cast,can
+      - cast,canfd
+      - starfive,can
+
+  reg:
+    maxItems: 1
+
+  interrupts:
+    maxItems: 1
+
+  clocks:
+    minItems: 3
+
+  clock-names:
+    items:
+      - const: apb_clk
+      - const: timer_clk
+      - const: can_clk
+
+  resets:
+    minItems: 3
+
+  reset-names:
+    items:
+      - const: rst_apb
+      - const: rst_core
+      - const: rst_timer
+
+  starfive,syscon:
+    $ref: /schemas/types.yaml#/definitions/phandle-array
+    items:
+      - items:
+          - description: phandle to System Register Controller syscon node
+          - description: offset of SYS_SYSCON_NE__SAIF__SYSCFG register for CAN controller
+          - description: shift of SYS_SYSCON_NE__SAIF__SYSCFG register for CAN controller
+          - description: mask of SYS_SYSCON_NE__SAIF__SYSCFG register for CAN controller
+    description:
+      Should be four parameters, the phandle to System Register Controller
+      syscon node and the offset/shift/mask of SYS_SYSCON_NE__SAIF__SYSCFG register
+      for CAN controller.
+
+required:
+  - compatible
+  - reg
+  - interrupts
+  - clocks
+  - clock-names
+  - resets
+  - reset-names
+
+additionalProperties: false
+
+examples:
+  - |
+    can@130d0000{
+        compatible = "starfive,can";
+        reg = <0x130d0000 0x1000>;
+        interrupts = <112>;
+        clocks = <&syscrg 115>,
+                 <&syscrg 116>,
+                 <&syscrg 117>;
+        clock-names = "apb_clk", "timer_clk", "can_clk";
+        resets = <&syscrg 111>,
+                 <&syscrg 112>,
+                 <&syscrg 113>;
+        reset-names = "rst_apb", "rst_core", "rst_timer";
+        starfive,syscon = <&sys_syscon 0x10 0x3 0x8>;
+    };
+
+...