clock_defs.h 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  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. /* PLL Control Registers */
  12. struct pllctl_regs {
  13. u32 ctl; /* 00 */
  14. u32 ocsel; /* 04 */
  15. u32 secctl; /* 08 */
  16. u32 resv0;
  17. u32 mult; /* 10 */
  18. u32 prediv; /* 14 */
  19. u32 div1; /* 18 */
  20. u32 div2; /* 1c */
  21. u32 div3; /* 20 */
  22. u32 oscdiv1; /* 24 */
  23. u32 resv1; /* 28 */
  24. u32 bpdiv; /* 2c */
  25. u32 wakeup; /* 30 */
  26. u32 resv2;
  27. u32 cmd; /* 38 */
  28. u32 stat; /* 3c */
  29. u32 alnctl; /* 40 */
  30. u32 dchange; /* 44 */
  31. u32 cken; /* 48 */
  32. u32 ckstat; /* 4c */
  33. u32 systat; /* 50 */
  34. u32 ckctl; /* 54 */
  35. u32 resv3[2];
  36. u32 div4; /* 60 */
  37. u32 div5; /* 64 */
  38. u32 div6; /* 68 */
  39. u32 div7; /* 6c */
  40. u32 div8; /* 70 */
  41. u32 div9; /* 74 */
  42. u32 div10; /* 78 */
  43. u32 div11; /* 7c */
  44. u32 div12; /* 80 */
  45. };
  46. static struct pllctl_regs *pllctl_regs[] = {
  47. (struct pllctl_regs *)(KS2_CLOCK_BASE + 0x100)
  48. };
  49. #define pllctl_reg(pll, reg) (&(pllctl_regs[pll]->reg))
  50. #define pllctl_reg_read(pll, reg) __raw_readl(pllctl_reg(pll, reg))
  51. #define pllctl_reg_write(pll, reg, val) __raw_writel(val, pllctl_reg(pll, reg))
  52. #define pllctl_reg_rmw(pll, reg, mask, val) \
  53. pllctl_reg_write(pll, reg, \
  54. (pllctl_reg_read(pll, reg) & ~(mask)) | val)
  55. #define pllctl_reg_setbits(pll, reg, mask) \
  56. pllctl_reg_rmw(pll, reg, 0, mask)
  57. #define pllctl_reg_clrbits(pll, reg, mask) \
  58. pllctl_reg_rmw(pll, reg, mask, 0)
  59. #define pll0div_read(N) ((pllctl_reg_read(CORE_PLL, div##N) & 0xff) + 1)
  60. /* PLLCTL Bits */
  61. #define PLLCTL_PLLENSRC_SHIF 5
  62. #define PLLCTL_PLLENSRC_MASK BIT(5)
  63. #define PLLCTL_PLLRST_SHIFT 3
  64. #define PLLCTL_PLLRST_MASK BIT(3)
  65. #define PLLCTL_PLLPWRDN_SHIFT 1
  66. #define PLLCTL_PLLPWRDN_MASK BIT(1)
  67. #define PLLCTL_PLLEN_SHIFT 0
  68. #define PLLCTL_PLLEN_MASK BIT(0)
  69. /* SECCTL Bits */
  70. #define SECCTL_BYPASS_SHIFT 23
  71. #define SECCTL_BYPASS_MASK BIT(23)
  72. #define SECCTL_OP_DIV_SHIFT 19
  73. #define SECCTL_OP_DIV_MASK (0xf << 19)
  74. /* PLLM Bits */
  75. #define PLLM_MULT_LO_SHIFT 0
  76. #define PLLM_MULT_LO_MASK 0x3f
  77. #define PLLM_MULT_LO_BITS 6
  78. /* PLLDIVn Bits */
  79. #define PLLDIV_ENABLE_SHIFT 15
  80. #define PLLDIV_ENABLE_MASK BIT(15)
  81. #define PLLDIV_RATIO_SHIFT 0x0
  82. #define PLLDIV_RATIO_MASK 0xff
  83. #define PLLDIV_MAX 16
  84. /* PLLCMD Bits */
  85. #define PLLCMD_GOSET_SHIFT 0
  86. #define PLLCMD_GOSET_MASK BIT(0)
  87. /* PLLSTAT Bits */
  88. #define PLLSTAT_GOSTAT_SHIFT 0
  89. #define PLLSTAT_GOSTAT_MASK BIT(0)
  90. /* Device Config PLLCTL0 */
  91. #define CFG_PLLCTL0_BWADJ_SHIFT 24
  92. #define CFG_PLLCTL0_BWADJ_MASK (0xff << 24)
  93. #define CFG_PLLCTL0_BWADJ_BITS 8
  94. #define CFG_PLLCTL0_BYPASS_SHIFT 23
  95. #define CFG_PLLCTL0_BYPASS_MASK BIT(23)
  96. #define CFG_PLLCTL0_CLKOD_SHIFT 19
  97. #define CFG_PLLCTL0_CLKOD_MASK (0xf << 19)
  98. #define CFG_PLLCTL0_PLLM_HI_SHIFT 12
  99. #define CFG_PLLCTL0_PLLM_HI_MASK (0x7f << 12)
  100. #define CFG_PLLCTL0_PLLM_SHIFT 6
  101. #define CFG_PLLCTL0_PLLM_MASK (0x1fff << 6)
  102. #define CFG_PLLCTL0_PLLD_SHIFT 0
  103. #define CFG_PLLCTL0_PLLD_MASK 0x3f
  104. /* Device Config PLLCTL1 */
  105. #define CFG_PLLCTL1_RST_SHIFT 14
  106. #define CFG_PLLCTL1_RST_MASK BIT(14)
  107. #define CFG_PLLCTL1_PAPLL_SHIFT 13
  108. #define CFG_PLLCTL1_PAPLL_MASK BIT(13)
  109. #define CFG_PLLCTL1_ENSAT_SHIFT 6
  110. #define CFG_PLLCTL1_ENSAT_MASK BIT(6)
  111. #define CFG_PLLCTL1_BWADJ_SHIFT 0
  112. #define CFG_PLLCTL1_BWADJ_MASK 0xf
  113. #define MISC_CTL1_ARM_PLL_EN BIT(13)
  114. #endif /* _CLOCK_DEFS_H_ */