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: 10800873 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 552E16C2 for ; Thu, 7 Feb 2019 11:27:17 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4009C2C617 for ; Thu, 7 Feb 2019 11:27:17 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 343012C662; Thu, 7 Feb 2019 11:27:17 +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=unavailable 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 C5DAC2C59D for ; Thu, 7 Feb 2019 11:27:16 +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=+4zUIOpBH8hrauLt9RO2B9gxhvtu5bRjHw8svJzUR3c=; b=UCBu7OPLo+3Ya6 cKuHIneNgyBSbc7804jt5VzZs8IRbUD6itKDyBBHoyBJ/o92B7zpXiBeMtuNdlR5m7uE4GK1QOoXK 3/Fau2jaRUFijMQz1+i7wbFE4EcGQ9wQ2XLro0wC9QflIu8dyP5gsteodKq/w3JYPdR8dcdenPDra rZriQzmmwbUEQDpyOUx7TBXyv6GYqz1h8xa+hSWZi4ASyV11ZEqjwRaAuyIYcCU6n51FsCVFsaXFL fMFRVrJzheqvppFAtG1l2fazboOcUZ0MSz8DDKpuE7U+F5FQW3wx/ROrfHCpeehEgVEyxggZ8Jst2 RevcllGz2THsDyQXNDXA==; 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 1grhpq-0005Nf-Uc; Thu, 07 Feb 2019 11:27:14 +0000 Received: from mail-ed1-x543.google.com ([2a00:1450:4864:20::543]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1grhpd-0005CY-GZ for linux-amlogic@lists.infradead.org; Thu, 07 Feb 2019 11:27:03 +0000 Received: by mail-ed1-x543.google.com with SMTP id y56so8658691edd.11 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=ltRcEVYTYObGo+ZphlmCpxPlZahGy5mOXhEH2iVZ0XhBLQcZOUut943Dqv11AFigwk xiwnywkwp5ZMcQN71BXbyYjft6rqkDKtK36+OPbYVEN1qGucqgY8gS4z74Hq/JdraY4V 8Hs3i6Fyjj1+qfoI83teR/PdykqR16eBiXBLYdKXHLQJKQ9uefC1DkzBimSpywQOKcBG 17azR1yblI4a136S1DHdYHnUtkxCCBVvpeNUwIGFk0DB+vz6BK96RpkiBqXNRZ4gO+5/ jPoDrdweUKLWrZlRhOhTYSsx3O6QkU0o788tkpFpy3BGMm1xbaS6EZ8L5ljEsCa9qkmb kDMg== X-Gm-Message-State: AHQUAubIizP+f48gcYGRMYiWPWzvcJ8p5q/o61NzZfzpIAmL1/0sJkGU Xkin15rygLsP8Pyg0WotEWDYdQ== 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_724610_F7911E20 X-CRM114-Status: GOOD ( 10.11 ) X-BeenThere: linux-amlogic@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-amlogic" Errors-To: linux-amlogic-bounces+patchwork-linux-amlogic=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