ufs_aio_cfg.h 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268
  1. /* Copyright Statement:
  2. *
  3. * This software/firmware and related documentation ("MediaTek Software") are
  4. * protected under relevant copyright laws. The information contained herein
  5. * is confidential and proprietary to MediaTek Inc. and/or its licensors.
  6. * Without the prior written permission of MediaTek inc. and/or its licensors,
  7. * any reproduction, modification, use or disclosure of MediaTek Software,
  8. * and information contained herein, in whole or in part, shall be strictly prohibited.
  9. */
  10. /* MediaTek Inc. (C) 2015. All rights reserved.
  11. *
  12. * BY OPENING THIS FILE, RECEIVER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
  13. * THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
  14. * RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO RECEIVER ON
  15. * AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES,
  16. * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
  17. * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT.
  18. * NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE
  19. * SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR
  20. * SUPPLIED WITH THE MEDIATEK SOFTWARE, AND RECEIVER AGREES TO LOOK ONLY TO SUCH
  21. * THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. RECEIVER EXPRESSLY ACKNOWLEDGES
  22. * THAT IT IS RECEIVER'S SOLE RESPONSIBILITY TO OBTAIN FROM ANY THIRD PARTY ALL PROPER LICENSES
  23. * CONTAINED IN MEDIATEK SOFTWARE. MEDIATEK SHALL ALSO NOT BE RESPONSIBLE FOR ANY MEDIATEK
  24. * SOFTWARE RELEASES MADE TO RECEIVER'S SPECIFICATION OR TO CONFORM TO A PARTICULAR
  25. * STANDARD OR OPEN FORUM. RECEIVER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND
  26. * CUMULATIVE LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE,
  27. * AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE,
  28. * OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY RECEIVER TO
  29. * MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE.
  30. */
  31. #ifndef _UFS_AIO_CFG_H
  32. #define _UFS_AIO_CFG_H
  33. /*--------------------------------------------------------------------------
  34. * AIO Driver Platform Configuration
  35. *--------------------------------------------------------------------------*/
  36. // ufs not defince platform macro self
  37. /*--------------------------------------------------------------------------
  38. * AIO Driver Environtment Configuration
  39. *--------------------------------------------------------------------------*/
  40. //#define MTK_UFS_DRV_PRELOADER
  41. #define MTK_UFS_DRV_LK
  42. //#define MTK_UFS_DRV_DA
  43. #if defined(MTK_UFS_DRV_PRELOADER)
  44. #if defined(MTK_UFS_DRV_LK) || defined(MTK_UFS_DRV_DA)
  45. #error "Only one environment definition is allowed!"
  46. #endif
  47. #elif defined(MTK_UFS_DRV_LK)
  48. #if defined(MTK_UFS_DRV_PRELOADER) || defined(MTK_UFS_DRV_DA)
  49. #error "Only one environment definition is allowed!"
  50. #endif
  51. #elif defined(MTK_UFS_DRV_DA)
  52. #include "autoconfig.h"
  53. #if defined(MTK_UFS_DRV_PRELOADER) || defined(MTK_UFS_DRV_LK)
  54. #error "Only one environment definition is allowed!"
  55. #endif
  56. #else
  57. #error "One of following definition shall be defined: MTK_UFS_DRV_PRELOADER, MTK_UFS_DRV_LK, MTK_UFS_DRV_DA"
  58. #endif
  59. /*--------------------------------------------------------------------------
  60. * FPGA Definition
  61. *--------------------------------------------------------------------------*/
  62. #if defined(MTK_UFS_DRV_PRELOADER)
  63. #if CFG_FPGA_PLATFORM
  64. #define UFS_CFG_FPGA_PLATFORM
  65. #endif
  66. #elif defined(MTK_UFS_DRV_LK)
  67. #ifdef MACH_FPGA
  68. #define UFS_CFG_FPGA_PLATFORM
  69. #endif
  70. #elif defined(MTK_UFS_DRV_DA)
  71. #if (DA_MODE == DA_MODE_FPGA)
  72. #define UFS_CFG_FPGA_PLATFORM
  73. #endif
  74. #endif
  75. /*--------------------------------------------------------------------------
  76. * Transfer Mode Configuration
  77. *--------------------------------------------------------------------------*/
  78. #if defined(MTK_UFS_DRV_PRELOADER)
  79. #define UFS_CFG_ENABLE_DMA
  80. #define UFS_CFG_DEFAULT_DMA
  81. #elif defined(MTK_UFS_DRV_LK)
  82. #define UFS_CFG_ENABLE_DMA
  83. #define UFS_CFG_DEFAULT_DMA
  84. #elif defined(MTK_UFS_DRV_DA)
  85. #define UFS_CFG_ENABLE_DMA
  86. #define UFS_CFG_DEFAULT_DMA
  87. #endif
  88. #ifdef UFS_CFG_DEFAULT_DMA
  89. #ifndef UFS_CFG_ENABLE_DMA
  90. #error "DMA mode shall be enabled since DMA is selected as default mode"
  91. #endif
  92. #endif
  93. #ifdef UFS_CFG_DEFAULT_PIO
  94. #ifndef UFS_CFG_ENABLE_PIO
  95. #error "PIO mode shall be enabled since PIO is selected as default mode"
  96. #endif
  97. #endif
  98. #if !defined(UFS_CFG_DEFAULT_DMA) && !defined(UFS_CFG_DEFAULT_PIO)
  99. #error "Must define DMA or PIO as default mode"
  100. #endif
  101. #if defined(UFS_CFG_DEFAULT_DMA) && defined(UFS_CFG_DEFAULT_PIO)
  102. #error "Must define only UFS_CFG_DEFAULT_DMA or only UFS_CFG_DEFAULT_PIO"
  103. #endif
  104. /*--------------------------------------------------------------------------*/
  105. /* AIO Driver Features */
  106. /*--------------------------------------------------------------------------*/
  107. /*
  108. * Support single command only
  109. * Must define this currently because AIO driver supports single command only now.
  110. */
  111. #define UFS_CFG_SINGLE_COMMAND
  112. /*
  113. * Defined: Enable UFS raw performance profiling
  114. * Non-defined: Disable UFS raw performance profiling
  115. */
  116. /* #define UFS_CFG_PERFORMANCE_PROFILING */
  117. /*
  118. * Defined: Use slow UFS device speed for safe bring-up. Used during development stage only.
  119. * Non-defined: Use high UFS device speed for performance. Shall be default configuration.
  120. */
  121. /* #define UFS_CFG_SAFE_BRING_UP */
  122. /*
  123. * Defined: Enable HQA mode. Preloader will configure GPIO for MPHY I2C mux and halt to wait for HQA process.
  124. * Non-defined: Disable HQA mode.
  125. */
  126. /* #define UFS_CFG_HQA_MODE */
  127. /*
  128. * Defined: Enable full log levels and debugging purpose code.
  129. * Non-defined: Disable full log levels and debugging purpose code.
  130. */
  131. /* #define UFS_CFG_DEBUG */
  132. #ifdef MTK_UFS_DRV_DA
  133. /*
  134. * Defined: Device reset can be triggerred by SW driver (default)
  135. * Non-defined: Device reset can be triggerred only by watchdog or system reset (for security-concerned customers)
  136. */
  137. #define UFS_CFG_DEVICE_RESET_NONPROTECTED
  138. #endif
  139. /*--------------------------------------------------------------------------
  140. * Debugging Configuration
  141. *--------------------------------------------------------------------------*/
  142. #define UFS_DBG_LVL_VERBOSE 0
  143. #define UFS_DBG_LVL_DEBUG 1
  144. #define UFS_DBG_LVL_INFO 2
  145. #define UFS_DBG_LVL_WARNING 3
  146. #define UFS_DBG_LVL_CRITICAL 4
  147. #define UFS_DBG_LVL_FATAL 5
  148. #if defined(UFS_CFG_SAFE_BRING_UP) || defined(UFS_CFG_DEBUG)
  149. #define UFS_DBG_LVL (UFS_DBG_LVL_DEBUG)
  150. #else
  151. #define UFS_DBG_LVL (UFS_DBG_LVL_INFO)
  152. #endif
  153. /*--------------------------------------------------------------------------
  154. * Common Definition
  155. *--------------------------------------------------------------------------*/
  156. /* UFS PA power modes */
  157. enum {
  158. FAST_MODE = 1,
  159. SLOW_MODE = 2,
  160. FASTAUTO_MODE = 4,
  161. SLOWAUTO_MODE = 5,
  162. UNCHANGED = 7,
  163. };
  164. /* UFS PA TX/RX Frequency Series */
  165. enum {
  166. PA_HS_MODE_A = 1,
  167. PA_HS_MODE_B = 2,
  168. };
  169. /* UFS device default power mode, gear, lane configurations */
  170. #ifndef UFS_CFG_SAFE_BRING_UP
  171. #if defined(MTK_UFS_DRV_PRELOADER)
  172. #if defined(SLT)
  173. #define UFS_DEV_MAX_GEAR_RX (3)
  174. #define UFS_DEV_MAX_GEAR_TX (3)
  175. #else
  176. #define UFS_DEV_MAX_GEAR_RX (1)
  177. #define UFS_DEV_MAX_GEAR_TX (1)
  178. #endif
  179. #define UFS_DEV_MAX_LANE_RX (1)
  180. #define UFS_DEV_MAX_LANE_TX (1)
  181. #define UFS_DEV_DEFAULT_HS_RATE (PA_HS_MODE_B)
  182. #define UFS_DEV_DEFAULT_PWR_RX (FAST_MODE)
  183. #define UFS_DEV_DEFAULT_PWR_TX (FAST_MODE)
  184. #elif defined(MTK_UFS_DRV_LK)
  185. #define UFS_DEV_MAX_GEAR_RX (1)
  186. #define UFS_DEV_MAX_GEAR_TX (1)
  187. #define UFS_DEV_MAX_LANE_RX (1)
  188. #define UFS_DEV_MAX_LANE_TX (1)
  189. #define UFS_DEV_DEFAULT_HS_RATE (PA_HS_MODE_B)
  190. #define UFS_DEV_DEFAULT_PWR_RX (FAST_MODE)
  191. #define UFS_DEV_DEFAULT_PWR_TX (FAST_MODE)
  192. #elif defined(MTK_UFS_DRV_DA)
  193. #ifdef UFS_CFG_FPGA_PLATFORM
  194. #define UFS_DEV_MAX_GEAR_RX (1)
  195. #define UFS_DEV_MAX_GEAR_TX (1)
  196. #else
  197. #define UFS_DEV_MAX_GEAR_RX (3)
  198. #define UFS_DEV_MAX_GEAR_TX (3)
  199. #endif
  200. #define UFS_DEV_MAX_LANE_RX (1)
  201. #define UFS_DEV_MAX_LANE_TX (1)
  202. #define UFS_DEV_DEFAULT_HS_RATE (PA_HS_MODE_B)
  203. #define UFS_DEV_DEFAULT_PWR_RX (FAST_MODE)
  204. #define UFS_DEV_DEFAULT_PWR_TX (FAST_MODE)
  205. #endif
  206. #else
  207. /* Use PWM-G4 for safe bring-up case */
  208. #define UFS_DEV_MAX_GEAR_RX (4)
  209. #define UFS_DEV_MAX_GEAR_TX (4)
  210. #define UFS_DEV_MAX_LANE_RX (1)
  211. #define UFS_DEV_MAX_LANE_TX (1)
  212. #define UFS_DEV_DEFAULT_HS_RATE (PA_HS_MODE_A)
  213. #define UFS_DEV_DEFAULT_PWR_RX (SLOW_MODE)
  214. #define UFS_DEV_DEFAULT_PWR_TX (SLOW_MODE)
  215. #endif
  216. #endif /* _UFS_AIO_CFG_H */