Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp475916imm; Fri, 21 Sep 2018 03:28:48 -0700 (PDT) X-Google-Smtp-Source: ANB0VdY4HD8p4yuj/kSPbVsYp09SGyyPfnn1PEQoRV9Cdc737SpvoyiTCJHu0hYGz+6slxgXmtN2 X-Received: by 2002:a65:66d4:: with SMTP id c20-v6mr38147915pgw.55.1537525728490; Fri, 21 Sep 2018 03:28:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537525728; cv=none; d=google.com; s=arc-20160816; b=DIsZG4tYI0W0v1Zs1Qk/dE3gqmmOwkwsl6WHVqYCqVHizgzQouv7VCEf6gwYYrn2is IWj7T/GOajoXGZv9MGnU+AA4pzyP98JOFEu9RYXprM/gnthLPl+E/RZlO5p9BKFLM4AF NN61RmwSHIUypyK6fo104HWvBOrIcRD/43FspYwxGaCqSIGmCN7dSKRIPejx/a4leKES LYND/JFLzPGZHaMkzj6g9vq5KMCOHqL9h6c8s11ZDPjcy+BNX6rHVtvsGcmMd8uBm3Ov 4WOKGQAdC81yHpQe/aqnPRezA6POc6FPXxXKUpiNGWVJaYSH68G4nrPCBne1h1Z2aLbC FuMg== 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; bh=Zb1pEq/7Y0jRAn9nRMQL9/laMZOm8SQbSboCqJYQG+M=; b=Tp7lhg+u1AzSg1QdWjQ4fuqmeb0SEtzStn00Kqh6nTxhmRCHk0rrVkY7A/EKM4NPmm kHRbbc/g9tqEg49W9ILoMCuXdjFvrBXL1K8HS9M9T2IdAQ+DPc1SX8foZvdkQ1lfJ9SH 4lUtGSMupYONhkeovnK2X5clEmrDGvCZSe6zQ6ZsaCcvpKLt9ZkdDClrPchpbAyc/CwN jObe6k5th7q4yX75dEf4pu/efOPt20tG1ihk9/P83vCsCVZhZwpoTP9ASj3EE7goEfE6 +mZorlLdommm93pYOrHBlF/ouTjoVDkLZZzYbjhwVOqubVSXeTm0HAg7vQ1LUhJ9+/V4 5PzQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b="Qr9/RnDd"; 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 y64-v6si8775131pgb.219.2018.09.21.03.28.33; Fri, 21 Sep 2018 03:28:48 -0700 (PDT) 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="Qr9/RnDd"; 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 S2390129AbeIUQM5 (ORCPT + 99 others); Fri, 21 Sep 2018 12:12:57 -0400 Received: from fllv0015.ext.ti.com ([198.47.19.141]:35170 "EHLO fllv0015.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727776AbeIUQM5 (ORCPT ); Fri, 21 Sep 2018 12:12:57 -0400 Received: from dlelxv90.itg.ti.com ([172.17.2.17]) by fllv0015.ext.ti.com (8.15.2/8.15.2) with ESMTP id w8LAOL1B030608; Fri, 21 Sep 2018 05:24:21 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1537525461; bh=Zb1pEq/7Y0jRAn9nRMQL9/laMZOm8SQbSboCqJYQG+M=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=Qr9/RnDd2oJjpm7qzfzWh3Picr00OuO8n75xmCyyI60rZH2AgodXim8eJeQP51tH4 pLQ0qRrl2ZvkQkULaTuVwsgeipw6aEXDVXXj6ioLVMfD8LFBMN7xVBWhfS0miOFdMK NCoNHGE0+JZsPyaluoQj7at25ftRYRelwrnYEjWU= Received: from DLEE102.ent.ti.com (dlee102.ent.ti.com [157.170.170.32]) by dlelxv90.itg.ti.com (8.14.3/8.13.8) with ESMTP id w8LAOLGK031053; Fri, 21 Sep 2018 05:24:21 -0500 Received: from DLEE110.ent.ti.com (157.170.170.21) by DLEE102.ent.ti.com (157.170.170.32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1466.3; Fri, 21 Sep 2018 05:24:20 -0500 Received: from dlep33.itg.ti.com (157.170.170.75) by DLEE110.ent.ti.com (157.170.170.21) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.1.1466.3 via Frontend Transport; Fri, 21 Sep 2018 05:24:20 -0500 Received: from a0393678ub.dal.design.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 w8LAMEtU032280; Fri, 21 Sep 2018 05:24:16 -0500 From: Kishon Vijay Abraham I To: Jingoo Han , Joao Pinto , Bjorn Helgaas , Rob Herring , Lorenzo Pieralisi , Murali Karicheri , Kishon Vijay Abraham I , CC: Mark Rutland , Santosh Shilimkar , Tero Kristo , Nishanth Menon , , , , Subject: [RFC PATCH 26/40] PCI: keystone: Explicitly set the PCIe mode Date: Fri, 21 Sep 2018 15:51:41 +0530 Message-ID: <20180921102155.22839-27-kishon@ti.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180921102155.22839-1-kishon@ti.com> References: <20180921102155.22839-1-kishon@ti.com> MIME-Version: 1.0 Content-Type: text/plain 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 Explicitly set the PCIe mode to BOOTCFG_DEVCFG instead of always relying on the default values. This is required when EP mode has to be explicitly written to BOOTCFG_DEVCFG register. Signed-off-by: Kishon Vijay Abraham I --- drivers/pci/controller/dwc/pci-keystone.c | 37 +++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/drivers/pci/controller/dwc/pci-keystone.c b/drivers/pci/controller/dwc/pci-keystone.c index 13e865f82f96..e8328039a017 100644 --- a/drivers/pci/controller/dwc/pci-keystone.c +++ b/drivers/pci/controller/dwc/pci-keystone.c @@ -80,6 +80,15 @@ #define PCIE_RC_K2L 0xb00a #define PCIE_RC_K2G 0xb00b +#define KS_PCIE_DEV_TYPE_MASK (0x3 << 1) +#define KS_PCIE_DEV_TYPE(mode) ((mode) << 1) + +#define EP 0x0 +#define LEG_EP 0x1 +#define RC 0x2 + +#define KS_PCIE_SYSCLOCKOUTEN BIT(0) + #define to_keystone_pcie(x) dev_get_drvdata((x)->dev) static int ks_pcie_start_link(struct dw_pcie *pci); @@ -749,6 +758,30 @@ static int ks_pcie_enable_phy(struct keystone_pcie *ks_pcie) return ret; } +static int ks_pcie_set_mode(struct device *dev) +{ + struct device_node *np = dev->of_node; + struct regmap *syscon; + u32 val; + u32 mask; + int ret = 0; + + syscon = syscon_regmap_lookup_by_phandle(np, "ti,syscon-pcie-mode"); + if (IS_ERR(syscon)) + return 0; + + mask = KS_PCIE_DEV_TYPE_MASK | KS_PCIE_SYSCLOCKOUTEN; + val = KS_PCIE_DEV_TYPE(RC) | KS_PCIE_SYSCLOCKOUTEN; + + ret = regmap_update_bits(syscon, 0, mask, val); + if (ret) { + dev_err(dev, "failed to set pcie mode\n"); + return ret; + } + + return 0; +} + static int __init ks_pcie_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; @@ -865,6 +898,10 @@ static int __init ks_pcie_probe(struct platform_device *pdev) goto err_get_sync; } + ret = ks_pcie_set_mode(dev); + if (ret < 0) + goto err_get_sync; + ret = ks_pcie_add_pcie_port(ks_pcie, pdev); if (ret < 0) goto err_get_sync; -- 2.17.1