From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.2 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_MUTT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id F2DC7C31E58 for ; Mon, 17 Jun 2019 11:18:30 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id C0ED3208C0 for ; Mon, 17 Jun 2019 11:18:30 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="TDOd6xcY" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C0ED3208C0 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=arm.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=n2EAYw69QjsMC7OY9r5nXWwkCt/XwdN/zRjMVniAlf8=; b=TDOd6xcYuegGsa YnmmE1Q9ZlxovJnbqYl8QvayS9Da+JJzHuMcEXBg1l3VjHaJX9A1Hc6s1YQAXmT2yWeLe5Jw/p1D9 ywYBLSrbxGVggFYZUyCbD48R/NiDObqGSI8lnhd5Jkjs7jvaIbeQaiRuVe7s8b5qnYYVJuqIUjyUF zrQW6ID/dE7g91imUoUJ3mrC6wkBMX7w9oQ8vbN7zvFgIj7djfSV3/DjjlXdOtX1p9vLGFSwP9i+i XTl96xyb9RFhC5rKom59rOzIDQ6yQicF7owEyf4T+WgmQH73JQX5PN8Fmg5Vwqzp0YxFXDrtJsfhm O5G57NSWcHsTDBPf7pJA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92 #3 (Red Hat Linux)) id 1hcpee-0006xq-Ap; Mon, 17 Jun 2019 11:18:28 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.92 #3 (Red Hat Linux)) id 1hcpea-0006xG-Ul for linux-arm-kernel@lists.infradead.org; Mon, 17 Jun 2019 11:18:26 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 358F6344; Mon, 17 Jun 2019 04:18:24 -0700 (PDT) Received: from e121166-lin.cambridge.arm.com (unknown [10.1.196.255]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id B3B5C3F246; Mon, 17 Jun 2019 04:20:08 -0700 (PDT) Date: Mon, 17 Jun 2019 12:18:17 +0100 From: Lorenzo Pieralisi To: Miquel Raynal Subject: Re: [PATCH] PCI: armada8k: Add PHYs support Message-ID: <20190617111817.GA24968@e121166-lin.cambridge.arm.com> References: <20190401131239.17008-1-miquel.raynal@bootlin.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20190401131239.17008-1-miquel.raynal@bootlin.com> User-Agent: Mutt/1.9.4 (2018-02-28) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190617_041825_075436_BA9F5661 X-CRM114-Status: GOOD ( 21.48 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Bjorn Helgaas , linux-pci@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Thomas Petazzoni Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Mon, Apr 01, 2019 at 03:12:39PM +0200, Miquel Raynal wrote: > Bring PHY support for the Armada8k driver. > > The Armada8k IP only supports x1, x2 or x4 link widths. Iterate over > the DT 'phys' entries and configure them one by one. Use > phy_set_mode_ext() to make use of the submode parameter (initially > introduced for Ethernet modes). For PCI configuration, let the submode > be the width (1, 2, 4, etc) so that the PHY driver knows how many > lanes are bundled. Do not error out in case of error for compatibility > reasons. > > Signed-off-by: Miquel Raynal > --- > drivers/pci/controller/dwc/pcie-armada8k.c | 82 +++++++++++++++++++++- > 1 file changed, 81 insertions(+), 1 deletion(-) Applied to pci/armada for v5.3, thanks. Lorenzo > diff --git a/drivers/pci/controller/dwc/pcie-armada8k.c b/drivers/pci/controller/dwc/pcie-armada8k.c > index 0c389a30ef5d..e567a7cfa3d7 100644 > --- a/drivers/pci/controller/dwc/pcie-armada8k.c > +++ b/drivers/pci/controller/dwc/pcie-armada8k.c > @@ -25,10 +25,14 @@ > > #include "pcie-designware.h" > > +#define ARMADA8K_PCIE_MAX_LANES PCIE_LNK_X4 > + > struct armada8k_pcie { > struct dw_pcie *pci; > struct clk *clk; > struct clk *clk_reg; > + struct phy *phy[ARMADA8K_PCIE_MAX_LANES]; > + unsigned int phy_count; > }; > > #define PCIE_VENDOR_REGS_OFFSET 0x8000 > @@ -67,6 +71,76 @@ struct armada8k_pcie { > > #define to_armada8k_pcie(x) dev_get_drvdata((x)->dev) > > +static void armada8k_pcie_disable_phys(struct armada8k_pcie *pcie) > +{ > + int i; > + > + for (i = 0; i < ARMADA8K_PCIE_MAX_LANES; i++) { > + phy_power_off(pcie->phy[i]); > + phy_exit(pcie->phy[i]); > + } > +} > + > +static int armada8k_pcie_enable_phys(struct armada8k_pcie *pcie) > +{ > + int ret; > + int i; > + > + for (i = 0; i < ARMADA8K_PCIE_MAX_LANES; i++) { > + ret = phy_init(pcie->phy[i]); > + if (ret) > + return ret; > + > + ret = phy_set_mode_ext(pcie->phy[i], PHY_MODE_PCIE, > + pcie->phy_count); > + if (ret) { > + phy_exit(pcie->phy[i]); > + return ret; > + } > + > + ret = phy_power_on(pcie->phy[i]); > + if (ret) { > + phy_exit(pcie->phy[i]); > + return ret; > + } > + } > + > + return 0; > +} > + > +static int armada8k_pcie_setup_phys(struct armada8k_pcie *pcie) > +{ > + struct dw_pcie *pci = pcie->pci; > + struct device *dev = pci->dev; > + struct device_node *node = dev->of_node; > + int ret = 0; > + int i; > + > + for (i = 0; i < ARMADA8K_PCIE_MAX_LANES; i++) { > + pcie->phy[i] = devm_of_phy_get_by_index(dev, node, i); > + if (IS_ERR(pcie->phy[i]) && > + (PTR_ERR(pcie->phy[i]) == -EPROBE_DEFER)) > + return PTR_ERR(pcie->phy[i]); > + > + if (IS_ERR(pcie->phy[i])) { > + pcie->phy[i] = NULL; > + continue; > + } > + > + pcie->phy_count++; > + } > + > + /* Old bindings miss the PHY handle, so just warn if there is no PHY */ > + if (!pcie->phy_count) > + dev_warn(dev, "No available PHY\n"); > + > + ret = armada8k_pcie_enable_phys(pcie); > + if (ret) > + dev_err(dev, "Failed to initialize PHY(s) (%d)\n", ret); > + > + return ret; > +} > + > static int armada8k_pcie_link_up(struct dw_pcie *pci) > { > u32 reg; > @@ -249,14 +323,20 @@ static int armada8k_pcie_probe(struct platform_device *pdev) > goto fail_clkreg; > } > > + ret = armada8k_pcie_setup_phys(pcie); > + if (ret) > + goto fail_clkreg; > + > platform_set_drvdata(pdev, pcie); > > ret = armada8k_add_pcie_port(pcie, pdev); > if (ret) > - goto fail_clkreg; > + goto disable_phy; > > return 0; > > +disable_phy: > + armada8k_pcie_disable_phys(pcie); > fail_clkreg: > clk_disable_unprepare(pcie->clk_reg); > fail: > -- > 2.19.1 > _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel