clk: qcom: Add support to vote to genpd
Subsystems (5)
cover clk: qcom: Add support to vote to genpd
A clock controller could be connected to single or multiple power domains. Add support for powerdomain_class which would help associate these power domains to the RCGs and PLLs in the clock controller. Map the domain and the corresponding frequencies to the clock(RCG/PLL). The clock frequency request from a consumer would be mapped to the corresponding performance corner, aggregated at the clock driver and would be vote/unvoted to the genpd framework for the desired performance state.
This series add an example of power domain class for sdm845 RCG/PLLs and the corresponding frequency mappings. This depends on power domain drivers of SDM845 https://lkml.org/lkml/2018/6/27/7.
Taniya Das (4):
clk: qcom: Add support to request power domain state
clk: qcom: Initialize the power domain class for each clock
clk: qcom: Add prepare/unprepare clock ops for PLL/RCG
clk: qcom: sdm845: Add Power Domain to RCGs and PLL
arch/arm64/boot/dts/qcom/sdm845.dtsi | 2 + drivers/clk/qcom/Makefile | 1 + drivers/clk/qcom/clk-alpha-pll.c | 52 ++++++++-- drivers/clk/qcom/clk-pd.c | 193 +++++++++++++++++++++++++++++++++++ drivers/clk/qcom/clk-pd.h | 55 ++++++++++ drivers/clk/qcom/clk-rcg2.c | 61 +++++++++-- drivers/clk/qcom/clk-regmap.h | 5 + drivers/clk/qcom/common.c | 17 ++- drivers/clk/qcom/gcc-sdm845.c | 83 ++++++++++++--- 9 files changed, 427 insertions(+), 42 deletions(-) create mode 100644 drivers/clk/qcom/clk-pd.c create mode 100644 drivers/clk/qcom/clk-pd.h
--
Qualcomm INDIA, on behalf of Qualcomm Innovation Center, Inc.is a member of the Code Aurora Forum, hosted by the Linux Foundation.
RFC PATCH 1/4 clk: qcom: Add support to request power domain state
There could be single power domain or multiple power domains associated with a clock controller. Add powerdomain_class support which would help vote/unvote for any power domain performance state for a clock frequency to the genpd framework.
A clock frequency request from a consumer would look for the corresponding performance corner and thus would aggregate and request the desired performance state to genpd.
--- drivers/clk/qcom/Makefile | 1 + drivers/clk/qcom/clk-pd.c | 193 ++++++++++++++++++++++++++++++++++++++++++++++ drivers/clk/qcom/clk-pd.h | 55 +++++++++++++ 3 files changed, 249 insertions(+) create mode 100644 drivers/clk/qcom/clk-pd.c create mode 100644 drivers/clk/qcom/clk-pd.h
drivers/clk/qcom/Makefile +1 -0
@@ -12,6 +12,7 @@ clk-qcom-y += clk-regmap-divider.o clk-qcom-y += clk-regmap-mux.o clk-qcom-y += clk-regmap-mux-div.o clk-qcom-y += reset.o +clk-qcom-y += clk-pd.o clk-qcom-$(CONFIG_QCOM_GDSC) += gdsc.o # Keep alphabetically sorted by config
drivers/clk/qcom/clk-pd.c new file +193 -0
193 lines not on this page · raw message
drivers/clk/qcom/clk-pd.h new file +55 -0
55 lines not on this page · raw message
Signature · 2 lines
Qualcomm INDIA, on behalf of Qualcomm Innovation Center, Inc.is a member of the Code Aurora Forum, hosted by the Linux Foundation.
RFC PATCH 2/4 clk: qcom: Initialize the power domain class for each clock
In reply to Taniya DasThe power domain class is being initialized for clocks which has an associated power domains before registering the clocks with the clock framework.
--- drivers/clk/qcom/clk-regmap.h | 5 +++++ drivers/clk/qcom/common.c | 17 +++++++---------- 2 files changed, 12 insertions(+), 10 deletions(-)
drivers/clk/qcom/clk-regmap.h +5 -0
@@ -17,22 +17,27 @@#include <linux/clk-provider.h> struct regmap ; +struct clk_powerdomain_class ;/** * struct clk_regmap - regmap supporting clock * @hw: handle between common and hardware-specific interfaces * @regmap: regmap to use for regmap helpers and/or by providers +* @pd: power domain scaling requirement class * @enable_reg: register when using regmap enable/disable ops * @enable_mask: mask when using regmap enable/disable ops * @enable_is_inverted: flag to indicate set enable_mask bits to disable * when using clock_enable_regmap and friends APIs. +* @rate_max: maximum clock rate in Hz supported at each power domain. */ struct clk_regmap {struct clk_hw hw;struct regmap *regmap; +struct clk_powerdomain_class *pd;unsigned int enable_reg;unsigned int enable_mask;bool enable_is_inverted; +unsigned long *rate_max; };#define to_clk_regmap (_hw) container_of(_hw, struct clk_regmap, hw)
drivers/clk/qcom/common.c +7 -10
@@ -1,14 +1,6 @@ +// SPDX-License-Identifier: GPL-2.0 /* -* Copyright (c) 2013-2014, The Linux Foundation. All rights reserved. -* -* This software is licensed under the terms of the GNU General Public -* License version 2, as published by the Free Software Foundation, and -* may be copied, distributed, and modified under those terms. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. +* Copyright (c) 2013-2014, 2018, The Linux Foundation. All rights reserved. */ #include <linux/export.h>
@@ -20,6 +12,7 @@#include <linux/of.h> #include "common.h" +#include "clk-pd.h" #include "clk-rcg.h" #include "clk-regmap.h" #include "reset.h"
@@ -263,6 +256,10 @@ int qcom_cc_really_probe(struct platform_device *pdev,if (!rclks[i])continue ; + ret =clk_power_domain_class_init (dev, rclks[i]->pd); +if (ret) +return ret; + ret =devm_clk_register_regmap (dev, rclks[i]);if (ret)return ret;
Signature · 2 lines
Qualcomm INDIA, on behalf of Qualcomm Innovation Center, Inc.is a member of the Code Aurora Forum, hosted by the Linux Foundation.
RFC PATCH 3/4 clk: qcom: Add prepare/unprepare clock ops for PLL/RCG
In reply to Taniya DasTo put across power domain votes associated with a PLL or RCG, add the prepare/unprepare clock ops which would map the corresponding performance state corners for a clock frequency when the clk_prepare/clk_unprepare is being invoked.
Also update the set_rate clock ops to send across the performance state to genpd framework when a new frequency is being requested.
--- drivers/clk/qcom/clk-alpha-pll.c | 52 +++++++++++++++++++++++++++------- drivers/clk/qcom/clk-rcg2.c | 61 +++++++++++++++++++++++++++++++++++----- 2 files changed, 96 insertions(+), 17 deletions(-)
drivers/clk/qcom/clk-alpha-pll.c +42 -10
@@ -1,14 +1,6 @@ +// SPDX-License-Identifier: GPL-2.0 /* * Copyright (c) 2015, 2018, The Linux Foundation. All rights reserved. -* -* This software is licensed under the terms of the GNU General Public -* License version 2, as published by the Free Software Foundation, and -* may be copied, distributed, and modified under those terms. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. */ #include <linux/kernel.h>
@@ -18,6 +10,7 @@#include <linux/delay.h> #include "clk-alpha-pll.h" +#include "clk-pd.h" #include "common.h" #define PLL_MODE (p) ((p)->offset + 0x0)
@@ -522,7 +515,9 @@ static int __clk_alpha_pll_set_rate(struct clk_hw *hw, unsigned long rate,struct clk_alpha_pll *pll =to_clk_alpha_pll (hw);const struct pll_vco *vco;u32 l, alpha_width =pll_alpha_width (pll); +unsigned long old_rate =clk_hw_get_rate (hw);u64 a; +int ret; rate =alpha_pll_round_rate (rate, prate, &l, &a, alpha_width); vco =alpha_pll_find_vco (pll, rate);
@@ -531,6 +526,15 @@ static int __clk_alpha_pll_set_rate(struct clk_hw *hw, unsigned long rate,return -EINVAL ; } +if (clk_hw_is_prepared (hw)) { +/* Enforce power domain requirement for new frequency */ + ret =clk_power_domain_vote_rate (&pll->clkr, rate); +if (ret) { +pr_err ("Failed to vote/set new rate %lu\n" , rate); +return ret; + } + } +regmap_write (pll->clkr.regmap,PLL_L_VAL (pll), l);if (alpha_width >ALPHA_BITWIDTH )
@@ -550,7 +554,15 @@ static int __clk_alpha_pll_set_rate(struct clk_hw *hw, unsigned long rate,regmap_update_bits (pll->clkr.regmap,PLL_USER_CTL (pll),PLL_ALPHA_EN ,PLL_ALPHA_EN ); -return clk_alpha_pll_update_latch (pll, is_enabled); + ret =clk_alpha_pll_update_latch (pll, is_enabled); +if (ret) + old_rate = rate; + +if (clk_hw_is_prepared (hw)) +/* Release the power domain requirement for old frequency */ +clk_power_domain_unvote_rate (&pll->clkr, old_rate); + +return ret; } static int clk_alpha_pll_set_rate(struct clk_hw *hw, unsigned long rate,
@@ -1017,7 +1029,25 @@ static int alpha_pll_fabia_set_rate(struct clk_hw *hw, unsigned long rate,return __clk_alpha_pll_update_latch (pll); } +static int clk_alpha_pll_prepare (struct clk_hw *hw) +{ +struct clk_alpha_pll *pll =to_clk_alpha_pll (hw); +unsigned long rate =clk_hw_get_rate (hw); + +return clk_power_domain_vote_rate (&pll->clkr, rate); +} + +static void clk_alpha_pll_unprepare (struct clk_hw *hw) +{ +struct clk_alpha_pll *pll =to_clk_alpha_pll (hw); +unsigned long rate =clk_hw_get_rate (hw); + +clk_power_domain_unvote_rate (&pll->clkr, rate); +} +const struct clk_ops clk_alpha_pll_fabia_ops = { + .prepare = clk_alpha_pll_prepare, + .unprepare = clk_alpha_pll_unprepare, .enable = alpha_pll_fabia_enable, .disable = alpha_pll_fabia_disable, .is_enabled = clk_alpha_pll_is_enabled,
@@ -1028,6 +1058,8 @@ static int alpha_pll_fabia_set_rate(struct clk_hw *hw, unsigned long rate,EXPORT_SYMBOL_GPL (clk_alpha_pll_fabia_ops);const struct clk_ops clk_alpha_pll_fixed_fabia_ops = { + .prepare = clk_alpha_pll_prepare, + .unprepare = clk_alpha_pll_unprepare, .enable = alpha_pll_fabia_enable, .disable = alpha_pll_fabia_disable, .is_enabled = clk_alpha_pll_is_enabled,
drivers/clk/qcom/clk-rcg2.c +54 -7
107 lines not on this page · raw message
Signature · 2 lines
Qualcomm INDIA, on behalf of Qualcomm Innovation Center, Inc.is a member of the Code Aurora Forum, hosted by the Linux Foundation.
RFC PATCH 4/4 clk: qcom: sdm845: Add Power Domain to RCGs and PLL
In reply to Taniya DasTest code for GCC Power Domain Voting for root clocks/plls.
--- arch/arm64/boot/dts/qcom/sdm845.dtsi | 2 + drivers/clk/qcom/gcc-sdm845.c | 83 +++++++++++++++++++++++++++++------- drivers/clk/qcom/vdd-level.h | 31 ++++++++++++++ 3 files changed, 101 insertions(+), 15 deletions(-) create mode 100644 drivers/clk/qcom/vdd-level.h
arch/arm64/boot/dts/qcom/sdm845.dtsi +2 -0
@@ -247,6 +247,8 @@ #clock-cells = <1>; #reset-cells = <1>; #power-domain-cells = <1>; + power-domains = <&rpmhpd SDM845_CX>, + <&rpmhpd SDM845_CX_AO>; }; qupv3_id_0: geniqup@8c0000 {
drivers/clk/qcom/gcc-sdm845.c +68 -15
131 lines not on this page · raw message
drivers/clk/qcom/vdd-level.h new file +31 -0
@@ -0,0 +1,31 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* Copyright (c) 2018, The Linux Foundation. All rights reserved. */ + +#ifndef __DRIVERS_CLK_QCOM_VDD_LEVEL_H +#define __DRIVERS_CLK_QCOM_VDD_LEVEL_H + +#include <dt-bindings/power/qcom-rpmpd.h> + +enum vdd_levels { +VDD_NONE , +VDD_MIN ,/* MIN SVS */ +VDD_LOWER ,/* SVS2 */ +VDD_LOW ,/* SVS */ +VDD_LOW_L1 ,/* SVSL1 */ +VDD_NOMINAL ,/* NOM */ +VDD_HIGH ,/* TURBO */ +VDD_NUM , +}; + +static int vdd_corner[] = { +RPMH_REGULATOR_LEVEL_RETENTION ,/* VDD_NONE */ +RPMH_REGULATOR_LEVEL_MIN_SVS ,/* VDD_MIN */ +RPMH_REGULATOR_LEVEL_LOW_SVS ,/* VDD_LOWER */ +RPMH_REGULATOR_LEVEL_SVS ,/* VDD_LOW */ +RPMH_REGULATOR_LEVEL_SVS_L1 ,/* VDD_LOW_L1 */ +RPMH_REGULATOR_LEVEL_NOM ,/* VDD_NOMINAL */ +RPMH_REGULATOR_LEVEL_TURBO ,/* VDD_HIGH */ +}; + +#endif +
--
Qualcomm INDIA, on behalf of Qualcomm Innovation Center, Inc.is a member of the Code Aurora Forum, hosted by the Linux Foundation.