From patchwork Sun Mar 13 23:30:55 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Fritz X-Patchwork-Id: 596864 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3qNcZY0Wbhz9sCt for ; Mon, 14 Mar 2016 10:31:01 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=googlemail.com header.i=@googlemail.com header.b=kl9rue8x; dkim-atps=neutral Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754375AbcCMXa7 (ORCPT ); Sun, 13 Mar 2016 19:30:59 -0400 Received: from mail-wm0-f47.google.com ([74.125.82.47]:37453 "EHLO mail-wm0-f47.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754320AbcCMXa7 (ORCPT ); Sun, 13 Mar 2016 19:30:59 -0400 Received: by mail-wm0-f47.google.com with SMTP id p65so81686646wmp.0 for ; Sun, 13 Mar 2016 16:30:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=20120113; h=message-id:subject:from:reply-to:to:cc:date:in-reply-to:references :mime-version:content-transfer-encoding; bh=3+YwwarADop0qySgMHtAEoWaX3Es6MzxjIgZNfCIisg=; b=kl9rue8x9qEtl9YzxU6ViOFxRXbGm9buqseJnGh/Kn6EdlZyYuAWebWryrYbLSDcGT KYOvpUhCZVk9KBlE10PySVmwCC6YC9/NpWwLQV8QKQUPnyCg4l8UenBhcVfEbkLYH5/l wanWNiJIWKvw45pfYn/MFSsgwiHL6kg6jrj2W8/DjcXcTpqbHpTIApX3fOSvthkP9S8+ xK7c3XZFhi3kmeNscCLFvDxtguVj8RbgiyMqt8SCjojnwAtEsnA/lTWTvgvmCAaGSGjL CPBVJK8YrnD8SvcezHab96HpgAX3sKGZs4CN6y6joavyOQvPz8MPXzmQqmtlSvXfDnSG cw3w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:message-id:subject:from:reply-to:to:cc:date :in-reply-to:references:mime-version:content-transfer-encoding; bh=3+YwwarADop0qySgMHtAEoWaX3Es6MzxjIgZNfCIisg=; b=X/2Z77eU2RPx+rjbL8kIQjIG4HBlnwGoGE5fdHZ7OX7JDeSpI8OHsy3+X3jyWzZYx0 6RJyEP1QADi6UR3K1x5P3HR3ths6qIu5iDEGBwxhctxp1LdI2tBBZ16rvK9CXzPipvPZ wMS1R56AkrHgobkI/YBX9FIS7dryr9c4xZSvtEfZJxShXDcz46AyNlfqYBObB5IabzkL e98yTZQlID1SJaJC+VnBs0nbdeMI8mDLhSQAPSYRKHYQEiR/ECjwxSSN1YlEf+beGWFs GPQ2sQ23XKpYvHzizsa97Hq52w8+V1GyCVqYJzMRSd65l7iVtthBIGtRehVxD4VoNtB4 IYiQ== X-Gm-Message-State: AD7BkJKoy0z6K4VITSKedp6awEEHI3cdinvsiqfYkuzxH9+U9T38I6VjUZ5J1Hy72Prs5w== X-Received: by 10.28.146.202 with SMTP id u193mr14731514wmd.82.1457911857529; Sun, 13 Mar 2016 16:30:57 -0700 (PDT) Received: from mars.fritz.box (HSI-KBW-37-209-75-7.hsi15.kabel-badenwuerttemberg.de. [37.209.75.7]) by smtp.googlemail.com with ESMTPSA id e19sm13554053wmd.1.2016.03.13.16.30.56 (version=TLSv1/SSLv3 cipher=OTHER); Sun, 13 Mar 2016 16:30:56 -0700 (PDT) Message-ID: <1457911855.16725.41.camel@googlemail.com> Subject: PCI: imx6: Factor out ref clock enable From: Christoph Fritz Reply-To: chf.fritz@googlemail.com To: Bjorn Helgaas Cc: Richard Zhu , Lucas Stach , Shawn Guo , Fabio Estevam , Bjorn Helgaas , Lee Jones , linux-pci@vger.kernel.org, linux-arm-kernel@lists.infradead.org Date: Mon, 14 Mar 2016 00:30:55 +0100 In-Reply-To: <1457911590.16725.37.camel@googlemail.com> References: <1456411669-4699-1-git-send-email-chf.fritz@googlemail.com> <1456411669-4699-3-git-send-email-chf.fritz@googlemail.com> <20160311175850.GA4725@localhost> <1457911590.16725.37.camel@googlemail.com> X-Mailer: Evolution 3.12.9-1+b1 Mime-Version: 1.0 Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org commit dfcc1a16e6954e8ca6cadfc9dd309db6b6ef46b2 Author: Bjorn Helgaas Date: Fri, 11 Mar 2016 11:15:36 -0600 Factor out ref clock enable to make it cleaner to add imx6sx support. No functional change intended. Signed-off-by: Bjorn Helgaas Tested-by: Christoph Fritz --- drivers/pci/host/pci-imx6.c | 36 ++++++++++++++++++++++++------------ 1 file changed, 24 insertions(+), 12 deletions(-) diff --git a/drivers/pci/host/pci-imx6.c b/drivers/pci/host/pci-imx6.c index bd3f7d0..4e0e47f 100644 --- a/drivers/pci/host/pci-imx6.c +++ b/drivers/pci/host/pci-imx6.c @@ -264,6 +264,23 @@ static int imx6_pcie_assert_core_reset(struct pcie_port *pp) return 0; } +static int imx6_pcie_enable_ref_clk(struct imx6_pcie *imx6_pcie) +{ + /* power up core phy and enable ref clock */ + regmap_update_bits(imx6_pcie->iomuxc_gpr, IOMUXC_GPR1, + IMX6Q_GPR1_PCIE_TEST_PD, 0 << 18); + /* + * the async reset input need ref clock to sync internally, + * when the ref clock comes after reset, internal synced + * reset time is too short, cannot meet the requirement. + * add one ~10us delay here. + */ + udelay(10); + regmap_update_bits(imx6_pcie->iomuxc_gpr, IOMUXC_GPR1, + IMX6Q_GPR1_PCIE_REF_CLK_EN, 1 << 16); + return 0; +} + static int imx6_pcie_deassert_core_reset(struct pcie_port *pp) { struct imx6_pcie *imx6_pcie = to_imx6_pcie(pp); @@ -287,18 +304,11 @@ static int imx6_pcie_deassert_core_reset(struct pcie_port *pp) goto err_pcie; } - /* power up core phy and enable ref clock */ - regmap_update_bits(imx6_pcie->iomuxc_gpr, IOMUXC_GPR1, - IMX6Q_GPR1_PCIE_TEST_PD, 0 << 18); - /* - * the async reset input need ref clock to sync internally, - * when the ref clock comes after reset, internal synced - * reset time is too short, cannot meet the requirement. - * add one ~10us delay here. - */ - udelay(10); - regmap_update_bits(imx6_pcie->iomuxc_gpr, IOMUXC_GPR1, - IMX6Q_GPR1_PCIE_REF_CLK_EN, 1 << 16); + ret = imx6_pcie_enable_ref_clk(imx6_pcie); + if (ret) { + dev_err(pp->dev, "unable to enable pcie ref clock\n"); + goto err_ref_clk; + } /* allow the clocks to stabilize */ usleep_range(200, 500); @@ -311,6 +321,8 @@ static int imx6_pcie_deassert_core_reset(struct pcie_port *pp) } return 0; +err_ref_clk: + clk_disable_unprepare(imx6_pcie->pcie); err_pcie: clk_disable_unprepare(imx6_pcie->pcie_bus); err_pcie_bus: