spid.h 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  1. /*
  2. * SPI device spec header file
  3. *
  4. * Portions of this code are copyright (c) 2020 Cypress Semiconductor Corporation
  5. *
  6. * Copyright (C) 1999-2020, Broadcom Corporation
  7. *
  8. * Unless you and Broadcom execute a separate written software license
  9. * agreement governing use of this software, this software is licensed to you
  10. * under the terms of the GNU General Public License version 2 (the "GPL"),
  11. * available at http://www.broadcom.com/licenses/GPLv2.php, with the
  12. * following added to such license:
  13. *
  14. * As a special exception, the copyright holders of this software give you
  15. * permission to link this software with independent modules, and to copy and
  16. * distribute the resulting executable under terms of your choice, provided that
  17. * you also meet, for each linked independent module, the terms and conditions of
  18. * the license of that module. An independent module is a module which is not
  19. * derived from this software. The special exception does not apply to any
  20. * modifications of the software.
  21. *
  22. * Notwithstanding the above, under no circumstances may you combine this
  23. * software in any way with any other Broadcom software provided under a license
  24. * other than the GPL, without Broadcom's express prior written consent.
  25. *
  26. *
  27. * <<Broadcom-WL-IPTag/Open:>>
  28. *
  29. * $Id: spid.h 514727 2014-11-12 03:02:48Z $
  30. */
  31. #ifndef _SPI_H
  32. #define _SPI_H
  33. /*
  34. * Brcm SPI Device Register Map.
  35. *
  36. */
  37. typedef volatile struct {
  38. uint8 config; /* 0x00, len, endian, clock, speed, polarity, wakeup */
  39. uint8 response_delay; /* 0x01, read response delay in bytes (corerev < 3) */
  40. uint8 status_enable; /* 0x02, status-enable, intr with status, response_delay
  41. * function selection, command/data error check
  42. */
  43. uint8 reset_bp; /* 0x03, reset on wlan/bt backplane reset (corerev >= 1) */
  44. uint16 intr_reg; /* 0x04, Intr status register */
  45. uint16 intr_en_reg; /* 0x06, Intr mask register */
  46. uint32 status_reg; /* 0x08, RO, Status bits of last spi transfer */
  47. uint16 f1_info_reg; /* 0x0c, RO, enabled, ready for data transfer, blocksize */
  48. uint16 f2_info_reg; /* 0x0e, RO, enabled, ready for data transfer, blocksize */
  49. uint16 f3_info_reg; /* 0x10, RO, enabled, ready for data transfer, blocksize */
  50. uint32 test_read; /* 0x14, RO 0xfeedbead signature */
  51. uint32 test_rw; /* 0x18, RW */
  52. uint8 resp_delay_f0; /* 0x1c, read resp delay bytes for F0 (corerev >= 3) */
  53. uint8 resp_delay_f1; /* 0x1d, read resp delay bytes for F1 (corerev >= 3) */
  54. uint8 resp_delay_f2; /* 0x1e, read resp delay bytes for F2 (corerev >= 3) */
  55. uint8 resp_delay_f3; /* 0x1f, read resp delay bytes for F3 (corerev >= 3) */
  56. } spi_regs_t;
  57. /* SPI device register offsets */
  58. #define SPID_CONFIG 0x00
  59. #define SPID_RESPONSE_DELAY 0x01
  60. #define SPID_STATUS_ENABLE 0x02
  61. #define SPID_RESET_BP 0x03 /* (corerev >= 1) */
  62. #define SPID_INTR_REG 0x04 /* 16 bits - Interrupt status */
  63. #define SPID_INTR_EN_REG 0x06 /* 16 bits - Interrupt mask */
  64. #define SPID_STATUS_REG 0x08 /* 32 bits */
  65. #define SPID_F1_INFO_REG 0x0C /* 16 bits */
  66. #define SPID_F2_INFO_REG 0x0E /* 16 bits */
  67. #define SPID_F3_INFO_REG 0x10 /* 16 bits */
  68. #define SPID_TEST_READ 0x14 /* 32 bits */
  69. #define SPID_TEST_RW 0x18 /* 32 bits */
  70. #define SPID_RESP_DELAY_F0 0x1c /* 8 bits (corerev >= 3) */
  71. #define SPID_RESP_DELAY_F1 0x1d /* 8 bits (corerev >= 3) */
  72. #define SPID_RESP_DELAY_F2 0x1e /* 8 bits (corerev >= 3) */
  73. #define SPID_RESP_DELAY_F3 0x1f /* 8 bits (corerev >= 3) */
  74. /* Bit masks for SPID_CONFIG device register */
  75. #define WORD_LENGTH_32 0x1 /* 0/1 16/32 bit word length */
  76. #define ENDIAN_BIG 0x2 /* 0/1 Little/Big Endian */
  77. #define CLOCK_PHASE 0x4 /* 0/1 clock phase delay */
  78. #define CLOCK_POLARITY 0x8 /* 0/1 Idle state clock polarity is low/high */
  79. #define HIGH_SPEED_MODE 0x10 /* 1/0 High Speed mode / Normal mode */
  80. #define INTR_POLARITY 0x20 /* 1/0 Interrupt active polarity is high/low */
  81. #define WAKE_UP 0x80 /* 0/1 Wake-up command from Host to WLAN */
  82. /* Bit mask for SPID_RESPONSE_DELAY device register */
  83. #define RESPONSE_DELAY_MASK 0xFF /* Configurable rd response delay in multiples of 8 bits */
  84. /* Bit mask for SPID_STATUS_ENABLE device register */
  85. #define STATUS_ENABLE 0x1 /* 1/0 Status sent/not sent to host after read/write */
  86. #define INTR_WITH_STATUS 0x2 /* 0/1 Do-not / do-interrupt if status is sent */
  87. #define RESP_DELAY_ALL 0x4 /* Applicability of resp delay to F1 or all func's read */
  88. #define DWORD_PKT_LEN_EN 0x8 /* Packet len denoted in dwords instead of bytes */
  89. #define CMD_ERR_CHK_EN 0x20 /* Command error check enable */
  90. #define DATA_ERR_CHK_EN 0x40 /* Data error check enable */
  91. /* Bit mask for SPID_RESET_BP device register */
  92. #define RESET_ON_WLAN_BP_RESET 0x4 /* enable reset for WLAN backplane */
  93. #define RESET_ON_BT_BP_RESET 0x8 /* enable reset for BT backplane */
  94. #define RESET_SPI 0x80 /* reset the above enabled logic */
  95. /* Bit mask for SPID_INTR_REG device register */
  96. #define DATA_UNAVAILABLE 0x0001 /* Requested data not available; Clear by writing a "1" */
  97. #define F2_F3_FIFO_RD_UNDERFLOW 0x0002
  98. #define F2_F3_FIFO_WR_OVERFLOW 0x0004
  99. #define COMMAND_ERROR 0x0008 /* Cleared by writing 1 */
  100. #define DATA_ERROR 0x0010 /* Cleared by writing 1 */
  101. #define F2_PACKET_AVAILABLE 0x0020
  102. #define F3_PACKET_AVAILABLE 0x0040
  103. #define F1_OVERFLOW 0x0080 /* Due to last write. Bkplane has pending write requests */
  104. #define MISC_INTR0 0x0100
  105. #define MISC_INTR1 0x0200
  106. #define MISC_INTR2 0x0400
  107. #define MISC_INTR3 0x0800
  108. #define MISC_INTR4 0x1000
  109. #define F1_INTR 0x2000
  110. #define F2_INTR 0x4000
  111. #define F3_INTR 0x8000
  112. /* Bit mask for 32bit SPID_STATUS_REG device register */
  113. #define STATUS_DATA_NOT_AVAILABLE 0x00000001
  114. #define STATUS_UNDERFLOW 0x00000002
  115. #define STATUS_OVERFLOW 0x00000004
  116. #define STATUS_F2_INTR 0x00000008
  117. #define STATUS_F3_INTR 0x00000010
  118. #define STATUS_F2_RX_READY 0x00000020
  119. #define STATUS_F3_RX_READY 0x00000040
  120. #define STATUS_HOST_CMD_DATA_ERR 0x00000080
  121. #define STATUS_F2_PKT_AVAILABLE 0x00000100
  122. #define STATUS_F2_PKT_LEN_MASK 0x000FFE00
  123. #define STATUS_F2_PKT_LEN_SHIFT 9
  124. #define STATUS_F3_PKT_AVAILABLE 0x00100000
  125. #define STATUS_F3_PKT_LEN_MASK 0xFFE00000
  126. #define STATUS_F3_PKT_LEN_SHIFT 21
  127. /* Bit mask for 16 bits SPID_F1_INFO_REG device register */
  128. #define F1_ENABLED 0x0001
  129. #define F1_RDY_FOR_DATA_TRANSFER 0x0002
  130. #define F1_MAX_PKT_SIZE 0x01FC
  131. /* Bit mask for 16 bits SPID_F2_INFO_REG device register */
  132. #define F2_ENABLED 0x0001
  133. #define F2_RDY_FOR_DATA_TRANSFER 0x0002
  134. #define F2_MAX_PKT_SIZE 0x3FFC
  135. /* Bit mask for 16 bits SPID_F3_INFO_REG device register */
  136. #define F3_ENABLED 0x0001
  137. #define F3_RDY_FOR_DATA_TRANSFER 0x0002
  138. #define F3_MAX_PKT_SIZE 0x3FFC
  139. /* Bit mask for 32 bits SPID_TEST_READ device register read in 16bit LE mode */
  140. #define TEST_RO_DATA_32BIT_LE 0xFEEDBEAD
  141. /* Maximum number of I/O funcs */
  142. #define SPI_MAX_IOFUNCS 4
  143. #define SPI_MAX_PKT_LEN (2048*4)
  144. /* Misc defines */
  145. #define SPI_FUNC_0 0
  146. #define SPI_FUNC_1 1
  147. #define SPI_FUNC_2 2
  148. #define SPI_FUNC_3 3
  149. #define WAIT_F2RXFIFORDY 100
  150. #define WAIT_F2RXFIFORDY_DELAY 20
  151. #endif /* _SPI_H */