From patchwork Mon Jan 18 04:43:18 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vinod Koul X-Patchwork-Id: 365460 Delivered-To: patch@linaro.org Received: by 2002:a02:ccad:0:0:0:0:0 with SMTP id t13csp1926676jap; Sun, 17 Jan 2021 20:45:56 -0800 (PST) X-Google-Smtp-Source: ABdhPJww5aprTfYx+U2PnkrNYZnC4mdDGiw3cTG6oxoX8o7hHYuJ0gwmZXVs8mYosnldrzVs0XXa X-Received: by 2002:aa7:c78c:: with SMTP id n12mr18125045eds.363.1610945155901; Sun, 17 Jan 2021 20:45:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1610945155; cv=none; d=google.com; s=arc-20160816; b=ePydaelvdTC/CKWJ6h2x4IHXpOSd4FsPt7ZD+4F03/d9yCwl3zXgkD71HpyLEi2X+I ApLRMah5ou4XF1Uxecog/CqVk74ISrAR0diK1eyRQz4DprbtfSRnDVtbegY5T2eCZMrV 8D5icLGg/VqIrHGFvyqE0eK7xU3okRWo6CnTrpc49vewOTciMo5N1cW4ahSylgRH4FvO Xmz3oMP3nTuc4pf7gawyasClicAnjlqYN2klRZOgVW5IQ5DqsN6I64Z54bKTH8SABxS+ v7m8YjN4T7HihyJMzMh/UGVo8JADUzMSMWAGGcP51KYn5qB/e00Wqg7Xuuhw34rGw1BG jBAg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=MU7juveuXkkRoW7++LWkMDXlMlgCfEcwLZnY4L7TTHg=; b=pKpxEwDlNjEg88J9TE/I598hQ1jqA3etu8JMigcNFjnqwKeZIYn/MeYoX9qMRugZtM JXN6AKeBeddTBl/0/bs5aiamj3GBtVi7AO+2vqf7ZOnf9Wx4eQi3VhDeM9yb4xfF8+Ss YGoi8YM5LVjoSBa+H5ee61bYg3Moc697BCjctHQeMchOFHw+56q/UizUrXHx4+Ky5rKp hCWQ6Kn8bffRUj2Mikr6hT0vIDqgBVL4bwqVHAkJJ0sNSOvE19pvFCfSdcflutbvs1BE 6SoDJCtUZSSYZ/Yy5/foIbkpg+AFLbMwhzFkBfgqOvYw92bNS/+MFPKmJWrGVYunBKcy 11VQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=HU7jygma; spf=pass (google.com: domain of linux-arm-msm-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-arm-msm-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id c25si5954937edx.588.2021.01.17.20.45.55; Sun, 17 Jan 2021 20:45:55 -0800 (PST) Received-SPF: pass (google.com: domain of linux-arm-msm-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=@kernel.org header.s=k20201202 header.b=HU7jygma; spf=pass (google.com: domain of linux-arm-msm-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-arm-msm-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730652AbhAREok (ORCPT + 15 others); Sun, 17 Jan 2021 23:44:40 -0500 Received: from mail.kernel.org ([198.145.29.99]:56830 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731039AbhAREog (ORCPT ); Sun, 17 Jan 2021 23:44:36 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id DF64A224B8; Mon, 18 Jan 2021 04:43:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1610945036; bh=ujekwcrP8/ZvXDo6NAzxT624d7YlfKOIsh1MNlzQXL8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=HU7jygmakiUs7elE/rEdfOsgxh+dqEtdpy7Rx57OM7tc9IJOmxvMy7Wn67vUf3Y6n sw5frbfK34dMU5lPFectduXcGK/V7leInaGVL58RKWyd9SF9BV/Slm34gGac432/PD G6iNcBG9F6HuPRsRMpjtKMRp0zV9Fv+hrBvyW/b8OoyDToHq4DntUTUuuTwprks4sE A0KPXXUuo31rZW2iWXbjsDYXy0EaXSxYYl/p5/B/j/s8BedJMiPKWkjA3Qay5pKcXt jSdf74Scb8ZJjd6cIlV2X7VdlDUZzNe7x1jkm+ms11FphfpUVD1OVO4vk8NG+AHdEv GhNkJYCvGBZeg== From: Vinod Koul To: Stephen Boyd Cc: linux-arm-msm@vger.kernel.org, Bjorn Andersson , Vinod Koul , Andy Gross , Michael Turquette , Rob Herring , Taniya Das , AngeloGioacchino Del Regno , linux-clk@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v4 2/5] clk: qcom: clk-alpha-pll: modularize alpha_pll_trion_set_rate() Date: Mon, 18 Jan 2021 10:13:18 +0530 Message-Id: <20210118044321.2571775-3-vkoul@kernel.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20210118044321.2571775-1-vkoul@kernel.org> References: <20210118044321.2571775-1-vkoul@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org Trion 5LPE set rate uses code similar to alpha_pll_trion_set_rate() but with different registers. Modularize these by moving out latch and latch ack bits so that we can reuse the function. Suggested-by: AngeloGioacchino Del Regno Signed-off-by: Vinod Koul --- drivers/clk/qcom/clk-alpha-pll.c | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) -- 2.26.2 diff --git a/drivers/clk/qcom/clk-alpha-pll.c b/drivers/clk/qcom/clk-alpha-pll.c index f7721088494c..a30ea7b09224 100644 --- a/drivers/clk/qcom/clk-alpha-pll.c +++ b/drivers/clk/qcom/clk-alpha-pll.c @@ -1471,8 +1471,8 @@ static int alpha_pll_lucid_prepare(struct clk_hw *hw) return __alpha_pll_trion_prepare(hw, LUCID_PCAL_DONE); } -static int alpha_pll_trion_set_rate(struct clk_hw *hw, unsigned long rate, - unsigned long prate) +static int __alpha_pll_trion_set_rate(struct clk_hw *hw, unsigned long rate, + unsigned long prate, u32 latch_bit, u32 latch_ack) { struct clk_alpha_pll *pll = to_clk_alpha_pll(hw); unsigned long rrate; @@ -1490,22 +1490,20 @@ static int alpha_pll_trion_set_rate(struct clk_hw *hw, unsigned long rate, regmap_write(pll->clkr.regmap, PLL_ALPHA_VAL(pll), a); /* Latch the PLL input */ - ret = regmap_update_bits(pll->clkr.regmap, PLL_MODE(pll), - PLL_UPDATE, PLL_UPDATE); + ret = regmap_update_bits(pll->clkr.regmap, PLL_MODE(pll), latch_bit, latch_bit); if (ret) return ret; /* Wait for 2 reference cycles before checking the ACK bit. */ udelay(1); regmap_read(pll->clkr.regmap, PLL_MODE(pll), &val); - if (!(val & ALPHA_PLL_ACK_LATCH)) { + if (!(val & latch_ack)) { pr_err("Lucid PLL latch failed. Output may be unstable!\n"); return -EINVAL; } /* Return the latch input to 0 */ - ret = regmap_update_bits(pll->clkr.regmap, PLL_MODE(pll), - PLL_UPDATE, 0); + ret = regmap_update_bits(pll->clkr.regmap, PLL_MODE(pll), latch_bit, 0); if (ret) return ret; @@ -1520,6 +1518,12 @@ static int alpha_pll_trion_set_rate(struct clk_hw *hw, unsigned long rate, return 0; } +static int alpha_pll_trion_set_rate(struct clk_hw *hw, unsigned long rate, + unsigned long prate) +{ + return __alpha_pll_trion_set_rate(hw, rate, prate, PLL_UPDATE, ALPHA_PLL_ACK_LATCH); +} + const struct clk_ops clk_alpha_pll_trion_ops = { .prepare = alpha_pll_trion_prepare, .enable = clk_trion_pll_enable,