Re: [Stratos-dev] [PATCH V3 1/3] gpio: Add virtio-gpio driver

From: Vincent Guittot
Date: Mon Jun 14 2021 - 09:26:04 EST


On Mon, 14 Jun 2021 at 15:00, Arnd Bergmann <arnd@xxxxxxxxxx> wrote:
>
> On Mon, Jun 14, 2021 at 2:50 PM Vincent Guittot via Stratos-dev
> <stratos-dev@xxxxxxxxxxxxxxxxxxx> wrote:>
> > On Mon, 14 Jun 2021 at 14:33, Arnd Bergmann <arnd@xxxxxxxxxx> wrote:
> > > On Mon, Jun 14, 2021 at 12:23 PM Viresh Kumar <viresh.kumar@xxxxxxxxxx> wrote:
> > >
> > > I think most importantly we need a DT binding to describe what device
> > > nodes are supposed to look like underneath a virtio-mmio or
> > > virtio-pci device in order for a hypervisor to pass down the
> > > information to a guest OS in a generic way. We can probably borrow
> > > the USB naming, and replace compatible="usbVID,PID" with
> > > compatible="virtioDID", with the device ID in hexadecimal digits,
> > > such as "virtio22" for I2C (virtio device ID 34 == 0x22) if we decide
> > > to have a sub-node under the device, or we just point dev->of_node
> > > of the virtio device to the platform/pci device that is its parent
> > > in Linux.
> > >
> > > Adding the Linux guest code to the virtio layer should be fairly
> > > straightforward, and I suppose it could be mostly copied from the
> > > corresponding code that added this for mmc in commit 25185f3f31c9
> > > ("mmc: Add SDIO function devicetree subnode parsing") and for USB
> > > in commit 69bec7259853 ("USB: core: let USB device know device
> > > node") and 1a7e3948cb9f ("USB: add device-tree support for
> > > interfaces").
> >
> > And something similar is also done with SCMI protocols which are
> > defined in a SCMI node. A typical example:
> >
> > cpu@0 {
> > ...
> > clocks = <&scmi_dvfs 0>;
> > ...
> > };
> >
> > deviceX: deviceX@YYYYYYY {
> > ...
> > clocks = <&scmi_clk 0>;
> > ...
> > };
> >
> > scmi: scmi {
> > compatible = "arm,scmi-virtio";
> > #address-cells = <1>;
> > #size-cells = <0>;
> >
> > scmi_devpd: protocol@11 {
> > reg = <0x11>;
> > #power-domain-cells = <1>;
> > };
> >
> > scmi_clk: protocol@14 {
> > reg = <0x14>;
> > #clock-cells = <1>;
> > };
> >
> > scmi_sensors: protocol@15 {
> > reg = <0x15>;
> > #thermal-sensor-cells = <1>;
> > };
> >
> > scmi_dvfs: protocol@13 {
> > reg = <0x13>;
> > #clock-cells = <1>;
> > };
> > };
>
> But this example seem to be completely different from the ones I mentioned:
> The scmi node that you have here looks like it shows up under the root of the
> device tree, not below the virtio device that implements the scmi transport.

I was thinking of something like below:

deviceX: deviceX@YYYYYYY {
...
gpio = <&virtio_gpio 0>;
...
};

virtio_mmio@a000000 {
dma-coherent;
interrupts = <0x0 0x10 0x1>;
reg = <0x0 0xa000000 0x0 0x200>;
compatible = "virtio,mmio";

virtio_gpio: protocol@22 {
reg = <0x22>;
};
};

>
> Arnd