dbg.h 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  1. #ifndef __MT_MSDC_DEUBG__
  2. #define __MT_MSDC_DEUBG__
  3. #include "mt_sd.h"
  4. #include<mt-plat/upmu_common.h>
  5. /* ========================== */
  6. extern u32 sdio_pro_enable;
  7. extern void __iomem *gpio_reg_base;
  8. extern void __iomem *infracfg_ao_reg_base;
  9. extern void __iomem *infracfg_reg_base;
  10. extern void __iomem *pericfg_reg_base;
  11. extern void __iomem *emi_reg_base;
  12. extern void __iomem *toprgu_reg_base;
  13. extern void __iomem *apmixed_reg_base1;
  14. extern void __iomem *topckgen_reg_base;
  15. extern void msdc_dump_info(u32 id);
  16. #ifndef FPGA_PLATFORM
  17. extern void msdc_set_driving(struct msdc_host *host, struct msdc_hw *hw, bool sd_18);
  18. extern void msdc_set_sr(struct msdc_host *host, int clk, int cmd, int dat, int rst, int ds);
  19. extern void msdc_set_smt(struct msdc_host *host, int set_smt);
  20. extern void msdc_set_rdtdsel_dbg(struct msdc_host *host, bool rdsel, u32 value);
  21. extern void msdc_get_rdtdsel_dbg(struct msdc_host *host, bool rdsel, u32 *value);
  22. #endif
  23. extern int ettagent_init(void);
  24. extern void ettagent_exit(void);
  25. extern int mmc_send_ext_csd(struct mmc_card *card, u8 *ext_csd);
  26. #ifdef MSDC_HQA
  27. extern void pmic_config_interface(unsigned int, unsigned int, unsigned int, unsigned int);
  28. #endif
  29. #ifdef ONLINE_TUNING_DVTTEST
  30. extern int mt_msdc_online_tuning_test(struct msdc_host *host, u32 rawcmd, u32 rawarg, u8 rw);
  31. #endif
  32. /* for a type command, e.g. CMD53, 2 blocks */
  33. struct cmd_profile {
  34. u32 max_tc; /* Max tick count */
  35. u32 min_tc;
  36. u32 tot_tc; /* total tick count */
  37. u32 tot_bytes;
  38. u32 count; /* the counts of the command */
  39. };
  40. /* dump when total_tc and total_bytes */
  41. struct sdio_profile {
  42. u32 total_tc; /* total tick count of CMD52 and CMD53 */
  43. u32 total_tx_bytes; /* total bytes of CMD53 Tx */
  44. u32 total_rx_bytes; /* total bytes of CMD53 Rx */
  45. /*CMD52 */
  46. struct cmd_profile cmd52_tx;
  47. struct cmd_profile cmd52_rx;
  48. /*CMD53 in byte unit */
  49. struct cmd_profile cmd53_tx_byte[512];
  50. struct cmd_profile cmd53_rx_byte[512];
  51. /*CMD53 in block unit */
  52. struct cmd_profile cmd53_tx_blk[100];
  53. struct cmd_profile cmd53_rx_blk[100];
  54. };
  55. #ifdef MTK_MSDC_ERROR_TUNE_DEBUG
  56. #define MTK_MSDC_ERROR_NONE (0)
  57. #define MTK_MSDC_ERROR_CMD_TMO (0x1)
  58. #define MTK_MSDC_ERROR_CMD_CRC (0x1 << 1)
  59. #define MTK_MSDC_ERROR_DAT_TMO (0x1 << 2)
  60. #define MTK_MSDC_ERROR_DAT_CRC (0x1 << 3)
  61. #define MTK_MSDC_ERROR_ACMD_TMO (0x1 << 4)
  62. #define MTK_MSDC_ERROR_ACMD_CRC (0x1 << 5)
  63. extern unsigned int g_err_tune_dbg_host;
  64. extern unsigned int g_err_tune_dbg_cmd;
  65. extern unsigned int g_err_tune_dbg_arg;
  66. extern unsigned int g_err_tune_dbg_error;
  67. extern unsigned int g_err_tune_dbg_count;
  68. #endif
  69. /* ========================== */
  70. typedef enum {
  71. SD_TOOL_ZONE = 0,
  72. SD_TOOL_DMA_SIZE = 1,
  73. SD_TOOL_PM_ENABLE = 2,
  74. SD_TOOL_SDIO_PROFILE = 3,
  75. SD_TOOL_CLK_SRC_SELECT = 4,
  76. SD_TOOL_REG_ACCESS = 5,
  77. SD_TOOL_SET_DRIVING = 6,
  78. SD_TOOL_DESENSE = 7,
  79. RW_BIT_BY_BIT_COMPARE = 8,
  80. SMP_TEST_ON_ONE_HOST = 9,
  81. SMP_TEST_ON_ALL_HOST = 10,
  82. SD_TOOL_MSDC_HOST_MODE = 11,
  83. SD_TOOL_DMA_STATUS = 12,
  84. SD_TOOL_ENABLE_SLEW_RATE = 13,
  85. SD_TOOL_ENABLE_SMT = 14,
  86. MMC_PERF_DEBUG = 15,
  87. MMC_PERF_DEBUG_PRINT = 16,
  88. SD_TOOL_SET_RDTDSEL = 17,
  89. MMC_REGISTER_READ = 18,
  90. MMC_REGISTER_WRITE = 19,
  91. MSDC_READ_WRITE = 20,
  92. MMC_ERROR_TUNE = 21,
  93. MMC_EDC_EMMC_CACHE = 22,
  94. MMC_DUMP_GPD = 23,
  95. MMC_ETT_TUNE = 24,
  96. MMC_CRC_STRESS = 25,
  97. ENABLE_AXI_MODULE = 26,
  98. } msdc_dbg;
  99. typedef struct {
  100. unsigned char clk_drv;
  101. unsigned char cmd_drv;
  102. unsigned char dat_drv;
  103. unsigned char rst_drv;
  104. unsigned char ds_drv;
  105. } drv_mod;
  106. extern u32 dma_size[HOST_MAX_NUM];
  107. extern unsigned char msdc_clock_src[HOST_MAX_NUM];
  108. extern drv_mod msdc_drv_mode[HOST_MAX_NUM];
  109. extern u32 msdc_host_mode[HOST_MAX_NUM]; /*SD/eMMC mode (HS/DDR/UHS) */
  110. extern u32 msdc_host_mode2[HOST_MAX_NUM];
  111. extern int g_dma_debug[HOST_MAX_NUM];
  112. #ifdef MSDC_DMA_ADDR_DEBUG
  113. extern struct dma_addr msdc_latest_dma_address[MAX_BD_PER_GPD];
  114. #endif
  115. extern struct dma_addr *msdc_get_dma_address(int host_id);
  116. extern int msdc_get_dma_status(int host_id);
  117. extern int emmc_multi_rw_compare(int host_num, uint address, int count);
  118. extern int msdc_tune_write(struct msdc_host *host);
  119. extern int msdc_tune_read(struct msdc_host *host);
  120. extern int msdc_tune_cmdrsp(struct msdc_host *host);
  121. extern int emmc_hs400_tune_rw(struct msdc_host *host);
  122. extern void msdc_dump_gpd_bd(int id);
  123. extern void msdc_dump_register(struct msdc_host *host);
  124. extern int g_ett_tune;
  125. extern int g_ett_hs400_tune;
  126. extern int g_ett_cmd_tune;
  127. extern int g_ett_read_tune;
  128. extern int g_ett_write_tune;
  129. extern int g_reset_tune;
  130. extern u32 sdio_enable_tune;
  131. extern u32 sdio_iocon_dspl;
  132. extern u32 sdio_iocon_w_dspl;
  133. extern u32 sdio_iocon_rspl;
  134. extern u32 sdio_pad_tune_rrdly;
  135. extern u32 sdio_pad_tune_rdly;
  136. extern u32 sdio_pad_tune_wrdly;
  137. extern u32 sdio_dat_rd_dly0_0;
  138. extern u32 sdio_dat_rd_dly0_1;
  139. extern u32 sdio_dat_rd_dly0_2;
  140. extern u32 sdio_dat_rd_dly0_3;
  141. extern u32 sdio_dat_rd_dly1_0;
  142. extern u32 sdio_dat_rd_dly1_1;
  143. extern u32 sdio_dat_rd_dly1_2;
  144. extern u32 sdio_dat_rd_dly1_3;
  145. extern u32 sdio_clk_drv;
  146. extern u32 sdio_cmd_drv;
  147. extern u32 sdio_data_drv;
  148. extern u32 sdio_tune_flag;
  149. int msdc_debug_proc_init(void);
  150. extern void GPT_GetCounter64(u32 *cntL32, u32 *cntH32);
  151. u32 msdc_time_calc(u32 old_L32, u32 old_H32, u32 new_L32, u32 new_H32);
  152. void msdc_performance(u32 opcode, u32 sizes, u32 bRx, u32 ticks);
  153. #endif