clk-gate.h 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * Copyright (c) 2014 MediaTek Inc.
  4. * Author: James Liao <jamesjj.liao@mediatek.com>
  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. extern const struct clk_ops mtk_clk_gate_hwv_ops_setclr;
  19. extern const struct clk_ops mtk_clk_gate_hwv_ops_setclr_inv;
  20. struct mtk_gate_regs {
  21. u32 sta_ofs;
  22. u32 clr_ofs;
  23. u32 set_ofs;
  24. };
  25. struct mtk_gate {
  26. int id;
  27. const char *name;
  28. const char *parent_name;
  29. const struct mtk_gate_regs *regs;
  30. const struct mtk_gate_regs *hwv_regs;
  31. int shift;
  32. const struct clk_ops *ops;
  33. unsigned long flags;
  34. };
  35. #define GATE_MTK_FLAGS(_id, _name, _parent, _regs, _shift, \
  36. _ops, _flags) { \
  37. .id = _id, \
  38. .name = _name, \
  39. .parent_name = _parent, \
  40. .regs = _regs, \
  41. .shift = _shift, \
  42. .ops = _ops, \
  43. .flags = _flags, \
  44. }
  45. #define GATE_MTK(_id, _name, _parent, _regs, _shift, _ops) \
  46. GATE_MTK_FLAGS(_id, _name, _parent, _regs, _shift, _ops, 0)
  47. int mtk_clk_register_gates(struct device *dev, struct device_node *node,
  48. const struct mtk_gate *clks, int num,
  49. struct clk_hw_onecell_data *clk_data);
  50. void mtk_clk_unregister_gates(const struct mtk_gate *clks, int num,
  51. struct clk_hw_onecell_data *clk_data);
  52. #endif /* __DRV_CLK_GATE_H */