]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/commitdiff
clk: qcom: Allow constant ratio freq tables for rcg
authorJeffrey Hugo <jeffrey.l.hugo@gmail.com>
Thu, 31 Oct 2019 18:57:15 +0000 (11:57 -0700)
committerKhalid Elmously <khalid.elmously@canonical.com>
Wed, 29 Jan 2020 04:47:27 +0000 (23:47 -0500)
BugLink: https://bugs.launchpad.net/bugs/1860602
[ Upstream commit efd164b5520afd6fb2883b68e0d408a7de29c491 ]

Some RCGs (the gfx_3d_src_clk in msm8998 for example) are basically just
some constant ratio from the input across the entire frequency range.  It
would be great if we could specify the frequency table as a single entry
constant ratio instead of a long list, ie:

{ .src = P_GPUPLL0_OUT_EVEN, .pre_div = 3 },
        { }

So, lets support that.

We need to fix a corner case in qcom_find_freq() where if the freq table
is non-null, but has no frequencies, we end up returning an "entry" before
the table array, which is bad.  Then, we need ignore the freq from the
table, and instead base everything on the requested freq.

Suggested-by: Stephen Boyd <sboyd@kernel.org>
Signed-off-by: Jeffrey Hugo <jeffrey.l.hugo@gmail.com>
Link: https://lkml.kernel.org/r/20191031185715.15504-1-jeffrey.l.hugo@gmail.com
Signed-off-by: Stephen Boyd <sboyd@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
Signed-off-by: Khalid Elmously <khalid.elmously@canonical.com>
drivers/clk/qcom/clk-rcg2.c
drivers/clk/qcom/common.c

index bbeaf9c09dbb4750cd6479ae16ab416626a19731..bdbbbdfc0fa176d63dd04188875a016d7978a91c 100644 (file)
@@ -212,6 +212,8 @@ static int _freq_tbl_determine_rate(struct clk_hw *hw, const struct freq_tbl *f,
        p = clk_hw_get_parent_by_index(hw, index);
        if (clk_flags & CLK_SET_RATE_PARENT) {
                if (f->pre_div) {
+                       if (!rate)
+                               rate = req->rate;
                        rate /= 2;
                        rate *= f->pre_div + 1;
                }
index b8064a336d464bbe9aa253c39ebf0c3283c2ee54..b75f3e3dedcf893253469db0283514166d65f77f 100644 (file)
@@ -37,6 +37,9 @@ struct freq_tbl *qcom_find_freq(const struct freq_tbl *f, unsigned long rate)
        if (!f)
                return NULL;
 
+       if (!f->freq)
+               return f;
+
        for (; f->freq; f++)
                if (rate <= f->freq)
                        return f;