lantiq: Tune the XWAY subtarget cflags
[openwrt/staging/yousong.git] / package / platform / lantiq / ltq-hcd / src / ifxusb_ctl.c
1 /*****************************************************************************
2 ** FILE NAME : ifxusb_ctl.c
3 ** PROJECT : IFX USB sub-system V3
4 ** MODULES : IFX USB sub-system Host and Device driver
5 ** SRC VERSION : 1.0
6 ** SRC VERSION : 3.2
7 ** DATE : 1/Jan/2011
8 ** DESCRIPTION : Implementing the procfs and sysfs for IFX USB driver
9 ** FUNCTIONS :
10 ** COMPILER : gcc
11 ** REFERENCE : Synopsys DWC-OTG Driver 2.7
12 ** COPYRIGHT : Copyright (c) 2010
13 ** LANTIQ DEUTSCHLAND GMBH,
14 ** Am Campeon 3, 85579 Neubiberg, Germany
15 **
16 ** This program is free software; you can redistribute it and/or modify
17 ** it under the terms of the GNU General Public License as published by
18 ** the Free Software Foundation; either version 2 of the License, or
19 ** (at your option) any later version.
20 **
21 ** Version Control Section **
22 ** $Author$
23 ** $Date$
24 ** $Revisions$
25 ** $Log$ Revision history
26 *****************************************************************************/
27
28 /*
29 * This file contains code fragments from Synopsys HS OTG Linux Software Driver.
30 * For this code the following notice is applicable:
31 *
32 * ==========================================================================
33 *
34 * Synopsys HS OTG Linux Software Driver and documentation (hereinafter,
35 * "Software") is an Unsupported proprietary work of Synopsys, Inc. unless
36 * otherwise expressly agreed to in writing between Synopsys and you.
37 *
38 * The Software IS NOT an item of Licensed Software or Licensed Product under
39 * any End User Software License Agreement or Agreement for Licensed Product
40 * with Synopsys or any supplement thereto. You are permitted to use and
41 * redistribute this Software in source and binary forms, with or without
42 * modification, provided that redistributions of source code must retain this
43 * notice. You may not view, use, disclose, copy or distribute this file or
44 * any information contained herein except pursuant to this license grant from
45 * Synopsys. If you do not agree with this notice, including the disclaimer
46 * below, then you are not authorized to use the Software.
47 *
48 * THIS SOFTWARE IS BEING DISTRIBUTED BY SYNOPSYS SOLELY ON AN "AS IS" BASIS
49 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
50 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
51 * ARE HEREBY DISCLAIMED. IN NO EVENT SHALL SYNOPSYS BE LIABLE FOR ANY DIRECT,
52 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
53 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
54 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
55 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
56 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
57 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
58 * DAMAGE.
59 * ========================================================================== */
60
61 /*! \file ifxusb_ctl.c
62 \ingroup IFXUSB_DRIVER_V3
63 \brief Implementing the procfs and sysfs for IFX USB driver
64 */
65
66 #include <linux/version.h>
67 #include "ifxusb_version.h"
68
69
70 #include <linux/proc_fs.h>
71 #include <asm/byteorder.h>
72 #include <asm/unaligned.h>
73 #include <asm/uaccess.h>
74
75 #include "ifxusb_plat.h"
76 #include "ifxusb_regs.h"
77 #include "ifxusb_cif.h"
78
79 #ifdef __IS_DEVICE__
80 #include "ifxpcd.h"
81 #ifdef __GADGET_COC__
82 #include <asm/ifx/ifx_types.h>
83 #include <asm/ifx/ifx_pmcu.h>
84 IFX_PMCU_REGISTER_t pmcuRegisterUSBGadget;
85 #endif
86 #endif
87
88 #ifdef __IS_HOST__
89 #include "ifxhcd.h"
90 #ifdef __HOST_COC__
91 #include <asm/ifx/ifx_types.h>
92 #include <asm/ifx/ifx_pmcu.h>
93 #ifdef __IS_DUAL__
94 IFX_PMCU_REGISTER_t pmcuRegisterUSBHost_1;
95 IFX_PMCU_REGISTER_t pmcuRegisterUSBHost_2;
96 #else
97 IFX_PMCU_REGISTER_t pmcuRegisterUSBHost;
98 #endif
99 #endif
100 #endif
101
102 #include <linux/device.h>
103 #include <linux/platform_device.h>
104 #include <linux/gfp.h>
105
106 #ifdef __IS_HOST__
107 extern char ifxusb_hcd_driver_name[];
108
109 #ifdef __IS_DUAL__
110 extern ifxhcd_hcd_t ifxusb_hcd_1;
111 extern ifxhcd_hcd_t ifxusb_hcd_2;
112 extern char ifxusb_hcd_name_1[];
113 extern char ifxusb_hcd_name_2[];
114 #else
115 extern ifxhcd_hcd_t ifxusb_hcd;
116 extern char ifxusb_hcd_name[];
117 #endif
118
119 #endif
120
121 #ifdef __IS_DEVICE__
122 extern char ifxusb_pcd_driver_name[];
123
124 extern ifxpcd_pcd_t ifxusb_pcd;
125 extern char ifxusb_pcd_name[];
126 #endif
127
128
129 //Attributes for sysfs (for 2.6 only)
130
131 #ifdef __IS_HOST__
132 extern struct device_attribute dev_attr_version_h;
133 #else
134 extern struct device_attribute dev_attr_version_d;
135 #endif
136 #ifdef __IS_HOST__
137 extern struct device_attribute dev_attr_dbglevel_h;
138 #else
139 extern struct device_attribute dev_attr_dbglevel_d;
140 #endif
141 #ifdef __IS_HOST__
142 #ifdef __IS_DUAL__
143 extern struct device_attribute dev_attr_suspend_host_1;
144 extern struct device_attribute dev_attr_suspend_host_2;
145 extern struct device_attribute dev_attr_probe_host_1;
146 extern struct device_attribute dev_attr_probe_host_2;
147 extern struct device_attribute dev_attr_probe_timer1_val_h;
148 extern struct device_attribute dev_attr_probe_timer2_val_h;
149 extern struct device_attribute dev_attr_autoprobe_timer1_val_h;
150 extern struct device_attribute dev_attr_autoprobe_timer2_val_h;
151 #else
152 extern struct device_attribute dev_attr_suspend_host;
153 extern struct device_attribute dev_attr_probe_host;
154 extern struct device_attribute dev_attr_probe_timer_val_h;
155 extern struct device_attribute dev_attr_autoprobe_timer_val_h;
156 #endif
157 #endif
158
159 #ifdef __IS_DEVICE__
160 extern struct device_attribute dev_attr_suspend_device;
161 extern struct device_attribute dev_attr_probe_device;
162 extern struct device_attribute dev_attr_probe_timer_val_d;
163 extern struct device_attribute dev_attr_autoprobe_timer_val_d;
164 #endif
165
166 #ifdef __IS_HOST__
167 #ifdef __IS_DUAL__
168 extern struct device_attribute dev_attr_dump_params_h_1;
169 extern struct device_attribute dev_attr_dump_params_h_2;
170 extern struct device_attribute dev_attr_mode_h_1;
171 extern struct device_attribute dev_attr_mode_h_2;
172 #else
173 extern struct device_attribute dev_attr_dump_params_h;
174 extern struct device_attribute dev_attr_mode_h;
175 #endif
176 #else
177 extern struct device_attribute dev_attr_dump_params_d;
178 extern struct device_attribute dev_attr_mode_d;
179 #endif
180
181 #ifdef __IS_HOST__
182 #ifdef __IS_DUAL__
183 extern struct device_attribute dev_attr_pkt_count_limit_bi_1;
184 extern struct device_attribute dev_attr_pkt_count_limit_bo_1;
185 extern struct device_attribute dev_attr_pkt_count_limit_bi_2;
186 extern struct device_attribute dev_attr_pkt_count_limit_bo_2;
187 extern struct device_attribute dev_attr_bandwidth_fs_1;
188 extern struct device_attribute dev_attr_bandwidth_ls_1;
189 extern struct device_attribute dev_attr_bandwidth_hs_2;
190 extern struct device_attribute dev_attr_bandwidth_fs_2;
191 extern struct device_attribute dev_attr_bandwidth_ls_2;
192 extern struct device_attribute dev_attr_buspower_1;
193 extern struct device_attribute dev_attr_buspower_2;
194 extern struct device_attribute dev_attr_bussuspend_1;
195 extern struct device_attribute dev_attr_bussuspend_2;
196 extern struct device_attribute dev_attr_busconnected_1;
197 extern struct device_attribute dev_attr_busconnected_2;
198 extern struct device_attribute dev_attr_connectspeed_1;
199 extern struct device_attribute dev_attr_connectspeed_1;
200 #else
201 extern struct device_attribute dev_attr_pkt_count_limit_bi;
202 extern struct device_attribute dev_attr_pkt_count_limit_bo;
203 extern struct device_attribute dev_attr_bandwidth_hs;
204 extern struct device_attribute dev_attr_bandwidth_fs;
205 extern struct device_attribute dev_attr_bandwidth_ls;
206 extern struct device_attribute dev_attr_buspower;
207 extern struct device_attribute dev_attr_bussuspend;
208 extern struct device_attribute dev_attr_busconnected;
209 extern struct device_attribute dev_attr_connectspeed;
210 #endif
211 #endif //__IS_HOST__
212
213 #ifdef __IS_DEVICE__
214 extern struct device_attribute dev_attr_devspeed;
215 extern struct device_attribute dev_attr_enumspeed;
216 #endif //__IS_DEVICE__
217
218 #ifdef __ENABLE_DUMP__
219 #ifdef __IS_HOST__
220 #ifdef __IS_DUAL__
221 extern struct device_attribute dev_attr_dump_reg_h_1;
222 extern struct device_attribute dev_attr_dump_reg_h_2;
223 extern struct device_attribute dev_attr_dump_spram_h_1;
224 extern struct device_attribute dev_attr_dump_spram_h_2;
225 extern struct device_attribute dev_attr_dump_host_state_1;
226 extern struct device_attribute dev_attr_dump_host_state_2;
227 #else
228 extern struct device_attribute dev_attr_dump_reg_h;
229 extern struct device_attribute dev_attr_dump_spram_h;
230 extern struct device_attribute dev_attr_dump_host_state;
231 #endif
232 #else
233 extern struct device_attribute dev_attr_dump_reg_d;
234 extern struct device_attribute dev_attr_dump_spram_d;
235 #endif
236 #endif //__ENABLE_DUMP__
237
238
239 /////////////////////////////////////////////////////////////////////////////////////////////////////
240 /////////////////////////////////////////////////////////////////////////////////////////////////////
241 /////////////////////////////////////////////////////////////////////////////////////////////////////
242
243 static ssize_t procfs_version_show(char *buf, char **start, off_t offset, int count, int *eof, void *data)
244 {
245 return sprintf( buf, "%s\n",IFXUSB_VERSION );
246 }
247
248 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
249 static ssize_t sysfs_version_show( struct device *_dev, struct device_attribute *attr,char *buf)
250 #else
251 static ssize_t sysfs_version_show( struct device *_dev, char *buf)
252 #endif
253 {
254 return sprintf( buf, "%s\n",IFXUSB_VERSION );
255 }
256
257 #ifdef __IS_HOST__
258 DEVICE_ATTR(version_h, S_IRUGO|S_IWUSR, sysfs_version_show, NULL);
259 #else
260 DEVICE_ATTR(version_d, S_IRUGO|S_IWUSR, sysfs_version_show, NULL);
261 #endif
262
263
264 /////////////////////////////////////////////////////////////////////////////////////////////////////
265 /////////////////////////////////////////////////////////////////////////////////////////////////////
266 /////////////////////////////////////////////////////////////////////////////////////////////////////
267 /////////////////////////////////////////////////////////////////////////////////////////////////////
268 /////////////////////////////////////////////////////////////////////////////////////////////////////
269 /////////////////////////////////////////////////////////////////////////////////////////////////////
270
271 static ssize_t procfs_dbglevel_show(char *buf, char **start, off_t offset, int count, int *eof, void *data)
272 {
273 #ifdef __IS_HOST__
274 return sprintf( buf, "%08X\n",h_dbg_lvl );
275 #else
276 return sprintf( buf, "%08X\n",d_dbg_lvl );
277 #endif
278 }
279
280 static ssize_t procfs_dbglevel_store(struct file *file, const char *buffer, unsigned long count, void *data)
281 {
282 char buf[10];
283 int i = 0;
284 uint32_t value;
285 if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1))
286 return -EFAULT;
287 value = simple_strtoul(buf, NULL, 16);
288 #ifdef __IS_HOST__
289 h_dbg_lvl =value;
290 #else
291 d_dbg_lvl =value;
292 #endif
293 //turn on and off power
294 return count;
295 }
296
297 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
298 static ssize_t sysfs_dbglevel_show( struct device *_dev, struct device_attribute *attr,char *buf)
299 #else
300 static ssize_t sysfs_dbglevel_show( struct device *_dev, char *buf)
301 #endif
302 {
303 #ifdef __IS_HOST__
304 return sprintf( buf, "%08X\n",h_dbg_lvl );
305 #else
306 return sprintf( buf, "%08X\n",d_dbg_lvl );
307 #endif
308 }
309
310 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
311 static ssize_t sysfs_dbglevel_store( struct device *_dev, struct device_attribute *attr,const char *buffer, size_t count )
312 #else
313 static ssize_t sysfs_dbglevel_store( struct device *_dev, const char *buffer, size_t count )
314 #endif
315 {
316 char buf[10];
317 int i = 0;
318 uint32_t value;
319 if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1))
320 return -EFAULT;
321 value = simple_strtoul(buf, NULL, 16);
322 #ifdef __IS_HOST__
323 h_dbg_lvl =value;
324 #else
325 d_dbg_lvl =value;
326 #endif
327 //turn on and off power
328 return count;
329 }
330
331 #ifdef __IS_HOST__
332 DEVICE_ATTR(dbglevel_h, S_IRUGO|S_IWUSR, sysfs_dbglevel_show, sysfs_dbglevel_store);
333 #else
334 DEVICE_ATTR(dbglevel_d, S_IRUGO|S_IWUSR, sysfs_dbglevel_show, sysfs_dbglevel_store);
335 #endif
336
337
338 /////////////////////////////////////////////////////////////////////////////////////////////////////
339 /////////////////////////////////////////////////////////////////////////////////////////////////////
340 /////////////////////////////////////////////////////////////////////////////////////////////////////
341
342 static void ifxusb_dump_params(ifxusb_core_if_t *_core_if);
343
344 #ifdef __IS_DUAL__
345 static void dump_params_1(void)
346 {
347 ifxusb_dump_params(&ifxusb_hcd_1.core_if);
348 }
349 static void dump_params_2(void)
350 {
351 ifxusb_dump_params(&ifxusb_hcd_2.core_if);
352 }
353
354 static ssize_t procfs_dump_params_show_1(char *buf, char **start, off_t offset, int count, int *eof, void *data)
355 {
356 dump_params_1();
357 return 0;
358 }
359 static ssize_t procfs_dump_params_show_2(char *buf, char **start, off_t offset, int count, int *eof, void *data)
360 {
361 dump_params_2();
362 return 0;
363 }
364
365 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
366 static ssize_t sysfs_dump_params_show_1( struct device *_dev, struct device_attribute *attr,char *buf)
367 #else
368 static ssize_t sysfs_dump_params_show_1( struct device *_dev,char *buf)
369 #endif
370 {
371 dump_params_1();
372 return 0;
373 }
374 DEVICE_ATTR(dump_params_h_1, S_IRUGO|S_IWUSR, sysfs_dump_params_show_1, NULL);
375
376 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
377 static ssize_t sysfs_dump_params_show_2( struct device *_dev, struct device_attribute *attr,char *buf)
378 #else
379 static ssize_t sysfs_dump_params_show_2( struct device *_dev,char *buf)
380 #endif
381 {
382 dump_params_2();
383 return 0;
384 }
385
386 DEVICE_ATTR(dump_params_h_2, S_IRUGO|S_IWUSR, sysfs_dump_params_show_2, NULL);
387 #else
388 static void dump_params(void)
389 {
390 #ifdef __IS_HOST__
391 ifxusb_dump_params(&ifxusb_hcd.core_if);
392 #else
393 ifxusb_dump_params(&ifxusb_pcd.core_if);
394 #endif
395 }
396
397 static ssize_t procfs_dump_params_show(char *buf, char **start, off_t offset, int count, int *eof, void *data)
398 {
399 dump_params();
400 return 0;
401 }
402
403 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
404 static ssize_t sysfs_dump_params_show( struct device *_dev, struct device_attribute *attr,char *buf)
405 #else
406 static ssize_t sysfs_dump_params_show( struct device *_dev,char *buf)
407 #endif
408 {
409 dump_params();
410 return 0;
411 }
412
413 #ifdef __IS_HOST__
414 DEVICE_ATTR(dump_params_h, S_IRUGO|S_IWUSR, sysfs_dump_params_show, NULL);
415 #else
416 DEVICE_ATTR(dump_params_d, S_IRUGO|S_IWUSR, sysfs_dump_params_show, NULL);
417 #endif
418 #endif
419
420 /////////////////////////////////////////////////////////////////////////////////////////////////////
421 /////////////////////////////////////////////////////////////////////////////////////////////////////
422 /////////////////////////////////////////////////////////////////////////////////////////////////////
423
424 #ifdef __IS_DUAL__
425 static ssize_t mode_show_1(char *buf)
426 {
427 if((ifxusb_rreg(&ifxusb_hcd_1.core_if.core_global_regs->gintsts ) & 0x1) == 1)
428 return sprintf( buf, "HOST\n" );
429 else
430 return sprintf( buf, "DEVICE(INCORRECT!)\n" );
431 }
432
433 static ssize_t mode_show_2(char *buf)
434 {
435 if((ifxusb_rreg(&ifxusb_hcd_2.core_if.core_global_regs->gintsts ) & 0x1) == 1)
436 return sprintf( buf, "HOST\n" );
437 else
438 return sprintf( buf, "DEVICE(INCORRECT!)\n" );
439 }
440
441 static ssize_t procfs_mode_show_1(char *buf, char **start, off_t offset, int count, int *eof, void *data)
442 {
443 return mode_show_1(buf);
444 }
445 static ssize_t procfs_mode_show_2(char *buf, char **start, off_t offset, int count, int *eof, void *data)
446 {
447 return mode_show_2(buf);
448 }
449
450 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
451 static ssize_t sysfs_mode_show_1( struct device *_dev, struct device_attribute *attr,char *buf)
452 #else
453 static ssize_t sysfs_mode_show_1( struct device *_dev,char *buf)
454 #endif
455 {
456 return mode_show_1(buf);
457 }
458
459 DEVICE_ATTR(mode_h_1, S_IRUGO|S_IWUSR, sysfs_mode_show_1, 0);
460
461 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
462 static ssize_t sysfs_mode_show_2( struct device *_dev, struct device_attribute *attr,char *buf)
463 #else
464 static ssize_t sysfs_mode_show_2( struct device *_dev,char *buf)
465 #endif
466 {
467 return mode_show_2(buf);
468 }
469 DEVICE_ATTR(mode_h_2, S_IRUGO|S_IWUSR, sysfs_mode_show_2, NULL);
470 #else
471 static ssize_t mode_show(char *buf)
472 {
473 #ifdef __IS_HOST__
474 if((ifxusb_rreg(&ifxusb_hcd.core_if.core_global_regs->gintsts ) & 0x1) == 1)
475 return sprintf( buf, "HOST\n" );
476 else
477 return sprintf( buf, "DEVICE(INCORRECT!)\n" );
478 #else
479 if((ifxusb_rreg(&ifxusb_pcd.core_if.core_global_regs->gintsts ) & 0x1) != 1)
480 return sprintf( buf, "DEVICE\n" );
481 else
482 return sprintf( buf, "HOST(INCORRECT!)\n" );
483 #endif
484 }
485 static ssize_t procfs_mode_show(char *buf, char **start, off_t offset, int count, int *eof, void *data)
486 {
487 return mode_show(buf);
488 }
489 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
490 static ssize_t sysfs_mode_show( struct device *_dev, struct device_attribute *attr,char *buf)
491 #else
492 static ssize_t sysfs_mode_show( struct device *_dev, char *buf)
493 #endif
494 {
495 return mode_show(buf);
496 }
497 #ifdef __IS_HOST__
498 DEVICE_ATTR(mode_h, S_IRUGO|S_IWUSR, sysfs_mode_show, NULL);
499 #else
500 DEVICE_ATTR(mode_d, S_IRUGO|S_IWUSR, sysfs_mode_show, NULL);
501 #endif
502 #endif
503
504 /////////////////////////////////////////////////////////////////////////////////////////////////////
505 /////////////////////////////////////////////////////////////////////////////////////////////////////
506 /////////////////////////////////////////////////////////////////////////////////////////////////////
507
508 #ifdef __IS_HOST__
509 /////////////////////////////////////////////////////////////////////////////////////////////////////
510 /////////////////////////////////////////////////////////////////////////////////////////////////////
511 /////////////////////////////////////////////////////////////////////////////////////////////////////
512 #ifdef __IS_DUAL__
513 static ssize_t bandwidth_hs_show_1(char *buf)
514 {
515 return sprintf( buf, "%d\n",ifxusb_hcd_1.pkt_remaining_reload_hs );
516 }
517 static ssize_t bandwidth_fs_show_1(char *buf)
518 {
519 return sprintf( buf, "%d\n",ifxusb_hcd_1.pkt_remaining_reload_fs );
520 }
521 static ssize_t bandwidth_ls_show_1(char *buf)
522 {
523 return sprintf( buf, "%d\n",ifxusb_hcd_1.pkt_remaining_reload_ls );
524 }
525 static void bandwidth_hs_store_1(uint32_t value)
526 {
527 if(value>16 && value<120)
528 {
529 hprt0_data_t hprt0;
530 ifxusb_hcd_1.pkt_remaining_reload_hs = value;
531 hprt0.d32 = ifxusb_rreg(ifxusb_hcd_1.core_if.hprt0);
532 if(hprt0.b.prtspd == IFXUSB_HPRT0_PRTSPD_HIGH_SPEED)
533 ifxusb_hcd_1.pkt_remaining_reload=value;
534 }
535 }
536 static void bandwidth_fs_store_1(uint32_t value)
537 {
538 if (value>2 && value<30)
539 {
540 hprt0_data_t hprt0;
541 ifxusb_hcd_1.pkt_remaining_reload_fs = value;
542 hprt0.d32 = ifxusb_rreg(ifxusb_hcd_1.core_if.hprt0);
543 if(hprt0.b.prtspd != IFXUSB_HPRT0_PRTSPD_LOW_SPEED && hprt0.b.prtspd != IFXUSB_HPRT0_PRTSPD_HIGH_SPEED)
544 ifxusb_hcd_1.pkt_remaining_reload=value;
545 }
546 }
547 static void bandwidth_ls_store_1(uint32_t value)
548 {
549 if (value>2 && value<30)
550 {
551 hprt0_data_t hprt0;
552 ifxusb_hcd_1.pkt_remaining_reload_ls = value;
553 hprt0.d32 = ifxusb_rreg(ifxusb_hcd_1.core_if.hprt0);
554 if(hprt0.b.prtspd == IFXUSB_HPRT0_PRTSPD_LOW_SPEED)
555 ifxusb_hcd_1.pkt_remaining_reload=value;
556 }
557 }
558 static ssize_t bandwidth_hs_show_2(char *buf)
559 {
560 return sprintf( buf, "%d\n",ifxusb_hcd_2.pkt_remaining_reload_hs );
561 }
562 static ssize_t bandwidth_fs_show_2(char *buf)
563 {
564 return sprintf( buf, "%d\n",ifxusb_hcd_2.pkt_remaining_reload_fs );
565 }
566 static ssize_t bandwidth_ls_show_2(char *buf)
567 {
568 return sprintf( buf, "%d\n",ifxusb_hcd_2.pkt_remaining_reload_ls );
569 }
570 static void bandwidth_hs_store_2(uint32_t value)
571 {
572 if(value>16 && value<120)
573 {
574 hprt0_data_t hprt0;
575 ifxusb_hcd_2.pkt_remaining_reload_hs = value;
576 hprt0.d32 = ifxusb_rreg(ifxusb_hcd_2.core_if.hprt0);
577 if(hprt0.b.prtspd == IFXUSB_HPRT0_PRTSPD_HIGH_SPEED)
578 ifxusb_hcd_2.pkt_remaining_reload=value;
579 }
580 }
581 static void bandwidth_fs_store_2(uint32_t value)
582 {
583 if (value>2 && value<30)
584 {
585 hprt0_data_t hprt0;
586 ifxusb_hcd_2.pkt_remaining_reload_fs = value;
587 hprt0.d32 = ifxusb_rreg(ifxusb_hcd_2.core_if.hprt0);
588 if(hprt0.b.prtspd != IFXUSB_HPRT0_PRTSPD_LOW_SPEED && hprt0.b.prtspd != IFXUSB_HPRT0_PRTSPD_HIGH_SPEED)
589 ifxusb_hcd_2.pkt_remaining_reload=value;
590 }
591 }
592 static void bandwidth_ls_store_2(uint32_t value)
593 {
594 if (value>2 && value<30)
595 {
596 hprt0_data_t hprt0;
597 ifxusb_hcd_2.pkt_remaining_reload_ls = value;
598 hprt0.d32 = ifxusb_rreg(ifxusb_hcd_2.core_if.hprt0);
599 if(hprt0.b.prtspd == IFXUSB_HPRT0_PRTSPD_LOW_SPEED)
600 ifxusb_hcd_2.pkt_remaining_reload=value;
601 }
602 }
603 static ssize_t procfs_bandwidth_hs_show_1(char *buf, char **start, off_t offset, int count, int *eof, void *data)
604 {
605 return bandwidth_hs_show_1(buf);
606 }
607 static ssize_t procfs_bandwidth_fs_show_1(char *buf, char **start, off_t offset, int count, int *eof, void *data)
608 {
609 return bandwidth_fs_show_1(buf);
610 }
611 static ssize_t procfs_bandwidth_ls_show_1(char *buf, char **start, off_t offset, int count, int *eof, void *data)
612 {
613 return bandwidth_ls_show_1(buf);
614 }
615 static ssize_t procfs_bandwidth_hs_store_1(struct file *file, const char *buffer, unsigned long count, void *data)
616 {
617 char buf[10];
618 int i = 0;
619 uint32_t value;
620 if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1))
621 return -EFAULT;
622 value = simple_strtoul(buf, NULL, 10);
623 bandwidth_hs_store_1(value);
624 return count;
625 }
626 static ssize_t procfs_bandwidth_fs_store_1(struct file *file, const char *buffer, unsigned long count, void *data)
627 {
628 char buf[10];
629 int i = 0;
630 uint32_t value;
631 if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1))
632 return -EFAULT;
633 value = simple_strtoul(buf, NULL, 10);
634 bandwidth_fs_store_1(value);
635 return count;
636 }
637 static ssize_t procfs_bandwidth_ls_store_1(struct file *file, const char *buffer, unsigned long count, void *data)
638 {
639 char buf[10];
640 int i = 0;
641 uint32_t value;
642 if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1))
643 return -EFAULT;
644 value = simple_strtoul(buf, NULL, 10);
645 bandwidth_ls_store_1(value);
646 return count;
647 }
648 static ssize_t procfs_bandwidth_hs_show_2(char *buf, char **start, off_t offset, int count, int *eof, void *data)
649 {
650 return bandwidth_hs_show_2(buf);
651 }
652 static ssize_t procfs_bandwidth_fs_show_2(char *buf, char **start, off_t offset, int count, int *eof, void *data)
653 {
654 return bandwidth_fs_show_2(buf);
655 }
656 static ssize_t procfs_bandwidth_ls_show_2(char *buf, char **start, off_t offset, int count, int *eof, void *data)
657 {
658 return bandwidth_ls_show_2(buf);
659 }
660 static ssize_t procfs_bandwidth_hs_store_2(struct file *file, const char *buffer, unsigned long count, void *data)
661 {
662 char buf[10];
663 int i = 0;
664 uint32_t value;
665 if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1))
666 return -EFAULT;
667 value = simple_strtoul(buf, NULL, 10);
668 bandwidth_hs_store_2(value);
669 return count;
670 }
671 static ssize_t procfs_bandwidth_fs_store_2(struct file *file, const char *buffer, unsigned long count, void *data)
672 {
673 char buf[10];
674 int i = 0;
675 uint32_t value;
676 if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1))
677 return -EFAULT;
678 value = simple_strtoul(buf, NULL, 10);
679 bandwidth_fs_store_2(value);
680 return count;
681 }
682 static ssize_t procfs_bandwidth_ls_store_2(struct file *file, const char *buffer, unsigned long count, void *data)
683 {
684 char buf[10];
685 int i = 0;
686 uint32_t value;
687 if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1))
688 return -EFAULT;
689 value = simple_strtoul(buf, NULL, 10);
690 bandwidth_ls_store_2(value);
691 return count;
692 }
693
694 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
695 static ssize_t sysfs_bandwidth_hs_show_1( struct device *_dev, struct device_attribute *attr,char *buf)
696 #else
697 static ssize_t sysfs_bandwidth_hs_show_1( struct device *_dev,char *buf)
698 #endif
699 {
700 return bandwidth_hs_show_1(buf);
701 }
702 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
703 static ssize_t sysfs_bandwidth_hs_store_1( struct device *_dev, struct device_attribute *attr,const char *buffer, size_t count )
704 #else
705 static ssize_t sysfs_bandwidth_hs_store_1( struct device *_dev, const char *buffer, size_t count )
706 #endif
707 {
708 char buf[10];
709 int i = 0;
710 uint32_t value;
711 if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1))
712 return -EFAULT;
713 value = simple_strtoul(buf, NULL, 10);
714 bandwidth_hs_store_1(value);
715 return count;
716 }
717 DEVICE_ATTR(bandwidth_hs_1, S_IRUGO|S_IWUSR, sysfs_bandwidth_hs_show_1, sysfs_bandwidth_hs_store_1);
718
719 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
720 static ssize_t sysfs_bandwidth_fs_show_1( struct device *_dev, struct device_attribute *attr,char *buf)
721 #else
722 static ssize_t sysfs_bandwidth_fs_show_1( struct device *_dev,char *buf)
723 #endif
724 {
725 return bandwidth_fs_show_1(buf);
726 }
727 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
728 static ssize_t sysfs_bandwidth_fs_store_1( struct device *_dev, struct device_attribute *attr,const char *buffer, size_t count )
729 #else
730 static ssize_t sysfs_bandwidth_fs_store_1( struct device *_dev, const char *buffer, size_t count )
731 #endif
732 {
733 char buf[10];
734 int i = 0;
735 uint32_t value;
736 if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1))
737 return -EFAULT;
738 value = simple_strtoul(buf, NULL, 10);
739 bandwidth_fs_store_1(value);
740 return count;
741 }
742 DEVICE_ATTR(bandwidth_fs_1, S_IRUGO|S_IWUSR, sysfs_bandwidth_fs_show_1, sysfs_bandwidth_fs_store_1);
743
744 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
745 static ssize_t sysfs_bandwidth_ls_show_1( struct device *_dev, struct device_attribute *attr,char *buf)
746 #else
747 static ssize_t sysfs_bandwidth_ls_show_1( struct device *_dev,char *buf)
748 #endif
749 {
750 return bandwidth_ls_show_1(buf);
751 }
752 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
753 static ssize_t sysfs_bandwidth_ls_store_1( struct device *_dev, struct device_attribute *attr,const char *buffer, size_t count )
754 #else
755 static ssize_t sysfs_bandwidth_ls_store_1( struct device *_dev, const char *buffer, size_t count )
756 #endif
757 {
758 char buf[10];
759 int i = 0;
760 uint32_t value;
761 if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1))
762 return -EFAULT;
763 value = simple_strtoul(buf, NULL, 10);
764 bandwidth_ls_store_1(value);
765 return count;
766 }
767 DEVICE_ATTR(bandwidth_ls_1, S_IRUGO|S_IWUSR, sysfs_bandwidth_ls_show_1, sysfs_bandwidth_ls_store_1);
768
769 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
770 static ssize_t sysfs_bandwidth_hs_show_2( struct device *_dev, struct device_attribute *attr,char *buf)
771 #else
772 static ssize_t sysfs_bandwidth_hs_show_2( struct device *_dev,char *buf)
773 #endif
774 {
775 return bandwidth_hs_show_2(buf);
776 }
777 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
778 static ssize_t sysfs_bandwidth_hs_store_2( struct device *_dev, struct device_attribute *attr,const char *buffer, size_t count )
779 #else
780 static ssize_t sysfs_bandwidth_hs_store_2( struct device *_dev, const char *buffer, size_t count )
781 #endif
782 {
783 char buf[10];
784 int i = 0;
785 uint32_t value;
786 if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1))
787 return -EFAULT;
788 value = simple_strtoul(buf, NULL, 10);
789 bandwidth_hs_store_2(value);
790 return count;
791 }
792 DEVICE_ATTR(bandwidth_hs_2, S_IRUGO|S_IWUSR, sysfs_bandwidth_hs_show_2, sysfs_bandwidth_hs_store_2);
793
794 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
795 static ssize_t sysfs_bandwidth_fs_show_2( struct device *_dev, struct device_attribute *attr,char *buf)
796 #else
797 static ssize_t sysfs_bandwidth_fs_show_2( struct device *_dev,char *buf)
798 #endif
799 {
800 return bandwidth_fs_show_2(buf);
801 }
802 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
803 static ssize_t sysfs_bandwidth_fs_store_2( struct device *_dev, struct device_attribute *attr,const char *buffer, size_t count )
804 #else
805 static ssize_t sysfs_bandwidth_fs_store_2( struct device *_dev, const char *buffer, size_t count )
806 #endif
807 {
808 char buf[10];
809 int i = 0;
810 uint32_t value;
811 if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1))
812 return -EFAULT;
813 value = simple_strtoul(buf, NULL, 10);
814 bandwidth_fs_store_2(value);
815 return count;
816 }
817 DEVICE_ATTR(bandwidth_fs_2, S_IRUGO|S_IWUSR, sysfs_bandwidth_fs_show_2, sysfs_bandwidth_fs_store_2);
818
819 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
820 static ssize_t sysfs_bandwidth_ls_show_2( struct device *_dev, struct device_attribute *attr,char *buf)
821 #else
822 static ssize_t sysfs_bandwidth_ls_show_2( struct device *_dev,char *buf)
823 #endif
824 {
825 return bandwidth_ls_show_2(buf);
826 }
827 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
828 static ssize_t sysfs_bandwidth_ls_store_2( struct device *_dev, struct device_attribute *attr,const char *buffer, size_t count )
829 #else
830 static ssize_t sysfs_bandwidth_ls_store_2( struct device *_dev, const char *buffer, size_t count )
831 #endif
832 {
833 char buf[10];
834 int i = 0;
835 uint32_t value;
836 if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1))
837 return -EFAULT;
838 value = simple_strtoul(buf, NULL, 10);
839 bandwidth_ls_store_2(value);
840 return count;
841 }
842 DEVICE_ATTR(bandwidth_ls_2, S_IRUGO|S_IWUSR, sysfs_bandwidth_ls_show_2, sysfs_bandwidth_ls_store_2);
843 #else
844 static ssize_t bandwidth_hs_show(char *buf)
845 {
846 return sprintf( buf, "%d\n",ifxusb_hcd.pkt_remaining_reload_hs );
847 }
848 static ssize_t bandwidth_fs_show(char *buf)
849 {
850 return sprintf( buf, "%d\n",ifxusb_hcd.pkt_remaining_reload_fs );
851 }
852 static ssize_t bandwidth_ls_show(char *buf)
853 {
854 return sprintf( buf, "%d\n",ifxusb_hcd.pkt_remaining_reload_ls );
855 }
856 static void bandwidth_hs_store(uint32_t value)
857 {
858 if (value>16 && value<120)
859 {
860 hprt0_data_t hprt0;
861 ifxusb_hcd.pkt_remaining_reload_hs = value;
862 hprt0.d32 = ifxusb_rreg(ifxusb_hcd.core_if.hprt0);
863 if(hprt0.b.prtspd == IFXUSB_HPRT0_PRTSPD_HIGH_SPEED)
864 ifxusb_hcd.pkt_remaining_reload=value;
865 }
866 }
867 static void bandwidth_fs_store(uint32_t value)
868 {
869 if (value>2 && value<30)
870 {
871 hprt0_data_t hprt0;
872 ifxusb_hcd.pkt_remaining_reload_fs = value;
873 hprt0.d32 = ifxusb_rreg(ifxusb_hcd.core_if.hprt0);
874 if(hprt0.b.prtspd != IFXUSB_HPRT0_PRTSPD_LOW_SPEED && hprt0.b.prtspd != IFXUSB_HPRT0_PRTSPD_HIGH_SPEED)
875 ifxusb_hcd.pkt_remaining_reload=value;
876 }
877 }
878 static void bandwidth_ls_store(uint32_t value)
879 {
880 if (value>2 && value<30)
881 {
882 hprt0_data_t hprt0;
883 ifxusb_hcd.pkt_remaining_reload_hs = value;
884 hprt0.d32 = ifxusb_rreg(ifxusb_hcd.core_if.hprt0);
885 if(hprt0.b.prtspd == IFXUSB_HPRT0_PRTSPD_LOW_SPEED)
886 ifxusb_hcd.pkt_remaining_reload=value;
887 }
888 }
889 static ssize_t procfs_bandwidth_hs_show(char *buf, char **start, off_t offset, int count, int *eof, void *data)
890 {
891 return bandwidth_hs_show(buf);
892 }
893 static ssize_t procfs_bandwidth_fs_show(char *buf, char **start, off_t offset, int count, int *eof, void *data)
894 {
895 return bandwidth_fs_show(buf);
896 }
897 static ssize_t procfs_bandwidth_ls_show(char *buf, char **start, off_t offset, int count, int *eof, void *data)
898 {
899 return bandwidth_ls_show(buf);
900 }
901 static ssize_t procfs_bandwidth_hs_store(struct file *file, const char *buffer, unsigned long count, void *data)
902 {
903 char buf[10];
904 int i = 0;
905 uint32_t value;
906 if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1))
907 return -EFAULT;
908 value = simple_strtoul(buf, NULL, 10);
909 bandwidth_hs_store(value);
910 return count;
911 }
912 static ssize_t procfs_bandwidth_fs_store(struct file *file, const char *buffer, unsigned long count, void *data)
913 {
914 char buf[10];
915 int i = 0;
916 uint32_t value;
917 if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1))
918 return -EFAULT;
919 value = simple_strtoul(buf, NULL, 10);
920 bandwidth_fs_store(value);
921 return count;
922 }
923 static ssize_t procfs_bandwidth_ls_store(struct file *file, const char *buffer, unsigned long count, void *data)
924 {
925 char buf[10];
926 int i = 0;
927 uint32_t value;
928 if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1))
929 return -EFAULT;
930 value = simple_strtoul(buf, NULL, 10);
931 bandwidth_ls_store(value);
932 return count;
933 }
934
935 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
936 static ssize_t sysfs_bandwidth_hs_show( struct device *_dev, struct device_attribute *attr,char *buf)
937 #else
938 static ssize_t sysfs_bandwidth_hs_show( struct device *_dev,char *buf)
939 #endif
940 {
941 return bandwidth_hs_show(buf);
942 }
943 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
944 static ssize_t sysfs_bandwidth_hs_store( struct device *_dev, struct device_attribute *attr,const char *buffer, size_t count )
945 #else
946 static ssize_t sysfs_bandwidth_hs_store( struct device *_dev, const char *buffer, size_t count )
947 #endif
948 {
949 char buf[10];
950 int i = 0;
951 uint32_t value;
952 if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1))
953 return -EFAULT;
954 value = simple_strtoul(buf, NULL, 10);
955 bandwidth_hs_store(value);
956 return count;
957 }
958 DEVICE_ATTR(bandwidth_hs, S_IRUGO|S_IWUSR, sysfs_bandwidth_hs_show, sysfs_bandwidth_hs_store);
959
960 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
961 static ssize_t sysfs_bandwidth_fs_show( struct device *_dev, struct device_attribute *attr,char *buf)
962 #else
963 static ssize_t sysfs_bandwidth_fs_show( struct device *_dev,char *buf)
964 #endif
965 {
966 return bandwidth_fs_show(buf);
967 }
968 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
969 static ssize_t sysfs_bandwidth_fs_store( struct device *_dev, struct device_attribute *attr,const char *buffer, size_t count )
970 #else
971 static ssize_t sysfs_bandwidth_fs_store( struct device *_dev, const char *buffer, size_t count )
972 #endif
973 {
974 char buf[10];
975 int i = 0;
976 uint32_t value;
977 if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1))
978 return -EFAULT;
979 value = simple_strtoul(buf, NULL, 10);
980 bandwidth_fs_store(value);
981 return count;
982 }
983 DEVICE_ATTR(bandwidth_fs, S_IRUGO|S_IWUSR, sysfs_bandwidth_fs_show, sysfs_bandwidth_fs_store);
984
985 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
986 static ssize_t sysfs_bandwidth_ls_show( struct device *_dev, struct device_attribute *attr,char *buf)
987 #else
988 static ssize_t sysfs_bandwidth_ls_show( struct device *_dev,char *buf)
989 #endif
990 {
991 return bandwidth_ls_show(buf);
992 }
993 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
994 static ssize_t sysfs_bandwidth_ls_store( struct device *_dev, struct device_attribute *attr,const char *buffer, size_t count )
995 #else
996 static ssize_t sysfs_bandwidth_ls_store( struct device *_dev, const char *buffer, size_t count )
997 #endif
998 {
999 char buf[10];
1000 int i = 0;
1001 uint32_t value;
1002 if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1))
1003 return -EFAULT;
1004 value = simple_strtoul(buf, NULL, 10);
1005 bandwidth_ls_store(value);
1006 return count;
1007 }
1008 DEVICE_ATTR(bandwidth_ls, S_IRUGO|S_IWUSR, sysfs_bandwidth_ls_show, sysfs_bandwidth_ls_store);
1009 #endif
1010
1011 /////////////////////////////////////////////////////////////////////////////////////////////////////
1012 /////////////////////////////////////////////////////////////////////////////////////////////////////
1013 #ifdef __IS_DUAL__
1014 static ssize_t pkt_count_limit_bi_show_1(char *buf)
1015 {
1016 return sprintf( buf, "%d\n",ifxusb_hcd_1.pkt_count_limit_bi );
1017 }
1018 static ssize_t pkt_count_limit_bo_show_1(char *buf)
1019 {
1020 return sprintf( buf, "%d\n",ifxusb_hcd_1.pkt_count_limit_bo );
1021 }
1022 static void pkt_count_limit_bi_store_1(uint32_t value)
1023 {
1024 if(value<=13)
1025 ifxusb_hcd_1.pkt_count_limit_bi = value;
1026 }
1027 static void pkt_count_limit_bo_store_1(uint32_t value)
1028 {
1029 if (value<=13)
1030 ifxusb_hcd_1.pkt_count_limit_bo = value;
1031 }
1032 static ssize_t pkt_count_limit_bi_show_2(char *buf)
1033 {
1034 return sprintf( buf, "%d\n",ifxusb_hcd_2.pkt_count_limit_bi );
1035 }
1036 static ssize_t pkt_count_limit_bo_show_2(char *buf)
1037 {
1038 return sprintf( buf, "%d\n",ifxusb_hcd_2.pkt_count_limit_bo );
1039 }
1040 static void pkt_count_limit_bi_store_2(uint32_t value)
1041 {
1042 if(value<=13)
1043 ifxusb_hcd_2.pkt_count_limit_bi = value;
1044 }
1045 static void pkt_count_limit_bo_store_2(uint32_t value)
1046 {
1047 if(value<=13)
1048 ifxusb_hcd_2.pkt_count_limit_bo = value;
1049 }
1050 static ssize_t procfs_pkt_count_limit_bi_show_1(char *buf, char **start, off_t offset, int count, int *eof, void *data)
1051 {
1052 return pkt_count_limit_bi_show_1(buf);
1053 }
1054 static ssize_t procfs_pkt_count_limit_bo_show_1(char *buf, char **start, off_t offset, int count, int *eof, void *data)
1055 {
1056 return pkt_count_limit_bo_show_1(buf);
1057 }
1058 static ssize_t procfs_pkt_count_limit_bi_store_1(struct file *file, const char *buffer, unsigned long count, void *data)
1059 {
1060 char buf[10];
1061 int i = 0;
1062 uint32_t value;
1063 if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1))
1064 return -EFAULT;
1065 value = simple_strtoul(buf, NULL, 10);
1066 pkt_count_limit_bi_store_1(value);
1067 return count;
1068 }
1069 static ssize_t procfs_pkt_count_limit_bo_store_1(struct file *file, const char *buffer, unsigned long count, void *data)
1070 {
1071 char buf[10];
1072 int i = 0;
1073 uint32_t value;
1074 if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1))
1075 return -EFAULT;
1076 value = simple_strtoul(buf, NULL, 10);
1077 pkt_count_limit_bo_store_1(value);
1078 return count;
1079 }
1080 static ssize_t procfs_pkt_count_limit_bi_show_2(char *buf, char **start, off_t offset, int count, int *eof, void *data)
1081 {
1082 return pkt_count_limit_bi_show_2(buf);
1083 }
1084 static ssize_t procfs_pkt_count_limit_bo_show_2(char *buf, char **start, off_t offset, int count, int *eof, void *data)
1085 {
1086 return pkt_count_limit_bo_show_2(buf);
1087 }
1088 static ssize_t procfs_pkt_count_limit_bi_store_2(struct file *file, const char *buffer, unsigned long count, void *data)
1089 {
1090 char buf[10];
1091 int i = 0;
1092 uint32_t value;
1093 if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1))
1094 return -EFAULT;
1095 value = simple_strtoul(buf, NULL, 10);
1096 pkt_count_limit_bi_store_2(value);
1097 return count;
1098 }
1099 static ssize_t procfs_pkt_count_limit_bo_store_2(struct file *file, const char *buffer, unsigned long count, void *data)
1100 {
1101 char buf[10];
1102 int i = 0;
1103 uint32_t value;
1104 if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1))
1105 return -EFAULT;
1106 value = simple_strtoul(buf, NULL, 10);
1107 pkt_count_limit_bo_store_2(value);
1108 return count;
1109 }
1110
1111 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
1112 static ssize_t sysfs_pkt_count_limit_bi_show_1( struct device *_dev, struct device_attribute *attr,char *buf)
1113 #else
1114 static ssize_t sysfs_pkt_count_limit_bi_show_1( struct device *_dev,char *buf)
1115 #endif
1116 {
1117 return pkt_count_limit_bi_show_1(buf);
1118 }
1119 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
1120 static ssize_t sysfs_pkt_count_limit_bi_store_1( struct device *_dev, struct device_attribute *attr,const char *buffer, size_t count )
1121 #else
1122 static ssize_t sysfs_pkt_count_limit_bi_store_1( struct device *_dev, const char *buffer, size_t count )
1123 #endif
1124 {
1125 char buf[10];
1126 int i = 0;
1127 uint32_t value;
1128 if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1))
1129 return -EFAULT;
1130 value = simple_strtoul(buf, NULL, 10);
1131 pkt_count_limit_bi_store_1(value);
1132 return count;
1133 }
1134 DEVICE_ATTR(pkt_count_limit_bi_1, S_IRUGO|S_IWUSR, sysfs_pkt_count_limit_bi_show_1, sysfs_pkt_count_limit_bi_store_1);
1135
1136 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
1137 static ssize_t sysfs_pkt_count_limit_bo_show_1( struct device *_dev, struct device_attribute *attr,char *buf)
1138 #else
1139 static ssize_t sysfs_pkt_count_limit_bo_show_1( struct device *_dev,char *buf)
1140 #endif
1141 {
1142 return pkt_count_limit_bo_show_1(buf);
1143 }
1144 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
1145 static ssize_t sysfs_pkt_count_limit_bo_store_1( struct device *_dev, struct device_attribute *attr,const char *buffer, size_t count )
1146 #else
1147 static ssize_t sysfs_pkt_count_limit_bo_store_1( struct device *_dev, const char *buffer, size_t count )
1148 #endif
1149 {
1150 char buf[10];
1151 int i = 0;
1152 uint32_t value;
1153 if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1))
1154 return -EFAULT;
1155 value = simple_strtoul(buf, NULL, 10);
1156 pkt_count_limit_bo_store_1(value);
1157 return count;
1158 }
1159 DEVICE_ATTR(pkt_count_limit_bo_1, S_IRUGO|S_IWUSR, sysfs_pkt_count_limit_bo_show_1, sysfs_pkt_count_limit_bo_store_1);
1160
1161 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
1162 static ssize_t sysfs_pkt_count_limit_bi_show_2( struct device *_dev, struct device_attribute *attr,char *buf)
1163 #else
1164 static ssize_t sysfs_pkt_count_limit_bi_show_2( struct device *_dev,char *buf)
1165 #endif
1166 {
1167 return pkt_count_limit_bi_show_2(buf);
1168 }
1169 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
1170 static ssize_t sysfs_pkt_count_limit_bi_store_2( struct device *_dev, struct device_attribute *attr,const char *buffer, size_t count )
1171 #else
1172 static ssize_t sysfs_pkt_count_limit_bi_2( struct device *_dev, const char *buffer, size_t count )
1173 #endif
1174 {
1175 char buf[10];
1176 int i = 0;
1177 uint32_t value;
1178 if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1))
1179 return -EFAULT;
1180 value = simple_strtoul(buf, NULL, 10);
1181 pkt_count_limit_bi_store_2(value);
1182 return count;
1183 }
1184 DEVICE_ATTR(pkt_count_limit_bi_2, S_IRUGO|S_IWUSR, sysfs_pkt_count_limit_bi_show_2, sysfs_pkt_count_limit_bi_store_2);
1185
1186 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
1187 static ssize_t sysfs_pkt_count_limit_bo_show_2( struct device *_dev, struct device_attribute *attr,char *buf)
1188 #else
1189 static ssize_t sysfs_pkt_count_limit_bo_show_2( struct device *_dev,char *buf)
1190 #endif
1191 {
1192 return pkt_count_limit_bo_show_2(buf);
1193 }
1194 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
1195 static ssize_t sysfs_pkt_count_limit_bo_store_2( struct device *_dev, struct device_attribute *attr,const char *buffer, size_t count )
1196 #else
1197 static ssize_t sysfs_pkt_count_limit_bo_store_2( struct device *_dev, const char *buffer, size_t count )
1198 #endif
1199 {
1200 char buf[10];
1201 int i = 0;
1202 uint32_t value;
1203 if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1))
1204 return -EFAULT;
1205 value = simple_strtoul(buf, NULL, 10);
1206 pkt_count_limit_bo_store_2(value);
1207 return count;
1208 }
1209 DEVICE_ATTR(pkt_count_limit_bo_2, S_IRUGO|S_IWUSR, sysfs_pkt_count_limit_bo_show_2, sysfs_pkt_count_limit_bo_store_2);
1210 #else
1211 static ssize_t pkt_count_limit_bi_show(char *buf)
1212 {
1213 return sprintf( buf, "%d\n",ifxusb_hcd.pkt_count_limit_bi );
1214 }
1215 static ssize_t pkt_count_limit_bo_show(char *buf)
1216 {
1217 return sprintf( buf, "%d\n",ifxusb_hcd.pkt_count_limit_bo );
1218 }
1219 static void pkt_count_limit_bi_store(uint32_t value)
1220 {
1221 if (value<=13)
1222 ifxusb_hcd.pkt_count_limit_bi = value;
1223 }
1224 static void pkt_count_limit_bo_store(uint32_t value)
1225 {
1226 if (value<=13)
1227 ifxusb_hcd.pkt_count_limit_bo = value;
1228 }
1229 static ssize_t procfs_pkt_count_limit_bi_show(char *buf, char **start, off_t offset, int count, int *eof, void *data)
1230 {
1231 return pkt_count_limit_bi_show(buf);
1232 }
1233 static ssize_t procfs_pkt_count_limit_bo_show(char *buf, char **start, off_t offset, int count, int *eof, void *data)
1234 {
1235 return pkt_count_limit_bo_show(buf);
1236 }
1237 static ssize_t procfs_pkt_count_limit_bi_store(struct file *file, const char *buffer, unsigned long count, void *data)
1238 {
1239 char buf[10];
1240 int i = 0;
1241 uint32_t value;
1242 if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1))
1243 return -EFAULT;
1244 value = simple_strtoul(buf, NULL, 10);
1245 pkt_count_limit_bi_store(value);
1246 return count;
1247 }
1248 static ssize_t procfs_pkt_count_limit_bo_store(struct file *file, const char *buffer, unsigned long count, void *data)
1249 {
1250 char buf[10];
1251 int i = 0;
1252 uint32_t value;
1253 if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1))
1254 return -EFAULT;
1255 value = simple_strtoul(buf, NULL, 10);
1256 pkt_count_limit_bo_store(value);
1257 return count;
1258 }
1259
1260 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
1261 static ssize_t sysfs_pkt_count_limit_bi_show( struct device *_dev, struct device_attribute *attr,char *buf)
1262 #else
1263 static ssize_t sysfs_pkt_count_limit_bi_show( struct device *_dev,char *buf)
1264 #endif
1265 {
1266 return pkt_count_limit_bi_show(buf);
1267 }
1268 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
1269 static ssize_t sysfs_pkt_count_limit_bi_store( struct device *_dev, struct device_attribute *attr,const char *buffer, size_t count )
1270 #else
1271 static ssize_t sysfs_pkt_count_limit_bi_store( struct device *_dev, const char *buffer, size_t count )
1272 #endif
1273 {
1274 char buf[10];
1275 int i = 0;
1276 uint32_t value;
1277 if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1))
1278 return -EFAULT;
1279 value = simple_strtoul(buf, NULL, 10);
1280 pkt_count_limit_bi_store(value);
1281 return count;
1282 }
1283 DEVICE_ATTR(pkt_count_limit_bi, S_IRUGO|S_IWUSR, sysfs_pkt_count_limit_bi_show, sysfs_pkt_count_limit_bi_store);
1284
1285 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
1286 static ssize_t sysfs_pkt_count_limit_bo_show( struct device *_dev, struct device_attribute *attr,char *buf)
1287 #else
1288 static ssize_t sysfs_pkt_count_limit_bo_show( struct device *_dev,char *buf)
1289 #endif
1290 {
1291 return pkt_count_limit_bo_show(buf);
1292 }
1293 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
1294 static ssize_t sysfs_pkt_count_limit_bo_store( struct device *_dev, struct device_attribute *attr,const char *buffer, size_t count )
1295 #else
1296 static ssize_t sysfs_pkt_count_limit_bo_store( struct device *_dev, const char *buffer, size_t count )
1297 #endif
1298 {
1299 char buf[10];
1300 int i = 0;
1301 uint32_t value;
1302 if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1))
1303 return -EFAULT;
1304 value = simple_strtoul(buf, NULL, 10);
1305 pkt_count_limit_bo_store(value);
1306 return count;
1307 }
1308 DEVICE_ATTR(pkt_count_limit_bo, S_IRUGO|S_IWUSR, sysfs_pkt_count_limit_bo_show, sysfs_pkt_count_limit_bo_store);
1309 #endif
1310
1311 /////////////////////////////////////////////////////////////////////////////////////////////////////
1312 /////////////////////////////////////////////////////////////////////////////////////////////////////
1313 /////////////////////////////////////////////////////////////////////////////////////////////////////
1314
1315 #ifdef __IS_DUAL__
1316 static ssize_t buspower_show_1(char *buf)
1317 {
1318 if(ifxusb_vbus (&ifxusb_hcd_1.core_if)==1) return sprintf( buf, "1\n" );
1319 if(ifxusb_vbus (&ifxusb_hcd_1.core_if)==0) return sprintf( buf, "0\n" );
1320 return sprintf( buf, "UNKNOWN\n" );
1321 }
1322 static void buspower_store_1(uint32_t value)
1323 {
1324 if (value==1) ifxusb_vbus_on (&ifxusb_hcd_1.core_if);
1325 else if(value==0) ifxusb_vbus_off(&ifxusb_hcd_1.core_if);
1326 }
1327 static ssize_t buspower_show_2(char *buf)
1328 {
1329 if(ifxusb_vbus (&ifxusb_hcd_2.core_if)==1) return sprintf( buf, "1\n" );
1330 if(ifxusb_vbus (&ifxusb_hcd_2.core_if)==0) return sprintf( buf, "0\n" );
1331 return sprintf( buf, "UNKNOWN\n" );
1332 }
1333 static void buspower_store_2(uint32_t value)
1334 {
1335 if (value==1) ifxusb_vbus_on (&ifxusb_hcd_2.core_if);
1336 else if(value==0) ifxusb_vbus_off(&ifxusb_hcd_2.core_if);
1337 }
1338 static ssize_t procfs_buspower_show_1(char *buf, char **start, off_t offset, int count, int *eof, void *data)
1339 {
1340 return buspower_show_1(buf);
1341 }
1342 static ssize_t procfs_buspower_store_1(struct file *file, const char *buffer, unsigned long count, void *data)
1343 {
1344 char buf[10];
1345 int i = 0;
1346 uint32_t value;
1347 if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1))
1348 return -EFAULT;
1349 value = simple_strtoul(buf, NULL, 10);
1350 buspower_store_1(value);
1351 return count;
1352 }
1353 static ssize_t procfs_buspower_show_2(char *buf, char **start, off_t offset, int count, int *eof, void *data)
1354 {
1355 return buspower_show_2(buf);
1356 }
1357 static ssize_t procfs_buspower_store_2(struct file *file, const char *buffer, unsigned long count, void *data)
1358 {
1359 char buf[10];
1360 int i = 0;
1361 uint32_t value;
1362 if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1))
1363 return -EFAULT;
1364 value = simple_strtoul(buf, NULL, 10);
1365 buspower_store_2(value);
1366 return count;
1367 }
1368
1369 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
1370 static ssize_t sysfs_buspower_show_1( struct device *_dev, struct device_attribute *attr,char *buf)
1371 #else
1372 static ssize_t sysfs_buspower_show_1( struct device *_dev,char *buf)
1373 #endif
1374 {
1375 return buspower_show_1(buf);
1376 }
1377 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
1378 static ssize_t sysfs_buspower_store_1( struct device *_dev, struct device_attribute *attr,const char *buffer, size_t count )
1379 #else
1380 static ssize_t sysfs_buspower_store_1( struct device *_dev, const char *buffer, size_t count )
1381 #endif
1382 {
1383 char buf[10];
1384 int i = 0;
1385 uint32_t value;
1386 if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1))
1387 return -EFAULT;
1388 value = simple_strtoul(buf, NULL, 10);
1389 buspower_store_1(value);
1390 return count;
1391 }
1392 DEVICE_ATTR(buspower_1, S_IRUGO|S_IWUSR, sysfs_buspower_show_1, sysfs_buspower_store_1);
1393
1394 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
1395 static ssize_t sysfs_buspower_show_2( struct device *_dev, struct device_attribute *attr,char *buf)
1396 #else
1397 static ssize_t sysfs_buspower_show_2( struct device *_dev,char *buf)
1398 #endif
1399 {
1400 return buspower_show_2(buf);
1401 }
1402 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
1403 static ssize_t sysfs_buspower_store_2( struct device *_dev, struct device_attribute *attr,const char *buffer, size_t count )
1404 #else
1405 static ssize_t sysfs_buspower_store_2( struct device *_dev, const char *buffer, size_t count )
1406 #endif
1407 {
1408 char buf[10];
1409 int i = 0;
1410 uint32_t value;
1411 if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1))
1412 return -EFAULT;
1413 value = simple_strtoul(buf, NULL, 10);
1414 buspower_store_2(value);
1415 return count;
1416 }
1417 DEVICE_ATTR(buspower_2, S_IRUGO|S_IWUSR, sysfs_buspower_show_2, sysfs_buspower_store_2);
1418 #else
1419 static ssize_t buspower_show(char *buf)
1420 {
1421 if(ifxusb_vbus (&ifxusb_hcd.core_if)==1) return sprintf( buf, "1\n" );
1422 if(ifxusb_vbus (&ifxusb_hcd.core_if)==0) return sprintf( buf, "0\n" );
1423 return sprintf( buf, "UNKNOWN\n" );
1424 }
1425 static void buspower_store(uint32_t value)
1426 {
1427 if (value==1) ifxusb_vbus_on (&ifxusb_hcd.core_if);
1428 else if(value==0) ifxusb_vbus_off(&ifxusb_hcd.core_if);
1429 }
1430 static ssize_t procfs_buspower_show(char *buf, char **start, off_t offset, int count, int *eof, void *data)
1431 {
1432 return buspower_show(buf);
1433 }
1434 static ssize_t procfs_buspower_store(struct file *file, const char *buffer, unsigned long count, void *data)
1435 {
1436 char buf[10];
1437 int i = 0;
1438 uint32_t value;
1439 if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1))
1440 return -EFAULT;
1441 value = simple_strtoul(buf, NULL, 10);
1442 buspower_store(value);
1443 return count;
1444 }
1445 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
1446 static ssize_t sysfs_buspower_show( struct device *_dev, struct device_attribute *attr,char *buf)
1447 #else
1448 static ssize_t sysfs_buspower_show( struct device *_dev, char *buf)
1449 #endif
1450 {
1451 return buspower_show(buf);
1452 }
1453 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
1454 static ssize_t sysfs_buspower_store( struct device *_dev, struct device_attribute *attr,const char *buffer, size_t count )
1455 #else
1456 static ssize_t sysfs_buspower_store( struct device *_dev, const char *buffer, size_t count )
1457 #endif
1458 {
1459 char buf[10];
1460 int i = 0;
1461 uint32_t value;
1462 if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1))
1463 return -EFAULT;
1464 value = simple_strtoul(buf, NULL, 10);
1465 buspower_store(value);
1466 return count;
1467 }
1468 DEVICE_ATTR(buspower, S_IRUGO|S_IWUSR, sysfs_buspower_show, sysfs_buspower_store);
1469 #endif
1470
1471 /////////////////////////////////////////////////////////////////////////////////////////////////////
1472 /////////////////////////////////////////////////////////////////////////////////////////////////////
1473 /////////////////////////////////////////////////////////////////////////////////////////////////////
1474
1475
1476 #ifdef __IS_DUAL__
1477 static ssize_t bussuspend_show_1(char *buf)
1478 {
1479 hprt0_data_t val;
1480 val.d32 = ifxusb_rreg(ifxusb_hcd_1.core_if.hprt0);
1481 return sprintf (buf, "Bus Suspend = 0x%x\n", val.b.prtsusp);
1482 }
1483 static ssize_t bussuspend_show_2(char *buf)
1484 {
1485 hprt0_data_t val;
1486 val.d32 = ifxusb_rreg(ifxusb_hcd_2.core_if.hprt0);
1487 return sprintf (buf, "Bus Suspend = 0x%x\n", val.b.prtsusp);
1488 }
1489
1490 static ssize_t procfs_bussuspend_show_1(char *buf, char **start, off_t offset, int count, int *eof, void *data)
1491 {
1492 return bussuspend_show_1(buf);
1493 }
1494 static ssize_t procfs_bussuspend_show_2(char *buf, char **start, off_t offset, int count, int *eof, void *data)
1495 {
1496 return bussuspend_show_2(buf);
1497 }
1498 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
1499 static ssize_t sysfs_bussuspend_show_1( struct device *_dev, struct device_attribute *attr,char *buf)
1500 #else
1501 static ssize_t sysfs_bussuspend_show_1( struct device *_dev,char *buf)
1502 #endif
1503 {
1504 return bussuspend_show_1(buf);
1505 }
1506 DEVICE_ATTR(bussuspend_1, S_IRUGO|S_IWUSR, sysfs_bussuspend_show_1, 0);
1507 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
1508 static ssize_t sysfs_bussuspend_show_2( struct device *_dev, struct device_attribute *attr,char *buf)
1509 #else
1510 static ssize_t sysfs_bussuspend_show_2( struct device *_dev,char *buf)
1511 #endif
1512 {
1513 return bussuspend_show_2(buf);
1514 }
1515 DEVICE_ATTR(bussuspend_2, S_IRUGO|S_IWUSR, sysfs_bussuspend_show_2, 0);
1516 #else
1517 static ssize_t bussuspend_show(char *buf)
1518 {
1519 hprt0_data_t val;
1520 val.d32 = ifxusb_rreg(ifxusb_hcd.core_if.hprt0);
1521 return sprintf (buf, "Bus Suspend = 0x%x\n", val.b.prtsusp);
1522 }
1523 static ssize_t procfs_bussuspend_show(char *buf, char **start, off_t offset, int count, int *eof, void *data)
1524 {
1525 return bussuspend_show(buf);
1526 }
1527
1528 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
1529 static ssize_t sysfs_bussuspend_show( struct device *_dev, struct device_attribute *attr,char *buf)
1530 #else
1531 static ssize_t sysfs_bussuspend_show( struct device *_dev, char *buf)
1532 #endif
1533 {
1534 return bussuspend_show(buf);
1535 }
1536 DEVICE_ATTR(bussuspend, S_IRUGO|S_IWUSR, sysfs_bussuspend_show, 0);
1537 #endif
1538
1539 /////////////////////////////////////////////////////////////////////////////////////////////////////
1540 /////////////////////////////////////////////////////////////////////////////////////////////////////
1541 /////////////////////////////////////////////////////////////////////////////////////////////////////
1542
1543 #ifdef __IS_DUAL__
1544 static ssize_t busconnected_show_1(char *buf)
1545 {
1546 hprt0_data_t val;
1547 val.d32 = ifxusb_rreg(ifxusb_hcd_1.core_if.hprt0);
1548 return sprintf (buf, "Bus Connected = 0x%x\n", val.b.prtconnsts);
1549 }
1550 static ssize_t busconnected_show_2(char *buf)
1551 {
1552 hprt0_data_t val;
1553 val.d32 = ifxusb_rreg(ifxusb_hcd_2.core_if.hprt0);
1554 return sprintf (buf, "Bus Connected = 0x%x\n", val.b.prtconnsts);
1555 }
1556
1557 static ssize_t procfs_busconnected_show_1(char *buf, char **start, off_t offset, int count, int *eof, void *data)
1558 {
1559 return busconnected_show_1(buf);
1560 }
1561 static ssize_t procfs_busconnected_show_2(char *buf, char **start, off_t offset, int count, int *eof, void *data)
1562 {
1563 return busconnected_show_2(buf);
1564 }
1565 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
1566 static ssize_t sysfs_busconnected_show_1( struct device *_dev, struct device_attribute *attr,char *buf)
1567 #else
1568 static ssize_t sysfs_busconnected_show_1( struct device *_dev,char *buf)
1569 #endif
1570 {
1571 return busconnected_show_1(buf);
1572 }
1573 DEVICE_ATTR(busconnected_1, S_IRUGO|S_IWUSR, sysfs_busconnected_show_1, 0);
1574 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
1575 static ssize_t sysfs_busconnected_show_2( struct device *_dev, struct device_attribute *attr,char *buf)
1576 #else
1577 static ssize_t sysfs_busconnected_show_2( struct device *_dev,char *buf)
1578 #endif
1579 {
1580 return busconnected_show_2(buf);
1581 }
1582 DEVICE_ATTR(busconnected_2, S_IRUGO|S_IWUSR, sysfs_busconnected_show_2, 0);
1583 #else
1584 static ssize_t busconnected_show(char *buf)
1585 {
1586 hprt0_data_t val;
1587 val.d32 = ifxusb_rreg(ifxusb_hcd.core_if.hprt0);
1588 return sprintf (buf, "Bus Connected = 0x%x\n", val.b.prtconnsts);
1589 }
1590 static ssize_t procfs_busconnected_show(char *buf, char **start, off_t offset, int count, int *eof, void *data)
1591 {
1592 return busconnected_show(buf);
1593 }
1594
1595 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
1596 static ssize_t sysfs_busconnected_show( struct device *_dev, struct device_attribute *attr,char *buf)
1597 #else
1598 static ssize_t sysfs_busconnected_show( struct device *_dev, char *buf)
1599 #endif
1600 {
1601 return busconnected_show(buf);
1602 }
1603 DEVICE_ATTR(busconnected, S_IRUGO|S_IWUSR, sysfs_busconnected_show, 0);
1604 #endif
1605
1606 /////////////////////////////////////////////////////////////////////////////////////////////////////
1607 /////////////////////////////////////////////////////////////////////////////////////////////////////
1608 /////////////////////////////////////////////////////////////////////////////////////////////////////
1609
1610 #ifdef __IS_DUAL__
1611 static ssize_t connectspeed_show_1(char *buf)
1612 {
1613 hprt0_data_t val;
1614 val.d32 = ifxusb_rreg(ifxusb_hcd_1.core_if.hprt0);
1615 if( val.b.prtspd ==0) return sprintf (buf, "Bus Speed = High (%d)\n", val.b.prtspd);
1616 if( val.b.prtspd ==1) return sprintf (buf, "Bus Speed = Full (%d)\n", val.b.prtspd);
1617 if( val.b.prtspd ==2) return sprintf (buf, "Bus Speed = Low (%d)\n", val.b.prtspd);
1618 return sprintf (buf, "Bus Speed = Unknown (%d)\n", val.b.prtspd);
1619 }
1620 static ssize_t connectspeed_show_2(char *buf)
1621 {
1622 hprt0_data_t val;
1623 val.d32 = ifxusb_rreg(ifxusb_hcd_2.core_if.hprt0);
1624 if( val.b.prtspd ==0) return sprintf (buf, "Bus Speed = High (%d)\n", val.b.prtspd);
1625 if( val.b.prtspd ==1) return sprintf (buf, "Bus Speed = Full (%d)\n", val.b.prtspd);
1626 if( val.b.prtspd ==2) return sprintf (buf, "Bus Speed = Low (%d)\n", val.b.prtspd);
1627 return sprintf (buf, "Bus Speed = Unknown (%d)\n", val.b.prtspd);
1628 }
1629
1630 static ssize_t procfs_connectspeed_show_1(char *buf, char **start, off_t offset, int count, int *eof, void *data)
1631 {
1632 return connectspeed_show_1(buf);
1633 }
1634 static ssize_t procfs_connectspeed_show_2(char *buf, char **start, off_t offset, int count, int *eof, void *data)
1635 {
1636 return connectspeed_show_2(buf);
1637 }
1638 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
1639 static ssize_t sysfs_connectspeed_show_1( struct device *_dev, struct device_attribute *attr,char *buf)
1640 #else
1641 static ssize_t sysfs_connectspeed_show_1( struct device *_dev,char *buf)
1642 #endif
1643 {
1644 return connectspeed_show_1(buf);
1645 }
1646 DEVICE_ATTR(connectspeed_1, S_IRUGO|S_IWUSR, sysfs_connectspeed_show_1, 0);
1647 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
1648 static ssize_t sysfs_connectspeed_show_2( struct device *_dev, struct device_attribute *attr,char *buf)
1649 #else
1650 static ssize_t sysfs_connectspeed_show_2( struct device *_dev,char *buf)
1651 #endif
1652 {
1653 return connectspeed_show_2(buf);
1654 }
1655 DEVICE_ATTR(connectspeed_2, S_IRUGO|S_IWUSR, sysfs_connectspeed_show_2, 0);
1656 #else
1657 static ssize_t connectspeed_show(char *buf)
1658 {
1659 hprt0_data_t val;
1660 val.d32 = ifxusb_rreg(ifxusb_hcd.core_if.hprt0);
1661 if( val.b.prtspd ==0) return sprintf (buf, "Bus Speed = High (%d)\n", val.b.prtspd);
1662 if( val.b.prtspd ==1) return sprintf (buf, "Bus Speed = Full (%d)\n", val.b.prtspd);
1663 if( val.b.prtspd ==2) return sprintf (buf, "Bus Speed = Low (%d)\n", val.b.prtspd);
1664 return sprintf (buf, "Bus Speed = Unknown (%d)\n", val.b.prtspd);
1665 }
1666
1667 static ssize_t procfs_connectspeed_show(char *buf, char **start, off_t offset, int count, int *eof, void *data)
1668 {
1669 return connectspeed_show(buf);
1670 }
1671
1672 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
1673 static ssize_t sysfs_connectspeed_show( struct device *_dev, struct device_attribute *attr,char *buf)
1674 #else
1675 static ssize_t sysfs_connectspeed_show( struct device *_dev, char *buf)
1676 #endif
1677 {
1678 return connectspeed_show(buf);
1679 }
1680 DEVICE_ATTR(connectspeed, S_IRUGO|S_IWUSR, sysfs_connectspeed_show, 0);
1681 #endif
1682 /////////////////////////////////////////////////////////////////////////////////////////////////////
1683 /////////////////////////////////////////////////////////////////////////////////////////////////////
1684 /////////////////////////////////////////////////////////////////////////////////////////////////////
1685 #endif
1686
1687
1688 #ifdef __IS_DEVICE__
1689 /////////////////////////////////////////////////////////////////////////////////////////////////////
1690 /////////////////////////////////////////////////////////////////////////////////////////////////////
1691 /////////////////////////////////////////////////////////////////////////////////////////////////////
1692 static ssize_t devspeed_show(char *buf)
1693 {
1694 dcfg_data_t val;
1695 val.d32 = ifxusb_rreg(&ifxusb_pcd.core_if.dev_global_regs->dcfg);
1696 if( val.b.devspd ==0) return sprintf (buf, "Dev Speed = High (%d)\n", val.b.devspd);
1697 if( val.b.devspd ==1) return sprintf (buf, "Dev Speed = Full (%d)\n", val.b.devspd);
1698 if( val.b.devspd ==3) return sprintf (buf, "Dev Speed = Full (%d)\n", val.b.devspd);
1699 return sprintf (buf, "Dev Speed = Unknown (%d)\n", val.b.devspd);
1700 }
1701
1702 static ssize_t procfs_devspeed_show(char *buf, char **start, off_t offset, int count, int *eof, void *data)
1703 {
1704 return devspeed_show(buf);
1705 }
1706
1707 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
1708 static ssize_t sysfs_devspeed_show( struct device *_dev, struct device_attribute *attr,char *buf)
1709 #else
1710 static ssize_t sysfs_devspeed_show( struct device *_dev, char *buf)
1711 #endif
1712 {
1713 return devspeed_show(buf);
1714 }
1715 DEVICE_ATTR(devspeed, S_IRUGO|S_IWUSR, sysfs_devspeed_show, 0);
1716
1717 static ssize_t enumspeed_show(char *buf)
1718 {
1719 dsts_data_t val;
1720 val.d32 = ifxusb_rreg(&ifxusb_pcd.core_if.dev_global_regs->dsts);
1721 if( val.b.enumspd ==0) return sprintf (buf, "Enum Speed = High (%d)\n", val.b.enumspd);
1722 if( val.b.enumspd ==1) return sprintf (buf, "Enum Speed = Full (%d)\n", val.b.enumspd);
1723 if( val.b.enumspd ==2) return sprintf (buf, "Enum Speed = Low (%d)\n", val.b.enumspd);
1724 return sprintf (buf, "Enum Speed = invalid(%d)\n", val.b.enumspd);
1725 }
1726
1727 static ssize_t procfs_enumspeed_show(char *buf, char **start, off_t offset, int count, int *eof, void *data)
1728 {
1729 return enumspeed_show(buf);
1730 }
1731
1732 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
1733 static ssize_t sysfs_enumspeed_show( struct device *_dev, struct device_attribute *attr,char *buf)
1734 #else
1735 static ssize_t sysfs_enumspeed_show( struct device *_dev, char *buf)
1736 #endif
1737 {
1738 return enumspeed_show(buf);
1739 }
1740 DEVICE_ATTR(enumspeed, S_IRUGO|S_IWUSR, sysfs_enumspeed_show, 0);
1741 /////////////////////////////////////////////////////////////////////////////////////////////////////
1742 /////////////////////////////////////////////////////////////////////////////////////////////////////
1743 /////////////////////////////////////////////////////////////////////////////////////////////////////
1744 #endif
1745
1746
1747 //////////////////////////////////////////////////////////////////////////////////
1748 #ifdef __ENABLE_DUMP__
1749
1750 #ifdef __IS_DUAL__
1751 static void dump_reg_1(void)
1752 {
1753 ifxusb_dump_registers_h(&ifxusb_hcd_1.core_if);
1754 }
1755 static void dump_reg_2(void)
1756 {
1757 ifxusb_dump_registers_h(&ifxusb_hcd_2.core_if);
1758 }
1759
1760 static ssize_t procfs_dump_reg_show_1(char *buf, char **start, off_t offset, int count, int *eof, void *data)
1761 {
1762 dump_reg_1();
1763 return 0;
1764 }
1765 static ssize_t procfs_dump_reg_show_2(char *buf, char **start, off_t offset, int count, int *eof, void *data)
1766 {
1767 dump_reg_2();
1768 return 0;
1769 }
1770 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
1771 static ssize_t sysfs_dump_reg_show_1( struct device *_dev, struct device_attribute *attr,char *buf)
1772 #else
1773 static ssize_t sysfs_dump_reg_show_1( struct device *_dev,char *buf)
1774 #endif
1775 {
1776 dump_reg_1();
1777 return 0;
1778 }
1779 DEVICE_ATTR(dump_reg_h_1, S_IRUGO|S_IWUSR, sysfs_dump_reg_show_1, 0);
1780 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
1781 static ssize_t sysfs_dump_reg_show_2( struct device *_dev, struct device_attribute *attr,char *buf)
1782 #else
1783 static ssize_t sysfs_dump_reg_show_2( struct device *_dev,char *buf)
1784 #endif
1785 {
1786 dump_reg_2();
1787 return 0;
1788 }
1789 DEVICE_ATTR(dump_reg_h_2, S_IRUGO|S_IWUSR, sysfs_dump_reg_show_2, 0);
1790 #else
1791 static void dump_reg(void)
1792 {
1793 #ifdef __IS_HOST__
1794 ifxusb_dump_registers_h(&ifxusb_hcd.core_if);
1795 #endif
1796 #ifdef __IS_DEVICE__
1797 ifxusb_dump_registers_d(&ifxusb_pcd.core_if);
1798 #endif
1799 }
1800 static ssize_t procfs_dump_reg_show(char *buf, char **start, off_t offset, int count, int *eof, void *data)
1801 {
1802 dump_reg();
1803 return 0;
1804 }
1805 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
1806 static ssize_t sysfs_dump_reg_show( struct device *_dev, struct device_attribute *attr,char *buf)
1807 #else
1808 static ssize_t sysfs_dump_reg_show( struct device *_dev,char *buf)
1809 #endif
1810 {
1811 dump_reg();
1812 return 0;
1813 }
1814 #ifdef __IS_HOST__
1815 DEVICE_ATTR(dump_reg_h, S_IRUGO|S_IWUSR, sysfs_dump_reg_show, 0);
1816 #else
1817 DEVICE_ATTR(dump_reg_d, S_IRUGO|S_IWUSR, sysfs_dump_reg_show, 0);
1818 #endif
1819 #endif
1820
1821
1822 /////////////////////////////////////////////////////////////////////////////////////////////////////
1823 /////////////////////////////////////////////////////////////////////////////////////////////////////
1824 /////////////////////////////////////////////////////////////////////////////////////////////////////
1825
1826 #ifdef __IS_DUAL__
1827 static void dump_spram_1(void)
1828 {
1829 ifxusb_dump_spram_h(&ifxusb_hcd_1.core_if);
1830 }
1831 static void dump_spram_2(void)
1832 {
1833 ifxusb_dump_spram_h(&ifxusb_hcd_2.core_if);
1834 }
1835
1836 static ssize_t procfs_dump_spram_show_1(char *buf, char **start, off_t offset, int count, int *eof, void *data)
1837 {
1838 dump_spram_1();
1839 return 0;
1840 }
1841 static ssize_t procfs_dump_spram_show_2(char *buf, char **start, off_t offset, int count, int *eof, void *data)
1842 {
1843 dump_spram_2();
1844 return 0;
1845 }
1846 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
1847 static ssize_t sysfs_dump_spram_show_1( struct device *_dev, struct device_attribute *attr,char *buf)
1848 #else
1849 static ssize_t sysfs_dump_spram_show_1( struct device *_dev,char *buf)
1850 #endif
1851 {
1852 dump_spram_1();
1853 return 0;
1854 }
1855 DEVICE_ATTR(dump_spram_h_1, S_IRUGO|S_IWUSR, sysfs_dump_spram_show_1, 0);
1856
1857 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
1858 static ssize_t sysfs_dump_spram_show_2( struct device *_dev, struct device_attribute *attr,char *buf)
1859 #else
1860 static ssize_t sysfs_dump_spram_show_2( struct device *_dev,char *buf)
1861 #endif
1862 {
1863 dump_spram_2();
1864 return 0;
1865 }
1866 DEVICE_ATTR(dump_spram_h_2, S_IRUGO|S_IWUSR, sysfs_dump_spram_show_2, 0);
1867 #else
1868 static void dump_spram(void)
1869 {
1870 #ifdef __IS_HOST__
1871 ifxusb_dump_spram_h(&ifxusb_hcd.core_if);
1872 #endif
1873 #ifdef __IS_DEVICE__
1874 ifxusb_dump_spram_d(&ifxusb_pcd.core_if);
1875 #endif
1876 }
1877 static ssize_t procfs_dump_spram_show(char *buf, char **start, off_t offset, int count, int *eof, void *data)
1878 {
1879 dump_spram();
1880 return 0;
1881 }
1882 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
1883 static ssize_t sysfs_dump_spram_show( struct device *_dev, struct device_attribute *attr,char *buf)
1884 #else
1885 static ssize_t sysfs_dump_spram_show( struct device *_dev,char *buf)
1886 #endif
1887 {
1888 dump_spram();
1889 return 0;
1890 }
1891 #ifdef __IS_HOST__
1892 DEVICE_ATTR(dump_spram_h, S_IRUGO|S_IWUSR, sysfs_dump_spram_show, 0);
1893 #else
1894 DEVICE_ATTR(dump_spram_d, S_IRUGO|S_IWUSR, sysfs_dump_spram_show, 0);
1895 #endif
1896
1897 #endif
1898 /////////////////////////////////////////////////////////////////////////////////////////////////////
1899 /////////////////////////////////////////////////////////////////////////////////////////////////////
1900 /////////////////////////////////////////////////////////////////////////////////////////////////////
1901
1902 #ifdef __IS_HOST__
1903 #ifdef __IS_DUAL__
1904 static ssize_t procfs_dump_host_state_show_1(char *buf, char **start, off_t offset, int count, int *eof, void *data)
1905 {
1906 ifxhcd_dump_state(&ifxusb_hcd_1);
1907 return 0;
1908 }
1909 static ssize_t procfs_dump_host_state_show_2(char *buf, char **start, off_t offset, int count, int *eof, void *data)
1910 {
1911 ifxhcd_dump_state(&ifxusb_hcd_2);
1912 return 0;
1913 }
1914 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
1915 static ssize_t sysfs_dump_host_state_show_1( struct device *_dev, struct device_attribute *attr,char *buf)
1916 #else
1917 static ssize_t sysfs_dump_host_state_show_1( struct device *_dev,char *buf)
1918 #endif
1919 {
1920 ifxhcd_dump_state(&ifxusb_hcd_1);
1921 return 0;
1922 }
1923 DEVICE_ATTR(dump_host_state_1, S_IRUGO|S_IWUSR, sysfs_dump_host_state_show_1, 0);
1924 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
1925 static ssize_t sysfs_dump_host_state_show_2( struct device *_dev, struct device_attribute *attr,char *buf)
1926 #else
1927 static ssize_t sysfs_dump_host_state_show_2( struct device *_dev,char *buf)
1928 #endif
1929 {
1930 ifxhcd_dump_state(&ifxusb_hcd_2);
1931 return 0;
1932 }
1933 DEVICE_ATTR(dump_host_state_2, S_IRUGO|S_IWUSR, sysfs_dump_host_state_show_2, 0);
1934 #else
1935 static ssize_t procfs_dump_host_state_show(char *buf, char **start, off_t offset, int count, int *eof, void *data)
1936 {
1937 ifxhcd_dump_state(&ifxusb_hcd);
1938 return 0;
1939 }
1940 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
1941 static ssize_t sysfs_dump_host_state_show( struct device *_dev, struct device_attribute *attr,char *buf)
1942 #else
1943 static ssize_t sysfs_dump_host_state_show( struct device *_dev,char *buf)
1944 #endif
1945 {
1946 ifxhcd_dump_state(&ifxusb_hcd);
1947 return 0;
1948 }
1949 DEVICE_ATTR(dump_host_state, S_IRUGO|S_IWUSR, sysfs_dump_host_state_show, 0);
1950 #endif
1951
1952 /////////////////////////////////////////////////////////////////////////////////////////////////////
1953 /////////////////////////////////////////////////////////////////////////////////////////////////////
1954 /////////////////////////////////////////////////////////////////////////////////////////////////////
1955
1956 #endif //IS_HOST_
1957
1958 #endif //__ENABLE_DUMP__
1959 /////////////////////////////////////////////////////////////////////////////////////////////////////
1960 /////////////////////////////////////////////////////////////////////////////////////////////////////
1961 #ifdef __IS_HOST__
1962 static void host_probe(unsigned long _ptr)
1963 {
1964 ifxhcd_hcd_t *ifxhcd = (ifxhcd_hcd_t *)_ptr;
1965
1966 if(ifxhcd->flags.b.port_connect_status)
1967 {
1968 del_timer(&ifxhcd->host_probe_timer);
1969 del_timer(&ifxhcd->autoprobe_timer);
1970 ifxhcd->power_status = 0;
1971 }
1972 else
1973 {
1974 del_timer(&ifxhcd->autoprobe_timer);
1975 ifxhcd->autoprobe_timer.expires = jiffies + (HZ*ifxhcd->autoprobe_sec);
1976 add_timer(&ifxhcd->autoprobe_timer);
1977 ifxhcd->power_status = 2;
1978 del_timer(&ifxhcd->host_probe_timer);
1979 do_suspend_h(&ifxhcd->core_if);
1980 }
1981 }
1982
1983 static void host_autoprobe(unsigned long _ptr)
1984 {
1985 ifxhcd_hcd_t *ifxhcd = (ifxhcd_hcd_t *)_ptr;
1986 del_timer(&ifxhcd->host_probe_timer);
1987 ifxhcd->host_probe_timer.function = host_probe;
1988 ifxhcd->host_probe_timer.expires = jiffies + (HZ*ifxhcd->probe_sec);
1989 ifxhcd->host_probe_timer.data = (unsigned long)ifxhcd;
1990 add_timer(&ifxhcd->host_probe_timer);
1991 do_resume_h(&ifxhcd->core_if);
1992 }
1993
1994 static void suspend_host_store(ifxhcd_hcd_t *ifxhcd , uint32_t value)
1995 {
1996 if(value==2)
1997 {
1998 del_timer(&ifxhcd->autoprobe_timer);
1999 ifxhcd->autoprobe_timer.function = host_autoprobe;
2000 ifxhcd->autoprobe_timer.expires = jiffies + (HZ*ifxhcd->autoprobe_sec);
2001 ifxhcd->autoprobe_timer.data = (unsigned long)ifxhcd;
2002 add_timer(&ifxhcd->autoprobe_timer);
2003 ifxhcd->power_status = 2;
2004 }
2005 else if(value==1)
2006 {
2007 do_suspend_h(&ifxhcd->core_if);
2008 ifxhcd->power_status = 1;
2009 del_timer(&ifxhcd->host_probe_timer);
2010 del_timer(&ifxhcd->autoprobe_timer);
2011 }
2012 else if(value==0)
2013 {
2014 do_resume_h(&ifxhcd->core_if);
2015 ifxhcd->power_status = 0;
2016 del_timer(&ifxhcd->host_probe_timer);
2017 del_timer(&ifxhcd->autoprobe_timer);
2018 }
2019 }
2020 #ifdef __IS_DUAL__
2021 static ssize_t procfs_suspend_host_2_store(struct file *file, const char *buffer, unsigned long count, void *data)
2022 {
2023 char buf[10];
2024 int i = 0;
2025 uint32_t value;
2026 if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1))
2027 return -EFAULT;
2028 value = simple_strtoul(buf, NULL, 10);
2029 suspend_host_store(&ifxusb_hcd_2,value);
2030 return count;
2031 }
2032
2033 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
2034 static ssize_t sysfs_suspend_host_2_store( struct device *_dev, struct device_attribute *attr,const char *buffer, size_t count )
2035 #else
2036 static ssize_t sysfs_suspend_host_2_store( struct device *_dev, const char *buffer, size_t count )
2037 #endif
2038 {
2039 char buf[10];
2040 int i = 0;
2041 uint32_t value;
2042 if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1))
2043 return -EFAULT;
2044 value = simple_strtoul(buf, NULL, 10);
2045 suspend_host_store(&ifxusb_hcd_2,value);
2046 return count;
2047 }
2048
2049 static ssize_t procfs_suspend_host_1_store(struct file *file, const char *buffer, unsigned long count, void *data)
2050 {
2051 char buf[10];
2052 int i = 0;
2053 uint32_t value;
2054 if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1))
2055 return -EFAULT;
2056 value = simple_strtoul(buf, NULL, 10);
2057 suspend_host_store(&ifxusb_hcd_1,value);
2058 return count;
2059 }
2060
2061 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
2062 static ssize_t sysfs_suspend_host_1_store( struct device *_dev, struct device_attribute *attr,const char *buffer, size_t count )
2063 #else
2064 static ssize_t sysfs_suspend_host_1_store( struct device *_dev, const char *buffer, size_t count )
2065 #endif
2066 {
2067 char buf[10];
2068 int i = 0;
2069 uint32_t value;
2070 if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1))
2071 return -EFAULT;
2072 value = simple_strtoul(buf, NULL, 10);
2073 suspend_host_store(&ifxusb_hcd_1,value);
2074 return count;
2075 }
2076 DEVICE_ATTR(suspend_host_2, S_IWUSR,NULL, sysfs_suspend_host_2_store);
2077 DEVICE_ATTR(suspend_host_1, S_IWUSR,NULL, sysfs_suspend_host_1_store);
2078 /////////////////////////////////////////////////////////////////////////////////////////////////////
2079 #else
2080 static ssize_t procfs_suspend_host_store(struct file *file, const char *buffer, unsigned long count, void *data)
2081 {
2082 char buf[10];
2083 int i = 0;
2084 uint32_t value;
2085 if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1))
2086 return -EFAULT;
2087 value = simple_strtoul(buf, NULL, 10);
2088 suspend_host_store(&ifxusb_hcd,value);
2089 return count;
2090 }
2091
2092 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
2093 static ssize_t sysfs_suspend_host_store( struct device *_dev, struct device_attribute *attr,const char *buffer, size_t count )
2094 #else
2095 static ssize_t sysfs_suspend_host_store( struct device *_dev, const char *buffer, size_t count )
2096 #endif
2097 {
2098 char buf[10];
2099 int i = 0;
2100 uint32_t value;
2101 if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1))
2102 return -EFAULT;
2103 value = simple_strtoul(buf, NULL, 10);
2104 suspend_host_store(&ifxusb_hcd,value);
2105 return count;
2106 }
2107 DEVICE_ATTR(suspend_host, S_IWUSR,NULL, sysfs_suspend_host_store);
2108 #endif
2109 #endif
2110
2111 /////////////////////////////////////////////////////////////////////////////////////////////////////
2112 /////////////////////////////////////////////////////////////////////////////////////////////////////
2113 #ifdef __IS_HOST__
2114 static void probe_host_store(ifxhcd_hcd_t *ifxhcd, uint32_t value)
2115 {
2116 if(ifxhcd->power_status == 1)
2117 {
2118 del_timer(&ifxhcd->host_probe_timer);
2119 ifxhcd->host_probe_timer.function = host_probe;
2120 ifxhcd->host_probe_timer.expires = jiffies + (HZ*ifxhcd->probe_sec);
2121 ifxhcd->host_probe_timer.data = (unsigned long) ifxhcd;
2122 add_timer(&ifxhcd->host_probe_timer);
2123 do_resume_h(&ifxhcd->core_if);
2124 }
2125 }
2126 #ifdef __IS_DUAL__
2127 static ssize_t probe_host_2_show(char *buf)
2128 {
2129 if(ifxusb_hcd_2.power_status == 0)
2130 return sprintf (buf,"Host 2 power status is ON\n");
2131 else if(ifxusb_hcd_2.power_status == 1)
2132 return sprintf (buf,"Host 2 power status is Suspend\n");
2133 else
2134 return sprintf (buf,"Host 2 power status is Auto-probing\n");
2135 }
2136 static ssize_t probe_host_1_show(char *buf)
2137 {
2138 if(ifxusb_hcd_1.power_status == 0)
2139 return sprintf (buf,"Host 1 power status is ON\n");
2140 else if(ifxusb_hcd_1.power_status == 1)
2141 return sprintf (buf,"Host 1 power status is Suspend\n");
2142 else
2143 return sprintf (buf,"Host 1 power status is Auto-probing\n");
2144 }
2145 static ssize_t procfs_probe_host_2_store(struct file *file, const char *buffer, unsigned long count, void *data)
2146 {
2147 char buf[10];
2148 int i = 0;
2149 uint32_t value;
2150 if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1))
2151 return -EFAULT;
2152 value = simple_strtoul(buf, NULL, 10);
2153 probe_host_store(&ifxusb_hcd_2,value);
2154 return count;
2155 }
2156 static ssize_t procfs_probe_host_2_show(char *buf, char **start, off_t offset, int count, int *eof, void *data)
2157 {
2158 return probe_host_2_show(buf);
2159 }
2160 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
2161 static ssize_t sysfs_probe_host_2_show( struct device *_dev, struct device_attribute *attr,char *buf)
2162 #else
2163 static ssize_t sysfs_probe_host_2_show( struct device *_dev, char *buf)
2164 #endif
2165 {
2166 return probe_host_2_show(buf);
2167 }
2168 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
2169 static ssize_t sysfs_probe_host_2_store( struct device *_dev, struct device_attribute *attr,const char *buffer, size_t count )
2170 #else
2171 static ssize_t sysfs_probe_host_2_store( struct device *_dev, const char *buffer, size_t count )
2172 #endif
2173 {
2174 char buf[10];
2175 int i = 0;
2176 uint32_t value;
2177 if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1))
2178 return -EFAULT;
2179 value = simple_strtoul(buf, NULL, 10);
2180 probe_host_store(&ifxusb_hcd_2,value);
2181 return count;
2182 }
2183
2184 static ssize_t procfs_probe_host_1_store(struct file *file, const char *buffer, unsigned long count, void *data)
2185 {
2186 char buf[10];
2187 int i = 0;
2188 uint32_t value;
2189 if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1))
2190 return -EFAULT;
2191 value = simple_strtoul(buf, NULL, 10);
2192 probe_host_store(&ifxusb_hcd_1,value);
2193 return count;
2194 }
2195 static ssize_t procfs_probe_host_1_show(char *buf, char **start, off_t offset, int count, int *eof, void *data)
2196 {
2197 return probe_host_1_show(buf);
2198 }
2199 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
2200 static ssize_t sysfs_probe_host_1_show( struct device *_dev, struct device_attribute *attr,char *buf)
2201 #else
2202 static ssize_t sysfs_probe_host_1_show( struct device *_dev, char *buf)
2203 #endif
2204 {
2205 return probe_host_1_show(buf);
2206 }
2207 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
2208 static ssize_t sysfs_probe_host_1_store( struct device *_dev, struct device_attribute *attr,const char *buffer, size_t count )
2209 #else
2210 static ssize_t sysfs_probe_host_1_store( struct device *_dev, const char *buffer, size_t count )
2211 #endif
2212 {
2213 char buf[10];
2214 int i = 0;
2215 uint32_t value;
2216 if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1))
2217 return -EFAULT;
2218 value = simple_strtoul(buf, NULL, 10);
2219 probe_host_store(&ifxusb_hcd_1,value);
2220 return count;
2221 }
2222 DEVICE_ATTR(probe_host_2, S_IRUGO|S_IWUSR, sysfs_probe_host_2_show, sysfs_probe_host_2_store);
2223 DEVICE_ATTR(probe_host_1, S_IRUGO|S_IWUSR, sysfs_probe_host_1_show, sysfs_probe_host_1_store);
2224 /////////////////////////////////////////////////////////////////////////////////////////////////////
2225 #else
2226 static ssize_t probe_host_show(char *buf)
2227 {
2228 if(ifxusb_hcd.power_status == 0)
2229 return sprintf (buf,"Host power status is ON\n");
2230 else if(ifxusb_hcd.power_status == 1)
2231 return sprintf (buf,"Host power status is Suspend\n");
2232 else
2233 return sprintf (buf,"Host power status is Auto-probing\n");
2234 }
2235 static ssize_t procfs_probe_host_store(struct file *file, const char *buffer, unsigned long count, void *data)
2236 {
2237 char buf[10];
2238 int i = 0;
2239 uint32_t value;
2240 if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1))
2241 return -EFAULT;
2242 value = simple_strtoul(buf, NULL, 10);
2243 probe_host_store(&ifxusb_hcd,value);
2244 return count;
2245 }
2246 static ssize_t procfs_probe_host_show(char *buf, char **start, off_t offset, int count, int *eof, void *data)
2247 {
2248 return probe_host_show(buf);
2249 }
2250 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
2251 static ssize_t sysfs_probe_host_show( struct device *_dev, struct device_attribute *attr,char *buf)
2252 #else
2253 static ssize_t sysfs_probe_host_show( struct device *_dev, char *buf)
2254 #endif
2255 {
2256 return probe_host_show(buf);
2257 }
2258 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
2259 static ssize_t sysfs_probe_host_store( struct device *_dev, struct device_attribute *attr,const char *buffer, size_t count )
2260 #else
2261 static ssize_t sysfs_probe_host_store( struct device *_dev, const char *buffer, size_t count )
2262 #endif
2263 {
2264 char buf[10];
2265 int i = 0;
2266 uint32_t value;
2267 if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1))
2268 return -EFAULT;
2269 value = simple_strtoul(buf, NULL, 10);
2270 probe_host_store(&ifxusb_hcd,value);
2271 return count;
2272 }
2273 DEVICE_ATTR(probe_host, S_IRUGO|S_IWUSR, sysfs_probe_host_show, sysfs_probe_host_store);
2274 #endif
2275 #endif
2276 /////////////////////////////////////////////////////////////////////////////////////////////////////
2277 /////////////////////////////////////////////////////////////////////////////////////////////////////
2278 #ifdef __IS_DEVICE__
2279 static void device_probe(unsigned long _ptr)
2280 {
2281 if(ifxusb_pcd.power_status == 2)
2282 {
2283 del_timer(&ifxusb_pcd.device_autoprobe_timer);
2284 ifxusb_pcd.device_autoprobe_timer.expires = jiffies + (HZ*ifxusb_pcd.autoprobe_sec);
2285 add_timer(&ifxusb_pcd.device_autoprobe_timer);
2286 ifxusb_pcd.power_status = 2;
2287 do_suspend_d(&ifxusb_pcd.core_if);
2288 }
2289 else if(ifxusb_pcd.power_status == 1)
2290 {
2291 do_suspend_d(&ifxusb_pcd.core_if);
2292 ifxusb_pcd.power_status = 1;
2293 }
2294 }
2295 static void device_autoprobe(unsigned long _ptr)
2296 {
2297 init_timer(&ifxusb_pcd.device_probe_timer);
2298 ifxusb_pcd.device_probe_timer.function = device_probe;
2299 ifxusb_pcd.device_probe_timer.expires = jiffies + (HZ*ifxusb_pcd.probe_sec);
2300 add_timer(&ifxusb_pcd.device_probe_timer);
2301 do_resume_d(&ifxusb_pcd.core_if);
2302 }
2303 static void suspend_device_store(uint32_t value)
2304 {
2305 if(value==2)
2306 {
2307 del_timer(&ifxusb_pcd.device_autoprobe_timer);
2308 ifxusb_pcd.device_autoprobe_timer.function = device_autoprobe;
2309 ifxusb_pcd.device_autoprobe_timer.expires = jiffies + (HZ*ifxusb_pcd.autoprobe_sec);
2310 add_timer(&ifxusb_pcd.device_autoprobe_timer);
2311 ifxusb_pcd.power_status = 2;
2312 }
2313 else if(value==1)
2314 {
2315 do_suspend_d(&ifxusb_pcd.core_if);
2316 ifxusb_pcd.power_status = 1;
2317 del_timer(&ifxusb_pcd.device_autoprobe_timer);
2318 del_timer(&ifxusb_pcd.device_probe_timer);
2319 }
2320 else if(value==0)
2321 {
2322 do_resume_d(&ifxusb_pcd.core_if);
2323 ifxusb_pcd.power_status = 0;
2324 del_timer(&ifxusb_pcd.device_autoprobe_timer);
2325 del_timer(&ifxusb_pcd.device_probe_timer);
2326 }
2327 }
2328 static ssize_t procfs_suspend_device_store(struct file *file, const char *buffer, unsigned long count, void *data)
2329 {
2330 char buf[10];
2331 int i = 0;
2332 uint32_t value;
2333 if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1))
2334 return -EFAULT;
2335 value = simple_strtoul(buf, NULL, 10);
2336 suspend_device_store(value);
2337 return count;
2338 }
2339 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
2340 static ssize_t sysfs_suspend_device_store( struct device *_dev, struct device_attribute *attr,const char *buffer, size_t count )
2341 #else
2342 static ssize_t sysfs_suspend_device_store( struct device *_dev, const char *buffer, size_t count )
2343 #endif
2344 {
2345 char buf[10];
2346 int i = 0;
2347 uint32_t value;
2348 if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1))
2349 return -EFAULT;
2350 value = simple_strtoul(buf, NULL, 10);
2351 suspend_device_store(value);
2352 return count;
2353 }
2354 DEVICE_ATTR(suspend_device, S_IWUSR,NULL,sysfs_suspend_device_store);
2355 #endif
2356 /////////////////////////////////////////////////////////////////////////////////////////////////////
2357 #ifdef __IS_DEVICE__
2358 static ssize_t probe_device_show(char *buf)
2359 {
2360 if(ifxusb_pcd.power_status == 0)
2361 return sprintf (buf,"Device power status is ON\n");
2362 else if(ifxusb_pcd.power_status == 1)
2363 return sprintf (buf,"Device power status is Suspend\n");
2364 else
2365 return printk(buf,"Device power status is Auto-probing\n");
2366 }
2367 static void probe_device_store(uint32_t value)
2368 {
2369
2370 if(ifxusb_pcd.power_status == 1)
2371 {
2372 del_timer(&ifxusb_pcd.device_probe_timer);
2373 ifxusb_pcd.device_probe_timer.function = device_probe;
2374 ifxusb_pcd.device_probe_timer.expires = jiffies + (HZ*ifxusb_pcd.probe_sec);
2375 add_timer(&ifxusb_pcd.device_probe_timer);
2376 do_resume_d(&ifxusb_pcd.core_if);
2377 }
2378 }
2379 static ssize_t procfs_probe_device_store(struct file *file, const char *buffer, unsigned long count, void *data)
2380 {
2381 char buf[10];
2382 int i = 0;
2383 uint32_t value;
2384 if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1))
2385 return -EFAULT;
2386 value = simple_strtoul(buf, NULL, 10);
2387 probe_device_store(value);
2388 return count;
2389 }
2390 static ssize_t procfs_probe_device_show(char *buf, char **start, off_t offset, int count, int *eof, void *data)
2391 {
2392 return probe_device_show(buf);
2393 }
2394 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
2395 static ssize_t sysfs_probe_device_show( struct device *_dev, struct device_attribute *attr,char *buf)
2396 #else
2397 static ssize_t sysfs_probe_device_show( struct device *_dev, char *buf)
2398 #endif
2399 {
2400 return probe_device_show(buf);
2401 }
2402 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
2403 static ssize_t sysfs_probe_device_store( struct device *_dev, struct device_attribute *attr,const char *buffer, size_t count )
2404 #else
2405 static ssize_t sysfs_probe_device_store( struct device *_dev, const char *buffer, size_t count )
2406 #endif
2407 {
2408 char buf[10];
2409 int i = 0;
2410 uint32_t value;
2411 if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1))
2412 return -EFAULT;
2413 value = simple_strtoul(buf, NULL, 10);
2414 probe_device_store(value);
2415 return count;
2416 }
2417 DEVICE_ATTR(probe_device, S_IRUGO|S_IWUSR, sysfs_probe_device_show, sysfs_probe_device_store);
2418 #endif
2419 /////////////////////////////////////////////////////////////////////////////////////////////////////
2420 /////////////////////////////////////////////////////////////////////////////////////////////////////
2421 #ifdef __IS_HOST__
2422 #ifdef __IS_DUAL__
2423 static ssize_t autoprobe_timer2_val_show(char *buf)
2424 {
2425 return sprintf (buf,"Host 2 auto-probe timer is %d second\n",ifxusb_hcd_2.autoprobe_sec);
2426 }
2427 static ssize_t procfs_autoprobe_timer2_val_store(struct file *file, const char *buffer, unsigned long count, void *data)
2428 {
2429 char buf[10];
2430 int i = 0;
2431 uint32_t value;
2432 if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1))
2433 return -EFAULT;
2434 value = simple_strtoul(buf, NULL, 10);
2435 if((value > 0)&&(value < 300))
2436 ifxusb_hcd_2.autoprobe_sec = value;
2437 return count;
2438 }
2439 static ssize_t procfs_autoprobe_timer2_val_show(char *buf, char **start, off_t offset, int count, int *eof, void *data)
2440 {
2441 return autoprobe_timer2_val_show(buf);
2442 }
2443 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
2444 static ssize_t sysfs_autoprobe_timer2_val_show( struct device *_dev, struct device_attribute *attr,char *buf)
2445 #else
2446 static ssize_t sysfs_autoprobe_timer2_val_show( struct device *_dev, char *buf)
2447 #endif
2448 {
2449 return autoprobe_timer2_val_show(buf);
2450 }
2451 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
2452 static ssize_t sysfs_autoprobe_timer2_val_store( struct device *_dev, struct device_attribute *attr,const char *buffer, size_t count )
2453 #else
2454 static ssize_t sysfs_autoprobe_timer2_val_store( struct device *_dev, const char *buffer, size_t count )
2455 #endif
2456 {
2457 char buf[10];
2458 int i = 0;
2459 uint32_t value;
2460 if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1))
2461 return -EFAULT;
2462 value = simple_strtoul(buf, NULL, 10);
2463 if((value > 0)&&(value < 300))
2464 ifxusb_hcd_2.autoprobe_sec = value;
2465 return count;
2466 }
2467
2468 static ssize_t autoprobe_timer1_val_show(char *buf)
2469 {
2470 return sprintf (buf,"Host 1 auto-probe timer is %d second\n",ifxusb_hcd_1.autoprobe_sec);
2471 }
2472 static ssize_t procfs_autoprobe_timer1_val_store(struct file *file, const char *buffer, unsigned long count, void *data)
2473 {
2474 char buf[10];
2475 int i = 0;
2476 uint32_t value;
2477 if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1))
2478 return -EFAULT;
2479 value = simple_strtoul(buf, NULL, 10);
2480 if((value > 0)&&(value < 300))
2481 ifxusb_hcd_1.autoprobe_sec = value;
2482 return count;
2483 }
2484 static ssize_t procfs_autoprobe_timer1_val_show(char *buf, char **start, off_t offset, int count, int *eof, void *data)
2485 {
2486 return autoprobe_timer1_val_show(buf);
2487 }
2488 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
2489 static ssize_t sysfs_autoprobe_timer1_val_show( struct device *_dev, struct device_attribute *attr,char *buf)
2490 #else
2491 static ssize_t sysfs_autoprobe_timer1_val_show( struct device *_dev, char *buf)
2492 #endif
2493 {
2494 return autoprobe_timer1_val_show(buf);
2495 }
2496 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
2497 static ssize_t sysfs_autoprobe_timer1_val_store( struct device *_dev, struct device_attribute *attr,const char *buffer, size_t count )
2498 #else
2499 static ssize_t sysfs_autoautoprobe_timer1_val_store( struct device *_dev, const char *buffer, size_t count )
2500 #endif
2501 {
2502 char buf[10];
2503 int i = 0;
2504 uint32_t value;
2505 if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1))
2506 return -EFAULT;
2507 value = simple_strtoul(buf, NULL, 10);
2508 if((value > 0)&&(value < 300))
2509 ifxusb_hcd_1.autoprobe_sec = value;
2510 return count;
2511 }
2512
2513 static ssize_t probe_timer2_val_show(char *buf)
2514 {
2515 return sprintf (buf,"Host 2 probe timer is %d second\n",ifxusb_hcd_2.probe_sec);
2516 }
2517 static ssize_t procfs_probe_timer2_val_store(struct file *file, const char *buffer, unsigned long count, void *data)
2518 {
2519 char buf[10];
2520 int i = 0;
2521 uint32_t value;
2522 if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1))
2523 return -EFAULT;
2524 value = simple_strtoul(buf, NULL, 10);
2525 if((value > 0)&&(value < 10))
2526 ifxusb_hcd_2.probe_sec = value;
2527 return count;
2528 }
2529 static ssize_t procfs_probe_timer2_val_show(char *buf, char **start, off_t offset, int count, int *eof,