clk-regmap.h 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. // SPDX-License-Identifier: GPL-2.0
  2. // Copyright (c) 2018 BayLibre, SAS.
  3. // Author: Jerome Brunet <jbrunet@baylibre.com>
  4. #ifndef __CLK_REGMAP_H
  5. #define __CLK_REGMAP_H
  6. #include <linux/clk-provider.h>
  7. #include <linux/regmap.h>
  8. /**
  9. * struct clk_regmap - regmap backed clock
  10. *
  11. * @hw: handle between common and hardware-specific interfaces
  12. * @map: pointer to the regmap structure controlling the clock
  13. * @data: data specific to the clock type
  14. *
  15. * Clock which is controlled by regmap backed registers. The actual type of
  16. * of the clock is controlled by the clock_ops and data.
  17. */
  18. struct clk_regmap {
  19. struct clk_hw hw;
  20. struct regmap *map;
  21. void *data;
  22. };
  23. #define to_clk_regmap(_hw) container_of(_hw, struct clk_regmap, hw)
  24. /**
  25. * struct clk_regmap_gate_data - regmap backed gate specific data
  26. *
  27. * @offset: offset of the register controlling gate
  28. * @bit_idx: single bit controlling gate
  29. * @flags: hardware-specific flags
  30. *
  31. * Flags:
  32. * Same as clk_gate except CLK_GATE_HIWORD_MASK which is ignored
  33. */
  34. struct clk_regmap_gate_data {
  35. unsigned int offset;
  36. u8 bit_idx;
  37. u8 flags;
  38. };
  39. static inline struct clk_regmap_gate_data *
  40. clk_get_regmap_gate_data(struct clk_regmap *clk)
  41. {
  42. return (struct clk_regmap_gate_data *)clk->data;
  43. }
  44. extern const struct clk_ops clk_regmap_gate_ops;
  45. /**
  46. * struct clk_regmap_div_data - regmap backed adjustable divider specific data
  47. *
  48. * @offset: offset of the register controlling the divider
  49. * @shift: shift to the divider bit field
  50. * @width: width of the divider bit field
  51. * @table: array of value/divider pairs, last entry should have div = 0
  52. *
  53. * Flags:
  54. * Same as clk_divider except CLK_DIVIDER_HIWORD_MASK which is ignored
  55. */
  56. struct clk_regmap_div_data {
  57. unsigned int offset;
  58. u8 shift;
  59. u8 width;
  60. u8 flags;
  61. const struct clk_div_table *table;
  62. };
  63. static inline struct clk_regmap_div_data *
  64. clk_get_regmap_div_data(struct clk_regmap *clk)
  65. {
  66. return (struct clk_regmap_div_data *)clk->data;
  67. }
  68. extern const struct clk_ops clk_regmap_divider_ops;
  69. extern const struct clk_ops clk_regmap_divider_ro_ops;
  70. /**
  71. * struct clk_regmap_mux_data - regmap backed multiplexer clock specific data
  72. *
  73. * @hw: handle between common and hardware-specific interfaces
  74. * @offset: offset of theregister controlling multiplexer
  75. * @table: array of parent indexed register values
  76. * @shift: shift to multiplexer bit field
  77. * @mask: mask of mutliplexer bit field
  78. * @flags: hardware-specific flags
  79. *
  80. * Flags:
  81. * Same as clk_divider except CLK_MUX_HIWORD_MASK which is ignored
  82. */
  83. struct clk_regmap_mux_data {
  84. unsigned int offset;
  85. u32 *table;
  86. u32 mask;
  87. u8 shift;
  88. u8 flags;
  89. };
  90. static inline struct clk_regmap_mux_data *
  91. clk_get_regmap_mux_data(struct clk_regmap *clk)
  92. {
  93. return (struct clk_regmap_mux_data *)clk->data;
  94. }
  95. extern const struct clk_ops clk_regmap_mux_ops;
  96. extern const struct clk_ops clk_regmap_mux_ro_ops;
  97. #endif /* __CLK_REGMAP_H */