Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp37813imm; Thu, 14 Jun 2018 14:58:03 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJ1KHbzp8ddFWxD6nlbedQgc6PQ6sQId5GZcj5vMMoh3ZOncEt8McAg5PgcJm6tsmFRe/ml X-Received: by 2002:a17:902:6acc:: with SMTP id i12-v6mr4919749plt.278.1529013483324; Thu, 14 Jun 2018 14:58:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529013483; cv=none; d=google.com; s=arc-20160816; b=V2BPUAPK1sLTXbBXuV2xRJT/QgZ7luT1snfcNGLp9IdCK+5ZtSxpVasoSwQIGBLbAA fI4gI9dhqiAXlvjRlsbTsNQ8mXhZknRmqCLDjHOjPdGe3Lx6jK3P3cSa0SmjQIEFVM8W xe9vcF3Ij6FepHAXPLbZVbMPtnykx83NlcoGODokQlANMT3KAYeXOweGJHBmnRY00jWe M1vZz2NjRNGqmjlgWwZJ60vNqqo64cpDvUpipVg4uqKM7pVeKF6kKRgN45dcROK71dfe gCIsWWwRKvXVMSuj2AgHsFzahiuuhHU22Fv/jjkC7HwQ/lNmW44HVVD56LAt4uh2tc1Q K7Ng== 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:dkim-signature:arc-authentication-results; bh=ieEMVoRfoQhfxE+IpQp08MjWf/guXO0i0UaAfjgC4m0=; b=fn1bd1ghLEeuAlt+ieKP4B30oK/fQYeB01ZSHhZBJmS34uvi0emjd4HiOzy4lGO1iT jYxpOD8wU1v+5MQrnXD7r2i5UxHP/4+BcCJ+5iHnN//2zapaMPT5uIZwRg3+iEB5EfiE 3CRwuN97YI3hCcJmCR6YesHWoXw5xYZUQD4QlFV8uyoRYxaq8WlyvVR+vyV+YDxX8qza V0mSCGzTXWMQ7LBfHGjMVfdJ0OhnlrQvQUsLLbX/HlkujfFlz7FOq+1w+plHP2v4NACT cZoSfkVFa19jOkzp3nlIWXHJP8hjq9onjREZMRlCRxPxjCSR2co1Y3Sb61JjmVTjSejZ zajg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=DZO0Faoz; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t87-v6si6297917pfk.228.2018.06.14.14.57.49; Thu, 14 Jun 2018 14:58:03 -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=@gmail.com header.s=20161025 header.b=DZO0Faoz; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S965038AbeFNVzm (ORCPT + 99 others); Thu, 14 Jun 2018 17:55:42 -0400 Received: from mail-wm0-f66.google.com ([74.125.82.66]:53138 "EHLO mail-wm0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S965023AbeFNVzh (ORCPT ); Thu, 14 Jun 2018 17:55:37 -0400 Received: by mail-wm0-f66.google.com with SMTP id p126-v6so410933wmb.2; Thu, 14 Jun 2018 14:55:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=ieEMVoRfoQhfxE+IpQp08MjWf/guXO0i0UaAfjgC4m0=; b=DZO0FaozbW+wgJ+kpL5zPyLsnzKLnGEZFVQOFK1WTMB0h3+dmYSmCMXvaECSR644q6 Bt7KhOjax6/07TAO6u4B8oNvsov5f04yakxtZtJ5LLfksea74Ew0YqfPBeRiP67Lrm74 gBTYT36d6vLY0fN661xhWoO0K3NJXWTEbZ2LTvQaVEdKzLtf+YMeAxN5QXgrxoOQN0nB yaOHiHvE9EEWYu0+mBXPrQ97Co2vwhc1B5T0lU3geOvqhGMjOf7P/gVauxNcKOOxCJTE 6DKO38HlBX7OYQSAzKR56gotjX3RZjpi1uAGTGdAwHdOZqljx5+P6w8StcGFfwhvQ9y5 nsqQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=ieEMVoRfoQhfxE+IpQp08MjWf/guXO0i0UaAfjgC4m0=; b=gDr+oMzxbPEKk3v7o7xtIoGaz23tF95RGyHGLhwKRQZ46sYbI1FIoqki6OXzN1WbDI OMviCUD5tGHOoep38yVT3S3Vq4nJJ8A88qSWyrwfiq1q1KLWhVGpxB5VTlRINKyoQ+g6 93GeA/pqN0Uz4sndAI4CLhMCTNu5k6Xq5b4mqzsXjBS4RuQlvA51wPJxK3Zu2Gqep2Sv bX8M2AHgr8UDIe2XtcbtxRTczvosvc6zvmxPyZBzaI1ndU/Ng0iDfFSdFrokXtQMHhMt avHIa+NGjyKYZIBZnrQU3dSCKnVAuxFSIE99VxvFyf6mts7f3d6RFS/I2DYaX1QsedV+ 8ybQ== X-Gm-Message-State: APt69E1fADP60g8l8hirYX9vHRwvG8a2R8iLdDQ+RvZPBbWFSC8YWooO hpHI3se0JlAezoo5aJIz2uA= X-Received: by 2002:a1c:eccb:: with SMTP id h72-v6mr2991411wmi.157.1529013335832; Thu, 14 Jun 2018 14:55:35 -0700 (PDT) Received: from gcc67.tetaneutral.net (gcc67.tetaneutral.net. [2a03:7220:8080:c00::1]) by smtp.gmail.com with ESMTPSA id i76-v6sm285367wmd.20.2018.06.14.14.55.34 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 14 Jun 2018 14:55:35 -0700 (PDT) From: ilia.lin@gmail.com To: ilia.lin@gmail.com Cc: Rajendra Nayak , Ilia Lin , Michael Turquette , Stephen Boyd , Rob Herring , Mark Rutland , Andy Gross , David Brown , Will Deacon , Amit Kucheria , linux-clk@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-soc@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH v13 6/8] clk: qcom: cpu-8996: Add support to switch to alternate PLL Date: Thu, 14 Jun 2018 23:53:53 +0200 Message-Id: <20180614215358.11264-7-ilia.lin@gmail.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180614215358.11264-1-ilia.lin@gmail.com> References: <20180614215358.11264-1-ilia.lin@gmail.com> 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 Tested-by: Amit Kucheria --- 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 d92cad93af20..620fdc2266ba 100644 --- a/drivers/clk/qcom/clk-cpu-8996.c +++ b/drivers/clk/qcom/clk-cpu-8996.c @@ -52,6 +52,7 @@ * detect voltage droops. */ +#include #include #include #include @@ -178,10 +179,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) { @@ -227,6 +232,26 @@ clk_cpu_8996_mux_determine_rate(struct clk_hw *hw, struct clk_rate_request *req) 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, @@ -270,6 +295,7 @@ static struct clk_cpu_8996_mux pwrcl_pmux = { .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 *[]){ @@ -289,6 +315,7 @@ static struct clk_cpu_8996_mux perfcl_pmux = { .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 *[]){ @@ -347,6 +374,12 @@ qcom_cpu_clk_msm8996_register_clks(struct device *dev, struct regmap *regmap) 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; } -- 2.11.0