Merge "clk: qcom: Retrieve pre_div from freq_tbl for shared RCG"

This commit is contained in:
Linux Build Service Account 2018-04-29 21:09:47 -07:00 committed by Gerrit - the friendly Code Review server
commit 5282e9782d

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2013, 2016-2017, The Linux Foundation. All rights reserved. * Copyright (c) 2013, 2016-2018, The Linux Foundation. All rights reserved.
* *
* This software is licensed under the terms of the GNU General Public * This software is licensed under the terms of the GNU General Public
* License version 2, as published by the Free Software Foundation, and * License version 2, as published by the Free Software Foundation, and
@ -210,9 +210,11 @@ static unsigned long
clk_rcg2_recalc_rate(struct clk_hw *hw, unsigned long parent_rate) clk_rcg2_recalc_rate(struct clk_hw *hw, unsigned long parent_rate)
{ {
struct clk_rcg2 *rcg = to_clk_rcg2(hw); struct clk_rcg2 *rcg = to_clk_rcg2(hw);
const struct freq_tbl *f_curr;
u32 cfg, hid_div, m = 0, n = 0, mode = 0, mask; u32 cfg, hid_div, m = 0, n = 0, mode = 0, mask;
if (rcg->enable_safe_config && !clk_hw_is_prepared(hw)) { if (rcg->enable_safe_config && (!clk_hw_is_prepared(hw)
|| !clk_hw_is_enabled(hw))) {
if (!rcg->current_freq) if (!rcg->current_freq)
rcg->current_freq = cxo_f.freq; rcg->current_freq = cxo_f.freq;
return rcg->current_freq; return rcg->current_freq;
@ -232,9 +234,17 @@ clk_rcg2_recalc_rate(struct clk_hw *hw, unsigned long parent_rate)
mode >>= CFG_MODE_SHIFT; mode >>= CFG_MODE_SHIFT;
} }
mask = BIT(rcg->hid_width) - 1; if (rcg->enable_safe_config) {
hid_div = cfg >> CFG_SRC_DIV_SHIFT; f_curr = qcom_find_freq(rcg->freq_tbl, rcg->current_freq);
hid_div &= mask; if (!f_curr)
return -EINVAL;
hid_div = f_curr->pre_div;
} else {
mask = BIT(rcg->hid_width) - 1;
hid_div = cfg >> CFG_SRC_DIV_SHIFT;
hid_div &= mask;
}
return calc_rate(parent_rate, m, n, mode, hid_div); return calc_rate(parent_rate, m, n, mode, hid_div);
} }