cpm.h 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212
  1. #ifndef __CPM_H
  2. #define __CPM_H
  3. #include <linux/compiler.h>
  4. #include <linux/types.h>
  5. #include <linux/errno.h>
  6. #include <linux/of.h>
  7. /*
  8. * SPI Parameter RAM common to QE and CPM.
  9. */
  10. struct spi_pram {
  11. __be16 rbase; /* Rx Buffer descriptor base address */
  12. __be16 tbase; /* Tx Buffer descriptor base address */
  13. u8 rfcr; /* Rx function code */
  14. u8 tfcr; /* Tx function code */
  15. __be16 mrblr; /* Max receive buffer length */
  16. __be32 rstate; /* Internal */
  17. __be32 rdp; /* Internal */
  18. __be16 rbptr; /* Internal */
  19. __be16 rbc; /* Internal */
  20. __be32 rxtmp; /* Internal */
  21. __be32 tstate; /* Internal */
  22. __be32 tdp; /* Internal */
  23. __be16 tbptr; /* Internal */
  24. __be16 tbc; /* Internal */
  25. __be32 txtmp; /* Internal */
  26. __be32 res; /* Tx temp. */
  27. __be16 rpbase; /* Relocation pointer (CPM1 only) */
  28. __be16 res1; /* Reserved */
  29. };
  30. /*
  31. * USB Controller pram common to QE and CPM.
  32. */
  33. struct usb_ctlr {
  34. u8 usb_usmod;
  35. u8 usb_usadr;
  36. u8 usb_uscom;
  37. u8 res1[1];
  38. __be16 usb_usep[4];
  39. u8 res2[4];
  40. __be16 usb_usber;
  41. u8 res3[2];
  42. __be16 usb_usbmr;
  43. u8 res4[1];
  44. u8 usb_usbs;
  45. /* Fields down below are QE-only */
  46. __be16 usb_ussft;
  47. u8 res5[2];
  48. __be16 usb_usfrn;
  49. u8 res6[0x22];
  50. } __attribute__ ((packed));
  51. /*
  52. * Function code bits, usually generic to devices.
  53. */
  54. #ifdef CONFIG_CPM1
  55. #define CPMFCR_GBL ((u_char)0x00) /* Flag doesn't exist in CPM1 */
  56. #define CPMFCR_TC2 ((u_char)0x00) /* Flag doesn't exist in CPM1 */
  57. #define CPMFCR_DTB ((u_char)0x00) /* Flag doesn't exist in CPM1 */
  58. #define CPMFCR_BDB ((u_char)0x00) /* Flag doesn't exist in CPM1 */
  59. #else
  60. #define CPMFCR_GBL ((u_char)0x20) /* Set memory snooping */
  61. #define CPMFCR_TC2 ((u_char)0x04) /* Transfer code 2 value */
  62. #define CPMFCR_DTB ((u_char)0x02) /* Use local bus for data when set */
  63. #define CPMFCR_BDB ((u_char)0x01) /* Use local bus for BD when set */
  64. #endif
  65. #define CPMFCR_EB ((u_char)0x10) /* Set big endian byte order */
  66. /* Opcodes common to CPM1 and CPM2
  67. */
  68. #define CPM_CR_INIT_TRX ((ushort)0x0000)
  69. #define CPM_CR_INIT_RX ((ushort)0x0001)
  70. #define CPM_CR_INIT_TX ((ushort)0x0002)
  71. #define CPM_CR_HUNT_MODE ((ushort)0x0003)
  72. #define CPM_CR_STOP_TX ((ushort)0x0004)
  73. #define CPM_CR_GRA_STOP_TX ((ushort)0x0005)
  74. #define CPM_CR_RESTART_TX ((ushort)0x0006)
  75. #define CPM_CR_CLOSE_RX_BD ((ushort)0x0007)
  76. #define CPM_CR_SET_GADDR ((ushort)0x0008)
  77. #define CPM_CR_SET_TIMER ((ushort)0x0008)
  78. #define CPM_CR_STOP_IDMA ((ushort)0x000b)
  79. /* Buffer descriptors used by many of the CPM protocols. */
  80. typedef struct cpm_buf_desc {
  81. ushort cbd_sc; /* Status and Control */
  82. ushort cbd_datlen; /* Data length in buffer */
  83. uint cbd_bufaddr; /* Buffer address in host memory */
  84. } cbd_t;
  85. /* Buffer descriptor control/status used by serial
  86. */
  87. #define BD_SC_EMPTY (0x8000) /* Receive is empty */
  88. #define BD_SC_READY (0x8000) /* Transmit is ready */
  89. #define BD_SC_WRAP (0x2000) /* Last buffer descriptor */
  90. #define BD_SC_INTRPT (0x1000) /* Interrupt on change */
  91. #define BD_SC_LAST (0x0800) /* Last buffer in frame */
  92. #define BD_SC_TC (0x0400) /* Transmit CRC */
  93. #define BD_SC_CM (0x0200) /* Continuous mode */
  94. #define BD_SC_ID (0x0100) /* Rec'd too many idles */
  95. #define BD_SC_P (0x0100) /* xmt preamble */
  96. #define BD_SC_BR (0x0020) /* Break received */
  97. #define BD_SC_FR (0x0010) /* Framing error */
  98. #define BD_SC_PR (0x0008) /* Parity error */
  99. #define BD_SC_NAK (0x0004) /* NAK - did not respond */
  100. #define BD_SC_OV (0x0002) /* Overrun */
  101. #define BD_SC_UN (0x0002) /* Underrun */
  102. #define BD_SC_CD (0x0001) /* */
  103. #define BD_SC_CL (0x0001) /* Collision */
  104. /* Buffer descriptor control/status used by Ethernet receive.
  105. * Common to SCC and FCC.
  106. */
  107. #define BD_ENET_RX_EMPTY (0x8000)
  108. #define BD_ENET_RX_WRAP (0x2000)
  109. #define BD_ENET_RX_INTR (0x1000)
  110. #define BD_ENET_RX_LAST (0x0800)
  111. #define BD_ENET_RX_FIRST (0x0400)
  112. #define BD_ENET_RX_MISS (0x0100)
  113. #define BD_ENET_RX_BC (0x0080) /* FCC Only */
  114. #define BD_ENET_RX_MC (0x0040) /* FCC Only */
  115. #define BD_ENET_RX_LG (0x0020)
  116. #define BD_ENET_RX_NO (0x0010)
  117. #define BD_ENET_RX_SH (0x0008)
  118. #define BD_ENET_RX_CR (0x0004)
  119. #define BD_ENET_RX_OV (0x0002)
  120. #define BD_ENET_RX_CL (0x0001)
  121. #define BD_ENET_RX_STATS (0x01ff) /* All status bits */
  122. /* Buffer descriptor control/status used by Ethernet transmit.
  123. * Common to SCC and FCC.
  124. */
  125. #define BD_ENET_TX_READY (0x8000)
  126. #define BD_ENET_TX_PAD (0x4000)
  127. #define BD_ENET_TX_WRAP (0x2000)
  128. #define BD_ENET_TX_INTR (0x1000)
  129. #define BD_ENET_TX_LAST (0x0800)
  130. #define BD_ENET_TX_TC (0x0400)
  131. #define BD_ENET_TX_DEF (0x0200)
  132. #define BD_ENET_TX_HB (0x0100)
  133. #define BD_ENET_TX_LC (0x0080)
  134. #define BD_ENET_TX_RL (0x0040)
  135. #define BD_ENET_TX_RCMASK (0x003c)
  136. #define BD_ENET_TX_UN (0x0002)
  137. #define BD_ENET_TX_CSL (0x0001)
  138. #define BD_ENET_TX_STATS (0x03ff) /* All status bits */
  139. /* Buffer descriptor control/status used by Transparent mode SCC.
  140. */
  141. #define BD_SCC_TX_LAST (0x0800)
  142. /* Buffer descriptor control/status used by I2C.
  143. */
  144. #define BD_I2C_START (0x0400)
  145. int cpm_muram_init(void);
  146. #if defined(CONFIG_CPM) || defined(CONFIG_QUICC_ENGINE)
  147. unsigned long cpm_muram_alloc(unsigned long size, unsigned long align);
  148. int cpm_muram_free(unsigned long offset);
  149. unsigned long cpm_muram_alloc_fixed(unsigned long offset, unsigned long size);
  150. void __iomem *cpm_muram_addr(unsigned long offset);
  151. unsigned long cpm_muram_offset(void __iomem *addr);
  152. dma_addr_t cpm_muram_dma(void __iomem *addr);
  153. #else
  154. static inline unsigned long cpm_muram_alloc(unsigned long size,
  155. unsigned long align)
  156. {
  157. return -ENOSYS;
  158. }
  159. static inline int cpm_muram_free(unsigned long offset)
  160. {
  161. return -ENOSYS;
  162. }
  163. static inline unsigned long cpm_muram_alloc_fixed(unsigned long offset,
  164. unsigned long size)
  165. {
  166. return -ENOSYS;
  167. }
  168. static inline void __iomem *cpm_muram_addr(unsigned long offset)
  169. {
  170. return NULL;
  171. }
  172. static inline unsigned long cpm_muram_offset(void __iomem *addr)
  173. {
  174. return -ENOSYS;
  175. }
  176. static inline dma_addr_t cpm_muram_dma(void __iomem *addr)
  177. {
  178. return 0;
  179. }
  180. #endif /* defined(CONFIG_CPM) || defined(CONFIG_QUICC_ENGINE) */
  181. #ifdef CONFIG_CPM
  182. int cpm_command(u32 command, u8 opcode);
  183. #else
  184. static inline int cpm_command(u32 command, u8 opcode)
  185. {
  186. return -ENOSYS;
  187. }
  188. #endif /* CONFIG_CPM */
  189. int cpm2_gpiochip_add32(struct device_node *np);
  190. #endif