From patchwork Mon Jan 16 18:47:59 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Lechner X-Patchwork-Id: 9519325 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 C3880601C3 for ; Mon, 16 Jan 2017 19:02:01 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B396627BFF for ; Mon, 16 Jan 2017 19:02:01 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A867E28306; Mon, 16 Jan 2017 19:02:01 +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=-4.1 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED, T_DKIM_INVALID autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 26B1027BFF for ; Mon, 16 Jan 2017 19:02:00 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1cTCXW-0001gf-Ce; Mon, 16 Jan 2017 19:01:58 +0000 Received: from casper.infradead.org ([2001:770:15f::2]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1cTCXU-0001d9-Un for linux-arm-kernel@bombadil.infradead.org; Mon, 16 Jan 2017 19:01:57 +0000 Received: from vern.gendns.com ([206.190.152.46]) by casper.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1cTCNN-0002n7-29 for linux-arm-kernel@lists.infradead.org; Mon, 16 Jan 2017 18:51:31 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lechnology.com; s=default; h=Content-Transfer-Encoding:Content-Type: In-Reply-To:MIME-Version:Date:Message-ID:From:Cc:References:To:Subject:Sender :Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=R0GUN6Z7jjEGpPUY6VWJSZqp0xTCyrBVeIXj31QPgsA=; b=tkOtOJVf/WmCyuovnJzsBeRsFb uC6Ar7O4ONpi7DexN/8NkglEC3wdg28YMq/XQamIZCU/Bt3IleKaBKIe26UlhGtneTE8F8CcUaDms UFuUU0F0NVfCQwFyUA0QQlwh08IQhd6bJYMjI0CnkSqZ2agg4YaO04latRaQBBkGr4hiu+mxp9L3b 0wplEXDHU3bNJrUpZPTf5kNRCy1UkBKeHZWbT7gVkCMJfnKNiDsPCYXcmCdogMlOahE2uD4pp13WW yu4MoGJOdHZsmR/i6IVylyXdDdfXD/t35ONg+UVEKRQks1baXuK/AvUAGvDkXS9iJdruN3rGrX00c LvElpd3w==; Received: from 108-198-5-147.lightspeed.okcbok.sbcglobal.net ([108.198.5.147]:38354 helo=[192.168.0.113]) by vern.gendns.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES128-GCM-SHA256:128) (Exim 4.87) (envelope-from ) id 1cTCJv-0004Ur-Ql; Mon, 16 Jan 2017 13:47:55 -0500 Subject: Re: [PATCH 03/10] devicetree: bindings: add bindings for ahci-da850 To: Bartosz Golaszewski , Sekhar Nori References: <1484311084-31547-1-git-send-email-bgolaszewski@baylibre.com> <1484311084-31547-4-git-send-email-bgolaszewski@baylibre.com> <35ff358d-9b17-b2be-38d8-6a51cdddc1a1@lechnology.com> From: David Lechner Message-ID: Date: Mon, 16 Jan 2017 12:47:59 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.5.1 MIME-Version: 1.0 In-Reply-To: X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - vern.gendns.com X-AntiAbuse: Original Domain - lists.infradead.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - lechnology.com X-Get-Message-Sender-Via: vern.gendns.com: authenticated_id: davidmain+lechnology.com/only user confirmed/virtual account not confirmed X-Authenticated-Sender: vern.gendns.com: davidmain@lechnology.com X-Source: X-Source-Args: X-Source-Dir: X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170116_185129_237022_716E3D56 X-CRM114-Status: GOOD ( 32.09 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mark Rutland , linux-devicetree , Kevin Hilman , Michael Turquette , Russell King , LKML , linux-ide@vger.kernel.org, Rob Herring , Patrick Titiano , Tejun Heo , arm-soc Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP On 01/16/2017 08:30 AM, Bartosz Golaszewski wrote: > 2017-01-16 13:45 GMT+01:00 Sekhar Nori : >> On Monday 16 January 2017 03:43 PM, Bartosz Golaszewski wrote: >>> 2017-01-13 20:25 GMT+01:00 David Lechner : >>>> >>>> A clock multiplier property seems redundant if you are specifying a clock. >>>> It should be possible to get the rate from the clock to determine which >>>> multiplier is needed. >>>> >>> >>> I probably should have named it differently. This is not a multiplier >>> of a clock derived from PLL0 or PLL1. Instead it's a value set by >>> writing to the Port PHY Control Register (MPY bits) of the SATA >>> controller that configures the multiplier for the external low-jitter >>> clock. On the lcdk the signals (REFCLKP, REFCLKN) are provided by >>> CDCM61001 (SATA OSCILLATOR component on the schematics). >>> >>> I'll find a better name and comment the property accordingly. >>> >>> FYI: the da850 platform does not use the common clock framework, so I >>> don't specify the clock property on the sata node in the device tree. >>> Instead I add the clock lookup entry in patch [01/10]. This is >>> transparent for AHCI which can get the clock as usual by calling >>> clk_get() in ahci_platform_get_resources(). >> >> I think David's point is that the SATA_REFCLK needs to be modeled as a >> actual clock input to the IP. You should be able to get the rate using >> clk_get_rate() and make the MPY bits calculation depending on the >> incoming rate. >> >> You should be able to model the clock even when not using common clock >> framework. >> >> DA850 AHCI does not use a con_id at the moment (it assumes a single >> clock), and that needs to change. >> > > It's true that once davinci gets ported (is this planned?) to using > the common clock framework, we could just create a fixed-clock node in > da850-lcdk for the SATA oscillator, so the new property is redundant. > I have some commits[1] where I started on converting da850 to use the common clock framework. But, I don't know anything about other davinci family devices, so I don't think I could really take that to completion without lots of help. [1]: https://github.com/dlech/ev3dev-kernel/commits/wip-20160509 > What I don't get is how should I model a clock that is not > configurable and is board-specific? Is hard-coding the relevant rate > in da850.c with a huge FIXME the right way? In arch/arm/mach-davinci/usb-da8xx.c, there is a "usb_refclkin" that is very similar to the situation with the sata refclk. You could do something like this to register the clock... --- pdata_quirks_init(); --- diff --git a/arch/arm/mach-davinci/devices-da8xx.c b/arch/arm/mach-davinci/devices-da8xx.c index c2457b3..790efce9 100644 --- a/arch/arm/mach-davinci/devices-da8xx.c +++ b/arch/arm/mach-davinci/devices-da8xx.c @@ -1023,6 +1023,34 @@ int __init da8xx_register_spi_bus(int instance, unsigned num_chipselect) } #ifdef CONFIG_ARCH_DAVINCI_DA850 + +static struct clk sata_refclkin = { + .name = "sata_refclkin", + .set_rate = davinci_simple_set_rate, +}; + +static struct clk_lookup sata_refclkin_lookup = + CLK(NULL, "sata_refclkin", &sata_refclkin); + +/** + * da8xx_register_sata_refclkin - register SATA_REFCLKIN clock + * + * @rate: The clock rate in Hz + */ +int __init da850_register_sata_refclkin(int rate) +{ + int ret; + + sata_refclkin.rate = rate; + ret = clk_register(&sata_refclkin); + if (ret) + return ret; + + clkdev_add(&sata_refclkin_lookup); + + return 0; +} + static struct resource da850_sata_resources[] = { { .start = DA850_SATA_BASE, @@ -1055,8 +1083,11 @@ static struct platform_device da850_sata_device = { int __init da850_register_sata(unsigned long refclkpn) { - /* please see comment in drivers/ata/ahci_da850.c */ - BUG_ON(refclkpn != 100 * 1000 * 1000); + int err; + + err = da850_register_sata_refclkin(refclkpn); + if (err) + return err; return platform_device_register(&da850_sata_device); } --- Then to get things working from device tree, add this... --- diff --git a/arch/arm/mach-davinci/da8xx-dt.c b/arch/arm/mach-davinci/da8xx-dt.c index d2be194..b54bdd6 100644 --- a/arch/arm/mach-davinci/da8xx-dt.c +++ b/arch/arm/mach-davinci/da8xx-dt.c @@ -60,6 +60,14 @@ static void __init da850_init_machine(void) pr_warn("%s: registering USB 1.1 PHY clock failed: %d", __func__, ret); + if (of_machine_is_compatible("ti,da850-evm") || + of_machine_is_compatible("ti,da850-lcdk")) { + ret = da850_register_sata_refclkin(100000000); + if (ret) + pr_warn("%s: registering SATA_REFCLK clock failed: %d", + __func__, ret); + } + of_platform_default_populate(NULL, da850_auxdata_lookup, NULL); davinci_pm_init();