lkml.org 
[lkml]   [2018]   [Mar]   [23]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[PATCH 4.14 63/77] clk: axi-clkgen: Correctly handle nocount bit in recalc_rate()
    Date
    4.14-stable review patch.  If anyone has any objections, please let me know.

    ------------------

    From: Lars-Peter Clausen <lars@metafoo.de>


    [ Upstream commit 063578dc5f407f67d149133818efabe457daafda ]

    If the nocount bit is set the divider is bypassed and the settings for the
    divider count should be ignored and a divider value of 1 should be assumed.
    Handle this correctly in the driver recalc_rate() callback.

    While the driver sets up the part so that the read back dividers values
    yield the correct result the power-on reset settings of the part might not
    reflect this and hence calling e.g. clk_get_rate() without prior calls to
    clk_set_rate() will yield the wrong result.

    Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
    Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
    Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    ---
    drivers/clk/clk-axi-clkgen.c | 29 ++++++++++++++++++++++++-----
    1 file changed, 24 insertions(+), 5 deletions(-)

    --- a/drivers/clk/clk-axi-clkgen.c
    +++ b/drivers/clk/clk-axi-clkgen.c
    @@ -40,6 +40,10 @@
    #define MMCM_REG_FILTER1 0x4e
    #define MMCM_REG_FILTER2 0x4f

    +#define MMCM_CLKOUT_NOCOUNT BIT(6)
    +
    +#define MMCM_CLK_DIV_NOCOUNT BIT(12)
    +
    struct axi_clkgen {
    void __iomem *base;
    struct clk_hw clk_hw;
    @@ -315,12 +319,27 @@ static unsigned long axi_clkgen_recalc_r
    unsigned int reg;
    unsigned long long tmp;

    - axi_clkgen_mmcm_read(axi_clkgen, MMCM_REG_CLKOUT0_1, &reg);
    - dout = (reg & 0x3f) + ((reg >> 6) & 0x3f);
    + axi_clkgen_mmcm_read(axi_clkgen, MMCM_REG_CLKOUT0_2, &reg);
    + if (reg & MMCM_CLKOUT_NOCOUNT) {
    + dout = 1;
    + } else {
    + axi_clkgen_mmcm_read(axi_clkgen, MMCM_REG_CLKOUT0_1, &reg);
    + dout = (reg & 0x3f) + ((reg >> 6) & 0x3f);
    + }
    +
    axi_clkgen_mmcm_read(axi_clkgen, MMCM_REG_CLK_DIV, &reg);
    - d = (reg & 0x3f) + ((reg >> 6) & 0x3f);
    - axi_clkgen_mmcm_read(axi_clkgen, MMCM_REG_CLK_FB1, &reg);
    - m = (reg & 0x3f) + ((reg >> 6) & 0x3f);
    + if (reg & MMCM_CLK_DIV_NOCOUNT)
    + d = 1;
    + else
    + d = (reg & 0x3f) + ((reg >> 6) & 0x3f);
    +
    + axi_clkgen_mmcm_read(axi_clkgen, MMCM_REG_CLK_FB2, &reg);
    + if (reg & MMCM_CLKOUT_NOCOUNT) {
    + m = 1;
    + } else {
    + axi_clkgen_mmcm_read(axi_clkgen, MMCM_REG_CLK_FB1, &reg);
    + m = (reg & 0x3f) + ((reg >> 6) & 0x3f);
    + }

    if (d == 0 || dout == 0)
    return 0;

    \
     
     \ /
      Last update: 2018-03-23 12:41    [W:4.165 / U:0.324 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site