Received: by 10.192.165.148 with SMTP id m20csp1749312imm; Thu, 3 May 2018 04:58:18 -0700 (PDT) X-Google-Smtp-Source: AB8JxZqs11PuWESqfmRHKqUlD022mSeW7oJ7QoQH4VZpTCJtsYwS+GIdkcYGlZaQyH6wakJd1NMC X-Received: by 2002:a63:b94a:: with SMTP id v10-v6mr19067280pgo.372.1525348698822; Thu, 03 May 2018 04:58:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525348698; cv=none; d=google.com; s=arc-20160816; b=s1PrZKjngZcHXRTXpZK8bfc3N6WAmmmMK/8JG+EPRCcRUzoYU7bawVUsQLkUEqoeR0 VRiI0GqxI6eSWUyIxaUcIIxRErEqYwnZVA59XGEUJWlZtIVWf1FKW+3CBujjURj4wUZo PxFx7cj8wkcR5L3qdDrudCscA8jd1Jn9U0BA8MOiw5wf30XPRIC3ryiXBuZAWEkwpS5x XSHASG9TjOQ9avRtyq/hASTFNZu/rc1XEqHY+hI7svZrn8QEWP+lb15x8KzR9qGgL7N4 eV4gITJ5Z97ZxKQDgZNoDuuvBkC0Dv7D+sStWHWRfFnkNfJvLZvSXONxObulBue6zEN0 P7cQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dmarc-filter:dkim-signature:dkim-signature :arc-authentication-results; bh=ybkLUTecoT17fzD+3AREEiX8V8KeCGVupob4b/q/YyM=; b=Ey/LgRQopywiEPsDq7ghkmwFJ0qbaumSbOgrC0oU8rm6K9Q+UythwZmFjBVzsRoBNI zj4yMgP1epDgPptZibdC6l356LyMhUgrI0tgcCm9bWK1zjtPbJ3F+RSQco1seMsz10XE Wy/tdGDipJoOkietJWToY55Vfc2Yo/HDqwfNN9PTIJs8k5qTmal05bjBLnTijYmwVpbX 8DPoZDtcpTwSkI63MCFHF3L1XOQ0ktCzK52VtEUtwSiTJo/73WMtuVw6PUou+SJEOxEf YjOO208E7aVSyM8pnpmWDxz8Bf63GRh5hp9wnZ0PykVKDK1xpnOiwSuqbKvHQtjGuA8k sWFQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@codeaurora.org header.s=default header.b=cBzJdYbk; dkim=pass header.i=@codeaurora.org header.s=default header.b=oZ9wE2Vl; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l23-v6si11176195pgo.280.2018.05.03.04.58.04; Thu, 03 May 2018 04:58:18 -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=@codeaurora.org header.s=default header.b=cBzJdYbk; dkim=pass header.i=@codeaurora.org header.s=default header.b=oZ9wE2Vl; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752031AbeECL4b (ORCPT + 99 others); Thu, 3 May 2018 07:56:31 -0400 Received: from smtp.codeaurora.org ([198.145.29.96]:34062 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751808AbeECLxN (ORCPT ); Thu, 3 May 2018 07:53:13 -0400 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id 9AF716090E; Thu, 3 May 2018 11:53:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1525348392; bh=qxnvIgZec1BobCrsvY94G2d6QsCu6/tS7OuwxOh7pEo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=cBzJdYbkDVLA+DHfb9VCZqGrUhpfyWsyEifqP8R+DVBMMcxC7md3CeMHWEKqt+hxp pBRvyMCZeL3FJIai/2howraiPMgAbR21oaPSXXMrULnYhYJFP5Z7Nxc2VyxkczDCxp dG+zXV8/JC50MD098jo0d/MwLNK+KN0atY33tGxk= X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on pdx-caf-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.8 required=2.0 tests=ALL_TRUSTED,BAYES_00, DKIM_SIGNED,T_DKIM_INVALID autolearn=no autolearn_force=no version=3.4.0 Received: from lx-ilial.mea.qualcomm.com (unknown [185.23.60.4]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: ilialin@smtp.codeaurora.org) by smtp.codeaurora.org (Postfix) with ESMTPSA id 221A0607F5; Thu, 3 May 2018 11:53:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1525348391; bh=qxnvIgZec1BobCrsvY94G2d6QsCu6/tS7OuwxOh7pEo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=oZ9wE2Vls7AkeuogTwq98eN4Gcp3K8VJXHHR9wcF+5sx/G6urooxD5+rg04eWUDqt 0VnbWAo63dNGQ0aY4a59ml4Zyi8GP3QT2O64Cc4Ll7gqbbQqfuFLRfheA9gBDtJ2a+ 8I1zvnZ3beHt70WGwo+hDyvoCM6ROblCVN355OK8= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 221A0607F5 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=ilialin@codeaurora.org From: Ilia Lin To: mturquette@baylibre.com, sboyd@kernel.org, robh@kernel.org, mark.rutland@arm.com, rjw@rjwysocki.net, viresh.kumar@linaro.org, lgirdwood@gmail.com, broonie@kernel.org, andy.gross@linaro.org, david.brown@linaro.org, catalin.marinas@arm.com, will.deacon@arm.com, linux-clk@vger.kernel.org Cc: devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-soc@vger.kernel.org, linux-arm-kernel@lists.infradead.org, rnayak@codeaurora.org, ilialin@codeaurora.org, amit.kucheria@linaro.org, nicolas.dechesne@linaro.org, celster@codeaurora.org, tfinkel@codeaurora.org Subject: [PATCH v5 05/14] clk: qcom: cpu-8996: Add support to switch to alternate PLL Date: Thu, 3 May 2018 14:52:26 +0300 Message-Id: <1525348355-25471-6-git-send-email-ilialin@codeaurora.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1525348355-25471-1-git-send-email-ilialin@codeaurora.org> References: <1525348355-25471-1-git-send-email-ilialin@codeaurora.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Rajendra Nayak Each of the CPU clusters on msm8996 are powered via a primary PLL and a secondary PLL. The primary PLL is what drives the CPU clk, except for times when we are reprogramming the PLL itself, when we temporarily switch to an alternate PLL. Use clock rate change notifiers to support this. Signed-off-by: Rajendra Nayak Signed-off-by: Ilia Lin --- drivers/clk/qcom/clk-cpu-8996.c | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/drivers/clk/qcom/clk-cpu-8996.c b/drivers/clk/qcom/clk-cpu-8996.c index beb97eb..390b369 100644 --- a/drivers/clk/qcom/clk-cpu-8996.c +++ b/drivers/clk/qcom/clk-cpu-8996.c @@ -61,6 +61,7 @@ * detect voltage droops. We do not add support for ACD as yet. */ +#include #include #include #include @@ -187,10 +188,14 @@ struct clk_cpu_8996_mux { u32 reg; u8 shift; u8 width; + struct notifier_block nb; struct clk_hw *pll; struct clk_regmap clkr; }; +#define to_clk_cpu_8996_mux_nb(_nb) \ + container_of(_nb, struct clk_cpu_8996_mux, nb) + static inline struct clk_cpu_8996_mux *to_clk_cpu_8996_mux_hw(struct clk_hw *hw) { @@ -236,6 +241,26 @@ static int clk_cpu_8996_mux_set_parent(struct clk_hw *hw, u8 index) return 0; } +int cpu_clk_notifier_cb(struct notifier_block *nb, unsigned long event, + void *data) +{ + int ret; + struct clk_cpu_8996_mux *cpuclk = to_clk_cpu_8996_mux_nb(nb); + + switch (event) { + case PRE_RATE_CHANGE: + ret = clk_cpu_8996_mux_set_parent(&cpuclk->clkr.hw, ALT_INDEX); + break; + case POST_RATE_CHANGE: + ret = clk_cpu_8996_mux_set_parent(&cpuclk->clkr.hw, PLL_INDEX); + break; + default: + ret = 0; + break; + } + + return notifier_from_errno(ret); +}; const struct clk_ops clk_cpu_8996_mux_ops = { .set_parent = clk_cpu_8996_mux_set_parent, .get_parent = clk_cpu_8996_mux_get_parent, @@ -279,6 +304,7 @@ static int clk_cpu_8996_mux_set_parent(struct clk_hw *hw, u8 index) .shift = 0, .width = 2, .pll = &pwrcl_pll.clkr.hw, + .nb.notifier_call = cpu_clk_notifier_cb, .clkr.hw.init = &(struct clk_init_data) { .name = "pwrcl_pmux", .parent_names = (const char *[]){ @@ -298,6 +324,7 @@ static int clk_cpu_8996_mux_set_parent(struct clk_hw *hw, u8 index) .shift = 0, .width = 2, .pll = &perfcl_pll.clkr.hw, + .nb.notifier_call = cpu_clk_notifier_cb, .clkr.hw.init = &(struct clk_init_data) { .name = "perfcl_pmux", .parent_names = (const char *[]){ @@ -356,6 +383,12 @@ struct clk_regmap *clks[] = { clk_alpha_pll_configure(&perfcl_alt_pll, regmap, &altpll_config); clk_alpha_pll_configure(&pwrcl_alt_pll, regmap, &altpll_config); + ret = clk_notifier_register(pwrcl_pmux.clkr.hw.clk, &pwrcl_pmux.nb); + if (ret) + return ret; + + ret = clk_notifier_register(perfcl_pmux.clkr.hw.clk, &perfcl_pmux.nb); + return ret; } -- 1.9.1