clk-mux.h 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. /*
  3. * Copyright (c) 2018 MediaTek Inc.
  4. * Author: Owen Chen <owen.chen@mediatek.com>
  5. */
  6. #ifndef __DRV_CLK_MTK_MUX_H
  7. #define __DRV_CLK_MTK_MUX_H
  8. #include <linux/clk-provider.h>
  9. struct mtk_clk_mux {
  10. struct clk_hw hw;
  11. struct regmap *regmap;
  12. const struct mtk_mux *data;
  13. spinlock_t *lock;
  14. };
  15. struct mtk_mux {
  16. int id;
  17. const char *name;
  18. const char * const *parent_names;
  19. unsigned int flags;
  20. u32 mux_ofs;
  21. u32 set_ofs;
  22. u32 clr_ofs;
  23. u32 upd_ofs;
  24. u8 mux_shift;
  25. u8 mux_width;
  26. u8 gate_shift;
  27. s8 upd_shift;
  28. const struct clk_ops *ops;
  29. signed char num_parents;
  30. };
  31. extern const struct clk_ops mtk_mux_ops;
  32. extern const struct clk_ops mtk_mux_clr_set_upd_ops;
  33. extern const struct clk_ops mtk_mux_gate_ops;
  34. extern const struct clk_ops mtk_mux_gate_clr_set_upd_ops;
  35. #define GATE_CLR_SET_UPD_FLAGS(_id, _name, _parents, _mux_ofs, \
  36. _mux_set_ofs, _mux_clr_ofs, _shift, _width, \
  37. _gate, _upd_ofs, _upd, _flags, _ops) { \
  38. .id = _id, \
  39. .name = _name, \
  40. .mux_ofs = _mux_ofs, \
  41. .set_ofs = _mux_set_ofs, \
  42. .clr_ofs = _mux_clr_ofs, \
  43. .upd_ofs = _upd_ofs, \
  44. .mux_shift = _shift, \
  45. .mux_width = _width, \
  46. .gate_shift = _gate, \
  47. .upd_shift = _upd, \
  48. .parent_names = _parents, \
  49. .num_parents = ARRAY_SIZE(_parents), \
  50. .flags = _flags, \
  51. .ops = &_ops, \
  52. }
  53. #define MUX_GATE_CLR_SET_UPD_FLAGS(_id, _name, _parents, _mux_ofs, \
  54. _mux_set_ofs, _mux_clr_ofs, _shift, _width, \
  55. _gate, _upd_ofs, _upd, _flags) \
  56. GATE_CLR_SET_UPD_FLAGS(_id, _name, _parents, _mux_ofs, \
  57. _mux_set_ofs, _mux_clr_ofs, _shift, _width, \
  58. _gate, _upd_ofs, _upd, _flags, \
  59. mtk_mux_gate_clr_set_upd_ops)
  60. #define MUX_GATE_CLR_SET_UPD(_id, _name, _parents, _mux_ofs, \
  61. _mux_set_ofs, _mux_clr_ofs, _shift, _width, \
  62. _gate, _upd_ofs, _upd) \
  63. MUX_GATE_CLR_SET_UPD_FLAGS(_id, _name, _parents, \
  64. _mux_ofs, _mux_set_ofs, _mux_clr_ofs, _shift, \
  65. _width, _gate, _upd_ofs, _upd, \
  66. CLK_SET_RATE_PARENT)
  67. struct clk *mtk_clk_register_mux(const struct mtk_mux *mux,
  68. struct regmap *regmap,
  69. spinlock_t *lock);
  70. int mtk_clk_register_muxes(const struct mtk_mux *muxes,
  71. int num, struct device_node *node,
  72. spinlock_t *lock,
  73. struct clk_onecell_data *clk_data);
  74. #endif /* __DRV_CLK_MTK_MUX_H */