riscv: qemu: Enable usb keyboard as an input device
authorBin Meng <bmeng@tinylab.org>
Sun, 23 Jul 2023 04:40:41 +0000 (12:40 +0800)
committerLeo Yu-Chi Liang <ycliang@andestech.com>
Wed, 2 Aug 2023 08:32:44 +0000 (16:32 +0800)
This brings PCI xHCI support to QEMU RISC-V and uses a usb keyboard
as one of the input devices.

Signed-off-by: Bin Meng <bmeng@tinylab.org>
Reviewed-by: Rick Chen <rick@andestech.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
board/emulation/qemu-riscv/Kconfig
board/emulation/qemu-riscv/qemu-riscv.c
doc/board/emulation/qemu-riscv.rst
include/configs/qemu-riscv.h

index 7220c55..b503578 100644 (file)
@@ -76,5 +76,10 @@ config BOARD_SPECIFIC_OPTIONS # dummy
        imply VIDEO_BOCHS
        imply SYS_WHITE_ON_BLACK
        imply PRE_CONSOLE_BUFFER
+       imply USB
+       imply USB_XHCI_HCD
+       imply USB_XHCI_PCI
+       imply USB_KEYBOARD
+       imply CMD_USB
 
 endif
index f39f3be..181abbb 100644 (file)
@@ -12,6 +12,7 @@
 #include <log.h>
 #include <spl.h>
 #include <init.h>
+#include <usb.h>
 #include <virtio_types.h>
 #include <virtio.h>
 
@@ -41,6 +42,10 @@ int board_init(void)
 
 int board_late_init(void)
 {
+       /* start usb so that usb keyboard can be used as input device */
+       if (CONFIG_IS_ENABLED(USB_KEYBOARD))
+               usb_init();
+
        return 0;
 }
 
index 9d21f32..61137bc 100644 (file)
@@ -138,6 +138,11 @@ and adding::
 
     -serial stdio -device VGA
 
+In addition, a usb keyboard can be attached to an emulated xHCI controller in
+RISC-V virt machine as an option of input devices by adding::
+
+    -device qemu-xhci,id=xhci -device usb-kbd,bus=xhci.0
+
 Running with KVM
 ----------------
 
index d5146e7..584559c 100644 (file)
@@ -17,7 +17,7 @@
 
 /* Environment options */
 
-#define CFG_STD_DEVICES_SETTINGS       "stdin=serial\0" \
+#define CFG_STD_DEVICES_SETTINGS       "stdin=serial,usbkbd\0" \
                                        "stdout=serial,vidconsole\0" \
                                        "stderr=serial,vidconsole\0"