]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
clk: sandbox: Adjust clk-mux.c to emulate reading divider value from HW
authorLukasz Majewski <lukma@denx.de>
Mon, 24 Jun 2019 13:50:49 +0000 (15:50 +0200)
committerStefano Babic <sbabic@denx.de>
Fri, 19 Jul 2019 12:50:30 +0000 (14:50 +0200)
The generic mux clock code for CCF requires reading the clock multiplexer
value from HW registers. As sandbox by design has readl() as no-op it was
necessary to provide this value in the other way.

The new field in the mux structure (accessible only when sandbox is run)
has been introduced for this purpose.

Signed-off-by: Lukasz Majewski <lukma@denx.de>
drivers/clk/clk-mux.c
include/linux/clk-provider.h

index 14b9f2b1d9eeaecb67c8e17847c01dc76bfbb9a4..3c075aa09ec78b8f63cf6254188d407b38e1653f 100644 (file)
@@ -64,7 +64,12 @@ static u8 clk_mux_get_parent(struct clk *clk)
        struct clk_mux *mux = to_clk_mux(clk);
        u32 val;
 
-       val = readl(mux->reg) >> mux->shift;
+#if CONFIG_IS_ENABLED(SANDBOX_CLK_CCF)
+       val = mux->io_mux_val;
+#else
+       val = readl(mux->reg);
+#endif
+       val >>= mux->shift;
        val &= mux->mask;
 
        return clk_mux_val_to_index(clk, mux->table, mux->flags, val);
@@ -108,6 +113,9 @@ struct clk *clk_hw_register_mux_table(struct device *dev, const char *name,
        mux->mask = mask;
        mux->flags = clk_mux_flags;
        mux->table = table;
+#if CONFIG_IS_ENABLED(SANDBOX_CLK_CCF)
+       mux->io_mux_val = *(u32 *)reg;
+#endif
 
        clk = &mux->clk;
 
index 53c9c41b90de4f5870b6ca8a3b26284437f27d50..43a25e9c6a87d54f1432cb68d7bd6e449ac0d1ce 100644 (file)
@@ -59,6 +59,10 @@ struct clk_mux {
         */
        const char      * const *parent_names;
        u8              num_parents;
+#if CONFIG_IS_ENABLED(SANDBOX_CLK_CCF)
+       u32             io_mux_val;
+#endif
+
 };
 
 #define to_clk_mux(_clk) container_of(_clk, struct clk_mux, clk)