mmc_test.h 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189
  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) 2018. 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. * The following software/firmware and/or related documentation ("MediaTek Software")
  32. * have been modified by MediaTek Inc. All revisions are subject to any receiver\'s
  33. * applicable license agreements with MediaTek Inc.
  34. */
  35. #ifndef MMC_TEST_H
  36. #define MMC_TEST_H
  37. #ifdef __cplusplus
  38. extern "C" {
  39. #endif
  40. #define MMC_TST_BUF_ADDR (0x01000000)
  41. #ifdef MMC_PROFILING
  42. #define MMC_TST_SIZE (4 * 1024 * 1024) /* 4MB */
  43. #define MMC_TST_CHUNK_BLKS (128) /* 64KB */
  44. #else
  45. #if defined(MSDC_INTSRAM)
  46. #define MMC_TST_SIZE (16 * 1024) /* 16KB */
  47. #else
  48. #ifndef FPGA_PLATFORM
  49. #define MMC_TST_SIZE (8 * 1024 * 1024) /* 8MB for test bit 23 of GPD/BD buffer size */
  50. #else
  51. #define MMC_TST_SIZE (1 * 1024 * 1024) /* 1MB for test bit 23 of GPD/BD buffer size */
  52. #endif
  53. #endif
  54. #define MMC_TST_CHUNK_BLKS (128) /* 8KB */
  55. //#define MMC_TST_CHUNK_BLKS (32 * 1024 - 1) /* 65535 blocks*/
  56. #endif
  57. #define MMC_TST_START_ADDR (128 * 1024 * 1024) /* 128MB */
  58. #define MMC_TST_START_BLK (MMC_TST_START_ADDR / MMC_BLOCK_SIZE)
  59. #define MMC_TST_BLK_NR(x) (MMC_TST_START_BLK+(x)*(MMC_TST_SIZE/MMC_BLOCK_SIZE))
  60. #define MAX_TEST_BLK_LEN (4096)
  61. struct mmc_test_config {
  62. char *desc; /* description */
  63. int id; /* host id to test */
  64. int autocmd; /* auto command */
  65. int cmd23_flags; /* reliable write, force prog, etc */
  66. int mode; /* PIO/DMA mode */
  67. int uhsmode; /* UHS mode */
  68. int burstsz; /* DMA burst size */
  69. int piobits;
  70. unsigned int flags; /* DMA flags */
  71. int count; /* repeat counts */
  72. int clksrc; /* clock source */
  73. unsigned int clock; /* clock frequency for testing */
  74. unsigned int buswidth; /* bus width */
  75. unsigned long blknr; /* n'th block number for read/write test */
  76. unsigned int total_size; /* total size to test */
  77. unsigned int blksz; /* block size */
  78. int chunk_blks; /* blocks of chunk */
  79. char *buf; /* read/write buffer */
  80. unsigned char chk_result; /* check write result? */
  81. unsigned char skip_reinit; /* necessity of reinit when count != 1 */
  82. unsigned char tst_single; /* test single block read/write? */
  83. unsigned char tst_multiple; /* test multiple block read/write? */
  84. unsigned char tst_interleave; /* test interleave block read/write ? */
  85. unsigned char single_bst;
  86. unsigned char start_bit; /* start bit of read data */
  87. unsigned char axi_burst_len; /* axi command length per one burst */
  88. unsigned char axi_rd_os; /* axi read outstanding number */
  89. unsigned char axi_wr_os; /* axi write outstanding number */
  90. unsigned char dcm_enable;
  91. unsigned char dcm_div1;
  92. unsigned char dcm_div2;
  93. };
  94. struct mmc_op_report {
  95. unsigned long count; /* the count of this operation */
  96. unsigned long min_time; /* the min. time of this operation */
  97. unsigned long max_time; /* the max. time of this operation */
  98. unsigned long total_time; /* the total time of this operation */
  99. unsigned long total_size; /* the total size of this operation */
  100. };
  101. struct mmc_op_perf {
  102. struct mmc_host *host;
  103. struct mmc_card *card;
  104. struct mmc_op_report single_blk_read;
  105. struct mmc_op_report single_blk_write;
  106. struct mmc_op_report multi_blks_read;
  107. struct mmc_op_report multi_blks_write;
  108. };
  109. typedef struct {
  110. /* register offset */
  111. u32 offset;
  112. /* r: read only, w: write only, a:readable & writable
  113. * k: read clear, x: don't care, n: do not test
  114. * s: readable and write 1 set, c: readable and write 1 clear
  115. *
  116. * RU: read only bit value update by the hw, denote as 'r', like MSDC_RXDATA
  117. * RO: read only, denote as 'r', like MSDC_VERSION
  118. * RW: writeable and readable, denote as 'a'
  119. * WO: write only, denote as 'w', like MSDC_TXDATA
  120. * W1: write once, denote as '', not used yet.
  121. * RC: clear on read, denote as 'k', not used yet.
  122. * A1: auto set by the hw.
  123. * A0: auto clear by the hw.
  124. * DC: don't care, denote as 'n' or 'x'
  125. * W1C: write 1 to bit wise-clear, denote as 'c', like SDC_CSTS
  126. * note: RU means the content of the regiter will change,
  127. * RO means the content of the register will not change
  128. */
  129. char attr[32];
  130. /* 0: default is 0
  131. * 1: default is 1
  132. * x: don't care
  133. */
  134. char reset[32];
  135. } reg_desc_t;
  136. typedef void (*mmc_prof_callback)(void *data, ulong id, ulong counts);
  137. #ifdef MMC_PROFILING
  138. extern struct mmc_op_perf *mmc_prof_handle(int id);
  139. extern void mmc_prof_init(int id, struct mmc_host *host, struct mmc_card *card);
  140. extern void mmc_prof_start(void);
  141. extern void mmc_prof_stop(void);
  142. extern unsigned int mmc_prof_count(void);
  143. extern void mmc_prof_update(mmc_prof_callback cb, ulong id, void *data);
  144. extern void mmc_prof_report(struct mmc_op_report *rpt);
  145. extern int mmc_prof_dump(int dev_id);
  146. #else
  147. #define mmc_prof_handle(i) NULL
  148. #define mmc_prof_init(i,h,c) do{}while(0)
  149. #define mmc_prof_count() 0
  150. #define mmc_prof_start() do{}while(0)
  151. #define mmc_prof_stop() do{}while(0)
  152. #define mmc_prof_update(c,i,d) do{}while(0)
  153. #define mmc_prof_report(rpt) do{}while(0)
  154. #define mmc_prof_dump(id) do{}while(0)
  155. #endif
  156. #ifdef MMC_TEST
  157. extern int msdc_reg_test(struct mmc_host *host, int id, int clock_gate_test);
  158. extern int mmc_test(int argc, char *argv[]);
  159. #ifdef MTK_EMMC_SUPPORT_OTP
  160. int mmc_otp_test();
  161. #endif
  162. #else
  163. #define mmc_test(c,v) 0
  164. #endif
  165. #if defined(MTK_POWER_ON_WP) || defined(FEATURE_MMC_POWER_ON_WP)
  166. extern int mmc_wp_test();
  167. #endif
  168. #ifdef __cplusplus
  169. }
  170. #endif
  171. #endif /* MMC_TEST_H */