diff options
author | Maxime Ripard <maxime.ripard@free-electrons.com> | 2017-01-19 16:49:26 -0500 |
---|---|---|
committer | Maxime Ripard <maxime.ripard@free-electrons.com> | 2017-01-23 05:45:02 -0500 |
commit | 7c09b858961df25a3bd1ac22e802525795338a6d (patch) | |
tree | 725afd33be597d655533de50cb85f377a45af4af | |
parent | 0c3c8e135897eb8e896a0bb82a5aff6c9bc158cc (diff) |
clk: sunxi-ng: Implement global pre-divider
Some clocks have a global pre-divider that applies to all their parents.
Since it might also apply to clocks that have a single parent, this is
merged in the ccu_common structure, unlike the other pre-divider settings
that are tied to a specific index, and thus a specific parent.
Acked-by: Chen-Yu Tsai <wens@csie.org>
Signed-off-by: Maxime Ripard <maxime.ripard@free-electrons.com>
-rw-r--r-- | drivers/clk/sunxi-ng/ccu_common.h | 2 | ||||
-rw-r--r-- | drivers/clk/sunxi-ng/ccu_mux.c | 8 |
2 files changed, 9 insertions, 1 deletions
diff --git a/drivers/clk/sunxi-ng/ccu_common.h b/drivers/clk/sunxi-ng/ccu_common.h index b3d9abfbd721..cdd69eb2e0b9 100644 --- a/drivers/clk/sunxi-ng/ccu_common.h +++ b/drivers/clk/sunxi-ng/ccu_common.h | |||
@@ -21,6 +21,7 @@ | |||
21 | #define CCU_FEATURE_VARIABLE_PREDIV BIT(1) | 21 | #define CCU_FEATURE_VARIABLE_PREDIV BIT(1) |
22 | #define CCU_FEATURE_FIXED_PREDIV BIT(2) | 22 | #define CCU_FEATURE_FIXED_PREDIV BIT(2) |
23 | #define CCU_FEATURE_FIXED_POSTDIV BIT(3) | 23 | #define CCU_FEATURE_FIXED_POSTDIV BIT(3) |
24 | #define CCU_FEATURE_ALL_PREDIV BIT(4) | ||
24 | 25 | ||
25 | struct device_node; | 26 | struct device_node; |
26 | 27 | ||
@@ -56,6 +57,7 @@ struct device_node; | |||
56 | struct ccu_common { | 57 | struct ccu_common { |
57 | void __iomem *base; | 58 | void __iomem *base; |
58 | u16 reg; | 59 | u16 reg; |
60 | u32 prediv; | ||
59 | 61 | ||
60 | unsigned long features; | 62 | unsigned long features; |
61 | spinlock_t *lock; | 63 | spinlock_t *lock; |
diff --git a/drivers/clk/sunxi-ng/ccu_mux.c b/drivers/clk/sunxi-ng/ccu_mux.c index a43ad52a957d..858a48621631 100644 --- a/drivers/clk/sunxi-ng/ccu_mux.c +++ b/drivers/clk/sunxi-ng/ccu_mux.c | |||
@@ -25,9 +25,15 @@ void ccu_mux_helper_adjust_parent_for_prediv(struct ccu_common *common, | |||
25 | int i; | 25 | int i; |
26 | 26 | ||
27 | if (!((common->features & CCU_FEATURE_FIXED_PREDIV) || | 27 | if (!((common->features & CCU_FEATURE_FIXED_PREDIV) || |
28 | (common->features & CCU_FEATURE_VARIABLE_PREDIV))) | 28 | (common->features & CCU_FEATURE_VARIABLE_PREDIV) || |
29 | (common->features & CCU_FEATURE_ALL_PREDIV))) | ||
29 | return; | 30 | return; |
30 | 31 | ||
32 | if (common->features & CCU_FEATURE_ALL_PREDIV) { | ||
33 | *parent_rate = *parent_rate / common->prediv; | ||
34 | return; | ||
35 | } | ||
36 | |||
31 | reg = readl(common->base + common->reg); | 37 | reg = readl(common->base + common->reg); |
32 | if (parent_index < 0) { | 38 | if (parent_index < 0) { |
33 | parent_index = reg >> cm->shift; | 39 | parent_index = reg >> cm->shift; |