clk-regmap.h 2.8 KB

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