1 /*****************************************************************************
2 ** FILE NAME : ifxusb_ctl.c
3 ** PROJECT : IFX USB sub-system V3
4 ** MODULES : IFX USB sub-system Host and Device driver
7 ** AUTHOR : Chen, Howard
8 ** DESCRIPTION : Implementing the procfs and sysfs for IFX USB driver
9 *****************************************************************************/
11 /*! \file ifxusb_ctl.c
12 \ingroup IFXUSB_DRIVER_V3
13 \brief Implementing the procfs and sysfs for IFX USB driver
16 #include <linux/version.h>
17 #include "ifxusb_version.h"
20 #include <linux/proc_fs.h>
21 #include <asm/byteorder.h>
22 #include <asm/unaligned.h>
23 #include <asm/uaccess.h>
25 #include "ifxusb_plat.h"
26 #include "ifxusb_regs.h"
27 #include "ifxusb_cif.h"
37 #include <linux/device.h>
38 #include <linux/platform_device.h>
39 #include <linux/gfp.h>
43 extern char ifxusb_driver_name
[];
46 extern ifxhcd_hcd_t ifxusb_hcd_1
;
47 extern ifxhcd_hcd_t ifxusb_hcd_2
;
48 extern char ifxusb_hcd_name_1
[];
49 extern char ifxusb_hcd_name_2
[];
51 extern ifxhcd_hcd_t ifxusb_hcd
;
52 extern char ifxusb_hcd_name
[];
58 extern char ifxusb_driver_name
[];
60 extern ifxpcd_pcd_t ifxusb_pcd
;
61 extern char ifxusb_pcd_name
[];
65 //Attributes for sysfs (for 2.6 only)
67 extern struct device_attribute dev_attr_dbglevel
;
70 extern struct device_attribute dev_attr_dump_params_1
;
71 extern struct device_attribute dev_attr_dump_params_2
;
73 extern struct device_attribute dev_attr_dump_params
;
77 extern struct device_attribute dev_attr_mode_1
;
78 extern struct device_attribute dev_attr_mode_2
;
80 extern struct device_attribute dev_attr_mode
;
85 extern struct device_attribute dev_attr_buspower_1
;
86 extern struct device_attribute dev_attr_buspower_2
;
87 extern struct device_attribute dev_attr_bussuspend_1
;
88 extern struct device_attribute dev_attr_bussuspend_2
;
89 extern struct device_attribute dev_attr_busconnected_1
;
90 extern struct device_attribute dev_attr_busconnected_2
;
91 extern struct device_attribute dev_attr_connectspeed_1
;
92 extern struct device_attribute dev_attr_connectspeed_1
;
94 extern struct device_attribute dev_attr_buspower
;
95 extern struct device_attribute dev_attr_bussuspend
;
96 extern struct device_attribute dev_attr_busconnected
;
97 extern struct device_attribute dev_attr_connectspeed
;
102 extern struct device_attribute dev_attr_devspeed
;
103 extern struct device_attribute dev_attr_enumspeed
;
104 #endif //__IS_DEVICE__
106 #ifdef __ENABLE_DUMP__
108 extern struct device_attribute dev_attr_dump_reg_1
;
109 extern struct device_attribute dev_attr_dump_reg_2
;
110 extern struct device_attribute dev_attr_dump_spram_1
;
111 extern struct device_attribute dev_attr_dump_spram_2
;
113 extern struct device_attribute dev_attr_dump_host_state_1
;
114 extern struct device_attribute dev_attr_dump_host_state_2
;
118 extern struct device_attribute dev_attr_dump_reg
;
119 extern struct device_attribute dev_attr_dump_spram
;
121 extern struct device_attribute dev_attr_dump_host_state
;
125 #endif //__ENABLE_DUMP__
128 /////////////////////////////////////////////////////////////////////////////////////////////////////
129 /////////////////////////////////////////////////////////////////////////////////////////////////////
130 /////////////////////////////////////////////////////////////////////////////////////////////////////
132 static ssize_t
procfs_dbglevel_show(char *buf
, char **start
, off_t offset
, int count
, int *eof
, void *data
)
135 return sprintf( buf
, "%08X\n",h_dbg_lvl
);
137 return sprintf( buf
, "%08X\n",d_dbg_lvl
);
141 static ssize_t
procfs_dbglevel_store(struct file
*file
, const char *buffer
, unsigned long count
, void *data
)
146 if (copy_from_user(buf
, &buffer
[i
], sizeof("0xFFFFFFFF\n")+1))
148 value
= simple_strtoul(buf
, NULL
, 16);
154 //turn on and off power
158 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
159 static ssize_t
sysfs_dbglevel_show( struct device
*_dev
, struct device_attribute
*attr
,char *buf
)
161 static ssize_t
sysfs_dbglevel_show( struct device
*_dev
, char *buf
)
165 return sprintf( buf
, "%08X\n",h_dbg_lvl
);
167 return sprintf( buf
, "%08X\n",d_dbg_lvl
);
171 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
172 static ssize_t
sysfs_dbglevel_store( struct device
*_dev
, struct device_attribute
*attr
,const char *buffer
, size_t count
)
174 static ssize_t
sysfs_dbglevel_store( struct device
*_dev
, const char *buffer
, size_t count
)
180 if (copy_from_user(buf
, &buffer
[i
], sizeof("0xFFFFFFFF\n")+1))
182 value
= simple_strtoul(buf
, NULL
, 16);
188 //turn on and off power
192 DEVICE_ATTR(dbglevel
, S_IRUGO
|S_IWUSR
, sysfs_dbglevel_show
, sysfs_dbglevel_store
);
195 /////////////////////////////////////////////////////////////////////////////////////////////////////
196 /////////////////////////////////////////////////////////////////////////////////////////////////////
197 /////////////////////////////////////////////////////////////////////////////////////////////////////
199 static void ifxusb_dump_params(ifxusb_core_if_t
*_core_if
);
202 static void dump_params_1(void)
204 ifxusb_dump_params(&ifxusb_hcd_1
.core_if
);
206 static void dump_params_2(void)
208 ifxusb_dump_params(&ifxusb_hcd_2
.core_if
);
211 static ssize_t
procfs_dump_params_show_1(char *buf
, char **start
, off_t offset
, int count
, int *eof
, void *data
)
216 static ssize_t
procfs_dump_params_show_2(char *buf
, char **start
, off_t offset
, int count
, int *eof
, void *data
)
222 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
223 static ssize_t
sysfs_dump_params_show_1( struct device
*_dev
, struct device_attribute
*attr
,char *buf
)
225 static ssize_t
sysfs_dump_params_show_1( struct device
*_dev
,char *buf
)
231 DEVICE_ATTR(dump_params_1
, S_IRUGO
|S_IWUSR
, sysfs_dump_params_show_1
, NULL
);
233 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
234 static ssize_t
sysfs_dump_params_show_2( struct device
*_dev
, struct device_attribute
*attr
,char *buf
)
236 static ssize_t
sysfs_dump_params_show_2( struct device
*_dev
,char *buf
)
243 DEVICE_ATTR(dump_params_2
, S_IRUGO
|S_IWUSR
, sysfs_dump_params_show_2
, NULL
);
245 static void dump_params(void)
248 ifxusb_dump_params(&ifxusb_hcd
.core_if
);
250 ifxusb_dump_params(&ifxusb_pcd
.core_if
);
254 static ssize_t
procfs_dump_params_show(char *buf
, char **start
, off_t offset
, int count
, int *eof
, void *data
)
260 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
261 static ssize_t
sysfs_dump_params_show( struct device
*_dev
, struct device_attribute
*attr
,char *buf
)
263 static ssize_t
sysfs_dump_params_show( struct device
*_dev
,char *buf
)
269 DEVICE_ATTR(dump_params
, S_IRUGO
|S_IWUSR
, sysfs_dump_params_show
, NULL
);
272 /////////////////////////////////////////////////////////////////////////////////////////////////////
273 /////////////////////////////////////////////////////////////////////////////////////////////////////
274 /////////////////////////////////////////////////////////////////////////////////////////////////////
277 static ssize_t
mode_show_1(char *buf
)
279 if((ifxusb_rreg(&ifxusb_hcd_1
.core_if
.core_global_regs
->gintsts
) & 0x1) == 1)
280 return sprintf( buf
, "HOST\n" );
282 return sprintf( buf
, "DEVICE(INCORRECT!)\n" );
285 static ssize_t
mode_show_2(char *buf
)
287 if((ifxusb_rreg(&ifxusb_hcd_2
.core_if
.core_global_regs
->gintsts
) & 0x1) == 1)
288 return sprintf( buf
, "HOST\n" );
290 return sprintf( buf
, "DEVICE(INCORRECT!)\n" );
293 static ssize_t
procfs_mode_show_1(char *buf
, char **start
, off_t offset
, int count
, int *eof
, void *data
)
295 return mode_show_1(buf
);
297 static ssize_t
procfs_mode_show_2(char *buf
, char **start
, off_t offset
, int count
, int *eof
, void *data
)
299 return mode_show_2(buf
);
302 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
303 static ssize_t
sysfs_mode_show_1( struct device
*_dev
, struct device_attribute
*attr
,char *buf
)
305 static ssize_t
sysfs_mode_show_1( struct device
*_dev
,char *buf
)
308 return mode_show_1(buf
);
311 DEVICE_ATTR(mode_1
, S_IRUGO
|S_IWUSR
, sysfs_mode_show_1
, 0);
313 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
314 static ssize_t
sysfs_mode_show_2( struct device
*_dev
, struct device_attribute
*attr
,char *buf
)
316 static ssize_t
sysfs_mode_show_2( struct device
*_dev
,char *buf
)
319 return mode_show_2(buf
);
321 DEVICE_ATTR(mode_2
, S_IRUGO
|S_IWUSR
, sysfs_mode_show_2
, NULL
);
323 static ssize_t
mode_show(char *buf
)
326 if((ifxusb_rreg(&ifxusb_hcd
.core_if
.core_global_regs
->gintsts
) & 0x1) == 1)
327 return sprintf( buf
, "HOST\n" );
329 return sprintf( buf
, "DEVICE(INCORRECT!)\n" );
331 if((ifxusb_rreg(&ifxusb_pcd
.core_if
.core_global_regs
->gintsts
) & 0x1) != 1)
332 return sprintf( buf
, "DEVICE\n" );
334 return sprintf( buf
, "HOST(INCORRECT!)\n" );
337 static ssize_t
procfs_mode_show(char *buf
, char **start
, off_t offset
, int count
, int *eof
, void *data
)
339 return mode_show(buf
);
341 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
342 static ssize_t
sysfs_mode_show( struct device
*_dev
, struct device_attribute
*attr
,char *buf
)
344 static ssize_t
sysfs_mode_show( struct device
*_dev
, char *buf
)
347 return mode_show(buf
);
349 DEVICE_ATTR(mode
, S_IRUGO
|S_IWUSR
, sysfs_mode_show
, NULL
);
352 /////////////////////////////////////////////////////////////////////////////////////////////////////
353 /////////////////////////////////////////////////////////////////////////////////////////////////////
354 /////////////////////////////////////////////////////////////////////////////////////////////////////
358 static ssize_t
buspower_show_1(char *buf
)
360 if(ifxusb_vbus (&ifxusb_hcd_1
.core_if
)==1) return sprintf( buf
, "1\n" );
361 if(ifxusb_vbus (&ifxusb_hcd_1
.core_if
)==0) return sprintf( buf
, "0\n" );
362 return sprintf( buf
, "UNKNOWN\n" );
364 static void buspower_store_1(uint32_t value
)
366 if (value
==1) ifxusb_vbus_on (&ifxusb_hcd_1
.core_if
);
367 else if(value
==0) ifxusb_vbus_off(&ifxusb_hcd_1
.core_if
);
369 static ssize_t
buspower_show_2(char *buf
)
371 if(ifxusb_vbus (&ifxusb_hcd_2
.core_if
)==1) return sprintf( buf
, "1\n" );
372 if(ifxusb_vbus (&ifxusb_hcd_2
.core_if
)==0) return sprintf( buf
, "0\n" );
373 return sprintf( buf
, "UNKNOWN\n" );
375 static void buspower_store_2(uint32_t value
)
377 if (value
==1) ifxusb_vbus_on (&ifxusb_hcd_2
.core_if
);
378 else if(value
==0) ifxusb_vbus_off(&ifxusb_hcd_2
.core_if
);
380 static ssize_t
procfs_buspower_show_1(char *buf
, char **start
, off_t offset
, int count
, int *eof
, void *data
)
382 return buspower_show_1(buf
);
384 static ssize_t
procfs_buspower_store_1(struct file
*file
, const char *buffer
, unsigned long count
, void *data
)
389 if (copy_from_user(buf
, &buffer
[i
], sizeof("0xFFFFFFFF\n")+1))
391 value
= simple_strtoul(buf
, NULL
, 16);
392 buspower_store_1(value
);
395 static ssize_t
procfs_buspower_show_2(char *buf
, char **start
, off_t offset
, int count
, int *eof
, void *data
)
397 return buspower_show_2(buf
);
399 static ssize_t
procfs_buspower_store_2(struct file
*file
, const char *buffer
, unsigned long count
, void *data
)
404 if (copy_from_user(buf
, &buffer
[i
], sizeof("0xFFFFFFFF\n")+1))
406 value
= simple_strtoul(buf
, NULL
, 16);
407 buspower_store_2(value
);
411 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
412 static ssize_t
sysfs_buspower_show_1( struct device
*_dev
, struct device_attribute
*attr
,char *buf
)
414 static ssize_t
sysfs_buspower_show_1( struct device
*_dev
,char *buf
)
417 return buspower_show_1(buf
);
419 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
420 static ssize_t
sysfs_buspower_store_1( struct device
*_dev
, struct device_attribute
*attr
,const char *buffer
, size_t count
)
422 static ssize_t
sysfs_buspower_store_1( struct device
*_dev
, const char *buffer
, size_t count
)
428 if (copy_from_user(buf
, &buffer
[i
], sizeof("0xFFFFFFFF\n")+1))
430 value
= simple_strtoul(buf
, NULL
, 16);
431 buspower_store_1(value
);
434 DEVICE_ATTR(buspower_1
, S_IRUGO
|S_IWUSR
, sysfs_buspower_show_1
, sysfs_buspower_store_1
);
436 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
437 static ssize_t
sysfs_buspower_show_2( struct device
*_dev
, struct device_attribute
*attr
,char *buf
)
439 static ssize_t
sysfs_buspower_show_2( struct device
*_dev
,char *buf
)
442 return buspower_show_2(buf
);
444 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
445 static ssize_t
sysfs_buspower_store_2( struct device
*_dev
, struct device_attribute
*attr
,const char *buffer
, size_t count
)
447 static ssize_t
sysfs_buspower_store_2( struct device
*_dev
, const char *buffer
, size_t count
)
453 if (copy_from_user(buf
, &buffer
[i
], sizeof("0xFFFFFFFF\n")+1))
455 value
= simple_strtoul(buf
, NULL
, 16);
456 buspower_store_2(value
);
459 DEVICE_ATTR(buspower_2
, S_IRUGO
|S_IWUSR
, sysfs_buspower_show_2
, sysfs_buspower_store_2
);
461 static ssize_t
buspower_show(char *buf
)
463 if(ifxusb_vbus (&ifxusb_hcd
.core_if
)==1) return sprintf( buf
, "1\n" );
464 if(ifxusb_vbus (&ifxusb_hcd
.core_if
)==0) return sprintf( buf
, "0\n" );
465 return sprintf( buf
, "UNKNOWN\n" );
467 static void buspower_store(uint32_t value
)
469 if (value
==1) ifxusb_vbus_on (&ifxusb_hcd
.core_if
);
470 else if(value
==0) ifxusb_vbus_off(&ifxusb_hcd
.core_if
);
472 static ssize_t
procfs_buspower_show(char *buf
, char **start
, off_t offset
, int count
, int *eof
, void *data
)
474 return buspower_show(buf
);
476 static ssize_t
procfs_buspower_store(struct file
*file
, const char *buffer
, unsigned long count
, void *data
)
481 if (copy_from_user(buf
, &buffer
[i
], sizeof("0xFFFFFFFF\n")+1))
483 value
= simple_strtoul(buf
, NULL
, 16);
484 buspower_store(value
);
487 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
488 static ssize_t
sysfs_buspower_show( struct device
*_dev
, struct device_attribute
*attr
,char *buf
)
490 static ssize_t
sysfs_buspower_show( struct device
*_dev
, char *buf
)
493 return buspower_show(buf
);
495 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
496 static ssize_t
sysfs_buspower_store( struct device
*_dev
, struct device_attribute
*attr
,const char *buffer
, size_t count
)
498 static ssize_t
sysfs_buspower_store( struct device
*_dev
, const char *buffer
, size_t count
)
504 if (copy_from_user(buf
, &buffer
[i
], sizeof("0xFFFFFFFF\n")+1))
506 value
= simple_strtoul(buf
, NULL
, 16);
507 buspower_store(value
);
510 DEVICE_ATTR(buspower
, S_IRUGO
|S_IWUSR
, sysfs_buspower_show
, sysfs_buspower_store
);
513 /////////////////////////////////////////////////////////////////////////////////////////////////////
514 /////////////////////////////////////////////////////////////////////////////////////////////////////
515 /////////////////////////////////////////////////////////////////////////////////////////////////////
519 static ssize_t
bussuspend_show_1(char *buf
)
522 val
.d32
= ifxusb_rreg(ifxusb_hcd_1
.core_if
.hprt0
);
523 return sprintf (buf
, "Bus Suspend = 0x%x\n", val
.b
.prtsusp
);
525 static ssize_t
bussuspend_show_2(char *buf
)
528 val
.d32
= ifxusb_rreg(ifxusb_hcd_2
.core_if
.hprt0
);
529 return sprintf (buf
, "Bus Suspend = 0x%x\n", val
.b
.prtsusp
);
532 static ssize_t
procfs_bussuspend_show_1(char *buf
, char **start
, off_t offset
, int count
, int *eof
, void *data
)
534 return bussuspend_show_1(buf
);
536 static ssize_t
procfs_bussuspend_show_2(char *buf
, char **start
, off_t offset
, int count
, int *eof
, void *data
)
538 return bussuspend_show_2(buf
);
540 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
541 static ssize_t
sysfs_bussuspend_show_1( struct device
*_dev
, struct device_attribute
*attr
,char *buf
)
543 static ssize_t
sysfs_bussuspend_show_1( struct device
*_dev
,char *buf
)
546 return bussuspend_show_1(buf
);
548 DEVICE_ATTR(bussuspend_1
, S_IRUGO
|S_IWUSR
, sysfs_bussuspend_show_1
, 0);
549 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
550 static ssize_t
sysfs_bussuspend_show_2( struct device
*_dev
, struct device_attribute
*attr
,char *buf
)
552 static ssize_t
sysfs_bussuspend_show_2( struct device
*_dev
,char *buf
)
555 return bussuspend_show_2(buf
);
557 DEVICE_ATTR(bussuspend_2
, S_IRUGO
|S_IWUSR
, sysfs_bussuspend_show_2
, 0);
559 static ssize_t
bussuspend_show(char *buf
)
562 val
.d32
= ifxusb_rreg(ifxusb_hcd
.core_if
.hprt0
);
563 return sprintf (buf
, "Bus Suspend = 0x%x\n", val
.b
.prtsusp
);
565 static ssize_t
procfs_bussuspend_show(char *buf
, char **start
, off_t offset
, int count
, int *eof
, void *data
)
567 return bussuspend_show(buf
);
570 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
571 static ssize_t
sysfs_bussuspend_show( struct device
*_dev
, struct device_attribute
*attr
,char *buf
)
573 static ssize_t
sysfs_bussuspend_show( struct device
*_dev
, char *buf
)
576 return bussuspend_show(buf
);
578 DEVICE_ATTR(bussuspend
, S_IRUGO
|S_IWUSR
, sysfs_bussuspend_show
, 0);
581 /////////////////////////////////////////////////////////////////////////////////////////////////////
582 /////////////////////////////////////////////////////////////////////////////////////////////////////
583 /////////////////////////////////////////////////////////////////////////////////////////////////////
586 static ssize_t
busconnected_show_1(char *buf
)
589 val
.d32
= ifxusb_rreg(ifxusb_hcd_1
.core_if
.hprt0
);
590 return sprintf (buf
, "Bus Connected = 0x%x\n", val
.b
.prtconnsts
);
592 static ssize_t
busconnected_show_2(char *buf
)
595 val
.d32
= ifxusb_rreg(ifxusb_hcd_2
.core_if
.hprt0
);
596 return sprintf (buf
, "Bus Connected = 0x%x\n", val
.b
.prtconnsts
);
599 static ssize_t
procfs_busconnected_show_1(char *buf
, char **start
, off_t offset
, int count
, int *eof
, void *data
)
601 return busconnected_show_1(buf
);
603 static ssize_t
procfs_busconnected_show_2(char *buf
, char **start
, off_t offset
, int count
, int *eof
, void *data
)
605 return busconnected_show_2(buf
);
607 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
608 static ssize_t
sysfs_busconnected_show_1( struct device
*_dev
, struct device_attribute
*attr
,char *buf
)
610 static ssize_t
sysfs_busconnected_show_1( struct device
*_dev
,char *buf
)
613 return busconnected_show_1(buf
);
615 DEVICE_ATTR(busconnected_1
, S_IRUGO
|S_IWUSR
, sysfs_busconnected_show_1
, 0);
616 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
617 static ssize_t
sysfs_busconnected_show_2( struct device
*_dev
, struct device_attribute
*attr
,char *buf
)
619 static ssize_t
sysfs_busconnected_show_2( struct device
*_dev
,char *buf
)
622 return busconnected_show_2(buf
);
624 DEVICE_ATTR(busconnected_2
, S_IRUGO
|S_IWUSR
, sysfs_busconnected_show_2
, 0);
626 static ssize_t
busconnected_show(char *buf
)
629 val
.d32
= ifxusb_rreg(ifxusb_hcd
.core_if
.hprt0
);
630 return sprintf (buf
, "Bus Connected = 0x%x\n", val
.b
.prtconnsts
);
632 static ssize_t
procfs_busconnected_show(char *buf
, char **start
, off_t offset
, int count
, int *eof
, void *data
)
634 return busconnected_show(buf
);
637 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
638 static ssize_t
sysfs_busconnected_show( struct device
*_dev
, struct device_attribute
*attr
,char *buf
)
640 static ssize_t
sysfs_busconnected_show( struct device
*_dev
, char *buf
)
643 return busconnected_show(buf
);
645 DEVICE_ATTR(busconnected
, S_IRUGO
|S_IWUSR
, sysfs_busconnected_show
, 0);
648 /////////////////////////////////////////////////////////////////////////////////////////////////////
649 /////////////////////////////////////////////////////////////////////////////////////////////////////
650 /////////////////////////////////////////////////////////////////////////////////////////////////////
653 static ssize_t
connectspeed_show_1(char *buf
)
656 val
.d32
= ifxusb_rreg(ifxusb_hcd_1
.core_if
.hprt0
);
657 if( val
.b
.prtspd
==0) return sprintf (buf
, "Bus Speed = High (%d)\n", val
.b
.prtspd
);
658 if( val
.b
.prtspd
==1) return sprintf (buf
, "Bus Speed = Full (%d)\n", val
.b
.prtspd
);
659 if( val
.b
.prtspd
==2) return sprintf (buf
, "Bus Speed = Low (%d)\n", val
.b
.prtspd
);
660 return sprintf (buf
, "Bus Speed = Unknown (%d)\n", val
.b
.prtspd
);
662 static ssize_t
connectspeed_show_2(char *buf
)
665 val
.d32
= ifxusb_rreg(ifxusb_hcd_2
.core_if
.hprt0
);
666 if( val
.b
.prtspd
==0) return sprintf (buf
, "Bus Speed = High (%d)\n", val
.b
.prtspd
);
667 if( val
.b
.prtspd
==1) return sprintf (buf
, "Bus Speed = Full (%d)\n", val
.b
.prtspd
);
668 if( val
.b
.prtspd
==2) return sprintf (buf
, "Bus Speed = Low (%d)\n", val
.b
.prtspd
);
669 return sprintf (buf
, "Bus Speed = Unknown (%d)\n", val
.b
.prtspd
);
672 static ssize_t
procfs_connectspeed_show_1(char *buf
, char **start
, off_t offset
, int count
, int *eof
, void *data
)
674 return connectspeed_show_1(buf
);
676 static ssize_t
procfs_connectspeed_show_2(char *buf
, char **start
, off_t offset
, int count
, int *eof
, void *data
)
678 return connectspeed_show_2(buf
);
680 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
681 static ssize_t
sysfs_connectspeed_show_1( struct device
*_dev
, struct device_attribute
*attr
,char *buf
)
683 static ssize_t
sysfs_connectspeed_show_1( struct device
*_dev
,char *buf
)
686 return connectspeed_show_1(buf
);
688 DEVICE_ATTR(connectspeed_1
, S_IRUGO
|S_IWUSR
, sysfs_connectspeed_show_1
, 0);
689 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
690 static ssize_t
sysfs_connectspeed_show_2( struct device
*_dev
, struct device_attribute
*attr
,char *buf
)
692 static ssize_t
sysfs_connectspeed_show_2( struct device
*_dev
,char *buf
)
695 return connectspeed_show_2(buf
);
697 DEVICE_ATTR(connectspeed_2
, S_IRUGO
|S_IWUSR
, sysfs_connectspeed_show_2
, 0);
699 static ssize_t
connectspeed_show(char *buf
)
702 val
.d32
= ifxusb_rreg(ifxusb_hcd
.core_if
.hprt0
);
703 if( val
.b
.prtspd
==0) return sprintf (buf
, "Bus Speed = High (%d)\n", val
.b
.prtspd
);
704 if( val
.b
.prtspd
==1) return sprintf (buf
, "Bus Speed = Full (%d)\n", val
.b
.prtspd
);
705 if( val
.b
.prtspd
==2) return sprintf (buf
, "Bus Speed = Low (%d)\n", val
.b
.prtspd
);
706 return sprintf (buf
, "Bus Speed = Unknown (%d)\n", val
.b
.prtspd
);
709 static ssize_t
procfs_connectspeed_show(char *buf
, char **start
, off_t offset
, int count
, int *eof
, void *data
)
711 return connectspeed_show(buf
);
714 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
715 static ssize_t
sysfs_connectspeed_show( struct device
*_dev
, struct device_attribute
*attr
,char *buf
)
717 static ssize_t
sysfs_connectspeed_show( struct device
*_dev
, char *buf
)
720 return connectspeed_show(buf
);
722 DEVICE_ATTR(connectspeed
, S_IRUGO
|S_IWUSR
, sysfs_connectspeed_show
, 0);
724 /////////////////////////////////////////////////////////////////////////////////////////////////////
725 /////////////////////////////////////////////////////////////////////////////////////////////////////
726 /////////////////////////////////////////////////////////////////////////////////////////////////////
731 /////////////////////////////////////////////////////////////////////////////////////////////////////
732 /////////////////////////////////////////////////////////////////////////////////////////////////////
733 /////////////////////////////////////////////////////////////////////////////////////////////////////
734 static ssize_t
devspeed_show(char *buf
)
737 val
.d32
= ifxusb_rreg(&ifxusb_pcd
.core_if
.dev_global_regs
->dcfg
);
738 if( val
.b
.devspd
==0) return sprintf (buf
, "Dev Speed = High (%d)\n", val
.b
.devspd
);
739 if( val
.b
.devspd
==1) return sprintf (buf
, "Dev Speed = Full (%d)\n", val
.b
.devspd
);
740 if( val
.b
.devspd
==3) return sprintf (buf
, "Dev Speed = Full (%d)\n", val
.b
.devspd
);
741 return sprintf (buf
, "Dev Speed = Unknown (%d)\n", val
.b
.devspd
);
744 static ssize_t
procfs_devspeed_show(char *buf
, char **start
, off_t offset
, int count
, int *eof
, void *data
)
746 return devspeed_show(buf
);
749 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
750 static ssize_t
sysfs_devspeed_show( struct device
*_dev
, struct device_attribute
*attr
,char *buf
)
752 static ssize_t
sysfs_devspeed_show( struct device
*_dev
, char *buf
)
755 return devspeed_show(buf
);
757 DEVICE_ATTR(devspeed
, S_IRUGO
|S_IWUSR
, sysfs_devspeed_show
, 0);
759 static ssize_t
enumspeed_show(char *buf
)
762 val
.d32
= ifxusb_rreg(&ifxusb_pcd
.core_if
.dev_global_regs
->dsts
);
763 if( val
.b
.enumspd
==0) return sprintf (buf
, "Enum Speed = High (%d)\n", val
.b
.enumspd
);
764 if( val
.b
.enumspd
==1) return sprintf (buf
, "Enum Speed = Full (%d)\n", val
.b
.enumspd
);
765 if( val
.b
.enumspd
==2) return sprintf (buf
, "Enum Speed = Low (%d)\n", val
.b
.enumspd
);
766 return sprintf (buf
, "Enum Speed = invalid(%d)\n", val
.b
.enumspd
);
769 static ssize_t
procfs_enumspeed_show(char *buf
, char **start
, off_t offset
, int count
, int *eof
, void *data
)
771 return enumspeed_show(buf
);
774 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
775 static ssize_t
sysfs_enumspeed_show( struct device
*_dev
, struct device_attribute
*attr
,char *buf
)
777 static ssize_t
sysfs_enumspeed_show( struct device
*_dev
, char *buf
)
780 return enumspeed_show(buf
);
782 DEVICE_ATTR(enumspeed
, S_IRUGO
|S_IWUSR
, sysfs_enumspeed_show
, 0);
783 /////////////////////////////////////////////////////////////////////////////////////////////////////
784 /////////////////////////////////////////////////////////////////////////////////////////////////////
785 /////////////////////////////////////////////////////////////////////////////////////////////////////
789 //////////////////////////////////////////////////////////////////////////////////
790 #ifdef __ENABLE_DUMP__
793 static void dump_reg_1(void)
795 ifxusb_dump_registers(&ifxusb_hcd_1
.core_if
);
797 static void dump_reg_2(void)
799 ifxusb_dump_registers(&ifxusb_hcd_2
.core_if
);
802 static ssize_t
procfs_dump_reg_show_1(char *buf
, char **start
, off_t offset
, int count
, int *eof
, void *data
)
807 static ssize_t
procfs_dump_reg_show_2(char *buf
, char **start
, off_t offset
, int count
, int *eof
, void *data
)
812 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
813 static ssize_t
sysfs_dump_reg_show_1( struct device
*_dev
, struct device_attribute
*attr
,char *buf
)
815 static ssize_t
sysfs_dump_reg_show_1( struct device
*_dev
,char *buf
)
821 DEVICE_ATTR(dump_reg_1
, S_IRUGO
|S_IWUSR
, sysfs_dump_reg_show_1
, 0);
822 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
823 static ssize_t
sysfs_dump_reg_show_2( struct device
*_dev
, struct device_attribute
*attr
,char *buf
)
825 static ssize_t
sysfs_dump_reg_show_2( struct device
*_dev
,char *buf
)
831 DEVICE_ATTR(dump_reg_2
, S_IRUGO
|S_IWUSR
, sysfs_dump_reg_show_2
, 0);
833 static void dump_reg(void)
836 ifxusb_dump_registers(&ifxusb_hcd
.core_if
);
839 ifxusb_dump_registers(&ifxusb_pcd
.core_if
);
842 static ssize_t
procfs_dump_reg_show(char *buf
, char **start
, off_t offset
, int count
, int *eof
, void *data
)
847 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
848 static ssize_t
sysfs_dump_reg_show( struct device
*_dev
, struct device_attribute
*attr
,char *buf
)
850 static ssize_t
sysfs_dump_reg_show( struct device
*_dev
,char *buf
)
856 DEVICE_ATTR(dump_reg
, S_IRUGO
|S_IWUSR
, sysfs_dump_reg_show
, 0);
860 /////////////////////////////////////////////////////////////////////////////////////////////////////
861 /////////////////////////////////////////////////////////////////////////////////////////////////////
862 /////////////////////////////////////////////////////////////////////////////////////////////////////
865 static void dump_spram_1(void)
867 ifxusb_dump_spram(&ifxusb_hcd_1
.core_if
);
869 static void dump_spram_2(void)
871 ifxusb_dump_spram(&ifxusb_hcd_2
.core_if
);
874 static ssize_t
procfs_dump_spram_show_1(char *buf
, char **start
, off_t offset
, int count
, int *eof
, void *data
)
879 static ssize_t
procfs_dump_spram_show_2(char *buf
, char **start
, off_t offset
, int count
, int *eof
, void *data
)
884 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
885 static ssize_t
sysfs_dump_spram_show_1( struct device
*_dev
, struct device_attribute
*attr
,char *buf
)
887 static ssize_t
sysfs_dump_spram_show_1( struct device
*_dev
,char *buf
)
893 DEVICE_ATTR(dump_spram_1
, S_IRUGO
|S_IWUSR
, sysfs_dump_spram_show_1
, 0);
895 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
896 static ssize_t
sysfs_dump_spram_show_2( struct device
*_dev
, struct device_attribute
*attr
,char *buf
)
898 static ssize_t
sysfs_dump_spram_show_2( struct device
*_dev
,char *buf
)
904 DEVICE_ATTR(dump_spram_2
, S_IRUGO
|S_IWUSR
, sysfs_dump_spram_show_2
, 0);
906 static void dump_spram(void)
909 ifxusb_dump_spram(&ifxusb_hcd
.core_if
);
912 ifxusb_dump_spram(&ifxusb_pcd
.core_if
);
915 static ssize_t
procfs_dump_spram_show(char *buf
, char **start
, off_t offset
, int count
, int *eof
, void *data
)
920 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
921 static ssize_t
sysfs_dump_spram_show( struct device
*_dev
, struct device_attribute
*attr
,char *buf
)
923 static ssize_t
sysfs_dump_spram_show( struct device
*_dev
,char *buf
)
929 DEVICE_ATTR(dump_spram
, S_IRUGO
|S_IWUSR
, sysfs_dump_spram_show
, 0);
931 /////////////////////////////////////////////////////////////////////////////////////////////////////
932 /////////////////////////////////////////////////////////////////////////////////////////////////////
933 /////////////////////////////////////////////////////////////////////////////////////////////////////
937 static ssize_t
procfs_dump_host_state_show_1(char *buf
, char **start
, off_t offset
, int count
, int *eof
, void *data
)
939 ifxhcd_dump_state(&ifxusb_hcd_1
);
942 static ssize_t
procfs_dump_host_state_show_2(char *buf
, char **start
, off_t offset
, int count
, int *eof
, void *data
)
944 ifxhcd_dump_state(&ifxusb_hcd_2
);
947 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
948 static ssize_t
sysfs_dump_host_state_show_1( struct device
*_dev
, struct device_attribute
*attr
,char *buf
)
950 static ssize_t
sysfs_dump_host_state_show_1( struct device
*_dev
,char *buf
)
953 ifxhcd_dump_state(&ifxusb_hcd_1
);
956 DEVICE_ATTR(dump_host_state_1
, S_IRUGO
|S_IWUSR
, sysfs_dump_host_state_show_1
, 0);
957 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
958 static ssize_t
sysfs_dump_host_state_show_2( struct device
*_dev
, struct device_attribute
*attr
,char *buf
)
960 static ssize_t
sysfs_dump_host_state_show_2( struct device
*_dev
,char *buf
)
963 ifxhcd_dump_state(&ifxusb_hcd_2
);
966 DEVICE_ATTR(dump_host_state_2
, S_IRUGO
|S_IWUSR
, sysfs_dump_host_state_show_2
, 0);
968 static ssize_t
procfs_dump_host_state_show(char *buf
, char **start
, off_t offset
, int count
, int *eof
, void *data
)
970 ifxhcd_dump_state(&ifxusb_hcd
);
973 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
974 static ssize_t
sysfs_dump_host_state_show( struct device
*_dev
, struct device_attribute
*attr
,char *buf
)
976 static ssize_t
sysfs_dump_host_state_show( struct device
*_dev
,char *buf
)
979 ifxhcd_dump_state(&ifxusb_hcd
);
982 DEVICE_ATTR(dump_host_state
, S_IRUGO
|S_IWUSR
, sysfs_dump_host_state_show
, 0);
985 /////////////////////////////////////////////////////////////////////////////////////////////////////
986 /////////////////////////////////////////////////////////////////////////////////////////////////////
987 /////////////////////////////////////////////////////////////////////////////////////////////////////
991 #endif //__ENABLE_DUMP__
993 //////////////////////////////////////////////////////////////////////////////////
995 static int ifx_proc_addproc(char *funcname
, read_proc_t
*hookfuncr
, write_proc_t
*hookfuncw
);
996 static void ifx_proc_delproc(char *funcname
);
998 //////////////////////////////////////////////////////////////////////////////////
1001 \brief This function create the sysfs and procfs entries
1002 \param[in] _dev Pointer of device structure, if applied
1004 void ifxusb_attr_create (void *_dev
)
1008 struct device
*dev
= (struct device
*) _dev
;
1010 IFX_DEBUGPL(DBG_ENTRY
, "%s() %d\n", __func__
, __LINE__
);
1011 error
= ifx_proc_addproc("dbglevel", procfs_dbglevel_show
, procfs_dbglevel_store
);
1012 error
= device_create_file(dev
, &dev_attr_dbglevel
);
1015 error
= ifx_proc_addproc("dump_params_1", procfs_dump_params_show_1
, NULL
);
1016 error
= ifx_proc_addproc("dump_params_2", procfs_dump_params_show_2
, NULL
);
1017 error
= device_create_file(dev
, &dev_attr_dump_params_1
);
1018 error
= device_create_file(dev
, &dev_attr_dump_params_2
);
1020 error
= ifx_proc_addproc("dump_params", procfs_dump_params_show
, NULL
);
1021 error
= device_create_file(dev
, &dev_attr_dump_params
);
1025 error
= ifx_proc_addproc("mode_1", procfs_mode_show_1
, NULL
);
1026 error
= ifx_proc_addproc("mode_2", procfs_mode_show_2
, NULL
);
1027 error
= device_create_file(dev
, &dev_attr_mode_1
);
1028 error
= device_create_file(dev
, &dev_attr_mode_2
);
1030 error
= ifx_proc_addproc("mode", procfs_mode_show
, NULL
);
1031 error
= device_create_file(dev
, &dev_attr_mode
);
1036 error
= ifx_proc_addproc("buspower_1", procfs_buspower_show_1
, procfs_buspower_store_1
);
1037 error
= ifx_proc_addproc("buspower_2", procfs_buspower_show_2
, procfs_buspower_store_2
);
1038 error
= device_create_file(dev
, &dev_attr_buspower_1
);
1039 error
= device_create_file(dev
, &dev_attr_buspower_2
);
1041 error
= ifx_proc_addproc("buspower", procfs_buspower_show
, procfs_buspower_store
);
1042 error
= device_create_file(dev
, &dev_attr_buspower
);
1046 error
= ifx_proc_addproc("bussuspend_1", procfs_bussuspend_show_1
, NULL
);
1047 error
= ifx_proc_addproc("bussuspend_2", procfs_bussuspend_show_2
, NULL
);
1048 error
= device_create_file(dev
, &dev_attr_bussuspend_1
);
1049 error
= device_create_file(dev
, &dev_attr_bussuspend_2
);
1051 error
= ifx_proc_addproc("bussuspend", procfs_bussuspend_show
, NULL
);
1052 error
= device_create_file(dev
, &dev_attr_bussuspend
);
1056 error
= ifx_proc_addproc("busconnected_1", procfs_busconnected_show_1
, NULL
);
1057 error
= ifx_proc_addproc("busconnected_2", procfs_busconnected_show_2
, NULL
);
1058 error
= device_create_file(dev
, &dev_attr_busconnected_1
);
1059 error
= device_create_file(dev
, &dev_attr_busconnected_2
);
1061 error
= ifx_proc_addproc("busconnected", procfs_busconnected_show
, NULL
);
1062 error
= device_create_file(dev
, &dev_attr_busconnected
);
1066 error
= ifx_proc_addproc("connectspeed_1", procfs_connectspeed_show_1
, NULL
);
1067 error
= ifx_proc_addproc("connectspeed_2", procfs_connectspeed_show_2
, NULL
);
1068 error
= device_create_file(dev
, &dev_attr_connectspeed_1
);
1069 error
= device_create_file(dev
, &dev_attr_connectspeed_2
);
1071 error
= ifx_proc_addproc("connectspeed", procfs_connectspeed_show
, NULL
);
1072 error
= device_create_file(dev
, &dev_attr_connectspeed
);
1076 #ifdef __IS_DEVICE__
1077 error
= ifx_proc_addproc("devspeed", procfs_devspeed_show
, NULL
);
1078 error
= device_create_file(dev
, &dev_attr_devspeed
);
1079 error
= ifx_proc_addproc("enumspeed", procfs_enumspeed_show
, NULL
);
1080 error
= device_create_file(dev
, &dev_attr_enumspeed
);
1083 //////////////////////////////////////////////////////
1084 #ifdef __ENABLE_DUMP__
1086 error
= ifx_proc_addproc("dump_reg_1", procfs_dump_reg_show_1
, NULL
);
1087 error
= ifx_proc_addproc("dump_reg_2", procfs_dump_reg_show_2
, NULL
);
1088 error
= device_create_file(dev
, &dev_attr_dump_reg_1
);
1089 error
= device_create_file(dev
, &dev_attr_dump_reg_2
);
1091 error
= ifx_proc_addproc("dump_reg", procfs_dump_reg_show
, NULL
);
1092 error
= device_create_file(dev
, &dev_attr_dump_reg
);
1096 error
= ifx_proc_addproc("dump_spram_1", procfs_dump_spram_show_1
, NULL
);
1097 error
= ifx_proc_addproc("dump_spram_2", procfs_dump_spram_show_2
, NULL
);
1098 error
= device_create_file(dev
, &dev_attr_dump_spram_1
);
1099 error
= device_create_file(dev
, &dev_attr_dump_spram_2
);
1101 error
= ifx_proc_addproc("dump_spram", procfs_dump_spram_show
, NULL
);
1102 error
= device_create_file(dev
, &dev_attr_dump_spram
);
1107 error
= ifx_proc_addproc("dump_host_state_1", procfs_dump_host_state_show_1
, NULL
);
1108 error
= ifx_proc_addproc("dump_host_state_2", procfs_dump_host_state_show_2
, NULL
);
1109 error
= device_create_file(dev
, &dev_attr_dump_host_state_1
);
1110 error
= device_create_file(dev
, &dev_attr_dump_host_state_2
);
1112 error
= ifx_proc_addproc("dump_host_state", procfs_dump_host_state_show
, NULL
);
1113 error
= device_create_file(dev
, &dev_attr_dump_host_state
);
1116 #endif //__ENABLE_DUMP__
1117 //////////////////////////////////////////////////////
1122 \brief This function remove the sysfs and procfs entries
1123 \param[in] _dev Pointer of device structure, if applied
1125 void ifxusb_attr_remove (void *_dev
)
1127 struct device
*dev
= (struct device
*) _dev
;
1129 IFX_DEBUGPL(DBG_ENTRY
, "%s() %d\n", __func__
, __LINE__
);
1130 ifx_proc_delproc("dbglevel");
1131 device_remove_file(dev
, &dev_attr_dbglevel
);
1134 ifx_proc_delproc("dump_params_1");
1135 ifx_proc_delproc("dump_params_2");
1136 device_remove_file(dev
, &dev_attr_dump_params_1
);
1137 device_remove_file(dev
, &dev_attr_dump_params_2
);
1139 ifx_proc_delproc("dump_params");
1140 device_remove_file(dev
, &dev_attr_dump_params
);
1144 ifx_proc_delproc("mode_1");
1145 ifx_proc_delproc("mode_2");
1146 device_remove_file(dev
, &dev_attr_mode_1
);
1147 device_remove_file(dev
, &dev_attr_mode_2
);
1149 ifx_proc_delproc("mode");
1150 device_remove_file(dev
, &dev_attr_mode
);
1155 ifx_proc_delproc("buspower_1");
1156 ifx_proc_delproc("buspower_2");
1157 device_remove_file(dev
, &dev_attr_buspower_1
);
1158 device_remove_file(dev
, &dev_attr_buspower_2
);
1160 ifx_proc_delproc("buspower");
1161 device_remove_file(dev
, &dev_attr_buspower
);
1165 ifx_proc_delproc("bussuspend_1");
1166 ifx_proc_delproc("bussuspend_2");
1167 device_remove_file(dev
, &dev_attr_bussuspend_1
);
1168 device_remove_file(dev
, &dev_attr_bussuspend_2
);
1170 ifx_proc_delproc("bussuspend");
1171 device_remove_file(dev
, &dev_attr_bussuspend
);
1175 ifx_proc_delproc("busconnected_1");
1176 ifx_proc_delproc("busconnected_2");
1177 device_remove_file(dev
, &dev_attr_busconnected_1
);
1178 device_remove_file(dev
, &dev_attr_busconnected_2
);
1180 ifx_proc_delproc("busconnected");
1181 device_remove_file(dev
, &dev_attr_busconnected
);
1185 ifx_proc_delproc("connectspeed_1");
1186 ifx_proc_delproc("connectspeed_2");
1187 device_remove_file(dev
, &dev_attr_connectspeed_1
);
1188 device_remove_file(dev
, &dev_attr_connectspeed_2
);
1190 ifx_proc_delproc("connectspeed");
1191 device_remove_file(dev
, &dev_attr_connectspeed
);
1195 #ifdef __IS_DEVICE__
1196 ifx_proc_delproc("devspeed");
1197 device_remove_file(dev
, &dev_attr_devspeed
);
1198 ifx_proc_delproc("enumspeed");
1199 device_remove_file(dev
, &dev_attr_enumspeed
);
1202 #ifdef __ENABLE_DUMP__
1204 ifx_proc_delproc("dump_reg_1");
1205 ifx_proc_delproc("dump_reg_2");
1206 device_remove_file(dev
, &dev_attr_dump_reg_1
);
1207 device_remove_file(dev
, &dev_attr_dump_reg_2
);
1209 ifx_proc_delproc("dump_reg");
1210 device_remove_file(dev
, &dev_attr_dump_reg
);
1214 ifx_proc_delproc("dump_spram_1");
1215 ifx_proc_delproc("dump_spram_2");
1216 device_remove_file(dev
, &dev_attr_dump_spram_1
);
1217 device_remove_file(dev
, &dev_attr_dump_spram_2
);
1219 ifx_proc_delproc("dump_spram");
1220 device_remove_file(dev
, &dev_attr_dump_spram
);
1225 ifx_proc_delproc("dump_host_state_1");
1226 ifx_proc_delproc("dump_host_state_2");
1227 device_remove_file(dev
, &dev_attr_dump_host_state_1
);
1228 device_remove_file(dev
, &dev_attr_dump_host_state_2
);
1230 ifx_proc_delproc("dump_host_state");
1231 device_remove_file(dev
, &dev_attr_dump_host_state
);
1234 #endif //__ENABLE_DUMP__
1235 /* AVM/WK fix: del IFXUSB root dir*/
1236 ifx_proc_delproc(NULL
);
1239 static struct proc_dir_entry
* proc_ifx_root
= NULL
;
1241 /* initialize the proc file system and make a dir named /proc/[name] */
1242 static void ifx_proc_init(void)
1244 IFX_DEBUGPL(DBG_ENTRY
, "%s() %d\n", __func__
, __LINE__
);
1245 proc_ifx_root
= proc_mkdir(ifxusb_driver_name
, (void *)0);
1246 if (!proc_ifx_root
){
1247 IFX_PRINT("%s proc initialization failed! \n", ifxusb_driver_name
);
1252 /* proc file system add function for debugging. */
1253 static int ifx_proc_addproc(char *funcname
, read_proc_t
*hookfuncr
, write_proc_t
*hookfuncw
)
1255 struct proc_dir_entry
*pe
;
1256 IFX_DEBUGPL(DBG_ENTRY
, "%s() %d\n", __func__
, __LINE__
);
1260 if (hookfuncw
== NULL
)
1262 pe
= create_proc_read_entry(funcname
, S_IRUGO
, proc_ifx_root
, hookfuncr
, NULL
);
1265 IFX_PRINT("ERROR in creating read proc entry (%s)! \n", funcname
);
1271 pe
= create_proc_entry(funcname
, S_IRUGO
| S_IWUGO
, proc_ifx_root
);
1274 pe
->read_proc
= hookfuncr
;
1275 pe
->write_proc
= hookfuncw
;
1279 IFX_PRINT("ERROR in creating proc entry (%s)! \n", funcname
);
1287 /* proc file system del function for removing module. */
1288 static void ifx_proc_delproc(char *funcname
)
1291 if (funcname
!= NULL
) {
1292 remove_proc_entry(funcname
, proc_ifx_root
);
1294 remove_proc_entry(ifxusb_driver_name
, NULL
);
1295 proc_ifx_root
= NULL
;
1299 static void ifxusb_dump_params(ifxusb_core_if_t
*_core_if
)
1301 ifxusb_params_t
*params
=&_core_if
->params
;
1304 IFX_PRINT("IFXUSB Dump Parameters ( Host Mode) \n");
1305 #endif //__IS_HOST__
1306 #ifdef __IS_DEVICE__
1307 IFX_PRINT("IFXUSB Dump Parameters ( Device Mode) \n");
1308 #endif //__IS_DEVICE__
1311 IFX_PRINT("DMA: Hermes DMA\n");
1313 IFX_PRINT("DMA: Non-Desc DMA\n");
1315 IFX_PRINT(" Burst size: %d\n",params
->dma_burst_size
);
1317 if (params
->speed
==1)
1318 IFX_PRINT("Full Speed only\n");
1319 else if(params
->speed
==0)
1320 IFX_PRINT("Full/Hign Speed\n");
1322 IFX_PRINT("Unkonwn setting (%d) for Speed\n",params
->speed
);
1324 IFX_PRINT("Total Data FIFO size: %d(0x%06X) DWord, %d(0x%06X) Bytes\n",
1325 params
->data_fifo_size
,params
->data_fifo_size
,
1326 params
->data_fifo_size
*4, params
->data_fifo_size
*4
1329 #ifdef __IS_DEVICE__
1330 IFX_PRINT("Rx FIFO size: %d(0x%06X) DWord, %d(0x%06X) Bytes\n",
1331 params
->rx_fifo_size
,params
->rx_fifo_size
,
1332 params
->rx_fifo_size
*4, params
->rx_fifo_size
*4
1336 for(i
=0;i
<MAX_EPS_CHANNELS
;i
++)
1338 IFX_PRINT("Tx FIFO #%d size: %d(0x%06X) DWord, %d(0x%06X) Bytes\n",i
,
1339 params
->tx_fifo_size
[i
],params
->tx_fifo_size
[i
],
1340 params
->tx_fifo_size
[i
]*4, params
->tx_fifo_size
[i
]*4
1345 IFX_PRINT("Treshold : %s Rx:%d Tx:%d \n",
1346 (params
->thr_ctl
)?"On":"Off",params
->tx_thr_length
,params
->rx_thr_length
);
1349 IFX_PRINT("Host Channels: %d\n",params
->host_channels
);
1351 IFX_PRINT("Rx FIFO size: %d(0x%06X) DWord, %d(0x%06X) Bytes\n",
1352 params
->data_fifo_size
,params
->data_fifo_size
,
1353 params
->data_fifo_size
*4, params
->data_fifo_size
*4
1356 IFX_PRINT("NP Tx FIFO size: %d(0x%06X) DWord, %d(0x%06X) Bytes\n",
1357 params
->nperio_tx_fifo_size
,params
->nperio_tx_fifo_size
,
1358 params
->nperio_tx_fifo_size
*4, params
->nperio_tx_fifo_size
*4
1361 IFX_PRINT(" P Tx FIFO size: %d(0x%06X) DWord, %d(0x%06X) Bytes\n",
1362 params
->perio_tx_fifo_size
,params
->perio_tx_fifo_size
,
1363 params
->perio_tx_fifo_size
*4, params
->perio_tx_fifo_size
*4
1365 #endif //__IS_HOST__
1367 IFX_PRINT("Max Transfer size: %d(0x%06X) Bytes\n",
1368 params
->max_transfer_size
,params
->max_transfer_size
1370 IFX_PRINT("Max Packet Count: %d(0x%06X)\n",
1371 params
->max_packet_count
,params
->max_packet_count
1374 IFX_PRINT("PHY UTMI Width: %d\n",params
->phy_utmi_width
);
1376 IFX_PRINT("Turn Around Time: HS:%d FS:%d\n",params
->turn_around_time_hs
,params
->turn_around_time_fs
);
1377 IFX_PRINT("Timeout Calibration: HS:%d FS:%d\n",params
->timeout_cal_hs
,params
->timeout_cal_fs
);
1380 IFX_PRINT("==================================================\n");
1381 IFX_PRINT("End of Parameters Dump\n");
1382 IFX_PRINT("==================================================\n");