Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp2440002pxj; Mon, 17 May 2021 01:19:36 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyiWCHwurvsjSg1bsBrUse0r++1Ci6Om0XGXAC91UykqDc5w2lfiqNzBMGbG6WFDyJywsXL X-Received: by 2002:a05:6638:2728:: with SMTP id m40mr6884613jav.55.1621239575795; Mon, 17 May 2021 01:19:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621239575; cv=none; d=google.com; s=arc-20160816; b=mGjCHRqGe+a3HYMHj8yTe1f7hGVXDgmdFgx0h4n6O5PsmHb9lHCrdV/AEKrS2U7Rvz cjjcMeAbG1PzXqvUpfCPr2qBoUjnP5l3ldDM8GMMthrtGb43B0EbrUp+ud5M8MBVLx5h SzqVDXfkifLnscxd6IT8KFWm8GsFJHVJ9MTLRbBtETbfIFseXNzS85HPaVkrEauW2ecK gYnJIKeX2/79rYGoxjnsNz9oZhzV7eLGt2hSyYr5HZI+5dbtMFk/oMvH87pV0G7FfBrc X5z0u4c39rmiL3rme++idEcLSK8BjgFsdZFls0X/nGMjdlgxce9rgs9+msVYo6PXnQli zrfw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject; bh=/Y2QrCRbgx4kkWGGhnIXaAKNy2eEk4cnk8Q73oTRaog=; b=GL7H/e6C00vv4WKaRb/YwmX6uWe2yVzyBX0QUsDGfxsQKPDvOnhBhs1VxFCeJ1SzVG CJ30FwYr9LJjZQExK/6zH7GyT3xOM1HXZKzJ5Dt7g18sPJG0P8aDBJ9DuMCNSNGJt0YK yW4QXFcjO4Xy/OVzNO1vM8tPLG8z/hPPgDi/Isf/3E1BCJT+zWveDFe9EpsAHuHJCzWe Vh8RVc/iCOOO7eXW8CK+hbXdGUoTw90A77ARQXUPblSSazUyTWuSa21PJJ8Fj87hu+nZ anDA1TzZ+U5u4GJWhKLPYmAYMgJWFp5joaHrWFnXw0ro1UsrZZtUWrHyJJAXaflv15mt s2zA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id u11si18289774ill.6.2021.05.17.01.19.22; Mon, 17 May 2021 01:19:35 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235235AbhEQIUF (ORCPT + 99 others); Mon, 17 May 2021 04:20:05 -0400 Received: from mail-wr1-f51.google.com ([209.85.221.51]:45906 "EHLO mail-wr1-f51.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235599AbhEQISq (ORCPT ); Mon, 17 May 2021 04:18:46 -0400 Received: by mail-wr1-f51.google.com with SMTP id h4so5355519wrt.12; Mon, 17 May 2021 01:16:56 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; 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=/Y2QrCRbgx4kkWGGhnIXaAKNy2eEk4cnk8Q73oTRaog=; b=jvqo4v0KjoGK1OiB4y/nt8VZ24osX5AoENqE9tqr7UKRjFpbKKjoAJuiGlkDi3jNlX QBNLzMDbvJe7RydLP82jyqFd9AULEkAm4UWUveZ7gn9ZahFKcU9vEqYoljewR1F5M9IO nEDFBC5R7TX8j9kHRFVDpP7Td2cpAsrFdAVc4N1e2bpBhMeLBNFRM0T7Psky6Xgxr8J6 0Sebb8WlnTA/NT2e033oxVPJl9XCnX21YNkzQqyTu8G6ClldoCaWn8g1eKECbWr2H55j GA76VBy/XuiXyr1tfyJvLJ0OZacXhnMlsDhGZkrQZ2vaxfKTYH+BpJj1ncXZaK21mon6 5DTQ== X-Gm-Message-State: AOAM532YqkCHTAlzu2gWFIOibTUQiI5CfrtyHXAlPAFK24ML5+ceDqH5 GUYHIcoCLEgqPvmIdNr6RET/1tHmCmlRsw== X-Received: by 2002:a5d:410e:: with SMTP id l14mr27744330wrp.230.1621239405371; Mon, 17 May 2021 01:16:45 -0700 (PDT) Received: from ?IPv6:2a0b:e7c0:0:107::70f? ([2a0b:e7c0:0:107::70f]) by smtp.gmail.com with ESMTPSA id f7sm18015993wrg.34.2021.05.17.01.16.44 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 17 May 2021 01:16:44 -0700 (PDT) Subject: Re: [PATCH] serial/liteuart; Add support for earlycon To: Stafford Horne , LKML Cc: Florent Kermarrec , Mateusz Holenko , Joel Stanley , "Gabriel L . Somlo" , Jonathan Corbet , Greg Kroah-Hartman , Karol Gugala , "Paul E. McKenney" , Randy Dunlap , Andrew Morton , Thomas Gleixner , Viresh Kumar , Mike Kravetz , Peter Zijlstra , linux-doc@vger.kernel.org, linux-serial@vger.kernel.org References: <20210515084519.167343-1-shorne@gmail.com> From: Jiri Slaby Message-ID: Date: Mon, 17 May 2021 10:16:43 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.10.1 MIME-Version: 1.0 In-Reply-To: <20210515084519.167343-1-shorne@gmail.com> Content-Type: text/plain; charset=iso-8859-2; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 15. 05. 21, 10:45, Stafford Horne wrote: > Most litex boards using RISC-V soft cores us the sbi earlycon, however > this is not available for non RISC-V litex SoC. This patch enables > earlycon for liteuart which is available on all Litex SoC's making > support for earycon debugging more widely available. > > Signed-off-by: Stafford Horne > Cc: Florent Kermarrec > Cc: Mateusz Holenko > Cc: Joel Stanley > Cc: Gabriel L. Somlo > --- > .../admin-guide/kernel-parameters.txt | 5 +++ > drivers/tty/serial/Kconfig | 1 + > drivers/tty/serial/liteuart.c | 31 +++++++++++++++++++ > 3 files changed, 37 insertions(+) > > diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt > index 04545725f187..2d4a43af8de2 100644 > --- a/Documentation/admin-guide/kernel-parameters.txt > +++ b/Documentation/admin-guide/kernel-parameters.txt > @@ -1084,6 +1084,11 @@ > the driver will use only 32-bit accessors to read/write > the device registers. > > + liteuart, > + Start an early console on a litex serial port at the > + specified address. The serial port must already be > + setup and configured. Options are not yet supported. > + > meson, > Start an early, polled-mode console on a meson serial > port at the specified address. The serial port must > diff --git a/drivers/tty/serial/Kconfig b/drivers/tty/serial/Kconfig > index 0c4cd4a348f4..9ceffe6ab6fd 100644 > --- a/drivers/tty/serial/Kconfig > +++ b/drivers/tty/serial/Kconfig > @@ -1531,6 +1531,7 @@ config SERIAL_LITEUART > depends on OF || COMPILE_TEST > depends on LITEX > select SERIAL_CORE > + select SERIAL_EARLYCON > help > This driver is for the FPGA-based LiteUART serial controller from LiteX > SoC builder. > diff --git a/drivers/tty/serial/liteuart.c b/drivers/tty/serial/liteuart.c > index 64842f3539e1..38c472487e68 100644 > --- a/drivers/tty/serial/liteuart.c > +++ b/drivers/tty/serial/liteuart.c > @@ -372,6 +372,37 @@ static int __init liteuart_console_init(void) > console_initcall(liteuart_console_init); > #endif /* CONFIG_SERIAL_LITEUART_CONSOLE */ > > +#ifdef CONFIG_SERIAL_EARLYCON > +static void early_liteuart_putc(struct uart_port *port, int c) > +{ > + while (litex_read8(port->membase + OFF_TXFULL)) > + cpu_relax(); > + > + litex_write8(port->membase + OFF_RXTX, c); Hi, am I missing something or this doesn't differ to liteuart_putchar? > +} > + > +static void early_liteuart_write(struct console *console, const char *s, > + unsigned int count) > +{ > + struct earlycon_device *device = console->data; > + struct uart_port *port = &device->port; > + > + uart_console_write(port, s, count, early_liteuart_putc); > +} > + > +static int __init early_liteuart_setup(struct earlycon_device *device, > + const char *options) > +{ > + if (!device->port.membase) > + return -ENODEV; > + > + device->con->write = early_liteuart_write; > + return 0; > +} > + > +OF_EARLYCON_DECLARE(liteuart, "litex,liteuart", early_liteuart_setup); > +#endif /* CONFIG_SERIAL_EARLYCON */ > + > static int __init liteuart_init(void) > { > int res; > -- js suse labs