clk-gate.h 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * Copyright (c) 2014 MediaTek Inc.
  4. * Author: James Liao <[email protected]>
  5. */
  6. #ifndef __DRV_CLK_GATE_H
  7. #define __DRV_CLK_GATE_H
  8. #include <linux/types.h>
  9. struct clk;
  10. struct clk_hw_onecell_data;
  11. struct clk_ops;
  12. struct device;
  13. struct device_node;
  14. extern const struct clk_ops mtk_clk_gate_ops_setclr;
  15. extern const struct clk_ops mtk_clk_gate_ops_setclr_inv;
  16. extern const struct clk_ops mtk_clk_gate_ops_no_setclr;
  17. extern const struct clk_ops mtk_clk_gate_ops_no_setclr_inv;
  18. struct mtk_gate_regs {
  19. u32 sta_ofs;
  20. u32 clr_ofs;
  21. u32 set_ofs;
  22. };
  23. struct mtk_gate {
  24. int id;
  25. const char *name;
  26. const char *parent_name;
  27. const struct mtk_gate_regs *regs;
  28. int shift;
  29. const struct clk_ops *ops;
  30. unsigned long flags;
  31. };
  32. #define GATE_MTK_FLAGS(_id, _name, _parent, _regs, _shift, \
  33. _ops, _flags) { \
  34. .id = _id, \
  35. .name = _name, \
  36. .parent_name = _parent, \
  37. .regs = _regs, \
  38. .shift = _shift, \
  39. .ops = _ops, \
  40. .flags = _flags, \
  41. }
  42. #define GATE_MTK(_id, _name, _parent, _regs, _shift, _ops) \
  43. GATE_MTK_FLAGS(_id, _name, _parent, _regs, _shift, _ops, 0)
  44. int mtk_clk_register_gates(struct device_node *node,
  45. const struct mtk_gate *clks, int num,
  46. struct clk_hw_onecell_data *clk_data);
  47. int mtk_clk_register_gates_with_dev(struct device_node *node,
  48. const struct mtk_gate *clks, int num,
  49. struct clk_hw_onecell_data *clk_data,
  50. struct device *dev);
  51. void mtk_clk_unregister_gates(const struct mtk_gate *clks, int num,
  52. struct clk_hw_onecell_data *clk_data);
  53. #endif /* __DRV_CLK_GATE_H */