mmc_test.h 7.1 KB

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