Merge branch 'clk-frac-divider' into clk-next
authorStephen Boyd <sboyd@kernel.org>
Wed, 1 Sep 2021 22:26:42 +0000 (15:26 -0700)
committerStephen Boyd <sboyd@kernel.org>
Wed, 1 Sep 2021 22:26:45 +0000 (15:26 -0700)
 - Add power of two flag to fractional divider clk type

* clk-frac-divider:
  clk: fractional-divider: Document the arithmetics used behind the code
  clk: fractional-divider: Introduce POWER_OF_TWO_PS flag
  clk: fractional-divider: Hide clk_fractional_divider_ops from wide audience
  clk: fractional-divider: Export approximation algorithm to the CCF users

1  2 
drivers/acpi/acpi_lpss.c
include/linux/clk-provider.h

diff --combined drivers/acpi/acpi_lpss.c
@@@ -385,9 -385,7 +385,9 @@@ static struct platform_device *lpss_clk
  
  static inline void lpt_register_clock_device(void)
  {
 -      lpss_clk_dev = platform_device_register_simple("clk-lpt", -1, NULL, 0);
 +      lpss_clk_dev = platform_device_register_simple("clk-lpss-atom",
 +                                                     PLATFORM_DEVID_NONE,
 +                                                     NULL, 0);
  }
  
  static int register_device_clock(struct acpi_device *adev,
                if (!clk_name)
                        return -ENOMEM;
                clk = clk_register_fractional_divider(NULL, clk_name, parent,
-                                                     0, prv_base,
-                                                     1, 15, 16, 15, 0, NULL);
+                                                     CLK_FRAC_DIVIDER_POWER_OF_TWO_PS,
+                                                     prv_base, 1, 15, 16, 15, 0, NULL);
                parent = clk_name;
  
                clk_name = kasprintf(GFP_KERNEL, "%s-update", devname);
@@@ -1339,7 -1337,7 +1339,7 @@@ void __init acpi_lpss_init(void
        const struct x86_cpu_id *id;
        int ret;
  
 -      ret = lpt_clk_init();
 +      ret = lpss_atom_clk_init();
        if (ret)
                return;
  
@@@ -342,7 -342,7 +342,7 @@@ struct clk_fixed_rate 
        unsigned long   flags;
  };
  
 -#define CLK_FIXED_RATE_PARENT_ACCURACY                BIT(0)
 +#define CLK_FIXED_RATE_PARENT_ACCURACY        BIT(0)
  
  extern const struct clk_ops clk_fixed_rate_ops;
  struct clk_hw *__clk_hw_register_fixed_rate(struct device *dev,
@@@ -1001,6 -1001,12 +1001,12 @@@ struct clk_hw *devm_clk_hw_register_fix
   * CLK_FRAC_DIVIDER_BIG_ENDIAN - By default little endian register accesses are
   *    used for the divider register.  Setting this flag makes the register
   *    accesses big endian.
+  * CLK_FRAC_DIVIDER_POWER_OF_TWO_PS - By default the resulting fraction might
+  *    be saturated and the caller will get quite far from the good enough
+  *    approximation. Instead the caller may require, by setting this flag,
+  *    to shift left by a few bits in case, when the asked one is quite small
+  *    to satisfy the desired range of denominator. It assumes that on the
+  *    caller's side the power-of-two capable prescaler exists.
   */
  struct clk_fractional_divider {
        struct clk_hw   hw;
  
  #define to_clk_fd(_hw) container_of(_hw, struct clk_fractional_divider, hw)
  
- #define CLK_FRAC_DIVIDER_ZERO_BASED   BIT(0)
- #define CLK_FRAC_DIVIDER_BIG_ENDIAN   BIT(1)
+ #define CLK_FRAC_DIVIDER_ZERO_BASED           BIT(0)
+ #define CLK_FRAC_DIVIDER_BIG_ENDIAN           BIT(1)
+ #define CLK_FRAC_DIVIDER_POWER_OF_TWO_PS      BIT(2)
  
- extern const struct clk_ops clk_fractional_divider_ops;
  struct clk *clk_register_fractional_divider(struct device *dev,
                const char *name, const char *parent_name, unsigned long flags,
                void __iomem *reg, u8 mshift, u8 mwidth, u8 nshift, u8 nwidth,
@@@ -1069,9 -1075,9 +1075,9 @@@ struct clk_multiplier 
  
  #define to_clk_multiplier(_hw) container_of(_hw, struct clk_multiplier, hw)
  
 -#define CLK_MULTIPLIER_ZERO_BYPASS            BIT(0)
 +#define CLK_MULTIPLIER_ZERO_BYPASS    BIT(0)
  #define CLK_MULTIPLIER_ROUND_CLOSEST  BIT(1)
 -#define CLK_MULTIPLIER_BIG_ENDIAN             BIT(2)
 +#define CLK_MULTIPLIER_BIG_ENDIAN     BIT(2)
  
  extern const struct clk_ops clk_multiplier_ops;