From patchwork Mon Dec 14 18:57:10 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geert Uytterhoeven X-Patchwork-Id: 7847141 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.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id A3F12BEEE1 for ; Mon, 14 Dec 2015 18:59:13 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id ACCAB202E9 for ; Mon, 14 Dec 2015 18:59:12 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 5FF5E2038F for ; Mon, 14 Dec 2015 18:59:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932099AbbLNS7F (ORCPT ); Mon, 14 Dec 2015 13:59:05 -0500 Received: from xavier.telenet-ops.be ([195.130.132.52]:46993 "EHLO xavier.telenet-ops.be" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932111AbbLNS5p (ORCPT ); Mon, 14 Dec 2015 13:57:45 -0500 Received: from ayla.of.borg ([84.195.106.123]) by xavier.telenet-ops.be with bizsmtp id tWxi1r01K2fm56U01WxiS9; Mon, 14 Dec 2015 19:57:43 +0100 Received: from ramsan.of.borg ([192.168.97.29] helo=ramsan) by ayla.of.borg with esmtp (Exim 4.82) (envelope-from ) id 1a8YJZ-0002tN-SH; Mon, 14 Dec 2015 19:57:41 +0100 Received: from geert by ramsan with local (Exim 4.82) (envelope-from ) id 1a8YJd-0000Ge-A9; Mon, 14 Dec 2015 19:57:45 +0100 From: Geert Uytterhoeven To: Greg Kroah-Hartman , Simon Horman , Magnus Damm , Yoshinori Sato Cc: linux-serial@vger.kernel.org, linux-sh@vger.kernel.org, Laurent Pinchart , devicetree@vger.kernel.org, Geert Uytterhoeven Subject: [PATCH v3 01/27] serial: sh-sci: Drop the interface clock Date: Mon, 14 Dec 2015 19:57:10 +0100 Message-Id: <1450119456-964-2-git-send-email-geert+renesas@glider.be> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1450119456-964-1-git-send-email-geert+renesas@glider.be> References: <1450119456-964-1-git-send-email-geert+renesas@glider.be> Sender: linux-sh-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-sh@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable 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 From: Laurent Pinchart As no platform defines an interface clock the SCI driver always falls back to a clock named "peripheral_clk". - On SH platforms that clock is the base clock for the SCI functional clock and has the same frequency, - On ARM platforms that clock doesn't exist, and clk_get() will return the default clock for the device. We can thus make the functional clock mandatory and drop the interface clock. EPROBE_DEFER is handled for clocks that may be referenced from DT (i.e. "fck", and the deprecated "sci_ick"). Cc: devicetree@vger.kernel.org Signed-off-by: Laurent Pinchart Acked-by: Simon Horman [geert: Handle EPROBE_DEFER, reformat description, break long comment line] Signed-off-by: Geert Uytterhoeven Acked-by: Rob Herring Acked-by: Greg Kroah-Hartman --- v3: - Add Acked-by, v2: - Add Acked-by, - Amendment by geert. --- .../bindings/serial/renesas,sci-serial.txt | 4 +- drivers/tty/serial/sh-sci.c | 64 ++++++++++++++-------- 2 files changed, 43 insertions(+), 25 deletions(-) diff --git a/Documentation/devicetree/bindings/serial/renesas,sci-serial.txt b/Documentation/devicetree/bindings/serial/renesas,sci-serial.txt index 73f825e5e6448815..2c9e6b8477e92792 100644 --- a/Documentation/devicetree/bindings/serial/renesas,sci-serial.txt +++ b/Documentation/devicetree/bindings/serial/renesas,sci-serial.txt @@ -42,7 +42,7 @@ Required properties: - clocks: Must contain a phandle and clock-specifier pair for each entry in clock-names. - - clock-names: Must contain "sci_ick" for the SCIx UART interface clock. + - clock-names: Must contain "fck" for the SCIx UART functional clock. Note: Each enabled SCIx UART should have an alias correctly numbered in the "aliases" node. @@ -63,7 +63,7 @@ Example: interrupt-parent = <&gic>; interrupts = <0 144 IRQ_TYPE_LEVEL_HIGH>; clocks = <&mstp2_clks R8A7790_CLK_SCIFA0>; - clock-names = "sci_ick"; + clock-names = "fck"; dmas = <&dmac0 0x21>, <&dmac0 0x22>; dma-names = "tx", "rx"; }; diff --git a/drivers/tty/serial/sh-sci.c b/drivers/tty/serial/sh-sci.c index 960e50a97558cff5..cc6fa55231ba3536 100644 --- a/drivers/tty/serial/sh-sci.c +++ b/drivers/tty/serial/sh-sci.c @@ -92,8 +92,6 @@ struct sci_port { struct timer_list break_timer; int break_flag; - /* Interface clock */ - struct clk *iclk; /* Function clock */ struct clk *fclk; @@ -457,9 +455,8 @@ static void sci_port_enable(struct sci_port *sci_port) pm_runtime_get_sync(sci_port->port.dev); - clk_prepare_enable(sci_port->iclk); - sci_port->port.uartclk = clk_get_rate(sci_port->iclk); clk_prepare_enable(sci_port->fclk); + sci_port->port.uartclk = clk_get_rate(sci_port->fclk); } static void sci_port_disable(struct sci_port *sci_port) @@ -476,7 +473,6 @@ static void sci_port_disable(struct sci_port *sci_port) sci_port->break_flag = 0; clk_disable_unprepare(sci_port->fclk); - clk_disable_unprepare(sci_port->iclk); pm_runtime_put_sync(sci_port->port.dev); } @@ -1622,7 +1618,7 @@ static int sci_notifier(struct notifier_block *self, struct uart_port *port = &sci_port->port; spin_lock_irqsave(&port->lock, flags); - port->uartclk = clk_get_rate(sci_port->iclk); + port->uartclk = clk_get_rate(sci_port->fclk); spin_unlock_irqrestore(&port->lock, flags); } @@ -2241,6 +2237,42 @@ static struct uart_ops sci_uart_ops = { #endif }; +static int sci_init_clocks(struct sci_port *sci_port, struct device *dev) +{ + /* Get the SCI functional clock. It's called "fck" on ARM. */ + sci_port->fclk = clk_get(dev, "fck"); + if (PTR_ERR(sci_port->fclk) == -EPROBE_DEFER) + return -EPROBE_DEFER; + if (!IS_ERR(sci_port->fclk)) + return 0; + + /* + * But it used to be called "sci_ick", and we need to maintain DT + * backward compatibility. + */ + sci_port->fclk = clk_get(dev, "sci_ick"); + if (PTR_ERR(sci_port->fclk) == -EPROBE_DEFER) + return -EPROBE_DEFER; + if (!IS_ERR(sci_port->fclk)) + return 0; + + /* SH has historically named the clock "sci_fck". */ + sci_port->fclk = clk_get(dev, "sci_fck"); + if (!IS_ERR(sci_port->fclk)) + return 0; + + /* + * Not all SH platforms declare a clock lookup entry for SCI devices, + * in which case we need to get the global "peripheral_clk" clock. + */ + sci_port->fclk = clk_get(dev, "peripheral_clk"); + if (!IS_ERR(sci_port->fclk)) + return 0; + + dev_err(dev, "failed to get functional clock\n"); + return PTR_ERR(sci_port->fclk); +} + static int sci_init_single(struct platform_device *dev, struct sci_port *sci_port, unsigned int index, struct plat_sci_port *p, bool early) @@ -2333,22 +2365,9 @@ static int sci_init_single(struct platform_device *dev, sci_port->sampling_rate = p->sampling_rate; if (!early) { - sci_port->iclk = clk_get(&dev->dev, "sci_ick"); - if (IS_ERR(sci_port->iclk)) { - sci_port->iclk = clk_get(&dev->dev, "peripheral_clk"); - if (IS_ERR(sci_port->iclk)) { - dev_err(&dev->dev, "can't get iclk\n"); - return PTR_ERR(sci_port->iclk); - } - } - - /* - * The function clock is optional, ignore it if we can't - * find it. - */ - sci_port->fclk = clk_get(&dev->dev, "sci_fck"); - if (IS_ERR(sci_port->fclk)) - sci_port->fclk = NULL; + ret = sci_init_clocks(sci_port, &dev->dev); + if (ret < 0) + return ret; port->dev = &dev->dev; @@ -2405,7 +2424,6 @@ static int sci_init_single(struct platform_device *dev, static void sci_cleanup_single(struct sci_port *port) { - clk_put(port->iclk); clk_put(port->fclk); pm_runtime_disable(port->port.dev);