Skip to content

Commit

Permalink
clk: sunxi-ng: Implement global pre-divider
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Maxime Ripard committed Jan 23, 2017
1 parent 0c3c8e1 commit 7c09b85
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 2 additions & 0 deletions drivers/clk/sunxi-ng/ccu_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#define CCU_FEATURE_VARIABLE_PREDIV BIT(1)
#define CCU_FEATURE_FIXED_PREDIV BIT(2)
#define CCU_FEATURE_FIXED_POSTDIV BIT(3)
#define CCU_FEATURE_ALL_PREDIV BIT(4)

struct device_node;

Expand Down Expand Up @@ -56,6 +57,7 @@ struct device_node;
struct ccu_common {
void __iomem *base;
u16 reg;
u32 prediv;

unsigned long features;
spinlock_t *lock;
Expand Down
8 changes: 7 additions & 1 deletion drivers/clk/sunxi-ng/ccu_mux.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,15 @@ void ccu_mux_helper_adjust_parent_for_prediv(struct ccu_common *common,
int i;

if (!((common->features & CCU_FEATURE_FIXED_PREDIV) ||
(common->features & CCU_FEATURE_VARIABLE_PREDIV)))
(common->features & CCU_FEATURE_VARIABLE_PREDIV) ||
(common->features & CCU_FEATURE_ALL_PREDIV)))
return;

if (common->features & CCU_FEATURE_ALL_PREDIV) {
*parent_rate = *parent_rate / common->prediv;
return;
}

reg = readl(common->base + common->reg);
if (parent_index < 0) {
parent_index = reg >> cm->shift;
Expand Down

0 comments on commit 7c09b85

Please sign in to comment.