dw_spi_hal.h 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. /* ------------------------------------------
  2. * Copyright (c) 2017, Synopsys, Inc. All rights reserved.
  3. * Redistribution and use in source and binary forms, with or without modification,
  4. * are permitted provided that the following conditions are met:
  5. * 1) Redistributions of source code must retain the above copyright notice, this
  6. * list of conditions and the following disclaimer.
  7. * 2) Redistributions in binary form must reproduce the above copyright notice,
  8. * this list of conditions and the following disclaimer in the documentation and/or
  9. * other materials provided with the distribution.
  10. * 3) Neither the name of the Synopsys, Inc., nor the names of its contributors may
  11. * be used to endorse or promote products derived from this software without
  12. * specific prior written permission.
  13. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
  14. * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  15. * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  16. * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
  17. * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  18. * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  19. * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
  20. * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  21. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  22. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  23. *
  24. * \version 2017.03
  25. * \date 2014-06-25
  26. * \author Huaqi Fang(Huaqi.Fang@synopsys.com)
  27. --------------------------------------------- */
  28. /**
  29. * \file
  30. * \ingroup DEVICE_DW_SPI
  31. * \brief DesignWare SPI driver hardware description related header file
  32. * \details detailed hardware related definitions of DesignWare SPI driver
  33. */
  34. #ifndef _DEVICE_DW_SPI_HAL_H_
  35. #define _DEVICE_DW_SPI_HAL_H_
  36. #include "device/designware/spi/dw_spi_hal_cfg.h"
  37. /* DW APB SPI bit definitions */
  38. /**
  39. * \name DesignWare SPI HAL CTRL0 Macros
  40. * \brief DesignWare SPI hal ctrl0 macros,
  41. * include dfs, scph, scppl, tmod, etc
  42. * @{
  43. */
  44. #define DW_SPI_CTRLR0_DFS_MASK (0xf)
  45. #define DW_SPI_CTRLR0_SC_OFS (6)
  46. #define DW_SPI_CTRLR0_SC_MASK (0xC0)
  47. #define DW_SPI_CTRLR0_SCPH_HIGH (0x40)
  48. #define DW_SPI_CTRLR0_SCPH_LOW (0)
  49. #define DW_SPI_CTRLR0_SCPOL_HIGH (0x80)
  50. #define DW_SPI_CTRLR0_SCPOL_LOW (0)
  51. #define DW_SPI_CTRLR0_TMOD_MASK (0x300)
  52. #define DW_SPI_TMOD_TRANSMIT_RECEIVE (0)
  53. #define DW_SPI_TMOD_TRANSMIT_ONLY (0x100)
  54. #define DW_SPI_TMOD_RECEIVE_ONLY (0x200)
  55. #define DW_SPI_TMOD_EEPROM_READ_ONLY (0x300)
  56. #define DW_SPI_CTRLR0_FRF_MOTOROLA (0x0)
  57. #define DW_SPI_CTRLR0_FRF_TI (0x10)
  58. #define DW_SPI_CTRLR0_FRF_MICROWIRE (0x20)
  59. #define DW_SPI_CTRLR0_SLV_OE_DISABLE (1<<10)
  60. #define DW_SPI_CTRLR0_SLV_OE_ENABLE (0)
  61. /** @} */
  62. /**
  63. * \name DesignWare SPI HAL ISR Flags
  64. * \brief DesignWare SPI hal Interrupt Status Flags
  65. * @{
  66. */
  67. #define DW_SPI_TX_OVERFLOW_ERROR (0x2)
  68. #define DW_SPI_RX_UNDERFLOW_ERROR (0x4)
  69. #define DW_SPI_RX_OVERFLOW_ERROR (0x8)
  70. #define DW_SPI_ISR_RX_FIFO_INT_MASK (0x10)
  71. #define DW_SPI_ISR_TX_FIFO_INT_MASK (0x1)
  72. #define DW_SPI_ISR_TX_OVERFLOW_INT_MASK (0x2)
  73. #define DW_SPI_ISR_RX_UNDERFLOW_INT_MASK (0x4)
  74. #define DW_SPI_ISR_RX_OVERFLOW_INT_MASK (0x8)
  75. /** @} */
  76. /**
  77. * \name DesignWare SPI HAL SR Flags
  78. * \brief DesignWare SPI hal Status Flags
  79. * @{
  80. */
  81. #define DW_SPI_SR_DCOL (0x40)
  82. #define DW_SPI_SR_TXE (0x20)
  83. #define DW_SPI_SR_RFF (0x10)
  84. #define DW_SPI_SR_RFNE (0x8)
  85. #define DW_SPI_SR_TFE (0x4)
  86. #define DW_SPI_SR_TFNF (0x2)
  87. #define DW_SPI_SR_BUSY (0x1)
  88. /** @} */
  89. /**
  90. * \name DesignWare SPI HAL SSI Enable Macros
  91. * \brief DesignWare SPI hal ssi enable macros
  92. * @{
  93. */
  94. /* Macros */
  95. #define DW_SPI_SSI_ENABLE (1) /*!< SSI Enable */
  96. #define DW_SPI_SSI_DISABLE (0) /*!< SSI Disable */
  97. /** @} */
  98. /**
  99. * \name DesignWare SPI HAL IMR Macros
  100. * \brief DesignWare SPI hal interrupt mask macros
  101. * @{
  102. */
  103. #define DW_SPI_IMR_MSTIM (0x20) /*!< Multi-Master Contention Interrupt Mask */
  104. #define DW_SPI_IMR_RXFIM (0x10) /*!< Receive FIFO Full Interrupt Mask */
  105. #define DW_SPI_IMR_RXOIM (0x08) /*!< Receive FIFO Overflow Interrupt Mask */
  106. #define DW_SPI_IMR_RXUIM (0x04) /*!< Receive FIFO Underflow Interrupt Mask */
  107. #define DW_SPI_IMR_TXOIM (0x02) /*!< Transmit FIFO Overflow Interrupt Mask */
  108. #define DW_SPI_IMR_TXEIM (0x01) /*!< Transmit FIFO Empty Interrupt Mask */
  109. #define DW_SPI_IMR_XFER (DW_SPI_IMR_TXEIM|DW_SPI_IMR_RXFIM|DW_SPI_IMR_TXOIM|DW_SPI_IMR_RXOIM|DW_SPI_IMR_RXUIM)
  110. /** @} */
  111. #define DW_SPI_SSI_IDLE (1)
  112. #define DW_SPI_SPI_TRANSMIT (1)
  113. #define DW_SPI_SPI_RECEIVE (2)
  114. #define DW_SPI_SSI_MASTER (1)
  115. #define DW_SPI_SSI_SLAVE (0)
  116. #endif /* _DEVICE_DW_SPI_HAL_H_ */