Skip to content

Commit 7c09b85

Browse files
committed
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>
1 parent 0c3c8e1 commit 7c09b85

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

drivers/clk/sunxi-ng/ccu_common.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
#define CCU_FEATURE_VARIABLE_PREDIV BIT(1)
2222
#define CCU_FEATURE_FIXED_PREDIV BIT(2)
2323
#define CCU_FEATURE_FIXED_POSTDIV BIT(3)
24+
#define CCU_FEATURE_ALL_PREDIV BIT(4)
2425

2526
struct device_node;
2627

@@ -56,6 +57,7 @@ struct device_node;
5657
struct ccu_common {
5758
void __iomem *base;
5859
u16 reg;
60+
u32 prediv;
5961

6062
unsigned long features;
6163
spinlock_t *lock;

drivers/clk/sunxi-ng/ccu_mux.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,15 @@ void ccu_mux_helper_adjust_parent_for_prediv(struct ccu_common *common,
2525
int i;
2626

2727
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)))
2930
return;
3031

32+
if (common->features & CCU_FEATURE_ALL_PREDIV) {
33+
*parent_rate = *parent_rate / common->prediv;
34+
return;
35+
}
36+
3137
reg = readl(common->base + common->reg);
3238
if (parent_index < 0) {
3339
parent_index = reg >> cm->shift;

0 commit comments

Comments
 (0)