qe.h 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237
  1. /*
  2. * Copyright (C) 2006 Freescale Semiconductor, Inc.
  3. *
  4. * Dave Liu <daveliu@freescale.com>
  5. * based on source code of Shlomi Gridish
  6. *
  7. * This program is free software; you can redistribute it and/or
  8. * modify it under the terms of the GNU General Public License as
  9. * published by the Free Software Foundation; either version 2 of
  10. * the License, or (at your option) any later version.
  11. *
  12. * This program is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with this program; if not, write to the Free Software
  19. * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  20. * MA 02111-1307 USA
  21. */
  22. #ifndef __QE_H__
  23. #define __QE_H__
  24. #include "common.h"
  25. #define QE_NUM_OF_SNUM 28
  26. #define QE_NUM_OF_BRGS 16
  27. #define UCC_MAX_NUM 8
  28. #define QE_DATAONLY_BASE 0
  29. #define QE_DATAONLY_SIZE (QE_MURAM_SIZE - QE_DATAONLY_BASE)
  30. /* QE threads SNUM
  31. */
  32. typedef enum qe_snum_state {
  33. QE_SNUM_STATE_USED, /* used */
  34. QE_SNUM_STATE_FREE /* free */
  35. } qe_snum_state_e;
  36. typedef struct qe_snum {
  37. u8 num; /* snum */
  38. qe_snum_state_e state; /* state */
  39. } qe_snum_t;
  40. /* QE RISC allocation
  41. */
  42. typedef enum qe_risc_allocation {
  43. QE_RISC_ALLOCATION_RISC1 = 1, /* RISC 1 */
  44. QE_RISC_ALLOCATION_RISC2 = 2, /* RISC 2 */
  45. QE_RISC_ALLOCATION_RISC1_AND_RISC2 = 3 /* RISC 1 or RISC 2 */
  46. } qe_risc_allocation_e;
  47. /* QE CECR commands for UCC fast.
  48. */
  49. #define QE_CR_FLG 0x00010000
  50. #define QE_RESET 0x80000000
  51. #define QE_INIT_TX_RX 0x00000000
  52. #define QE_INIT_RX 0x00000001
  53. #define QE_INIT_TX 0x00000002
  54. #define QE_ENTER_HUNT_MODE 0x00000003
  55. #define QE_STOP_TX 0x00000004
  56. #define QE_GRACEFUL_STOP_TX 0x00000005
  57. #define QE_RESTART_TX 0x00000006
  58. #define QE_SWITCH_COMMAND 0x00000007
  59. #define QE_SET_GROUP_ADDRESS 0x00000008
  60. #define QE_INSERT_CELL 0x00000009
  61. #define QE_ATM_TRANSMIT 0x0000000a
  62. #define QE_CELL_POOL_GET 0x0000000b
  63. #define QE_CELL_POOL_PUT 0x0000000c
  64. #define QE_IMA_HOST_CMD 0x0000000d
  65. #define QE_ATM_MULTI_THREAD_INIT 0x00000011
  66. #define QE_ASSIGN_PAGE 0x00000012
  67. #define QE_START_FLOW_CONTROL 0x00000014
  68. #define QE_STOP_FLOW_CONTROL 0x00000015
  69. #define QE_ASSIGN_PAGE_TO_DEVICE 0x00000016
  70. #define QE_GRACEFUL_STOP_RX 0x0000001a
  71. #define QE_RESTART_RX 0x0000001b
  72. /* QE CECR Sub Block Code - sub block code of QE command.
  73. */
  74. #define QE_CR_SUBBLOCK_INVALID 0x00000000
  75. #define QE_CR_SUBBLOCK_USB 0x03200000
  76. #define QE_CR_SUBBLOCK_UCCFAST1 0x02000000
  77. #define QE_CR_SUBBLOCK_UCCFAST2 0x02200000
  78. #define QE_CR_SUBBLOCK_UCCFAST3 0x02400000
  79. #define QE_CR_SUBBLOCK_UCCFAST4 0x02600000
  80. #define QE_CR_SUBBLOCK_UCCFAST5 0x02800000
  81. #define QE_CR_SUBBLOCK_UCCFAST6 0x02a00000
  82. #define QE_CR_SUBBLOCK_UCCFAST7 0x02c00000
  83. #define QE_CR_SUBBLOCK_UCCFAST8 0x02e00000
  84. #define QE_CR_SUBBLOCK_UCCSLOW1 0x00000000
  85. #define QE_CR_SUBBLOCK_UCCSLOW2 0x00200000
  86. #define QE_CR_SUBBLOCK_UCCSLOW3 0x00400000
  87. #define QE_CR_SUBBLOCK_UCCSLOW4 0x00600000
  88. #define QE_CR_SUBBLOCK_UCCSLOW5 0x00800000
  89. #define QE_CR_SUBBLOCK_UCCSLOW6 0x00a00000
  90. #define QE_CR_SUBBLOCK_UCCSLOW7 0x00c00000
  91. #define QE_CR_SUBBLOCK_UCCSLOW8 0x00e00000
  92. #define QE_CR_SUBBLOCK_MCC1 0x03800000
  93. #define QE_CR_SUBBLOCK_MCC2 0x03a00000
  94. #define QE_CR_SUBBLOCK_MCC3 0x03000000
  95. #define QE_CR_SUBBLOCK_IDMA1 0x02800000
  96. #define QE_CR_SUBBLOCK_IDMA2 0x02a00000
  97. #define QE_CR_SUBBLOCK_IDMA3 0x02c00000
  98. #define QE_CR_SUBBLOCK_IDMA4 0x02e00000
  99. #define QE_CR_SUBBLOCK_HPAC 0x01e00000
  100. #define QE_CR_SUBBLOCK_SPI1 0x01400000
  101. #define QE_CR_SUBBLOCK_SPI2 0x01600000
  102. #define QE_CR_SUBBLOCK_RAND 0x01c00000
  103. #define QE_CR_SUBBLOCK_TIMER 0x01e00000
  104. #define QE_CR_SUBBLOCK_GENERAL 0x03c00000
  105. /* QE CECR Protocol - For non-MCC, specifies mode for QE CECR command.
  106. */
  107. #define QE_CR_PROTOCOL_UNSPECIFIED 0x00 /* For all other protocols */
  108. #define QE_CR_PROTOCOL_HDLC_TRANSPARENT 0x00
  109. #define QE_CR_PROTOCOL_ATM_POS 0x0A
  110. #define QE_CR_PROTOCOL_ETHERNET 0x0C
  111. #define QE_CR_PROTOCOL_L2_SWITCH 0x0D
  112. #define QE_CR_PROTOCOL_SHIFT 6
  113. /* QE ASSIGN PAGE command
  114. */
  115. #define QE_CR_ASSIGN_PAGE_SNUM_SHIFT 17
  116. /* Communication Direction.
  117. */
  118. typedef enum comm_dir {
  119. COMM_DIR_NONE = 0,
  120. COMM_DIR_RX = 1,
  121. COMM_DIR_TX = 2,
  122. COMM_DIR_RX_AND_TX = 3
  123. } comm_dir_e;
  124. /* Clocks and BRG's
  125. */
  126. typedef enum qe_clock {
  127. QE_CLK_NONE = 0,
  128. QE_BRG1, /* Baud Rate Generator 1 */
  129. QE_BRG2, /* Baud Rate Generator 2 */
  130. QE_BRG3, /* Baud Rate Generator 3 */
  131. QE_BRG4, /* Baud Rate Generator 4 */
  132. QE_BRG5, /* Baud Rate Generator 5 */
  133. QE_BRG6, /* Baud Rate Generator 6 */
  134. QE_BRG7, /* Baud Rate Generator 7 */
  135. QE_BRG8, /* Baud Rate Generator 8 */
  136. QE_BRG9, /* Baud Rate Generator 9 */
  137. QE_BRG10, /* Baud Rate Generator 10 */
  138. QE_BRG11, /* Baud Rate Generator 11 */
  139. QE_BRG12, /* Baud Rate Generator 12 */
  140. QE_BRG13, /* Baud Rate Generator 13 */
  141. QE_BRG14, /* Baud Rate Generator 14 */
  142. QE_BRG15, /* Baud Rate Generator 15 */
  143. QE_BRG16, /* Baud Rate Generator 16 */
  144. QE_CLK1, /* Clock 1 */
  145. QE_CLK2, /* Clock 2 */
  146. QE_CLK3, /* Clock 3 */
  147. QE_CLK4, /* Clock 4 */
  148. QE_CLK5, /* Clock 5 */
  149. QE_CLK6, /* Clock 6 */
  150. QE_CLK7, /* Clock 7 */
  151. QE_CLK8, /* Clock 8 */
  152. QE_CLK9, /* Clock 9 */
  153. QE_CLK10, /* Clock 10 */
  154. QE_CLK11, /* Clock 11 */
  155. QE_CLK12, /* Clock 12 */
  156. QE_CLK13, /* Clock 13 */
  157. QE_CLK14, /* Clock 14 */
  158. QE_CLK15, /* Clock 15 */
  159. QE_CLK16, /* Clock 16 */
  160. QE_CLK17, /* Clock 17 */
  161. QE_CLK18, /* Clock 18 */
  162. QE_CLK19, /* Clock 19 */
  163. QE_CLK20, /* Clock 20 */
  164. QE_CLK21, /* Clock 21 */
  165. QE_CLK22, /* Clock 22 */
  166. QE_CLK23, /* Clock 23 */
  167. QE_CLK24, /* Clock 24 */
  168. QE_CLK_DUMMY
  169. } qe_clock_e;
  170. /* QE CMXGCR register
  171. */
  172. #define QE_CMXGCR_MII_ENET_MNG_MASK 0x00007000
  173. #define QE_CMXGCR_MII_ENET_MNG_SHIFT 12
  174. /* QE CMXUCR registers
  175. */
  176. #define QE_CMXUCR_TX_CLK_SRC_MASK 0x0000000F
  177. /* QE BRG configuration register
  178. */
  179. #define QE_BRGC_ENABLE 0x00010000
  180. #define QE_BRGC_DIVISOR_SHIFT 1
  181. #define QE_BRGC_DIVISOR_MAX 0xFFF
  182. #define QE_BRGC_DIV16 1
  183. /* QE SDMA registers
  184. */
  185. #define QE_SDSR_BER1 0x02000000
  186. #define QE_SDSR_BER2 0x01000000
  187. #define QE_SDMR_GLB_1_MSK 0x80000000
  188. #define QE_SDMR_ADR_SEL 0x20000000
  189. #define QE_SDMR_BER1_MSK 0x02000000
  190. #define QE_SDMR_BER2_MSK 0x01000000
  191. #define QE_SDMR_EB1_MSK 0x00800000
  192. #define QE_SDMR_ER1_MSK 0x00080000
  193. #define QE_SDMR_ER2_MSK 0x00040000
  194. #define QE_SDMR_CEN_MASK 0x0000E000
  195. #define QE_SDMR_SBER_1 0x00000200
  196. #define QE_SDMR_SBER_2 0x00000200
  197. #define QE_SDMR_EB1_PR_MASK 0x000000C0
  198. #define QE_SDMR_ER1_PR 0x00000008
  199. #define QE_SDMR_CEN_SHIFT 13
  200. #define QE_SDMR_EB1_PR_SHIFT 6
  201. #define QE_SDTM_MSNUM_SHIFT 24
  202. #define QE_SDEBCR_BA_MASK 0x01FFFFFF
  203. void qe_config_iopin(u8 port, u8 pin, int dir, int open_drain, int assign);
  204. void qe_issue_cmd(uint cmd, uint sbc, u8 mcn, u32 cmd_data);
  205. uint qe_muram_alloc(uint size, uint align);
  206. void *qe_muram_addr(uint offset);
  207. int qe_get_snum(void);
  208. void qe_put_snum(u8 snum);
  209. void qe_init(uint qe_base);
  210. void qe_reset(void);
  211. void qe_assign_page(uint snum, uint para_ram_base);
  212. int qe_set_brg(uint brg, uint rate);
  213. int qe_set_mii_clk_src(int ucc_num);
  214. #endif /* __QE_H__ */