From patchwork Fri Feb 3 10:38:19 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulrich Hecht X-Patchwork-Id: 9553857 X-Patchwork-Delegate: geert@linux-m68k.org Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id A9262604A7 for ; Fri, 3 Feb 2017 10:38:39 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9BB7E28425 for ; Fri, 3 Feb 2017 10:38:39 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8F1432851B; Fri, 3 Feb 2017 10:38:39 +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=-6.3 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3811328425 for ; Fri, 3 Feb 2017 10:38:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752274AbdBCKii (ORCPT ); Fri, 3 Feb 2017 05:38:38 -0500 Received: from mail-wm0-f65.google.com ([74.125.82.65]:35837 "EHLO mail-wm0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752219AbdBCKii (ORCPT ); Fri, 3 Feb 2017 05:38:38 -0500 Received: by mail-wm0-f65.google.com with SMTP id u63so3474579wmu.2; Fri, 03 Feb 2017 02:38:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=GtcamAA20TH8OzUQ//I6SaSN+NvFJrxJIL2lc4TWZdQ=; b=iPh2yGyI8wr79Cj+Zpk1sMKLQ6ClusI8lOsmZGUmDfy6QoDHA1jjX/IgEHA5lLo2KX fbWU37ftM8teQWU/K/qs1786NLcHXfuhDRcr005felgT7eo4KRPJnlAxcIoEpYpcnGg4 ZVuGoz6aWQm3AlBybFB1hv8oxev/yDw+nur2XQKX0zsgJQ45e544YZPjNbwTaNOki55E L07K5X4xPsLmpbqQwGRHD/RJ90m+6h5mz8uYCQE21sNnFZe0r97LGWttq2AAeeSmfDhw X2pWbTGf5g43kBdB9kceL9/Ykw6vs3r19AuXhU8fhHv00c1pwcRCcFAZg8UifMsy+c5p CliQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=GtcamAA20TH8OzUQ//I6SaSN+NvFJrxJIL2lc4TWZdQ=; b=P1ASbO3iP9oE0weeEsGQxz9gKEjGxwEnBL2hP4hblHXguOCRPV9B7w1LbmQQUMaKxm XnEPpUt5o/ZC8md2wiO5NAESKusqk3ECQpVjse9jgFPqmq0kPtUtikXI+Npvcel2ggGE Ox0BWzfUP2vSbylualBx7/MWZq45/JSbz6BPM8IzXk4OEo64ugccNjSbgZIvgGSNLgpf /jRN6WhI2KvXcmuGhApQXsDRrxgP9FiD0pact4B8s8MJ0cL3TkcPDPvVE58yVfEGMzU1 ssWU3vruC5d6HTMyJVTQcSCwSTU9sDGvBvZnrXHa79EUID9Syb8gEVJvv41VQ9Th6PUH /79w== X-Gm-Message-State: AMke39n+rWPJNE8Hc2r3H5fH2ue8SbC/0/LpzDa0sjovv2bds3yXVgdEBM3wFalZrb6W1g== X-Received: by 10.28.109.70 with SMTP id i67mr747891wmc.102.1486118316376; Fri, 03 Feb 2017 02:38:36 -0800 (PST) Received: from groucho.site (ipbcc0353e.dynamic.kabel-deutschland.de. [188.192.53.62]) by smtp.gmail.com with ESMTPSA id 186sm2278913wmw.24.2017.02.03.02.38.35 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 03 Feb 2017 02:38:35 -0800 (PST) From: Ulrich Hecht To: linux-renesas-soc@vger.kernel.org, geert@linux-m68k.org, gregkh@linuxfoundation.org Cc: wsa@the-dreams.de, linux-serial@vger.kernel.org, magnus.damm@gmail.com, sergei.shtylyov@cogentembedded.com, Ulrich Hecht Subject: [PATCH v4 3/4] serial: sh-sci: make RX FIFO parameters tunable via sysfs Date: Fri, 3 Feb 2017 11:38:19 +0100 Message-Id: <1486118300-12633-4-git-send-email-ulrich.hecht+renesas@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1486118300-12633-1-git-send-email-ulrich.hecht+renesas@gmail.com> References: <1486118300-12633-1-git-send-email-ulrich.hecht+renesas@gmail.com> Sender: linux-renesas-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-renesas-soc@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Allows tuning of the RX FIFO fill threshold and timeout. (The latter is only applicable to SCIFA and SCIFB). Signed-off-by: Ulrich Hecht Reviewed-by: Geert Uytterhoeven --- drivers/tty/serial/sh-sci.c | 87 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 87 insertions(+) diff --git a/drivers/tty/serial/sh-sci.c b/drivers/tty/serial/sh-sci.c index 4a165ed..f95a56c 100644 --- a/drivers/tty/serial/sh-sci.c +++ b/drivers/tty/serial/sh-sci.c @@ -1055,6 +1055,66 @@ static void rx_fifo_timer_fn(unsigned long arg) scif_set_rtrg(port, 1); } +static ssize_t rx_trigger_show(struct device *dev, + struct device_attribute *attr, + char *buf) +{ + struct uart_port *port = dev_get_drvdata(dev); + struct sci_port *sci = to_sci_port(port); + + return sprintf(buf, "%d\n", sci->rx_trigger); +} + +static ssize_t rx_trigger_store(struct device *dev, + struct device_attribute *attr, + const char *buf, + size_t count) +{ + struct uart_port *port = dev_get_drvdata(dev); + struct sci_port *sci = to_sci_port(port); + long r; + + if (kstrtol(buf, 0, &r) == -EINVAL) + return -EINVAL; + sci->rx_trigger = scif_set_rtrg(port, r); + scif_set_rtrg(port, 1); + return count; +} + +static DEVICE_ATTR(rx_fifo_trigger, 0644, rx_trigger_show, rx_trigger_store); + +static ssize_t rx_fifo_timeout_show(struct device *dev, + struct device_attribute *attr, + char *buf) +{ + struct uart_port *port = dev_get_drvdata(dev); + struct sci_port *sci = to_sci_port(port); + + return sprintf(buf, "%d\n", sci->rx_fifo_timeout); +} + +static ssize_t rx_fifo_timeout_store(struct device *dev, + struct device_attribute *attr, + const char *buf, + size_t count) +{ + struct uart_port *port = dev_get_drvdata(dev); + struct sci_port *sci = to_sci_port(port); + long r; + + if (kstrtol(buf, 0, &r) == -EINVAL) + return -EINVAL; + sci->rx_fifo_timeout = r; + scif_set_rtrg(port, 1); + if (r > 0) + setup_timer(&sci->rx_fifo_timer, rx_fifo_timer_fn, + (unsigned long)sci); + return count; +} + +static DEVICE_ATTR(rx_fifo_timeout, 0644, rx_fifo_timeout_show, rx_fifo_timeout_store); + + #ifdef CONFIG_SERIAL_SH_SCI_DMA static void sci_dma_tx_complete(void *arg) { @@ -2886,6 +2946,15 @@ static int sci_remove(struct platform_device *dev) sci_cleanup_single(port); + if (port->port.fifosize > 1) { + sysfs_remove_file(&dev->dev.kobj, + &dev_attr_rx_fifo_trigger.attr); + } + if (port->port.type == PORT_SCIFA || port->port.type == PORT_SCIFB) { + sysfs_remove_file(&dev->dev.kobj, + &dev_attr_rx_fifo_timeout.attr); + } + return 0; } @@ -3051,6 +3120,24 @@ static int sci_probe(struct platform_device *dev) if (ret) return ret; + if (sp->port.fifosize > 1) { + ret = sysfs_create_file(&dev->dev.kobj, + &dev_attr_rx_fifo_trigger.attr); + if (ret) + return ret; + } + if (sp->port.type == PORT_SCIFA || sp->port.type == PORT_SCIFB) { + ret = sysfs_create_file(&dev->dev.kobj, + &dev_attr_rx_fifo_timeout.attr); + if (ret) { + if (sp->port.fifosize > 1) { + sysfs_remove_file(&dev->dev.kobj, + &dev_attr_rx_fifo_trigger.attr); + } + return ret; + } + } + #ifdef CONFIG_SH_STANDARD_BIOS sh_bios_gdb_detach(); #endif