Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp802923imm; Wed, 23 May 2018 05:54:51 -0700 (PDT) X-Google-Smtp-Source: AB8JxZqhOkzMd7t64bjEqANIYc45iPyTHzr+gJIMuZjp3gC1XwacIKBA0++jTiIKDD0/LF4hM/6m X-Received: by 2002:a62:a096:: with SMTP id p22-v6mr2825138pfl.9.1527080090959; Wed, 23 May 2018 05:54:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527080090; cv=none; d=google.com; s=arc-20160816; b=OCi8I171kb4jAuurelKIicfHgnbBn8i+eydycpq2xa/yrFa5IzVB5TdPaZ0D5c/P6T +x6YAAjPrCDKbdtX91Ea5R7ejrzF20lSFXtibf/dJ0yuqoc/gSL+aoepb8LKBGIUlui3 g+xmKBE/Ik5vfINW4QwDOUe2f5CLbU62i7S3bryY+Syrdbj2L+M5QmbB6QPY4vFs9qDr tiE1tZWfe6cke/AWGKcHVfv0zb4eWFbvs7jekj9RUrrUha4sG8fNJZPHopvja76Pe4e3 50eYhCtGcYowR7vjzfTwx22UjQLBL6p2+chGH4jzkab/cAW7pZTKgCF+q56Pm+rvS9zu bkaA== 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=bu3WWolQXwgI2wPvZD2wERi2vqbs3EjFlntJH02eM1Y=; b=iJ8VkXn5D0/0lIq1gVBiMu5d977FW0mJK33lFA/w7u/3YGPIOa3oNq52VnUyUH1MGn HuzpdfikASq0bVb4p0629zu1hBihOUaiJFxLNC+88Ae1VErRHx3iOTEIZYED3SFKmWeB xx9V9Ypg2Fm1xqsnuZDVlnH2ExSoow86rchP7la08XDs0IsD3n83IR/dOxeBPGzgemVR FCKUGPMTXYIYCHoE4Gyd7jiXXneV19+DFPuCzeFLKJ1aZSkq+82VhrWTUD3bRZKE8/3w 6gIRFSaMFG8WI2hVKO/dOPxAuLLoq6a5Mxkr7BPOiy0XJGz6Q2Gjllc77nDkkK2a3IC+ eVgg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@codeaurora.org header.s=default header.b=LNh/UZcJ; dkim=pass header.i=@codeaurora.org header.s=default header.b=Tn3bU5S4; 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 b37-v6si18710173plb.377.2018.05.23.05.54.36; Wed, 23 May 2018 05:54:50 -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=LNh/UZcJ; dkim=pass header.i=@codeaurora.org header.s=default header.b=Tn3bU5S4; 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 S933020AbeEWMyC (ORCPT + 99 others); Wed, 23 May 2018 08:54:02 -0400 Received: from smtp.codeaurora.org ([198.145.29.96]:56798 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932998AbeEWMxj (ORCPT ); Wed, 23 May 2018 08:53:39 -0400 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id 1DFD36090E; Wed, 23 May 2018 12:53:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1527080018; bh=wFVifI9YZTHt6bXghKA3d9bD6PaJjaPNLQI8GRZk3hU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=LNh/UZcJK56QrW7fRFKC2mAHg/QGfRA+tIw9bCVm/DM5JicZXbzNO+JXQ9Won6LQ+ CwhLOCIIGIAxRZgT63U1vyI9R92oMwKLO5ZiLG3+BTfb09bli1R9D9rwkS/FbWHfE+ UlH2EQDJCRhhlqXu/X2gV89IxrboMSqGMeLvPQ+k= 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 C730E60F6E; Wed, 23 May 2018 12:53:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1527080017; bh=wFVifI9YZTHt6bXghKA3d9bD6PaJjaPNLQI8GRZk3hU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Tn3bU5S4E+nsWefkODhm3zb2BMlV377mP4cKt8I6sZnzz2jiatVnNUpB/0geIDVJC xWu4BIlQcu4C3JzTTa9riTir8pWyfrjyOQI4FCVwQQ+tZumPzx+ka6NYhLJCMtB+H5 CPwSFlP/KJnveU67Rfcb+cvV3fUX+tQhfC1S0/rA= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org C730E60F6E 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 Subject: [PATCH v11 8/8] clk: qcom: Add ACD path to CPU clock driver for msm8996 Date: Wed, 23 May 2018 15:53:01 +0300 Message-Id: <1527079981-11179-9-git-send-email-ilialin@codeaurora.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1527079981-11179-1-git-send-email-ilialin@codeaurora.org> References: <1527079981-11179-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 The PMUX for each duplex allows for selection of ACD clock source. The DVM (Dynamic Variation Monitor) will flag an error when a voltage droop event is detected. This flagged error enables ACD to provide a div-by-2 clock, sourced from the primary PLL. The duplex will be provided the divided clock until a pre-programmed delay has expired. This change configures ACD during the probe and switches the PMUXes to the ACD clock source. Signed-off-by: Ilia Lin --- drivers/clk/qcom/clk-cpu-8996.c | 75 +++++++++++++++++++++++++++++++++++------ 1 file changed, 65 insertions(+), 10 deletions(-) diff --git a/drivers/clk/qcom/clk-cpu-8996.c b/drivers/clk/qcom/clk-cpu-8996.c index ff5c0a5..0a908d8 100644 --- a/drivers/clk/qcom/clk-cpu-8996.c +++ b/drivers/clk/qcom/clk-cpu-8996.c @@ -53,9 +53,11 @@ */ #include +#include #include #include #include +#include #include "clk-alpha-pll.h" #include "clk-regmap.h" @@ -69,6 +71,11 @@ enum _pmux_input { }; #define DIV_2_THRESHOLD 600000000 +#define PWRCL_REG_OFFSET 0x0 +#define PERFCL_REG_OFFSET 0x80000 +#define MUX_OFFSET 0x40 +#define ALT_PLL_OFFSET 0x100 +#define SSSCTL_OFFSET 0x160 static const u8 prim_pll_regs[PLL_OFF_MAX_REGS] = { [PLL_OFF_L_VAL] = 0x04, @@ -107,7 +114,7 @@ enum _pmux_input { }; static struct clk_alpha_pll perfcl_pll = { - .offset = 0x80000, + .offset = PERFCL_REG_OFFSET, .regs = prim_pll_regs, .flags = SUPPORTS_DYNAMIC_UPDATE | SUPPORTS_FSM_MODE, .clkr.hw.init = &(struct clk_init_data){ @@ -119,7 +126,7 @@ enum _pmux_input { }; static struct clk_alpha_pll pwrcl_pll = { - .offset = 0x0, + .offset = PWRCL_REG_OFFSET, .regs = prim_pll_regs, .flags = SUPPORTS_DYNAMIC_UPDATE | SUPPORTS_FSM_MODE, .clkr.hw.init = &(struct clk_init_data){ @@ -149,7 +156,7 @@ enum _pmux_input { }; static struct clk_alpha_pll perfcl_alt_pll = { - .offset = 0x80100, + .offset = PERFCL_REG_OFFSET + ALT_PLL_OFFSET, .regs = alt_pll_regs, .vco_table = alt_pll_vco_modes, .num_vco = ARRAY_SIZE(alt_pll_vco_modes), @@ -163,7 +170,7 @@ enum _pmux_input { }; static struct clk_alpha_pll pwrcl_alt_pll = { - .offset = 0x100, + .offset = PWRCL_REG_OFFSET + ALT_PLL_OFFSET, .regs = alt_pll_regs, .vco_table = alt_pll_vco_modes, .num_vco = ARRAY_SIZE(alt_pll_vco_modes), @@ -176,6 +183,9 @@ enum _pmux_input { }, }; +void __iomem *base; +static void qcom_cpu_clk_msm8996_acd_init(void __iomem *base); + /* Mux'es */ struct clk_cpu_8996_mux { @@ -253,6 +263,7 @@ int cpu_clk_notifier_cb(struct notifier_block *nb, unsigned long event, switch (event) { case PRE_RATE_CHANGE: ret = clk_cpu_8996_mux_set_parent(&cpuclk->clkr.hw, ALT_INDEX); + qcom_cpu_clk_msm8996_acd_init(base); break; case POST_RATE_CHANGE: if (cnd->new_rate < DIV_2_THRESHOLD) @@ -260,7 +271,7 @@ int cpu_clk_notifier_cb(struct notifier_block *nb, unsigned long event, DIV_2_INDEX); else ret = clk_cpu_8996_mux_set_parent(&cpuclk->clkr.hw, - PLL_INDEX); + ACD_INDEX); break; default: ret = 0; @@ -276,7 +287,7 @@ int cpu_clk_notifier_cb(struct notifier_block *nb, unsigned long event, }; static struct clk_cpu_8996_mux pwrcl_smux = { - .reg = 0x40, + .reg = PWRCL_REG_OFFSET + MUX_OFFSET, .shift = 2, .width = 2, .clkr.hw.init = &(struct clk_init_data) { @@ -292,7 +303,7 @@ int cpu_clk_notifier_cb(struct notifier_block *nb, unsigned long event, }; static struct clk_cpu_8996_mux perfcl_smux = { - .reg = 0x80040, + .reg = PERFCL_REG_OFFSET + MUX_OFFSET, .shift = 2, .width = 2, .clkr.hw.init = &(struct clk_init_data) { @@ -308,7 +319,7 @@ int cpu_clk_notifier_cb(struct notifier_block *nb, unsigned long event, }; static struct clk_cpu_8996_mux pwrcl_pmux = { - .reg = 0x40, + .reg = PWRCL_REG_OFFSET + MUX_OFFSET, .shift = 0, .width = 2, .pll = &pwrcl_pll.clkr.hw, @@ -329,7 +340,7 @@ int cpu_clk_notifier_cb(struct notifier_block *nb, unsigned long event, }; static struct clk_cpu_8996_mux perfcl_pmux = { - .reg = 0x80040, + .reg = PERFCL_REG_OFFSET + MUX_OFFSET, .shift = 0, .width = 2, .pll = &perfcl_pll.clkr.hw, @@ -393,6 +404,10 @@ struct clk_regmap *clks[] = { clk_alpha_pll_configure(&perfcl_alt_pll, regmap, &altpll_config); clk_alpha_pll_configure(&pwrcl_alt_pll, regmap, &altpll_config); + /* Enable alt PLLs */ + clk_prepare_enable(pwrcl_alt_pll.clkr.hw.clk); + clk_prepare_enable(perfcl_alt_pll.clkr.hw.clk); + ret = clk_notifier_register(pwrcl_pmux.clkr.hw.clk, &pwrcl_pmux.nb); if (ret) return ret; @@ -402,10 +417,48 @@ struct clk_regmap *clks[] = { return ret; } +#define CPU_AFINITY_MASK 0xFFF +#define PWRCL_CPU_REG_MASK 0x3 +#define PERFCL_CPU_REG_MASK 0x103 + +#define L2ACDCR_REG 0x580ULL +#define L2ACDTD_REG 0x581ULL +#define L2ACDDVMRC_REG 0x584ULL +#define L2ACDSSCR_REG 0x589ULL + +static DEFINE_SPINLOCK(acd_lock); + +static void qcom_cpu_clk_msm8996_acd_init(void __iomem *base) +{ + u64 hwid; + unsigned long flags; + + spin_lock_irqsave(&acd_lock, flags); + + hwid = read_cpuid_mpidr() & CPU_AFINITY_MASK; + + kryo_l2_set_indirect_reg(L2ACDTD_REG, 0x00006A11); + kryo_l2_set_indirect_reg(L2ACDDVMRC_REG, 0x000E0F0F); + kryo_l2_set_indirect_reg(L2ACDSSCR_REG, 0x00000601); + + if (PWRCL_CPU_REG_MASK == (hwid | PWRCL_CPU_REG_MASK)) { + writel(0xF, base + PWRCL_REG_OFFSET + SSSCTL_OFFSET); + wmb(); + kryo_l2_set_indirect_reg(L2ACDCR_REG, 0x002C5FFD); + } + + if (PERFCL_CPU_REG_MASK == (hwid | PERFCL_CPU_REG_MASK)) { + kryo_l2_set_indirect_reg(L2ACDCR_REG, 0x002C5FFD); + writel(0xF, base + PERFCL_REG_OFFSET + SSSCTL_OFFSET); + wmb(); + } + + spin_unlock_irqrestore(&acd_lock, flags); +} + static int qcom_cpu_clk_msm8996_driver_probe(struct platform_device *pdev) { int ret; - void __iomem *base; struct resource *res; struct regmap *regmap; struct clk_hw_onecell_data *data; @@ -429,6 +482,8 @@ static int qcom_cpu_clk_msm8996_driver_probe(struct platform_device *pdev) if (ret) return ret; + qcom_cpu_clk_msm8996_acd_init(base); + data->hws[0] = &pwrcl_pmux.clkr.hw; data->hws[1] = &perfcl_pmux.clkr.hw; data->num = 2; -- 1.9.1