Received: by 2002:a25:ef43:0:0:0:0:0 with SMTP id w3csp648824ybm; Fri, 29 May 2020 08:52:55 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw5DcAtpYrgPRaoicUAW4SOdaSiibUxwVF1L3D+NjGL+6F0UVr96UMS3weHJgBWdr5RMAej X-Received: by 2002:a05:6402:1cad:: with SMTP id cz13mr9123609edb.56.1590767574927; Fri, 29 May 2020 08:52:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590767574; cv=none; d=google.com; s=arc-20160816; b=KuddEVUXWDL+EM5CY9Bll1rRkzqLXim2gDQf+bjEBpUB6k9f4lF+6kvqQuQ0dKFIvz ylnWupAbR5ItdebHwyidmwZTNT8gaj908WpI3mrDNPHHZ36bpJo8AoDM1YqI/b8emS/v Ht+cIzPGpWeW3yaMAfGVrTaI6JlejR8UcaUly5RXVWmUeAafUJScblHDy6R43WckVa/N DVPWfZhQRCtYfriyUvcDKCo41R6vChaWdkAEODQaicFJZHbfPJsi2fRB48L4BpbXyIsj MQolpKY6ixIuWrTaTi3iez+BAMoP81TMP5tee5BNCE3excBGpNuAP8XsvtzHU4SlZC1z frEQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=EsMvt8EiZib5FGRRaF/qmPkTiPSrV02BKHt077M8wMI=; b=gKZ26NzxLKzJyfWa3URu4gki37G+b/7YwfXq62CufxBc0vdURcnmSzYEbrLPXyz/Q7 gENMD6HYpumDUt53y+LHZI9ylV0D6qDeJu27JGRUWZwGSDuMctFMXjy6u4MqiC1NzSxh E1Jo81OVlaB76vPrIL1w0siwCnYPXiobB6i5gxPgRxpYPv1gNxtqWshPgDdyEXUoQPCk WZahI+qK5WlrJMEXhcIX8o1q1AMgtFClei1hDZUq+/YHlfsAv42tA6eII9o5JxPsdNCh nmMPQMtKpHPqsMOLrmC0rxKRB7kkcNyXk3qRUWzu3Eob2emZIbGysqgEBc+H1XTH/IBf 3H0Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=cGUtShBa; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id z20si2932866eja.58.2020.05.29.08.52.31; Fri, 29 May 2020 08:52:54 -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=@gmail.com header.s=20161025 header.b=cGUtShBa; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727822AbgE2Pub (ORCPT + 99 others); Fri, 29 May 2020 11:50:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53280 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726971AbgE2Pu3 (ORCPT ); Fri, 29 May 2020 11:50:29 -0400 Received: from mail-ed1-x543.google.com (mail-ed1-x543.google.com [IPv6:2a00:1450:4864:20::543]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 20B00C03E969; Fri, 29 May 2020 08:50:29 -0700 (PDT) Received: by mail-ed1-x543.google.com with SMTP id s19so2067098edt.12; Fri, 29 May 2020 08:50:29 -0700 (PDT) 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=EsMvt8EiZib5FGRRaF/qmPkTiPSrV02BKHt077M8wMI=; b=cGUtShBaCi9MqoE1+GESbw69dKQPzfpBkPzL3us2slLVv6fyW3FzZR38Ss0xy1A4Yh 8iss/1gsa3WW9/xeUZSAv4euyAve2ASBsIjapI7OxHttUYUEEopFsOQr5gtW2x5K5DVv xVcOJQyCfYgiQM0ZEi2S3hc4pTM0phT9t8mt4RPzVUv4RbiwbWMbTC4Xda9iJQ19GUFU 4Vuze25Dm/GfmaXfyvhPMotiRoRlhae3fCXG+9MqDgTLBwr0foE2cAwLI/LkEyRSuBXL YPVTXNicS/KYigpGnlH14hS02GzJL0KIS5PDjXI8yWtoebKHBFfq3ifTgX2kWJOrJtmT +e1Q== 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=EsMvt8EiZib5FGRRaF/qmPkTiPSrV02BKHt077M8wMI=; b=tOmhRHW3FDVQMULiSoDaRuLgnK1Sowcr/+B7aCUe+5k06e9p0OuCElPBvaWXKQLxxJ q7wsggLyrtfxGRBoBJ/LIN/hCMvq7Ve66Ctyhb0p2MGX3QoHRCUSm01ea884ZBzv0e3O CIQWYdTdj7juBqFWpwEe8IW39990bwGtqQPFrTmkwrQtIjGj/TTfuguWRoAkQ6G7pG95 KVXvT9a9FPVzwCSS7BtIcFKMG2PiwoLWoFO2ExLcYCZs7ijY1bPCVmD75hXOS6j2v7kj D1YlAwQpqDVGtvZ88DzVGI7dkRcL1hm/8IYduc6LwSlyDujSnhin6HBuAMYDnQAGrlg8 +uwA== X-Gm-Message-State: AOAM532xkH56YbQlztNYW3NeYizuW1UX22HPrjLlXvMNpx4NRBlxTGzh 3S1Rgmj4z7EjjGOqmgffkC4= X-Received: by 2002:a50:bb41:: with SMTP id y59mr8736067ede.311.1590767427825; Fri, 29 May 2020 08:50:27 -0700 (PDT) Received: from localhost.localdomain ([188.27.38.213]) by smtp.gmail.com with ESMTPSA id cz9sm7068103edb.18.2020.05.29.08.50.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 May 2020 08:50:27 -0700 (PDT) From: Cristian Ciocaltea To: =?UTF-8?q?Andreas=20F=C3=A4rber?= , Manivannan Sadhasivam , Greg Kroah-Hartman , Jiri Slaby Cc: linux-serial@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-actions@lists.infradead.org Subject: [PATCH 1/1] tty: serial: owl: Add support for kernel debugger Date: Fri, 29 May 2020 18:50:25 +0300 Message-Id: <6ee88060c129715980592a1ae33c93923916a14b.1590766726.git.cristian.ciocaltea@gmail.com> X-Mailer: git-send-email 2.26.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Implement poll_put_char and poll_get_char callbacks in struct uart_ops that enables OWL UART to be used for KGDB debugging over serial line. Signed-off-by: Cristian Ciocaltea --- drivers/tty/serial/owl-uart.c | 45 ++++++++++++++++++++++++++++++----- 1 file changed, 39 insertions(+), 6 deletions(-) diff --git a/drivers/tty/serial/owl-uart.c b/drivers/tty/serial/owl-uart.c index c2fa2f15d50a..26dcc374dec5 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 @@ -20,13 +21,13 @@ #include #include -#define OWL_UART_PORT_NUM 7 -#define OWL_UART_DEV_NAME "ttyOWL" +#define OWL_UART_PORT_NUM 7 +#define OWL_UART_DEV_NAME "ttyOWL" -#define OWL_UART_CTL 0x000 -#define OWL_UART_RXDAT 0x004 -#define OWL_UART_TXDAT 0x008 -#define OWL_UART_STAT 0x00c +#define OWL_UART_CTL 0x000 +#define OWL_UART_RXDAT 0x004 +#define OWL_UART_TXDAT 0x008 +#define OWL_UART_STAT 0x00c #define OWL_UART_CTL_DWLS_MASK GENMASK(1, 0) #define OWL_UART_CTL_DWLS_5BITS (0x0 << 0) @@ -461,6 +462,34 @@ 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) +{ + u32 c = NO_POLL_CHAR; + + if (!(owl_uart_read(port, OWL_UART_STAT) & OWL_UART_STAT_RFEM)) + c = owl_uart_read(port, OWL_UART_RXDAT); + + return c; +} + +static void owl_uart_poll_put_char(struct uart_port *port, unsigned char c) +{ + /* Wait while TX FIFO is full */ + while (owl_uart_read(port, OWL_UART_STAT) & OWL_UART_STAT_TFFU) + cpu_relax(); + + /* Send the character out */ + owl_uart_write(port, c, OWL_UART_TXDAT); + + /* Wait for transmitter to become empty */ + while (owl_uart_read(port, OWL_UART_STAT) & OWL_UART_STAT_TRFL_MASK) + cpu_relax(); +} + +#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 +505,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 -- 2.26.2