From patchwork Thu Feb 2 17:10: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: 9552593 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 B7DF6602F0 for ; Thu, 2 Feb 2017 17:10:55 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id ADC561FFC9 for ; Thu, 2 Feb 2017 17:10:55 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A27AC28499; Thu, 2 Feb 2017 17:10:55 +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 4A8B71FFC9 for ; Thu, 2 Feb 2017 17:10:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752241AbdBBRKy (ORCPT ); Thu, 2 Feb 2017 12:10:54 -0500 Received: from mail-wm0-f68.google.com ([74.125.82.68]:33004 "EHLO mail-wm0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752215AbdBBRKy (ORCPT ); Thu, 2 Feb 2017 12:10:54 -0500 Received: by mail-wm0-f68.google.com with SMTP id v77so5319902wmv.0; Thu, 02 Feb 2017 09:10:53 -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=QF3rDbo5oHu6XagWF9PzpUhUdVvp8KeIkJHhiqwkWBE=; b=MZJD/r9W7v5mbuqOZLzwILbH2Y/5jt46EJfrNiU+S7q8om0JoLy1a/JVZo2GaFdHhe Lh2r3hhvBNJ3xKMAXiMY1GJnptG2ve5jj5b+oFwk3jVblM4UqNxlDCVaIDnpk/IcHRiv 0ejcEr742hAPwavD/YGbYz4RkmQb5i/tFsLGxgfHpk49TlmpcTh4+eDneWWypxKY8rUF qNFcTFnd05Hr58ibsl+/tPfGxIRlIm7fi21pbZjVvLG9cTJxdyQM+E4GnEThxbkKRcVO P5MxgcgDuvK4eWS6NIQUfdbJ9mASDt1q7q2FAGsOdEDU05VyC0SCvzXQ3SIoEiHLQHBm V2aA== 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=QF3rDbo5oHu6XagWF9PzpUhUdVvp8KeIkJHhiqwkWBE=; b=Ib+ikwyTerfKeaFjKPbdc46pFIPQDMmEV8D0qGW0QC8CLnmrnOq85ynmhKdGU2BDSP D0RlLrMSFaY9/QigTogJ07sfm1dPGtAXlsfsmC9A+l61e5018HcWQO98PSC0SSc+3g4r 7+4x+VHISkEdW4Hsz/9mmqikNPdf91HSHJl3t1s6FiLn0EB/ICckSsxhbHCos5sI82qy voOBLShl6eFVAIMeXpzoDxvO0OHpESX3ioqDFM+Ta41eoNNe9WghSbGZhkhO+f4w5s9U O9bfkN0Kk5fe0kyCQD/YtLGRXhjC9svJtLbTzQ2dJYQRzgm7S77wFKZrhV/jKIaG+p4/ 7sxw== X-Gm-Message-State: AIkVDXI16IwHPOJ28a1wwndeCqFV3j0jMEXcdwFDhsVrdRTFKDX+1vYm7r8/J6PLOmDj+w== X-Received: by 10.28.63.5 with SMTP id m5mr8925722wma.95.1486055452479; Thu, 02 Feb 2017 09:10:52 -0800 (PST) Received: from groucho.site (ipbcc0353e.dynamic.kabel-deutschland.de. [188.192.53.62]) by smtp.gmail.com with ESMTPSA id l67sm4146040wmf.1.2017.02.02.09.10.48 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 02 Feb 2017 09:10:50 -0800 (PST) From: Ulrich Hecht To: linux-renesas-soc@vger.kernel.org, wsa@the-dreams.de, geert@linux-m68k.org Cc: linux-serial@vger.kernel.org, magnus.damm@gmail.com, sergei.shtylyov@cogentembedded.com, gregkh@linuxfoundation.org, Ulrich Hecht Subject: [PATCH v3 6/7] serial: sh-sci: make RX FIFO parameters tunable via sysfs Date: Thu, 2 Feb 2017 18:10:19 +0100 Message-Id: <1486055420-31595-7-git-send-email-ulrich.hecht+renesas@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1486055420-31595-1-git-send-email-ulrich.hecht+renesas@gmail.com> References: <1486055420-31595-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 17a2be3..5bbcb3b 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) { @@ -2891,6 +2951,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; } @@ -3056,6 +3125,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