2021-07-22 09:58:11

by Viresh Kumar

[permalink] [raw]
Subject: [PATCH V2 1/5] dt-bindings: virtio: Add binding for virtio devices

Allow virtio device sub-nodes to be added to the virtio mmio or pci
nodes. The compatible property for virtio device must be of format
"virtio,<DID>", where DID is virtio device ID in hexadecimal format.

Signed-off-by: Viresh Kumar <[email protected]>
---
.../devicetree/bindings/virtio/mmio.yaml | 2 +-
.../bindings/virtio/virtio-device.yaml | 47 +++++++++++++++++++
2 files changed, 48 insertions(+), 1 deletion(-)
create mode 100644 Documentation/devicetree/bindings/virtio/virtio-device.yaml

diff --git a/Documentation/devicetree/bindings/virtio/mmio.yaml b/Documentation/devicetree/bindings/virtio/mmio.yaml
index d46597028cf1..1b91553f87c6 100644
--- a/Documentation/devicetree/bindings/virtio/mmio.yaml
+++ b/Documentation/devicetree/bindings/virtio/mmio.yaml
@@ -36,7 +36,7 @@ title: virtio memory mapped devices
- reg
- interrupts

-additionalProperties: false
+additionalProperties: true

examples:
- |
diff --git a/Documentation/devicetree/bindings/virtio/virtio-device.yaml b/Documentation/devicetree/bindings/virtio/virtio-device.yaml
new file mode 100644
index 000000000000..15cb6df8c98a
--- /dev/null
+++ b/Documentation/devicetree/bindings/virtio/virtio-device.yaml
@@ -0,0 +1,47 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/virtio/virtio-device.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Virtio device bindings
+
+maintainers:
+ - Viresh Kumar <[email protected]>
+
+description:
+ These bindings are applicable to virtio devices irrespective of the bus they
+ are bound to, like mmio or pci.
+
+# We need a select here so we don't match all nodes with 'virtio,mmio'
+properties:
+ $nodename:
+ pattern: '^[a-z0-9]+-virtio(-[a-z0-9]+)?$'
+ description: |
+ Exactly one node describing the virtio device. The name of the node isn't
+ significant but its phandle can be used to by a user of the virtio device.
+
+ compatible:
+ pattern: "^virtio,[0-9a-f]+$"
+ description: Virtio device nodes.
+ "virtio,DID", where DID is the virtio device id. The textual
+ representation of DID shall be in lower case hexadecimal with leading
+ zeroes suppressed.
+
+required:
+ - compatible
+
+additionalProperties: true
+
+examples:
+ - |
+ virtio@3000 {
+ compatible = "virtio,mmio";
+ reg = <0x3000 0x100>;
+ interrupts = <43>;
+
+ i2c-virtio {
+ compatible = "virtio,22";
+ };
+ };
+...
--
2.31.1.272.g89b43f80a514


2021-07-22 10:31:14

by Arnd Bergmann

[permalink] [raw]
Subject: Re: [PATCH V2 1/5] dt-bindings: virtio: Add binding for virtio devices

On Thu, Jul 22, 2021 at 11:57 AM Viresh Kumar <[email protected]> wrote:
>
> Allow virtio device sub-nodes to be added to the virtio mmio or pci
> nodes. The compatible property for virtio device must be of format
> "virtio,<DID>", where DID is virtio device ID in hexadecimal format.
>
> Signed-off-by: Viresh Kumar <[email protected]>

Looks good to me overall. One question would be for the exact format of
the 'compatible' string. After seeing this version, I would slightly prefer
"virtio,device22" over "virtio,22". I think in the previous version
we had mentioned both, but not actually decided on which one to use.

Arnd

2021-07-22 10:33:20

by Viresh Kumar

[permalink] [raw]
Subject: Re: [PATCH V2 1/5] dt-bindings: virtio: Add binding for virtio devices

On 22-07-21, 12:28, Arnd Bergmann wrote:
> On Thu, Jul 22, 2021 at 11:57 AM Viresh Kumar <[email protected]> wrote:
> >
> > Allow virtio device sub-nodes to be added to the virtio mmio or pci
> > nodes. The compatible property for virtio device must be of format
> > "virtio,<DID>", where DID is virtio device ID in hexadecimal format.
> >
> > Signed-off-by: Viresh Kumar <[email protected]>
>
> Looks good to me overall. One question would be for the exact format of
> the 'compatible' string. After seeing this version, I would slightly prefer
> "virtio,device22" over "virtio,22". I think in the previous version
> we had mentioned both, but not actually decided on which one to use.

Right, so there were few doubts I had.
- Should I use "device" as well or not.
- Should I use hex value or decimal.

I went with what's already done with USB/PCI, and so dropped device
and used hex values.

I don't have any strong opinions about using or dropping "device", I
am fine with whatever You/Rob suggest.

--
viresh