clk-scu.h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. /* SPDX-License-Identifier: GPL-2.0+ */
  2. /*
  3. * Copyright 2018-2021 NXP
  4. * Dong Aisheng <[email protected]>
  5. */
  6. #ifndef __IMX_CLK_SCU_H
  7. #define __IMX_CLK_SCU_H
  8. #include <linux/firmware/imx/sci.h>
  9. #include <linux/of.h>
  10. #define IMX_SCU_GPR_CLK_GATE BIT(0)
  11. #define IMX_SCU_GPR_CLK_DIV BIT(1)
  12. #define IMX_SCU_GPR_CLK_MUX BIT(2)
  13. struct imx_clk_scu_rsrc_table {
  14. const u32 *rsrc;
  15. u8 num;
  16. };
  17. extern struct list_head imx_scu_clks[];
  18. extern const struct dev_pm_ops imx_clk_lpcg_scu_pm_ops;
  19. extern const struct imx_clk_scu_rsrc_table imx_clk_scu_rsrc_imx8dxl;
  20. extern const struct imx_clk_scu_rsrc_table imx_clk_scu_rsrc_imx8qxp;
  21. extern const struct imx_clk_scu_rsrc_table imx_clk_scu_rsrc_imx8qm;
  22. int imx_clk_scu_init(struct device_node *np,
  23. const struct imx_clk_scu_rsrc_table *data);
  24. struct clk_hw *imx_scu_of_clk_src_get(struct of_phandle_args *clkspec,
  25. void *data);
  26. struct clk_hw *imx_clk_scu_alloc_dev(const char *name,
  27. const char * const *parents,
  28. int num_parents, u32 rsrc_id, u8 clk_type);
  29. struct clk_hw *__imx_clk_scu(struct device *dev, const char *name,
  30. const char * const *parents, int num_parents,
  31. u32 rsrc_id, u8 clk_type);
  32. void imx_clk_scu_unregister(void);
  33. struct clk_hw *__imx_clk_lpcg_scu(struct device *dev, const char *name,
  34. const char *parent_name, unsigned long flags,
  35. void __iomem *reg, u8 bit_idx, bool hw_gate);
  36. void imx_clk_lpcg_scu_unregister(struct clk_hw *hw);
  37. struct clk_hw *__imx_clk_gpr_scu(const char *name, const char * const *parent_name,
  38. int num_parents, u32 rsrc_id, u8 gpr_id, u8 flags,
  39. bool invert);
  40. static inline struct clk_hw *imx_clk_scu(const char *name, u32 rsrc_id,
  41. u8 clk_type)
  42. {
  43. return imx_clk_scu_alloc_dev(name, NULL, 0, rsrc_id, clk_type);
  44. }
  45. static inline struct clk_hw *imx_clk_scu2(const char *name, const char * const *parents,
  46. int num_parents, u32 rsrc_id, u8 clk_type)
  47. {
  48. return imx_clk_scu_alloc_dev(name, parents, num_parents, rsrc_id, clk_type);
  49. }
  50. static inline struct clk_hw *imx_clk_lpcg_scu_dev(struct device *dev, const char *name,
  51. const char *parent_name, unsigned long flags,
  52. void __iomem *reg, u8 bit_idx, bool hw_gate)
  53. {
  54. return __imx_clk_lpcg_scu(dev, name, parent_name, flags, reg,
  55. bit_idx, hw_gate);
  56. }
  57. static inline struct clk_hw *imx_clk_lpcg_scu(const char *name, const char *parent_name,
  58. unsigned long flags, void __iomem *reg,
  59. u8 bit_idx, bool hw_gate)
  60. {
  61. return __imx_clk_lpcg_scu(NULL, name, parent_name, flags, reg,
  62. bit_idx, hw_gate);
  63. }
  64. static inline struct clk_hw *imx_clk_gate_gpr_scu(const char *name, const char *parent_name,
  65. u32 rsrc_id, u8 gpr_id, bool invert)
  66. {
  67. return __imx_clk_gpr_scu(name, &parent_name, 1, rsrc_id, gpr_id,
  68. IMX_SCU_GPR_CLK_GATE, invert);
  69. }
  70. static inline struct clk_hw *imx_clk_divider_gpr_scu(const char *name, const char *parent_name,
  71. u32 rsrc_id, u8 gpr_id)
  72. {
  73. return __imx_clk_gpr_scu(name, &parent_name, 1, rsrc_id, gpr_id,
  74. IMX_SCU_GPR_CLK_DIV, 0);
  75. }
  76. static inline struct clk_hw *imx_clk_mux_gpr_scu(const char *name, const char * const *parent_names,
  77. int num_parents, u32 rsrc_id, u8 gpr_id)
  78. {
  79. return __imx_clk_gpr_scu(name, parent_names, num_parents, rsrc_id,
  80. gpr_id, IMX_SCU_GPR_CLK_MUX, 0);
  81. }
  82. #endif