From patchwork Thu Jun 14 21:53:53 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilia Lin X-Patchwork-Id: 10465375 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id AE67F60348 for ; Thu, 14 Jun 2018 21:59:04 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9A6B528B1E for ; Thu, 14 Jun 2018 21:59:04 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8D72E28B9B; Thu, 14 Jun 2018 21:59:04 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, DKIM_VALID, FREEMAIL_FROM, MAILING_LIST_MULTI autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 33F6F28B1E for ; Thu, 14 Jun 2018 21:59:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=1nxvxInHr+cfO7pA3joz4nE1T2/+dVt4OFBMjJC+bGc=; b=qjFpVABVEvMCXqQL/Htd85zhFO gr7EZ4lTp4ylUo3VornWM58xLmje6umeW2I4PV0V6wFTVFIS93CjHa40hS3GQ/A0uFyEvFe41OLjV oGMvXhcG7OMoVbh5He9vf3OrwHKTWVc6c44xlzZI50V+cXpamKjCAZd0M8Wloyp56Ue7bqpACoR5T QCPD7bBlrX1HOtsSnbjC1ZFY8kCQaiM8ET/Bs7OjBA9eSc3z6nRLlZnmbEq6ih+QqKjrMiap7Llk2 eXFtnKS8d4oTIWDLez0CiRylzh1lc1i2a45gV+yAhfDtIYZOHt6xcF8zXtfZw1gAyOym5Fqw/s0RD cAhO3HtQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1fTaGZ-00047P-7B; Thu, 14 Jun 2018 21:58:51 +0000 Received: from mail-wm0-x243.google.com ([2a00:1450:400c:c09::243]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1fTaDb-0001jn-HQ for linux-arm-kernel@lists.infradead.org; Thu, 14 Jun 2018 21:55:58 +0000 Received: by mail-wm0-x243.google.com with SMTP id o13-v6so393344wmf.4 for ; Thu, 14 Jun 2018 14:55:37 -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=D6Y28GeuCxPrpnkW0YhMPcSQUStyGeLLY0H/alkxMnUkwSOb7WekTmZgF65zM3t19r eNoNiCb4H/62QVjGnbVat+JUcpOuGNRptQdJTnee/lwEdFnd0jUCuOXI/pNeazl3gQ46 dh4zSF/5oex1ebrAZi2gf6Ekav9hXhtTX5cPYJvdYHN1YiBGaF4WS6fZipErj/xydXWl 4vVklxKe877iMwG9KKLxrRE9qSovBfDVrp3pYO1aU9GDzBV/yN1ndoHl8a1dnEfRc7DS hmwoHgNb50ckisB/o+0XSM046aXwbEctaONIoiC49TlCmX4Kd0zeESnZkrnsm7oyOZjV 7K2g== X-Gm-Message-State: APt69E3if2qV94QmGxokThnYO3mtEk8mswpvSS43MM9vY5I4iQYfCjg3 B/84kQcTc5/LF/M1D/+PKeo= X-Google-Smtp-Source: ADUXVKL1T5V0UMiZ0MG6E4pK8GZqR1GOwaLxhP+MFb8pzU6K0Taof96Fmd0ipEuIZ1PRvm/pmxDSxw== 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 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> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180614_145547_600956_A5F47342 X-CRM114-Status: GOOD ( 16.40 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mark Rutland , devicetree@vger.kernel.org, Rajendra Nayak , Stephen Boyd , linux-arm-msm@vger.kernel.org, Michael Turquette , Will Deacon , linux-kernel@vger.kernel.org, Amit Kucheria , David Brown , Rob Herring , Ilia Lin , Andy Gross , linux-soc@vger.kernel.org, linux-clk@vger.kernel.org, linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP 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; }