From patchwork Fri Jul 21 11:36:13 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Varadarajan Narayanan X-Patchwork-Id: 9856695 X-Patchwork-Delegate: agross@codeaurora.org Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id BBA00600F5 for ; Fri, 21 Jul 2017 11:38:12 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A1F592876A for ; Fri, 21 Jul 2017 11:38:12 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 95BE7287B6; Fri, 21 Jul 2017 11:38:12 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 197062876A for ; Fri, 21 Jul 2017 11:38:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753343AbdGULgt (ORCPT ); Fri, 21 Jul 2017 07:36:49 -0400 Received: from smtp.codeaurora.org ([198.145.29.96]:45248 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753336AbdGULgr (ORCPT ); Fri, 21 Jul 2017 07:36:47 -0400 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id 3DD176121D; Fri, 21 Jul 2017 11:36:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1500637006; bh=HQSbEp2kMaLv42iC1hPXjWXIz1eNOMPQCq8GwMS3kpY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ihJEWha74jihT3cs34qcRtASds0s1Cufyp+pQXgJBqJE3dscwPUVlh4d6khSGEtfL 7JxzOigerTVqaxAYT1SQ48dTEFPJ4sdbumrTNwUdNMVwDINSGURij6OsHUB0qcYK3+ MZbfbMMrEub5fVyRhXMc+JsjMRHzxtSppTBOzztw= Received: from varda-linux.qualcomm.com (blr-c-bdr-fw-01_globalnat_allzones-outside.qualcomm.com [103.229.19.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: varada@smtp.codeaurora.org) by smtp.codeaurora.org (Postfix) with ESMTPSA id 968F261161; Fri, 21 Jul 2017 11:36:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1500637003; bh=HQSbEp2kMaLv42iC1hPXjWXIz1eNOMPQCq8GwMS3kpY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=JL26hZrDCZTDN6hN85yL0g8ADv6ZxfLdxA+csFQsNNAsYQigqv7EmrdfN5GiWB5Dm Cc6dmNmzv5urecMpEvyvEy0AyVieY88T0eDPen0nWP+rjy9hZWjb+0a9tNY98i7rU8 K/aCLOAWz5wqbnsdw/xkwaEydksfnxFNYefb/GUw= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 968F261161 Authentication-Results: pdx-caf-mail.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: pdx-caf-mail.web.codeaurora.org; spf=none smtp.mailfrom=varada@codeaurora.org From: Varadarajan Narayanan To: bhelgaas@google.com, robh+dt@kernel.org, mark.rutland@arm.com, svarbanov@mm-sol.com, kishon@ti.com, sboyd@codeaurora.org, vivek.gautam@codeaurora.org, fengguang.wu@intel.com, weiyongjun1@huawei.com, linux-pci@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org Cc: Varadarajan Narayanan Subject: [PATCH v4 3/7] phy: qcom-qmp: Fix phy pipe clock name Date: Fri, 21 Jul 2017 17:06:13 +0530 Message-Id: <1500636977-11934-4-git-send-email-varada@codeaurora.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1500636977-11934-1-git-send-email-varada@codeaurora.org> References: <1500636977-11934-1-git-send-email-varada@codeaurora.org> Sender: linux-arm-msm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Presently, the phy pipe clock's name is assumed to be either usb3_phy_pipe_clk_src or pcie_XX_pipe_clk_src (where XX is the phy lane's number). However, this will not work if an SoC has more than one instance of the phy. Hence, instead of assuming the name of the clock, fetch it from the DT. Signed-off-by: Varadarajan Narayanan --- drivers/phy/qualcomm/phy-qcom-qmp.c | 45 +++++++++++++++++++++++-------------- 1 file changed, 28 insertions(+), 17 deletions(-) diff --git a/drivers/phy/qualcomm/phy-qcom-qmp.c b/drivers/phy/qualcomm/phy-qcom-qmp.c index 78ca628..b046866 100644 --- a/drivers/phy/qualcomm/phy-qcom-qmp.c +++ b/drivers/phy/qualcomm/phy-qcom-qmp.c @@ -925,20 +925,13 @@ static int qcom_qmp_phy_clk_init(struct device *dev) * clk | +-------+ | +-----+ * +---------------+ */ -static int phy_pipe_clk_register(struct qcom_qmp *qmp, int id) +static int phy_pipe_clk_register(struct qcom_qmp *qmp, const char *clk_name) { - char name[24]; struct clk_fixed_rate *fixed; struct clk_init_data init = { }; - switch (qmp->cfg->type) { - case PHY_TYPE_USB3: - snprintf(name, sizeof(name), "usb3_phy_pipe_clk_src"); - break; - case PHY_TYPE_PCIE: - snprintf(name, sizeof(name), "pcie_%d_pipe_clk_src", id); - break; - default: + if ((qmp->cfg->type != PHY_TYPE_USB3) && + (qmp->cfg->type != PHY_TYPE_PCIE)) { /* not all phys register pipe clocks, so return success */ return 0; } @@ -947,7 +940,7 @@ static int phy_pipe_clk_register(struct qcom_qmp *qmp, int id) if (!fixed) return -ENOMEM; - init.name = name; + init.name = clk_name; init.ops = &clk_fixed_rate_ops; /* controllers using QMP phys use 125MHz pipe clock interface */ @@ -1110,6 +1103,8 @@ static int qcom_qmp_phy_probe(struct platform_device *pdev) id = 0; for_each_available_child_of_node(dev->of_node, child) { + const char *clk_name; + /* Create per-lane phy */ ret = qcom_qmp_phy_create(dev, child, id); if (ret) { @@ -1119,15 +1114,31 @@ static int qcom_qmp_phy_probe(struct platform_device *pdev) } /* - * Register the pipe clock provided by phy. - * See function description to see details of this pipe clock. + * This property is mandatory only for PCIe/USB phys. + * For other phy types don't return failure. */ - ret = phy_pipe_clk_register(qmp, id); - if (ret) { - dev_err(qmp->dev, - "failed to register pipe clock source\n"); + ret = of_property_read_string(child, "clock-output-names", + &clk_name); + if (ret && (qmp->cfg->type == PHY_TYPE_PCIE || + qmp->cfg->type == PHY_TYPE_USB3)) { + dev_err(dev, + "failed to get clock-output-names for lane%d phy, %d\n", + id, ret); return ret; } + + if (!ret) { + /* + * Register the pipe clock provided by phy. See function + * description to see details of this pipe clock. + */ + ret = phy_pipe_clk_register(qmp, clk_name); + if (ret) { + dev_err(qmp->dev, + "failed to register pipe clock source\n"); + return ret; + } + } id++; }