clk: sunxi-ng: Implement global pre-divider
authorMaxime Ripard <maxime.ripard@free-electrons.com>
Thu, 19 Jan 2017 21:49:26 +0000 (22:49 +0100)
committerMaxime Ripard <maxime.ripard@free-electrons.com>
Mon, 23 Jan 2017 10:45:02 +0000 (11:45 +0100)
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>
drivers/clk/sunxi-ng/ccu_common.h
drivers/clk/sunxi-ng/ccu_mux.c

index b3d9abfbd721d6f1def3e366044e8bd13fa1fe94..cdd69eb2e0b9d37944af13c99ded28f1542b09dc 100644 (file)
@@ -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;
 
@@ -56,6 +57,7 @@ struct device_node;
 struct ccu_common {
        void __iomem    *base;
        u16             reg;
+       u32             prediv;
 
        unsigned long   features;
        spinlock_t      *lock;
index a43ad52a957dcbd104ae29a67ecdf4e057038bf1..858a486216311337b4442105e9d7a3380b1cca37 100644 (file)
@@ -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;