cpm.h 5.0 KB

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