From patchwork Tue Dec 19 08:58:22 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kishon Vijay Abraham I X-Patchwork-Id: 122345 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp3882939qgn; Tue, 19 Dec 2017 00:58:55 -0800 (PST) X-Google-Smtp-Source: ACJfBouB42qLkLVkG6gIcqQF3+TL1KFDlh1SPY9qkaDmsNqwMXm/5/LfOXolCxz/5LTicTitU7Rw X-Received: by 10.84.130.65 with SMTP id 59mr2621867plc.161.1513673935006; Tue, 19 Dec 2017 00:58:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1513673934; cv=none; d=google.com; s=arc-20160816; b=oLPP9bjFvcarRXjwgDdsfUna8aVwybxgcai+ILA7WHnTGLcpMFocupX/sZpZpqD5RS 3NdgRG/CbdSfaOXwITDUF+LK1WbOyhnEf0nG4We7P6XDSNIU+M7jTBg/jdp8bNBq5ULq eXsRavAV6IPmH0CKzibf0toezDdadKMoDjqznti4xQVLOUZo6dbvY3l5HrCr7lZjZe+J GxLLFvanGp7ike0HaXSSJk9P7mfMZnYiCIL3EaA6T7v7MM1y4IWv6O+rYTlz7yCrcxav gpLV9i5l5JOfna464xqZmp+ZCJjNVqX/9cW3YmC76voqDBDoMwWeeBi7w5H4e+ec+VyA LVEQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature :arc-authentication-results; bh=+wEvjuPcjkAWUtGoa1B6YBLp3JinKgQQlLCOCLldIWM=; b=DGF73oeTX9nDZo+03J2ZYe5HmDcqQz6+Q2R/FdfcUYaD4/1r5RZNwDcIGAd5i4ch7b evGgCYapxkIDGK7+MCpk3nkVYDCdBR46esCRnu7m7WmSZoEEnDUQfcVxlQUyphZQXC+v airm9wpRWQr3L6RPgY1LErfDLt7P5rrVGJToBjXmXAZTwDN8rr/ClA4bJq0N8Jcsb5y8 I9D2h4tsOqO3lyqgQzmPTA6qXn8oBCMTWfZZfKDKAWUaWwTNVZ1Ak2zwPa/aZhJtqJC7 PwBh0ItNQyzW6KBLjVu2d3G+lxBbD1S59obtHp+uAoLDuUcGymckWnES8u9ZRoq5UiXW 53nw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=xkgSvAEs; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id o18si10891991pfa.3.2017.12.19.00.58.54; Tue, 19 Dec 2017 00:58:54 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=xkgSvAEs; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S966721AbdLSI6v (ORCPT + 28 others); Tue, 19 Dec 2017 03:58:51 -0500 Received: from lelnx194.ext.ti.com ([198.47.27.80]:15888 "EHLO lelnx194.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933786AbdLSI6o (ORCPT ); Tue, 19 Dec 2017 03:58:44 -0500 Received: from dflxv15.itg.ti.com ([128.247.5.124]) by lelnx194.ext.ti.com (8.15.1/8.15.1) with ESMTP id vBJ8wdQZ019722; Tue, 19 Dec 2017 02:58:39 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ti.com; s=ti-com-17Q1; t=1513673919; bh=5Qy5dcr/i7WhyEWJNjUKajSJEJsaDJU8FMOL2iy8O/c=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=xkgSvAEsRrZgM4IojHrJUHrtvEX91hJzIsCB598amVROSxyuMgMUs7j1XvVSvqNGH Oxo357uQA0uOMd201EhzF87nCNnR1CVZY+Zy7JBqomt+3sT4y4h36S9HCA93P1QEtx fiOKie+RCcbes1Zf8C3CtWuSzNfVTZNPYoCrsT7M= Received: from DFLE106.ent.ti.com (dfle106.ent.ti.com [10.64.6.27]) by dflxv15.itg.ti.com (8.14.3/8.13.8) with ESMTP id vBJ8wdsk015199; Tue, 19 Dec 2017 02:58:39 -0600 Received: from DFLE114.ent.ti.com (10.64.6.35) by DFLE106.ent.ti.com (10.64.6.27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1261.35; Tue, 19 Dec 2017 02:58:39 -0600 Received: from dlep33.itg.ti.com (157.170.170.75) by DFLE114.ent.ti.com (10.64.6.35) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.1.1261.35 via Frontend Transport; Tue, 19 Dec 2017 02:58:39 -0600 Received: from a0393678ub.india.ti.com (ileax41-snat.itg.ti.com [10.172.224.153]) by dlep33.itg.ti.com (8.14.3/8.13.8) with ESMTP id vBJ8wTaq021479; Tue, 19 Dec 2017 02:58:36 -0600 From: Kishon Vijay Abraham I To: Lorenzo Pieralisi , Bjorn Helgaas , Rob Herring CC: Mark Rutland , , , , , , Subject: [PATCH v2 2/3] dt-bindings: PCI: dra7xx: Add properties to enable x2 lane in dra7 Date: Tue, 19 Dec 2017 14:28:22 +0530 Message-ID: <20171219085823.8695-3-kishon@ti.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20171219085823.8695-1-kishon@ti.com> References: <20171219085823.8695-1-kishon@ti.com> MIME-Version: 1.0 X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add syscon properties required for configuring PCIe in x2 lane mode. Signed-off-by: Kishon Vijay Abraham I Signed-off-by: Sekhar Nori --- Documentation/devicetree/bindings/pci/ti-pci.txt | 6 ++++++ 1 file changed, 6 insertions(+) -- 2.11.0 diff --git a/Documentation/devicetree/bindings/pci/ti-pci.txt b/Documentation/devicetree/bindings/pci/ti-pci.txt index 82cb875e4cec..bfbc77ac7355 100644 --- a/Documentation/devicetree/bindings/pci/ti-pci.txt +++ b/Documentation/devicetree/bindings/pci/ti-pci.txt @@ -13,6 +13,12 @@ PCIe DesignWare Controller - ti,hwmods : Name of the hwmod associated to the pcie, "pcie", where is the instance number of the pcie from the HW spec. - num-lanes as specified in ../designware-pcie.txt + - ti,syscon-lane-conf : phandle/offset pair. Phandle to the system control + module and the register offset to specify 1 lane or + 2 lane. + - ti,syscon-lane-sel : phandle/offset pair. Phandle to the system control + module and the register offset to specify lane + selection. HOST MODE ========= From patchwork Tue Dec 19 08:58:23 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kishon Vijay Abraham I X-Patchwork-Id: 122346 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp3888690qgn; Tue, 19 Dec 2017 01:04:11 -0800 (PST) X-Google-Smtp-Source: ACJfBovWWpZkQ8+xM1HHlV9FAw1lMSOUphRy4wW+yvsa7x8s55fu6xhJ1FhFJYDwuF0G10rUku9+ X-Received: by 10.99.56.10 with SMTP id f10mr707561pga.221.1513674251866; Tue, 19 Dec 2017 01:04:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1513674251; cv=none; d=google.com; s=arc-20160816; b=KXfRlsh0LeIs/HAYTt3o1/O1AkirUid9bSypV2THfgpTwGOf3d4HHOiSi1F55TJjP0 4mjEXqRy0zdYEew/mv2RlR15YpVYfVaRalMSnySoQZN7tjALdAEFvEd+h2foOB3BgLyy a/vAKQsfBEW6llwLpcSJ1RKrzvp2pOpwJQBQhF3PnhTUw/nrjYY0xhVo3nV2By4EWMP6 6A7tCMCd9ivhf2QB5EyFU3OHd4h5Ws/uc0XXRGHkfv8aBe6XnJIgMn8GrHukQq8Rhp1I ZjyrodAyqigtyyzFePeXTCsLMjv/l+7GFfNQ2fAeJBjZPAQb9CD79bFELY9DP8e243mP HF9w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature :arc-authentication-results; bh=hsiZNsGKLX8ijj/fRmwTjxCLyR+rTtMLaObQU1m3HlE=; b=IVX5b4acOHZs3uDtI5B24vXBohQVJB4zpOxF3F9P0D9YzsU80WBgd0I8Dzf46cHMcT eRIuwiakT/E4cRXh3a1BTC7B14vVAU72PMYp3mxb7b+kto4og/0FRacqCHvUuZ4qDhHw mnsDRhExaw/h55v8wef4JCF9v0+tjrNHMx47m0ageEHSqlJJSVYQebj92f0fViGd8Rbr RhWNfKFH+Z7QrNe11clXRfRUNnnWFqpIRbN+Ub3zW/9Diqx9g5FRQKhWVPkQIouxnOfR Ph73Zym7DQ/cQLm7rUuRYbNoxKscQAH0ZdLHSUpEMFQS3zMCDQUwknHPyQz/UPDLDcYy GoLw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=HNmK8jT6; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l1si10529675plg.451.2017.12.19.01.04.11; Tue, 19 Dec 2017 01:04:11 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=HNmK8jT6; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S938056AbdLSJDq (ORCPT + 28 others); Tue, 19 Dec 2017 04:03:46 -0500 Received: from fllnx210.ext.ti.com ([198.47.19.17]:33694 "EHLO fllnx210.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S965019AbdLSI6q (ORCPT ); Tue, 19 Dec 2017 03:58:46 -0500 Received: from dflxv15.itg.ti.com ([128.247.5.124]) by fllnx210.ext.ti.com (8.15.1/8.15.1) with ESMTP id vBJ8wgtj027280; Tue, 19 Dec 2017 02:58:42 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ti.com; s=ti-com-17Q1; t=1513673922; bh=aYpFZUWxaNc13XsXTSq1s8393WkY8+QusYdYD4dH8gc=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=HNmK8jT6C2VZuBsbQSGZrZlm6i9TsWY14NgEbefLViJ6BNpA30PU322kIlvLvn06M HT8wSbeJkaoh0lsT3Y5uNu18gaIBC01530IGWFgIZtE4gQAQJ6EBOmmcmkejHQB7JY izj70ORMWjVrdGhrVvNQ/srB6OVKEvOvCsQNrcUU= Received: from DLEE115.ent.ti.com (dlee115.ent.ti.com [157.170.170.26]) by dflxv15.itg.ti.com (8.14.3/8.13.8) with ESMTP id vBJ8wg7E015242; Tue, 19 Dec 2017 02:58:42 -0600 Received: from DLEE104.ent.ti.com (157.170.170.34) by DLEE115.ent.ti.com (157.170.170.26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1261.35; Tue, 19 Dec 2017 02:58:42 -0600 Received: from dlep33.itg.ti.com (157.170.170.75) by DLEE104.ent.ti.com (157.170.170.34) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.1.1261.35 via Frontend Transport; Tue, 19 Dec 2017 02:58:42 -0600 Received: from a0393678ub.india.ti.com (ileax41-snat.itg.ti.com [10.172.224.153]) by dlep33.itg.ti.com (8.14.3/8.13.8) with ESMTP id vBJ8wTar021479; Tue, 19 Dec 2017 02:58:39 -0600 From: Kishon Vijay Abraham I To: Lorenzo Pieralisi , Bjorn Helgaas , Rob Herring CC: Mark Rutland , , , , , , Subject: [PATCH v2 3/3] PCI: dra7xx: Enable x2 mode support for dra74x, dra76x and dra72x Date: Tue, 19 Dec 2017 14:28:23 +0530 Message-ID: <20171219085823.8695-4-kishon@ti.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20171219085823.8695-1-kishon@ti.com> References: <20171219085823.8695-1-kishon@ti.com> MIME-Version: 1.0 X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org dra74x/dra76x and dra72x has separate compatible strings. Add support for these compatible strings in pci-dra7xx driver to perform syscon configurations required to get x2 mode working. Signed-off-by: Kishon Vijay Abraham I --- drivers/pci/dwc/pci-dra7xx.c | 90 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 90 insertions(+) -- 2.11.0 diff --git a/drivers/pci/dwc/pci-dra7xx.c b/drivers/pci/dwc/pci-dra7xx.c index e77a4ceed74c..3b4427c10228 100644 --- a/drivers/pci/dwc/pci-dra7xx.c +++ b/drivers/pci/dwc/pci-dra7xx.c @@ -83,11 +83,15 @@ #define MSI_REQ_GRANT BIT(0) #define MSI_VECTOR_SHIFT 7 +#define PCIE_1LANE_2LANE_SELECTION BIT(13) +#define PCIE_B1C0_MODE_SEL BIT(2) + struct dra7xx_pcie { struct dw_pcie *pci; void __iomem *base; /* DT ti_conf */ int phy_count; /* DT phy-names count */ struct phy **phy; + u32 *b1c0_mask; int link_gen; struct irq_domain *irq_domain; enum dw_pcie_device_mode mode; @@ -95,6 +99,7 @@ struct dra7xx_pcie { struct dra7xx_pcie_of_data { enum dw_pcie_device_mode mode; + u32 b1co_mode_sel_mask; }; #define to_dra7xx_pcie(x) dev_get_drvdata((x)->dev) @@ -533,6 +538,26 @@ static const struct dra7xx_pcie_of_data dra7xx_pcie_ep_of_data = { .mode = DW_PCIE_EP_TYPE, }; +static const struct dra7xx_pcie_of_data dra746_pcie_rc_of_data = { + .b1co_mode_sel_mask = BIT(2), + .mode = DW_PCIE_RC_TYPE, +}; + +static const struct dra7xx_pcie_of_data dra726_pcie_rc_of_data = { + .b1co_mode_sel_mask = GENMASK(3, 2), + .mode = DW_PCIE_RC_TYPE, +}; + +static const struct dra7xx_pcie_of_data dra746_pcie_ep_of_data = { + .b1co_mode_sel_mask = BIT(2), + .mode = DW_PCIE_EP_TYPE, +}; + +static const struct dra7xx_pcie_of_data dra726_pcie_ep_of_data = { + .b1co_mode_sel_mask = GENMASK(3, 2), + .mode = DW_PCIE_EP_TYPE, +}; + static const struct of_device_id of_dra7xx_pcie_match[] = { { .compatible = "ti,dra7-pcie", @@ -542,6 +567,22 @@ static const struct of_device_id of_dra7xx_pcie_match[] = { .compatible = "ti,dra7-pcie-ep", .data = &dra7xx_pcie_ep_of_data, }, + { + .compatible = "ti,dra746-pcie-rc", + .data = &dra746_pcie_rc_of_data, + }, + { + .compatible = "ti,dra726-pcie-rc", + .data = &dra726_pcie_rc_of_data, + }, + { + .compatible = "ti,dra746-pcie-ep", + .data = &dra746_pcie_ep_of_data, + }, + { + .compatible = "ti,dra726-pcie-ep", + .data = &dra726_pcie_ep_of_data, + }, {}, }; @@ -587,6 +628,47 @@ static int dra7xx_pcie_ep_unaligned_memaccess(struct device *dev) return ret; } +static int dra7xx_pcie_configure_two_lane(struct device *dev, + u32 b1co_mode_sel_mask) +{ + struct device_node *np = dev->of_node; + struct regmap *pcie_syscon; + unsigned int pcie_reg; + + pcie_syscon = syscon_regmap_lookup_by_phandle(np, + "ti,syscon-lane-conf"); + if (IS_ERR(pcie_syscon)) { + dev_err(dev, "unable to get ti,syscon-lane-conf\n"); + return -EINVAL; + } + + if (of_property_read_u32_index(np, "ti,syscon-lane-conf", 1, + &pcie_reg)) { + dev_err(dev, "couldn't get lane configuration reg offset\n"); + return -EINVAL; + } + + regmap_update_bits(pcie_syscon, pcie_reg, PCIE_1LANE_2LANE_SELECTION, + PCIE_1LANE_2LANE_SELECTION); + + pcie_syscon = syscon_regmap_lookup_by_phandle(np, "ti,syscon-lane-sel"); + if (IS_ERR(pcie_syscon)) { + dev_err(dev, "unable to get ti,syscon-lane-sel\n"); + return -EINVAL; + } + + if (of_property_read_u32_index(np, "ti,syscon-lane-sel", 1, + &pcie_reg)) { + dev_err(dev, "couldn't get lane selection reg offset\n"); + return -EINVAL; + } + + regmap_update_bits(pcie_syscon, pcie_reg, b1co_mode_sel_mask, + PCIE_B1C0_MODE_SEL); + + return 0; +} + static int __init dra7xx_pcie_probe(struct platform_device *pdev) { u32 reg; @@ -608,6 +690,7 @@ static int __init dra7xx_pcie_probe(struct platform_device *pdev) const struct of_device_id *match; const struct dra7xx_pcie_of_data *data; enum dw_pcie_device_mode mode; + u32 b1co_mode_sel_mask; match = of_match_device(of_match_ptr(of_dra7xx_pcie_match), dev); if (!match) @@ -615,6 +698,7 @@ static int __init dra7xx_pcie_probe(struct platform_device *pdev) data = (struct dra7xx_pcie_of_data *)match->data; mode = (enum dw_pcie_device_mode)data->mode; + b1co_mode_sel_mask = data->b1co_mode_sel_mask; dra7xx = devm_kzalloc(dev, sizeof(*dra7xx), GFP_KERNEL); if (!dra7xx) @@ -673,6 +757,12 @@ static int __init dra7xx_pcie_probe(struct platform_device *pdev) dra7xx->pci = pci; dra7xx->phy_count = phy_count; + if (phy_count == 2) { + ret = dra7xx_pcie_configure_two_lane(dev, b1co_mode_sel_mask); + if (ret < 0) + goto err_link; + } + ret = dra7xx_pcie_enable_phy(dra7xx); if (ret) { dev_err(dev, "failed to enable phy\n");