From patchwork Thu Mar 4 04:41:18 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: 392730 Delivered-To: patch@linaro.org Received: by 2002:a02:8562:0:0:0:0:0 with SMTP id g89csp348706jai; Thu, 4 Mar 2021 14:16:33 -0800 (PST) X-Google-Smtp-Source: ABdhPJzTm/QU7X3uPEnZpPUFwnHtw5fgpEwdpBKnIWctLd0oZNfRL6VVv0PH84cieF8L6hxiXvHp X-Received: by 2002:a17:906:228d:: with SMTP id p13mr6587588eja.412.1614896193129; Thu, 04 Mar 2021 14:16:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614896193; cv=none; d=google.com; s=arc-20160816; b=0UjJB8RrkkWCvQ/gTt/AR4IK6ruEuAX9jCPcAZzj05pZE8zzJbLAGg78pa1pfclU+7 v4KUxNRiPr5/x7RByRlVejalDC22c+IWxkiUeAKmSkMGg8RQElvGOsuh0Jaq0gzNltvP PKFt5XbTkk/cO/y2uCygKpOFbx+kc9BozssHHx0d7jSE0rlE8m0/ZmfKfZ0jqlEIbk0K wh/be1DnBeTeCjqoMcfm4DNyMmV3gVNF2PzihNftCnYbvzqw2ZJRxk2udUZgalG2kJru jzRw/kBPCEQiw6S06I7inKEXw33u5ghL76LTR3NeGAc8gpU73jqZwv7l2aqp2GSk0Q+B NgZA== 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=fTTzBtUNI6wOHn23Acadhw+lAANu22wL/U385vCODoY=; b=v6qvNmkrT6SadZhvgF+dqCOnMBD828Tq/fpmd+vQVdQO6QNZc2oEGf+BP+DrHhmim3 lKDtWweKXIX4k4rvXPeGzVdoky1ViQ+ly3jviY/Fv7Qo/PfCi233Drt0puGQOXqD4+8/ ep5tP4mW/va84xm4oaWRhQOG5KL0WyCm5hU9Q3WDBH6KBsMn3sEqBhOfjMSOXSfYPEMt 5lbBYpQ83ESCWarKbh2hV6nGioB7W1GVPuL0BwQN1jB4ieE+BnChfUXWL88OzIq8KVfx hTvKJv5g3tC/7O7fcBU3BrFMIFhRGjkpOhl0wLGI5tVN5lI/1QDiypkV65RpRzTlMAp+ 7tng== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=BPRcouaw; 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 k6si527757edj.545.2021.03.04.14.16.32; Thu, 04 Mar 2021 14:16:33 -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=BPRcouaw; 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 S233533AbhCDEoI (ORCPT + 6 others); Wed, 3 Mar 2021 23:44:08 -0500 Received: from fllv0016.ext.ti.com ([198.47.19.142]:47166 "EHLO fllv0016.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233818AbhCDEnn (ORCPT ); Wed, 3 Mar 2021 23:43:43 -0500 Received: from fllv0035.itg.ti.com ([10.64.41.0]) by fllv0016.ext.ti.com (8.15.2/8.15.2) with ESMTP id 1244g3RH052822; Wed, 3 Mar 2021 22:42:03 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1614832923; bh=fTTzBtUNI6wOHn23Acadhw+lAANu22wL/U385vCODoY=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=BPRcouawPEu36ib6WQy00n2RUecemNJILrhPfP0qsZ11Vz8BYIYAo4Hbu5VgRJ2kd QjEm3Ek3JVUsznJD9MLX9k6G2AXWeAoKy6OLNrv/ucMGkJPT47kQhNFbLbp8KxWqnK O/guZRohspVGLyKtcKw0Fdj3ICAuriy4zOdAB+RA= Received: from DLEE105.ent.ti.com (dlee105.ent.ti.com [157.170.170.35]) by fllv0035.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 1244g2Mv088488 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Wed, 3 Mar 2021 22:42:03 -0600 Received: from DLEE108.ent.ti.com (157.170.170.38) by DLEE105.ent.ti.com (157.170.170.35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1979.3; Wed, 3 Mar 2021 22:42:02 -0600 Received: from lelv0327.itg.ti.com (10.180.67.183) by DLEE108.ent.ti.com (157.170.170.38) 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; Wed, 3 Mar 2021 22:42:02 -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 1244fQfq042911; Wed, 3 Mar 2021 22:41:59 -0600 From: Kishon Vijay Abraham I To: Kishon Vijay Abraham I , Vinod Koul , Rob Herring , Philipp Zabel , Swapnil Jakhade CC: , , Lokesh Vutla Subject: [PATCH v4 09/13] phy: cadence: cadence-sierra: Add array of input clocks in "struct cdns_sierra_phy" Date: Thu, 4 Mar 2021 10:11:18 +0530 Message-ID: <20210304044122.15166-10-kishon@ti.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210304044122.15166-1-kishon@ti.com> References: <20210304044122.15166-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 Instead of having separate structure members for each input clock, add an array for the input clocks within "struct cdns_sierra_phy". This is in preparation for adding more input clocks required for supporting additional clock combination. Signed-off-by: Kishon Vijay Abraham I --- drivers/phy/cadence/phy-cadence-sierra.c | 25 ++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) -- 2.17.1 diff --git a/drivers/phy/cadence/phy-cadence-sierra.c b/drivers/phy/cadence/phy-cadence-sierra.c index 44c52a0842dc..a45278c30948 100644 --- a/drivers/phy/cadence/phy-cadence-sierra.c +++ b/drivers/phy/cadence/phy-cadence-sierra.c @@ -144,6 +144,13 @@ #define SIERRA_MAX_LANES 16 #define PLL_LOCK_TIME 100000 +#define CDNS_SIERRA_INPUT_CLOCKS 3 +enum cdns_sierra_clock_input { + PHY_CLK, + CMN_REFCLK_DIG_DIV, + CMN_REFCLK1_DIG_DIV, +}; + static const struct reg_field macro_id_type = REG_FIELD(SIERRA_MACRO_ID_REG, 0, 15); static const struct reg_field phy_pll_cfg_1 = @@ -197,9 +204,7 @@ struct cdns_sierra_phy { struct regmap_field *macro_id_type; struct regmap_field *phy_pll_cfg_1; struct regmap_field *pllctrl_lock[SIERRA_MAX_LANES]; - struct clk *clk; - struct clk *cmn_refclk_dig_div; - struct clk *cmn_refclk1_dig_div; + struct clk *input_clks[CDNS_SIERRA_INPUT_CLOCKS]; int nsubnodes; u32 num_lanes; bool autoconf; @@ -281,8 +286,8 @@ static int cdns_sierra_phy_init(struct phy *gphy) if (phy->autoconf) return 0; - clk_set_rate(phy->cmn_refclk_dig_div, 25000000); - clk_set_rate(phy->cmn_refclk1_dig_div, 25000000); + clk_set_rate(phy->input_clks[CMN_REFCLK_DIG_DIV], 25000000); + clk_set_rate(phy->input_clks[CMN_REFCLK1_DIG_DIV], 25000000); if (ins->phy_type == PHY_TYPE_PCIE) { num_cmn_regs = phy->init_data->pcie_cmn_regs; num_ln_regs = phy->init_data->pcie_ln_regs; @@ -488,7 +493,7 @@ static int cdns_sierra_phy_get_clocks(struct cdns_sierra_phy *sp, dev_err(dev, "failed to get clock phy_clk\n"); return PTR_ERR(clk); } - sp->clk = clk; + sp->input_clks[PHY_CLK] = clk; clk = devm_clk_get_optional(dev, "cmn_refclk_dig_div"); if (IS_ERR(clk)) { @@ -496,7 +501,7 @@ static int cdns_sierra_phy_get_clocks(struct cdns_sierra_phy *sp, ret = PTR_ERR(clk); return ret; } - sp->cmn_refclk_dig_div = clk; + sp->input_clks[CMN_REFCLK_DIG_DIV] = clk; clk = devm_clk_get_optional(dev, "cmn_refclk1_dig_div"); if (IS_ERR(clk)) { @@ -504,7 +509,7 @@ static int cdns_sierra_phy_get_clocks(struct cdns_sierra_phy *sp, ret = PTR_ERR(clk); return ret; } - sp->cmn_refclk1_dig_div = clk; + sp->input_clks[CMN_REFCLK1_DIG_DIV] = clk; return 0; } @@ -585,7 +590,7 @@ static int cdns_sierra_phy_probe(struct platform_device *pdev) if (ret) return ret; - ret = clk_prepare_enable(sp->clk); + ret = clk_prepare_enable(sp->input_clks[PHY_CLK]); if (ret) return ret; @@ -662,7 +667,7 @@ static int cdns_sierra_phy_probe(struct platform_device *pdev) reset_control_put(sp->phys[i].lnk_rst); of_node_put(child); clk_disable: - clk_disable_unprepare(sp->clk); + clk_disable_unprepare(sp->input_clks[PHY_CLK]); reset_control_assert(sp->apb_rst); return ret; }