From patchwork Wed Feb 16 16:18:22 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Walle X-Patchwork-Id: 12748740 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id DE7AAC433F5 for ; Wed, 16 Feb 2022 16:19:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:Cc :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=bFiIUYuUeb17MRKB3nt1m0TLCB+Ij11syoqros6uhMk=; b=OLk1erR+1lubJQ 6xC0XUaypdEc8nNTSysNCf015FswlnxUuKoMiNw4JtVYn9+EfC5BwEO+JMf90I5uYB0FgZvJ3Sbv3 9ACKSBeIYT8gM4okGAghF+2zNAS5x2D4xSzh48Kqnvo05gYZ/kBdDYBuRf2HDRw3DdWR3Yk44pvQQ 97wDZGWTymEYOcxpv96uUO0Ru7CptMzWtc3FBVWdpM7XA719ya5VfaIAu0+bIgdrVxDdriuNkvu93 CCJv1taaU7aZpcT1laLNgIvbVtN2PD2wR2ocvbpPFsrE2fHu0JzTdXFBkVZCSI/osxcC6SvEZCzRX 1iPNUVk9FRicPievjrug==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nKN0m-007enh-Qi; Wed, 16 Feb 2022 16:18:36 +0000 Received: from ssl.serverraum.org ([2a01:4f8:151:8464::1:2]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nKN0i-007em7-TC for linux-arm-kernel@lists.infradead.org; Wed, 16 Feb 2022 16:18:35 +0000 Received: from mwalle01.kontron.local. (unknown [213.135.10.150]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-384) server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by ssl.serverraum.org (Postfix) with ESMTPSA id 24F3922246; Wed, 16 Feb 2022 17:18:27 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=walle.cc; s=mail2016061301; t=1645028307; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=7AB8VBpyFBQKRoN6d6vVzUF8grAsjn3IGpYvohsqVUY=; b=XUlEGO8/0o2gpwuSbOUUklB3WX45dX2DxfaFJ6f1VD0048KatWTVsWqKE/7woCd3Ugw6p4 DkRS8IPWyqCSQ3fDD+iDtpJxSx3HlcgHThKAQKDb4XigY4r9hTsjykgZEtbF3x+s5OxH1m Bjb2M/z+NdUeUfAibmlZA2gir71oT1A= From: Michael Walle To: Richard Genoud , Greg Kroah-Hartman , Jiri Slaby , Nicolas Ferre , Alexandre Belloni , Claudiu Beznea Cc: linux-serial@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Michael Walle Subject: [PATCH] tty: serial: atmel: add earlycon support Date: Wed, 16 Feb 2022 17:18:22 +0100 Message-Id: <20220216161822.1071245-1-michael@walle.cc> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220216_081833_593423_7E8638F4 X-CRM114-Status: GOOD ( 11.21 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Add early console support which relies on the bootloader for the initialization of the UART. Please note, that the compatibles are taken from at91-usart MFD driver. Signed-off-by: Michael Walle --- drivers/tty/serial/atmel_serial.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/drivers/tty/serial/atmel_serial.c b/drivers/tty/serial/atmel_serial.c index 2d09a89974a2..50fc6d51ff0d 100644 --- a/drivers/tty/serial/atmel_serial.c +++ b/drivers/tty/serial/atmel_serial.c @@ -2673,6 +2673,30 @@ static struct console atmel_console = { .data = &atmel_uart, }; +static void atmel_serial_early_write(struct console *con, const char *s, + unsigned int n) +{ + struct earlycon_device *dev = con->data; + + uart_console_write(&dev->port, s, n, atmel_console_putchar); +} + +static int __init atmel_early_console_setup(struct earlycon_device *device, + const char *options) +{ + if (!device->port.membase) + return -ENODEV; + + device->con->write = atmel_serial_early_write; + + return 0; +} + +OF_EARLYCON_DECLARE(atmelserial, "atmel,at91rm9200-usart", + atmel_early_console_setup); +OF_EARLYCON_DECLARE(atmelserial, "atmel,at91sam9260-usart", + atmel_early_console_setup); + #define ATMEL_CONSOLE_DEVICE (&atmel_console) #else