Misc patches to support clocks for SDM845
v6 cover Misc patches to support clocks for SDM845
Changes in v6:
1. Adressed review comments for v3 and v4 version of GCC driver for SDM845.
https://lkml.org/lkml/2018/4/16/1129.
2. Add support for new flag 'BRANCH_NO_DELAY' for branch clocks.
3. Addressed review comments for v5 version of rcg2_shared_ops patch.
https://lkml.org/lkml/2018/4/19/86
4. The GCC clock driver(patch 3) depends upon the below patches related to GDSC operation and RPMh clock driver, which are under review.
https://lkml.org/lkml/2018/4/27/110
https://lkml.org/lkml/2018/4/24/390
Changes in v5:
1. Adressed review comments for v3 and v4 version of GCC driver for SDM845
https://lkml.org/lkml/2018/4/16/1129
2. Removed bi_tcxo clock being modelled from the GCC driver, as RPMH clock driver would provide the same. https://lkml.org/lkml/2018/4/13/685
3. The GCC clock driver(patch 2) depends upon the below patches related to GDSC operation and RPMh clock driver, which are under review.
https://lkml.org/lkml/2018/4/2/143
https://lkml.org/lkml/2018/4/13/685
Changes in v4:
1. Adressed review comments for v2 version of GCC driver for SDM845
https://lkml.org/lkml/2018/4/9/55.
2. The GCC clock driver(patch 3) depends upon the below patches related to GDSC operation and are under review.
https://lkml.org/lkml/2018/4/2/142
Changes in v3:
1. Adressed review comments given for v2 series.
2. The GCC clock driver(patch 3) depends upon the below patches related to GDSC operation and are under review.
https://lkml.org/lkml/2018/4/2/142
Changes in v2:
Fixup for recalc_rate ops for clk_rcg2_shared_ops:
There could be few scenarios where shared clocks are configured at rate other than CXO by boot. In those cases there would be a mismatch between the rate calculated by the recalc shared ops and the actual HW register configuration. Fix the same by adding an additional check to read current src from CFG register and make a decision based on that.
Changes in v1:
https://lkml.org/lkml/2018/1/31/209
This patch series does the miscellaneous changes to support clock nodes for SDM845. Below are the major changes for which the existing code does not have support.
1. Clear hardware clock control bit of RCGs where HW clock control bit is set by default so that software can control those root clocks.
2. Introduces clk_rcg2_shared_ops to support clock controller drivers for SDM845. With new shared ops, RCGs with shared branches will be configured to a safe source in disable path and actual RCG update configuration will be done in enable path instead of doing config update in set_rate. In set_rate(), just cache the rate instead of doing actual configuration update. Also each RCG in clock controller driver will have their own safe configuration frequency table to switch to safe frequency.
3. Add support for controlling Fabia PLL for which the support is not available in existing alpha PLL code.
4. Add Global Clock controller (GCC) driver for SDM845. This should allow most non-multimedia device drivers to probe and control their clocks.
[v1] : https://lkml.org/lkml/2018/1/31/209
[v2] : https://lkml.org/lkml/2018/3/8/495
[v3] : https://www.spinics.net/lists/linux-arm-msm/msg35009.html
[v4] : https://lkml.org/lkml/2018/4/9/79
[v5] : https://lkml.org/lkml/2018/4/18/367
Amit Nischal (2):
clk: qcom: Configure the RCGs to a safe source as needed
clk: qcom: Add support for BRANCH_NO_DELAY flag for branch clocks
Taniya Das (1):
clk: qcom: Add Global Clock controller (GCC) driver for SDM845
.../devicetree/bindings/clock/qcom,gcc.txt | 1 + drivers/clk/qcom/Kconfig | 10 +- drivers/clk/qcom/Makefile | 1 + drivers/clk/qcom/clk-branch.c | 7 +- drivers/clk/qcom/clk-branch.h | 1 + drivers/clk/qcom/clk-rcg.h | 7 +- drivers/clk/qcom/clk-rcg2.c | 207 +- drivers/clk/qcom/gcc-sdm845.c | 3480 ++++++++++++++++++++ include/dt-bindings/clock/qcom,gcc-sdm845.h | 239 ++ 9 files changed, 3940 insertions(+), 13 deletions(-) create mode 100644 drivers/clk/qcom/gcc-sdm845.c create mode 100644 include/dt-bindings/clock/qcom,gcc-sdm845.h
--
QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by The Linux Foundation
PATCH v6 1/3 clk: qcom: Configure the RCGs to a safe source as needed
For some root clock generators, there could be child branches which are controlled by an entity other than application processor subsystem. For such RCGs, as per application processor subsystem clock driver, all of its downstream clocks are disabled and RCG is in disabled state but in reality downstream clocks can be left enabled before.
So in this scenario, when RCG is disabled as per clock driver's point of view and when rate scaling request comes before downstream clock enable request, then RCG fails to update its configuration because in reality RCG is on and it expects its new source to already be in enable state but in reality new source is off. In order to avoid having the RCG to go into an invalid state, add support to update the CFG, M, N and D registers during set_rate() without configuration update and defer the actual RCG configuration update to be done during clk_enable() as at this point of time, both its new parent and safe source will be already enabled and RCG can safely switch to new parent.
During clk_disable() request, configure it to safe source as both its parents, safe source and current parent will be enabled and RCG can safely execute a switch.
--- drivers/clk/qcom/clk-rcg.h | 7 +- drivers/clk/qcom/clk-rcg2.c | 207 ++++++++++++++++++++++++++++++++++++++++++-- 2 files changed, 207 insertions(+), 7 deletions(-)
drivers/clk/qcom/clk-rcg.h +6 -1
@@ -1,5 +1,5 @@/* -* Copyright (c) 2013, The Linux Foundation. All rights reserved. +* Copyright (c) 2013, 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
@@ -144,8 +144,10 @@ struct clk_dyn_rcg {* @cmd_rcgr: corresponds to *_CMD_RCGR * @mnd_width: number of bits in m/n/d values * @hid_width: number of bits in half integer divider +* @safe_src_index: safe src index value * @parent_map: map from software's parent index to hardware's src_sel field * @freq_tbl: frequency table +* @current_freq_tbl: Stores current frequency freq_tbl when using shared RCGs * @clkr: regmap clock handle * */
@@ -153,8 +155,10 @@ struct clk_rcg2 {u32 cmd_rcgr;u8 mnd_width;u8 hid_width; +u8 safe_src_index;const struct parent_map *parent_map;const struct freq_tbl *freq_tbl; +const struct freq_tbl *current_freq_tbl;struct clk_regmap clkr; };
@@ -167,5 +171,6 @@ struct clk_rcg2 {extern const struct clk_ops clk_byte2_ops;extern const struct clk_ops clk_pixel_ops;extern const struct clk_ops clk_gfx3d_ops; +extern const struct clk_ops clk_rcg2_shared_ops;#endif
drivers/clk/qcom/clk-rcg2.c +201 -6
252 lines not on this page · raw message
--
QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by The Linux Foundation
Stephen Boyd
maintainerRe: [PATCH v6 1/3] clk: qcom: Configure the RCGs to a safe source as needed
Quoting Amit Nischal (2018-04-30 09:20:08)
drivers/clk/qcom/clk-rcg.h line 2
Quoted 8 lines
drivers/clk/qcom/clk-rcg.h +1
-1@@ -1,5 +1,5 @@/* -* Copyright (c) 2013, The Linux Foundation. All rights reserved. +* Copyright (c) 2013, 2018, The Linux Foundation. All rights reserved.
Given that you're updating this, can you move this to SPDX as well? If that causes some sort of delay, it's OK to defer, but please send a patch to do it sometime soon after this series.
Quoted 8 lines
drivers/clk/qcom/clk-rcg.h +0
-0* * This software is licensed under the terms of the GNU General Public * License version 2, as published by the Free Software Foundation, and drivers/clk/qcom/clk-rcg2.c +0
-0
drivers/clk/qcom/clk-rcg2.c static int clk_rcg2_determine_floor_rate(struct clk_hw *hw, · line 253
Quoted 6 lines
drivers/clk/qcom/clk-rcg2.c +2
-1@@ -249,7 +249,8 @@ static int clk_rcg2_determine_floor_rate(struct clk_hw *hw,return _freq_tbl_determine_rate (hw, rcg->freq_tbl, req,FLOOR ); } -static int clk_rcg2_configure (struct clk_rcg2 *rcg,const struct freq_tbl *f) +static int clk_rcg2_configure (struct clk_rcg2 *rcg,const struct freq_tbl *f, +bool update_rcg_config)
Please leave clk_rcg2_configure() signature alone. Don't add a flag to say "hit the update". Instead, make a __clk_rcg2_configure() that doesn't hit the update bit, but does everything else and then have clk_rcg2_configure() call that function and also hit the update bit.
drivers/clk/qcom/clk-rcg2.c static int clk_rcg2_configure(struct clk_rcg2 *rcg, const struct freq_tbl *f) · line 293
Quoted 10 lines
drivers/clk/qcom/clk-rcg2.c +3
-0{u32 cfg, mask;struct clk_hw *hw = &rcg->clkr.hw;@@ -287,6 +288,9 @@ static int clk_rcg2_configure(struct clk_rcg2 *rcg, const struct freq_tbl *f)if (ret)return ret; +if (!update_rcg_config) +return 0 ; +
Then this logic doesn't have to exist.
Quoted 40 lines
drivers/clk/qcom/clk-rcg2.c +4
-4return update_config (rcg); }@@ -310,7 +314,7 @@ static int __clk_rcg2_set_rate(struct clk_hw *hw, unsigned long rate,if (!f)return -EINVAL ; -return clk_rcg2_configure (rcg, f); +return clk_rcg2_configure (rcg, f, true); } static int clk_rcg2_set_rate(struct clk_hw *hw, unsigned long rate,@@ -419,7 +423,7 @@ static int clk_edp_pixel_set_rate(struct clk_hw *hw, unsigned long rate, f.m = frac->num; f.n = frac->den; -return clk_rcg2_configure (rcg, &f); +return clk_rcg2_configure (rcg, &f, true); }return -EINVAL ;@@ -523,7 +527,7 @@ static int clk_byte_set_rate(struct clk_hw *hw, unsigned long rate, f.pre_div = div; -return clk_rcg2_configure (rcg, &f); +return clk_rcg2_configure (rcg, &f, true); } static int clk_byte_set_rate_and_parent(struct clk_hw *hw,@@ -589,7 +593,7 @@ static int clk_byte2_set_rate(struct clk_hw *hw, unsigned long rate,for (i =0 ; i < num_parents; i++) {if (cfg == rcg->parent_map[i].cfg) { f.src = rcg->parent_map[i].src; -return clk_rcg2_configure (rcg, &f); +return clk_rcg2_configure (rcg, &f, true); } }
drivers/clk/qcom/clk-rcg2.c static int clk_pixel_set_rate(struct clk_hw *hw, unsigned long rate, · line 692
Quoted 8 lines
drivers/clk/qcom/clk-rcg2.c +1
-1@@ -682,7 +686,7 @@ static int clk_pixel_set_rate(struct clk_hw *hw, unsigned long rate, f.m = frac->num; f.n = frac->den; -return clk_rcg2_configure (rcg, &f); +return clk_rcg2_configure (rcg, &f, true); }return -EINVAL ; }
And all those hunks don't happen. Yay!
Quoted 27 lines
drivers/clk/qcom/clk-rcg2.c +26
-0@@ -790,3 +794,194 @@ static int clk_gfx3d_set_rate(struct clk_hw *hw, unsigned long rate, + +static int +clk_rcg2_shared_force_enable_clear (struct clk_hw *hw,const struct freq_tbl *f) +{ +struct clk_rcg2 *rcg =to_clk_rcg2 (hw); +int ret; + +if (!f) +return -EINVAL ; + + ret =clk_rcg2_set_force_enable (hw); +if (ret) +return ret; + + ret =clk_rcg2_configure (rcg, f, true); +if (ret) +return ret; + +return clk_rcg2_clear_force_enable (hw); +} + +static int clk_rcg2_shared_set_rate (struct clk_hw *hw,unsigned long rate, +unsigned long parent_rate) +{ +struct clk_rcg2 *rcg =to_clk_rcg2 (hw); +const struct freq_tbl *f;
drivers/clk/qcom/clk-rcg2.c static int clk_gfx3d_set_rate(struct clk_hw *hw, unsigned long rate, · line 829
Quoted 10 lines
drivers/clk/qcom/clk-rcg2.c +10
-0+ + f =qcom_find_freq (rcg->freq_tbl, rate); +if (!f) +return -EINVAL ; + +/* +* Store freq_tbl corresponding to requested rate in case disable() op +* clears the cached registers - disable() gets call after set_rate(). +*/ + rcg->current_freq_tbl = f;
Shouldn't be needed.
Quoted 15 lines
drivers/clk/qcom/clk-rcg2.c +15
-0+ +/* +* In case clock is disabled, update the CFG, M, N and D registers +* and do not hit the update bit of CMD register. +*/ +if (!__clk_is_enabled (hw->clk)) +/* Skip the configuration update */ +return clk_rcg2_configure (rcg, rcg->current_freq_tbl, false); + +return clk_rcg2_shared_force_enable_clear (hw, rcg->current_freq_tbl); +} + +static int clk_rcg2_shared_set_rate_and_parent (struct clk_hw *hw, +unsigned long rate,unsigned long parent_rate,u8 index) +{
drivers/clk/qcom/clk-rcg2.c static int clk_gfx3d_set_rate(struct clk_hw *hw, unsigned long rate, · line 892
Quoted 10 lines
drivers/clk/qcom/clk-rcg2.c +10
-0+return clk_rcg2_shared_set_rate (hw, rate, parent_rate); +} + +static unsigned long +clk_rcg2_shared_recalc_rate (struct clk_hw *hw,unsigned long parent_rate) +{ +struct clk_rcg2 *rcg =to_clk_rcg2 (hw); + +if (!__clk_is_enabled (hw->clk) && rcg->current_freq_tbl) +return rcg->current_freq_tbl->freq;
Why can't we read the hardware? The M, N, D registers should always have the latest configuration of the frequency when recalc is called regardless of the on/off state.
Quoted 55 lines
drivers/clk/qcom/clk-rcg2.c +55
-0+ +return clk_rcg2_recalc_rate (hw, parent_rate); +} + +static int clk_rcg2_shared_enable (struct clk_hw *hw) +{ +struct clk_rcg2 *rcg =to_clk_rcg2 (hw); +struct freq_tbl safe_src_tbl = {0 }; +int ret; +u32 cfg_src; + +regmap_read (rcg->clkr.regmap, rcg->cmd_rcgr +CFG_REG , &cfg_src); + + cfg_src = cfg_src &CFG_SRC_SEL_MASK ; + cfg_src >>=CFG_SRC_SEL_SHIFT ; + +if (!rcg->current_freq_tbl) { +/* +* In the case where clk_enable() would be called +* without a clk_set_rate(), check for RCG configuration +* if done previously. +*/ + +if (cfg_src) +return 0 ; + +/* +* Configure RCG to safe_src, if following conditions +* holds true: +* - Bootloader configures the RCG to run from safe_src. +* - RCG's frequency table does not hold entry for +* safe_src speed. +*/ + safe_src_tbl.src = rcg->safe_src_index; +return clk_rcg2_shared_force_enable_clear (hw, &safe_src_tbl); + } + +/* +* Switch from safe source to the stashed mux selection. The current +* parent has already been prepared and enabled at this point, and +* the safe source is always on while application processor subsystem +* is online. Therefore, the RCG can safely switch its source. +*/ + +if (!cfg_src) +/* +* Reconfigure the RCG if cached registers are overwritten +* by clk_disable() after clk_set_rate(). +*/ +return clk_rcg2_shared_force_enable_clear (hw, + rcg->current_freq_tbl); + +/* +* Set the update bit only as other required configuration has been +* already done inside set_rate().
drivers/clk/qcom/clk-rcg2.c static int clk_gfx3d_set_rate(struct clk_hw *hw, unsigned long rate, · line 957
Quoted 10 lines
drivers/clk/qcom/clk-rcg2.c +10
-0+*/ + ret =clk_rcg2_set_force_enable (hw); +if (ret) +return ret; + + ret =update_config (rcg); +if (ret) +return ret; + +return clk_rcg2_clear_force_enable (hw);
This whole function seems overly complicated. Please see my comment below.
Quoted 7 lines
drivers/clk/qcom/clk-rcg2.c +7
-0+} + +static void clk_rcg2_shared_disable (struct clk_hw *hw) +{ +struct clk_rcg2 *rcg =to_clk_rcg2 (hw); +struct freq_tbl safe_src_tbl = {0 }; +
drivers/clk/qcom/clk-rcg2.c static int clk_gfx3d_set_rate(struct clk_hw *hw, unsigned long rate, · line 974
Quoted 10 lines
drivers/clk/qcom/clk-rcg2.c +10
-0+/* +* Park the RCG at a safe configuration - sourced off from safe source. +* Force enable and disable the RCG while configuring it to safeguard +* against any update signal coming from the downstream clock. +* The current parent is still prepared and enabled at this point, and +* the safe source is always on while application processor subsystem +* is online. Therefore, the RCG can safely switch its parent. +*/ + safe_src_tbl.src = rcg->safe_src_index; +clk_rcg2_shared_force_enable_clear (hw, &safe_src_tbl);
This should then re-dirty the config register to have the software frequency settings that existed in the hardware when disable was called. Given that MND shouldn't be changed here, this should be as simple as saving away the CFG register, forcing it to XO speed by changing the src and disabling dual edge in the CFG register (please don't call force_enable_clear with some frequency pointer, just do this inline here), and then rewriting the cfg register with the "real" settings for whatever frequency it's supposed to run at and then returning from this function.
I guess we have to do a read cfg from hardware, write cfg, hit update config, and then write cfg again each time we disable. For enable, we just do an update config (if it's dirty?) inside of a force enable/disable pair. And set_rate doesn't really change except it either does or doesn't hit the update config bit if the clk is enabled or disabled respectively.
Re: [PATCH v6 1/3] clk: qcom: Configure the RCGs to a safe source as needed
Quoted 15 lines · Stephen Boyd
Quoting Amit Nischal (2018-04-30 09:20:08)
Quoted 9 lines
drivers/clk/qcom/clk-rcg.h +1
-1@@ -1,5 +1,5 @@/* -* Copyright (c) 2013, The Linux Foundation. All rights reserved. +* Copyright (c) 2013, 2018, The Linux Foundation. All rights reserved.
Given that you're updating this, can you move this to SPDX as well? If that causes some sort of delay, it's OK to defer, but please send a patch to do it sometime soon after this series.
ok sure, I will update the same to SPDX as suggested in the next patch series.
Quoted 15 lines
Quoted 15 lines
*
* This software is licensed under the terms of the GNU General
Public
* License version 2, as published by the Free Software Foundation,
anddrivers/clk/qcom/clk-rcg2.c +0
-0@@ -249,7 +249,8 @@ static int clk_rcg2_determine_floor_rate(structclk_hw *hw, return _freq_tbl_determine_rate(hw, rcg->freq_tbl, req,FLOOR ); }
Quoted 11 lines
Quoted 5 lines
drivers/clk/qcom/clk-rcg2.c +1
-1-static int clk_rcg2_configure (struct clk_rcg2 *rcg,const struct freq_tbl *f) +static int clk_rcg2_configure(struct clk_rcg2 *rcg, const struct
freq_tbl*f,
+ boolupdate_rcg_config)Please leave
clk_rcg2_configure()signature alone. Don't add a flag to say "hit the update". Instead, make a__clk_rcg2_configure()that doesn't hit the update bit, but does everything else and then haveclk_rcg2_configure()call that function and also hit the update bit.
Thanks for the suggestion. Will take care of the same in the next patch series.
Quoted 8 lines
Quoted 8 lines
{ u32 cfg, mask; struct clk_hw *hw = &rcg->clkr.hw;drivers/clk/qcom/clk-rcg2.c +0
-0@@ -287,6 +288,9 @@ static int clk_rcg2_configure(struct clk_rcg2 *rcg, const struct freq_tbl *f)if (ret)return ret;
Quoted 5 lines
drivers/clk/qcom/clk-rcg2.c static int clk_rcg2_configure(struct clk_rcg2 *rcg, const struct freq_tbl *f) · line 293
Quoted 3 lines
drivers/clk/qcom/clk-rcg2.c +3
-0+if (!update_rcg_config) +return 0 ; +Then this logic doesn't have to exist.
Yes true. Above logic is not required anymore.
Quoted 93 lines
Quoted 53 lines
drivers/clk/qcom/clk-rcg2.c +1
-1return update_config (rcg); }@@ -310,7 +314,7 @@ static int __clk_rcg2_set_rate(struct clk_hw *hw, unsigned long rate, if (!f) return -EINVAL; -return clk_rcg2_configure (rcg, f); +return clk_rcg2_configure (rcg, f, true); }static int clk_rcg2_set_rate(struct
clk_hw*hw, unsigned long rate,drivers/clk/qcom/clk-rcg2.c +1
-1@@ -419,7 +423,7 @@ static int clk_edp_pixel_set_rate(struct clk_hw *hw, unsigned long rate, f.m = frac->num; f.n = frac->den; -return clk_rcg2_configure (rcg, &f); +return clk_rcg2_configure (rcg, &f, true); }return -EINVAL;drivers/clk/qcom/clk-rcg2.c +1
-1@@ -523,7 +527,7 @@ static int clk_byte_set_rate(struct clk_hw *hw,unsigned long rate, f.pre_div = div; -return clk_rcg2_configure (rcg, &f); +return clk_rcg2_configure (rcg, &f, true); }static int clk_byte_set_rate_and_parent(struct
clk_hw*hw,drivers/clk/qcom/clk-rcg2.c +2
-2@@ -589,7 +593,7 @@ static int clk_byte2_set_rate(struct clk_hw *hw,unsigned long rate, for (i = 0; i < num_parents; i++) {if (cfg == rcg->parent_map[i].cfg) { f.src = rcg->parent_map[i].src; -return clk_rcg2_configure (rcg, &f); +return clk_rcg2_configure (rcg, &f, true); } }@@ -682,7 +686,7 @@ static int clk_pixel_set_rate(struct clk_hw *hw,unsigned long rate, f.m = frac->num; f.n = frac->den; -return clk_rcg2_configure (rcg, &f); +return clk_rcg2_configure (rcg, &f, true); }return -EINVAL ;Quoted 1 line
}
And all those hunks don't happen. Yay!
Quoted 36 lines
drivers/clk/qcom/clk-rcg2.c +32
-0@@ -790,3 +794,194 @@ static int clk_gfx3d_set_rate(struct clk_hw *hw,unsigned long rate, + +static int +clk_rcg2_shared_force_enable_clear(struct clk_hw *hw, const struct freq_tbl *f) +{ + struct clk_rcg2 *rcg = to_clk_rcg2(hw); +int ret; + +if (!f) +return -EINVAL ; + + ret =clk_rcg2_set_force_enable (hw); +if (ret) +return ret; + + ret =clk_rcg2_configure (rcg, f, true); +if (ret) +return ret; + +return clk_rcg2_clear_force_enable (hw); +} + +static int clk_rcg2_shared_set_rate (struct clk_hw *hw,unsigned long rate, +unsigned long parent_rate) +{ +struct clk_rcg2 *rcg =to_clk_rcg2 (hw); +const struct freq_tbl *f; + + f =qcom_find_freq (rcg->freq_tbl, rate); +if (!f) +return -EINVAL ; + +/*
Quoted 9 lines
drivers/clk/qcom/clk-rcg2.c static int clk_gfx3d_set_rate(struct clk_hw *hw, unsigned long rate, · line 867
Quoted 6 lines
drivers/clk/qcom/clk-rcg2.c +1
-0+* Store freq_tbl corresponding to requested rate in case
disable()op
+ * clears the cached registers -disable()gets call afterset_rate().drivers/clk/qcom/clk-rcg2.c +2
-0+*/ + rcg->current_freq_tbl = f;Shouldn't be needed.
Yes with new implementation it is not required to store freq_tbl. Please have a look at my last comment where I have explained the new logic.
Quoted 26 lines
Quoted 26 lines
drivers/clk/qcom/clk-rcg2.c +3
-0+ +/* +* In case clock is disabled, update the CFG, M, N and D registers
drivers/clk/qcom/clk-rcg2.c +5
-0+* and do not hit the update bit of CMD register. +*/ +if (!__clk_is_enabled (hw->clk)) +/* Skip the configuration update */ + return clk_rcg2_configure(rcg, rcg->current_freq_tbl,false);
drivers/clk/qcom/clk-rcg2.c +2
-0+ + return clk_rcg2_shared_force_enable_clear(hw,
rcg->current_freq_tbl);drivers/clk/qcom/clk-rcg2.c +4
-0+} + +static int clk_rcg2_shared_set_rate_and_parent (struct clk_hw *hw, + unsigned long rate, unsigned long parent_rate, u8index)
drivers/clk/qcom/clk-rcg2.c +6
-0+{ +return clk_rcg2_shared_set_rate (hw, rate, parent_rate); +} + +static unsigned long +clk_rcg2_shared_recalc_rate(struct clk_hw *hw, unsigned long
parent_rate)
+{
Quoted 9 lines
drivers/clk/qcom/clk-rcg2.c static int clk_gfx3d_set_rate(struct clk_hw *hw, unsigned long rate, · line 892
Quoted 4 lines
drivers/clk/qcom/clk-rcg2.c +4
-0+struct clk_rcg2 *rcg =to_clk_rcg2 (hw); + +if (!__clk_is_enabled (hw->clk) && rcg->current_freq_tbl) +return rcg->current_freq_tbl->freq;Why can't we read the hardware? The M, N, D registers should always have the latest configuration of the frequency when recalc is called regardless of the on/off state.
With new implementation, it is not required to make a decision based on the clk on/off status. Please have a look at my last comment.
Quoted 111 lines
Quoted 65 lines
drivers/clk/qcom/clk-rcg2.c +12
-0+ +return clk_rcg2_recalc_rate (hw, parent_rate); +} + +static int clk_rcg2_shared_enable (struct clk_hw *hw) +{ +struct clk_rcg2 *rcg =to_clk_rcg2 (hw); +struct freq_tbl safe_src_tbl = {0 }; +int ret; +u32 cfg_src; + + regmap_read(rcg->clkr.regmap, rcg->cmd_rcgr + CFG_REG,
&cfg_src);drivers/clk/qcom/clk-rcg2.c +8
-0+ + cfg_src = cfg_src &CFG_SRC_SEL_MASK ; + cfg_src >>=CFG_SRC_SEL_SHIFT ; + +if (!rcg->current_freq_tbl) { +/* +* In the case where clk_enable() would be called +* without a clk_set_rate(), check for RCG configuration
drivers/clk/qcom/clk-rcg2.c +10
-0+* if done previously. +*/ + +if (cfg_src) +return 0 ; + +/* +* Configure RCG to safe_src, if following conditions +* holds true: +* - Bootloader configures the RCG to run from
safe_src.drivers/clk/qcom/clk-rcg2.c +5
-0+* - RCG's frequency table does not hold entry for +* safe_src speed. +*/ + safe_src_tbl.src = rcg->safe_src_index; + return clk_rcg2_shared_force_enable_clear(hw,
&safe_src_tbl);drivers/clk/qcom/clk-rcg2.c +4
-0+ } + +/* +* Switch from safe source to the stashed mux selection. The current
+ * parent has already been prepared and enabled at this point,
and
+ * the safe source is always on while application processor
subsystemdrivers/clk/qcom/clk-rcg2.c +6
-0+* is online. Therefore, the RCG can safely switch its source. +*/ + +if (!cfg_src) +/* +* Reconfigure the RCG if cached registers are overwritten
drivers/clk/qcom/clk-rcg2.c +4
-0+* by clk_disable() after clk_set_rate(). +*/ + return clk_rcg2_shared_force_enable_clear(hw, +
rcg->current_freq_tbl);drivers/clk/qcom/clk-rcg2.c +3
-0+ +/* +* Set the update bit only as other required configuration has been
drivers/clk/qcom/clk-rcg2.c +1
-0+* already done inside set_rate(). drivers/clk/qcom/clk-rcg2.c static int clk_gfx3d_set_rate(struct clk_hw *hw, unsigned long rate, · line 957
Quoted 10 lines
drivers/clk/qcom/clk-rcg2.c +10
-0+*/ + ret =clk_rcg2_set_force_enable (hw); +if (ret) +return ret; + + ret =update_config (rcg); +if (ret) +return ret; + +return clk_rcg2_clear_force_enable (hw);This whole function seems overly complicated. Please see my comment below.
Quoted 17 lines
drivers/clk/qcom/clk-rcg2.c +9
-0+} + +static void clk_rcg2_shared_disable (struct clk_hw *hw) +{ +struct clk_rcg2 *rcg =to_clk_rcg2 (hw); +struct freq_tbl safe_src_tbl = {0 }; + +/* +* Park the RCG at a safe configuration - sourced off from safe source.
+ * Force enable and disable the RCG while configuring it to
safeguarddrivers/clk/qcom/clk-rcg2.c +2
-0+* against any update signal coming from the downstream clock. +* The current parent is still prepared and enabled at this point, and
+ * the safe source is always on while application processor
subsystemdrivers/clk/qcom/clk-rcg2.c static int clk_gfx3d_set_rate(struct clk_hw *hw, unsigned long rate, · line 974
Quoted 4 lines
drivers/clk/qcom/clk-rcg2.c +4
-0+* is online. Therefore, the RCG can safely switch its parent. +*/ + safe_src_tbl.src = rcg->safe_src_index; +clk_rcg2_shared_force_enable_clear (hw, &safe_src_tbl);This should then re-dirty the config register to have the software frequency settings that existed in the hardware when disable was called. Given that MND shouldn't be changed here, this should be as simple as saving away the CFG register, forcing it to XO speed by changing the src and disabling dual edge in the CFG register (please don't call
force_enable_clearwith some frequency pointer, just do this inline here), and then rewriting the cfg register with the "real" settings for whatever frequency it's supposed to run at and then returning from this function.
Quoted 7 lines
I guess we have to do a read cfg from hardware, write cfg, hit update config, and then write cfg again each time we disable. For enable, we just do an update config (if it's dirty?) inside of a force enable/disable pair. And
set_ratedoesn't really change except it either does or doesn't hit the update config bit if the clk is enabled or disabled respectively.
We have done the below changes suggested by you and that logic seems to be working fine. But we have one concern about leaving the RCG registers in dirty state and would like to have a little bit modification as explained below:
Suggested Logic:
1. set_rate()--> Update CFG, M, N and D registers and don't hit the update bit if clock is disabled - call new__clk_rcg2_configure().
Above will make the CFG register as dirty.
2. _disable()--> 2.1 - Store the CFG register configuration in a variable. 2.2 - Move to the safe source (XO) and hit the update
bit.
It will only touch the CFG register and M, N, D register values will remain as it was.
2.3 - Write back the stored CFG value done in step #2.1
This will again redirty the CFG register.
3. _enable()--> Just hit the update bit as the configuration write will be taken care in the steps #1 and #2.
It would be great if we don't redirty the CFG register and leave the RCG CFG register to at safe source(XO) in disable() path.
This would help us to debug the issues where device crashes and we want to dump the RCG registers to know whether from software, we have actually moved to safe source or not. Otherwise, we would get the dirty register values in crash dumps.
So instead of writing back the stored CFG(corresponding to real rate settings) in disable path, we want to restore the stored CFG in enable path and then hit the update bit.
CFG configuration store can happen at two places - set_rate() and disable() path and above logic will be modified as below:
1. set_rate()--> 1.1 - Update CFG, M, N and D registers and don't hit the update bit if clock is disabled.
1.2 - Store CFG register value in 'current_cfg' member
of 'rcg2' structure.
2. _disable()--> 2.1 - Store the CFG register value in 'current_cfg' before switching to the safe source (XO).
2.2 - Move to the safe source (XO) and hit the update
bit.
Now RCG configuration wil not be dirty.
3. _enable()--> 3.1 - Check for 'current_cfg' value and if 0 then return. This would catch the below one time condition:
- when clk_enable() gets call without set_rate().
3.2 - Write the CFG value from 'current_cfg' to CFG
register.
3.2 - Hit the update bit as we have already written the
latest
configuration in step #3.2.
3.3 - Clear the 'current_cfg' value.
We feel above logic will work as expected and in this way, we don't have CFG registers in dirty state when clock is disabled.
Could you please inform us your thoughts about above implementation and based on that I will send the required changes.
Quoted 4 lines
--
To unsubscribe from this list: send the line "unsubscribe linux-clk" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Stephen Boyd
maintainerRe: [PATCH v6 1/3] clk: qcom: Configure the RCGs to a safe source as needed
Quoting Amit Nischal (2018-05-03 04:57:37)
Quoted 101 lines · Stephen Boyd
Quoted 36 lines
Quoting Amit Nischal (2018-04-30 09:20:08)
Quoted 17 lines
drivers/clk/qcom/clk-rcg2.c +9
-0+} + +static void clk_rcg2_shared_disable (struct clk_hw *hw) +{ +struct clk_rcg2 *rcg =to_clk_rcg2 (hw); +struct freq_tbl safe_src_tbl = {0 }; + +/* +* Park the RCG at a safe configuration - sourced off from safe source.
+ * Force enable and disable the RCG while configuring it to
safeguard(quoted diff) +2
-0+ * against any update signal coming from the downstream clock. + * The current parent is still prepared and enabled at thispoint, and
+ * the safe source is always on while application processor
subsystemdrivers/clk/qcom/clk-rcg2.c static int clk_gfx3d_set_rate(struct clk_hw *hw, unsigned long rate, · line 974
Quoted 4 lines
drivers/clk/qcom/clk-rcg2.c +4
-0+* is online. Therefore, the RCG can safely switch its parent. +*/ + safe_src_tbl.src = rcg->safe_src_index; +clk_rcg2_shared_force_enable_clear (hw, &safe_src_tbl);This should then re-dirty the config register to have the software frequency settings that existed in the hardware when disable was called.
Given that MND shouldn't be changed here, this should be as simple as saving away the CFG register, forcing it to XO speed by changing the src
and disabling dual edge in the CFG register (please don't callforce_enable_clearwith some frequency pointer, just do this inline here), and then rewriting the cfg register with the "real" settings for whatever frequency it's supposed to run at and then returning from this function.Quoted 8 lines
I guess we have to do a read cfg from hardware, write cfg, hit update config, and then write cfg again each time we disable. For enable, we just do an update config (if it's dirty?) inside of a force enable/disable pair. And
set_ratedoesn't really change except it either
does or doesn't hit the update config bit if the clk is enabled or disabled respectively.We have done the below changes suggested by you and that logic seems to be
working fine. But we have one concern about leaving the RCG registers in dirty state and would like to have a little bit modification as explained
below:Suggested Logic:
1. set_rate()--> Update CFG, M, N and D registers and don't hit the update
bit if clock is disabled - call new__clk_rcg2_configure().
Above will make the CFG register as dirty.2. _disable()--> 2.1 - Store the CFG register configuration in a variable.
2.2 - Move to the safe source (XO) and hit the update
bit.
It will only touch the CFG register and M, N, D register values will remain as it was.
2.3 - Write back the stored CFG value done in step #2.1
This will again redirty the CFG register.3. _enable()--> Just hit the update bit as the configuration write will be taken care in the steps #1 and #2.
It would be great if we don't redirty the CFG register and leave the RCG CFG register to at safe source(XO) in
disable()path.This would help us to debug the issues where device crashes and we want to dump the RCG registers to know whether from software, we have actually
moved to safe source or not. Otherwise, we would get the dirty register values in crash dumps.So instead of writing back the stored CFG(corresponding to real rate settings) in disable path, we want to restore the stored CFG in enable path and then hit the update bit.
CFG configuration store can happen at two places -set_rate()anddisable()
path and above logic will be modified as below:1. set_rate()--> 1.1 - Update CFG, M, N and D registers and don't hit the
update bit if clock is disabled.
1.2 - Store CFG register value in 'current_cfg' member
of 'rcg2' structure.2. _disable()--> 2.1 - Store the CFG register value in '
current_cfg' before
switching to the safe source (XO).
2.2 - Move to the safe source (XO) and hit the update
bit.
Now RCG configuration wil not be dirty.
Quoted 4 lines
3. _enable()--> 3.1 - Check for '
current_cfg' value and if 0 then return.
This would catch the below one time condition:
- whenclk_enable()gets call withoutset_rate().
We want clk_enable() to work without set_rate() though. So returning 0 if the value is 0 is wrong.
Quoted 7 lines
3.2 - Write the CFG value from '
current_cfg' to CFG
register.
3.2 - Hit the update bit as we have already written the
latest
configuration in step #3.2.
3.3 - Clear the 'current_cfg' value.
Quoted 7 lines
We feel above logic will work as expected and in this way, we don't have CFG
registers in dirty state when clock is disabled.
Could you please inform us your thoughts about above implementation and based
on that I will send the required changes.
If you want to save away current_cfg in a memory location so you know what it was before it was dirty, then perhaps that needs to be a debug patch that you stack on top when debugging. In the end, it would just be saving the state of the frequency setting that we have in software though, and that would be the latest rate of the clk we have configured the clk for. There aren't any mux switches going on when the clk is off, so you're saying you want to know the rate of the clk that the kernel set when we turned the clk off, which we already have with the clk rate. I'm confused.
Re: [PATCH v6 1/3] clk: qcom: Configure the RCGs to a safe source as needed
Quoted 132 lines · Stephen Boyd
Quoting Amit Nischal (2018-05-03 04:57:37)
Quoted 106 lines · Stephen Boyd
Quoted 36 lines
Quoting Amit Nischal (2018-04-30 09:20:08)
Quoted 17 lines
drivers/clk/qcom/clk-rcg2.c +9
-0+} + +static void clk_rcg2_shared_disable (struct clk_hw *hw) +{ +struct clk_rcg2 *rcg =to_clk_rcg2 (hw); +struct freq_tbl safe_src_tbl = {0 }; + +/* +* Park the RCG at a safe configuration - sourced off from safe source.
+ * Force enable and disable the RCG while configuring it to
safeguard(quoted diff) +2
-0+ * against any update signal coming from the downstream clock. + * The current parent is still prepared and enabled at thispoint, and
+ * the safe source is always on while application processor
subsystemdrivers/clk/qcom/clk-rcg2.c static int clk_gfx3d_set_rate(struct clk_hw *hw, unsigned long rate, · line 974
Quoted 4 lines
drivers/clk/qcom/clk-rcg2.c +4
-0+* is online. Therefore, the RCG can safely switch its parent. +*/ + safe_src_tbl.src = rcg->safe_src_index; +clk_rcg2_shared_force_enable_clear (hw, &safe_src_tbl);This should then re-dirty the config register to have the software frequency settings that existed in the hardware when disable was called.
Given that MND shouldn't be changed here, this should be as simple as saving away the CFG register, forcing it to XO speed by changing the src
and disabling dual edge in the CFG register (please don't callforce_enable_clearwith some frequency pointer, just do this inline here), and then rewriting the cfg register with the "real" settings for whatever frequency it's supposed to run at and then returning from this function.Quoted 8 lines
I guess we have to do a read cfg from hardware, write cfg, hit update config, and then write cfg again each time we disable. For enable, we just do an update config (if it's dirty?) inside of a force enable/disable pair. And
set_ratedoesn't really change except it either
does or doesn't hit the update config bit if the clk is enabled or disabled respectively.We have done the below changes suggested by you and that logic seems to be
working fine. But we have one concern about leaving the RCG registers in dirty state and would like to have a little bit modification as explained
below:Suggested Logic:
1. set_rate()--> Update CFG, M, N and D registers and don't hit the update
bit if clock is disabled - call new__clk_rcg2_configure().
Above will make the CFG register as dirty.2. _disable()--> 2.1 - Store the CFG register configuration in a variable.
2.2 - Move to the safe source (XO) and hit the
update
bit.
It will only touch the CFG register and M, N,
D
register values will remain as it was.
2.3 - Write back the stored CFG value done in step
#2.1
This will again redirty the CFG register.3. _enable()--> Just hit the update bit as the configuration write will be taken care in the steps #1 and #2.
It would be great if we don't redirty the CFG register and leave the RCG CFG register to at safe source(XO) in
disable()path.This would help us to debug the issues where device crashes and we want to dump the RCG registers to know whether from software, we have actually
moved to safe source or not. Otherwise, we would get the dirty register values in crash dumps.So instead of writing back the stored CFG(corresponding to real rate settings) in disable path, we want to restore the stored CFG in enable path and then hit the update bit.
CFG configuration store can happen at two places -set_rate()anddisable()
path and above logic will be modified as below:1. set_rate()--> 1.1 - Update CFG, M, N and D registers and don't hit the
update bit if clock is disabled.
1.2 - Store CFG register value in 'current_cfg'
member
of 'rcg2' structure.2. _disable()--> 2.1 - Store the CFG register value in '
current_cfg' before
switching to the safe source (XO).
2.2 - Move to the safe source (XO) and hit the
update
bit.
Now RCG configuration wil not be dirty.Quoted 5 lines
3. _enable()--> 3.1 - Check for '
current_cfg' value and if 0 then return.
This would catch the below one time condition:
- whenclk_enable()gets call withoutset_rate().We want
clk_enable()to work withoutset_rate()though. So returning 0 if the value is 0 is wrong.Quoted 8 lines
3.2 - Write the CFG value from '
current_cfg' to CFG
register.
3.2 - Hit the update bit as we have already written
the
latest
configuration in step #3.2.
3.3 - Clear the 'current_cfg' value.Quoted 7 lines
We feel above logic will work as expected and in this way, we don't have CFG
registers in dirty state when clock is disabled.
Could you please inform us your thoughts about above implementation and based
on that I will send the required changes.
Quoted 9 lines
If you want to save away
current_cfgin a memory location so you know what it was before it was dirty, then perhaps that needs to be a debug patch that you stack on top when debugging. In the end, it would just be saving the state of the frequency setting that we have in software though, and that would be the latest rate of the clk we have configured the clk for. There aren't any mux switches going on when the clk is off, so you're saying you want to know the rate of the clk that the kernel set when we turned the clk off, which we already have with the clk rate. I'm confused.
Thanks for the suggestions. We will implement the new ops with the below logic which you suggested earlier i.e. re-dirtying the RCG in disable() path with real CFG settings and in enable() path, only hit the update bit.
1. set_rate()--> Update CFG, M, N and D registers and don't hit the update bit if clock is disabled - call new __clk_rcg2_configure().
Above will make the CFG register as dirty.
2. _disable()--> 2.1 - Store the CFG register configuration in a variable.
2.2 - Move to the safe source (XO) and hit the update
bit. It will only touch the CFG register and M,
N, D
register values will remain as it was.
2.3 - Write back the stored CFG value done in step #2.1
This will again redirty the CFG register.
3. _enable()--> Just hit the update bit as the configuration write will be taken care in the steps #1 and #2.
PATCH v6 2/3 clk: qcom: Add support for BRANCH_NO_DELAY flag for branch clocks
In reply to Amit NischalThere could be few clocks where the clock status bit is not required to be polled as the clock on/off would be controlled by enabling/disabling external source. Add support for the same by introducing new flag named as 'BRANCH_NO_DELAY'.
--- drivers/clk/qcom/clk-branch.c | 7 +++++-- drivers/clk/qcom/clk-branch.h | 1 + 2 files changed, 6 insertions(+), 2 deletions(-)
drivers/clk/qcom/clk-branch.c +5 -2
@@ -77,8 +77,11 @@ static int clk_branch_wait(const struct clk_branch *br, bool enabling,bool voted = br->halt_check &BRANCH_VOTED ;const char *name =clk_hw_get_name (&br->clkr.hw); -/* Skip checking halt bit if the clock is in hardware gated mode */ -if (clk_branch_in_hwcg_mode (br)) +/* +* Skip checking halt bit if halt_check is BRANCH_NO_DELAY or +* the clock is in hardware gated mode +*/ +if (br->halt_check ==BRANCH_NO_DELAY ||clk_branch_in_hwcg_mode (br))return 0 ;if (br->halt_check ==BRANCH_HALT_DELAY || (!enabling && voted)) {
drivers/clk/qcom/clk-branch.h +1 -0
@@ -42,6 +42,7 @@ struct clk_branch {#define BRANCH_HALT_ENABLE 1/* pol: 0 = halt */ #define BRANCH_HALT_ENABLE_VOTED (BRANCH_HALT_ENABLE | BRANCH_VOTED)#define BRANCH_HALT_DELAY 2/* No bit to check; just delay */ +#define BRANCH_NO_DELAY 3/* No bit to check; without delay */ struct clk_regmap clkr; };
--
QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by The Linux Foundation
Stephen Boyd
maintainerRe: [PATCH v6 2/3] clk: qcom: Add support for BRANCH_NO_DELAY flag for branch clocks
Quoting Amit Nischal (2018-04-30 09:20:09)
drivers/clk/qcom/clk-branch.h struct clk_branch { · line 45
Quoted 9 lines
drivers/clk/qcom/clk-branch.h +1
-0@@ -42,6 +42,7 @@ struct clk_branch {#define BRANCH_HALT_ENABLE 1/* pol: 0 = halt */ #define BRANCH_HALT_ENABLE_VOTED (BRANCH_HALT_ENABLE | BRANCH_VOTED)#define BRANCH_HALT_DELAY 2/* No bit to check; just delay */ +#define BRANCH_NO_DELAY 3/* No bit to check; without delay */
Let's call it BRANCH_HALT_SKIP and indicate that it's skipping the halt bit check. Technically there is a bit to check, we just refuse to check it. I've reworked and applied this patch as below.
From f9ddbd74bf4940d3b7a0eb076eb254833660643c Mon Sep 17 00:00:00 2001
From: Amit Nischal <[email protected]>
Date: Mon, 30 Apr 2018 21:50:09 +0530
Subject: [PATCH] clk: qcom: Add support for BRANCH_HALT_SKIP flag for branch
clocks
There could be few clocks where the clock status bit is not required to be polled as the clock on/off would be controlled by enabling/disabling external source. Add support for the same by introducing new flag named as 'BRANCH_HALT_SKIP'.
--- drivers/clk/qcom/clk-branch.c | 7 +++++-- drivers/clk/qcom/clk-branch.h | 1 + 2 files changed, 6 insertions(+), 2 deletions(-)
drivers/clk/qcom/clk-branch.c +5 -2
@@ -77,8 +77,11 @@ static int clk_branch_wait(const struct clk_branch *br, bool enabling,bool voted = br->halt_check &BRANCH_VOTED ;const char *name =clk_hw_get_name (&br->clkr.hw); -/* Skip checking halt bit if the clock is in hardware gated mode */ -if (clk_branch_in_hwcg_mode (br)) +/* +* Skip checking halt bit if we're explicitly ignoring the bit or the +* clock is in hardware gated mode +*/ +if (br->halt_check ==BRANCH_HALT_SKIP ||clk_branch_in_hwcg_mode (br))return 0 ;if (br->halt_check ==BRANCH_HALT_DELAY || (!enabling && voted)) {
drivers/clk/qcom/clk-branch.h +1 -0
@@ -42,6 +42,7 @@ struct clk_branch {#define BRANCH_HALT_ENABLE 1/* pol: 0 = halt */ #define BRANCH_HALT_ENABLE_VOTED (BRANCH_HALT_ENABLE | BRANCH_VOTED)#define BRANCH_HALT_DELAY 2/* No bit to check; just delay */ +#define BRANCH_HALT_SKIP 3/* Don't check halt bit */ struct clk_regmap clkr; };
Signature · 1 line
Sent by a computer through tubes
PATCH v6 3/3 clk: qcom: Add Global Clock controller (GCC) driver for SDM845
In reply to Amit NischalFrom: Taniya Das <[email protected]>
Add support for the global clock controller found on SDM845 based devices. This should allow most non-multimedia device drivers to probe and control their clocks.
--- .../devicetree/bindings/clock/qcom,gcc.txt | 1 + drivers/clk/qcom/Kconfig | 10 +- drivers/clk/qcom/Makefile | 1 + drivers/clk/qcom/gcc-sdm845.c | 3480 ++++++++++++++++++++ include/dt-bindings/clock/qcom,gcc-sdm845.h | 239 ++ 5 files changed, 3727 insertions(+), 4 deletions(-) create mode 100644 drivers/clk/qcom/gcc-sdm845.c create mode 100644 include/dt-bindings/clock/qcom,gcc-sdm845.h
Documentation/devicetree/bindings/clock/qcom,gcc.txt +1 -0
@@ -19,6 +19,7 @@ Required properties : "qcom,gcc-msm8996" "qcom,gcc-msm8998" "qcom,gcc-mdm9615" + "qcom,gcc-sdm845" - reg : shall contain base register location and length - #clock-cells : shall contain 1
drivers/clk/qcom/Kconfig +6 -4
@@ -218,13 +218,15 @@ config MSM_MMCC_8996 Say Y if you want to support multimedia devices such as display, graphics, video encode/decode, camera, etc. -config MSM_GCC_8998 - tristate "MSM8998 Global Clock Controller" +config SDM_GCC_845 + tristate "SDM845 Global Clock Controller" + select QCOM_GDSC depends on COMMON_CLK_QCOM help - Support for the global clock controller on msm8998 devices. + Support for the global clock controller on Qualcomm Technologies, Inc + sdm845 devices. Say Y if you want to use peripheral devices such as UART, SPI, - i2c, USB, UFS, SD/eMMC, PCIe, etc. + I2C, USB, UFS, SDDC, PCIe, etc. config SPMI_PMIC_CLKDIV tristate "SPMI PMIC clkdiv Support"
drivers/clk/qcom/Makefile +1 -0
@@ -38,4 +38,5 @@ obj-$(CONFIG_QCOM_A53PLL) += a53-pll.o obj-$(CONFIG_QCOM_CLK_APCS_MSM8916) += apcs-msm8916.o obj-$(CONFIG_QCOM_CLK_RPM) += clk-rpm.o obj-$(CONFIG_QCOM_CLK_SMD_RPM) += clk-smd-rpm.o +obj-$(CONFIG_SDM_GCC_845) += gcc-sdm845.o obj-$(CONFIG_SPMI_PMIC_CLKDIV) += clk-spmi-pmic-div.o
drivers/clk/qcom/gcc-sdm845.c new file +3480 -0
2,969 lines not on this page · raw message
include/dt-bindings/clock/qcom,gcc-sdm845.h new file +239 -0
239 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
--
QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by The Linux Foundation
Part of the diff is not shown here. View the raw message.
Re: [PATCH v6 3/3] clk: qcom: Add Global Clock controller (GCC) driver for SDM845
Quoted 8 lines · Amit Nischal
From: Taniya Das <[email protected]>
Add support for the global clock controller found on SDM845 based devices. This should allow most non-multimedia device drivers to probe and control their clocks.
Signed-off-by Taniya Das <[email protected]>Signed-off-by Amit Nischal <[email protected]>
Quoted 9 lines
--- .../devicetree/bindings/clock/qcom,gcc.txt | 1 + drivers/clk/qcom/Kconfig | 10 +- drivers/clk/qcom/Makefile | 1 + drivers/clk/qcom/gcc-sdm845.c | 3480 ++++++++++++++++++++ include/dt-bindings/clock/qcom,gcc-sdm845.h | 239 ++ 5 files changed, 3727 insertions(+), 4 deletions(-) create mode 100644 drivers/clk/qcom/gcc-sdm845.c create mode 100644 include/dt-bindings/clock/qcom,gcc-sdm845.h
For the DT bits:
In the future please split bindings and binding headers to separate patch.
Rob
Stephen Boyd
maintainerRe: [PATCH v6 3/3] clk: qcom: Add Global Clock controller (GCC) driver for SDM845
In reply to Amit NischalQuoting Amit Nischal (2018-04-30 09:20:10)
Quoted 6 lines
--- .../devicetree/bindings/clock/qcom,gcc.txt | 1 + drivers/clk/qcom/Kconfig | 10 +- drivers/clk/qcom/Makefile | 1 + drivers/clk/qcom/gcc-sdm845.c | 3480 ++++++++++++++++++++ include/dt-bindings/clock/qcom,gcc-sdm845.h | 239 ++
Do the split that Rob suggests please, given that you're resending. And also include his reviewed-by tag.
Quoted 15 lines
5 files changed, 3727 insertions(+), 4 deletions(-) create mode 100644 drivers/clk/qcom/gcc-sdm845.c create mode 100644 include/dt-bindings/clock/qcom,gcc-sdm845.hdrivers/clk/qcom/Kconfig +1
-2@@ -218,13 +218,15 @@ config MSM_MMCC_8996 Say Y if you want to support multimedia devices such as display, graphics, video encode/decode, camera, etc. -config MSM_GCC_8998 - tristate "MSM8998 Global Clock Controller" +config SDM_GCC_845
drivers/clk/qcom/Kconfig config MSM_MMCC_8996 · line 229
Quoted 10 lines
drivers/clk/qcom/Kconfig +5
-2+ tristate "SDM845 Global Clock Controller" + select QCOM_GDSC depends on COMMON_CLK_QCOM help - Support for the global clock controller on msm8998 devices. + Support for the global clock controller on Qualcomm Technologies, Inc + sdm845 devices. Say Y if you want to use peripheral devices such as UART, SPI, - i2c, USB, UFS, SD/eMMC, PCIe, etc. + I2C, USB, UFS, SDDC, PCIe, etc.
This is all wrong.
Quoted 14 lines
drivers/clk/qcom/Kconfig +0
-0config SPMI_PMIC_CLKDIV tristate "SPMI PMIC clkdiv Support"drivers/clk/qcom/gcc-sdm845.c new file +5
-0@@ -0,0 +1,3480 @@ +// SPDX-License-Identifier: GPL-2.0 +/* +* Copyright (c) 2018, The Linux Foundation. All rights reserved. +*/ +
[...]
drivers/clk/qcom/gcc-sdm845.c line 1293
Quoted 9 lines
drivers/clk/qcom/gcc-sdm845.c new file +9
-0+ .name = "gcc_disp_axi_clk", + .ops = &clk_branch2_ops, + }, + }, +}; + +static struct clk_branch gcc_disp_gpll0_clk_src = { + .halt_reg =0x52004 , + .halt_check = BRANCH_HALT_DELAY,
What about this one? It's not a phy so I'm confused again why we're unable to check the halt bit. To be clear(er), I don't see why we ever want to have HALT_DELAY used. Hopefully we can remove that flag.
From what I recall, the flag is there for clks that don't toggle their status bit at all, but that we know take a few cycles to ungate the upstream clk. So we threw a delay into the code to make sure that when clk_enable() returned, a driver wouldn't try to use hardware before the clk was actually on. But these cases should pretty much never happen, hence all the pushback against this flag.
Quoted 9 lines
drivers/clk/qcom/gcc-sdm845.c new file +9
-0+ .clkr = { + .enable_reg = 0x52004, + .enable_mask = BIT(18), + .hw.init = &(struct clk_init_data){ + .name = "gcc_disp_gpll0_clk_src", + .parent_names = (const char *[]){ + "gpll0", + }, + .num_parents = 1,
[...]
Quoted 7 lines
drivers/clk/qcom/gcc-sdm845.c new file +7
-0+ .enable_reg = 0x7508c, + .enable_mask = BIT(0), + .hw.init = &(struct clk_init_data ){ + .name ="gcc_ufs_card_phy_aux_clk" , + .parent_names = (const char *[]){ +"gcc_ufs_card_phy_aux_clk_src" , + },
drivers/clk/qcom/gcc-sdm845.c line 2498
Quoted 10 lines
drivers/clk/qcom/gcc-sdm845.c new file +10
-0+ .num_parents = 1, + .flags = CLK_SET_RATE_PARENT, + .ops = &clk_branch2_ops, + }, + }, +}; + +static struct clk_branch gcc_ufs_card_rx_symbol_0_clk = { + .halt_reg =0x75018 , + .halt_check = BRANCH_HALT_DELAY,
There are still HALT_DELAY flags for UFS though? Why?
Also, are you going to send DFS support for the QUP clks? I would like to see that code merged soon.
Re: [PATCH v6 3/3] clk: qcom: Add Global Clock controller (GCC) driver for SDM845
Quoted 11 lines · Stephen Boyd
Quoting Amit Nischal (2018-04-30 09:20:10)
Quoted 7 lines
--- .../devicetree/bindings/clock/qcom,gcc.txt | 1 + drivers/clk/qcom/Kconfig | 10 +- drivers/clk/qcom/Makefile | 1 + drivers/clk/qcom/gcc-sdm845.c | 3480 ++++++++++++++++++++ include/dt-bindings/clock/qcom,gcc-sdm845.h | 239 ++Do the split that Rob suggests please, given that you're resending. And also include his reviewed-by tag.
Thanks for the review. Sure I will split the dt-binding into separate patch in next series.
Quoted 23 lines
Quoted 23 lines
5 files changed, 3727 insertions(+), 4 deletions(-) create mode 100644 drivers/clk/qcom/gcc-sdm845.c create mode 100644 include/dt-bindings/clock/qcom,gcc-sdm845.hdrivers/clk/qcom/Kconfig +4
-3@@ -218,13 +218,15 @@ config MSM_MMCC_8996 Say Y if you want to support multimedia devices such as display, graphics, video encode/decode, camera, etc. -config MSM_GCC_8998 - tristate "MSM8998 Global Clock Controller" +config SDM_GCC_845 + tristate "SDM845 Global Clock Controller" + select QCOM_GDSC depends on COMMON_CLK_QCOM help - Support for the global clock controller on msm8998 devices. + Support for the global clock controller on Qualcomm
Quoted 9 lines
drivers/clk/qcom/Kconfig config MSM_MMCC_8996 · line 229
Quoted 6 lines
Technologies, Inc
+ sdm845 devices.
Say Y if you want to use peripheral devices such as UART,
SPI,drivers/clk/qcom/Kconfig +1
-1- i2c, USB, UFS, SD/eMMC, PCIe, etc. + I2C, USB, UFS, SDDC, PCIe, etc.This is all wrong.
My bad. I did by mistake. Will fix this in next series.
Quoted 29 lines
Quoted 14 lines
config
SPMI_PMIC_CLKDIV
tristate "SPMI PMIC clkdiv Support"drivers/clk/qcom/gcc-sdm845.c new file +5
-0@@ -0,0 +1,3480 @@ +// SPDX-License-Identifier: GPL-2.0 +/* +* Copyright (c) 2018, The Linux Foundation. All rights reserved. +*/ +[...]
drivers/clk/qcom/gcc-sdm845.c line 1293
Quoted 9 lines
drivers/clk/qcom/gcc-sdm845.c new file +9
-0+ .name = "gcc_disp_axi_clk", + .ops = &clk_branch2_ops, + }, + }, +}; + +static struct clk_branch gcc_disp_gpll0_clk_src = { + .halt_reg =0x52004 , + .halt_check = BRANCH_HALT_DELAY,What about this one? It's not a phy so I'm confused again why we're unable to check the halt bit. To be clear(er), I don't see why we ever want to have
HALT_DELAYused. Hopefully we can remove that flag.
Quoted 7 lines
From what I recall, the flag is there for clks that don't toggle their status bit at all, but that we know take a few cycles to ungate the upstream clk. So we threw a delay into the code to make sure that when
clk_enable()returned, a driver wouldn't try to use hardware before the clk was actually on. But these cases should pretty much never happen, hence all the pushback against this flag.
For these "*gpll0_clk_src" and "*gpll0_div_clk" clocks, there is no halt bit to check the status and it is required to have delay for few cycles so that clock gets turned on before a client driver to use the hardware.
Quoted 21 lines
Quoted 9 lines
drivers/clk/qcom/gcc-sdm845.c new file +9
-0+ .clkr = { + .enable_reg = 0x52004, + .enable_mask = BIT(18), + .hw.init = &(struct clk_init_data){ + .name = "gcc_disp_gpll0_clk_src", + .parent_names = (const char *[]){ + "gpll0", + }, + .num_parents = 1,[...]
Quoted 11 lines
drivers/clk/qcom/gcc-sdm845.c new file +11
-0+ .enable_reg = 0x7508c, + .enable_mask = BIT(0), + .hw.init = &(struct clk_init_data ){ + .name ="gcc_ufs_card_phy_aux_clk" , + .parent_names = (const char *[]){ +"gcc_ufs_card_phy_aux_clk_src" , + }, + .num_parents =1 , + .flags =CLK_SET_RATE_PARENT , + .ops = &clk_branch2_ops, + },
Quoted 8 lines
drivers/clk/qcom/gcc-sdm845.c line 2498
Quoted 6 lines
drivers/clk/qcom/gcc-sdm845.c new file +6
-0+ }, +}; + +static struct clk_branch gcc_ufs_card_rx_symbol_0_clk = { + .halt_reg =0x75018 , + .halt_check =BRANCH_HALT_DELAY ,There are still
HALT_DELAYflags for UFS though? Why?
For ufs_card tx/rx symbol clocks, we don't poll the status bit as per the recommendation from the HW team. We can change the halt_check type to newly implemented flag "BRANCH_HALT_SKIP". Please update us with your thoughts to change the flag to "BRANCH_HALT_SKIP".
Quoted 3 lines
Also, are you going to send DFS support for the QUP clks? I would like to see that code merged soon.
Taniya has sent the patches for DFS support for QUP clocks.
https://patchwork.kernel.org/patch/10376951/
Stephen Boyd
maintainerRe: [PATCH v6 3/3] clk: qcom: Add Global Clock controller (GCC) driver for SDM845
Quoting Amit Nischal (2018-05-04 03:45:12)
Quoted 19 lines · Stephen Boyd
Quoted 10 lines
Quoting Amit Nischal (2018-04-30 09:20:10)
drivers/clk/qcom/gcc-sdm845.c line 1293
Quoted 4 lines
drivers/clk/qcom/gcc-sdm845.c new file +4
-0+ +static struct clk_branch gcc_disp_gpll0_clk_src = { + .halt_reg =0x52004 , + .halt_check =BRANCH_HALT_DELAY ,What about this one? It's not a phy so I'm confused again why we're unable to check the halt bit. To be clear(er), I don't see why we ever want to have
HALT_DELAYused. Hopefully we can remove that flag.Quoted 7 lines
From what I recall, the flag is there for clks that don't toggle their status bit at all, but that we know take a few cycles to ungate the upstream clk. So we threw a delay into the code to make sure that when
clk_enable()returned, a driver wouldn't try to use hardware before the clk was actually on. But these cases should pretty much never happen, hence all the pushback against this flag.
Quoted 3 lines
For these "
*gpll0_clk_src" and "*gpll0_div_clk" clocks, there is no halt bit to check the status and it is required to have delay for few cycles so that clock gets turned on before a client driver to use the hardware.
Ok.. but then why is there a 'halt_reg' configured for the clk?
Quoted 11 lines
Quoted 6 lines
drivers/clk/qcom/gcc-sdm845.c line 2498
Quoted 4 lines
drivers/clk/qcom/gcc-sdm845.c new file +4
-0+ +static struct clk_branch gcc_ufs_card_rx_symbol_0_clk = { + .halt_reg =0x75018 , + .halt_check =BRANCH_HALT_DELAY ,There are still
HALT_DELAYflags for UFS though? Why?For
ufs_cardtx/rx symbol clocks, we don't poll the status bit as per the recommendation from the HW team. We can change thehalt_checktype to newly implemented flag "BRANCH_HALT_SKIP". Please update us with your thoughts to change the flag to "BRANCH_HALT_SKIP".
Yes use HALT_SKIP please.
Quoted 8 lines
Quoted 4 lines
Also, are you going to send DFS support for the QUP clks? I would like to see that code merged soon.
Taniya has sent the patches for DFS support for QUP clocks.
https://patchwork.kernel.org/patch/10376951/
I'll take a look.
Re: [PATCH v6 3/3] clk: qcom: Add Global Clock controller (GCC) driver for SDM845
Quoted 20 lines · Stephen Boyd
Quoting Amit Nischal (2018-05-04 03:45:12)
Quoted 19 lines · Stephen Boyd
Quoted 17 lines
Quoting Amit Nischal (2018-04-30 09:20:10)
drivers/clk/qcom/gcc-sdm845.c line 1293
Quoted 4 lines
drivers/clk/qcom/gcc-sdm845.c new file +4
-0+ +static struct clk_branch gcc_disp_gpll0_clk_src = { + .halt_reg =0x52004 , + .halt_check =BRANCH_HALT_DELAY ,What about this one? It's not a phy so I'm confused again why we're unable to check the halt bit. To be clear(er), I don't see why we ever want to have
HALT_DELAYused. Hopefully we can remove that flag.From what I recall, the flag is there for clks that don't toggle their status bit at all, but that we know take a few cycles to ungate the upstream clk. So we threw a delay into the code to make sure that when
clk_enable()returned, a driver wouldn't try to use hardware before the clk was actually on. But these cases should pretty much never happen, hence all the pushback against this flag.
Quoted 5 lines
Quoted 3 lines
For these "
*gpll0_clk_src" and "*gpll0_div_clk" clocks, there is no halt bit to check the status and it is required to have delay for few cycles so that clock gets turned on before a client driver to use the hardware.Ok.. but then why is there a '
halt_reg' configured for the clk?
Thanks for the review.
I will remove the halt_reg for the clocks where we are using the 'HALT_DELAY' flag and there is no need to poll the status bit as we are returning early from the 'clk_branch_wait()' function.
Quoted 8 lines
Quoted 8 lines
Quoted 7 lines
drivers/clk/qcom/gcc-sdm845.c line 2498
Quoted 5 lines
drivers/clk/qcom/gcc-sdm845.c new file +4
-0+ +static struct clk_branch gcc_ufs_card_rx_symbol_0_clk = { + .halt_reg =0x75018 , + .halt_check =BRANCH_HALT_DELAY ,There are still
HALT_DELAYflags for UFS though? Why?
Quoted 6 lines
Quoted 4 lines
For
ufs_cardtx/rx symbol clocks, we don't poll the status bit as per the recommendation from the HW team. We can change thehalt_checktype to newly implemented flag "BRANCH_HALT_SKIP". Please update us with your thoughts to change the flag to "BRANCH_HALT_SKIP".Yes use
HALT_SKIPplease.
Thanks for confirming. I will do the changes in the next patch series.
Quoted 15 lines
Quoted 9 lines
Quoted 5 lines
Also, are you going to send DFS support for the QUP clks? I would like to see that code merged soon.
Taniya has sent the patches for DFS support for QUP clocks.
https://patchwork.kernel.org/patch/10376951/I'll take a look.
--
To unsubscribe from this list: send the line "unsubscribe linux-clk" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html