kernel: bump 4.14 to 4.14.48 for 18.06
[openwrt/openwrt.git] / target / linux / ipq806x / patches-4.14 / 0035-clk-mux-Split-out-register-accessors-for-reuse.patch
index 43b25a3c5152c3891ecb59431ac04ed9cfd7d2c8..0d919ee668fc18302d41002aa5f1eccd7e94d3f7 100644 (file)
@@ -34,13 +34,13 @@ Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
 @@ -26,35 +26,24 @@
   * parent - parent is adjustable through clk_set_parent
   */
-
 -static u8 clk_mux_get_parent(struct clk_hw *hw)
 +unsigned int clk_mux_get_parent(struct clk_hw *hw, unsigned int val,
 +                              unsigned int *table, unsigned long flags)
  {
 -      struct clk_mux *mux = to_clk_mux(hw);
-       int num_parents = clk_hw_get_num_parents(hw);
+       int num_parents = clk_hw_get_num_parents(hw);
 -      u32 val;
 -
 -      /*
@@ -52,40 +52,40 @@ Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
 -       */
 -      val = clk_readl(mux->reg) >> mux->shift;
 -      val &= mux->mask;
-
 -      if (mux->table) {
 +      if (table) {
-               int i;
-
-               for (i = 0; i < num_parents; i++)
+               int i;
+               for (i = 0; i < num_parents; i++)
 -                      if (mux->table[i] == val)
 +                      if (table[i] == val)
-                               return i;
-               return -EINVAL;
-       }
-
+                               return i;
+               return -EINVAL;
+       }
 -      if (val && (mux->flags & CLK_MUX_INDEX_BIT))
 +      if (val && (flags & CLK_MUX_INDEX_BIT))
-               val = ffs(val) - 1;
-
+               val = ffs(val) - 1;
 -      if (val && (mux->flags & CLK_MUX_INDEX_ONE))
 +      if (val && (flags & CLK_MUX_INDEX_ONE))
-               val--;
-
-       if (val >= num_parents)
+               val--;
+       if (val >= num_parents)
 @@ -62,23 +51,53 @@ static u8 clk_mux_get_parent(struct clk_
-
-       return val;
+       return val;
  }
 +EXPORT_SYMBOL_GPL(clk_mux_get_parent);
-
 -static int clk_mux_set_parent(struct clk_hw *hw, u8 index)
 +static u8 _clk_mux_get_parent(struct clk_hw *hw)
  {
-       struct clk_mux *mux = to_clk_mux(hw);
-       u32 val;
+       struct clk_mux *mux = to_clk_mux(hw);
+       u32 val;
 -      unsigned long flags = 0;
-
 -      if (mux->table) {
 -              index = mux->table[index];
 +      /*
@@ -108,18 +108,18 @@ Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
 +
 +      if (table) {
 +              val = table[val];
-       } else {
+       } else {
 -              if (mux->flags & CLK_MUX_INDEX_BIT)
 -                      index = 1 << index;
 +              if (flags & CLK_MUX_INDEX_BIT)
 +                      val = 1 << index;
-
 -              if (mux->flags & CLK_MUX_INDEX_ONE)
 -                      index++;
 +              if (flags & CLK_MUX_INDEX_ONE)
 +                      val++;
-       }
-
+       }
 +      return val;
 +}
 +EXPORT_SYMBOL_GPL(clk_mux_reindex);
@@ -132,64 +132,64 @@ Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
 +
 +      index = clk_mux_reindex(index, mux->table, mux->flags);
 +
-       if (mux->lock)
-               spin_lock_irqsave(mux->lock, flags);
-       else
+       if (mux->lock)
+               spin_lock_irqsave(mux->lock, flags);
+       else
 @@ -102,14 +121,14 @@ static int clk_mux_set_parent(struct clk
  }
-
  const struct clk_ops clk_mux_ops = {
 -      .get_parent = clk_mux_get_parent,
 +      .get_parent = _clk_mux_get_parent,
-       .set_parent = clk_mux_set_parent,
-       .determine_rate = __clk_mux_determine_rate,
+       .set_parent = clk_mux_set_parent,
+       .determine_rate = __clk_mux_determine_rate,
  };
  EXPORT_SYMBOL_GPL(clk_mux_ops);
-
  const struct clk_ops clk_mux_ro_ops = {
 -      .get_parent = clk_mux_get_parent,
 +      .get_parent = _clk_mux_get_parent,
  };
  EXPORT_SYMBOL_GPL(clk_mux_ro_ops);
-
 @@ -117,7 +136,7 @@ struct clk_hw *clk_hw_register_mux_table
-               const char * const *parent_names, u8 num_parents,
-               unsigned long flags,
-               void __iomem *reg, u8 shift, u32 mask,
+               const char * const *parent_names, u8 num_parents,
+               unsigned long flags,
+               void __iomem *reg, u8 shift, u32 mask,
 -              u8 clk_mux_flags, u32 *table, spinlock_t *lock)
 +              u8 clk_mux_flags, unsigned int *table, spinlock_t *lock)
  {
-       struct clk_mux *mux;
-       struct clk_hw *hw;
+       struct clk_mux *mux;
+       struct clk_hw *hw;
 --- a/include/linux/clk-provider.h
 +++ b/include/linux/clk-provider.h
 @@ -468,7 +468,7 @@ void clk_hw_unregister_divider(struct cl
  struct clk_mux {
-       struct clk_hw   hw;
-       void __iomem    *reg;
+       struct clk_hw   hw;
+       void __iomem    *reg;
 -      u32             *table;
 +      unsigned int    *table;
-       u32             mask;
-       u8              shift;
-       u8              flags;
+       u32             mask;
+       u8              shift;
+       u8              flags;
 @@ -486,6 +486,11 @@ struct clk_mux {
  extern const struct clk_ops clk_mux_ops;
  extern const struct clk_ops clk_mux_ro_ops;
-
 +unsigned int clk_mux_get_parent(struct clk_hw *hw, unsigned int val,
 +                              unsigned int *table, unsigned long flags);
 +unsigned int clk_mux_reindex(u8 index, unsigned int *table,
 +                           unsigned long flags);
 +
  struct clk *clk_register_mux(struct device *dev, const char *name,
-               const char * const *parent_names, u8 num_parents,
-               unsigned long flags,
+               const char * const *parent_names, u8 num_parents,
+               unsigned long flags,
 @@ -506,7 +511,7 @@ struct clk_hw *clk_hw_register_mux_table
-               const char * const *parent_names, u8 num_parents,
-               unsigned long flags,
-               void __iomem *reg, u8 shift, u32 mask,
+               const char * const *parent_names, u8 num_parents,
+               unsigned long flags,
+               void __iomem *reg, u8 shift, u32 mask,
 -              u8 clk_mux_flags, u32 *table, spinlock_t *lock);
 +              u8 clk_mux_flags, unsigned int *table, spinlock_t *lock);
-
  void clk_unregister_mux(struct clk *clk);
  void clk_hw_unregister_mux(struct clk_hw *hw);