Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp1812465imm; Thu, 24 May 2018 01:02:04 -0700 (PDT) X-Google-Smtp-Source: AB8JxZo2AieC+YbxgUNBJNL6aZHskH8R/pik3EJ85l7tdXP0QHOZQx8K83BjxtcpGPbWaOL3T7ts X-Received: by 2002:a63:7b4e:: with SMTP id k14-v6mr3677582pgn.261.1527148924238; Thu, 24 May 2018 01:02:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527148924; cv=none; d=google.com; s=arc-20160816; b=wteKFyMu6u8X30EW416VSuUqLKsfa5+MxaA0Hz1fHBRR22K5BkgbFKV8ZJ5Zl/nd+K rQZfl852ahMY9Zt7vf4GjEY+CoNee4FPciKWjGhjM9p9kM7EcUNwjY7YspvVI85bOGcP 0wBVRqf6ria8doG+W82ERO/Yi86vANEJyXNM+eIivP8+gLCdPTzI20HwEjYrIV0l0BJ6 YJJP9NWfMJWMm4B/X99KydbBa+NTb9AV2OQk3fsegmgMA1gL8fMQ6eqEI9nlLaGSUDxE MeJO9e2DSooAAnIHP/ZwVGh6ZRortGbeqP9lDNKwwY8pe/i/ESp/wS78uuDeiBC0ws+h KoCg== 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=At9ikht2CWambXFr4yhVQ+E7zhijIcRdqfMXTr8j7+I=; b=O2LysJqDPp7wR/JYFlc4Rf2cNxiXZ2DCVIqA8B19F+NOtL0DmmvHkE1AtGxFBzLr6A dCACkPfjkWWukOsbanS6q9ZGsIzD/L5jE6vkovlkLv9h7QeXbH89T3qhQCgh18sFNPvZ HOfdDBLI9FjgchbX1joidLklvEUlaG7bjFYyY+9bCL4v5IJ4F3ouedi8rzIYCcXycPVl k4W1gZS4vsNZRDRdB/nElEbDNcafstMqGCd4VpxaVVdReXd7p6NBSOAttshctYJbuv2h sgRTADD3zcdEGiIcZckbJ6fNR5S77PT5pbLA1KuJvNFGWBcJzURZpSGSDkoUNW5r6W4L XQWA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@codeaurora.org header.s=default header.b=mCYuqMpD; dkim=pass header.i=@codeaurora.org header.s=default header.b=BTQnoUz2; 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 a1-v6si16301991pgn.425.2018.05.24.01.01.09; Thu, 24 May 2018 01:02:04 -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=mCYuqMpD; dkim=pass header.i=@codeaurora.org header.s=default header.b=BTQnoUz2; 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 S965290AbeEXHux (ORCPT + 99 others); Thu, 24 May 2018 03:50:53 -0400 Received: from smtp.codeaurora.org ([198.145.29.96]:53286 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S965274AbeEXHus (ORCPT ); Thu, 24 May 2018 03:50:48 -0400 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id 3C94A60F8F; Thu, 24 May 2018 07:50:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1527148248; bh=/r1w+Yc0St1u/INnDlvOev0yNepaMGc+87aSg5DVMDo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=mCYuqMpDx+2u0Xs5uKTTWJNWu1rAFsSndWJV9x3N4X1+CPQwWTuRGwk3znj39jM6v DbG6iBRT6NzYysYlZOJVVfjM9Iv0ZiesWc4Rfg4LuKGjmUAVOiZjdEttqQL37zxgh9 pOr17WnMVS1nnq6ce0NPmQJUQAQ08/SfzVCS2ngM= 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 971B060C55; Thu, 24 May 2018 07:50:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1527148247; bh=/r1w+Yc0St1u/INnDlvOev0yNepaMGc+87aSg5DVMDo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=BTQnoUz2pPmVLnIzvCmdbkGB2P4/JGRpfyfZjsjQ2UMK3Hz+WyO7YpylUUx5tKEZa jkXnQMA2rYX4GtWhTgIBuEwUSYu0M6aTWVN8g5rIY7ljk7WVXtrFgCL7ZJrzwx8UYe L3mBqNIbPeIzhVAoSbqwm7Xp8+cKOlohjIUbGCSk= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 971B060C55 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, andy.gross@linaro.org, david.brown@linaro.org, will.deacon@arm.com Cc: 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, vireshk@kernel.org, ilialin@codeaurora.org, Rajendra Nayak Subject: [PATCH v12 6/8] clk: qcom: cpu-8996: Add support to switch to alternate PLL Date: Thu, 24 May 2018 10:50:16 +0300 Message-Id: <1527148218-16540-7-git-send-email-ilialin@codeaurora.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1527148218-16540-1-git-send-email-ilialin@codeaurora.org> References: <1527148218-16540-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 d92cad93..620fdc2 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 @@ 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, @@ -270,6 +295,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 *[]){ @@ -289,6 +315,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 *[]){ @@ -347,6 +374,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