OpenWrt – Diff between revs 2 and 3

Subversion Repositories:
Rev:
Show entire fileIgnore whitespace
Rev 2 Rev 3
Line 30... Line 30...
30 * 30 *
31 * The following software/firmware and/or related documentation ("MediaTek Software") 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 32 * have been modified by MediaTek Inc. All revisions are subject to any receiver's
33 * applicable license agreements with MediaTek Inc. 33 * applicable license agreements with MediaTek Inc.
34 */ 34 */
35   35
36 #include <linux/version.h> 36 #include <linux/version.h>
37 #include <linux/kernel.h> 37 #include <linux/kernel.h>
38 #include <linux/sched.h> 38 #include <linux/sched.h>
39 #include <linux/kthread.h> 39 #include <linux/kthread.h>
40 #include <linux/delay.h> 40 #include <linux/delay.h>
Line 46... Line 46...
46 // #include <mach/mt6575_gpt.h> /* --- by chhung */ 46 // #include <mach/mt6575_gpt.h> /* --- by chhung */
47 #include "dbg.h" 47 #include "dbg.h"
48 #include "mt6575_sd.h" 48 #include "mt6575_sd.h"
49 #include <linux/seq_file.h> 49 #include <linux/seq_file.h>
Line -... Line 50...
-   50  
-   51 /* mode select */
-   52 u32 dma_size[4]={
-   53 512,
-   54 512,
-   55 512,
-   56 512
-   57 };
-   58 msdc_mode drv_mode[4]={
-   59 MODE_SIZE_DEP, /* using DMA or not depend on the size */
-   60 MODE_SIZE_DEP,
-   61 MODE_SIZE_DEP,
-   62 MODE_SIZE_DEP
-   63 };
-   64  
50   65 #if defined (MT6575_SD_DEBUG)
Line 51... Line 66...
51 static char cmd_buf[256]; 66 static char cmd_buf[256];
52   67  
53 /* for debug zone */ 68 /* for debug zone */
54 unsigned int sd_debug_zone[4] = { 69 static unsigned int sd_debug_zone[4]={
55 0, 70 0,
56 0, 71 0,
57 0, 72 0,
Line 58... Line -...
58 0 -  
-   73 0
59 }; 74 };
60   75  
61 #if defined(MT6575_SD_DEBUG) 76  
62 /* for driver profile */ 77 /* for driver profile */
63 #define TICKS_ONE_MS (13000) 78 #define TICKS_ONE_MS (13000)
64 u32 gpt_enable; 79 u32 gpt_enable = 0;
Line 65... Line 80...
65 u32 sdio_pro_enable; /* make sure gpt is enabled */ 80 u32 sdio_pro_enable = 0; /* make sure gpt is enabled */
66 u32 sdio_pro_time; /* no more than 30s */ 81 u32 sdio_pro_time = 0; /* no more than 30s */
67 struct sdio_profile sdio_perfomance = {0}; 82 struct sdio_profile sdio_perfomance = {0};
68   83  
69 #if 0 /* --- chhung */ 84 #if 0 /* --- chhung */
70 void msdc_init_gpt(void) 85 void msdc_init_gpt(void)
71 { 86 {
72 GPT_CONFIG config; 87 GPT_CONFIG config;
73   88
74 config.num = GPT6; 89 config.num = GPT6;
75 config.mode = GPT_FREE_RUN; 90 config.mode = GPT_FREE_RUN;
76 config.clkSrc = GPT_CLK_SRC_SYS; 91 config.clkSrc = GPT_CLK_SRC_SYS;
77 config.clkDiv = GPT_CLK_DIV_1; /* 13MHz GPT6 */ 92 config.clkDiv = GPT_CLK_DIV_1; /* 13MHz GPT6 */
78   93
79 if (GPT_Config(config) == FALSE) 94 if (GPT_Config(config) == FALSE )
80 return; 95 return;
Line 81... Line 96...
81   96
82 GPT_Start(GPT6); 97 GPT_Start(GPT6);
83 } 98 }
84 #endif /* end of --- */ 99 #endif /* end of --- */
85   100  
86 u32 msdc_time_calc(u32 old_L32, u32 old_H32, u32 new_L32, u32 new_H32) 101 u32 msdc_time_calc(u32 old_L32, u32 old_H32, u32 new_L32, u32 new_H32)
87 { 102 {
88 u32 ret = 0; 103 u32 ret = 0;
89   104
-   105 if (new_H32 == old_H32) {
90 if (new_H32 == old_H32) { 106 ret = new_L32 - old_L32;
91 ret = new_L32 - old_L32; 107 } else if(new_H32 == (old_H32 + 1)) {
92 } else if (new_H32 == (old_H32 + 1)) { 108 if (new_L32 > old_L32) {
93 if (new_L32 > old_L32) 109 printk("msdc old_L<0x%x> new_L<0x%x>\n", old_L32, new_L32);
94 printk("msdc old_L<0x%x> new_L<0x%x>\n", old_L32, new_L32); 110 }
Line 95... Line 111...
95 ret = (0xffffffff - old_L32); 111 ret = (0xffffffff - old_L32);
96 ret += new_L32; 112 ret += new_L32;
Line 97... Line 113...
97 } else { 113 } else {
98 printk("msdc old_H<0x%x> new_H<0x%x>\n", old_H32, new_H32); 114 printk("msdc old_H<0x%x> new_H<0x%x>\n", old_H32, new_H32);
99 } 115 }
100   116  
101 return ret; 117 return ret;
102 } 118 }
103   119  
104 void msdc_sdio_profile(struct sdio_profile *result) 120 void msdc_sdio_profile(struct sdio_profile* result)
105 { 121 {
106 struct cmd_profile *cmd; 122 struct cmd_profile* cmd;
107 u32 i; 123 u32 i;
108   124
109 printk("sdio === performance dump ===\n"); 125 printk("sdio === performance dump ===\n");
110 printk("sdio === total execute tick<%d> time<%dms> Tx<%dB> Rx<%dB>\n", 126 printk("sdio === total execute tick<%d> time<%dms> Tx<%dB> Rx<%dB>\n",
111 result->total_tc, result->total_tc / TICKS_ONE_MS, 127 result->total_tc, result->total_tc / TICKS_ONE_MS,
112 result->total_tx_bytes, result->total_rx_bytes); 128 result->total_tx_bytes, result->total_rx_bytes);
113   129  
114 /* CMD52 Dump */ 130 /* CMD52 Dump */
115 cmd = &result->cmd52_rx; 131 cmd = &result->cmd52_rx;
116 printk("sdio === CMD52 Rx <%d>times tick<%d> Max<%d> Min<%d> Aver<%d>\n", cmd->count, cmd->tot_tc, 132 printk("sdio === CMD52 Rx <%d>times tick<%d> Max<%d> Min<%d> Aver<%d>\n", cmd->count, cmd->tot_tc,
117 cmd->max_tc, cmd->min_tc, cmd->tot_tc / cmd->count); 133 cmd->max_tc, cmd->min_tc, cmd->tot_tc/cmd->count);
118 cmd = &result->cmd52_tx; 134 cmd = &result->cmd52_tx;
119 printk("sdio === CMD52 Tx <%d>times tick<%d> Max<%d> Min<%d> Aver<%d>\n", cmd->count, cmd->tot_tc, 135 printk("sdio === CMD52 Tx <%d>times tick<%d> Max<%d> Min<%d> Aver<%d>\n", cmd->count, cmd->tot_tc,
120 cmd->max_tc, cmd->min_tc, cmd->tot_tc / cmd->count); 136 cmd->max_tc, cmd->min_tc, cmd->tot_tc/cmd->count);
121   137
122 /* CMD53 Rx bytes + block mode */ 138 /* CMD53 Rx bytes + block mode */
123 for (i = 0; i < 512; i++) { 139 for (i=0; i<512; i++) {
124 cmd = &result->cmd53_rx_byte[i]; 140 cmd = &result->cmd53_rx_byte[i];
125 if (cmd->count) { 141 if (cmd->count) {
126 printk("sdio<%6d><%3dB>_Rx_<%9d><%9d><%6d><%6d>_<%9dB><%2dM>\n", cmd->count, i, cmd->tot_tc, 142 printk("sdio<%6d><%3dB>_Rx_<%9d><%9d><%6d><%6d>_<%9dB><%2dM>\n", cmd->count, i, cmd->tot_tc,
127 cmd->max_tc, cmd->min_tc, cmd->tot_tc / cmd->count, 143 cmd->max_tc, cmd->min_tc, cmd->tot_tc/cmd->count,
128 cmd->tot_bytes, (cmd->tot_bytes / 10) * 13 / (cmd->tot_tc / 10)); 144 cmd->tot_bytes, (cmd->tot_bytes/10)*13 / (cmd->tot_tc/10));
129 } 145 }
130 } 146 }
131 for (i = 0; i < 100; i++) { 147 for (i=0; i<100; i++) {
132 cmd = &result->cmd53_rx_blk[i]; 148 cmd = &result->cmd53_rx_blk[i];
133 if (cmd->count) { 149 if (cmd->count) {
134 printk("sdio<%6d><%3d>B_Rx_<%9d><%9d><%6d><%6d>_<%9dB><%2dM>\n", cmd->count, i, cmd->tot_tc, 150 printk("sdio<%6d><%3d>B_Rx_<%9d><%9d><%6d><%6d>_<%9dB><%2dM>\n", cmd->count, i, cmd->tot_tc,
135 cmd->max_tc, cmd->min_tc, cmd->tot_tc / cmd->count, 151 cmd->max_tc, cmd->min_tc, cmd->tot_tc/cmd->count,
136 cmd->tot_bytes, (cmd->tot_bytes / 10) * 13 / (cmd->tot_tc / 10)); 152 cmd->tot_bytes, (cmd->tot_bytes/10)*13 / (cmd->tot_tc/10));
137 } 153 }
138 } 154 }
139   155  
140 /* CMD53 Tx bytes + block mode */ 156 /* CMD53 Tx bytes + block mode */
141 for (i = 0; i < 512; i++) { 157 for (i=0; i<512; i++) {
142 cmd = &result->cmd53_tx_byte[i]; 158 cmd = &result->cmd53_tx_byte[i];
143 if (cmd->count) { 159 if (cmd->count) {
144 printk("sdio<%6d><%3dB>_Tx_<%9d><%9d><%6d><%6d>_<%9dB><%2dM>\n", cmd->count, i, cmd->tot_tc, 160 printk("sdio<%6d><%3dB>_Tx_<%9d><%9d><%6d><%6d>_<%9dB><%2dM>\n", cmd->count, i, cmd->tot_tc,
145 cmd->max_tc, cmd->min_tc, cmd->tot_tc / cmd->count, 161 cmd->max_tc, cmd->min_tc, cmd->tot_tc/cmd->count,
146 cmd->tot_bytes, (cmd->tot_bytes / 10) * 13 / (cmd->tot_tc / 10)); 162 cmd->tot_bytes, (cmd->tot_bytes/10)*13 / (cmd->tot_tc/10));
147 } 163 }
148 } 164 }
149 for (i = 0; i < 100; i++) { 165 for (i=0; i<100; i++) {
150 cmd = &result->cmd53_tx_blk[i]; 166 cmd = &result->cmd53_tx_blk[i];
151 if (cmd->count) { 167 if (cmd->count) {
152 printk("sdio<%6d><%3d>B_Tx_<%9d><%9d><%6d><%6d>_<%9dB><%2dM>\n", cmd->count, i, cmd->tot_tc, 168 printk("sdio<%6d><%3d>B_Tx_<%9d><%9d><%6d><%6d>_<%9dB><%2dM>\n", cmd->count, i, cmd->tot_tc,
Line 153... Line 169...
153 cmd->max_tc, cmd->min_tc, cmd->tot_tc / cmd->count, 169 cmd->max_tc, cmd->min_tc, cmd->tot_tc/cmd->count,
154 cmd->tot_bytes, (cmd->tot_bytes / 10) * 13 / (cmd->tot_tc / 10)); 170 cmd->tot_bytes, (cmd->tot_bytes/10)*13 / (cmd->tot_tc/10));
155 } 171 }
156 } 172 }
157   173
158 printk("sdio === performance dump done ===\n"); 174 printk("sdio === performance dump done ===\n");
159 } 175 }
160   176  
161 //========= sdio command table =========== 177 //========= sdio command table ===========
-   178 void msdc_performance(u32 opcode, u32 sizes, u32 bRx, u32 ticks)
162 void msdc_performance(u32 opcode, u32 sizes, u32 bRx, u32 ticks) 179 {
163 { 180 struct sdio_profile* result = &sdio_perfomance;
164 struct sdio_profile *result = &sdio_perfomance; 181 struct cmd_profile* cmd;
165 struct cmd_profile *cmd; 182 u32 block;
166 u32 block; 183  
167   184 if (sdio_pro_enable == 0) {
168 if (sdio_pro_enable == 0) 185 return;
169 return; 186 }
170   187  
171 if (opcode == 52) { 188 if (opcode == 52) {
172 cmd = bRx ? &result->cmd52_rx : &result->cmd52_tx; 189 cmd = bRx ? &result->cmd52_rx : &result->cmd52_tx;
173 } else if (opcode == 53) { 190 } else if (opcode == 53) {
174 if (sizes < 512) { -  
175 cmd = bRx ? &result->cmd53_rx_byte[sizes] : &result->cmd53_tx_byte[sizes]; 191 if (sizes < 512) {
176 } else { 192 cmd = bRx ? &result->cmd53_rx_byte[sizes] : &result->cmd53_tx_byte[sizes];
177 block = sizes / 512; 193 } else {
178 if (block >= 99) { 194 block = sizes / 512;
179 printk("cmd53 error blocks\n"); 195 if (block >= 99) {
180 while (1) 196 printk("cmd53 error blocks\n");
181 ; 197 while(1);
182 } 198 }
183 cmd = bRx ? &result->cmd53_rx_blk[block] : &result->cmd53_tx_blk[block]; 199 cmd = bRx ? &result->cmd53_rx_blk[block] : &result->cmd53_tx_blk[block];
-   200 }
184 } 201 } else {
185 } else { 202 return;
-   203 }
186 return; 204
187 } 205 /* update the members */
188   206 if (ticks > cmd->max_tc){
189 /* update the members */ 207 cmd->max_tc = ticks;
190 if (ticks > cmd->max_tc) 208 }
191 cmd->max_tc = ticks; 209 if (cmd->min_tc == 0 || ticks < cmd->min_tc) {
192 if (cmd->min_tc == 0 || ticks < cmd->min_tc) 210 cmd->min_tc = ticks;
193 cmd->min_tc = ticks; 211 }
-   212 cmd->tot_tc += ticks;
194 cmd->tot_tc += ticks; 213 cmd->tot_bytes += sizes;
195 cmd->tot_bytes += sizes; 214 cmd->count ++;
196 cmd->count++; 215
197   216 if (bRx) {
198 if (bRx) 217 result->total_rx_bytes += sizes;
199 result->total_rx_bytes += sizes; 218 } else {
200 else 219 result->total_tx_bytes += sizes;
201 result->total_tx_bytes += sizes; 220 }
Line 202... Line 221...
202 result->total_tc += ticks; 221 result->total_tc += ticks;
203   222
204 /* dump when total_tc > 30s */ 223 /* dump when total_tc > 30s */
205 if (result->total_tc >= sdio_pro_time * TICKS_ONE_MS * 1000) { 224 if (result->total_tc >= sdio_pro_time * TICKS_ONE_MS * 1000) {
206 msdc_sdio_profile(result); 225 msdc_sdio_profile(result);
207 memset(result, 0, sizeof(struct sdio_profile)); 226 memset(result, 0 , sizeof(struct sdio_profile));
208 } 227 }
209 } 228 }
210   229  
211 //========== driver proc interface =========== 230 //========== driver proc interface ===========
212 static int msdc_debug_proc_read(struct seq_file *s, void *p) 231 static int msdc_debug_proc_read(struct seq_file *s, void *p)
Line -... Line 232...
-   232 {
-   233 seq_printf(s, "\n=========================================\n");
-   234 seq_printf(s, "Index<0> + Id + Zone\n");
-   235 seq_printf(s, "-> PWR<9> WRN<8> | FIO<7> OPS<6> FUN<5> CFG<4> | INT<3> RSP<2> CMD<1> DMA<0>\n");
-   236 seq_printf(s, "-> echo 0 3 0x3ff >msdc_bebug -> host[3] debug zone set to 0x3ff\n");
-   237 seq_printf(s, "-> MSDC[0] Zone: 0x%.8x\n", sd_debug_zone[0]);
-   238 seq_printf(s, "-> MSDC[1] Zone: 0x%.8x\n", sd_debug_zone[1]);
-   239 seq_printf(s, "-> MSDC[2] Zone: 0x%.8x\n", sd_debug_zone[2]);
213 { 240 seq_printf(s, "-> MSDC[3] Zone: 0x%.8x\n", sd_debug_zone[3]);
214 seq_puts(s, "\n=========================================\n"); 241  
215 seq_puts(s, "Index<0> + Id + Zone\n"); 242 seq_printf(s, "Index<1> + ID:4|Mode:4 + DMA_SIZE\n");
216 seq_puts(s, "-> PWR<9> WRN<8> | FIO<7> OPS<6> FUN<5> CFG<4> | INT<3> RSP<2> CMD<1> DMA<0>\n"); 243 seq_printf(s, "-> 0)PIO 1)DMA 2)SIZE\n");
Line 217... Line 244...
217 seq_puts(s, "-> echo 0 3 0x3ff >msdc_bebug -> host[3] debug zone set to 0x3ff\n"); 244 seq_printf(s, "-> echo 1 22 0x200 >msdc_bebug -> host[2] size mode, dma when >= 512\n");
218 seq_printf(s, "-> MSDC[0] Zone: 0x%.8x\n", sd_debug_zone[0]); 245 seq_printf(s, "-> MSDC[0] mode<%d> size<%d>\n", drv_mode[0], dma_size[0]);
Line 219... Line 246...
219 seq_printf(s, "-> MSDC[1] Zone: 0x%.8x\n", sd_debug_zone[1]); 246 seq_printf(s, "-> MSDC[1] mode<%d> size<%d>\n", drv_mode[1], dma_size[1]);
220 seq_printf(s, "-> MSDC[2] Zone: 0x%.8x\n", sd_debug_zone[2]); 247 seq_printf(s, "-> MSDC[2] mode<%d> size<%d>\n", drv_mode[2], dma_size[2]);
221 seq_printf(s, "-> MSDC[3] Zone: 0x%.8x\n", sd_debug_zone[3]); 248 seq_printf(s, "-> MSDC[3] mode<%d> size<%d>\n", drv_mode[3], dma_size[3]);
222   249  
223 seq_puts(s, "Index<3> + SDIO_PROFILE + TIME\n"); 250 seq_printf(s, "Index<3> + SDIO_PROFILE + TIME\n");
224 seq_puts(s, "-> echo 3 1 0x1E >msdc_bebug -> enable sdio_profile, 30s\n"); 251 seq_printf(s, "-> echo 3 1 0x1E >msdc_bebug -> enable sdio_profile, 30s\n");
225 seq_printf(s, "-> SDIO_PROFILE<%d> TIME<%ds>\n", sdio_pro_enable, sdio_pro_time); 252 seq_printf(s, "-> SDIO_PROFILE<%d> TIME<%ds>\n", sdio_pro_enable, sdio_pro_time);
226 seq_puts(s, "=========================================\n\n"); 253 seq_printf(s, "=========================================\n\n");
227   254  
228 return 0; 255 return 0;
229 } -  
230   256 }
231 static ssize_t msdc_debug_proc_write(struct file *file, -  
232 const char __user *buf, size_t count, loff_t *data) 257  
233 { 258 static ssize_t msdc_debug_proc_write(struct file *file,
234 int ret; 259 const char __user *buf, size_t count, loff_t *data)
235   260 {
236 int cmd, p1, p2; 261 int ret;
237 int id, zone; 262
Line 238... Line 263...
238 int mode, size; 263 int cmd, p1, p2;
239   264 int id, zone;
240 if (count == 0) 265 int mode, size;
241 return -1; -  
242 if (count > 255) -  
243 count = 255; 266
244   267 if (count == 0)return -1;
245 if (copy_from_user(cmd_buf, buf, count)) 268 if(count > 255)count = 255;
246 return -EFAULT; 269  
-   270 ret = copy_from_user(cmd_buf, buf, count);
247   271 if (ret < 0)return -1;
248 cmd_buf[count] = '\0'; 272
249 printk("msdc Write %s\n", cmd_buf); 273 cmd_buf[count] = '\0';
-   274 printk("msdc Write %s\n", cmd_buf);
250   275  
251 sscanf(cmd_buf, "%x %x %x", &cmd, &p1, &p2); 276 sscanf(cmd_buf, "%x %x %x", &cmd, &p1, &p2);
252   277
-   278 if(cmd == SD_TOOL_ZONE) {
-   279 id = p1; zone = p2; zone &= 0x3ff;
-   280 printk("msdc host_id<%d> zone<0x%.8x>\n", id, zone);
-   281 if(id >=0 && id<=3){
-   282 sd_debug_zone[id] = zone;
-   283 }
-   284 else if(id == 4){
-   285 sd_debug_zone[0] = sd_debug_zone[1] = zone;
-   286 sd_debug_zone[2] = sd_debug_zone[3] = zone;
-   287 }
-   288 else{
-   289 printk("msdc host_id error when set debug zone\n");
-   290 }
-   291 } else if (cmd == SD_TOOL_DMA_SIZE) {
-   292 id = p1>>4; mode = (p1&0xf); size = p2;
253 if (cmd == SD_TOOL_ZONE) { 293 if(id >=0 && id<=3){
254 id = p1; 294 drv_mode[id] = mode;
255 zone = p2; 295 dma_size[id] = p2;
256 zone &= 0x3ff; 296 }
257 printk("msdc host_id<%d> zone<0x%.8x>\n", id, zone); 297 else if(id == 4){
258 if (id >= 0 && id <= 3) { 298 drv_mode[0] = drv_mode[1] = mode;
259 sd_debug_zone[id] = zone; 299 drv_mode[2] = drv_mode[3] = mode;
260 } else if (id == 4) { -  
261 sd_debug_zone[0] = sd_debug_zone[1] = zone; -  
262 sd_debug_zone[2] = sd_debug_zone[3] = zone; 300 dma_size[0] = dma_size[1] = p2;
263 } else { -  
264 printk("msdc host_id error when set debug zone\n"); 301 dma_size[2] = dma_size[3] = p2;
265 } 302 }
266 } else if (cmd == SD_TOOL_SDIO_PROFILE) { 303 else{
267 if (p1 == 1) { /* enable profile */ 304 printk("msdc host_id error when select mode\n");
268 if (gpt_enable == 0) { 305 }
269 // msdc_init_gpt(); /* --- by chhung */ 306 } else if (cmd == SD_TOOL_SDIO_PROFILE) {
270 gpt_enable = 1; 307 if (p1 == 1) { /* enable profile */
271 } 308 if (gpt_enable == 0) {
272 sdio_pro_enable = 1; 309 // msdc_init_gpt(); /* --- by chhung */
Line 273... Line 310...
273 if (p2 == 0) 310 gpt_enable = 1;
274 p2 = 1; 311 }
275 if (p2 >= 30) 312 sdio_pro_enable = 1;
276 p2 = 30; 313 if (p2 == 0) p2 = 1; if (p2 >= 30) p2 = 30;
Line 277... Line 314...
277 sdio_pro_time = p2; 314 sdio_pro_time = p2 ;
278 } else if (p1 == 0) { 315 } else if (p1 == 0) {
279 /* todo */ 316 /* todo */
280 sdio_pro_enable = 0; 317 sdio_pro_enable = 0;
281 } 318 }
282 } 319 }
283   320
284 return count; 321 return count;
Line 285... Line 322...
285 } 322 }
286   323  
287 static int msdc_debug_show(struct inode *inode, struct file *file) 324 static int msdc_debug_show(struct inode *inode, struct file *file)
-   325 {
-   326 return single_open(file, msdc_debug_proc_read, NULL);
-   327 }
-   328  
-   329 static const struct file_operations msdc_debug_fops = {
288 { 330 .owner = THIS_MODULE,
289 return single_open(file, msdc_debug_proc_read, NULL); 331 .open = msdc_debug_show,
290 } 332 .read = seq_read,