From patchwork Thu Feb 6 05:53:38 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shawn Guo X-Patchwork-Id: 24236 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-qc0-f199.google.com (mail-qc0-f199.google.com [209.85.216.199]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 641A7203C5 for ; Thu, 6 Feb 2014 05:54:39 +0000 (UTC) Received: by mail-qc0-f199.google.com with SMTP id m20sf2979455qcx.6 for ; Wed, 05 Feb 2014 21:54:38 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:from:to:subject:date:message-id :mime-version:cc:precedence:list-id:list-unsubscribe:list-archive :list-post:list-help:list-subscribe:sender:errors-to :x-original-sender:x-original-authentication-results:mailing-list :content-type:content-transfer-encoding; bh=6pHEHr+y291nMaldBh+3MkPJWLL980NMwpSHkRkNfEs=; b=Xr2Ug6GMSOSNTC2E37W8tBkHUY/y4wAw2evSdnCab+BJ+vxalFvqM8JQzXQNN60425 T1VVfB7J5v8zKFblwg1/+dVojibMcgerDr0myhfhwfteW8xx5Qly3lYRBGou79jqhsg7 XN78OSU0xUQ7Z9mv9Bzdrk7O0BVSGq4fUk8LrFLbu4L8DRkGDDVVMeOjYEThQtbyPDw+ 5lYy4QecsYORiEP7rTpi7uymBgZXxMXAypQoCQ44auzXNqEpTkcy+eZ1FV4/mGdvYtyT Qr9gVqy9sIjLV7mPLReoKkEPNCLkffk93LTuv8xSXqhgJG+36O/Pp4fzZ17pYnlzEPH7 RbIA== X-Gm-Message-State: ALoCoQl1ZyHfeMYKm/srO9+E4r2/MWubPVX59Wz+fAHUL/wIi3GWGC5B4vM9mzvaweR6ONyC+hzZ X-Received: by 10.236.133.82 with SMTP id p58mr638112yhi.37.1391666078582; Wed, 05 Feb 2014 21:54:38 -0800 (PST) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.34.76 with SMTP id k70ls396828qgk.30.gmail; Wed, 05 Feb 2014 21:54:38 -0800 (PST) X-Received: by 10.220.92.135 with SMTP id r7mr4257300vcm.11.1391666078408; Wed, 05 Feb 2014 21:54:38 -0800 (PST) Received: from mail-vb0-f49.google.com (mail-vb0-f49.google.com [209.85.212.49]) by mx.google.com with ESMTPS id a2si10460481vea.105.2014.02.05.21.54.38 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 05 Feb 2014 21:54:38 -0800 (PST) Received-SPF: neutral (google.com: 209.85.212.49 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.212.49; Received: by mail-vb0-f49.google.com with SMTP id x14so1069748vbb.22 for ; Wed, 05 Feb 2014 21:54:38 -0800 (PST) X-Received: by 10.58.49.129 with SMTP id u1mr4405472ven.0.1391666078240; Wed, 05 Feb 2014 21:54:38 -0800 (PST) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.220.174.196 with SMTP id u4csp111876vcz; Wed, 5 Feb 2014 21:54:37 -0800 (PST) X-Received: by 10.180.211.50 with SMTP id mz18mr12477562wic.43.1391666077146; Wed, 05 Feb 2014 21:54:37 -0800 (PST) Received: from casper.infradead.org (casper.infradead.org. [2001:770:15f::2]) by mx.google.com with ESMTPS id s13si10748320wiv.5.2014.02.05.21.54.36 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 05 Feb 2014 21:54:37 -0800 (PST) Received-SPF: pass (google.com: domain of linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org designates 2001:770:15f::2 as permitted sender) client-ip=2001:770:15f::2; Received: from merlin.infradead.org ([2001:4978:20e::2]) by casper.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1WBHue-00031b-2s; Thu, 06 Feb 2014 05:54:12 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1WBHub-00035N-Jg; Thu, 06 Feb 2014 05:54:09 +0000 Received: from co9ehsobe002.messaging.microsoft.com ([207.46.163.25] helo=co9outboundpool.messaging.microsoft.com) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1WBHuY-00034D-MJ for linux-arm-kernel@lists.infradead.org; Thu, 06 Feb 2014 05:54:07 +0000 Received: from mail86-co9-R.bigfish.com (10.236.132.231) by CO9EHSOBE015.bigfish.com (10.236.130.78) with Microsoft SMTP Server id 14.1.225.22; Thu, 6 Feb 2014 05:53:37 +0000 Received: from mail86-co9 (localhost [127.0.0.1]) by mail86-co9-R.bigfish.com (Postfix) with ESMTP id 769723E0328; Thu, 6 Feb 2014 05:53:37 +0000 (UTC) X-Forefront-Antispam-Report: CIP:70.37.183.190; KIP:(null); UIP:(null); IPV:NLI; H:mail.freescale.net; RD:none; EFVD:NLI X-SpamScore: 3 X-BigFish: VS3(zcb8kzzz1f42h2148h208ch1ee6h1de0h1fdah2073h2146h1202h1e76h2189h1d1ah1d2ah21bch1fc6hzz1de098h8275dh1de097hz2dh87h2a8h839hd24he5bhf0ah1288h12a5h12a9h12bdh12e5h137ah139eh13b6h1441h1504h1537h162dh1631h1758h1898h18e1h1946h19b5h1ad9h1b0ah1b2fh2222h224fh1fb3h1d0ch1d2eh1d3fh1dc1h1dfeh1dffh1e23h1fe8h1ff5h2218h2216h226dh22d0h24afh2327h2336h2438h2461h2487h24d7h2516h2545h1151h1155h) X-FB-DOMAIN-IP-MATCH: fail Received: from mail86-co9 (localhost.localdomain [127.0.0.1]) by mail86-co9 (MessageSwitch) id 139166601524719_2796; Thu, 6 Feb 2014 05:53:35 +0000 (UTC) Received: from CO9EHSMHS032.bigfish.com (unknown [10.236.132.237]) by mail86-co9.bigfish.com (Postfix) with ESMTP id EB5754801DB; Thu, 6 Feb 2014 05:53:34 +0000 (UTC) Received: from mail.freescale.net (70.37.183.190) by CO9EHSMHS032.bigfish.com (10.236.130.42) with Microsoft SMTP Server (TLS) id 14.16.227.3; Thu, 6 Feb 2014 05:53:34 +0000 Received: from tx30smr01.am.freescale.net (10.81.153.31) by 039-SN1MMR1-003.039d.mgd.msft.net (10.84.1.16) with Microsoft SMTP Server (TLS) id 14.3.158.2; Thu, 6 Feb 2014 05:53:34 +0000 Received: from S2101-09.ap.freescale.net ([10.192.185.222]) by tx30smr01.am.freescale.net (8.14.3/8.14.0) with ESMTP id s165rVDD024187; Wed, 5 Feb 2014 22:53:32 -0700 From: Shawn Guo To: Subject: [PATCH] ARM: imx6q: support ptp and rmii clock from pad Date: Thu, 6 Feb 2014 13:53:38 +0800 Message-ID: <1391666018-12825-1-git-send-email-shawn.guo@linaro.org> X-Mailer: git-send-email 1.7.9.5 MIME-Version: 1.0 X-OriginatorOrg: sigmatel.com X-FOPE-CONNECTOR: Id%0$Dn%*$RO%0$TLS%0$FQDN%$TlsDn% X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20140206_005406_862723_DA885E72 X-CRM114-Status: GOOD ( 13.08 ) X-Spam-Score: -3.5 (---) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (-3.5 points) pts rule name description ---- ---------------------- -------------------------------------------------- -2.3 RCVD_IN_DNSWL_MED RBL: Sender listed at http://www.dnswl.org/, medium trust [207.46.163.25 listed in list.dnswl.org] 0.7 SPF_SOFTFAIL SPF: sender does not match SPF record (softfail) -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] Cc: Philippe De Muyter , kernel@pengutronix.de, Shawn Guo X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: , List-Help: , List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: shawn.guo@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.212.49 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 On imx6qdl, the ENET RMII and PTP clock can come from either internal ANATOP/CCM or external clock source through pad GPIO_16. But in case of the external clock source, bit IOMUXC_GPR1[21] needs to be cleared. The patch adds the support for systems that use an external clock source and distinguishes above two cases by checking if the PTP clock specified in device tree is the one coming from the internal ANATOP/CCM. Signed-off-by: Shawn Guo --- arch/arm/mach-imx/clk-imx6q.c | 1 + arch/arm/mach-imx/mach-imx6q.c | 36 +++++++++++++++++++++++++++++++++++- 2 files changed, 36 insertions(+), 1 deletion(-) diff --git a/arch/arm/mach-imx/clk-imx6q.c b/arch/arm/mach-imx/clk-imx6q.c index dd4f1e3..45de2e5 100644 --- a/arch/arm/mach-imx/clk-imx6q.c +++ b/arch/arm/mach-imx/clk-imx6q.c @@ -437,6 +437,7 @@ static void __init imx6q_clocks_init(struct device_node *ccm_node) clk_register_clkdev(clk[gpt_ipg], "ipg", "imx-gpt.0"); clk_register_clkdev(clk[gpt_ipg_per], "per", "imx-gpt.0"); + clk_register_clkdev(clk[enet_ref], "enet_ref", NULL); if ((imx_get_soc_revision() != IMX_CHIP_REVISION_1_0) || cpu_is_imx6dl()) { diff --git a/arch/arm/mach-imx/mach-imx6q.c b/arch/arm/mach-imx/mach-imx6q.c index f9cbbf9..d131499b 100644 --- a/arch/arm/mach-imx/mach-imx6q.c +++ b/arch/arm/mach-imx/mach-imx6q.c @@ -182,16 +182,50 @@ static void __init imx6q_enet_phy_init(void) static void __init imx6q_1588_init(void) { + struct device_node *np; + struct clk *ptp_clk; + struct clk *enet_ref; struct regmap *gpr; + u32 clksel; + + np = of_find_compatible_node(NULL, NULL, "fsl,imx6q-fec"); + if (!np) { + pr_warn("%s: failed to find fec node\n", __func__); + return; + } + + ptp_clk = of_clk_get(np, 2); + if (IS_ERR(ptp_clk)) { + pr_warn("%s: failed to get ptp clock\n", __func__); + goto put_node; + } + + enet_ref = clk_get_sys(NULL, "enet_ref"); + if (IS_ERR(enet_ref)) { + pr_warn("%s: failed to get enet clock\n", __func__); + goto put_ptp_clk; + } + /* + * If enet_ref from ANATOP/CCM is the PTP clock source, we need to + * set bit IOMUXC_GPR1[21]. Or the PTP clock must be from pad + * (external OSC), and we need to clear the bit. + */ + clksel = ptp_clk == enet_ref ? IMX6Q_GPR1_ENET_CLK_SEL_ANATOP : + IMX6Q_GPR1_ENET_CLK_SEL_PAD; gpr = syscon_regmap_lookup_by_compatible("fsl,imx6q-iomuxc-gpr"); if (!IS_ERR(gpr)) regmap_update_bits(gpr, IOMUXC_GPR1, IMX6Q_GPR1_ENET_CLK_SEL_MASK, - IMX6Q_GPR1_ENET_CLK_SEL_ANATOP); + clksel); else pr_err("failed to find fsl,imx6q-iomux-gpr regmap\n"); + clk_put(enet_ref); +put_ptp_clk: + clk_put(ptp_clk); +put_node: + of_node_put(np); } static void __init imx6q_init_machine(void)