From patchwork Fri Sep 21 10:21:41 2018 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: 147206 Delivered-To: patch@linaro.org Received: by 2002:a2e:1648:0:0:0:0:0 with SMTP id 8-v6csp629248ljw; Fri, 21 Sep 2018 03:24:47 -0700 (PDT) X-Google-Smtp-Source: ANB0VdawmlyfB7gVT9LYZIh3J7JiVRXwS4Q2x4OCMw+slo3dQzjxzD6EdDnYkCmS6WYJGGICvJNW X-Received: by 2002:a63:91:: with SMTP id 139-v6mr40953698pga.389.1537525487724; Fri, 21 Sep 2018 03:24:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537525487; cv=none; d=google.com; s=arc-20160816; b=CETEulD/GL7bKwJcwLyokOPu0gwjlbMrmtxnPPNcfSy12zXzSWLdVs63EaBpDHeE5u FJ+vVE1qwlNwNMwwnT809VmwUuzY5vhNHOJYeH5J9/YN3iiKIAgoIV0z1woWVqcfega9 BvuhJaM870VDI6yErH4dSNAFP374lEEdXMCREc4S+5r2DNVIZwxiyyGd7o+Vb9TDbzXv L2nt0bNxHBegyocIhfQX0fyqsEsRQ5HZYBLnUBWn8gFvO1yUuxUHLwShZgpFMBC3dPBe /jZzdrFsDilIEyPMdbuknNevWftLf2t00Ddm9KQrBU3Lan1YzC/giLvzpx3mmWnjvhYD ruNw== 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 b3-v6si6006772pld.36.2018.09.21.03.24.47; Fri, 21 Sep 2018 03:24:47 -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 S2390133AbeIUQM5 (ORCPT + 32 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 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(+) -- 2.17.1 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;