From: Bin Meng Date: Sun, 23 Jul 2023 04:40:41 +0000 (+0800) Subject: riscv: qemu: Enable usb keyboard as an input device X-Git-Url: http://git.dujemihanovic.xyz/%22/img/sics.gif/%22/static/git-favicon.png?a=commitdiff_plain;h=02be57caf730e2213bc844bf1dbe58bedd2c3734;p=u-boot.git riscv: qemu: Enable usb keyboard as an input device 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 Reviewed-by: Rick Chen Reviewed-by: Simon Glass --- 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 + 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 #include #include +#include #include #include @@ -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"