From patchwork Tue Jan 5 17:02:02 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cristian Ciocaltea X-Patchwork-Id: 11999851 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=-13.7 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_SIGNED,DKIM_VALID,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT 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 E4B1EC433E6 for ; Tue, 5 Jan 2021 17:03:39 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id A1C3322CBB for ; Tue, 5 Jan 2021 17:03:39 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A1C3322CBB Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject: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=D6lpOGtxvWhgA++NRfr3ZQAQ86/mH8wiTNMF/cMdn8M=; b=m+mBOx5TfyGpCTJmeVBCL6OVqe tJq9l24hrXWY/PlnmczRaZSjkW+oNvMcu92tsISVOmb5rFv963Ec8htNZI9eBxEg80NZt2gSAjNId A4wYquTsThVijJvCv9n+vjDd0bsosv8c14oinSu8wY7t1a4N8xfF0bKTtaVCJFUIBmxFyMl4VQ+kZ zBMSaXunXK4jGb5A7R1NOPPu2Pd75aXbMqvCHX2qTLBhHvbYPHw6v+oSLmrqu6gz5JRSZqIi1kIAU E2oAde6C/9RS0ifVQNnHxIlpJUg6+8ML0uHIpn6fN3YANRsufQThvtXPem8EEcfVcaDHfMZiIaLQv 7fuzkIbg==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kwpil-0000I8-Jv; Tue, 05 Jan 2021 17:02:11 +0000 Received: from mail-ed1-x52c.google.com ([2a00:1450:4864:20::52c]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kwpii-0000GW-4A; Tue, 05 Jan 2021 17:02:09 +0000 Received: by mail-ed1-x52c.google.com with SMTP id c7so1249306edv.6; Tue, 05 Jan 2021 09:02:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=nXr5ak/ayXG0mLNUO+7vuO7bjdOSjjDtr/aQD9ygt94=; b=UwfxheqcSiLFAO91/TjnnIkUrkB6PT/YCmY7jZlQU1agpQXOc4Lgx0mjoaWIonFNm9 NwSOwSKa/6cNJBSYGuHlskmt+jsZGbOrKs42zEqMaKZngfCwrPwSmmps69qOExcTKA+r HROEOg6T4QQlkx2GNhyvajHaF/YFKD0amleuLP8xL1ovnE8PaOBHg275uRsGPb8CRx6g 70y01GVqGmEXhGe4W1CzFvJ0z4O+216TS3lsA4HUtIDxiymtCjc8VeQNzrvia4wBw8Q6 LAU0gZ0Nh/FZ46C6Mnry1LONCCVo3MoTxY+dGSACqNAQoqZD4mRssNHuxksJkMI9KLH8 ugSQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=nXr5ak/ayXG0mLNUO+7vuO7bjdOSjjDtr/aQD9ygt94=; b=oFnEi0kUgXXxzqoTte3gluU/P5rprjs3a3i9SR9a4g57i8ZjU0417Ejq/i0FQH6VQ+ 1qGkab4jZabSopKutrXRL0dSjtBQ9m47He+6yjJf8UUZWSIhOX0EBIjRDfoG+Ab1mtNB nNso1sdooPed0taze/2IsUfSUT6S8W0CH/YzB9GjOR16vYKFZLgVIKVGSPvib0N5uyRd vD7a5qxV65e6gcjcWZlHHnnPPY76a/aBZjKcrii957Xr8lgYt1/EOgQg1PTYaf2CHqCf i1TxLaf2HyMnjBZX9KS6mS0kZX2vK/1uDoDtabdO2H7XgFSqKO/7Una6JZY3tzWukZEX LxRQ== X-Gm-Message-State: AOAM530A9GxZOnzikidLBKfrbjGG49BG6sOTaG52AS/Ia/mxDoU5zPzw NTn6X8ZKy9P3NvJqLx5zScU1/asrzmQ7Vw== X-Google-Smtp-Source: ABdhPJxTHWpX5TO4IyFPB3yzCKjStI6pzZednGNDFCMMLEcZkJn1sMxbR0ie6QI0LnZd5NB+IZyBmA== X-Received: by 2002:a50:8a90:: with SMTP id j16mr687135edj.334.1609866125260; Tue, 05 Jan 2021 09:02:05 -0800 (PST) Received: from localhost.localdomain ([188.24.159.61]) by smtp.gmail.com with ESMTPSA id u2sm99711ejb.65.2021.01.05.09.02.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Jan 2021 09:02:04 -0800 (PST) From: Cristian Ciocaltea To: Greg Kroah-Hartman , Jiri Slaby , =?utf-8?q?Andreas_F=C3=A4rber?= , Manivannan Sadhasivam Subject: [PATCH v2 1/1] tty: serial: owl: Add support for kernel debugger Date: Tue, 5 Jan 2021 19:02:02 +0200 Message-Id: <036c09732183a30eaab230884114f65ca42ca3b9.1609865007.git.cristian.ciocaltea@gmail.com> X-Mailer: git-send-email 2.30.0 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210105_120208_249442_1B3D98A5 X-CRM114-Status: GOOD ( 15.31 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-actions@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Implement 'poll_put_char' and 'poll_get_char' callbacks in struct 'owl_uart_ops' that enables OWL UART to be used for kernel debugging over serial line. Signed-off-by: Cristian Ciocaltea --- Changes in v2: - Reverted unnecessary changes per Andreas feedback - Optimized implementation for 'owl_uart_poll_get_char()' and 'owl_uart_poll_put_char()' callbacks drivers/tty/serial/owl-uart.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/drivers/tty/serial/owl-uart.c b/drivers/tty/serial/owl-uart.c index c149f8c30007..54b24669ebc5 100644 --- a/drivers/tty/serial/owl-uart.c +++ b/drivers/tty/serial/owl-uart.c @@ -12,6 +12,7 @@ #include #include #include +#include #include #include #include @@ -461,6 +462,26 @@ static void owl_uart_config_port(struct uart_port *port, int flags) } } +#ifdef CONFIG_CONSOLE_POLL + +static int owl_uart_poll_get_char(struct uart_port *port) +{ + if (owl_uart_read(port, OWL_UART_STAT) & OWL_UART_STAT_RFEM) + return NO_POLL_CHAR; + + return owl_uart_read(port, OWL_UART_RXDAT); +} + +static void owl_uart_poll_put_char(struct uart_port *port, unsigned char ch) +{ + while (owl_uart_read(port, OWL_UART_STAT) & OWL_UART_STAT_TFFU) + cpu_relax(); + + owl_uart_write(port, ch, OWL_UART_TXDAT); +} + +#endif /* CONFIG_CONSOLE_POLL */ + static const struct uart_ops owl_uart_ops = { .set_mctrl = owl_uart_set_mctrl, .get_mctrl = owl_uart_get_mctrl, @@ -476,6 +497,10 @@ static const struct uart_ops owl_uart_ops = { .request_port = owl_uart_request_port, .release_port = owl_uart_release_port, .verify_port = owl_uart_verify_port, +#ifdef CONFIG_CONSOLE_POLL + .poll_get_char = owl_uart_poll_get_char, + .poll_put_char = owl_uart_poll_put_char, +#endif }; #ifdef CONFIG_SERIAL_OWL_CONSOLE