ccu-pll.h 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * Copyright (C) 2020 BAIKAL ELECTRONICS, JSC
  4. *
  5. * Baikal-T1 CCU PLL interface driver
  6. */
  7. #ifndef __CLK_BT1_CCU_PLL_H__
  8. #define __CLK_BT1_CCU_PLL_H__
  9. #include <linux/clk-provider.h>
  10. #include <linux/spinlock.h>
  11. #include <linux/regmap.h>
  12. #include <linux/bits.h>
  13. #include <linux/of.h>
  14. /*
  15. * CCU PLL private flags
  16. * @CCU_PLL_BASIC: Basic PLL required by the kernel as early as possible.
  17. */
  18. #define CCU_PLL_BASIC BIT(0)
  19. /*
  20. * struct ccu_pll_init_data - CCU PLL initialization data
  21. * @id: Clock private identifier.
  22. * @name: Clocks name.
  23. * @parent_name: Clocks parent name in a fw node.
  24. * @base: PLL registers base address with respect to the sys_regs base.
  25. * @sys_regs: Baikal-T1 System Controller registers map.
  26. * @np: Pointer to the node describing the CCU PLLs.
  27. * @flags: PLL clock flags.
  28. * @features: PLL private features.
  29. */
  30. struct ccu_pll_init_data {
  31. unsigned int id;
  32. const char *name;
  33. const char *parent_name;
  34. unsigned int base;
  35. struct regmap *sys_regs;
  36. struct device_node *np;
  37. unsigned long flags;
  38. unsigned long features;
  39. };
  40. /*
  41. * struct ccu_pll - CCU PLL descriptor
  42. * @hw: clk_hw of the PLL.
  43. * @id: Clock private identifier.
  44. * @reg_ctl: PLL control register base.
  45. * @reg_ctl1: PLL control1 register base.
  46. * @sys_regs: Baikal-T1 System Controller registers map.
  47. * @lock: PLL state change spin-lock.
  48. */
  49. struct ccu_pll {
  50. struct clk_hw hw;
  51. unsigned int id;
  52. unsigned int reg_ctl;
  53. unsigned int reg_ctl1;
  54. struct regmap *sys_regs;
  55. spinlock_t lock;
  56. };
  57. #define to_ccu_pll(_hw) container_of(_hw, struct ccu_pll, hw)
  58. static inline struct clk_hw *ccu_pll_get_clk_hw(struct ccu_pll *pll)
  59. {
  60. return pll ? &pll->hw : NULL;
  61. }
  62. struct ccu_pll *ccu_pll_hw_register(const struct ccu_pll_init_data *init);
  63. void ccu_pll_hw_unregister(struct ccu_pll *pll);
  64. #endif /* __CLK_BT1_CCU_PLL_H__ */