hal_spi_nand.h 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  1. /* Copyright (C) 2018 RDA Technologies Limited and/or its affiliates("RDA").
  2. * All rights reserved.
  3. *
  4. * This software is supplied "AS IS" without any warranties.
  5. * RDA assumes no responsibility or liability for the use of the software,
  6. * conveys no license or title under any patent, copyright, or mask work
  7. * right to the product. RDA reserves the right to make changes in the
  8. * software without notification. RDA also make no representation or
  9. * warranty that such application will be suitable for the specified use
  10. * without further testing or modification.
  11. */
  12. #ifndef _HAL_SPI_NAND_H_
  13. #define _HAL_SPI_NAND_H_
  14. #include <stdint.h>
  15. #include <stdbool.h>
  16. #include <stddef.h>
  17. #ifdef __cplusplus
  18. extern "C" {
  19. #endif
  20. /**
  21. * \brief read manufacture/device id
  22. *
  23. * \param hwp hardware register base
  24. * \return
  25. * - 2 bytes manufacture id and device id
  26. */
  27. uint32_t halSpiNandReadId(uintptr_t hwp);
  28. /**
  29. * \brief get device status
  30. *
  31. * \param hwp hardware register base
  32. * \param addr status address (A0H/B0H/C0H)
  33. * \return
  34. * - device status
  35. */
  36. uint8_t halSpiNandGetFeature(uintptr_t hwp, uint8_t addr);
  37. /**
  38. * \brief set device status
  39. *
  40. * \param hwp hardware register base
  41. * \param addr status address (A0H/B0H/C0H)
  42. * \param val device status
  43. */
  44. void halSpiNandSetFeature(uintptr_t hwp, uint8_t addr, uint8_t val);
  45. /**
  46. * \brief write enable
  47. *
  48. * \param hwp hardware register base
  49. */
  50. void halSpiNandWriteEnable(uintptr_t hwp);
  51. /**
  52. * \brief write disable
  53. *
  54. * \param hwp hardware register base
  55. */
  56. void halSpiNandWriteDisable(uintptr_t hwp);
  57. /**
  58. * \brief read flash array to device cache
  59. *
  60. * \param hwp hardware register base
  61. * \param row_addr row address
  62. */
  63. void halSpiNandPageReadToCache(uintptr_t hwp, uint32_t row_addr);
  64. /**
  65. * \brief read from device cache
  66. *
  67. * \param hwp hardware register base
  68. * \param col_addr address inside page
  69. * \param data memory of read data
  70. * \param size read size
  71. */
  72. void halSpiNandPageRead(uintptr_t hwp, uint32_t col_addr, void *data, unsigned size);
  73. /**
  74. * \brief read from device cache
  75. *
  76. * Command and address are single, data are quad.
  77. *
  78. * \param hwp hardware register base
  79. * \param col_addr address inside page
  80. * \param data memory of read data
  81. * \param size read size
  82. */
  83. void halSpiNandPageReadX4(uintptr_t hwp, uint32_t col_addr, void *data, unsigned size);
  84. /**
  85. * \brief read from device cache
  86. *
  87. * Command is single, address and data are quad.
  88. *
  89. * \param hwp hardware register base
  90. * \param col_addr address inside page
  91. * \param data memory of read data
  92. * \param size read size
  93. */
  94. void halSpiNandPageReadQuad(uintptr_t hwp, uint32_t col_addr, void *data, unsigned size);
  95. /**
  96. * \brief load data to device cache
  97. *
  98. * \param hwp hardware register base
  99. * \param col_addr address inside page
  100. * \param data data to be load
  101. * \param size read size
  102. */
  103. void halSpiNandProgramLoadRandom(uintptr_t hwp, uint32_t col_addr, const void *data, unsigned size);
  104. /**
  105. * \brief load data to device cache
  106. *
  107. * Command and address are single, data are quad.
  108. *
  109. * \param hwp hardware register base
  110. * \param col_addr address inside page
  111. * \param data data to be load
  112. * \param size read size
  113. */
  114. void halSpiNandProgramLoadRandomX4(uintptr_t hwp, uint32_t col_addr, const void *data, unsigned size);
  115. /**
  116. * \brief load data to device cache
  117. *
  118. * Command is single, address and data are quad.
  119. *
  120. * \param hwp hardware register base
  121. * \param col_addr address inside page
  122. * \param data data to be load
  123. * \param size read size
  124. */
  125. void halSpiNandProgramLoadRandomQuad(uintptr_t hwp, uint32_t col_addr, const void *data, unsigned size);
  126. /**
  127. * \brief program execute
  128. *
  129. * \param hwp hardware register base
  130. * \param row_addr row address
  131. */
  132. void halSpiNandProgramExec(uintptr_t hwp, uint32_t row_addr);
  133. /**
  134. * \brief erase block
  135. *
  136. * \param hwp hardware register base
  137. * \param row_addr row address
  138. */
  139. void halSpiNandBlockErase(uintptr_t hwp, uint32_t row_addr);
  140. /**
  141. * \brief reset (stop all operations)
  142. *
  143. * \param hwp hardware register base
  144. */
  145. void halSpiNandReset(uintptr_t hwp);
  146. /**
  147. * \brief whether operation is finished
  148. *
  149. * It will check OIP bit in device status.
  150. *
  151. * \param hwp hardware register base
  152. */
  153. bool halSpiNandIsOpFinished(uintptr_t hwp);
  154. /**
  155. * \brief wait operation finished
  156. *
  157. * \param hwp hardware register base
  158. */
  159. void halSpiNandWaitOpFinished(uintptr_t hwp);
  160. #ifdef __cplusplus
  161. }
  162. #endif
  163. #endif