]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
virtio: Add a block device
authorSimon Glass <sjg@chromium.org>
Tue, 17 Jan 2023 17:47:51 +0000 (10:47 -0700)
committerTom Rini <trini@konsulko.com>
Mon, 23 Jan 2023 23:11:40 +0000 (18:11 -0500)
The test code for virtio is fairly simplistic and does not actually create
a block device. Add a way to specify the device type in the device tree.
Add a block device so that we can do more testing.

Signed-off-by: Simon Glass <sjg@chromium.org>
arch/sandbox/dts/test.dts
drivers/virtio/virtio_sandbox.c

index 2e580f980fc6f924ba779f120aaa1dc34d2958fd..9d96e479ca82a180cb0cb1ae5af026efc4f52f6a 100644 (file)
 
        sandbox_virtio1 {
                compatible = "sandbox,virtio1";
+               virtio-type = <4>;      /* rng */
        };
 
        sandbox_virtio2 {
                compatible = "sandbox,virtio2";
        };
 
+       sandbox-virtio-blk {
+               compatible = "sandbox,virtio1";
+               virtio-type = <2>;      /* block */
+       };
+
        sandbox_scmi {
                compatible = "sandbox,scmi-devices";
                clocks = <&clk_scmi 2>, <&clk_scmi 0>;
index cf7761c75ee9f4c830c2ca0e62b8dafbfebe7a99..b34f1d60455e554cb3b2ddf0b7fd0bd357c9b163 100644 (file)
@@ -161,7 +161,8 @@ static int virtio_sandbox_probe(struct udevice *udev)
 
        /* fake some information for testing */
        priv->device_features = BIT_ULL(VIRTIO_F_VERSION_1);
-       uc_priv->device = VIRTIO_ID_RNG;
+       uc_priv->device = dev_read_u32_default(udev, "virtio-type",
+                                              VIRTIO_ID_RNG);
        uc_priv->vendor = ('u' << 24) | ('b' << 16) | ('o' << 8) | 't';
 
        return 0;