rk312x: add psci support
[firefly-linux-kernel-4.4.55.git] / drivers / clk / clk-mux.c
index 25b1734560d0c99bbae8455c78d22d613ccb99c0..b487b3cd5a4a8ed8c16f192119fbc70bd34ac57c 100644 (file)
@@ -86,8 +86,12 @@ static int clk_mux_set_parent(struct clk_hw *hw, u8 index)
        if (mux->lock)
                spin_lock_irqsave(mux->lock, flags);
 
-       val = readl(mux->reg);
-       val &= ~(mux->mask << mux->shift);
+       if (mux->flags & CLK_MUX_HIWORD_MASK) {
+               val = mux->mask << (mux->shift + 16);
+       } else {
+               val = readl(mux->reg);
+               val &= ~(mux->mask << mux->shift);
+       }
        val |= index << mux->shift;
        writel(val, mux->reg);
 
@@ -100,6 +104,7 @@ static int clk_mux_set_parent(struct clk_hw *hw, u8 index)
 const struct clk_ops clk_mux_ops = {
        .get_parent = clk_mux_get_parent,
        .set_parent = clk_mux_set_parent,
+       .determine_rate = __clk_mux_determine_rate,
 };
 EXPORT_SYMBOL_GPL(clk_mux_ops);
 
@@ -111,6 +116,15 @@ struct clk *clk_register_mux_table(struct device *dev, const char *name,
        struct clk_mux *mux;
        struct clk *clk;
        struct clk_init_data init;
+       u8 width = 0;
+
+       if (clk_mux_flags & CLK_MUX_HIWORD_MASK) {
+               width = fls(mask) - ffs(mask) + 1;
+               if (width + shift > 16) {
+                       pr_err("mux value exceeds LOWORD field\n");
+                       return ERR_PTR(-EINVAL);
+               }
+       }
 
        /* allocate the mux */
        mux = kzalloc(sizeof(struct clk_mux), GFP_KERNEL);