From patchwork Fri Sep 12 08:51:48 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulrich Hecht X-Patchwork-Id: 4892801 X-Patchwork-Delegate: geert@linux-m68k.org Return-Path: X-Original-To: patchwork-linux-sh@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 55344BEEA5 for ; Fri, 12 Sep 2014 08:52:14 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id E17B82012E for ; Fri, 12 Sep 2014 08:52:12 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 3CD71201F4 for ; Fri, 12 Sep 2014 08:52:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753134AbaILIwG (ORCPT ); Fri, 12 Sep 2014 04:52:06 -0400 Received: from mail-lb0-f172.google.com ([209.85.217.172]:35959 "EHLO mail-lb0-f172.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753059AbaILIwE (ORCPT ); Fri, 12 Sep 2014 04:52:04 -0400 Received: by mail-lb0-f172.google.com with SMTP id w7so483919lbi.31 for ; Fri, 12 Sep 2014 01:52:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=ccdxuo9fzMfpDpR6mgjf8rR+Bg6Rbqh2COgjUFpa49E=; b=F84vvQgHjYTrFYWFj30yxwfxt0x7c3MKfWSerL4BABvF0BY0WpRPz6OoNgXgu1NVOG NXxWPrOuvIb1a7MGaIyLeln/efPimmx0FhhLXqYGX+vOz80LPGw/ysDX9NspgoLd48PY Q9fcZ5N973Mo/iMr+1pTjqrpuSnWDS/fcMWBQQ7N6EfT8IFDKvof7ghTz/xT8X0oBfVu XF/PrqCpg0cw3cLo2KSTf3/EOqoR119CDwXdITpeX/0YrTZz43wv26bFm65J7t7MlDWh CB37RDy1n9vIoGCe1j+Xvq4ulzxABioYkNIQONgurRta4+5HjD1ZQyIAaCiXCzf17h+k o0rg== X-Received: by 10.112.56.206 with SMTP id c14mr6866696lbq.27.1410511923267; Fri, 12 Sep 2014 01:52:03 -0700 (PDT) Received: from groucho.site ([185.3.135.58]) by mx.google.com with ESMTPSA id cm9sm1107745lbb.39.2014.09.12.01.52.01 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 12 Sep 2014 01:52:02 -0700 (PDT) From: Ulrich Hecht To: linux-sh@vger.kernel.org, linux-serial@vger.kernel.org Cc: horms@verge.net.au, magnus.damm@gmail.com, Ulrich Hecht Subject: [RFC 3/3] serial: sh-sci: make RX FIFO trigger tunable via sysfs Date: Fri, 12 Sep 2014 10:51:48 +0200 Message-Id: <1410511908-9282-4-git-send-email-ulrich.hecht+renesas@gmail.com> X-Mailer: git-send-email 1.8.4.5 In-Reply-To: <1410511908-9282-1-git-send-email-ulrich.hecht+renesas@gmail.com> References: <1410511908-9282-1-git-send-email-ulrich.hecht+renesas@gmail.com> Sender: linux-sh-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-sh@vger.kernel.org X-Spam-Status: No, score=-8.8 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RCVD_IN_SBL, RP_MATCHES_RCVD, T_DKIM_INVALID,UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Allows tuning of the RX FIFO interrupt threshold in case there are problems with buffer overruns or latency. Signed-off-by: Ulrich Hecht --- drivers/tty/serial/sh-sci.c | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/drivers/tty/serial/sh-sci.c b/drivers/tty/serial/sh-sci.c index 78aeec1..a72ba5c 100644 --- a/drivers/tty/serial/sh-sci.c +++ b/drivers/tty/serial/sh-sci.c @@ -1913,6 +1913,30 @@ static void scif_set_rtrg(struct uart_port *port) serial_port_out(port, SCFCR, serial_port_in(port, SCFCR) | bits); } +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); + int r = simple_strtol(buf, NULL, 0); + sci->rx_trigger = r; + scif_set_rtrg(port); + return count; +} + +static DEVICE_ATTR(rx_trigger_level, 0644, rx_trigger_show, rx_trigger_store); + static void sci_reset(struct uart_port *port) { struct plat_sci_reg *reg; @@ -2516,6 +2540,11 @@ 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_trigger_level.attr); + } + return 0; } @@ -2660,6 +2689,13 @@ 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_trigger_level.attr); + if (ret) + return ret; + } + sp->freq_transition.notifier_call = sci_notifier; ret = cpufreq_register_notifier(&sp->freq_transition,