From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-17.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7E960C433F5 for ; Sun, 12 Sep 2021 16:22:30 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id C0F3A60F92 for ; Sun, 12 Sep 2021 16:22:29 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org C0F3A60F92 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=lists.denx.de Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 1066183943; Sun, 12 Sep 2021 18:22:27 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com 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; unprotected) header.d=gmail.com header.i=@gmail.com header.b="LwIzfFrc"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 9662F83943; Sun, 12 Sep 2021 18:22:25 +0200 (CEST) Received: from mail-qt1-x834.google.com (mail-qt1-x834.google.com [IPv6:2607:f8b0:4864:20::834]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 3C98E8392E for ; Sun, 12 Sep 2021 18:22:20 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=seanga2@gmail.com Received: by mail-qt1-x834.google.com with SMTP id d11so6184442qtw.3 for ; Sun, 12 Sep 2021 09:22:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=Jc3EZKb6CELTvIdsQcJy8pqjT6y6GnXi4H4OGjmMAwo=; b=LwIzfFrcmFiMY0kPbYtkwmYF/7v/824b3h1PuwvkMNQyLiUeAF5YjjrXDuNvFe3Umc chQOlTNF9X/gMUD/El3IH5gifdjC5nZ6HcM2zeijOA8RvctO6iSadNAa2KTUYvVslNAn SMR05hxyyB47jMXieo0bZ1msgv2gAe3GXvi3+dmCBK7ZpDbHuCQWTpzc0icjOYuHsKRy bSxBJdVfeSOj/1TQuVSMqg+XYC0zedwASleMgF+m9Wx2Rxwx8yrHzSEDsCz6QkGkw5iL A+fP72TPiXbnZE2ew36GdUVJWGr8csSRpbKsXXFXa818C46s4kjGL475dhhDl67ywCW9 ob4Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=Jc3EZKb6CELTvIdsQcJy8pqjT6y6GnXi4H4OGjmMAwo=; b=nuw8G22RKAr5CjsdUtxG86YUxLRtLhiJyPd0zbxeUwnTEjDurz75jiotjbBeUs9/p6 q7r8PTzxLGp+RwAllRw36MBOmpz55tr+BGqVkQUgQqC+Vyh4P3x+admN0hNW7Pl0Ly9i ypBn5QblELwUIxkjkArkI/SjdENDD/KXF4Wvq/D64z6GcOsQ8xRgZ5m7Gj0PEVI+A1Na Lj0gNroqpfn+c6eLhToAjvyf+T3uW3gMzQ5C/hPpDY1qZzgXGvF4a3sZ43xw7OwLvocJ 5B2lMaCdOipW+sEn3njJpDMWILhYLAtyEfmAZvqLdjIVzi/pa9mXXibjnZSW4HcaJN4R 4arw== X-Gm-Message-State: AOAM5321CKia6ufx+rAE8iP90XCnXnEfYFmwmCLZ4x5fJyvJtz+PiR5G JB/LNzGNVCI+gAlI6EUgvcc= X-Google-Smtp-Source: ABdhPJz/VvECVoj7cLmfw11Uj3oHWf0VODz+Im/KFu1qVEMan36BkjxW69oJc2wOXnUubY5Ez37qlw== X-Received: by 2002:a05:622a:141:: with SMTP id v1mr6074676qtw.154.1631463739048; Sun, 12 Sep 2021 09:22:19 -0700 (PDT) Received: from [192.168.1.201] (pool-108-45-127-224.washdc.fios.verizon.net. [108.45.127.224]) by smtp.googlemail.com with ESMTPSA id j23sm3467297qkl.65.2021.09.12.09.22.18 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 12 Sep 2021 09:22:18 -0700 (PDT) Subject: Re: [PATCH] serial: Add a debug console using the RISC-V SBI interface To: Samuel Holland , Rick Chen , Leo Cc: u-boot@lists.denx.de, AKASHI Takahiro , =?UTF-8?Q?Marek_Beh=c3=ban?= , Mark Kettenis , Michal Simek , Minkyu Kang , Simon Glass , Stefan Roese , Vabhav Sharma , Weijie Gao References: <20210912155610.49935-1-samuel@sholland.org> From: Sean Anderson Message-ID: <4a54a4a7-df5b-2cdf-8660-e93652c36fdd@gmail.com> Date: Sun, 12 Sep 2021 12:22:17 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.12.0 MIME-Version: 1.0 In-Reply-To: <20210912155610.49935-1-samuel@sholland.org> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 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.2 at phobos.denx.de X-Virus-Status: Clean On 9/12/21 11:56 AM, Samuel Holland wrote: > The RISC-V SBI interface v0.1 provides a function for printing a > character to the console. Even though SBI v0.1 functions are deprecated, > the SBI console is quite useful for early debugging, because it works > without any dcache, memory, or MMIO access in S mode. > > Signed-off-by: Samuel Holland > --- > > drivers/serial/Kconfig | 10 ++++++++++ > drivers/serial/Makefile | 1 + > drivers/serial/serial_sbi.c | 16 ++++++++++++++++ > 3 files changed, 27 insertions(+) > create mode 100644 drivers/serial/serial_sbi.c > > diff --git a/drivers/serial/Kconfig b/drivers/serial/Kconfig > index 36ee43210a9..e5f086271ef 100644 > --- a/drivers/serial/Kconfig > +++ b/drivers/serial/Kconfig > @@ -280,6 +280,14 @@ config DEBUG_EFI_CONSOLE > U-Boot when running on top of EFI (Extensive Firmware Interface). > This is a type of BIOS used by PCs. > > +config DEBUG_SBI_CONSOLE > + bool "SBI" > + depends on SBI_V01 > + help > + Select this to enable a debug console which calls back to SBI to > + output to the console. This can be useful for early debugging of > + U-Boot when running on top of SBI (Supervisor Binary Interface). > + > config DEBUG_UART_S5P > bool "Samsung S5P" > depends on ARCH_EXYNOS || ARCH_S5PC1XX > @@ -442,6 +450,7 @@ endchoice > config DEBUG_UART_BASE > hex "Base address of UART" > depends on DEBUG_UART > + default 0 if DEBUG_SBI_CONSOLE > default 0 if DEBUG_UART_SANDBOX > help > This is the base address of your UART for memory-mapped UARTs. > @@ -452,6 +461,7 @@ config DEBUG_UART_BASE > config DEBUG_UART_CLOCK > int "UART input clock" > depends on DEBUG_UART > + default 0 if DEBUG_SBI_CONSOLE > default 0 if DEBUG_UART_SANDBOX > default 0 if DEBUG_MVEBU_A3700_UART > help > diff --git a/drivers/serial/Makefile b/drivers/serial/Makefile > index 3cbea8156f8..4edd2aa9458 100644 > --- a/drivers/serial/Makefile > +++ b/drivers/serial/Makefile > @@ -36,6 +36,7 @@ obj-$(CONFIG_ATMEL_USART) += atmel_usart.o > obj-$(CONFIG_BCM6345_SERIAL) += serial_bcm6345.o > obj-$(CONFIG_COREBOOT_SERIAL) += serial_coreboot.o > obj-$(CONFIG_CORTINA_UART) += serial_cortina.o > +obj-$(CONFIG_DEBUG_SBI_CONSOLE) += serial_sbi.o > obj-$(CONFIG_EFI_APP) += serial_efi.o > obj-$(CONFIG_LPC32XX_HSUART) += lpc32xx_hsuart.o > obj-$(CONFIG_MCFUART) += serial_mcf.o > diff --git a/drivers/serial/serial_sbi.c b/drivers/serial/serial_sbi.c > new file mode 100644 > index 00000000000..b9f35ed36e6 > --- /dev/null > +++ b/drivers/serial/serial_sbi.c > @@ -0,0 +1,16 @@ > +// SPDX-License-Identifier: GPL-2.0+ > + > +#include > +#include > + > +static inline void _debug_uart_init(void) > +{ > +} > + > +static inline void _debug_uart_putc(int c) > +{ > + if (CONFIG_IS_ENABLED(RISCV_SMODE)) > + sbi_console_putchar(c); > +} > + > +DEBUG_UART_FUNCS > Reviewed-by: Sean Anderson