atmel_spi.h 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  1. /*
  2. * Register definitions for Atmel Serial Peripheral Interface (SPI)
  3. *
  4. * Copyright (C) 2006 Atmel Corporation
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License version 2 as
  8. * published by the Free Software Foundation.
  9. */
  10. #ifndef __ATMEL_SPI_H__
  11. #define __ATMEL_SPI_H__
  12. /* SPI register offsets */
  13. #define SPI_CR 0x0000
  14. #define SPI_MR 0x0004
  15. #define SPI_RDR 0x0008
  16. #define SPI_TDR 0x000c
  17. #define SPI_SR 0x0010
  18. #define SPI_IER 0x0014
  19. #define SPI_IDR 0x0018
  20. #define SPI_IMR 0x001c
  21. #define SPI_CSR0 0x0030
  22. #define SPI_CSR1 0x0034
  23. #define SPI_CSR2 0x0038
  24. #define SPI_CSR3 0x003c
  25. #define SPI_RPR 0x0100
  26. #define SPI_RCR 0x0104
  27. #define SPI_TPR 0x0108
  28. #define SPI_TCR 0x010c
  29. #define SPI_RNPR 0x0110
  30. #define SPI_RNCR 0x0114
  31. #define SPI_TNPR 0x0118
  32. #define SPI_TNCR 0x011c
  33. #define SPI_PTCR 0x0120
  34. #define SPI_PTSR 0x0124
  35. /* Bitfields in CR */
  36. #define SPI_SPIEN_OFFSET 0
  37. #define SPI_SPIEN_SIZE 1
  38. #define SPI_SPIDIS_OFFSET 1
  39. #define SPI_SPIDIS_SIZE 1
  40. #define SPI_SWRST_OFFSET 7
  41. #define SPI_SWRST_SIZE 1
  42. #define SPI_LASTXFER_OFFSET 24
  43. #define SPI_LASTXFER_SIZE 1
  44. /* Bitfields in MR */
  45. #define SPI_MSTR_OFFSET 0
  46. #define SPI_MSTR_SIZE 1
  47. #define SPI_PS_OFFSET 1
  48. #define SPI_PS_SIZE 1
  49. #define SPI_PCSDEC_OFFSET 2
  50. #define SPI_PCSDEC_SIZE 1
  51. #define SPI_FDIV_OFFSET 3
  52. #define SPI_FDIV_SIZE 1
  53. #define SPI_MODFDIS_OFFSET 4
  54. #define SPI_MODFDIS_SIZE 1
  55. #define SPI_LLB_OFFSET 7
  56. #define SPI_LLB_SIZE 1
  57. #define SPI_PCS_OFFSET 16
  58. #define SPI_PCS_SIZE 4
  59. #define SPI_DLYBCS_OFFSET 24
  60. #define SPI_DLYBCS_SIZE 8
  61. /* Bitfields in RDR */
  62. #define SPI_RD_OFFSET 0
  63. #define SPI_RD_SIZE 16
  64. /* Bitfields in TDR */
  65. #define SPI_TD_OFFSET 0
  66. #define SPI_TD_SIZE 16
  67. /* Bitfields in SR */
  68. #define SPI_RDRF_OFFSET 0
  69. #define SPI_RDRF_SIZE 1
  70. #define SPI_TDRE_OFFSET 1
  71. #define SPI_TDRE_SIZE 1
  72. #define SPI_MODF_OFFSET 2
  73. #define SPI_MODF_SIZE 1
  74. #define SPI_OVRES_OFFSET 3
  75. #define SPI_OVRES_SIZE 1
  76. #define SPI_ENDRX_OFFSET 4
  77. #define SPI_ENDRX_SIZE 1
  78. #define SPI_ENDTX_OFFSET 5
  79. #define SPI_ENDTX_SIZE 1
  80. #define SPI_RXBUFF_OFFSET 6
  81. #define SPI_RXBUFF_SIZE 1
  82. #define SPI_TXBUFE_OFFSET 7
  83. #define SPI_TXBUFE_SIZE 1
  84. #define SPI_NSSR_OFFSET 8
  85. #define SPI_NSSR_SIZE 1
  86. #define SPI_TXEMPTY_OFFSET 9
  87. #define SPI_TXEMPTY_SIZE 1
  88. #define SPI_SPIENS_OFFSET 16
  89. #define SPI_SPIENS_SIZE 1
  90. /* Bitfields in CSR0 */
  91. #define SPI_CPOL_OFFSET 0
  92. #define SPI_CPOL_SIZE 1
  93. #define SPI_NCPHA_OFFSET 1
  94. #define SPI_NCPHA_SIZE 1
  95. #define SPI_CSAAT_OFFSET 3
  96. #define SPI_CSAAT_SIZE 1
  97. #define SPI_BITS_OFFSET 4
  98. #define SPI_BITS_SIZE 4
  99. #define SPI_SCBR_OFFSET 8
  100. #define SPI_SCBR_SIZE 8
  101. #define SPI_DLYBS_OFFSET 16
  102. #define SPI_DLYBS_SIZE 8
  103. #define SPI_DLYBCT_OFFSET 24
  104. #define SPI_DLYBCT_SIZE 8
  105. /* Bitfields in RCR */
  106. #define SPI_RXCTR_OFFSET 0
  107. #define SPI_RXCTR_SIZE 16
  108. /* Bitfields in TCR */
  109. #define SPI_TXCTR_OFFSET 0
  110. #define SPI_TXCTR_SIZE 16
  111. /* Bitfields in RNCR */
  112. #define SPI_RXNCR_OFFSET 0
  113. #define SPI_RXNCR_SIZE 16
  114. /* Bitfields in TNCR */
  115. #define SPI_TXNCR_OFFSET 0
  116. #define SPI_TXNCR_SIZE 16
  117. /* Bitfields in PTCR */
  118. #define SPI_RXTEN_OFFSET 0
  119. #define SPI_RXTEN_SIZE 1
  120. #define SPI_RXTDIS_OFFSET 1
  121. #define SPI_RXTDIS_SIZE 1
  122. #define SPI_TXTEN_OFFSET 8
  123. #define SPI_TXTEN_SIZE 1
  124. #define SPI_TXTDIS_OFFSET 9
  125. #define SPI_TXTDIS_SIZE 1
  126. /* Constants for BITS */
  127. #define SPI_BITS_8_BPT 0
  128. #define SPI_BITS_9_BPT 1
  129. #define SPI_BITS_10_BPT 2
  130. #define SPI_BITS_11_BPT 3
  131. #define SPI_BITS_12_BPT 4
  132. #define SPI_BITS_13_BPT 5
  133. #define SPI_BITS_14_BPT 6
  134. #define SPI_BITS_15_BPT 7
  135. #define SPI_BITS_16_BPT 8
  136. /* Bit manipulation macros */
  137. #define SPI_BIT(name) \
  138. (1 << SPI_##name##_OFFSET)
  139. #define SPI_BF(name,value) \
  140. (((value) & ((1 << SPI_##name##_SIZE) - 1)) << SPI_##name##_OFFSET)
  141. #define SPI_BFEXT(name,value) \
  142. (((value) >> SPI_##name##_OFFSET) & ((1 << SPI_##name##_SIZE) - 1))
  143. #define SPI_BFINS(name,value,old) \
  144. ( ((old) & ~(((1 << SPI_##name##_SIZE) - 1) << SPI_##name##_OFFSET)) \
  145. | SPI_BF(name,value))
  146. /* Register access macros */
  147. #define spi_readl(port,reg) \
  148. __raw_readl((port)->regs + SPI_##reg)
  149. #define spi_writel(port,reg,value) \
  150. __raw_writel((value), (port)->regs + SPI_##reg)
  151. #endif /* __ATMEL_SPI_H__ */