From patchwork Mon Feb 22 11:40:30 2021 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: 385768 Delivered-To: patch@linaro.org Received: by 2002:a02:290e:0:0:0:0:0 with SMTP id p14csp1195013jap; Mon, 22 Feb 2021 03:43:08 -0800 (PST) X-Google-Smtp-Source: ABdhPJxzNKC8XC4JHftNVOrQnnnPamJ9iVxPLj5c7iWtUkxiZPDKfFmsu3dEEZAtnO7L3cUhEzTQ X-Received: by 2002:a17:906:c1ca:: with SMTP id bw10mr3030117ejb.510.1613994188847; Mon, 22 Feb 2021 03:43:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1613994188; cv=none; d=google.com; s=arc-20160816; b=cfTzUHrXP75QHG1SCSkDTHjNuFuFWNlW+FAsKaodJP2SQl+eMWCwxydPqjCzd8sO6k WNlznrVm5V9foVTpWj1C6H9sqL9OIOpGKdXICx5UDyJR5/0rvceTT2vnErSS1KFgon3T wARLZOrZpIDKwwxX0UY8ttbsG5TyQF9nhNrGbphwayWHWr160pTVUZMHwVmvXjGXer+2 tBJHpwnXu1fLxzeI7JT51Pf82IWIGBo+oveFLLcKpPFg39VFPpuBNHg+KWt+Hu/jO7gy BfNOKHcJUqfZhZNPFeU9GjbBFVcVBE4QShTQ5KXBx/5Jtb8vVOQUc2lhG/VAOgcXk8Tk Joiw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=nleILobfMKrszZKPLki70KC/+TSFlp8Thy//aVVnqQ8=; b=0Rfv+DT7C4bsQRaA8omNXdUv8vnlON+aNNGqr+YV5BN7GhLEWH0ct0C1Rfhuy2NQa3 S+mNAhhLP/qshHCkswmSBzgZ3vuZpIPP1yRO07U43nV2EsY8komMVhSD5Gj7Y+LRzTGr RfiAPDG+xAPvsCz2m5W+yxbATZvcDfQpzmY5QvV8CQSYdjUB5oyKZ4RmMPIleA9AUKQB J/gInG1001oXkhFrTYmbzwNYD//gIA8EDjDM981STi6UKzBkKnqjnp91+Q3kkW6QUB0N KV7YjSZhhjArqmNZWAspo7beClpXpMx4xHZLU17HfS4OfxTy9XDCOQgb7F+d5DJH/a6u 0neg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=ogDe6+kF; spf=pass (google.com: domain of devicetree-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=devicetree-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. [23.128.96.18]) by mx.google.com with ESMTP id w5si10570251edd.350.2021.02.22.03.43.08; Mon, 22 Feb 2021 03:43:08 -0800 (PST) Received-SPF: pass (google.com: domain of devicetree-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=ogDe6+kF; spf=pass (google.com: domain of devicetree-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=devicetree-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 S230331AbhBVLmk (ORCPT + 6 others); Mon, 22 Feb 2021 06:42:40 -0500 Received: from fllv0016.ext.ti.com ([198.47.19.142]:60602 "EHLO fllv0016.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230375AbhBVLmb (ORCPT ); Mon, 22 Feb 2021 06:42:31 -0500 Received: from lelv0265.itg.ti.com ([10.180.67.224]) by fllv0016.ext.ti.com (8.15.2/8.15.2) with ESMTP id 11MBelgK012592; Mon, 22 Feb 2021 05:40:47 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1613994047; bh=nleILobfMKrszZKPLki70KC/+TSFlp8Thy//aVVnqQ8=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=ogDe6+kFgPit6OqfNMQZbNHDEVQ6xyutHVgouQMw+eZ+yZ4LV+liqYFa9+roIegfD euHevik/TgkF19DW3e6L2P4N0yqso77AapXrPSJqCpSFhDTAH7nxmeEk0+mbNIQtC3 flS5+5vrSYC42YheyQyqKCjUmjKvdY6NPedk1SY4= Received: from DLEE100.ent.ti.com (dlee100.ent.ti.com [157.170.170.30]) by lelv0265.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 11MBel63126196 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Mon, 22 Feb 2021 05:40:47 -0600 Received: from DLEE109.ent.ti.com (157.170.170.41) by DLEE100.ent.ti.com (157.170.170.30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1979.3; Mon, 22 Feb 2021 05:40:47 -0600 Received: from lelv0327.itg.ti.com (10.180.67.183) by DLEE109.ent.ti.com (157.170.170.41) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1979.3 via Frontend Transport; Mon, 22 Feb 2021 05:40:47 -0600 Received: from a0393678-ssd.dhcp.ti.com (ileax41-snat.itg.ti.com [10.172.224.153]) by lelv0327.itg.ti.com (8.15.2/8.15.2) with ESMTP id 11MBeVjq105473; Mon, 22 Feb 2021 05:40:44 -0600 From: Kishon Vijay Abraham I To: Kishon Vijay Abraham I , Bjorn Helgaas , Rob Herring , Tom Joseph , Lorenzo Pieralisi CC: , , , Subject: [PATCH v3 4/4] PCI: j721e: Add support to provide refclk to PCIe connector Date: Mon, 22 Feb 2021 17:10:30 +0530 Message-ID: <20210222114030.26445-5-kishon@ti.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210222114030.26445-1-kishon@ti.com> References: <20210222114030.26445-1-kishon@ti.com> MIME-Version: 1.0 X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org Add support to provide refclk to PCIe connector. Signed-off-by: Kishon Vijay Abraham I --- drivers/pci/controller/cadence/pci-j721e.c | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) -- 2.17.1 Reported-by: kernel test robot Reported-by: Dan Carpenter diff --git a/drivers/pci/controller/cadence/pci-j721e.c b/drivers/pci/controller/cadence/pci-j721e.c index dac1ac8a7615..f99af98ab7d1 100644 --- a/drivers/pci/controller/cadence/pci-j721e.c +++ b/drivers/pci/controller/cadence/pci-j721e.c @@ -6,6 +6,7 @@ * Author: Kishon Vijay Abraham I */ +#include #include #include #include @@ -50,6 +51,7 @@ enum link_status { struct j721e_pcie { struct device *dev; + struct clk *refclk; u32 mode; u32 num_lanes; struct cdns_pcie *cdns_pcie; @@ -310,6 +312,7 @@ static int j721e_pcie_probe(struct platform_device *pdev) struct cdns_pcie_ep *ep; struct gpio_desc *gpiod; void __iomem *base; + struct clk *clk; u32 num_lanes; u32 mode; int ret; @@ -408,6 +411,19 @@ static int j721e_pcie_probe(struct platform_device *pdev) goto err_get_sync; } + clk = devm_clk_get_optional(dev, "pcie_refclk"); + if (IS_ERR(clk)) { + dev_err(dev, "failed to get pcie_refclk\n"); + goto err_pcie_setup; + } + + ret = clk_prepare_enable(clk); + if (ret) { + dev_err(dev, "failed to enable pcie_refclk\n"); + goto err_get_sync; + } + pcie->refclk = clk; + /* * "Power Sequencing and Reset Signal Timings" table in * PCI EXPRESS CARD ELECTROMECHANICAL SPECIFICATION, REV. 3.0 @@ -422,8 +438,10 @@ static int j721e_pcie_probe(struct platform_device *pdev) } ret = cdns_pcie_host_setup(rc); - if (ret < 0) + if (ret < 0) { + clk_disable_unprepare(pcie->refclk); goto err_pcie_setup; + } break; case PCI_MODE_EP: @@ -476,6 +494,7 @@ static int j721e_pcie_remove(struct platform_device *pdev) struct cdns_pcie *cdns_pcie = pcie->cdns_pcie; struct device *dev = &pdev->dev; + clk_disable_unprepare(pcie->refclk); cdns_pcie_disable_phy(cdns_pcie); pm_runtime_put(dev); pm_runtime_disable(dev);