From patchwork Tue Oct 13 18:04:23 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: WingMan Kwok X-Patchwork-Id: 7387961 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 66CAE9F36A for ; Tue, 13 Oct 2015 18:07:52 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id B29E2207E4 for ; Tue, 13 Oct 2015 18:07:50 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id C9AAA207D0 for ; Tue, 13 Oct 2015 18:07:49 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1Zm3xc-0006Wk-Eh; Tue, 13 Oct 2015 18:06:04 +0000 Received: from devils.ext.ti.com ([198.47.26.153]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1Zm3xY-0006KT-MJ for linux-arm-kernel@lists.infradead.org; Tue, 13 Oct 2015 18:06:02 +0000 Received: from dflxv15.itg.ti.com ([128.247.5.124]) by devils.ext.ti.com (8.13.7/8.13.7) with ESMTP id t9DI54kU030890; Tue, 13 Oct 2015 13:05:04 -0500 Received: from DFLE72.ent.ti.com (dfle72.ent.ti.com [128.247.5.109]) by dflxv15.itg.ti.com (8.14.3/8.13.8) with ESMTP id t9DI54tQ024279; Tue, 13 Oct 2015 13:05:04 -0500 Received: from dflp32.itg.ti.com (10.64.6.15) by DFLE72.ent.ti.com (128.247.5.109) with Microsoft SMTP Server id 14.3.224.2; Tue, 13 Oct 2015 13:05:04 -0500 Received: from udb0216549.am.dhcp.ti.com (ileax41-snat.itg.ti.com [10.172.224.153]) by dflp32.itg.ti.com (8.14.3/8.13.8) with ESMTP id t9DI54EZ011151; Tue, 13 Oct 2015 13:05:04 -0500 Received: from a0216549local by udb0216549.am.dhcp.ti.com with local (Exim 4.76) (envelope-from ) id 1Zm3we-0008Pp-B3; Tue, 13 Oct 2015 14:05:04 -0400 From: WingMan Kwok To: , , , , , , , , , , , , , , Subject: [PATCH 2/3] PCI: keystone: update to use generic keystone serdes driver Date: Tue, 13 Oct 2015 14:04:23 -0400 Message-ID: <1444759464-32299-3-git-send-email-w-kwok2@ti.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1444759464-32299-1-git-send-email-w-kwok2@ti.com> References: <1444759464-32299-1-git-send-email-w-kwok2@ti.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20151013_110600_918216_E11737A3 X-CRM114-Status: GOOD ( 16.29 ) X-Spam-Score: -6.9 (------) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: WingMan Kwok Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable 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 This patch updates the Keystone PCI driver to use the generic Keystone serdes driver for serdes initialization and configuration. The generic serdes driver supports peripherals on Keystone platforms that require serdes. Signed-off-by: WingMan Kwok --- drivers/pci/host/pci-keystone.c | 54 ++++++++++++++++++++++++++++++++------- drivers/pci/host/pci-keystone.h | 2 ++ 2 files changed, 47 insertions(+), 9 deletions(-) diff --git a/drivers/pci/host/pci-keystone.c b/drivers/pci/host/pci-keystone.c index 0aa81bd..b4de05b 100644 --- a/drivers/pci/host/pci-keystone.c +++ b/drivers/pci/host/pci-keystone.c @@ -335,6 +335,7 @@ static int __exit ks_pcie_remove(struct platform_device *pdev) { struct keystone_pcie *ks_pcie = platform_get_drvdata(pdev); + phy_exit(ks_pcie->serdes_phy); clk_disable_unprepare(ks_pcie->clk); return 0; @@ -342,6 +343,8 @@ static int __exit ks_pcie_remove(struct platform_device *pdev) static int __init ks_pcie_probe(struct platform_device *pdev) { + struct device_node *node = pdev->dev.of_node; + struct device_node *serdeses_np, *child; struct device *dev = &pdev->dev; struct keystone_pcie *ks_pcie; struct pcie_port *pp; @@ -349,6 +352,7 @@ static int __init ks_pcie_probe(struct platform_device *pdev) void __iomem *reg_p; struct phy *phy; int ret = 0; + u32 phy_num; ks_pcie = devm_kzalloc(&pdev->dev, sizeof(*ks_pcie), GFP_KERNEL); @@ -357,14 +361,6 @@ static int __init ks_pcie_probe(struct platform_device *pdev) pp = &ks_pcie->pp; - /* initialize SerDes Phy if present */ - phy = devm_phy_get(dev, "pcie-phy"); - if (!IS_ERR_OR_NULL(phy)) { - ret = phy_init(phy); - if (ret < 0) - return ret; - } - /* index 2 is to read PCI DEVICE_ID */ res = platform_get_resource(pdev, IORESOURCE_MEM, 2); reg_p = devm_ioremap_resource(dev, res); @@ -385,6 +381,46 @@ static int __init ks_pcie_probe(struct platform_device *pdev) if (ret) return ret; + serdeses_np = of_get_child_by_name(node, "serdeses"); + if (serdeses_np) { + for_each_available_child_of_node(serdeses_np, child) { + ret = of_property_read_u32(child, "reg", &phy_num); + if (ret) { + dev_err(dev, "Failed to parse device tree\n"); + of_node_put(child); + of_node_put(serdeses_np); + goto fail_clk; + } + + if (phy_num >= MAX_NUM_PCI_SERDES) { + dev_err(dev, "Invalid phy number: %u\n", + phy_num); + of_node_put(child); + of_node_put(serdeses_np); + ret = -EINVAL; + goto fail_clk; + } + + phy = devm_of_phy_get(dev, child, NULL); + of_node_put(child); + ks_pcie->serdes_phy = phy; + if (IS_ERR(phy)) { + dev_err(dev, "No %s serdes driver found: %ld\n", + node->name, PTR_ERR(phy)); + of_node_put(serdeses_np); + ret = PTR_ERR(phy); + goto fail_clk; + } + + ret = phy_init(phy); + if (ret < 0) { + of_node_put(serdeses_np); + goto fail_clk; + } + } + of_node_put(serdeses_np); + } + ret = ks_add_pcie_port(ks_pcie, pdev); if (ret < 0) goto fail_clk; @@ -392,7 +428,7 @@ static int __init ks_pcie_probe(struct platform_device *pdev) return 0; fail_clk: clk_disable_unprepare(ks_pcie->clk); - + phy_exit(ks_pcie->serdes_phy); return ret; } diff --git a/drivers/pci/host/pci-keystone.h b/drivers/pci/host/pci-keystone.h index 478d932..21662ba 100644 --- a/drivers/pci/host/pci-keystone.h +++ b/drivers/pci/host/pci-keystone.h @@ -15,6 +15,7 @@ #define MAX_LEGACY_IRQS 4 #define MAX_MSI_HOST_IRQS 8 #define MAX_LEGACY_HOST_IRQS 4 +#define MAX_NUM_PCI_SERDES 1 struct keystone_pcie { struct clk *clk; @@ -33,6 +34,7 @@ struct keystone_pcie { /* Application register space */ void __iomem *va_app_base; struct resource app; + struct phy *serdes_phy; }; /* Keystone DW specific MSI controller APIs/definitions */