Received: by 10.213.65.68 with SMTP id h4csp1961106imn; Thu, 29 Mar 2018 14:32:16 -0700 (PDT) X-Google-Smtp-Source: AIpwx4+M1ErxJ1kqEAgxk/aPqVAt4zuszw7UNH6g/Xm4sz0LV9IrXOnhDaKNx9gEQtHU0Oj/S7ic X-Received: by 2002:a17:902:780d:: with SMTP id p13-v6mr10048296pll.281.1522359136612; Thu, 29 Mar 2018 14:32:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522359136; cv=none; d=google.com; s=arc-20160816; b=WGV7sxfGmpQqY4xNGb+v3RLqdzs8fpwgaPTBusGSpfrJyH9h5kYS+k/Nh87b4fUDdO Pqg1H7+f6wQQ7XmQ5Pcv+l4ecxCGtYu7t6mYrFuK/Cwpi4BS8UwR5fZRTJEyTOJ1I2+b rwh+V033+pa0qg9Kpj0pJIaGZg2M1u1v7fqCAzRxutunV27sKckhb/hzARyByChzAx6V 36CHHoCo8AZF0rtLQZsqucKzXPxXgK7Tr3IUy/QzgA2HOgHTWvTjOlL5fkpJS32r/G2n hHjTI1a4YIfBL8b4spW/meUXjbqaRbdWPeGm+O718fB+OdgZRmBta8SJo7X7FoCpeoTG J5rQ== 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=Wj2kJJkC6rdbkCRk4u940WlvtLRPSf6HkzqzK4bIDwU=; b=UzDCtHW/ZM1BftD0gVCD8o1WA9QrF71F6AQNezSJULH2tsTVk+6ad/oWwVXef5GuGF V98FGc/kYMmdHabthKhDaRPHfNluvuSvwoRZltGAcFncs1xKJ1koxmeOFskC/h5XLc0s jUAHninHfNDjupNgsx/ZWw5FEZnoau/dZ+fryz9qH6+gLRatBj0cEhhR4Wn2nzry0hER bdiw+zYasVZT8xDMR/dAdiA58r4XKW8Vrv9HJ4KZkEe/J1kXmQSpxrfeR2LHtkWJOXZZ WaQZWenB7bp5dPHkss3ek0K5l0yupI3HWkdcNPtdgaYOchmStuV/zxxW9uFMmnQ+7gSh ruOw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@codeaurora.org header.s=default header.b=AXwzvbSL; dkim=pass header.i=@codeaurora.org header.s=default header.b=U2feljM9; 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 h187si4637561pgc.294.2018.03.29.14.32.02; Thu, 29 Mar 2018 14:32:16 -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=AXwzvbSL; dkim=pass header.i=@codeaurora.org header.s=default header.b=U2feljM9; 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 S1752679AbeC2Va1 (ORCPT + 99 others); Thu, 29 Mar 2018 17:30:27 -0400 Received: from smtp.codeaurora.org ([198.145.29.96]:34424 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752514AbeC2V1o (ORCPT ); Thu, 29 Mar 2018 17:27:44 -0400 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id D777660C55; Thu, 29 Mar 2018 21:27:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1522358864; bh=YrLKLKvKLvhz7gS4MhIm6+k2oYGwuLpszdMk9jvqzbc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=AXwzvbSLV5OHOCOOMdFjBUNDCftbYwyQUNrunnLC0TOvuGh8de3kVn4OuYN8JC0zq 8m+eTgWg43FaLhE/HoHydiqhbmtn7Xy9hLBEWi7CSR6Qxxy31EtoJgFehx14OjnBB9 8nRvmzZGU9wzqB21W878DaLtWZATu9a77oYBjZJ8= 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 D2CED610D9; Thu, 29 Mar 2018 21:27:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1522358859; bh=YrLKLKvKLvhz7gS4MhIm6+k2oYGwuLpszdMk9jvqzbc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=U2feljM9Yx86pVMKQvDXOU7WXqwpFiGrg3DYsRqlIvwWkvucTALLoIrakb5Vw53b9 vxzjPqn1Jj+7ZuzVgCTE4Qn9/XbruIN8Q8NChej19SzzWgmgg6gdsTBM0OF4WSnm9U /6rCfXme1wXE8FmpomlGxoM56bsTUY+g8W+aM78Q= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org D2CED610D9 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, 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 Cc: rnayak@codeaurora.org, ilialin@codeaurora.org, amit.kucheria@linaro.org, nicolas.dechesne@linaro.org, celster@codeaurora.org, tfinkel@codeaurora.org Subject: [PATCH v4 07/14] clk: qcom: Add ACD path to CPU clock driver for msm8996 Date: Fri, 30 Mar 2018 00:26:40 +0300 Message-Id: <1522358807-10413-8-git-send-email-ilialin@codeaurora.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1522358807-10413-1-git-send-email-ilialin@codeaurora.org> References: <1522358807-10413-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 064a3fe..9a43bdf 100644 --- a/drivers/clk/qcom/clk-cpu-8996.c +++ b/drivers/clk/qcom/clk-cpu-8996.c @@ -63,9 +63,11 @@ */ #include +#include #include #include #include +#include #include "clk-alpha-pll.h" #include "clk-regmap.h" @@ -79,6 +81,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, @@ -117,7 +124,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){ @@ -129,7 +136,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){ @@ -159,7 +166,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), @@ -173,7 +180,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), @@ -186,6 +193,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 { @@ -263,6 +273,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) @@ -270,7 +281,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; @@ -286,7 +297,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) { @@ -302,7 +313,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) { @@ -318,7 +329,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, @@ -339,7 +350,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, @@ -403,6 +414,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; @@ -412,10 +427,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; + + set_l2_indirect_reg(L2ACDTD_REG, 0x00006A11); + set_l2_indirect_reg(L2ACDDVMRC_REG, 0x000E0F0F); + set_l2_indirect_reg(L2ACDSSCR_REG, 0x00000601); + + if (PWRCL_CPU_REG_MASK == (hwid | PWRCL_CPU_REG_MASK)) { + writel(0xF, base + PWRCL_REG_OFFSET + SSSCTL_OFFSET); + wmb(); + set_l2_indirect_reg(L2ACDCR_REG, 0x002C5FFD); + } + + if (PERFCL_CPU_REG_MASK == (hwid | PERFCL_CPU_REG_MASK)) { + set_l2_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; @@ -439,6 +492,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