gate.h 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. // SPDX-License-Identifier: GPL-2.0
  2. //
  3. // Spreadtrum gate clock driver
  4. //
  5. // Copyright (C) 2017 Spreadtrum, Inc.
  6. // Author: Chunyan Zhang <chunyan.zhang@spreadtrum.com>
  7. #ifndef _SPRD_GATE_H_
  8. #define _SPRD_GATE_H_
  9. #include "common.h"
  10. struct sprd_gate {
  11. u32 enable_mask;
  12. u16 flags;
  13. u16 sc_offset;
  14. struct sprd_clk_common common;
  15. };
  16. #define SPRD_SC_GATE_CLK_OPS(_struct, _name, _parent, _reg, _sc_offset, \
  17. _enable_mask, _flags, _gate_flags, _ops) \
  18. struct sprd_gate _struct = { \
  19. .enable_mask = _enable_mask, \
  20. .sc_offset = _sc_offset, \
  21. .flags = _gate_flags, \
  22. .common = { \
  23. .regmap = NULL, \
  24. .reg = _reg, \
  25. .hw.init = CLK_HW_INIT(_name, \
  26. _parent, \
  27. _ops, \
  28. _flags), \
  29. } \
  30. }
  31. #define SPRD_GATE_CLK(_struct, _name, _parent, _reg, \
  32. _enable_mask, _flags, _gate_flags) \
  33. SPRD_SC_GATE_CLK_OPS(_struct, _name, _parent, _reg, 0, \
  34. _enable_mask, _flags, _gate_flags, \
  35. &sprd_gate_ops)
  36. #define SPRD_SC_GATE_CLK(_struct, _name, _parent, _reg, _sc_offset, \
  37. _enable_mask, _flags, _gate_flags) \
  38. SPRD_SC_GATE_CLK_OPS(_struct, _name, _parent, _reg, _sc_offset, \
  39. _enable_mask, _flags, _gate_flags, \
  40. &sprd_sc_gate_ops)
  41. static inline struct sprd_gate *hw_to_sprd_gate(const struct clk_hw *hw)
  42. {
  43. struct sprd_clk_common *common = hw_to_sprd_clk_common(hw);
  44. return container_of(common, struct sprd_gate, common);
  45. }
  46. extern const struct clk_ops sprd_gate_ops;
  47. extern const struct clk_ops sprd_sc_gate_ops;
  48. #endif /* _SPRD_GATE_H_ */