clock_defs.h 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. /*
  2. * keystone2: common pll clock definitions
  3. * (C) Copyright 2012-2014
  4. * Texas Instruments Incorporated, <www.ti.com>
  5. *
  6. * SPDX-License-Identifier: GPL-2.0+
  7. */
  8. #ifndef _CLOCK_DEFS_H_
  9. #define _CLOCK_DEFS_H_
  10. #include <asm/arch/hardware.h>
  11. #define BIT(x) (1 << (x))
  12. /* PLL Control Registers */
  13. struct pllctl_regs {
  14. u32 ctl; /* 00 */
  15. u32 ocsel; /* 04 */
  16. u32 secctl; /* 08 */
  17. u32 resv0;
  18. u32 mult; /* 10 */
  19. u32 prediv; /* 14 */
  20. u32 div1; /* 18 */
  21. u32 div2; /* 1c */
  22. u32 div3; /* 20 */
  23. u32 oscdiv1; /* 24 */
  24. u32 resv1; /* 28 */
  25. u32 bpdiv; /* 2c */
  26. u32 wakeup; /* 30 */
  27. u32 resv2;
  28. u32 cmd; /* 38 */
  29. u32 stat; /* 3c */
  30. u32 alnctl; /* 40 */
  31. u32 dchange; /* 44 */
  32. u32 cken; /* 48 */
  33. u32 ckstat; /* 4c */
  34. u32 systat; /* 50 */
  35. u32 ckctl; /* 54 */
  36. u32 resv3[2];
  37. u32 div4; /* 60 */
  38. u32 div5; /* 64 */
  39. u32 div6; /* 68 */
  40. u32 div7; /* 6c */
  41. u32 div8; /* 70 */
  42. u32 div9; /* 74 */
  43. u32 div10; /* 78 */
  44. u32 div11; /* 7c */
  45. u32 div12; /* 80 */
  46. };
  47. static struct pllctl_regs *pllctl_regs[] = {
  48. (struct pllctl_regs *)(KS2_CLOCK_BASE + 0x100)
  49. };
  50. #define pllctl_reg(pll, reg) (&(pllctl_regs[pll]->reg))
  51. #define pllctl_reg_read(pll, reg) __raw_readl(pllctl_reg(pll, reg))
  52. #define pllctl_reg_write(pll, reg, val) __raw_writel(val, pllctl_reg(pll, reg))
  53. #define pllctl_reg_rmw(pll, reg, mask, val) \
  54. pllctl_reg_write(pll, reg, \
  55. (pllctl_reg_read(pll, reg) & ~(mask)) | val)
  56. #define pllctl_reg_setbits(pll, reg, mask) \
  57. pllctl_reg_rmw(pll, reg, 0, mask)
  58. #define pllctl_reg_clrbits(pll, reg, mask) \
  59. pllctl_reg_rmw(pll, reg, mask, 0)
  60. #define pll0div_read(N) ((pllctl_reg_read(CORE_PLL, div##N) & 0xff) + 1)
  61. /* PLLCTL Bits */
  62. #define PLLCTL_BYPASS BIT(23)
  63. #define PLL_PLLRST BIT(14)
  64. #define PLLCTL_PAPLL BIT(13)
  65. #define PLLCTL_CLKMODE BIT(8)
  66. #define PLLCTL_PLLSELB BIT(7)
  67. #define PLLCTL_ENSAT BIT(6)
  68. #define PLLCTL_PLLENSRC BIT(5)
  69. #define PLLCTL_PLLDIS BIT(4)
  70. #define PLLCTL_PLLRST BIT(3)
  71. #define PLLCTL_PLLPWRDN BIT(1)
  72. #define PLLCTL_PLLEN BIT(0)
  73. #define PLLSTAT_GO BIT(0)
  74. #define MAIN_ENSAT_OFFSET 6
  75. #define PLLDIV_ENABLE BIT(15)
  76. #define PLL_DIV_MASK 0x3f
  77. #define PLL_MULT_MASK 0x1fff
  78. #define PLL_MULT_SHIFT 6
  79. #define PLLM_MULT_HI_MASK 0x7f
  80. #define PLLM_MULT_HI_SHIFT 12
  81. #define PLLM_MULT_HI_SMASK (PLLM_MULT_HI_MASK << PLLM_MULT_HI_SHIFT)
  82. #define PLLM_MULT_LO_MASK 0x3f
  83. #define PLL_CLKOD_MASK 0xf
  84. #define PLL_CLKOD_SHIFT 19
  85. #define PLL_CLKOD_SMASK (PLL_CLKOD_MASK << PLL_CLKOD_SHIFT)
  86. #define PLL_BWADJ_LO_MASK 0xff
  87. #define PLL_BWADJ_LO_SHIFT 24
  88. #define PLL_BWADJ_LO_SMASK (PLL_BWADJ_LO_MASK << PLL_BWADJ_LO_SHIFT)
  89. #define PLL_BWADJ_HI_MASK 0xf
  90. #define PLLM_RATIO_DIV1 (PLLDIV_ENABLE | 0x0)
  91. #define PLLM_RATIO_DIV2 (PLLDIV_ENABLE | 0x0)
  92. #define PLLM_RATIO_DIV3 (PLLDIV_ENABLE | 0x1)
  93. #define PLLM_RATIO_DIV4 (PLLDIV_ENABLE | 0x4)
  94. #define PLLM_RATIO_DIV5 (PLLDIV_ENABLE | 0x17)
  95. #endif /* _CLOCK_DEFS_H_ */