From patchwork Fri Feb 21 10:20:06 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geert Uytterhoeven X-Patchwork-Id: 3695271 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 8C74EBF13A for ; Fri, 21 Feb 2014 10:20:12 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 63F0F20131 for ; Fri, 21 Feb 2014 10:20:11 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 51B6720115 for ; Fri, 21 Feb 2014 10:20:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754765AbaBUKUJ (ORCPT ); Fri, 21 Feb 2014 05:20:09 -0500 Received: from mail-pa0-f43.google.com ([209.85.220.43]:59143 "EHLO mail-pa0-f43.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754761AbaBUKUG (ORCPT ); Fri, 21 Feb 2014 05:20:06 -0500 Received: by mail-pa0-f43.google.com with SMTP id rd3so3266340pab.16 for ; Fri, 21 Feb 2014 02:20:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:date:message-id:subject :from:to:cc:content-type; bh=AWCvuzB4/Z7Mm6wR6KRVmttGwFdmBQmLepKXfFyS/Us=; b=fF536ll9BKy8f8AWMQ/d+OFj0ddvy9lU+8EEE4uV8RU4tCUvv+UTuGSWqTx2HrTRsm eZKAcBcjPkOMfyEMUEzBL/5jViGHfzD5tW4L/hHtcUwtO7AKnHWYA2IBywK2CqL75SCd OPKXdlFqWg5kOtRVq9vpKZwYSW7dqBJcF/FshIxxF04wAySH49GgK8J285qIGsBsy5Al a30+PnlJecrYTHiaKZKWr1tRKmy83JTzPbTtiWDbQP//qnlKpQjN/ryvQhc8Pz7NXZTu TGuezgx8LRKpvgiQuefcyr0u2QPDzcRmWIJbClCQZiTQN+GRpvtW/Gzpwgkb89CONvI9 Kw0g== MIME-Version: 1.0 X-Received: by 10.67.22.100 with SMTP id hr4mr8231589pad.112.1392978006378; Fri, 21 Feb 2014 02:20:06 -0800 (PST) Received: by 10.70.28.195 with HTTP; Fri, 21 Feb 2014 02:20:06 -0800 (PST) In-Reply-To: <87zjlkq1v1.wl%kuninori.morimoto.gx@gmail.com> References: <87zjlkq1v1.wl%kuninori.morimoto.gx@gmail.com> Date: Fri, 21 Feb 2014 11:20:06 +0100 X-Google-Sender-Auth: 9RFl0ZMLKzDR6r6CkF5Aobai0eI Message-ID: Subject: Re: Maybe this is CCF bug From: Geert Uytterhoeven To: Kuninori Morimoto Cc: Simon , Laurent , Morimoto , Magnus , Linux-SH Sender: linux-sh-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-sh@vger.kernel.org X-Spam-Status: No, score=-7.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,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 Hi Morimoto-san, On Fri, Feb 21, 2014 at 9:58 AM, Kuninori Morimoto wrote: > Now, I'm working for sound DT support, > and I noticed common clock setting's strange behavior. > I guess this is bug, but 50% my misunderstanding. > > Now, we have clock index on ${LINUX}/include/dt-bindings/clock/r8a7790-clock.h > For example, r8a7790's MSTP9 case, like this > > /* MSTP9 */ > #define R8A7790_CLK_GPIO5 7 > #define R8A7790_CLK_GPIO4 8 > #define R8A7790_CLK_GPIO3 9 > #define R8A7790_CLK_GPIO2 10 > #define R8A7790_CLK_GPIO1 11 > #define R8A7790_CLK_GPIO0 12 > #define R8A7790_CLK_RCAN1 15 > #define R8A7790_CLK_RCAN0 16 > #define R8A7790_CLK_QSPI_MOD 17 > #define R8A7790_CLK_IICDVFS 26 > #define R8A7790_CLK_I2C3 28 > #define R8A7790_CLK_I2C2 29 > #define R8A7790_CLK_I2C1 30 > #define R8A7790_CLK_I2C0 31 > > and MSTP9 is like this > > mstp9_clks: mstp9_clks@e6150994 { > compatible = "renesas,r8a7790-mstp-clocks", "renesas,cpg-mstp-clocks"; > reg = <0 0xe6150994 0 4>, <0 0xe61509a4 0 4>; > clocks = <&p_clk>, <&p_clk>, <&cpg_clocks R8A7790_CLK_QSPI>, > <&p_clk>, <&p_clk>, <&p_clk>, <&p_clk>; > #clock-cells = <1>; > renesas,clock-indices = < > R8A7790_CLK_RCAN1 R8A7790_CLK_RCAN0 R8A7790_CLK_QSPI_MOD > R8A7790_CLK_I2C3 R8A7790_CLK_I2C2 R8A7790_CLK_I2C1 > R8A7790_CLK_I2C0 > >; > clock-output-names = > "rcan1", "rcan0", "qspi_mod", "i2c3", "i2c2", "i2c1", "i2c0"; > }; > > And, now, spi parent is MSTP9 QSPI MOD > > spi: spi@e6b10000 { > ... > clocks = <&mstp9_clks R8A7790_CLK_QSPI_MOD>; > ... > }; > > This SPI would like to use MSTP9's 17th (= R8A7790_CLK_QSPI_MOD) clock as its parent. > But, mstp9_clks has 7 clocks only. > R8A7790_CLK_xxx means "bit shift", not "index" on DT clock. Documentation/devicetree/bindings/clock/renesas,cpg-mstp-clocks.txt says: The MSTP groups are sparsely populated. Unimplemented gate clocks must not be declared. > On ${LINUX}/drivers/clk/shmobile/clk-mstp.c, > it try to get parent name by > > parent_name = of_clk_get_parent_name(np, i); > > and it returns "mstp9_clks" in this case. > Maybe SPI would like to get "qspi_mod" ? I don't know about of_clk_get_parent_name(), but in the end the QSPI driver does seem to get the right clock, cfr. this output on Lager reference: clk qspi_mod at 97500000 Hz clk qspi at 97500000 Hz clk pll1_div2 at 780000000 Hz clk pll1 at 1560000000 Hz clk main at 20000000 Hz clk extal at 20000000 Hz with the (whitespace-damaged) patch at the end of this email. BTW, you do have these 2 applied? clk: shmobile: rcar-gen2: Fix clock parent all non-PLL clocks clk: shmobile: rcar-gen2: Fix qspi divisor They are not in Simon's repository, but in http://git.linaro.org/people/mike.turquette/linux.git/shortlog/refs/heads/clk-fixes Gr{oetje,eeting}s, Geert --- Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that. -- Linus Torvalds -- To unsubscribe from this list: send the line "unsubscribe linux-sh" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/spi/spi-rspi.c b/drivers/spi/spi-rspi.c index 239bd4206fc6..5ae0cdf96231 100644 --- a/drivers/spi/spi-rspi.c +++ b/drivers/spi/spi-rspi.c @@ -22,6 +22,11 @@ * */ +#ifdef CONFIG_COMMON_CLK +#include +#else +#include +#endif #include #include #include @@ -1311,6 +1316,18 @@ static int rspi_probe(struct platform_device *pdev) goto error1; } +{ + struct clk *clk = rspi->clk; + + while (clk) { +#ifdef CONFIG_COMMON_CLK + printk("clk %s at %lu Hz\n", clk->name, clk_get_rate(clk)); +#else + printk("clk at %lu Hz\n", clk_get_rate(clk)); +#endif + clk = clk->parent; + } +} init_waitqueue_head(&rspi->wait); master->bus_num = pdev->id;