pwm_context.h 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198
  1. #ifndef ZEPHYR_DRIVERS_PWM_SPI_CONTEXT_H_
  2. #define ZEPHYR_DRIVERS_PWM_SPI_CONTEXT_H_
  3. /* pwm reg list */
  4. #define PWM0_BASE(base) (0 + base)
  5. #define PWM1_BASE(base) (0x100 + base)
  6. #define PWM2_BASE(base) (0x200 + base)
  7. #define PWM3_BASE(base) (0x300 + base)
  8. #define PWM4_BASE(base) (0x400 + base)
  9. #define PWM5_BASE(base) (0x500 + base)
  10. #define PWM_FIFO(base) (0xa00 + base)
  11. #define PWM_IR(base) (0xb00 + base)
  12. #define PWM_INT_CTL(base) (0xc00 + base)
  13. #define PWM_PENDING(base) (0xc04 + base)
  14. #define PWM_BREATH(base) (0x30 + base)
  15. #define PWM_BREATH_REG_SIZE (0x20)
  16. /* pwm control registers */
  17. struct acts_pwm_group0 {
  18. volatile u32_t ctrl;
  19. volatile u32_t ch_ctrl0;
  20. volatile u32_t ch_ctrl1;
  21. volatile u32_t repeat;
  22. volatile u32_t cntmax;
  23. volatile u32_t cmp[6];
  24. volatile u32_t dt;
  25. };
  26. /* group1 */
  27. struct acts_pwm_group1 {
  28. volatile u32_t ctrl;
  29. volatile u32_t ch_ctrl0;
  30. volatile u32_t ch_ctrl1;
  31. volatile u32_t repeat;
  32. volatile u32_t cntmax;
  33. volatile u32_t cmp[6];
  34. };
  35. /* group 1 breath mode reg */
  36. struct acts_pwm_breath_mode {
  37. volatile u32_t pwm_bth_a;
  38. volatile u32_t pwm_bth_b;
  39. volatile u32_t pwm_bth_c;
  40. volatile u32_t pwm_bth_d;
  41. volatile u32_t pwm_bth_e;
  42. volatile u32_t pwm_bth_f;
  43. volatile u32_t pwm_bth_hl;
  44. volatile u32_t pwm_bth_st;
  45. };
  46. /* group 2~5 */
  47. struct acts_pwm_groupx {
  48. volatile u32_t ctrl;
  49. volatile u32_t ch_ctrl0;
  50. volatile u32_t reserve;
  51. volatile u32_t repeat;
  52. volatile u32_t cntmax;
  53. volatile u32_t cmp[1];
  54. };
  55. /* fifo */
  56. struct acts_pwm_fifo {
  57. volatile u32_t fifoctl;
  58. volatile u32_t fifodat;
  59. volatile u32_t fifosta;
  60. };
  61. /* IR */
  62. struct acts_pwm_ir {
  63. volatile u32_t ir_period;
  64. volatile u32_t ir_duty;
  65. volatile u32_t ir_lc;
  66. volatile u32_t ir_pl0_pre;
  67. volatile u32_t ir_pl0_post;
  68. volatile u32_t ir_pl1_pre;
  69. volatile u32_t ir_pl1_post;
  70. volatile u32_t ir_ll;
  71. volatile u32_t ir_ld;
  72. volatile u32_t ir_pl;
  73. volatile u32_t ir_pd0;
  74. volatile u32_t ir_pd1;
  75. volatile u32_t reserve[2];
  76. volatile u32_t ir_sl;
  77. volatile u32_t ir_asc;
  78. volatile u32_t ir_ctl;
  79. };
  80. /* pwm ctl */
  81. #define PWMx_CTRL_HUC(x) (1 << (22 + x))//chan : 0~5
  82. #define PWMx_CTRL_HUA (1 << 21)
  83. #define PWMx_CTRL_CU (1 << 20)
  84. #define PWMx_CTRL_GSM(X) (X << 17)//slave mode master source sel: 0 normal, 1 pwm1 co4,2 pwm1 co5,3~6 pwm2~pwm5
  85. #define PWMx_CTRL_SMP (1 << 16)
  86. #define PWMx_CTRL_OSM (1 << 15)
  87. #define PWMx_CTRL_CHx_MODE_SEL(chan,X) (X << (3 + chan*2))//0:disable,1:normal,2:programmable ,chan : 0~5
  88. #define PWMx_CTRL_CM (1 << 2)
  89. #define PWMx_CTRL_RM (1 << 1)
  90. #define PWMx_CTRL_CNT_EN (1 << 0)
  91. /* pwm ch_ctl0 */
  92. #define PWMx_CH_CTL0_CHx_OL(chan, X) (X << (4 + chan*8))//chan : 0~3
  93. #define PWMx_CH_CTL0_CHx_SLM(chan, X) (X << (1 + chan*8))//chan : 0~3
  94. #define PWMx_CH_CTL0_CHx_POL_SEL(chan) (1 << (chan*8))//chan : 0~3
  95. /* pwm ch_ctl1 */
  96. #define PWMx_CH_CTL1_CHx_SLM(chan, X) (X << (1 + (chan - 4)*8))//chan : 4~5
  97. #define PWMx_CH_CTL1_CHx_POL_SEL(chan) (1 << ((chan - 4)*8))//chan : 4~5
  98. /* pwm dt*/
  99. #define PWMx_DT_CHxP_NEG(chan) (1 << (17 + (2*chan)))
  100. #define PWMx_DT_CHxN_NEG(chan) (1 << (16 + (2*chan)))
  101. #define PWMx_DT_CHx_DTEN(chan) (1 << (10 + chan))
  102. #define PWMx_DT_DT(time) (time << 0)
  103. /* pwm bthxy, x:0~5, y:a~f */
  104. #define PWMx_BTHxy_EN (1 << 24)
  105. #define PWMx_BTHxy_REPEAT(X) (X << 16)
  106. #define PWMx_BTHxy_STEP(X) (X << 8)
  107. #define PWMx_BTHxy_XS(X) (X << 0)
  108. /* pwm bth HL */
  109. #define PWMx_BTHx_HL_HEN (1 << 21)
  110. #define PWMx_BTHx_HL_LEN (1 << 20)
  111. #define PWMx_BTHx_HL_H(X) (1 << 10)
  112. #define PWMx_BTHx_HL_L(X) (1 << 0)
  113. /* pwm bth ST */
  114. #define PWMx_BTHx_ST_DIR (1 << 8)
  115. #define PWMx_BTHx_ST_ST(X) (X << 0)
  116. /* pwm fifo ctl */
  117. #define PWM_FIFOCTL_PWM_SEL(X) (X << 1)
  118. #define PWM_FIFOCTL_START (1 << 0)
  119. /* pwm fifosta */
  120. #define PWM_FIFOSTA_LEVEL (3)
  121. #define PWM_FIFOSTA_EMPTY (2)
  122. #define PWM_FIFOSTA_FULL (1)
  123. #define PWM_FIFOSTA_ERROR (0)
  124. /*pwm ir duty*/
  125. #define PWM_IRDUTY_DUTY1(X) (X << 16)
  126. #define PWM_IRDUTY_DUTY0(X) (X << 0)
  127. /* pwm ir plx pre */
  128. #define PWM_IRPLxPRE_OUT(X) (X << 16)
  129. #define PWM_IRPLxPRE_CYCLE(X) (X << 0)
  130. /* pwm ir plx post */
  131. #define PWM_IRPLxPOST_OUT(X) (X << 16)
  132. #define PWM_IRPLxPOST_CYCLE(X) (X << 16)
  133. /*pwm ir ctl*/
  134. #define PWM_IRCTL_PLED (1 << 3)
  135. #define PWM_IRCTL_CU (1 << 2)
  136. #define PWM_IRCTL_STOP (1 << 1)
  137. #define PWM_IRCTL_START (1 << 0)
  138. /* pwm interrupt ctl */
  139. #define PWM_INTCTL_IRAE (1 << 24)
  140. #define PWM_INTCTL_IRSS (1 << 23)
  141. #define PWM_INTCTL_FIFOHE (1 << 22)
  142. #define PWM_INTCTL_G5C0 (1 << 21)
  143. #define PWM_INTCTL_G5REPEAT (1 << 20)
  144. #define PWM_INTCTL_G4C0 (1 << 19)
  145. #define PWM_INTCTL_G4REPEAT (1 << 18)
  146. #define PWM_INTCTL_G3C0 (1 << 17)
  147. #define PWM_INTCTL_G3REPEAT (1 << 16)
  148. #define PWM_INTCTL_G2C0 (1 << 15)
  149. #define PWM_INTCTL_G2REPEAT (1 << 14)
  150. #define PWM_INTCTL_G1C(X) (1 << (8 + X))
  151. #define PWM_INTCTL_G1REPEAT (1 << 7)
  152. #define PWM_INTCTL_G0C(X) (1 << (8 + X))
  153. #define PWM_INTCTL_G0REPEAT (1 << 0)
  154. /* pwm interrupt ctl */
  155. #define PWM_PENDING_IRAE (1 << 24)
  156. #define PWM_PENDING_IRSS (1 << 23)
  157. #define PWM_PENDING_FIFOHE (1 << 22)
  158. #define PWM_PENDING_G5C0 (1 << 21)
  159. #define PWM_PENDING_G5REPEAT (1 << 20)
  160. #define PWM_PENDING_G4C0 (1 << 19)
  161. #define PWM_PENDING_G4REPEAT (1 << 18)
  162. #define PWM_PENDING_G3C0 (1 << 17)
  163. #define PWM_PENDING_G3REPEAT (1 << 16)
  164. #define PWM_PENDING_G2C0 (1 << 15)
  165. #define PWM_PENDING_G2REPEAT (1 << 14)
  166. #define PWM_PENDING_G1C(X) (1 << (8 + X))
  167. #define PWM_PENDING_G1REPEAT (1 << 7)
  168. #define PWM_PENDING_G0C(X) (1 << (8 + X))
  169. #define PWM_PENDING_G0REPEAT (1 << 0)
  170. #endif /* ZEPHYR_DRIVERS_PWM_SPI_CONTEXT_H_ */