Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id DCEA1C001DC for ; Sun, 23 Jul 2023 10:12:02 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 9078E86684; Sun, 23 Jul 2023 12:12:00 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=xs4all.nl Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; secure) header.d=xs4all.nl header.i=@xs4all.nl header.b="WwVZ74ac"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id A80728668A; Sun, 23 Jul 2023 12:11:59 +0200 (CEST) Received: from ewsoutbound.kpnmail.nl (ewsoutbound.kpnmail.nl [195.121.94.183]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 04827863E4 for ; Sun, 23 Jul 2023 12:11:55 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=xs4all.nl Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=mark.kettenis@xs4all.nl X-KPN-MessageId: 08982dfa-2941-11ee-a2b4-005056992ed3 Received: from smtp.kpnmail.nl (unknown [10.31.155.5]) by ewsoutbound.so.kpn.org (Halon) with ESMTPS id 08982dfa-2941-11ee-a2b4-005056992ed3; Sun, 23 Jul 2023 12:09:38 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=xs4all.nl; s=xs4all01; h=subject:to:from:message-id:date; bh=Zl4fn/FnbVhqRbGPJlL76Xe9NPgi4xxfBGF1Q+2pdCQ=; b=WwVZ74achmWfMq9xsrYqd4IXwfen37r0durEwIfc/00L5Vla5K1fee1EQj/tHWkJsep1l2C67l5CY GQI8/NNQ7majby5RnPDwezDZjn5hBpBAUtCYqxcpjJDwxFhFI/gR4urNhtRQMEbb/xi0OYGANehHUz LmH0Q/7RKrBUX+8qN88gcalbJNUuuyPGfnMT9LWXWPGvz6FkpisYsNg3FcLB9GysWMRTJHugB4Wq/B X+alE8FHsiVwqyTCPpkPdgL2l7pARLidy4zZ03H23iYgJ/l9grYKQ29FeJyc/CIPG2Vr+5tYsq8Crk JUjiBA+SQ7VDf/ujvmh+EELhmI1I+iQ== X-KPN-MID: 33|lQWrZhO0ab6PNiAdILkCVK9QOERtfuvy8sGonb2Bmr3Z8BxuEhjavxtCYp44Gxa 9w32DL/tNGTihP2HYDJuLtfOojOB0Owrmfplt+OyynGU= X-KPN-VerifiedSender: Yes X-CMASSUN: 33|aSitntBpYn4QF2UoGfo0nacF+YVOvqgapBTOq0hZmxpoI1qBvEO6M3rA0Fw+V3G dvYLSdYXiQXw7jIDJapHx3A== X-Originating-IP: 80.61.163.207 Received: from bloch.sibelius.xs4all.nl (80-61-163-207.fixed.kpn.net [80.61.163.207]) by smtp.xs4all.nl (Halon) with ESMTPSA id 594ba209-2941-11ee-aef8-00505699b758; Sun, 23 Jul 2023 12:11:55 +0200 (CEST) Date: Sun, 23 Jul 2023 12:11:54 +0200 Message-Id: <87lef7lyxh.fsf@bloch.sibelius.xs4all.nl> From: Mark Kettenis To: Heinrich Schuchardt Cc: bmeng@tinylab.org, sjg@chromium.org, u-boot@lists.denx.de, bmeng.cn@gmail.com In-Reply-To: <8BE7576C-0939-4A0F-8FC3-E26779C20765@gmx.de> (message from Heinrich Schuchardt on Sun, 23 Jul 2023 11:30:31 +0200) Subject: Re: [PATCH 18/18] riscv: qemu: Enable usb keyboard as an input device References: <20230723044041.1089804-1-bmeng@tinylab.org> <20230723044041.1089804-19-bmeng@tinylab.org> <87msznm39z.fsf@bloch.sibelius.xs4all.nl> <8BE7576C-0939-4A0F-8FC3-E26779C20765@gmx.de> X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean > Date: Sun, 23 Jul 2023 11:30:31 +0200 > From: Heinrich Schuchardt > > Am 23. Juli 2023 10:38:00 MESZ schrieb Mark Kettenis : > >> From: Bin Meng > >> Date: Sun, 23 Jul 2023 12:40:41 +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 > >> > >> --- > >> > >> 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 > >> + 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(); > >> + > > > >This is typically handled by including "usb start" in CONFIG_PREBOOT, > >which is done by boot/Kconfig. Any reason why that doesn't work for > >you? > > We run pci_init() in board_r.c. Why don't do the same for USB > instead of the PREBOOT quirk? Well, yes, that was going to be my next question. If using PREBOOT is for some reason no longer the preferred way to do this, should there be some other generic method to make sure the USB controllers are started when a USB keyboard is configured as an input method. Doing something generic like this in board-specific code seems wrong to me. Cheers, Mark > > > >> 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" > >> > >> -- > >> 2.34.1 > >> > >> >