Received: by 2002:a05:6a10:7420:0:0:0:0 with SMTP id hk32csp261867pxb; Thu, 17 Feb 2022 03:40:02 -0800 (PST) X-Google-Smtp-Source: ABdhPJwtjz8/hwV7orfqlyKKt056MCr1uJh62cRpoGjHmy59zU499XB49L08XcFjWobzXLZmA7AF X-Received: by 2002:a50:9f08:0:b0:410:b961:eea4 with SMTP id b8-20020a509f08000000b00410b961eea4mr2155641edf.394.1645098002657; Thu, 17 Feb 2022 03:40:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1645098002; cv=none; d=google.com; s=arc-20160816; b=PzBWZxdph8sqXouSVRQC7Blxw/xs2UJ4hMFFUQsoyDIjbV//XTkp6TeEhy7CHLqx9E neVk5xAaXQMNNY57Z/fcojZLcFJU4Wh9yMtEDBy0Lwyu1Sqrm4m/1YRjP24ybjDbVwCG sdd/FQnjzkFonRe1QiTr5s8qGccVqhEIBpxeqy+ljil47gd2aL8QhAxQdK4H66VhbCwv 6jRIFTMzrWUzyYRwUGCLh2dnLij0YzWxig/Y1P9Nx/ppoPkjz6KgLRVCz1zGoiTC8s8W RTliXM4Obo1IDl5RJYHc4C14ZItnZeeOKIA60OcoCcrKdwY6FxEF5M2FbJboANAQTOXZ t3lg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=uMIY4q1dw2g0DupncXTpW6aZDCSYaQ0ItOC+2/6KcXc=; b=htljhUxeaAZg8fwT9bXIxubpFgLYwOKgOVETcp2Xa12LJCc/uwd9r1TgnU1xY9rZvu PPHxeTbxSv3MZAQptiMBEP08UXzhRJGb39x9tpw2ZDPvAIeE8TWZ0Yy0avzvewMuy7qt eikk3ukpQ3fPte1ykT09qz6R2+j2HSxNzvo80bmmUgX3rEXOynkZ6yf7InQPdkXiLruT nGPdlSEDQ9qPAwtbUBPMRZ/O7T8AyE6dxaM3Scf2LR9sPAhMTOAAquIYLmmuCHSt1RkV WgyzbBwkNWTFAD4tFB2b9z952ZUbfWMmkF2a+9nJm2WkkeJNbWyVwPmdp/VXs9JALayF dgOQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@walle.cc header.s=mail2016061301 header.b=bea5cxY1; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id y26si3697666edm.375.2022.02.17.03.39.39; Thu, 17 Feb 2022 03:40:02 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@walle.cc header.s=mail2016061301 header.b=bea5cxY1; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238838AbiBQJq5 (ORCPT + 99 others); Thu, 17 Feb 2022 04:46:57 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:57276 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238824AbiBQJqp (ORCPT ); Thu, 17 Feb 2022 04:46:45 -0500 Received: from ssl.serverraum.org (ssl.serverraum.org [IPv6:2a01:4f8:151:8464::1:2]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2261B62EF; Thu, 17 Feb 2022 01:46:31 -0800 (PST) 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 3513622205; Thu, 17 Feb 2022 10:46:27 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=walle.cc; s=mail2016061301; t=1645091188; 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=uMIY4q1dw2g0DupncXTpW6aZDCSYaQ0ItOC+2/6KcXc=; b=bea5cxY1s+igLLttFbfWazshFuoO8SPXLgg3V6oVbn8Mazj+rV3b3D/bmuCxFiqYSkGzXD +7AHgj2bvdEQh78V5Ge0Q5ltrCRXl8ongEHltbH9s7g7iYL++5SMO02GwYB5hvn372Mqu7 OaO0Y0uUHxIX4rUo6oPxxb3Lb/mUv5A= 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 v2] tty: serial: atmel: add earlycon support Date: Thu, 17 Feb 2022 10:46:20 +0100 Message-Id: <20220217094620.1148571-1-michael@walle.cc> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.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/Kconfig | 1 + drivers/tty/serial/atmel_serial.c | 24 ++++++++++++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/drivers/tty/serial/Kconfig b/drivers/tty/serial/Kconfig index 0e5ccb25bdb1..407a98ec0791 100644 --- a/drivers/tty/serial/Kconfig +++ b/drivers/tty/serial/Kconfig @@ -139,6 +139,7 @@ config SERIAL_ATMEL_CONSOLE bool "Support for console on AT91 serial port" depends on SERIAL_ATMEL=y select SERIAL_CORE_CONSOLE + select SERIAL_EARLYCON help Say Y here if you wish to use an on-chip UART on a Atmel AT91 processor as the system console (the system diff --git a/drivers/tty/serial/atmel_serial.c b/drivers/tty/serial/atmel_serial.c index 2d09a89974a2..73d43919898d 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(atmel_serial, "atmel,at91rm9200-usart", + atmel_early_console_setup); +OF_EARLYCON_DECLARE(atmel_serial, "atmel,at91sam9260-usart", + atmel_early_console_setup); + #define ATMEL_CONSOLE_DEVICE (&atmel_console) #else -- 2.30.2