[PATCH 18/18] riscv: qemu: Enable usb keyboard as an input device

Heinrich Schuchardt xypron.glpk at gmx.de
Sun Jul 23 08:11:19 CEST 2023



Am 23. Juli 2023 06:40:41 MESZ schrieb Bin Meng <bmeng at tinylab.org>:
>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 at tinylab.org>
>
>---
>
> board/emulation/qemu-riscv/Kconfig      | 5 +++++
> board/emulation/qemu-riscv/qemu-riscv.c | 5 +++++
> doc/board/emulation/qemu-riscv.rst      | 5 +++++
> include/configs/qemu-riscv.h            | 2 +-
> 4 files changed, 16 insertions(+), 1 deletion(-)
>
>diff --git a/board/emulation/qemu-riscv/Kconfig b/board/emulation/qemu-riscv/Kconfig
>index 7220c55350..b503578d27 100644
>--- a/board/emulation/qemu-riscv/Kconfig
>+++ b/board/emulation/qemu-riscv/Kconfig
>@@ -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

QEMU could alternatively use EHCI or OHCI for the keyboard. Does enabling XHCI add support for these too?

Best regards

Heinrich 

>+	imply USB_KEYBOARD
>+	imply CMD_USB
> 
> endif
>diff --git a/board/emulation/qemu-riscv/qemu-riscv.c b/board/emulation/qemu-riscv/qemu-riscv.c
>index f39f3be366..181abbbf97 100644
>--- a/board/emulation/qemu-riscv/qemu-riscv.c
>+++ b/board/emulation/qemu-riscv/qemu-riscv.c
>@@ -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;
> }
> 
>diff --git a/doc/board/emulation/qemu-riscv.rst b/doc/board/emulation/qemu-riscv.rst
>index 9d21f3270c..61137bcbf1 100644
>--- a/doc/board/emulation/qemu-riscv.rst
>+++ b/doc/board/emulation/qemu-riscv.rst
>@@ -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
> ----------------
> 
>diff --git a/include/configs/qemu-riscv.h b/include/configs/qemu-riscv.h
>index d5146e70f7..584559cfa3 100644
>--- a/include/configs/qemu-riscv.h
>+++ b/include/configs/qemu-riscv.h
>@@ -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"
> 


More information about the U-Boot mailing list