aboutsummaryrefslogtreecommitdiff
path: root/drivers/clk/clk-divider.c
diff options
context:
space:
mode:
authorLukasz Majewski2019-06-24 15:50:48 +0200
committerStefano Babic2019-07-19 14:50:30 +0200
commit6bb15d6f07a8348cca07f2f245f3025cb79e7680 (patch)
tree9354db4ddf38f1a73767d24d83cd8a7cacbf0bad /drivers/clk/clk-divider.c
parent4ab8e783f33d80a3875e990f3069f21018379b36 (diff)
clk: sandbox: Adjust clk-divider to emulate reading its value from HW
The generic divider clock code for CCF requires reading the divider 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 divider structure (accessible only when sandbox is run) has been introduced for this purpose. Signed-off-by: Lukasz Majewski <lukma@denx.de>
Diffstat (limited to 'drivers/clk/clk-divider.c')
-rw-r--r--drivers/clk/clk-divider.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/drivers/clk/clk-divider.c b/drivers/clk/clk-divider.c
index 3348d97829b..6921c76a48f 100644
--- a/drivers/clk/clk-divider.c
+++ b/drivers/clk/clk-divider.c
@@ -74,7 +74,12 @@ static ulong clk_divider_recalc_rate(struct clk *clk)
unsigned long parent_rate = clk_get_parent_rate(clk);
unsigned int val;
- val = readl(divider->reg) >> divider->shift;
+#if CONFIG_IS_ENABLED(SANDBOX_CLK_CCF)
+ val = divider->io_divider_val;
+#else
+ val = readl(divider->reg);
+#endif
+ val >>= divider->shift;
val &= clk_div_mask(divider->width);
return divider_recalc_rate(clk, parent_rate, val, divider->table,
@@ -112,6 +117,9 @@ static struct clk *_register_divider(struct device *dev, const char *name,
div->width = width;
div->flags = clk_divider_flags;
div->table = table;
+#if CONFIG_IS_ENABLED(SANDBOX_CLK_CCF)
+ div->io_divider_val = *(u32 *)reg;
+#endif
/* register the clock */
clk = &div->clk;