Skip to content

Commit

Permalink
riscv: qemu: Enable usb keyboard as an input device
Browse files Browse the repository at this point in the history
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 <[email protected]>
Reviewed-by: Rick Chen <[email protected]>
Reviewed-by: Simon Glass <[email protected]>
  • Loading branch information
lbmeng authored and Leo Yu-Chi Liang committed Aug 2, 2023
1 parent 124308e commit 02be57c
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 1 deletion.
5 changes: 5 additions & 0 deletions board/emulation/qemu-riscv/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -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
5 changes: 5 additions & 0 deletions board/emulation/qemu-riscv/qemu-riscv.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#include <log.h>
#include <spl.h>
#include <init.h>
#include <usb.h>
#include <virtio_types.h>
#include <virtio.h>

Expand Down Expand Up @@ -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;
}

Expand Down
5 changes: 5 additions & 0 deletions doc/board/emulation/qemu-riscv.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
----------------

Expand Down
2 changes: 1 addition & 1 deletion include/configs/qemu-riscv.h
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down

0 comments on commit 02be57c

Please sign in to comment.