cmem7_ddr.h 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185
  1. /**
  2. *****************************************************************************
  3. * @file cmem7_ddr.h
  4. *
  5. * @brief CMEM7 AES header file
  6. *
  7. *
  8. * @version V1.0
  9. * @date 3. September 2013
  10. *
  11. * @note
  12. *
  13. *****************************************************************************
  14. * @attention
  15. *
  16. * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
  17. * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE
  18. * TIME. AS A RESULT, CAPITAL-MICRO SHALL NOT BE HELD LIABLE FOR ANY DIRECT,
  19. * INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING
  20. * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE
  21. * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
  22. *
  23. * <h2><center>&copy; COPYRIGHT 2013 Capital-micro </center></h2>
  24. *****************************************************************************
  25. */
  26. #ifndef __CMEM7_DDR_H
  27. #define __CMEM7_DDR_H
  28. #ifdef __cplusplus
  29. extern "C" {
  30. #endif
  31. #include "cmem7.h"
  32. #include "cmem7_conf.h"
  33. /** @defgroup _MEM_TYPE
  34. * @{
  35. */
  36. enum _MEM_TYPE
  37. {
  38. MEM_DDR2=1,
  39. MEM_DDR3
  40. } ;
  41. /**
  42. * @}
  43. */
  44. /** @defgroup _BUS_WIDTH
  45. * @{
  46. */
  47. enum _BUS_WIDTH
  48. {
  49. BUS_WIDTH_8,
  50. BUS_WIDTH_16,
  51. BUS_WIDTH_MAX
  52. };
  53. /**
  54. * @}
  55. */
  56. /** @defgroup _CHIP_TYPE
  57. * @{
  58. */
  59. enum _CHIP_TYPE
  60. {
  61. _32Mbx8,
  62. _64Mbx8,
  63. _128Mbx8,
  64. _256Mbx8,
  65. _512Mbx8,
  66. _16Mbx16,
  67. _32Mbx16,
  68. _64Mbx16,
  69. _128Mbx16,
  70. _256Mbx16,
  71. _512Mbx16,
  72. CHIP_TYPE_MAX
  73. };
  74. /**
  75. * @}
  76. */
  77. /** @defgroup _CHIP_NUM
  78. * @{
  79. */
  80. enum _CHIP_NUM
  81. {
  82. CHIP_NUM_x1,
  83. CHIP_NUM_x2,
  84. CHIP_NUM_MAX
  85. };
  86. /**
  87. * @}
  88. */
  89. /** @defgroup MEM_CHIP_INFO
  90. * @{
  91. */
  92. typedef struct {
  93. uint8_t mem_type; /*!< ddr type @ref _MEM_TYPE*/
  94. uint8_t Bus_width; /*!< ddr qs bus width @ref _BUS_WIDTH*/
  95. uint8_t Chip_type; /*!< chip type @ref _CHIP_TYPE*/
  96. uint8_t Chip_num; /*!< chip number @ref _CHIP_NUM*/
  97. uint8_t Chip_bank; /*!< chip bank number*/
  98. } MEM_CHIP_INFO;
  99. /**
  100. * @}
  101. */
  102. /** @defgroup DDR2MEM
  103. * @{
  104. */
  105. typedef struct {
  106. uint32_t tCK; /*!< Period of clock(ps), not data period */
  107. uint32_t tCL; /*!< tCL */
  108. uint32_t tRCD; /*!< tRCD */
  109. uint32_t tRP; /*!< tRP */
  110. uint32_t tRC; /*!< tRC */
  111. uint32_t tRAS; /*!< tRAS */
  112. uint32_t tWR; /*!< tWR */
  113. uint32_t tRRD; /*!< tRRD */
  114. uint32_t tWTR; /*!< tWTR */
  115. uint32_t tRTP; /*!< tRTP */
  116. uint32_t tFAW; /*!< tFAW */
  117. } DDR2MEM; /*!< DDR2ʱÐò¶¨Òå */
  118. /**
  119. * @}
  120. */
  121. /** @defgroup DDR3MEM
  122. * @{
  123. */
  124. typedef struct {
  125. uint32_t tCK; /*!< Period of clock(ps), not data period */
  126. uint32_t tCL; /*!< tCL */
  127. uint32_t tWCL; /*!< tWCL */
  128. uint32_t tRCD; /*!< tRCD */
  129. uint32_t tRAS; /*!< tRAS */
  130. uint32_t tRP; /*!< tRP */
  131. uint32_t tRC; /*!< tRC */
  132. uint32_t tRRD; /*!< tRRD */
  133. uint32_t tFAW; /*!< tFAW */
  134. uint32_t tWR; /*!< tWR */
  135. uint32_t tRTP; /*!< tRTP */
  136. uint32_t tZQoper; /*!< tZQCL */
  137. uint32_t tZQCS; /*!< tZQCS */
  138. } DDR3MEM; /*!< DDR3ʱÐò¶¨Òå */
  139. /**
  140. * @}
  141. */
  142. /** @defgroup DDR2PREDEF
  143. * @{
  144. */
  145. extern const DDR2MEM DDR2PREDEF[]; /*!< Pre-defined DDR2 Timing in library */
  146. #define DDR2_400C 0 /*!< sg5E: DDR2-400C CL=4, tCK=5000ps */
  147. /**
  148. * @}
  149. */
  150. /** @defgroup DDR3PREDEF
  151. * @{
  152. */
  153. extern const DDR3MEM DDR3PREDEF[]; /*!< Pre-defined DDR3 Timing in library */
  154. #define DDR3_400 0
  155. #define DDR3_667 1
  156. /**
  157. * @}
  158. */
  159. /**
  160. * @brief DDR Timing Configuration
  161. * @param[in] chip information ,A pointer to struct @ref MEM_CHIP_INFO
  162. * @param[in] ddr A pointer to struct @ref DDR2MEM or @ref DDR3MEM that specified DDR Timing. Some typital DDR2/3 Timings are defined in arrays @ref DDR2PREDEF and @ref DDR3PREDEF.
  163. * @retval void
  164. */
  165. BOOL DDR_Init(const MEM_CHIP_INFO *chip_info, const void *ddr);
  166. #ifdef __cplusplus
  167. }
  168. #endif
  169. #endif /* __CMEM7_DDR_H */