Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp348777ybz; Fri, 24 Apr 2020 01:17:55 -0700 (PDT) X-Google-Smtp-Source: APiQypIwprrgWxxp1kUo3TnQTGE7O8SZ5Ecy5czz9Vy80EyI7VzvbDDdOVdyG9spW+eWNY1DUWr5 X-Received: by 2002:a05:6402:3076:: with SMTP id bs22mr6411510edb.112.1587716275746; Fri, 24 Apr 2020 01:17:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1587716275; cv=none; d=google.com; s=arc-20160816; b=wUXGLjS0EXUI74QlJ0HIhYYaRO4ox1m1ySjRSbQ4OoFVZLRtvV72+r0qmo3LlPgpyf jr+g8wHh72xfBENjaBd/sTMSlQ/GhuGBUoYR+B62LS+fucHH9W/c9Gudbm1ManOIWL5x Jm9c7GbIvNY3X0JV5nZBgTiKVVLnP1RJH1UDFKeirqCasI/ktSnW+Qw4IwkwOWsJoMXQ uETAXNXlmdTggMV7vPMQtrY695SQsn921ozEBAve0bDJj4VnMS7rTI6+51IJcYjVY0hH HBYFAqCPQZtFiXV9PDqJzGZBGwQHbFt/mKV32G5vIxw3X38KgRqzeiNdLdjVuu75a6Do A7Hg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature; bh=mD/kfPP0LJg4RaHAfHE48TNR0vDMyG0NIvrIYBVARm4=; b=vyIpTGYS+osScl2nQJUzxiKhX/kBnuUJ1dLKTehTFMY5t3+5RJ7e3STwqDeA6o97PS 1wyhmoDYAjkBfxoYu8iM1FQOpDqTrLwUvJy3cxsM39rdbyLvT+X9TsmuAVA93DLCo7Dz IcrJdNyCZ+BPDtleSyi+nTQVy3Vnsy8VgZfqBFBnzKzMt5sYW68O9G3ToiOdpaEfz/lV v5rCk+HV4I2icmlhH5RyMfXlnpdTfeaEwaokSzID6MpK3Vtom0//ZMx7eaEWzx/sz1pa o48KCTFE61QWnAR533n2Ti1f8044z8MDdHXj9z8Nvoz/k2s6rKym0OOQw8iD4dHMhjym 0YdQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=U+zdC02v; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id e7si2462347ejx.367.2020.04.24.01.17.31; Fri, 24 Apr 2020 01:17:55 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=U+zdC02v; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726654AbgDXIPA (ORCPT + 99 others); Fri, 24 Apr 2020 04:15:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40460 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726317AbgDXIO7 (ORCPT ); Fri, 24 Apr 2020 04:14:59 -0400 Received: from mail-pj1-x1042.google.com (mail-pj1-x1042.google.com [IPv6:2607:f8b0:4864:20::1042]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 58281C09B046 for ; Fri, 24 Apr 2020 01:14:59 -0700 (PDT) Received: by mail-pj1-x1042.google.com with SMTP id h12so2508243pjz.1 for ; Fri, 24 Apr 2020 01:14:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=mD/kfPP0LJg4RaHAfHE48TNR0vDMyG0NIvrIYBVARm4=; b=U+zdC02vPpa+dW82b5konrmLSoLeQfS1bxJbZyxDYPtJKTL3/ZyaLfUT22Gh6Hb+yQ vdpuVUFR5Mj1U4PSuIHGD9vUt25BRP+1dzf9tl3AD96LnDwcN6PcX2bO0PjuUsRDonzE 9d6O9Ud5RgNBiAloHqRMT9G9djQlKWVxNbQzxSkyu0cFFZIapMhibJhxYCmCumNEy2l0 RU4FIW+Ag6a1rTMYezFeBuu0zZiNE2Iakx8gDg2vyuxt8qajobywkK6QL1duo3J9Ai35 IqnNw40CcBuZ0757a4pwrHuhSXUQeHr+vz39ybQUYZ4+1/vvaVA5kjFpoC/7I/hYcvSs Enig== 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; bh=mD/kfPP0LJg4RaHAfHE48TNR0vDMyG0NIvrIYBVARm4=; b=n1otj2MmiwjZwErZP8uNoK7dUUHZUBtals1UKajDfr/9U+GjjeylwdP41U8bt1Oe+P hUEHZHI8Fduo5BxdMoxzP8VBXUkOj2VB+1TeBdmat4TZzvB8+EJITVLIdbXJJ2wBP7mZ c+UGskx2NobOqQsrw8L9Wyh/72+agg6PsKdUGSvBjskYYUYKt+UR3DjVOi+qI770c1b/ WWOX1eAw27DRojUdzFbbRnYJhrt0jNHbYUi5x2kD+T7457X8wV6HxxtK8QLWVtIjyBq/ RN4Z0ZwOUPd8O/OCeN1BiAWD8oYzHv+qpYm7wNAclzVzAqDk2sX3usy/EOyY/dcWSkJa /8vA== X-Gm-Message-State: AGi0PuZqOhvGsFVcsbW52tAt0jweZov154Jdy50sq/72QGvaKtcASulJ 11oHb5EYq7z6hZZDvfMaoIOJxg== X-Received: by 2002:a17:902:7593:: with SMTP id j19mr8125373pll.62.1587716098746; Fri, 24 Apr 2020 01:14:58 -0700 (PDT) Received: from localhost.localdomain ([117.252.71.186]) by smtp.gmail.com with ESMTPSA id q201sm5080005pfq.40.2020.04.24.01.14.52 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 24 Apr 2020 01:14:57 -0700 (PDT) From: Sumit Garg To: dianders@chromium.org, linux-serial@vger.kernel.org Cc: linux@armlinux.org.uk, gregkh@linuxfoundation.org, jslaby@suse.com, daniel.thompson@linaro.org, jason.wessel@windriver.com, kgdb-bugreport@lists.sourceforge.net, linux-kernel@vger.kernel.org, Sumit Garg Subject: [PATCH] serial: amba-pl011: Support earlycon_kgdboc Date: Fri, 24 Apr 2020 13:43:51 +0530 Message-Id: <1587716031-28199-1-git-send-email-sumit.garg@linaro.org> X-Mailer: git-send-email 2.7.4 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Implement the read() function in the early console driver. With recently added earlycon_kgdboc feature, this allows you to use kgdb to debug fairly early into the system boot. We only bother implementing this if polling is enabled since kgdb can't be enabled without that. Signed-off-by: Sumit Garg --- Depends on kgdb patch series: https://lkml.org/lkml/2020/4/21/1179 drivers/tty/serial/amba-pl011.c | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/drivers/tty/serial/amba-pl011.c b/drivers/tty/serial/amba-pl011.c index 2296bb0..c010f63 100644 --- a/drivers/tty/serial/amba-pl011.c +++ b/drivers/tty/serial/amba-pl011.c @@ -2435,6 +2435,37 @@ static void pl011_early_write(struct console *con, const char *s, unsigned n) uart_console_write(&dev->port, s, n, pl011_putc); } +#ifdef CONFIG_CONSOLE_POLL +static int pl011_getc(struct uart_port *port) +{ + if (readl(port->membase + UART01x_FR) & UART01x_FR_RXFE) + return NO_POLL_CHAR; + + if (port->iotype == UPIO_MEM32) + return readl(port->membase + UART01x_DR); + else + return readb(port->membase + UART01x_DR); +} + +static int pl011_early_read(struct console *con, char *s, unsigned int n) +{ + struct earlycon_device *dev = con->data; + int ch, num_read = 0; + + while (num_read < n) { + ch = pl011_getc(&dev->port); + if (ch == NO_POLL_CHAR) + break; + + s[num_read++] = ch; + } + + return num_read; +} +#else +#define pl011_early_read NULL +#endif + /* * On non-ACPI systems, earlycon is enabled by specifying * "earlycon=pl011,
" on the kernel command line. @@ -2454,6 +2485,7 @@ static int __init pl011_early_console_setup(struct earlycon_device *device, return -ENODEV; device->con->write = pl011_early_write; + device->con->read = pl011_early_read; return 0; } -- 2.7.4