From patchwork Thu Feb 7 11:26:16 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Masson X-Patchwork-Id: 10800871 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id F12F76C2 for ; Thu, 7 Feb 2019 11:27:07 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DE9B12C59D for ; Thu, 7 Feb 2019 11:27:07 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D30EF2C5C6; Thu, 7 Feb 2019 11:27:07 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 39DA82C59D for ; Thu, 7 Feb 2019 11:27:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:Reply-To:List-Subscribe:List-Help: List-Post:List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-ID: References:Date:Subject:To:From:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To: List-Owner; bh=a6M/xNycioX79R9wyPD4KMdTAIBYDQEpfUgaym1vOLc=; b=QkifegbsFQmuET 6nAvRtC9JN+fkW100nl02monZbSBIzzY7hXfJxrRg6fediKKJlrrEb394B0mmkbnTyBRccr5625yK aPq93tusee6nHAkKs2TkTAgj7S/oClA+iblHYCApHv3HwUeQcXJS/8m7vXP74hTz6Be9MmHmQzo0B tRfM7SPH9Uoeovm+xA4lN+Ly13R9xxZNjlp7ETuuIueR3noYSDX+jIM/JRGerKS1iMBx7STzSFR8G PbP6m6IyUTBbKJ63Tq3nggWXT6k/mqyeSQPEL+D+kTEXJcLC9rwrgF0IiyY1H1IGhlVN2p1oxmyho QS/wRcRoyXTqG58U4wIg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1grhpg-0005DS-Vi; Thu, 07 Feb 2019 11:27:04 +0000 Received: from mail-ed1-x541.google.com ([2a00:1450:4864:20::541]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1grhpd-0005CZ-Gw for linux-arm-kernel@lists.infradead.org; Thu, 07 Feb 2019 11:27:03 +0000 Received: by mail-ed1-x541.google.com with SMTP id b17so4534923eds.2 for ; Thu, 07 Feb 2019 03:27:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:references:reply-to:message-id:mime-version; bh=obC/o0x/Of+oiYvDNo+3FmUgPGJAQl+NE5x85eXAQHI=; b=lpGa0Grw3h/abtMaXn8NhnwSyAc4gkosLOJN3rQecVmu/PUkG6561GanDZRktd8Nca SmSdGAm7PK7OLr+TV0dpGPi2QnPfRciLmalt04YeQub95QaqfKMzO5nMopKi6EA51LaA HHqzvMmE6uovrowLcZJf0bK4COmQu/hZ+bfPRRyVE9vJ8tJkjSc/LYeRHaFXueQ5Pfov MMFTeIH4v1IvyDhmAIWOIqikUDlDabQZvovVAWtgJ8/qAynFQH1PCB6a7bbSIrfjKWVf 7v2rQY2Z66S9UFvsAue90atnXEAbwYSrw/JY08p1V/2cCbKHOUWq4l0DVZqZdXHKM66c gKzA== 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:references:reply-to :message-id:mime-version; bh=obC/o0x/Of+oiYvDNo+3FmUgPGJAQl+NE5x85eXAQHI=; b=Wt7CYVF0kpmiPWw26MVzox0bAB9Wo4LoD/R7+CDvxhkMdC57RhaKEU6OMSsThUhDt6 7Nxj16d8UJMpmKSidBqdZHzWCfHTeEhEUuDlAIHSg5ixd3yG0RdT172vi7eaFV0ks3Ob X9QTnoRtuQnJU1i3iamZMzpSX2TdOxLEZY5id/crEsLauXD1boL10KF88nOdLrYICO+F Qlss01mBjvBDPFUfGi/TSRkupzBporzVijO7GbCW7zXiJtjZuAjg5I3oO+jrPMaydwJ3 YjDeNmu/zmVLVcphtd2elOTgQAL2bRvFcGJzxBMlhAtu0u/dgwobar90SPWQqiHtPcSm CjHw== X-Gm-Message-State: AHQUAuZ5oaPE6EgZuedxKk57yfj6eA2TAxPa6vQoh5aDCB+4ddIJLdsE 1IAfe+iDqeqL/eIO6QzvxL8U5w== X-Google-Smtp-Source: AHgI3IaacZRmJNMHtyYLIrXWsYmX+kBY4nCl0BEnTm3g+kmpaGvMP3TR483tFqfu5leYPUmmyCMgkg== X-Received: by 2002:aa7:c0c8:: with SMTP id j8mr4962862edp.94.1549538818755; Thu, 07 Feb 2019 03:26:58 -0800 (PST) Received: from localhost ([2620:10d:c092:180::1:a0f9]) by smtp.gmail.com with ESMTPSA id e26sm3239012eja.9.2019.02.07.03.26.57 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 07 Feb 2019 03:26:58 -0800 (PST) From: Julien Masson To: Kevin Hilman , Greg Kroah-Hartman Subject: [PATCH 1/2] tty: serial: meson_uart: Add support for kernel debugger Date: Thu, 7 Feb 2019 12:26:16 +0100 References: <86h8dfx2jv.fsf@gmail.com> Message-ID: <86ftszx2im.fsf@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190207_032701_720091_C4A122AA X-CRM114-Status: GOOD ( 11.68 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: 86h8dfx2jv.fsf@gmail.com Cc: Julien Masson , linux-kernel@vger.kernel.org, linux-serial@vger.kernel.org, Jiri Slaby , linux-amlogic@lists.infradead.org, linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP The kgdb invokes the poll_put_char and poll_get_char when communicating with the host. This patch implement the serial polling hooks for the meson_uart to be used for KGDB debugging over serial line. Signed-off-by: Julien Masson --- drivers/tty/serial/meson_uart.c | 46 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/drivers/tty/serial/meson_uart.c b/drivers/tty/serial/meson_uart.c index 8a84259..49b20da 100644 --- a/drivers/tty/serial/meson_uart.c +++ b/drivers/tty/serial/meson_uart.c @@ -426,6 +426,48 @@ static void meson_uart_config_port(struct uart_port *port, int flags) } } +#ifdef CONFIG_CONSOLE_POLL +/* + * Console polling routines for writing and reading from the uart while + * in an interrupt or debug context (i.e. kgdb). + */ + +static int meson_uart_poll_get_char(struct uart_port *port) +{ + u32 c; + unsigned long flags; + + spin_lock_irqsave(&port->lock, flags); + + if (readl(port->membase + AML_UART_STATUS) & AML_UART_RX_EMPTY) + c = NO_POLL_CHAR; + else + c = readl(port->membase + AML_UART_RFIFO); + + spin_unlock_irqrestore(&port->lock, flags); + + return c; +} + +static void meson_uart_poll_put_char(struct uart_port *port, unsigned char c) +{ + unsigned long flags; + + spin_lock_irqsave(&port->lock, flags); + + while (!(readl(port->membase + AML_UART_STATUS) & AML_UART_TX_EMPTY)) + cpu_relax(); + + writel(c, port->membase + AML_UART_WFIFO); + + while (!(readl(port->membase + AML_UART_STATUS) & AML_UART_TX_EMPTY)) + cpu_relax(); + + spin_unlock_irqrestore(&port->lock, flags); +} + +#endif /* CONFIG_CONSOLE_POLL */ + static const struct uart_ops meson_uart_ops = { .set_mctrl = meson_uart_set_mctrl, .get_mctrl = meson_uart_get_mctrl, @@ -441,6 +483,10 @@ static const struct uart_ops meson_uart_ops = { .request_port = meson_uart_request_port, .release_port = meson_uart_release_port, .verify_port = meson_uart_verify_port, +#ifdef CONFIG_CONSOLE_POLL + .poll_get_char = meson_uart_poll_get_char, + .poll_put_char = meson_uart_poll_put_char, +#endif }; #ifdef CONFIG_SERIAL_MESON_CONSOLE