mxs-spi.h 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. /*
  2. * include/linux/spi/mxs-spi.h
  3. *
  4. * Freescale i.MX233/i.MX28 SPI controller register definition
  5. *
  6. * Copyright 2008 Embedded Alley Solutions, Inc.
  7. * Copyright 2009-2011 Freescale Semiconductor, Inc.
  8. *
  9. * This program is free software; you can redistribute it and/or modify
  10. * it under the terms of the GNU General Public License as published by
  11. * the Free Software Foundation; either version 2 of the License, or
  12. * (at your option) any later version.
  13. *
  14. * This program is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. * GNU General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU General Public License along
  20. * with this program; if not, write to the Free Software Foundation, Inc.,
  21. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  22. */
  23. #ifndef __LINUX_SPI_MXS_SPI_H__
  24. #define __LINUX_SPI_MXS_SPI_H__
  25. #define ssp_is_old(host) ((host)->devid == IMX23_SSP)
  26. /* SSP registers */
  27. #define HW_SSP_CTRL0 0x000
  28. #define BM_SSP_CTRL0_RUN (1 << 29)
  29. #define BM_SSP_CTRL0_SDIO_IRQ_CHECK (1 << 28)
  30. #define BM_SSP_CTRL0_LOCK_CS (1 << 27)
  31. #define BM_SSP_CTRL0_IGNORE_CRC (1 << 26)
  32. #define BM_SSP_CTRL0_READ (1 << 25)
  33. #define BM_SSP_CTRL0_DATA_XFER (1 << 24)
  34. #define BP_SSP_CTRL0_BUS_WIDTH 22
  35. #define BM_SSP_CTRL0_BUS_WIDTH (0x3 << 22)
  36. #define BM_SSP_CTRL0_WAIT_FOR_IRQ (1 << 21)
  37. #define BM_SSP_CTRL0_WAIT_FOR_CMD (1 << 20)
  38. #define BM_SSP_CTRL0_LONG_RESP (1 << 19)
  39. #define BM_SSP_CTRL0_GET_RESP (1 << 17)
  40. #define BM_SSP_CTRL0_ENABLE (1 << 16)
  41. #define BP_SSP_CTRL0_XFER_COUNT 0
  42. #define BM_SSP_CTRL0_XFER_COUNT 0xffff
  43. #define HW_SSP_CMD0 0x010
  44. #define BM_SSP_CMD0_DBL_DATA_RATE_EN (1 << 25)
  45. #define BM_SSP_CMD0_SLOW_CLKING_EN (1 << 22)
  46. #define BM_SSP_CMD0_CONT_CLKING_EN (1 << 21)
  47. #define BM_SSP_CMD0_APPEND_8CYC (1 << 20)
  48. #define BP_SSP_CMD0_BLOCK_SIZE 16
  49. #define BM_SSP_CMD0_BLOCK_SIZE (0xf << 16)
  50. #define BP_SSP_CMD0_BLOCK_COUNT 8
  51. #define BM_SSP_CMD0_BLOCK_COUNT (0xff << 8)
  52. #define BP_SSP_CMD0_CMD 0
  53. #define BM_SSP_CMD0_CMD 0xff
  54. #define HW_SSP_CMD1 0x020
  55. #define HW_SSP_XFER_SIZE 0x030
  56. #define HW_SSP_BLOCK_SIZE 0x040
  57. #define BP_SSP_BLOCK_SIZE_BLOCK_COUNT 4
  58. #define BM_SSP_BLOCK_SIZE_BLOCK_COUNT (0xffffff << 4)
  59. #define BP_SSP_BLOCK_SIZE_BLOCK_SIZE 0
  60. #define BM_SSP_BLOCK_SIZE_BLOCK_SIZE 0xf
  61. #define HW_SSP_TIMING(h) (ssp_is_old(h) ? 0x050 : 0x070)
  62. #define BP_SSP_TIMING_TIMEOUT 16
  63. #define BM_SSP_TIMING_TIMEOUT (0xffff << 16)
  64. #define BP_SSP_TIMING_CLOCK_DIVIDE 8
  65. #define BM_SSP_TIMING_CLOCK_DIVIDE (0xff << 8)
  66. #define BF_SSP_TIMING_CLOCK_DIVIDE(v) \
  67. (((v) << 8) & BM_SSP_TIMING_CLOCK_DIVIDE)
  68. #define BP_SSP_TIMING_CLOCK_RATE 0
  69. #define BM_SSP_TIMING_CLOCK_RATE 0xff
  70. #define BF_SSP_TIMING_CLOCK_RATE(v) \
  71. (((v) << 0) & BM_SSP_TIMING_CLOCK_RATE)
  72. #define HW_SSP_CTRL1(h) (ssp_is_old(h) ? 0x060 : 0x080)
  73. #define BM_SSP_CTRL1_SDIO_IRQ (1 << 31)
  74. #define BM_SSP_CTRL1_SDIO_IRQ_EN (1 << 30)
  75. #define BM_SSP_CTRL1_RESP_ERR_IRQ (1 << 29)
  76. #define BM_SSP_CTRL1_RESP_ERR_IRQ_EN (1 << 28)
  77. #define BM_SSP_CTRL1_RESP_TIMEOUT_IRQ (1 << 27)
  78. #define BM_SSP_CTRL1_RESP_TIMEOUT_IRQ_EN (1 << 26)
  79. #define BM_SSP_CTRL1_DATA_TIMEOUT_IRQ (1 << 25)
  80. #define BM_SSP_CTRL1_DATA_TIMEOUT_IRQ_EN (1 << 24)
  81. #define BM_SSP_CTRL1_DATA_CRC_IRQ (1 << 23)
  82. #define BM_SSP_CTRL1_DATA_CRC_IRQ_EN (1 << 22)
  83. #define BM_SSP_CTRL1_FIFO_UNDERRUN_IRQ (1 << 21)
  84. #define BM_SSP_CTRL1_FIFO_UNDERRUN_IRQ_EN (1 << 20)
  85. #define BM_SSP_CTRL1_RECV_TIMEOUT_IRQ (1 << 17)
  86. #define BM_SSP_CTRL1_RECV_TIMEOUT_IRQ_EN (1 << 16)
  87. #define BM_SSP_CTRL1_FIFO_OVERRUN_IRQ (1 << 15)
  88. #define BM_SSP_CTRL1_FIFO_OVERRUN_IRQ_EN (1 << 14)
  89. #define BM_SSP_CTRL1_DMA_ENABLE (1 << 13)
  90. #define BM_SSP_CTRL1_PHASE (1 << 10)
  91. #define BM_SSP_CTRL1_POLARITY (1 << 9)
  92. #define BP_SSP_CTRL1_WORD_LENGTH 4
  93. #define BM_SSP_CTRL1_WORD_LENGTH (0xf << 4)
  94. #define BF_SSP_CTRL1_WORD_LENGTH(v) \
  95. (((v) << 4) & BM_SSP_CTRL1_WORD_LENGTH)
  96. #define BV_SSP_CTRL1_WORD_LENGTH__FOUR_BITS 0x3
  97. #define BV_SSP_CTRL1_WORD_LENGTH__EIGHT_BITS 0x7
  98. #define BV_SSP_CTRL1_WORD_LENGTH__SIXTEEN_BITS 0xF
  99. #define BP_SSP_CTRL1_SSP_MODE 0
  100. #define BM_SSP_CTRL1_SSP_MODE 0xf
  101. #define BF_SSP_CTRL1_SSP_MODE(v) \
  102. (((v) << 0) & BM_SSP_CTRL1_SSP_MODE)
  103. #define BV_SSP_CTRL1_SSP_MODE__SPI 0x0
  104. #define BV_SSP_CTRL1_SSP_MODE__SSI 0x1
  105. #define BV_SSP_CTRL1_SSP_MODE__SD_MMC 0x3
  106. #define BV_SSP_CTRL1_SSP_MODE__MS 0x4
  107. #define HW_SSP_DATA(h) (ssp_is_old(h) ? 0x070 : 0x090)
  108. #define HW_SSP_SDRESP0(h) (ssp_is_old(h) ? 0x080 : 0x0a0)
  109. #define HW_SSP_SDRESP1(h) (ssp_is_old(h) ? 0x090 : 0x0b0)
  110. #define HW_SSP_SDRESP2(h) (ssp_is_old(h) ? 0x0a0 : 0x0c0)
  111. #define HW_SSP_SDRESP3(h) (ssp_is_old(h) ? 0x0b0 : 0x0d0)
  112. #define HW_SSP_STATUS(h) (ssp_is_old(h) ? 0x0c0 : 0x100)
  113. #define BM_SSP_STATUS_CARD_DETECT (1 << 28)
  114. #define BM_SSP_STATUS_SDIO_IRQ (1 << 17)
  115. #define BM_SSP_STATUS_FIFO_EMPTY (1 << 5)
  116. #define BF_SSP(value, field) (((value) << BP_SSP_##field) & BM_SSP_##field)
  117. #define SSP_PIO_NUM 3
  118. enum mxs_ssp_id {
  119. IMX23_SSP,
  120. IMX28_SSP,
  121. };
  122. #endif /* __LINUX_SPI_MXS_SPI_H__ */