clk-regmap-mux-div.h 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. /*
  3. * Copyright (c) 2017, Linaro Limited
  4. * Author: Georgi Djakov <georgi.djakov@linaro.org>
  5. */
  6. #ifndef __QCOM_CLK_REGMAP_MUX_DIV_H__
  7. #define __QCOM_CLK_REGMAP_MUX_DIV_H__
  8. #include <linux/clk-provider.h>
  9. #include "clk-regmap.h"
  10. /**
  11. * struct mux_div_clk - combined mux/divider clock
  12. * @reg_offset: offset of the mux/divider register
  13. * @hid_width: number of bits in half integer divider
  14. * @hid_shift: lowest bit of hid value field
  15. * @src_width: number of bits in source select
  16. * @src_shift: lowest bit of source select field
  17. * @div: the divider raw configuration value
  18. * @src: the mux index which will be used if the clock is enabled
  19. * @safe_src: the safe source mux value we switch to, while the main PLL is
  20. * reconfigured
  21. * @safe_div: the safe divider value that we set, while the main PLL is
  22. * reconfigured
  23. * @safe_freq: When switching rates from A to B, the mux div clock will
  24. * instead switch from A -> safe_freq -> B. This allows the
  25. * mux_div clock to change rates while enabled, even if this
  26. * behavior is not supported by the parent clocks.
  27. * If changing the rate of parent A also causes the rate of
  28. * parent B to change, then safe_freq must be defined.
  29. * safe_freq is expected to have a source clock which is always
  30. * on and runs at only one rate.
  31. * @parent_map: pointer to parent_map struct
  32. * @clkr: handle between common and hardware-specific interfaces
  33. * @pclk: the input PLL clock
  34. * @clk_nb: clock notifier for rate changes of the input PLL
  35. */
  36. struct clk_regmap_mux_div {
  37. u32 reg_offset;
  38. u32 hid_width;
  39. u32 hid_shift;
  40. u32 src_width;
  41. u32 src_shift;
  42. u32 div;
  43. u32 src;
  44. u32 safe_src;
  45. u32 safe_div;
  46. unsigned long safe_freq;
  47. const struct parent_map *parent_map;
  48. struct clk_regmap clkr;
  49. struct clk *pclk;
  50. struct notifier_block clk_nb;
  51. };
  52. extern const struct clk_ops clk_regmap_mux_div_ops;
  53. extern int mux_div_set_src_div(struct clk_regmap_mux_div *md, u32 src, u32 div);
  54. int mux_div_get_src_div(struct clk_regmap_mux_div *md, u32 *src, u32 *div);
  55. #endif