1 /*****************************************************************************
2 ** FILE NAME : ifxusb_ctl.c
3 ** PROJECT : IFX USB sub-system V3
4 ** MODULES : IFX USB sub-system Host and Device driver
8 ** DESCRIPTION : Implementing the procfs and sysfs for IFX USB driver
11 ** REFERENCE : Synopsys DWC-OTG Driver 2.7
12 ** COPYRIGHT : Copyright (c) 2010
13 ** LANTIQ DEUTSCHLAND GMBH,
14 ** Am Campeon 3, 85579 Neubiberg, Germany
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.
21 ** Version Control Section **
25 ** $Log$ Revision history
26 *****************************************************************************/
29 * This file contains code fragments from Synopsys HS OTG Linux Software Driver.
30 * For this code the following notice is applicable:
32 * ==========================================================================
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.
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.
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
59 * ========================================================================== */
61 /*! \file ifxusb_ctl.c
62 \ingroup IFXUSB_DRIVER_V3
63 \brief Implementing the procfs and sysfs for IFX USB driver
66 #include <linux/version.h>
67 #include "ifxusb_version.h"
70 #include <linux/proc_fs.h>
71 #include <asm/byteorder.h>
72 #include <asm/unaligned.h>
73 #include <asm/uaccess.h>
75 #include "ifxusb_plat.h"
76 #include "ifxusb_regs.h"
77 #include "ifxusb_cif.h"
82 #include <asm/ifx/ifx_types.h>
83 #include <asm/ifx/ifx_pmcu.h>
84 IFX_PMCU_REGISTER_t pmcuRegisterUSBGadget;
91 #include <asm/ifx/ifx_types.h>
92 #include <asm/ifx/ifx_pmcu.h>
94 IFX_PMCU_REGISTER_t pmcuRegisterUSBHost_1;
95 IFX_PMCU_REGISTER_t pmcuRegisterUSBHost_2;
97 IFX_PMCU_REGISTER_t pmcuRegisterUSBHost;
102 #include <linux/device.h>
103 #include <linux/platform_device.h>
104 #include <linux/gfp.h>
107 extern char ifxusb_hcd_driver_name[];
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[];
115 extern ifxhcd_hcd_t ifxusb_hcd;
116 extern char ifxusb_hcd_name[];
122 extern char ifxusb_pcd_driver_name[];
124 extern ifxpcd_pcd_t ifxusb_pcd;
125 extern char ifxusb_pcd_name[];
129 //Attributes for sysfs (for 2.6 only)
132 extern struct device_attribute dev_attr_version_h;
134 extern struct device_attribute dev_attr_version_d;
137 extern struct device_attribute dev_attr_dbglevel_h;
139 extern struct device_attribute dev_attr_dbglevel_d;
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;
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;
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;
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;
173 extern struct device_attribute dev_attr_dump_params_h;
174 extern struct device_attribute dev_attr_mode_h;
177 extern struct device_attribute dev_attr_dump_params_d;
178 extern struct device_attribute dev_attr_mode_d;
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;
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;
214 extern struct device_attribute dev_attr_devspeed;
215 extern struct device_attribute dev_attr_enumspeed;
216 #endif //__IS_DEVICE__
218 #ifdef __ENABLE_DUMP__
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;
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;
233 extern struct device_attribute dev_attr_dump_reg_d;
234 extern struct device_attribute dev_attr_dump_spram_d;
236 #endif //__ENABLE_DUMP__
239 /////////////////////////////////////////////////////////////////////////////////////////////////////
240 /////////////////////////////////////////////////////////////////////////////////////////////////////
241 /////////////////////////////////////////////////////////////////////////////////////////////////////
243 static ssize_t procfs_version_show(char *buf, char **start, off_t offset, int count, int *eof, void *data)
245 return sprintf( buf, "%s\n",IFXUSB_VERSION );
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)
251 static ssize_t sysfs_version_show( struct device *_dev, char *buf)
254 return sprintf( buf, "%s\n",IFXUSB_VERSION );
258 DEVICE_ATTR(version_h, S_IRUGO|S_IWUSR, sysfs_version_show, NULL);
260 DEVICE_ATTR(version_d, S_IRUGO|S_IWUSR, sysfs_version_show, NULL);
264 /////////////////////////////////////////////////////////////////////////////////////////////////////
265 /////////////////////////////////////////////////////////////////////////////////////////////////////
266 /////////////////////////////////////////////////////////////////////////////////////////////////////
267 /////////////////////////////////////////////////////////////////////////////////////////////////////
268 /////////////////////////////////////////////////////////////////////////////////////////////////////
269 /////////////////////////////////////////////////////////////////////////////////////////////////////
271 static ssize_t procfs_dbglevel_show(char *buf, char **start, off_t offset, int count, int *eof, void *data)
274 return sprintf( buf, "%08X\n",h_dbg_lvl );
276 return sprintf( buf, "%08X\n",d_dbg_lvl );
280 static ssize_t procfs_dbglevel_store(struct file *file, const char *buffer, unsigned long count, void *data)
285 if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1))
287 value = simple_strtoul(buf, NULL, 16);
293 //turn on and off power
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)
300 static ssize_t sysfs_dbglevel_show( struct device *_dev, char *buf)
304 return sprintf( buf, "%08X\n",h_dbg_lvl );
306 return sprintf( buf, "%08X\n",d_dbg_lvl );
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 )
313 static ssize_t sysfs_dbglevel_store( struct device *_dev, const char *buffer, size_t count )
319 if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1))
321 value = simple_strtoul(buf, NULL, 16);
327 //turn on and off power
332 DEVICE_ATTR(dbglevel_h, S_IRUGO|S_IWUSR, sysfs_dbglevel_show, sysfs_dbglevel_store);
334 DEVICE_ATTR(dbglevel_d, S_IRUGO|S_IWUSR, sysfs_dbglevel_show, sysfs_dbglevel_store);
338 /////////////////////////////////////////////////////////////////////////////////////////////////////
339 /////////////////////////////////////////////////////////////////////////////////////////////////////
340 /////////////////////////////////////////////////////////////////////////////////////////////////////
342 static void ifxusb_dump_params(ifxusb_core_if_t *_core_if);
345 static void dump_params_1(void)
347 ifxusb_dump_params(&ifxusb_hcd_1.core_if);
349 static void dump_params_2(void)
351 ifxusb_dump_params(&ifxusb_hcd_2.core_if);
354 static ssize_t procfs_dump_params_show_1(char *buf, char **start, off_t offset, int count, int *eof, void *data)
359 static ssize_t procfs_dump_params_show_2(char *buf, char **start, off_t offset, int count, int *eof, void *data)
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)
368 static ssize_t sysfs_dump_params_show_1( struct device *_dev,char *buf)
374 DEVICE_ATTR(dump_params_h_1, S_IRUGO|S_IWUSR, sysfs_dump_params_show_1, NULL);
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)
379 static ssize_t sysfs_dump_params_show_2( struct device *_dev,char *buf)
386 DEVICE_ATTR(dump_params_h_2, S_IRUGO|S_IWUSR, sysfs_dump_params_show_2, NULL);
388 static void dump_params(void)
391 ifxusb_dump_params(&ifxusb_hcd.core_if);
393 ifxusb_dump_params(&ifxusb_pcd.core_if);
397 static ssize_t procfs_dump_params_show(char *buf, char **start, off_t offset, int count, int *eof, void *data)
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)
406 static ssize_t sysfs_dump_params_show( struct device *_dev,char *buf)
414 DEVICE_ATTR(dump_params_h, S_IRUGO|S_IWUSR, sysfs_dump_params_show, NULL);
416 DEVICE_ATTR(dump_params_d, S_IRUGO|S_IWUSR, sysfs_dump_params_show, NULL);
420 /////////////////////////////////////////////////////////////////////////////////////////////////////
421 /////////////////////////////////////////////////////////////////////////////////////////////////////
422 /////////////////////////////////////////////////////////////////////////////////////////////////////
425 static ssize_t mode_show_1(char *buf)
427 if((ifxusb_rreg(&ifxusb_hcd_1.core_if.core_global_regs->gintsts ) & 0x1) == 1)
428 return sprintf( buf, "HOST\n" );
430 return sprintf( buf, "DEVICE(INCORRECT!)\n" );
433 static ssize_t mode_show_2(char *buf)
435 if((ifxusb_rreg(&ifxusb_hcd_2.core_if.core_global_regs->gintsts ) & 0x1) == 1)
436 return sprintf( buf, "HOST\n" );
438 return sprintf( buf, "DEVICE(INCORRECT!)\n" );
441 static ssize_t procfs_mode_show_1(char *buf, char **start, off_t offset, int count, int *eof, void *data)
443 return mode_show_1(buf);
445 static ssize_t procfs_mode_show_2(char *buf, char **start, off_t offset, int count, int *eof, void *data)
447 return mode_show_2(buf);
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)
453 static ssize_t sysfs_mode_show_1( struct device *_dev,char *buf)
456 return mode_show_1(buf);
459 DEVICE_ATTR(mode_h_1, S_IRUGO|S_IWUSR, sysfs_mode_show_1, 0);
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)
464 static ssize_t sysfs_mode_show_2( struct device *_dev,char *buf)
467 return mode_show_2(buf);
469 DEVICE_ATTR(mode_h_2, S_IRUGO|S_IWUSR, sysfs_mode_show_2, NULL);
471 static ssize_t mode_show(char *buf)
474 if((ifxusb_rreg(&ifxusb_hcd.core_if.core_global_regs->gintsts ) & 0x1) == 1)
475 return sprintf( buf, "HOST\n" );
477 return sprintf( buf, "DEVICE(INCORRECT!)\n" );
479 if((ifxusb_rreg(&ifxusb_pcd.core_if.core_global_regs->gintsts ) & 0x1) != 1)
480 return sprintf( buf, "DEVICE\n" );
482 return sprintf( buf, "HOST(INCORRECT!)\n" );
485 static ssize_t procfs_mode_show(char *buf, char **start, off_t offset, int count, int *eof, void *data)
487 return mode_show(buf);
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)
492 static ssize_t sysfs_mode_show( struct device *_dev, char *buf)
495 return mode_show(buf);
498 DEVICE_ATTR(mode_h, S_IRUGO|S_IWUSR, sysfs_mode_show, NULL);
500 DEVICE_ATTR(mode_d, S_IRUGO|S_IWUSR, sysfs_mode_show, NULL);
504 /////////////////////////////////////////////////////////////////////////////////////////////////////
505 /////////////////////////////////////////////////////////////////////////////////////////////////////
506 /////////////////////////////////////////////////////////////////////////////////////////////////////
509 /////////////////////////////////////////////////////////////////////////////////////////////////////
510 /////////////////////////////////////////////////////////////////////////////////////////////////////
511 /////////////////////////////////////////////////////////////////////////////////////////////////////
513 static ssize_t bandwidth_hs_show_1(char *buf)
515 return sprintf( buf, "%d\n",ifxusb_hcd_1.pkt_remaining_reload_hs );
517 static ssize_t bandwidth_fs_show_1(char *buf)
519 return sprintf( buf, "%d\n",ifxusb_hcd_1.pkt_remaining_reload_fs );
521 static ssize_t bandwidth_ls_show_1(char *buf)
523 return sprintf( buf, "%d\n",ifxusb_hcd_1.pkt_remaining_reload_ls );
525 static void bandwidth_hs_store_1(uint32_t value)
527 if(value>16 && value<120)
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;
536 static void bandwidth_fs_store_1(uint32_t value)
538 if (value>2 && value<30)
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;
547 static void bandwidth_ls_store_1(uint32_t value)
549 if (value>2 && value<30)
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;
558 static ssize_t bandwidth_hs_show_2(char *buf)
560 return sprintf( buf, "%d\n",ifxusb_hcd_2.pkt_remaining_reload_hs );
562 static ssize_t bandwidth_fs_show_2(char *buf)
564 return sprintf( buf, "%d\n",ifxusb_hcd_2.pkt_remaining_reload_fs );
566 static ssize_t bandwidth_ls_show_2(char *buf)
568 return sprintf( buf, "%d\n",ifxusb_hcd_2.pkt_remaining_reload_ls );
570 static void bandwidth_hs_store_2(uint32_t value)
572 if(value>16 && value<120)
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;
581 static void bandwidth_fs_store_2(uint32_t value)
583 if (value>2 && value<30)
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;
592 static void bandwidth_ls_store_2(uint32_t value)
594 if (value>2 && value<30)
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;
603 static ssize_t procfs_bandwidth_hs_show_1(char *buf, char **start, off_t offset, int count, int *eof, void *data)
605 return bandwidth_hs_show_1(buf);
607 static ssize_t procfs_bandwidth_fs_show_1(char *buf, char **start, off_t offset, int count, int *eof, void *data)
609 return bandwidth_fs_show_1(buf);
611 static ssize_t procfs_bandwidth_ls_show_1(char *buf, char **start, off_t offset, int count, int *eof, void *data)
613 return bandwidth_ls_show_1(buf);
615 static ssize_t procfs_bandwidth_hs_store_1(struct file *file, const char *buffer, unsigned long count, void *data)
620 if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1))
622 value = simple_strtoul(buf, NULL, 10);
623 bandwidth_hs_store_1(value);
626 static ssize_t procfs_bandwidth_fs_store_1(struct file *file, const char *buffer, unsigned long count, void *data)
631 if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1))
633 value = simple_strtoul(buf, NULL, 10);
634 bandwidth_fs_store_1(value);
637 static ssize_t procfs_bandwidth_ls_store_1(struct file *file, const char *buffer, unsigned long count, void *data)
642 if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1))
644 value = simple_strtoul(buf, NULL, 10);
645 bandwidth_ls_store_1(value);
648 static ssize_t procfs_bandwidth_hs_show_2(char *buf, char **start, off_t offset, int count, int *eof, void *data)
650 return bandwidth_hs_show_2(buf);
652 static ssize_t procfs_bandwidth_fs_show_2(char *buf, char **start, off_t offset, int count, int *eof, void *data)
654 return bandwidth_fs_show_2(buf);
656 static ssize_t procfs_bandwidth_ls_show_2(char *buf, char **start, off_t offset, int count, int *eof, void *data)
658 return bandwidth_ls_show_2(buf);
660 static ssize_t procfs_bandwidth_hs_store_2(struct file *file, const char *buffer, unsigned long count, void *data)
665 if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1))
667 value = simple_strtoul(buf, NULL, 10);
668 bandwidth_hs_store_2(value);
671 static ssize_t procfs_bandwidth_fs_store_2(struct file *file, const char *buffer, unsigned long count, void *data)
676 if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1))
678 value = simple_strtoul(buf, NULL, 10);
679 bandwidth_fs_store_2(value);
682 static ssize_t procfs_bandwidth_ls_store_2(struct file *file, const char *buffer, unsigned long count, void *data)
687 if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1))
689 value = simple_strtoul(buf, NULL, 10);
690 bandwidth_ls_store_2(value);
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)
697 static ssize_t sysfs_bandwidth_hs_show_1( struct device *_dev,char *buf)
700 return bandwidth_hs_show_1(buf);
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 )
705 static ssize_t sysfs_bandwidth_hs_store_1( struct device *_dev, const char *buffer, size_t count )
711 if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1))
713 value = simple_strtoul(buf, NULL, 10);
714 bandwidth_hs_store_1(value);
717 DEVICE_ATTR(bandwidth_hs_1, S_IRUGO|S_IWUSR, sysfs_bandwidth_hs_show_1, sysfs_bandwidth_hs_store_1);
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)
722 static ssize_t sysfs_bandwidth_fs_show_1( struct device *_dev,char *buf)
725 return bandwidth_fs_show_1(buf);
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 )
730 static ssize_t sysfs_bandwidth_fs_store_1( struct device *_dev, const char *buffer, size_t count )
736 if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1))
738 value = simple_strtoul(buf, NULL, 10);
739 bandwidth_fs_store_1(value);
742 DEVICE_ATTR(bandwidth_fs_1, S_IRUGO|S_IWUSR, sysfs_bandwidth_fs_show_1, sysfs_bandwidth_fs_store_1);
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)
747 static ssize_t sysfs_bandwidth_ls_show_1( struct device *_dev,char *buf)
750 return bandwidth_ls_show_1(buf);
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 )
755 static ssize_t sysfs_bandwidth_ls_store_1( struct device *_dev, const char *buffer, size_t count )
761 if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1))
763 value = simple_strtoul(buf, NULL, 10);
764 bandwidth_ls_store_1(value);
767 DEVICE_ATTR(bandwidth_ls_1, S_IRUGO|S_IWUSR, sysfs_bandwidth_ls_show_1, sysfs_bandwidth_ls_store_1);
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)
772 static ssize_t sysfs_bandwidth_hs_show_2( struct device *_dev,char *buf)
775 return bandwidth_hs_show_2(buf);
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 )
780 static ssize_t sysfs_bandwidth_hs_store_2( struct device *_dev, const char *buffer, size_t count )
786 if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1))
788 value = simple_strtoul(buf, NULL, 10);
789 bandwidth_hs_store_2(value);
792 DEVICE_ATTR(bandwidth_hs_2, S_IRUGO|S_IWUSR, sysfs_bandwidth_hs_show_2, sysfs_bandwidth_hs_store_2);
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)
797 static ssize_t sysfs_bandwidth_fs_show_2( struct device *_dev,char *buf)
800 return bandwidth_fs_show_2(buf);
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 )
805 static ssize_t sysfs_bandwidth_fs_store_2( struct device *_dev, const char *buffer, size_t count )
811 if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1))
813 value = simple_strtoul(buf, NULL, 10);
814 bandwidth_fs_store_2(value);
817 DEVICE_ATTR(bandwidth_fs_2, S_IRUGO|S_IWUSR, sysfs_bandwidth_fs_show_2, sysfs_bandwidth_fs_store_2);
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)
822 static ssize_t sysfs_bandwidth_ls_show_2( struct device *_dev,char *buf)
825 return bandwidth_ls_show_2(buf);
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 )
830 static ssize_t sysfs_bandwidth_ls_store_2( struct device *_dev, const char *buffer, size_t count )
836 if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1))
838 value = simple_strtoul(buf, NULL, 10);
839 bandwidth_ls_store_2(value);
842 DEVICE_ATTR(bandwidth_ls_2, S_IRUGO|S_IWUSR, sysfs_bandwidth_ls_show_2, sysfs_bandwidth_ls_store_2);
844 static ssize_t bandwidth_hs_show(char *buf)
846 return sprintf( buf, "%d\n",ifxusb_hcd.pkt_remaining_reload_hs );
848 static ssize_t bandwidth_fs_show(char *buf)
850 return sprintf( buf, "%d\n",ifxusb_hcd.pkt_remaining_reload_fs );
852 static ssize_t bandwidth_ls_show(char *buf)
854 return sprintf( buf, "%d\n",ifxusb_hcd.pkt_remaining_reload_ls );
856 static void bandwidth_hs_store(uint32_t value)
858 if (value>16 && value<120)
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;
867 static void bandwidth_fs_store(uint32_t value)
869 if (value>2 && value<30)
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;
878 static void bandwidth_ls_store(uint32_t value)
880 if (value>2 && value<30)
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;
889 static ssize_t procfs_bandwidth_hs_show(char *buf, char **start, off_t offset, int count, int *eof, void *data)
891 return bandwidth_hs_show(buf);
893 static ssize_t procfs_bandwidth_fs_show(char *buf, char **start, off_t offset, int count, int *eof, void *data)
895 return bandwidth_fs_show(buf);
897 static ssize_t procfs_bandwidth_ls_show(char *buf, char **start, off_t offset, int count, int *eof, void *data)
899 return bandwidth_ls_show(buf);
901 static ssize_t procfs_bandwidth_hs_store(struct file *file, const char *buffer, unsigned long count, void *data)
906 if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1))
908 value = simple_strtoul(buf, NULL, 10);
909 bandwidth_hs_store(value);
912 static ssize_t procfs_bandwidth_fs_store(struct file *file, const char *buffer, unsigned long count, void *data)
917 if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1))
919 value = simple_strtoul(buf, NULL, 10);
920 bandwidth_fs_store(value);
923 static ssize_t procfs_bandwidth_ls_store(struct file *file, const char *buffer, unsigned long count, void *data)
928 if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1))
930 value = simple_strtoul(buf, NULL, 10);
931 bandwidth_ls_store(value);
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)
938 static ssize_t sysfs_bandwidth_hs_show( struct device *_dev,char *buf)
941 return bandwidth_hs_show(buf);
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 )
946 static ssize_t sysfs_bandwidth_hs_store( struct device *_dev, const char *buffer, size_t count )
952 if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1))
954 value = simple_strtoul(buf, NULL, 10);
955 bandwidth_hs_store(value);
958 DEVICE_ATTR(bandwidth_hs, S_IRUGO|S_IWUSR, sysfs_bandwidth_hs_show, sysfs_bandwidth_hs_store);
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)
963 static ssize_t sysfs_bandwidth_fs_show( struct device *_dev,char *buf)
966 return bandwidth_fs_show(buf);
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 )
971 static ssize_t sysfs_bandwidth_fs_store( struct device *_dev, const char *buffer, size_t count )
977 if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1))
979 value = simple_strtoul(buf, NULL, 10);
980 bandwidth_fs_store(value);
983 DEVICE_ATTR(bandwidth_fs, S_IRUGO|S_IWUSR, sysfs_bandwidth_fs_show, sysfs_bandwidth_fs_store);
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)
988 static ssize_t sysfs_bandwidth_ls_show( struct device *_dev,char *buf)
991 return bandwidth_ls_show(buf);
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 )
996 static ssize_t sysfs_bandwidth_ls_store( struct device *_dev, const char *buffer, size_t count )
1002 if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1))
1004 value = simple_strtoul(buf, NULL, 10);
1005 bandwidth_ls_store(value);
1008 DEVICE_ATTR(bandwidth_ls, S_IRUGO|S_IWUSR, sysfs_bandwidth_ls_show, sysfs_bandwidth_ls_store);
1011 /////////////////////////////////////////////////////////////////////////////////////////////////////
1012 /////////////////////////////////////////////////////////////////////////////////////////////////////
1014 static ssize_t pkt_count_limit_bi_show_1(char *buf)
1016 return sprintf( buf, "%d\n",ifxusb_hcd_1.pkt_count_limit_bi );
1018 static ssize_t pkt_count_limit_bo_show_1(char *buf)
1020 return sprintf( buf, "%d\n",ifxusb_hcd_1.pkt_count_limit_bo );
1022 static void pkt_count_limit_bi_store_1(uint32_t value)
1025 ifxusb_hcd_1.pkt_count_limit_bi = value;
1027 static void pkt_count_limit_bo_store_1(uint32_t value)
1030 ifxusb_hcd_1.pkt_count_limit_bo = value;
1032 static ssize_t pkt_count_limit_bi_show_2(char *buf)
1034 return sprintf( buf, "%d\n",ifxusb_hcd_2.pkt_count_limit_bi );
1036 static ssize_t pkt_count_limit_bo_show_2(char *buf)
1038 return sprintf( buf, "%d\n",ifxusb_hcd_2.pkt_count_limit_bo );
1040 static void pkt_count_limit_bi_store_2(uint32_t value)
1043 ifxusb_hcd_2.pkt_count_limit_bi = value;
1045 static void pkt_count_limit_bo_store_2(uint32_t value)
1048 ifxusb_hcd_2.pkt_count_limit_bo = value;
1050 static ssize_t procfs_pkt_count_limit_bi_show_1(char *buf, char **start, off_t offset, int count, int *eof, void *data)
1052 return pkt_count_limit_bi_show_1(buf);
1054 static ssize_t procfs_pkt_count_limit_bo_show_1(char *buf, char **start, off_t offset, int count, int *eof, void *data)
1056 return pkt_count_limit_bo_show_1(buf);
1058 static ssize_t procfs_pkt_count_limit_bi_store_1(struct file *file, const char *buffer, unsigned long count, void *data)
1063 if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1))
1065 value = simple_strtoul(buf, NULL, 10);
1066 pkt_count_limit_bi_store_1(value);
1069 static ssize_t procfs_pkt_count_limit_bo_store_1(struct file *file, const char *buffer, unsigned long count, void *data)
1074 if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1))
1076 value = simple_strtoul(buf, NULL, 10);
1077 pkt_count_limit_bo_store_1(value);
1080 static ssize_t procfs_pkt_count_limit_bi_show_2(char *buf, char **start, off_t offset, int count, int *eof, void *data)
1082 return pkt_count_limit_bi_show_2(buf);
1084 static ssize_t procfs_pkt_count_limit_bo_show_2(char *buf, char **start, off_t offset, int count, int *eof, void *data)
1086 return pkt_count_limit_bo_show_2(buf);
1088 static ssize_t procfs_pkt_count_limit_bi_store_2(struct file *file, const char *buffer, unsigned long count, void *data)
1093 if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1))
1095 value = simple_strtoul(buf, NULL, 10);
1096 pkt_count_limit_bi_store_2(value);
1099 static ssize_t procfs_pkt_count_limit_bo_store_2(struct file *file, const char *buffer, unsigned long count, void *data)
1104 if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1))
1106 value = simple_strtoul(buf, NULL, 10);
1107 pkt_count_limit_bo_store_2(value);
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)
1114 static ssize_t sysfs_pkt_count_limit_bi_show_1( struct device *_dev,char *buf)
1117 return pkt_count_limit_bi_show_1(buf);
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 )
1122 static ssize_t sysfs_pkt_count_limit_bi_store_1( struct device *_dev, const char *buffer, size_t count )
1128 if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1))
1130 value = simple_strtoul(buf, NULL, 10);
1131 pkt_count_limit_bi_store_1(value);
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);
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)
1139 static ssize_t sysfs_pkt_count_limit_bo_show_1( struct device *_dev,char *buf)
1142 return pkt_count_limit_bo_show_1(buf);
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 )
1147 static ssize_t sysfs_pkt_count_limit_bo_store_1( struct device *_dev, const char *buffer, size_t count )
1153 if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1))
1155 value = simple_strtoul(buf, NULL, 10);
1156 pkt_count_limit_bo_store_1(value);
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);
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)
1164 static ssize_t sysfs_pkt_count_limit_bi_show_2( struct device *_dev,char *buf)
1167 return pkt_count_limit_bi_show_2(buf);
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 )
1172 static ssize_t sysfs_pkt_count_limit_bi_2( struct device *_dev, const char *buffer, size_t count )
1178 if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1))
1180 value = simple_strtoul(buf, NULL, 10);
1181 pkt_count_limit_bi_store_2(value);
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);
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)
1189 static ssize_t sysfs_pkt_count_limit_bo_show_2( struct device *_dev,char *buf)
1192 return pkt_count_limit_bo_show_2(buf);
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 )
1197 static ssize_t sysfs_pkt_count_limit_bo_store_2( struct device *_dev, const char *buffer, size_t count )
1203 if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1))
1205 value = simple_strtoul(buf, NULL, 10);
1206 pkt_count_limit_bo_store_2(value);
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);
1211 static ssize_t pkt_count_limit_bi_show(char *buf)
1213 return sprintf( buf, "%d\n",ifxusb_hcd.pkt_count_limit_bi );
1215 static ssize_t pkt_count_limit_bo_show(char *buf)
1217 return sprintf( buf, "%d\n",ifxusb_hcd.pkt_count_limit_bo );
1219 static void pkt_count_limit_bi_store(uint32_t value)
1222 ifxusb_hcd.pkt_count_limit_bi = value;
1224 static void pkt_count_limit_bo_store(uint32_t value)
1227 ifxusb_hcd.pkt_count_limit_bo = value;
1229 static ssize_t procfs_pkt_count_limit_bi_show(char *buf, char **start, off_t offset, int count, int *eof, void *data)
1231 return pkt_count_limit_bi_show(buf);
1233 static ssize_t procfs_pkt_count_limit_bo_show(char *buf, char **start, off_t offset, int count, int *eof, void *data)
1235 return pkt_count_limit_bo_show(buf);
1237 static ssize_t procfs_pkt_count_limit_bi_store(struct file *file, const char *buffer, unsigned long count, void *data)
1242 if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1))
1244 value = simple_strtoul(buf, NULL, 10);
1245 pkt_count_limit_bi_store(value);
1248 static ssize_t procfs_pkt_count_limit_bo_store(struct file *file, const char *buffer, unsigned long count, void *data)
1253 if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1))
1255 value = simple_strtoul(buf, NULL, 10);
1256 pkt_count_limit_bo_store(value);
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)
1263 static ssize_t sysfs_pkt_count_limit_bi_show( struct device *_dev,char *buf)
1266 return pkt_count_limit_bi_show(buf);
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 )
1271 static ssize_t sysfs_pkt_count_limit_bi_store( struct device *_dev, const char *buffer, size_t count )
1277 if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1))
1279 value = simple_strtoul(buf, NULL, 10);
1280 pkt_count_limit_bi_store(value);
1283 DEVICE_ATTR(pkt_count_limit_bi, S_IRUGO|S_IWUSR, sysfs_pkt_count_limit_bi_show, sysfs_pkt_count_limit_bi_store);
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)
1288 static ssize_t sysfs_pkt_count_limit_bo_show( struct device *_dev,char *buf)
1291 return pkt_count_limit_bo_show(buf);
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 )
1296 static ssize_t sysfs_pkt_count_limit_bo_store( struct device *_dev, const char *buffer, size_t count )
1302 if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1))
1304 value = simple_strtoul(buf, NULL, 10);
1305 pkt_count_limit_bo_store(value);
1308 DEVICE_ATTR(pkt_count_limit_bo, S_IRUGO|S_IWUSR, sysfs_pkt_count_limit_bo_show, sysfs_pkt_count_limit_bo_store);
1311 /////////////////////////////////////////////////////////////////////////////////////////////////////
1312 /////////////////////////////////////////////////////////////////////////////////////////////////////
1313 /////////////////////////////////////////////////////////////////////////////////////////////////////
1316 static ssize_t buspower_show_1(char *buf)
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" );
1322 static void buspower_store_1(uint32_t value)
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);
1327 static ssize_t buspower_show_2(char *buf)
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" );
1333 static void buspower_store_2(uint32_t value)
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);
1338 static ssize_t procfs_buspower_show_1(char *buf, char **start, off_t offset, int count, int *eof, void *data)
1340 return buspower_show_1(buf);
1342 static ssize_t procfs_buspower_store_1(struct file *file, const char *buffer, unsigned long count, void *data)
1347 if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1))
1349 value = simple_strtoul(buf, NULL, 10);
1350 buspower_store_1(value);
1353 static ssize_t procfs_buspower_show_2(char *buf, char **start, off_t offset, int count, int *eof, void *data)
1355 return buspower_show_2(buf);
1357 static ssize_t procfs_buspower_store_2(struct file *file, const char *buffer, unsigned long count, void *data)
1362 if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1))
1364 value = simple_strtoul(buf, NULL, 10);
1365 buspower_store_2(value);
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)
1372 static ssize_t sysfs_buspower_show_1( struct device *_dev,char *buf)
1375 return buspower_show_1(buf);
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 )
1380 static ssize_t sysfs_buspower_store_1( struct device *_dev, const char *buffer, size_t count )
1386 if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1))
1388 value = simple_strtoul(buf, NULL, 10);
1389 buspower_store_1(value);
1392 DEVICE_ATTR(buspower_1, S_IRUGO|S_IWUSR, sysfs_buspower_show_1, sysfs_buspower_store_1);
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)
1397 static ssize_t sysfs_buspower_show_2( struct device *_dev,char *buf)
1400 return buspower_show_2(buf);
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 )
1405 static ssize_t sysfs_buspower_store_2( struct device *_dev, const char *buffer, size_t count )
1411 if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1))
1413 value = simple_strtoul(buf, NULL, 10);
1414 buspower_store_2(value);
1417 DEVICE_ATTR(buspower_2, S_IRUGO|S_IWUSR, sysfs_buspower_show_2, sysfs_buspower_store_2);
1419 static ssize_t buspower_show(char *buf)
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" );
1425 static void buspower_store(uint32_t value)
1427 if (value==1) ifxusb_vbus_on (&ifxusb_hcd.core_if);
1428 else if(value==0) ifxusb_vbus_off(&ifxusb_hcd.core_if);
1430 static ssize_t procfs_buspower_show(char *buf, char **start, off_t offset, int count, int *eof, void *data)
1432 return buspower_show(buf);
1434 static ssize_t procfs_buspower_store(struct file *file, const char *buffer, unsigned long count, void *data)
1439 if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1))
1441 value = simple_strtoul(buf, NULL, 10);
1442 buspower_store(value);
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)
1448 static ssize_t sysfs_buspower_show( struct device *_dev, char *buf)
1451 return buspower_show(buf);
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 )
1456 static ssize_t sysfs_buspower_store( struct device *_dev, const char *buffer, size_t count )
1462 if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1))
1464 value = simple_strtoul(buf, NULL, 10);
1465 buspower_store(value);
1468 DEVICE_ATTR(buspower, S_IRUGO|S_IWUSR, sysfs_buspower_show, sysfs_buspower_store);
1471 /////////////////////////////////////////////////////////////////////////////////////////////////////
1472 /////////////////////////////////////////////////////////////////////////////////////////////////////
1473 /////////////////////////////////////////////////////////////////////////////////////////////////////
1477 static ssize_t bussuspend_show_1(char *buf)
1480 val.d32 = ifxusb_rreg(ifxusb_hcd_1.core_if.hprt0);
1481 return sprintf (buf, "Bus Suspend = 0x%x\n", val.b.prtsusp);
1483 static ssize_t bussuspend_show_2(char *buf)
1486 val.d32 = ifxusb_rreg(ifxusb_hcd_2.core_if.hprt0);
1487 return sprintf (buf, "Bus Suspend = 0x%x\n", val.b.prtsusp);
1490 static ssize_t procfs_bussuspend_show_1(char *buf, char **start, off_t offset, int count, int *eof, void *data)
1492 return bussuspend_show_1(buf);
1494 static ssize_t procfs_bussuspend_show_2(char *buf, char **start, off_t offset, int count, int *eof, void *data)
1496 return bussuspend_show_2(buf);
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)
1501 static ssize_t sysfs_bussuspend_show_1( struct device *_dev,char *buf)
1504 return bussuspend_show_1(buf);
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)
1510 static ssize_t sysfs_bussuspend_show_2( struct device *_dev,char *buf)
1513 return bussuspend_show_2(buf);
1515 DEVICE_ATTR(bussuspend_2, S_IRUGO|S_IWUSR, sysfs_bussuspend_show_2, 0);
1517 static ssize_t bussuspend_show(char *buf)
1520 val.d32 = ifxusb_rreg(ifxusb_hcd.core_if.hprt0);
1521 return sprintf (buf, "Bus Suspend = 0x%x\n", val.b.prtsusp);
1523 static ssize_t procfs_bussuspend_show(char *buf, char **start, off_t offset, int count, int *eof, void *data)
1525 return bussuspend_show(buf);
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)
1531 static ssize_t sysfs_bussuspend_show( struct device *_dev, char *buf)
1534 return bussuspend_show(buf);
1536 DEVICE_ATTR(bussuspend, S_IRUGO|S_IWUSR, sysfs_bussuspend_show, 0);
1539 /////////////////////////////////////////////////////////////////////////////////////////////////////
1540 /////////////////////////////////////////////////////////////////////////////////////////////////////
1541 /////////////////////////////////////////////////////////////////////////////////////////////////////
1544 static ssize_t busconnected_show_1(char *buf)
1547 val.d32 = ifxusb_rreg(ifxusb_hcd_1.core_if.hprt0);
1548 return sprintf (buf, "Bus Connected = 0x%x\n", val.b.prtconnsts);
1550 static ssize_t busconnected_show_2(char *buf)
1553 val.d32 = ifxusb_rreg(ifxusb_hcd_2.core_if.hprt0);
1554 return sprintf (buf, "Bus Connected = 0x%x\n", val.b.prtconnsts);
1557 static ssize_t procfs_busconnected_show_1(char *buf, char **start, off_t offset, int count, int *eof, void *data)
1559 return busconnected_show_1(buf);
1561 static ssize_t procfs_busconnected_show_2(char *buf, char **start, off_t offset, int count, int *eof, void *data)
1563 return busconnected_show_2(buf);
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)
1568 static ssize_t sysfs_busconnected_show_1( struct device *_dev,char *buf)
1571 return busconnected_show_1(buf);
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)
1577 static ssize_t sysfs_busconnected_show_2( struct device *_dev,char *buf)
1580 return busconnected_show_2(buf);
1582 DEVICE_ATTR(busconnected_2, S_IRUGO|S_IWUSR, sysfs_busconnected_show_2, 0);
1584 static ssize_t busconnected_show(char *buf)
1587 val.d32 = ifxusb_rreg(ifxusb_hcd.core_if.hprt0);
1588 return sprintf (buf, "Bus Connected = 0x%x\n", val.b.prtconnsts);
1590 static ssize_t procfs_busconnected_show(char *buf, char **start, off_t offset, int count, int *eof, void *data)
1592 return busconnected_show(buf);
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)
1598 static ssize_t sysfs_busconnected_show( struct device *_dev, char *buf)
1601 return busconnected_show(buf);
1603 DEVICE_ATTR(busconnected, S_IRUGO|S_IWUSR, sysfs_busconnected_show, 0);
1606 /////////////////////////////////////////////////////////////////////////////////////////////////////
1607 /////////////////////////////////////////////////////////////////////////////////////////////////////
1608 /////////////////////////////////////////////////////////////////////////////////////////////////////
1611 static ssize_t connectspeed_show_1(char *buf)
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);
1620 static ssize_t connectspeed_show_2(char *buf)
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);
1630 static ssize_t procfs_connectspeed_show_1(char *buf, char **start, off_t offset, int count, int *eof, void *data)
1632 return connectspeed_show_1(buf);
1634 static ssize_t procfs_connectspeed_show_2(char *buf, char **start, off_t offset, int count, int *eof, void *data)
1636 return connectspeed_show_2(buf);
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)
1641 static ssize_t sysfs_connectspeed_show_1( struct device *_dev,char *buf)
1644 return connectspeed_show_1(buf);
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)
1650 static ssize_t sysfs_connectspeed_show_2( struct device *_dev,char *buf)
1653 return connectspeed_show_2(buf);
1655 DEVICE_ATTR(connectspeed_2, S_IRUGO|S_IWUSR, sysfs_connectspeed_show_2, 0);
1657 static ssize_t connectspeed_show(char *buf)
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);
1667 static ssize_t procfs_connectspeed_show(char *buf, char **start, off_t offset, int count, int *eof, void *data)
1669 return connectspeed_show(buf);
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)
1675 static ssize_t sysfs_connectspeed_show( struct device *_dev, char *buf)
1678 return connectspeed_show(buf);
1680 DEVICE_ATTR(connectspeed, S_IRUGO|S_IWUSR, sysfs_connectspeed_show, 0);
1682 /////////////////////////////////////////////////////////////////////////////////////////////////////
1683 /////////////////////////////////////////////////////////////////////////////////////////////////////
1684 /////////////////////////////////////////////////////////////////////////////////////////////////////
1688 #ifdef __IS_DEVICE__
1689 /////////////////////////////////////////////////////////////////////////////////////////////////////
1690 /////////////////////////////////////////////////////////////////////////////////////////////////////
1691 /////////////////////////////////////////////////////////////////////////////////////////////////////
1692 static ssize_t devspeed_show(char *buf)
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);
1702 static ssize_t procfs_devspeed_show(char *buf, char **start, off_t offset, int count, int *eof, void *data)
1704 return devspeed_show(buf);
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)
1710 static ssize_t sysfs_devspeed_show( struct device *_dev, char *buf)
1713 return devspeed_show(buf);
1715 DEVICE_ATTR(devspeed, S_IRUGO|S_IWUSR, sysfs_devspeed_show, 0);
1717 static ssize_t enumspeed_show(char *buf)
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);
1727 static ssize_t procfs_enumspeed_show(char *buf, char **start, off_t offset, int count, int *eof, void *data)
1729 return enumspeed_show(buf);
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)
1735 static ssize_t sysfs_enumspeed_show( struct device *_dev, char *buf)
1738 return enumspeed_show(buf);
1740 DEVICE_ATTR(enumspeed, S_IRUGO|S_IWUSR, sysfs_enumspeed_show, 0);
1741 /////////////////////////////////////////////////////////////////////////////////////////////////////
1742 /////////////////////////////////////////////////////////////////////////////////////////////////////
1743 /////////////////////////////////////////////////////////////////////////////////////////////////////
1747 //////////////////////////////////////////////////////////////////////////////////
1748 #ifdef __ENABLE_DUMP__
1751 static void dump_reg_1(void)
1753 ifxusb_dump_registers_h(&ifxusb_hcd_1.core_if);
1755 static void dump_reg_2(void)
1757 ifxusb_dump_registers_h(&ifxusb_hcd_2.core_if);
1760 static ssize_t procfs_dump_reg_show_1(char *buf, char **start, off_t offset, int count, int *eof, void *data)
1765 static ssize_t procfs_dump_reg_show_2(char *buf, char **start, off_t offset, int count, int *eof, void *data)
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)
1773 static ssize_t sysfs_dump_reg_show_1( struct device *_dev,char *buf)
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)
1783 static ssize_t sysfs_dump_reg_show_2( struct device *_dev,char *buf)
1789 DEVICE_ATTR(dump_reg_h_2, S_IRUGO|S_IWUSR, sysfs_dump_reg_show_2, 0);
1791 static void dump_reg(void)
1794 ifxusb_dump_registers_h(&ifxusb_hcd.core_if);
1796 #ifdef __IS_DEVICE__
1797 ifxusb_dump_registers_d(&ifxusb_pcd.core_if);
1800 static ssize_t procfs_dump_reg_show(char *buf, char **start, off_t offset, int count, int *eof, void *data)
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)
1808 static ssize_t sysfs_dump_reg_show( struct device *_dev,char *buf)
1815 DEVICE_ATTR(dump_reg_h, S_IRUGO|S_IWUSR, sysfs_dump_reg_show, 0);
1817 DEVICE_ATTR(dump_reg_d, S_IRUGO|S_IWUSR, sysfs_dump_reg_show, 0);
1822 /////////////////////////////////////////////////////////////////////////////////////////////////////
1823 /////////////////////////////////////////////////////////////////////////////////////////////////////
1824 /////////////////////////////////////////////////////////////////////////////////////////////////////
1827 static void dump_spram_1(void)
1829 ifxusb_dump_spram_h(&ifxusb_hcd_1.core_if);
1831 static void dump_spram_2(void)
1833 ifxusb_dump_spram_h(&ifxusb_hcd_2.core_if);
1836 static ssize_t procfs_dump_spram_show_1(char *buf, char **start, off_t offset, int count, int *eof, void *data)
1841 static ssize_t procfs_dump_spram_show_2(char *buf, char **start, off_t offset, int count, int *eof, void *data)
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)
1849 static ssize_t sysfs_dump_spram_show_1( struct device *_dev,char *buf)
1855 DEVICE_ATTR(dump_spram_h_1, S_IRUGO|S_IWUSR, sysfs_dump_spram_show_1, 0);
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)
1860 static ssize_t sysfs_dump_spram_show_2( struct device *_dev,char *buf)
1866 DEVICE_ATTR(dump_spram_h_2, S_IRUGO|S_IWUSR, sysfs_dump_spram_show_2, 0);
1868 static void dump_spram(void)
1871 ifxusb_dump_spram_h(&ifxusb_hcd.core_if);
1873 #ifdef __IS_DEVICE__
1874 ifxusb_dump_spram_d(&ifxusb_pcd.core_if);
1877 static ssize_t procfs_dump_spram_show(char *buf, char **start, off_t offset, int count, int *eof, void *data)
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)
1885 static ssize_t sysfs_dump_spram_show( struct device *_dev,char *buf)
1892 DEVICE_ATTR(dump_spram_h, S_IRUGO|S_IWUSR, sysfs_dump_spram_show, 0);
1894 DEVICE_ATTR(dump_spram_d, S_IRUGO|S_IWUSR, sysfs_dump_spram_show, 0);
1898 /////////////////////////////////////////////////////////////////////////////////////////////////////
1899 /////////////////////////////////////////////////////////////////////////////////////////////////////
1900 /////////////////////////////////////////////////////////////////////////////////////////////////////
1904 static ssize_t procfs_dump_host_state_show_1(char *buf, char **start, off_t offset, int count, int *eof, void *data)
1906 ifxhcd_dump_state(&ifxusb_hcd_1);
1909 static ssize_t procfs_dump_host_state_show_2(char *buf, char **start, off_t offset, int count, int *eof, void *data)
1911 ifxhcd_dump_state(&ifxusb_hcd_2);
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)
1917 static ssize_t sysfs_dump_host_state_show_1( struct device *_dev,char *buf)
1920 ifxhcd_dump_state(&ifxusb_hcd_1);
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)
1927 static ssize_t sysfs_dump_host_state_show_2( struct device *_dev,char *buf)
1930 ifxhcd_dump_state(&ifxusb_hcd_2);
1933 DEVICE_ATTR(dump_host_state_2, S_IRUGO|S_IWUSR, sysfs_dump_host_state_show_2, 0);
1935 static ssize_t procfs_dump_host_state_show(char *buf, char **start, off_t offset, int count, int *eof, void *data)
1937 ifxhcd_dump_state(&ifxusb_hcd);
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)
1943 static ssize_t sysfs_dump_host_state_show( struct device *_dev,char *buf)
1946 ifxhcd_dump_state(&ifxusb_hcd);
1949 DEVICE_ATTR(dump_host_state, S_IRUGO|S_IWUSR, sysfs_dump_host_state_show, 0);
1952 /////////////////////////////////////////////////////////////////////////////////////////////////////
1953 /////////////////////////////////////////////////////////////////////////////////////////////////////
1954 /////////////////////////////////////////////////////////////////////////////////////////////////////
1958 #endif //__ENABLE_DUMP__
1959 /////////////////////////////////////////////////////////////////////////////////////////////////////
1960 /////////////////////////////////////////////////////////////////////////////////////////////////////
1962 static void host_probe(unsigned long _ptr)
1964 ifxhcd_hcd_t *ifxhcd = (ifxhcd_hcd_t *)_ptr;
1966 if(ifxhcd->flags.b.port_connect_status)
1968 del_timer(&ifxhcd->host_probe_timer);
1969 del_timer(&ifxhcd->autoprobe_timer);
1970 ifxhcd->power_status = 0;
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);
1983 static void host_autoprobe(unsigned long _ptr)
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);
1994 static void suspend_host_store(ifxhcd_hcd_t *ifxhcd , uint32_t value)
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;
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);
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);
2021 static ssize_t procfs_suspend_host_2_store(struct file *file, const char *buffer, unsigned long count, void *data)
2026 if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1))
2028 value = simple_strtoul(buf, NULL, 10);
2029 suspend_host_store(&ifxusb_hcd_2,value);
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 )
2036 static ssize_t sysfs_suspend_host_2_store( struct device *_dev, const char *buffer, size_t count )
2042 if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1))
2044 value = simple_strtoul(buf, NULL, 10);
2045 suspend_host_store(&ifxusb_hcd_2,value);
2049 static ssize_t procfs_suspend_host_1_store(struct file *file, const char *buffer, unsigned long count, void *data)
2054 if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1))
2056 value = simple_strtoul(buf, NULL, 10);
2057 suspend_host_store(&ifxusb_hcd_1,value);
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 )
2064 static ssize_t sysfs_suspend_host_1_store( struct device *_dev, const char *buffer, size_t count )
2070 if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1))
2072 value = simple_strtoul(buf, NULL, 10);
2073 suspend_host_store(&ifxusb_hcd_1,value);
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 /////////////////////////////////////////////////////////////////////////////////////////////////////
2080 static ssize_t procfs_suspend_host_store(struct file *file, const char *buffer, unsigned long count, void *data)
2085 if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1))
2087 value = simple_strtoul(buf, NULL, 10);
2088 suspend_host_store(&ifxusb_hcd,value);
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 )
2095 static ssize_t sysfs_suspend_host_store( struct device *_dev, const char *buffer, size_t count )
2101 if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1))
2103 value = simple_strtoul(buf, NULL, 10);
2104 suspend_host_store(&ifxusb_hcd,value);
2107 DEVICE_ATTR(suspend_host, S_IWUSR,NULL, sysfs_suspend_host_store);
2111 /////////////////////////////////////////////////////////////////////////////////////////////////////
2112 /////////////////////////////////////////////////////////////////////////////////////////////////////
2114 static void probe_host_store(ifxhcd_hcd_t *ifxhcd, uint32_t value)
2116 if(ifxhcd->power_status == 1)
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);
2127 static ssize_t probe_host_2_show(char *buf)
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");
2134 return sprintf (buf,"Host 2 power status is Auto-probing\n");
2136 static ssize_t probe_host_1_show(char *buf)
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");
2143 return sprintf (buf,"Host 1 power status is Auto-probing\n");
2145 static ssize_t procfs_probe_host_2_store(struct file *file, const char *buffer, unsigned long count, void *data)
2150 if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1))
2152 value = simple_strtoul(buf, NULL, 10);
2153 probe_host_store(&ifxusb_hcd_2,value);
2156 static ssize_t procfs_probe_host_2_show(char *buf, char **start, off_t offset, int count, int *eof, void *data)
2158 return probe_host_2_show(buf);
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)
2163 static ssize_t sysfs_probe_host_2_show( struct device *_dev, char *buf)
2166 return probe_host_2_show(buf);
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 )
2171 static ssize_t sysfs_probe_host_2_store( struct device *_dev, const char *buffer, size_t count )
2177 if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1))
2179 value = simple_strtoul(buf, NULL, 10);
2180 probe_host_store(&ifxusb_hcd_2,value);
2184 static ssize_t procfs_probe_host_1_store(struct file *file, const char *buffer, unsigned long count, void *data)
2189 if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1))
2191 value = simple_strtoul(buf, NULL, 10);
2192 probe_host_store(&ifxusb_hcd_1,value);
2195 static ssize_t procfs_probe_host_1_show(char *buf, char **start, off_t offset, int count, int *eof, void *data)
2197 return probe_host_1_show(buf);
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)
2202 static ssize_t sysfs_probe_host_1_show( struct device *_dev, char *buf)
2205 return probe_host_1_show(buf);
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 )
2210 static ssize_t sysfs_probe_host_1_store( struct device *_dev, const char *buffer, size_t count )
2216 if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1))
2218 value = simple_strtoul(buf, NULL, 10);
2219 probe_host_store(&ifxusb_hcd_1,value);
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 /////////////////////////////////////////////////////////////////////////////////////////////////////
2226 static ssize_t probe_host_show(char *buf)
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");
2233 return sprintf (buf,"Host power status is Auto-probing\n");
2235 static ssize_t procfs_probe_host_store(struct file *file, const char *buffer, unsigned long count, void *data)
2240 if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1))
2242 value = simple_strtoul(buf, NULL, 10);
2243 probe_host_store(&ifxusb_hcd,value);
2246 static ssize_t procfs_probe_host_show(char *buf, char **start, off_t offset, int count, int *eof, void *data)
2248 return probe_host_show(buf);
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)
2253 static ssize_t sysfs_probe_host_show( struct device *_dev, char *buf)
2256 return probe_host_show(buf);
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 )
2261 static ssize_t sysfs_probe_host_store( struct device *_dev, const char *buffer, size_t count )
2267 if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1))
2269 value = simple_strtoul(buf, NULL, 10);
2270 probe_host_store(&ifxusb_hcd,value);
2273 DEVICE_ATTR(probe_host, S_IRUGO|S_IWUSR, sysfs_probe_host_show, sysfs_probe_host_store);
2276 /////////////////////////////////////////////////////////////////////////////////////////////////////
2277 /////////////////////////////////////////////////////////////////////////////////////////////////////
2278 #ifdef __IS_DEVICE__
2279 static void device_probe(unsigned long _ptr)
2281 if(ifxusb_pcd.power_status == 2)
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);
2289 else if(ifxusb_pcd.power_status == 1)
2291 do_suspend_d(&ifxusb_pcd.core_if);
2292 ifxusb_pcd.power_status = 1;
2295 static void device_autoprobe(unsigned long _ptr)
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);
2303 static void suspend_device_store(uint32_t value)
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;
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);
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);
2328 static ssize_t procfs_suspend_device_store(struct file *file, const char *buffer, unsigned long count, void *data)
2333 if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1))
2335 value = simple_strtoul(buf, NULL, 10);
2336 suspend_device_store(value);
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 )
2342 static ssize_t sysfs_suspend_device_store( struct device *_dev, const char *buffer, size_t count )
2348 if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1))
2350 value = simple_strtoul(buf, NULL, 10);
2351 suspend_device_store(value);
2354 DEVICE_ATTR(suspend_device, S_IWUSR,NULL,sysfs_suspend_device_store);
2356 /////////////////////////////////////////////////////////////////////////////////////////////////////
2357 #ifdef __IS_DEVICE__
2358 static ssize_t probe_device_show(char *buf)
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");
2365 return printk(buf,"Device power status is Auto-probing\n");
2367 static void probe_device_store(uint32_t value)
2370 if(ifxusb_pcd.power_status == 1)
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);
2379 static ssize_t procfs_probe_device_store(struct file *file, const char *buffer, unsigned long count, void *data)
2384 if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1))
2386 value = simple_strtoul(buf, NULL, 10);
2387 probe_device_store(value);
2390 static ssize_t procfs_probe_device_show(char *buf, char **start, off_t offset, int count, int *eof, void *data)
2392 return probe_device_show(buf);
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)
2397 static ssize_t sysfs_probe_device_show( struct device *_dev, char *buf)
2400 return probe_device_show(buf);
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 )
2405 static ssize_t sysfs_probe_device_store( struct device *_dev, const char *buffer, size_t count )
2411 if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1))
2413 value = simple_strtoul(buf, NULL, 10);
2414 probe_device_store(value);
2417 DEVICE_ATTR(probe_device, S_IRUGO|S_IWUSR, sysfs_probe_device_show, sysfs_probe_device_store);
2419 /////////////////////////////////////////////////////////////////////////////////////////////////////
2420 /////////////////////////////////////////////////////////////////////////////////////////////////////
2423 static ssize_t autoprobe_timer2_val_show(char *buf)
2425 return sprintf (buf,"Host 2 auto-probe timer is %d second\n",ifxusb_hcd_2.autoprobe_sec);
2427 static ssize_t procfs_autoprobe_timer2_val_store(struct file *file, const char *buffer, unsigned long count, void *data)
2432 if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1))
2434 value = simple_strtoul(buf, NULL, 10);
2435 if((value > 0)&&(value < 300))
2436 ifxusb_hcd_2.autoprobe_sec = value;
2439 static ssize_t procfs_autoprobe_timer2_val_show(char *buf, char **start, off_t offset, int count, int *eof, void *data)
2441 return autoprobe_timer2_val_show(buf);
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)
2446 static ssize_t sysfs_autoprobe_timer2_val_show( struct device *_dev, char *buf)
2449 return autoprobe_timer2_val_show(buf);
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 )
2454 static ssize_t sysfs_autoprobe_timer2_val_store( struct device *_dev, const char *buffer, size_t count )
2460 if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1))
2462 value = simple_strtoul(buf, NULL, 10);
2463 if((value > 0)&&(value < 300))
2464 ifxusb_hcd_2.autoprobe_sec = value;
2468 static ssize_t autoprobe_timer1_val_show(char *buf)
2470 return sprintf (buf,"Host 1 auto-probe timer is %d second\n",ifxusb_hcd_1.autoprobe_sec);
2472 static ssize_t procfs_autoprobe_timer1_val_store(struct file *file, const char *buffer, unsigned long count, void *data)
2477 if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1))
2479 value = simple_strtoul(buf, NULL, 10);
2480 if((value > 0)&&(value < 300))
2481 ifxusb_hcd_1.autoprobe_sec = value;
2484 static ssize_t procfs_autoprobe_timer1_val_show(char *buf, char **start, off_t offset, int count, int *eof, void *data)
2486 return autoprobe_timer1_val_show(buf);
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)
2491 static ssize_t sysfs_autoprobe_timer1_val_show( struct device *_dev, char *buf)
2494 return autoprobe_timer1_val_show(buf);
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 )
2499 static ssize_t sysfs_autoautoprobe_timer1_val_store( struct device *_dev, const char *buffer, size_t count )
2505 if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1))
2507 value = simple_strtoul(buf, NULL, 10);
2508 if((value > 0)&&(value < 300))
2509 ifxusb_hcd_1.autoprobe_sec = value;
2513 static ssize_t probe_timer2_val_show(char *buf)
2515 return sprintf (buf,"Host 2 probe timer is %d second\n",ifxusb_hcd_2.probe_sec);
2517 static ssize_t procfs_probe_timer2_val_store(struct file *file, const char *buffer, unsigned long count, void *data)
2522 if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1))
2524 value = simple_strtoul(buf, NULL, 10);
2525 if((value > 0)&&(value < 10))
2526 ifxusb_hcd_2.probe_sec = value;
2529 static ssize_t procfs_probe_timer2_val_show(char *buf, char **start, off_t offset, int count, int *eof, void *data)
2531 return probe_timer2_val_show(buf);
2533 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
2534 static ssize_t sysfs_probe_timer2_val_show( struct device *_dev, struct device_attribute *attr,char *buf)
2536 static ssize_t sysfs_probe_timer2_val_show( struct device *_dev, char *buf)
2539 return probe_timer2_val_show(buf);
2541 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
2542 static ssize_t sysfs_probe_timer2_val_store( struct device *_dev, struct device_attribute *attr,const char *buffer, size_t count )
2544 static ssize_t sysfs_probe_timer2_val_store( struct device *_dev, const char *buffer, size_t count )
2550 if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1))
2552 value = simple_strtoul(buf, NULL, 10);
2553 if((value > 0)&&(value < 10))
2554 ifxusb_hcd_2.probe_sec = value;
2558 static ssize_t probe_timer1_val_show(char *buf)
2560 return sprintf (buf,"Host 1 probe timer is %d second\n",ifxusb_hcd_1.probe_sec);
2562 static ssize_t procfs_probe_timer1_val_store(struct file *file, const char *buffer, unsigned long count, void *data)
2567 if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1))
2569 value = simple_strtoul(buf, NULL, 10);
2570 if((value > 0)&&(value < 10))
2571 ifxusb_hcd_1.probe_sec = value;
2574 static ssize_t procfs_probe_timer1_val_show(char *buf, char **start, off_t offset, int count, int *eof, void *data)
2576 return probe_timer1_val_show(buf);
2578 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
2579 static ssize_t sysfs_probe_timer1_val_show( struct device *_dev, struct device_attribute *attr,char *buf)
2581 static ssize_t sysfs_probe_timer1_val_show( struct device *_dev, char *buf)
2584 return probe_timer1_val_show(buf);
2586 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
2587 static ssize_t sysfs_probe_timer1_val_store( struct device *_dev, struct device_attribute *attr,const char *buffer, size_t count )
2589 static ssize_t sysfs_probe_timer1_val_store( struct device *_dev, const char *buffer, size_t count )
2595 if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1))
2597 value = simple_strtoul(buf, NULL, 10);
2598 if((value > 0)&&(value < 10))
2599 ifxusb_hcd_1.probe_sec = value;
2602 DEVICE_ATTR(probe_timer1_val_h, S_IRUGO|S_IWUSR, sysfs_probe_timer1_val_show, sysfs_probe_timer1_val_store);
2603 DEVICE_ATTR(probe_timer2_val_h, S_IRUGO|S_IWUSR, sysfs_probe_timer2_val_show, sysfs_probe_timer2_val_store);
2604 DEVICE_ATTR(autoprobe_timer1_val_h, S_IRUGO|S_IWUSR, sysfs_autoprobe_timer1_val_show, sysfs_autoprobe_timer1_val_store);
2605 DEVICE_ATTR(autoprobe_timer2_val_h, S_IRUGO|S_IWUSR, sysfs_autoprobe_timer2_val_show, sysfs_autoprobe_timer2_val_store);
2607 static ssize_t autoprobe_timer_val_show(char *buf)
2609 return sprintf (buf,"Host auto-probe timer is %d second\n",ifxusb_hcd.autoprobe_sec);
2611 static ssize_t procfs_autoprobe_timer_val_store(struct file *file, const char *buffer, unsigned long count, void *data)
2616 if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1))
2618 value = simple_strtoul(buf, NULL, 10);
2619 if((value > 0)&&(value < 300))
2620 ifxusb_hcd.autoprobe_sec = value;
2623 static ssize_t procfs_autoprobe_timer_val_show(char *buf, char **start, off_t offset, int count, int *eof, void *data)
2625 return autoprobe_timer_val_show(buf);
2627 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
2628 static ssize_t sysfs_autoprobe_timer_val_show( struct device *_dev, struct device_attribute *attr,char *buf)
2630 static ssize_t sysfs_autoprobe_timer_val_show( struct device *_dev, char *buf)
2633 return autoprobe_timer_val_show(buf);
2635 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
2636 static ssize_t sysfs_autoprobe_timer_val_store( struct device *_dev, struct device_attribute *attr,const char *buffer, size_t count )
2638 static ssize_t sysfs_autoautoprobe_timer_val_store( struct device *_dev, const char *buffer, size_t count )
2644 if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1))
2646 value = simple_strtoul(buf, NULL, 10);
2647 if((value > 0)&&(value < 300))
2648 ifxusb_hcd.autoprobe_sec = value;
2651 static ssize_t probe_timer_val_show(char *buf)
2653 return sprintf (buf,"Host probe timer is %d second\n",ifxusb_hcd.probe_sec);
2655 static ssize_t procfs_probe_timer_val_store(struct file *file, const char *buffer, unsigned long count, void *data)
2660 if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1))
2662 value = simple_strtoul(buf, NULL, 10);
2663 if((value > 0)&&(value < 10))
2664 ifxusb_hcd.probe_sec = value;
2667 static ssize_t procfs_probe_timer_val_show(char *buf, char **start, off_t offset, int count, int *eof, void *data)
2669 return probe_timer_val_show(buf);
2671 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
2672 static ssize_t sysfs_probe_timer_val_show( struct device *_dev, struct device_attribute *attr,char *buf)
2674 static ssize_t sysfs_probe_timer_val_show( struct device *_dev, char *buf)
2677 return probe_timer_val_show(buf);
2679 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
2680 static ssize_t sysfs_probe_timer_val_store( struct device *_dev, struct device_attribute *attr,const char *buffer, size_t count )
2682 static ssize_t sysfs_probe_timer_val_store( struct device *_dev, const char *buffer, size_t count )
2688 if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1))
2690 value = simple_strtoul(buf, NULL, 10);
2691 if((value > 0)&&(value < 10))
2692 ifxusb_hcd.probe_sec = value;
2695 DEVICE_ATTR(probe_timer_val_h, S_IRUGO|S_IWUSR, sysfs_probe_timer_val_show, sysfs_probe_timer_val_store);
2696 DEVICE_ATTR(autoprobe_timer_val_h, S_IRUGO|S_IWUSR, sysfs_autoprobe_timer_val_show, sysfs_autoprobe_timer_val_store);
2699 /////////////////////////////////////////////////////////////////////////////////////////////////////
2700 /////////////////////////////////////////////////////////////////////////////////////////////////////
2701 #ifdef __IS_DEVICE__
2702 static ssize_t autoprobe_timer_val_show(char *buf)
2704 return sprintf (buf,"Device auto-probe timer is %d second\n",ifxusb_pcd.autoprobe_sec);
2706 static ssize_t procfs_autoprobe_timer_val_store(struct file *file, const char *buffer, unsigned long count, void *data)
2711 if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1))
2713 value = simple_strtoul(buf, NULL, 10);
2714 if((value > 0)&&(value < 300))
2715 ifxusb_pcd.autoprobe_sec = value;
2718 static ssize_t procfs_autoprobe_timer_val_show(char *buf, char **start, off_t offset, int count, int *eof, void *data)
2720 return autoprobe_timer_val_show(buf);
2722 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
2723 static ssize_t sysfs_autoprobe_timer_val_show( struct device *_dev, struct device_attribute *attr,char *buf)
2725 static ssize_t sysfs_autoprobe_timer_val_show( struct device *_dev, char *buf)
2728 return autoprobe_timer_val_show(buf);
2730 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
2731 static ssize_t sysfs_autoprobe_timer_val_store( struct device *_dev, struct device_attribute *attr,const char *buffer, size_t count )
2733 static ssize_t sysfs_autoautoprobe_timer_val_store( struct device *_dev, const char *buffer, size_t count )
2739 if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1))
2741 value = simple_strtoul(buf, NULL, 10);
2742 if((value > 0)&&(value < 300))
2743 ifxusb_pcd.autoprobe_sec = value;
2746 static ssize_t probe_timer_val_show(char *buf)
2748 return sprintf (buf,"Device probe timer is %d second\n",ifxusb_pcd.probe_sec);
2750 static ssize_t procfs_probe_timer_val_store(struct file *file, const char *buffer, unsigned long count, void *data)
2755 if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1))
2757 value = simple_strtoul(buf, NULL, 10);
2758 if((value > 0)&&(value < 10))
2759 ifxusb_pcd.probe_sec = value;
2762 static ssize_t procfs_probe_timer_val_show(char *buf, char **start, off_t offset, int count, int *eof, void *data)
2764 return probe_timer_val_show(buf);
2766 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
2767 static ssize_t sysfs_probe_timer_val_show( struct device *_dev, struct device_attribute *attr,char *buf)
2769 static ssize_t sysfs_probe_timer_val_show( struct device *_dev, char *buf)
2772 return probe_timer_val_show(buf);
2774 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
2775 static ssize_t sysfs_probe_timer_val_store( struct device *_dev, struct device_attribute *attr,const char *buffer, size_t count )
2777 static ssize_t sysfs_probe_timer_val_store( struct device *_dev, const char *buffer, size_t count )
2783 if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1))
2785 value = simple_strtoul(buf, NULL, 10);
2786 if((value > 0)&&(value < 10))
2787 ifxusb_pcd.probe_sec = value;
2790 DEVICE_ATTR(probe_timer_val_d, S_IRUGO|S_IWUSR, sysfs_probe_timer_val_show, sysfs_probe_timer_val_store);
2791 DEVICE_ATTR(autoprobe_timer_val_d, S_IRUGO|S_IWUSR, sysfs_autoprobe_timer_val_show, sysfs_autoprobe_timer_val_store);
2793 //////////////////////////////////////////////////////////////////////////////////
2794 //////////////////////////////////////////////////////////////////////////////////
2796 static int ifx_proc_addproc(char *funcname, read_proc_t *hookfuncr, write_proc_t *hookfuncw);
2797 static void ifx_proc_delproc(char *funcname);
2799 //////////////////////////////////////////////////////////////////////////////////
2801 #if defined(__IS_HOST__) && defined(__HOST_COC__)
2803 static IFX_PMCU_MODULE_DEP_t depListUSBHost_1=
2807 {IFX_PMCU_MODULE_CPU, IFX_PMCU_STATE_D0, IFX_PMCU_STATE_D0D3, IFX_PMCU_STATE_D0D3, IFX_PMCU_STATE_D0D3}
2810 static IFX_PMCU_MODULE_DEP_t depListUSBHost_2=
2814 {IFX_PMCU_MODULE_CPU, IFX_PMCU_STATE_D0, IFX_PMCU_STATE_D0D3, IFX_PMCU_STATE_D0D3, IFX_PMCU_STATE_D0D3}
2817 // This functions returns the current power state of the module
2818 static IFX_PMCU_RETURN_t
2819 ifx_usbhost_stateGet_1(IFX_PMCU_STATE_t *pmcuModState) {
2820 printk(KERN_DEBUG "ifx_usbhost_stateGet_1 is called\n");
2821 if(ifxusb_hcd_1.power_status == 0){
2822 printk(KERN_DEBUG "current power state of USB Host #1 is D0\n");
2823 *pmcuModState = IFX_PMCU_STATE_D0; // set here the right value
2825 else if(ifxusb_hcd_1.power_status == 1){
2826 printk(KERN_DEBUG "current power state of USB Host #1 is D3 (Suspend)\n");
2827 *pmcuModState = IFX_PMCU_STATE_D3; // set here the right value
2829 else if(ifxusb_hcd_1.power_status == 2){
2830 printk(KERN_DEBUG "current power state of USB Host #1 is D3 (Auto-Probing)\n");
2831 *pmcuModState = IFX_PMCU_STATE_D3; // set here the right value
2834 printk(KERN_DEBUG "current power state of USB Host #1 is unknown (%d)\n",ifxusb_hcd_1.power_status);
2835 *pmcuModState = IFX_PMCU_STATE_INVALID; // must be set to INVALID
2837 return IFX_PMCU_RETURN_SUCCESS;
2839 static IFX_PMCU_RETURN_t
2840 ifx_usbhost_stateGet_2(IFX_PMCU_STATE_t *pmcuModState) {
2841 printk(KERN_DEBUG "ifx_usbhost_stateGet_2 is called\n");
2842 if(ifxusb_hcd_2.power_status == 0){
2843 printk(KERN_DEBUG "current power state of USB Host #2 is D0\n");
2844 *pmcuModState = IFX_PMCU_STATE_D0; // set here the right value
2846 else if(ifxusb_hcd_2.power_status == 1){
2847 printk(KERN_DEBUG "current power state of USB Host #2 is D3 (Suspend)\n");
2848 *pmcuModState = IFX_PMCU_STATE_D3; // set here the right value
2850 else if(ifxusb_hcd_2.power_status == 2){
2851 printk(KERN_DEBUG "current power state of USB Host #2 is D3 (Auto-Probing)\n");
2852 *pmcuModState = IFX_PMCU_STATE_D3; // set here the right value
2855 printk(KERN_DEBUG "current power state of USB Host #2 is unknown (%d)\n",ifxusb_hcd_2.power_status);
2856 *pmcuModState = IFX_PMCU_STATE_INVALID; // must be set to INVALID
2858 return IFX_PMCU_RETURN_SUCCESS;
2862 // The function should be used to enable/disable the module specific power saving methods
2863 static IFX_PMCU_RETURN_t
2864 ifx_usbhost_pwrFeatureSwitch_1(IFX_PMCU_PWR_STATE_ENA_t pmcuPwrStateEna)
2866 if (pmcuPwrStateEna == IFX_PMCU_PWR_STATE_ON) {
2867 suspend_host_store(&ifxusb_hcd_1, 0);
2868 return IFX_PMCU_RETURN_SUCCESS;
2870 if (pmcuPwrStateEna == IFX_PMCU_PWR_STATE_OFF) {
2871 suspend_host_store(&ifxusb_hcd_1, 1);
2872 return IFX_PMCU_RETURN_SUCCESS;
2874 return IFX_PMCU_RETURN_SUCCESS;
2876 static IFX_PMCU_RETURN_t
2877 ifx_usbhost_pwrFeatureSwitch_2(IFX_PMCU_PWR_STATE_ENA_t pmcuPwrStateEna)
2879 if (pmcuPwrStateEna == IFX_PMCU_PWR_STATE_ON) {
2880 suspend_host_store(&ifxusb_hcd_2, 0);
2881 return IFX_PMCU_RETURN_SUCCESS;
2883 if (pmcuPwrStateEna == IFX_PMCU_PWR_STATE_OFF) {
2884 suspend_host_store(&ifxusb_hcd_2, 1);
2885 return IFX_PMCU_RETURN_SUCCESS;
2887 return IFX_PMCU_RETURN_SUCCESS;
2890 // This function should be used to do all the necessary clean-up's before a the real
2891 // power state change is initiated; e.g. flush all serial buffers inside the UART before
2892 // the frequency will be changed.
2893 static IFX_PMCU_RETURN_t
2894 ifx_usbhost_preChange_1(IFX_PMCU_MODULE_t pmcuModule, IFX_PMCU_STATE_t newState, IFX_PMCU_STATE_t oldState)
2896 printk(KERN_DEBUG "ifx_usbhost_preChange_1 is called\n");
2897 return IFX_PMCU_RETURN_SUCCESS;
2899 static IFX_PMCU_RETURN_t
2900 ifx_usbhost_preChange_2(IFX_PMCU_MODULE_t pmcuModule, IFX_PMCU_STATE_t newState, IFX_PMCU_STATE_t oldState)
2902 printk(KERN_DEBUG "ifx_usbhost_preChange_2 is called\n");
2903 return IFX_PMCU_RETURN_SUCCESS;
2907 // This function initiate the real power state change. The module should do all the necessary
2908 // adpations to the new state.
2909 static IFX_PMCU_RETURN_t
2910 ifx_usbhost_stateChange_1(IFX_PMCU_STATE_t newState)
2912 printk(KERN_DEBUG "ifx_usbhost_stateChange_1 is called\n");
2913 if (newState == IFX_PMCU_STATE_D0) {
2914 suspend_host_store(&ifxusb_hcd_1, 0);
2915 return IFX_PMCU_RETURN_SUCCESS;
2917 if (newState == IFX_PMCU_STATE_D1) {
2918 suspend_host_store(&ifxusb_hcd_1, 1);
2919 return IFX_PMCU_RETURN_SUCCESS;
2921 if (newState == IFX_PMCU_STATE_D2) {
2922 suspend_host_store(&ifxusb_hcd_1, 1);
2923 return IFX_PMCU_RETURN_SUCCESS;
2925 if (newState == IFX_PMCU_STATE_D3) {
2926 suspend_host_store(&ifxusb_hcd_1, 1);
2927 return IFX_PMCU_RETURN_SUCCESS;
2929 return IFX_PMCU_RETURN_SUCCESS;
2931 static IFX_PMCU_RETURN_t
2932 ifx_usbhost_stateChange_2(IFX_PMCU_STATE_t newState)
2934 printk(KERN_DEBUG "ifx_usbhost_stateChange_2 is called\n");
2935 if (newState == IFX_PMCU_STATE_D0) {
2936 suspend_host_store(&ifxusb_hcd_2, 0);
2937 return IFX_PMCU_RETURN_SUCCESS;
2939 if (newState == IFX_PMCU_STATE_D1) {
2940 suspend_host_store(&ifxusb_hcd_2, 1);
2941 return IFX_PMCU_RETURN_SUCCESS;
2943 if (newState == IFX_PMCU_STATE_D2) {
2944 suspend_host_store(&ifxusb_hcd_2, 1);
2945 return IFX_PMCU_RETURN_SUCCESS;
2947 if (newState == IFX_PMCU_STATE_D3) {
2948 suspend_host_store(&ifxusb_hcd_2, 1);
2949 return IFX_PMCU_RETURN_SUCCESS;
2951 return IFX_PMCU_RETURN_SUCCESS;
2954 // This function should be used to do all the necessary post processing after a the real
2955 // power state change was initiated.
2956 static IFX_PMCU_RETURN_t
2957 ifx_usbhost_postChange_1(IFX_PMCU_MODULE_t pmcuModule, IFX_PMCU_STATE_t newState, IFX_PMCU_STATE_t oldState)
2959 printk(KERN_DEBUG "ifx_usbhost_postChange_1 is called\n");
2960 return IFX_PMCU_RETURN_SUCCESS;
2962 static IFX_PMCU_RETURN_t
2963 ifx_usbhost_postChange_2(IFX_PMCU_MODULE_t pmcuModule, IFX_PMCU_STATE_t newState, IFX_PMCU_STATE_t oldState)
2965 printk(KERN_DEBUG "ifx_usbhost_postChange_2 is called\n");
2966 return IFX_PMCU_RETURN_SUCCESS;
2969 static IFX_PMCU_MODULE_DEP_t depListUSBHost=
2973 {IFX_PMCU_MODULE_CPU, IFX_PMCU_STATE_D0, IFX_PMCU_STATE_D0D3, IFX_PMCU_STATE_D0D3, IFX_PMCU_STATE_D0D3}
2976 // This functions returns the current power state of the module
2977 static IFX_PMCU_RETURN_t
2978 ifx_usbhost_stateGet(IFX_PMCU_STATE_t *pmcuModState) {
2979 printk(KERN_DEBUG "ifx_usbhost_stateGet is called\n");
2980 if(ifxusb_hcd.power_status == 0){
2981 printk(KERN_DEBUG "current power state of USB Host is D0\n");
2982 *pmcuModState = IFX_PMCU_STATE_D0; // set here the right value
2984 else if(ifxusb_hcd.power_status == 1){
2985 printk(KERN_DEBUG "current power state of USB Host is D3 (Suspend)\n");
2986 *pmcuModState = IFX_PMCU_STATE_D3; // set here the right value
2988 else if(ifxusb_hcd.power_status == 2){
2989 printk(KERN_DEBUG "current power state of USB Host is D3 (Auto-Probing)\n");
2990 *pmcuModState = IFX_PMCU_STATE_D3; // set here the right value
2993 printk(KERN_DEBUG "current power state of USB Host is unknown (%d)\n",ifxusb_hcd.power_status);
2994 *pmcuModState = IFX_PMCU_STATE_INVALID; // must be set to INVALID
2996 return IFX_PMCU_RETURN_SUCCESS;
2998 // The function should be used to enable/disable the module specific power saving methods
2999 static IFX_PMCU_RETURN_t
3000 ifx_usbhost_pwrFeatureSwitch(IFX_PMCU_PWR_STATE_ENA_t pmcuPwrStateEna)
3002 if (pmcuPwrStateEna == IFX_PMCU_PWR_STATE_ON) {
3003 suspend_host_store(&ifxusb_hcd, 0);
3004 return IFX_PMCU_RETURN_SUCCESS;
3006 if (pmcuPwrStateEna == IFX_PMCU_PWR_STATE_OFF) {
3007 suspend_host_store(&ifxusb_hcd, 1);
3008 return IFX_PMCU_RETURN_SUCCESS;
3010 return IFX_PMCU_RETURN_SUCCESS;
3013 // This function should be used to do all the necessary clean-up's before a the real
3014 // power state change is initiated; e.g. flush all serial buffers inside the UART before
3015 // the frequency will be changed.
3016 static IFX_PMCU_RETURN_t
3017 ifx_usbhost_preChange(IFX_PMCU_MODULE_t pmcuModule, IFX_PMCU_STATE_t newState, IFX_PMCU_STATE_t oldState)
3019 printk(KERN_DEBUG "ifx_usbhost_preChange is called\n");
3020 return IFX_PMCU_RETURN_SUCCESS;
3024 // This function initiate the real power state change. The module should do all the necessary
3025 // adpations to the new state.
3026 static IFX_PMCU_RETURN_t
3027 ifx_usbhost_stateChange(IFX_PMCU_STATE_t newState)
3029 printk(KERN_DEBUG "ifx_usbhost_stateChange is called\n");
3030 if (newState == IFX_PMCU_STATE_D0) {
3031 suspend_host_store(&ifxusb_hcd, 0);
3032 return IFX_PMCU_RETURN_SUCCESS;
3034 if (newState == IFX_PMCU_STATE_D1) {
3035 suspend_host_store(&ifxusb_hcd, 1);
3036 return IFX_PMCU_RETURN_SUCCESS;
3038 if (newState == IFX_PMCU_STATE_D2) {
3039 suspend_host_store(&ifxusb_hcd, 1);
3040 return IFX_PMCU_RETURN_SUCCESS;
3042 if (newState == IFX_PMCU_STATE_D3) {
3043 suspend_host_store(&ifxusb_hcd, 1);
3044 return IFX_PMCU_RETURN_SUCCESS;
3046 return IFX_PMCU_RETURN_SUCCESS;
3049 // This function should be used to do all the necessary post processing after a the real
3050 // power state change was initiated.
3051 static IFX_PMCU_RETURN_t
3052 ifx_usbhost_postChange(IFX_PMCU_MODULE_t pmcuModule, IFX_PMCU_STATE_t newState, IFX_PMCU_STATE_t oldState)
3054 printk(KERN_DEBUG "ifx_usbhost_postChange is called\n");
3055 return IFX_PMCU_RETURN_SUCCESS;
3059 #if defined(__IS_DEVICE__) && defined(__GADGET_COC__)
3060 static IFX_PMCU_MODULE_DEP_t depListUSBGadget=
3064 {IFX_PMCU_MODULE_CPU, IFX_PMCU_STATE_D0, IFX_PMCU_STATE_D0D3, IFX_PMCU_STATE_D0D3, IFX_PMCU_STATE_D0D3}
3067 // This functions returns the current power state of the module
3068 static IFX_PMCU_RETURN_t
3069 ifx_usbgadget_stateGet(IFX_PMCU_STATE_t *pmcuModState) {
3070 printk(KERN_DEBUG "ifx_usbgadget_stateGet is called\n");
3071 if(ifxusb_pcd.power_status == 0){
3072 printk(KERN_DEBUG "current power state of USB Gadget is D0\n");
3073 *pmcuModState = IFX_PMCU_STATE_D0; // set here the right value
3075 else if(ifxusb_pcd.power_status == 1){
3076 printk(KERN_DEBUG "current power state of USB Gadget is D3 (Suspend)\n");
3077 *pmcuModState = IFX_PMCU_STATE_D3; // set here the right value
3079 else if(ifxusb_pcd.power_status == 2){
3080 printk(KERN_DEBUG "current power state of USB Gadget is D3 (Auto-Probing)\n");
3081 *pmcuModState = IFX_PMCU_STATE_D3; // set here the right value
3084 printk(KERN_DEBUG "current power state of USB Gadget is unknown (%d)\n",ifxusb_pcd.power_status);
3085 *pmcuModState = IFX_PMCU_STATE_INVALID; // must be set to INVALID
3087 return IFX_PMCU_RETURN_SUCCESS;
3089 // The function should be used to enable/disable the module specific power saving methods
3090 static IFX_PMCU_RETURN_t
3091 ifx_usbgadget_pwrFeatureSwitch(IFX_PMCU_PWR_STATE_ENA_t pmcuPwrStateEna)
3093 if (pmcuPwrStateEna == IFX_PMCU_PWR_STATE_ON) {
3094 suspend_device_store(0);
3095 return IFX_PMCU_RETURN_SUCCESS;
3097 if (pmcuPwrStateEna == IFX_PMCU_PWR_STATE_OFF) {
3098 suspend_device_store(1);
3099 return IFX_PMCU_RETURN_SUCCESS;
3101 return IFX_PMCU_RETURN_SUCCESS;
3104 // This function should be used to do all the necessary clean-up's before a the real
3105 // power state change is initiated; e.g. flush all serial buffers inside the UART before
3106 // the frequency will be changed.
3107 static IFX_PMCU_RETURN_t
3108 ifx_usbgadget_preChange(IFX_PMCU_MODULE_t pmcuModule, IFX_PMCU_STATE_t newState, IFX_PMCU_STATE_t oldState)
3110 printk(KERN_DEBUG "ifx_usbgadget_preChange is called\n");
3111 return IFX_PMCU_RETURN_SUCCESS;
3115 // This function initiate the real power state change. The module should do all the necessary
3116 // adpations to the new state.
3117 static IFX_PMCU_RETURN_t
3118 ifx_usbgadget_stateChange(IFX_PMCU_STATE_t newState)
3120 printk(KERN_DEBUG "ifx_usbgadget_stateChange is called\n");
3121 if (newState == IFX_PMCU_STATE_D0) {
3122 suspend_device_store(0);
3123 return IFX_PMCU_RETURN_SUCCESS;
3125 if (newState == IFX_PMCU_STATE_D1) {
3126 suspend_device_store(1);
3127 return IFX_PMCU_RETURN_SUCCESS;
3129 if (newState == IFX_PMCU_STATE_D2) {
3130 suspend_device_store(1);
3131 return IFX_PMCU_RETURN_SUCCESS;
3133 if (newState == IFX_PMCU_STATE_D3) {
3134 suspend_device_store(1);
3135 return IFX_PMCU_RETURN_SUCCESS;
3137 return IFX_PMCU_RETURN_SUCCESS;
3140 // This function should be used to do all the necessary post processing after a the real
3141 // power state change was initiated.
3142 static IFX_PMCU_RETURN_t
3143 ifx_usbgadget_postChange(IFX_PMCU_MODULE_t pmcuModule, IFX_PMCU_STATE_t newState, IFX_PMCU_STATE_t oldState)
3145 printk(KERN_DEBUG "ifx_usbgadget_postChange is called\n");
3146 return IFX_PMCU_RETURN_SUCCESS;
3152 \brief This function create the sysfs and procfs entries
3153 \param[in] _dev Pointer of device structure, if applied
3156 void ifxusb_attr_create_h (void *_dev)
3158 void ifxusb_attr_create_d (void *_dev)
3163 struct device *dev = (struct device *) _dev;
3165 IFX_DEBUGPL(DBG_ENTRY, "%s() %d\n", __func__, __LINE__ );
3167 error = ifx_proc_addproc("dbglevel", procfs_dbglevel_show, procfs_dbglevel_store);
3169 error = device_create_file(dev, &dev_attr_dbglevel_h);
3171 error = device_create_file(dev, &dev_attr_dbglevel_d);
3176 error = ifx_proc_addproc("dump_params_1", procfs_dump_params_show_1, NULL);
3177 error = ifx_proc_addproc("dump_params_2", procfs_dump_params_show_2, NULL);
3178 error = device_create_file(dev, &dev_attr_dump_params_h_1);
3179 error = device_create_file(dev, &dev_attr_dump_params_h_2);
3181 error = ifx_proc_addproc("mode_1", procfs_mode_show_1, NULL);
3182 error = ifx_proc_addproc("mode_2", procfs_mode_show_2, NULL);
3183 error = device_create_file(dev, &dev_attr_mode_h_1);
3184 error = device_create_file(dev, &dev_attr_mode_h_2);
3186 error = ifx_proc_addproc("dump_params", procfs_dump_params_show, NULL);
3187 error = device_create_file(dev, &dev_attr_dump_params_h);
3188 error = ifx_proc_addproc("mode", procfs_mode_show, NULL);
3189 error = device_create_file(dev, &dev_attr_mode_h);
3192 error = ifx_proc_addproc("dump_params", procfs_dump_params_show, NULL);
3193 error = device_create_file(dev, &dev_attr_dump_params_d);
3195 error = ifx_proc_addproc("mode", procfs_mode_show, NULL);
3196 error = device_create_file(dev, &dev_attr_mode_d);
3200 error = ifx_proc_addproc("version", procfs_version_show, NULL);
3201 error = device_create_file(dev, &dev_attr_version_h);
3203 error = ifx_proc_addproc("version", procfs_version_show, NULL);
3204 error = device_create_file(dev, &dev_attr_version_d);
3210 error = ifx_proc_addproc("pkt_count_limit_bi_1", procfs_pkt_count_limit_bi_show_1, procfs_pkt_count_limit_bi_store_1);
3211 error = ifx_proc_addproc("pkt_count_limit_bo_1", procfs_pkt_count_limit_bo_show_1, procfs_pkt_count_limit_bo_store_1);
3212 error = ifx_proc_addproc("pkt_count_limit_bi_2", procfs_pkt_count_limit_bi_show_2, procfs_pkt_count_limit_bi_store_2);
3213 error = ifx_proc_addproc("pkt_count_limit_bo_2", procfs_pkt_count_limit_bo_show_2, procfs_pkt_count_limit_bo_store_2);
3214 error = ifx_proc_addproc("bandwidth_hs_1", procfs_bandwidth_hs_show_1, procfs_bandwidth_hs_store_1);
3215 error = ifx_proc_addproc("bandwidth_fs_1", procfs_bandwidth_fs_show_1, procfs_bandwidth_fs_store_1);
3216 error = ifx_proc_addproc("bandwidth_ls_1", procfs_bandwidth_ls_show_1, procfs_bandwidth_ls_store_1);
3217 error = ifx_proc_addproc("bandwidth_hs_2", procfs_bandwidth_hs_show_2, procfs_bandwidth_hs_store_2);
3218 error = ifx_proc_addproc("bandwidth_fs_2", procfs_bandwidth_fs_show_2, procfs_bandwidth_fs_store_2);
3219 error = ifx_proc_addproc("bandwidth_ls_2", procfs_bandwidth_ls_show_2, procfs_bandwidth_ls_store_2);
3220 error = device_create_file(dev, &dev_attr_pkt_count_limit_bi_1);
3221 error = device_create_file(dev, &dev_attr_pkt_count_limit_bo_1);
3222 error = device_create_file(dev, &dev_attr_pkt_count_limit_bi_2);
3223 error = device_create_file(dev, &dev_attr_pkt_count_limit_bo_2);
3224 error = device_create_file(dev, &dev_attr_bandwidth_hs_1);
3225 error = device_create_file(dev, &dev_attr_bandwidth_fs_1);
3226 error = device_create_file(dev, &dev_attr_bandwidth_ls_1);
3227 error = device_create_file(dev, &dev_attr_bandwidth_hs_2);
3228 error = device_create_file(dev, &dev_attr_bandwidth_fs_2);
3229 error = device_create_file(dev, &dev_attr_bandwidth_ls_2);
3231 error = ifx_proc_addproc("pkt_count_limit_bi", procfs_pkt_count_limit_bi_show, procfs_pkt_count_limit_bi_store);
3232 error = ifx_proc_addproc("pkt_count_limit_bo", procfs_pkt_count_limit_bo_show, procfs_pkt_count_limit_bo_store);
3233 error = ifx_proc_addproc("bandwidth_hs", procfs_bandwidth_hs_show, procfs_bandwidth_hs_store);
3234 error = ifx_proc_addproc("bandwidth_fs", procfs_bandwidth_fs_show, procfs_bandwidth_fs_store);
3235 error = ifx_proc_addproc("bandwidth_ls", procfs_bandwidth_ls_show, procfs_bandwidth_ls_store);
3236 error = device_create_file(dev, &dev_attr_pkt_count_limit_bi);
3237 error = device_create_file(dev, &dev_attr_pkt_count_limit_bo);
3238 error = device_create_file(dev, &dev_attr_bandwidth_hs);
3239 error = device_create_file(dev, &dev_attr_bandwidth_fs);
3240 error = device_create_file(dev, &dev_attr_bandwidth_ls);
3244 error = ifx_proc_addproc("buspower_1", procfs_buspower_show_1, procfs_buspower_store_1);
3245 error = ifx_proc_addproc("buspower_2", procfs_buspower_show_2, procfs_buspower_store_2);
3246 error = device_create_file(dev, &dev_attr_buspower_1);
3247 error = device_create_file(dev, &dev_attr_buspower_2);
3249 error = ifx_proc_addproc("buspower", procfs_buspower_show, procfs_buspower_store);
3250 error = device_create_file(dev, &dev_attr_buspower);
3254 error = ifx_proc_addproc("bussuspend_1", procfs_bussuspend_show_1, NULL);
3255 error = ifx_proc_addproc("bussuspend_2", procfs_bussuspend_show_2, NULL);
3256 error = device_create_file(dev, &dev_attr_bussuspend_1);
3257 error = device_create_file(dev, &dev_attr_bussuspend_2);
3259 error = ifx_proc_addproc("bussuspend", procfs_bussuspend_show, NULL);
3260 error = device_create_file(dev, &dev_attr_bussuspend);
3264 error = ifx_proc_addproc("busconnected_1", procfs_busconnected_show_1, NULL);
3265 error = ifx_proc_addproc("busconnected_2", procfs_busconnected_show_2, NULL);
3266 error = device_create_file(dev, &dev_attr_busconnected_1);
3267 error = device_create_file(dev, &dev_attr_busconnected_2);
3269 error = ifx_proc_addproc("busconnected", procfs_busconnected_show, NULL);
3270 error = device_create_file(dev, &dev_attr_busconnected);
3274 error = ifx_proc_addproc("connectspeed_1", procfs_connectspeed_show_1, NULL);
3275 error = ifx_proc_addproc("connectspeed_2", procfs_connectspeed_show_2, NULL);
3276 error = device_create_file(dev, &dev_attr_connectspeed_1);
3277 error = device_create_file(dev, &dev_attr_connectspeed_2);
3279 error = ifx_proc_addproc("connectspeed", procfs_connectspeed_show, NULL);
3280 error = device_create_file(dev, &dev_attr_connectspeed);
3284 #ifdef __IS_DEVICE__
3285 error = ifx_proc_addproc("devspeed", procfs_devspeed_show, NULL);
3286 error = device_create_file(dev, &dev_attr_devspeed);
3287 error = ifx_proc_addproc("enumspeed", procfs_enumspeed_show, NULL);
3288 error = device_create_file(dev, &dev_attr_enumspeed);
3291 //////////////////////////////////////////////////////
3292 #ifdef __ENABLE_DUMP__
3296 error = ifx_proc_addproc("dump_reg_1", procfs_dump_reg_show_1, NULL);
3297 error = ifx_proc_addproc("dump_reg_2", procfs_dump_reg_show_2, NULL);
3298 error = device_create_file(dev, &dev_attr_dump_reg_h_1);
3299 error = device_create_file(dev, &dev_attr_dump_reg_h_2);
3301 error = ifx_proc_addproc("dump_reg", procfs_dump_reg_show, NULL);
3302 error = device_create_file(dev, &dev_attr_dump_reg_h);
3306 error = ifx_proc_addproc("dump_spram_1", procfs_dump_spram_show_1, NULL);
3307 error = ifx_proc_addproc("dump_spram_2", procfs_dump_spram_show_2, NULL);
3308 error = device_create_file(dev, &dev_attr_dump_spram_h_1);
3309 error = device_create_file(dev, &dev_attr_dump_spram_h_2);
3311 error = ifx_proc_addproc("dump_spram", procfs_dump_spram_show, NULL);
3312 error = device_create_file(dev, &dev_attr_dump_spram_h);
3316 error = ifx_proc_addproc("dump_host_state_1", procfs_dump_host_state_show_1, NULL);
3317 error = ifx_proc_addproc("dump_host_state_2", procfs_dump_host_state_show_2, NULL);
3318 error = device_create_file(dev, &dev_attr_dump_host_state_1);
3319 error = device_create_file(dev, &dev_attr_dump_host_state_2);
3321 error = ifx_proc_addproc("dump_host_state", procfs_dump_host_state_show, NULL);
3322 error = device_create_file(dev, &dev_attr_dump_host_state);
3325 error = ifx_proc_addproc("dump_reg", procfs_dump_reg_show, NULL);
3326 error = device_create_file(dev, &dev_attr_dump_reg_d);
3327 error = ifx_proc_addproc("dump_spram", procfs_dump_spram_show, NULL);
3328 error = device_create_file(dev, &dev_attr_dump_spram_d);
3330 #endif //__ENABLE_DUMP__
3331 //////////////////////////////////////////////////////
3334 error = ifx_proc_addproc("suspend_host_1",NULL, procfs_suspend_host_1_store);
3335 error = device_create_file(dev, &dev_attr_suspend_host_1);
3337 error = ifx_proc_addproc("probe_host_1", procfs_probe_host_1_show, procfs_probe_host_1_store);
3338 error = device_create_file(dev, &dev_attr_probe_host_1);
3340 error = ifx_proc_addproc("suspend_host_2",NULL, procfs_suspend_host_2_store);
3341 error = device_create_file(dev, &dev_attr_suspend_host_2);
3343 error = ifx_proc_addproc("probe_host_2", procfs_probe_host_2_show, procfs_probe_host_2_store);
3344 error = device_create_file(dev, &dev_attr_probe_host_2);
3346 error = ifx_proc_addproc("probe_timer1", procfs_probe_timer1_val_show, procfs_probe_timer1_val_store);
3347 error = device_create_file(dev, &dev_attr_probe_timer1_val_h);
3349 error = ifx_proc_addproc("probe_timer2", procfs_probe_timer2_val_show, procfs_probe_timer2_val_store);
3350 error = device_create_file(dev, &dev_attr_probe_timer2_val_h);
3352 error = ifx_proc_addproc("autoprobe_timer1", procfs_autoprobe_timer1_val_show, procfs_autoprobe_timer1_val_store);
3353 error = device_create_file(dev, &dev_attr_autoprobe_timer1_val_h);
3355 error = ifx_proc_addproc("autoprobe_timer2", procfs_autoprobe_timer2_val_show, procfs_autoprobe_timer2_val_store);
3356 error = device_create_file(dev, &dev_attr_autoprobe_timer2_val_h);
3358 error = ifx_proc_addproc("suspend_host",NULL, procfs_suspend_host_store);
3359 error = device_create_file(dev, &dev_attr_suspend_host);
3361 error = ifx_proc_addproc("probe_host", procfs_probe_host_show, procfs_probe_host_store);
3362 error = device_create_file(dev, &dev_attr_probe_host);
3364 error = ifx_proc_addproc("probe_timer", procfs_probe_timer_val_show, procfs_probe_timer_val_store);
3365 error = device_create_file(dev, &dev_attr_probe_timer_val_h);
3367 error = ifx_proc_addproc("autoprobe_timer", procfs_autoprobe_timer_val_show, procfs_autoprobe_timer_val_store);
3368 error = device_create_file(dev, &dev_attr_autoprobe_timer_val_h);
3372 #ifdef __IS_DEVICE__
3373 error = ifx_proc_addproc("suspend_device",NULL, procfs_suspend_device_store);
3374 error = device_create_file(dev, &dev_attr_suspend_device);
3376 error = ifx_proc_addproc("probe_device", procfs_probe_device_show, procfs_probe_device_store);
3377 error = device_create_file(dev, &dev_attr_probe_device);
3379 error = ifx_proc_addproc("probe_timer", procfs_probe_timer_val_show, procfs_probe_timer_val_store);
3380 error = device_create_file(dev, &dev_attr_probe_timer_val_d);
3382 error = ifx_proc_addproc("autoprobe_timer", procfs_autoprobe_timer_val_show, procfs_autoprobe_timer_val_store);
3383 error = device_create_file(dev, &dev_attr_autoprobe_timer_val_d);
3385 #if defined(__IS_HOST__) && defined(__HOST_COC__)
3387 memset (&pmcuRegisterUSBHost_1, 0, sizeof(pmcuRegisterUSBHost_1));
3388 memset (&pmcuRegisterUSBHost_2, 0, sizeof(pmcuRegisterUSBHost_2));
3389 pmcuRegisterUSBHost_1.pmcuModule=
3390 pmcuRegisterUSBHost_2.pmcuModule=IFX_PMCU_MODULE_USB;
3391 pmcuRegisterUSBHost_1.pmcuModuleNr=1;
3392 pmcuRegisterUSBHost_2.pmcuModuleNr=2;
3393 pmcuRegisterUSBHost_1.pmcuModuleDep = &depListUSBHost_1;
3394 pmcuRegisterUSBHost_2.pmcuModuleDep = &depListUSBHost_2;
3395 pmcuRegisterUSBHost_1.pre = ifx_usbhost_preChange_1;
3396 pmcuRegisterUSBHost_2.pre = ifx_usbhost_preChange_2;
3397 pmcuRegisterUSBHost_1.post = ifx_usbhost_postChange_1;
3398 pmcuRegisterUSBHost_2.post = ifx_usbhost_postChange_2;
3399 pmcuRegisterUSBHost_1.ifx_pmcu_state_change = ifx_usbhost_stateChange_1;
3400 pmcuRegisterUSBHost_2.ifx_pmcu_state_change = ifx_usbhost_stateChange_2;
3401 pmcuRegisterUSBHost_1.ifx_pmcu_state_get = ifx_usbhost_stateGet_1;
3402 pmcuRegisterUSBHost_2.ifx_pmcu_state_get = ifx_usbhost_stateGet_2;
3403 pmcuRegisterUSBHost_1.ifx_pmcu_pwr_feature_switch = ifx_usbhost_pwrFeatureSwitch_1;
3404 pmcuRegisterUSBHost_2.ifx_pmcu_pwr_feature_switch = ifx_usbhost_pwrFeatureSwitch_2;
3405 ifx_pmcu_register ( &pmcuRegisterUSBHost_1 );
3406 ifx_pmcu_register ( &pmcuRegisterUSBHost_2 );
3408 memset (&pmcuRegisterUSBHost, 0, sizeof(pmcuRegisterUSBHost));
3409 pmcuRegisterUSBHost.pmcuModule=IFX_PMCU_MODULE_USB;
3410 pmcuRegisterUSBHost.pmcuModuleNr=1;
3411 pmcuRegisterUSBHost.pmcuModuleDep = &depListUSBHost;
3412 pmcuRegisterUSBHost.pre = ifx_usbhost_preChange;
3413 pmcuRegisterUSBHost.post = ifx_usbhost_postChange;
3414 pmcuRegisterUSBHost.ifx_pmcu_state_change = ifx_usbhost_stateChange;
3415 pmcuRegisterUSBHost.ifx_pmcu_state_get = ifx_usbhost_stateGet;
3416 pmcuRegisterUSBHost.ifx_pmcu_pwr_feature_switch = ifx_usbhost_pwrFeatureSwitch;
3417 ifx_pmcu_register ( &pmcuRegisterUSBHost );
3420 #if defined(__IS_DEVICE__) && defined(__GADGET_COC__)
3421 memset (&pmcuRegisterUSBGadget, 0, sizeof(pmcuRegisterUSBGadget));
3422 pmcuRegisterUSBGadget.pmcuModule=IFX_PMCU_MODULE_USB;
3423 pmcuRegisterUSBGadget.pmcuModuleNr=0;
3424 pmcuRegisterUSBGadget.pmcuModuleDep = &depListUSBGadget;
3425 pmcuRegisterUSBGadget.pre = ifx_usbgadget_preChange;
3426 pmcuRegisterUSBGadget.post = ifx_usbgadget_postChange;
3427 pmcuRegisterUSBGadget.ifx_pmcu_state_change = ifx_usbgadget_stateChange;
3428 pmcuRegisterUSBGadget.ifx_pmcu_state_get = ifx_usbgadget_stateGet;
3429 pmcuRegisterUSBGadget.ifx_pmcu_pwr_feature_switch = ifx_usbgadget_pwrFeatureSwitch;
3430 ifx_pmcu_register ( &pmcuRegisterUSBGadget );
3436 \brief This function remove the sysfs and procfs entries
3437 \param[in] _dev Pointer of device structure, if applied
3440 void ifxusb_attr_remove_h (void *_dev)
3442 void ifxusb_attr_remove_d (void *_dev)
3445 struct device *dev = (struct device *) _dev;
3447 IFX_DEBUGPL(DBG_ENTRY, "%s() %d\n", __func__, __LINE__ );
3448 ifx_proc_delproc("dbglevel");
3450 device_remove_file(dev, &dev_attr_dbglevel_h);
3452 device_remove_file(dev, &dev_attr_dbglevel_d);
3457 ifx_proc_delproc("dump_params_1");
3458 ifx_proc_delproc("dump_params_2");
3459 device_remove_file(dev, &dev_attr_dump_params_h_1);
3460 device_remove_file(dev, &dev_attr_dump_params_h_2);
3462 ifx_proc_delproc("dump_params");
3463 device_remove_file(dev, &dev_attr_dump_params_h);
3467 ifx_proc_delproc("mode_1");
3468 ifx_proc_delproc("mode_2");
3469 device_remove_file(dev, &dev_attr_mode_h_1);
3470 device_remove_file(dev, &dev_attr_mode_h_2);
3472 ifx_proc_delproc("mode");
3473 device_remove_file(dev, &dev_attr_mode_h);
3476 ifx_proc_delproc("dump_params");
3477 device_remove_file(dev, &dev_attr_dump_params_d);
3478 ifx_proc_delproc("mode");
3479 device_remove_file(dev, &dev_attr_mode_d);
3483 ifx_proc_delproc("version");
3484 device_remove_file(dev, &dev_attr_version_h);
3486 ifx_proc_delproc("version");
3487 device_remove_file(dev, &dev_attr_version_d);
3493 ifx_proc_delproc("pkt_count_limit_bi_1");
3494 ifx_proc_delproc("pkt_count_limit_bo_1");
3495 ifx_proc_delproc("pkt_count_limit_bi_2");
3496 ifx_proc_delproc("pkt_count_limit_bo_2");
3497 ifx_proc_delproc("bandwidth_hs_1");
3498 ifx_proc_delproc("bandwidth_fs_1");
3499 ifx_proc_delproc("bandwidth_ls_1");
3500 ifx_proc_delproc("bandwidth_hs_2");
3501 ifx_proc_delproc("bandwidth_fs_2");
3502 ifx_proc_delproc("bandwidth_ls_2");
3503 device_remove_file(dev, &dev_attr_pkt_count_limit_bi_1);
3504 device_remove_file(dev, &dev_attr_pkt_count_limit_bo_1);
3505 device_remove_file(dev, &dev_attr_pkt_count_limit_bi_2);
3506 device_remove_file(dev, &dev_attr_pkt_count_limit_bo_2);
3507 device_remove_file(dev, &dev_attr_bandwidth_hs_1);
3508 device_remove_file(dev, &dev_attr_bandwidth_fs_1);
3509 device_remove_file(dev, &dev_attr_bandwidth_ls_1);
3510 device_remove_file(dev, &dev_attr_bandwidth_hs_2);
3511 device_remove_file(dev, &dev_attr_bandwidth_fs_2);
3512 device_remove_file(dev, &dev_attr_bandwidth_ls_2);
3514 ifx_proc_delproc("pkt_count_limit_bi");
3515 ifx_proc_delproc("pkt_count_limit_bo");
3516 ifx_proc_delproc("bandwidth_hs");
3517 ifx_proc_delproc("bandwidth_fs");
3518 ifx_proc_delproc("bandwidth_ls");
3519 device_remove_file(dev, &dev_attr_pkt_count_limit_bi);
3520 device_remove_file(dev, &dev_attr_pkt_count_limit_bo);
3521 device_remove_file(dev, &dev_attr_bandwidth_hs);
3522 device_remove_file(dev, &dev_attr_bandwidth_fs);
3523 device_remove_file(dev, &dev_attr_bandwidth_ls);
3529 ifx_proc_delproc("buspower_1");
3530 ifx_proc_delproc("buspower_2");
3531 device_remove_file(dev, &dev_attr_buspower_1);
3532 device_remove_file(dev, &dev_attr_buspower_2);
3534 ifx_proc_delproc("buspower");
3535 device_remove_file(dev, &dev_attr_buspower);
3539 ifx_proc_delproc("bussuspend_1");
3540 ifx_proc_delproc("bussuspend_2");
3541 device_remove_file(dev, &dev_attr_bussuspend_1);
3542 device_remove_file(dev, &dev_attr_bussuspend_2);
3544 ifx_proc_delproc("bussuspend");
3545 device_remove_file(dev, &dev_attr_bussuspend);
3549 ifx_proc_delproc("busconnected_1");
3550 ifx_proc_delproc("busconnected_2");
3551 device_remove_file(dev, &dev_attr_busconnected_1);
3552 device_remove_file(dev, &dev_attr_busconnected_2);
3554 ifx_proc_delproc("busconnected");
3555 device_remove_file(dev, &dev_attr_busconnected);
3559 ifx_proc_delproc("connectspeed_1");
3560 ifx_proc_delproc("connectspeed_2");
3561 device_remove_file(dev, &dev_attr_connectspeed_1);
3562 device_remove_file(dev, &dev_attr_connectspeed_2);
3564 ifx_proc_delproc("connectspeed");
3565 device_remove_file(dev, &dev_attr_connectspeed);
3569 #ifdef __IS_DEVICE__
3570 ifx_proc_delproc("devspeed");
3571 device_remove_file(dev, &dev_attr_devspeed);
3572 ifx_proc_delproc("enumspeed");
3573 device_remove_file(dev, &dev_attr_enumspeed);
3576 #ifdef __ENABLE_DUMP__
3579 ifx_proc_delproc("dump_reg_1");
3580 ifx_proc_delproc("dump_reg_2");
3581 device_remove_file(dev, &dev_attr_dump_reg_h_1);
3582 device_remove_file(dev, &dev_attr_dump_reg_h_2);
3584 ifx_proc_delproc("dump_reg");
3585 device_remove_file(dev, &dev_attr_dump_reg_h);
3589 ifx_proc_delproc("dump_spram_1");
3590 ifx_proc_delproc("dump_spram_2");
3591 device_remove_file(dev, &dev_attr_dump_spram_h_1);
3592 device_remove_file(dev, &dev_attr_dump_spram_h_2);
3594 ifx_proc_delproc("dump_spram");
3595 device_remove_file(dev, &dev_attr_dump_spram_h);
3599 ifx_proc_delproc("dump_host_state_1");
3600 ifx_proc_delproc("dump_host_state_2");
3601 device_remove_file(dev, &dev_attr_dump_host_state_1);
3602 device_remove_file(dev, &dev_attr_dump_host_state_2);
3604 ifx_proc_delproc("dump_host_state");
3605 device_remove_file(dev, &dev_attr_dump_host_state);
3608 ifx_proc_delproc("dump_reg");
3609 device_remove_file(dev, &dev_attr_dump_reg_d);
3610 ifx_proc_delproc("dump_spram");
3611 device_remove_file(dev, &dev_attr_dump_spram_d);
3616 #endif //__ENABLE_DUMP__
3619 ifx_proc_delproc("suspend_host_1");
3620 ifx_proc_delproc("probe_host_1");
3621 device_remove_file(dev, &dev_attr_suspend_host_1);
3622 device_remove_file(dev, &dev_attr_probe_host_1);
3623 ifx_proc_delproc("suspend_host_2");
3624 ifx_proc_delproc("probe_host_2");
3625 device_remove_file(dev, &dev_attr_suspend_host_2);
3626 device_remove_file(dev, &dev_attr_probe_host_2);
3627 ifx_proc_delproc("probe_timer1");
3628 ifx_proc_delproc("autoprobe_timer1");
3629 device_remove_file(dev, &dev_attr_probe_timer1_val_h);
3630 device_remove_file(dev, &dev_attr_autoprobe_timer1_val_h);
3631 ifx_proc_delproc("probe_timer2");
3632 ifx_proc_delproc("autoprobe_timer2");
3633 device_remove_file(dev, &dev_attr_probe_timer2_val_h);
3634 device_remove_file(dev, &dev_attr_autoprobe_timer2_val_h);
3636 ifx_proc_delproc("suspend_host");
3637 ifx_proc_delproc("probe_host");
3638 device_remove_file(dev, &dev_attr_suspend_host);
3639 device_remove_file(dev, &dev_attr_probe_host);
3640 ifx_proc_delproc("probe_timer");
3641 ifx_proc_delproc("autoprobe_timer");
3642 device_remove_file(dev, &dev_attr_probe_timer_val_h);
3643 device_remove_file(dev, &dev_attr_autoprobe_timer_val_h);
3645 remove_proc_entry(ifxusb_hcd_driver_name, (void *)0);
3648 #ifdef __IS_DEVICE__
3649 ifx_proc_delproc("suspend_device");
3650 ifx_proc_delproc("probe_device");
3651 device_remove_file(dev, &dev_attr_suspend_device);
3652 device_remove_file(dev, &dev_attr_probe_device);
3653 ifx_proc_delproc("probe_timer");
3654 ifx_proc_delproc("autoprobe_timer");
3655 device_remove_file(dev, &dev_attr_probe_timer_val_d);
3656 device_remove_file(dev, &dev_attr_autoprobe_timer_val_d);
3657 remove_proc_entry(ifxusb_pcd_driver_name, (void *)0);
3659 #if defined(__IS_HOST__) && defined(__HOST_COC__)
3661 ifx_pmcu_unregister ( &pmcuRegisterUSBHost_1 );
3662 ifx_pmcu_unregister ( &pmcuRegisterUSBHost_2 );
3664 ifx_pmcu_unregister ( &pmcuRegisterUSBHost );
3667 #if defined(__IS_DEVICE__) && defined(__GADGET_COC__)
3668 ifx_pmcu_unregister ( &pmcuRegisterUSBGadget );
3673 static struct proc_dir_entry * proc_ifx_root = NULL;
3675 /* initialize the proc file system and make a dir named /proc/[name] */
3676 static void ifx_proc_init(void)
3678 IFX_DEBUGPL(DBG_ENTRY, "%s() %d\n", __func__, __LINE__ );
3680 proc_ifx_root = proc_mkdir(ifxusb_hcd_driver_name, (void *)0);
3681 if (!proc_ifx_root){
3682 IFX_PRINT("%s proc initialization failed! \n", ifxusb_hcd_driver_name);
3686 proc_ifx_root = proc_mkdir(ifxusb_pcd_driver_name, (void *)0);
3687 if (!proc_ifx_root){
3688 IFX_PRINT("%s proc initialization failed! \n", ifxusb_pcd_driver_name);
3694 /* proc file system add function for debugging. */
3695 static int ifx_proc_addproc(char *funcname, read_proc_t *hookfuncr, write_proc_t *hookfuncw)
3697 struct proc_dir_entry *pe;
3698 IFX_DEBUGPL(DBG_ENTRY, "%s() %d\n", __func__, __LINE__ );
3702 if (hookfuncw == NULL)
3704 pe = create_proc_read_entry(funcname, S_IRUGO, proc_ifx_root, hookfuncr, NULL);
3707 IFX_PRINT("ERROR in creating read proc entry (%s)! \n", funcname);
3713 pe = create_proc_entry(funcname, S_IRUGO | S_IWUGO, proc_ifx_root);
3716 pe->read_proc = hookfuncr;
3717 pe->write_proc = hookfuncw;
3721 IFX_PRINT("ERROR in creating proc entry (%s)! \n", funcname);
3729 /* proc file system del function for removing module. */
3730 static void ifx_proc_delproc(char *funcname)
3733 IFX_DEBUGPL(DBG_ENTRY, "%s() %d\n", __func__, __LINE__ );
3734 sprintf(pname, "%s", funcname);
3736 remove_proc_entry(pname, proc_ifx_root);
3740 static void ifxusb_dump_params(ifxusb_core_if_t *_core_if)
3742 ifxusb_params_t *params=&_core_if->params;
3745 IFX_PRINT("IFXUSB Dump Parameters ( Host Mode) \n");
3746 #endif //__IS_HOST__
3747 #ifdef __IS_DEVICE__
3748 IFX_PRINT("IFXUSB Dump Parameters ( Device Mode) \n");
3749 #endif //__IS_DEVICE__
3752 IFX_PRINT("DMA: Hermes DMA\n");
3754 IFX_PRINT("DMA: Non-Desc DMA\n");
3756 IFX_PRINT(" Burst size: %d\n",params->dma_burst_size);
3758 if (params->speed==1)
3759 IFX_PRINT("Full Speed only\n");
3760 else if(params->speed==0)
3761 IFX_PRINT("Full/Hign Speed\n");
3763 IFX_PRINT("Unkonwn setting (%d) for Speed\n",params->speed);
3765 IFX_PRINT("Total Data FIFO size: %d(0x%06X) DWord, %d(0x%06X) Bytes\n",
3766 params->data_fifo_size,params->data_fifo_size,
3767 params->data_fifo_size*4, params->data_fifo_size*4
3770 #ifdef __IS_DEVICE__
3771 IFX_PRINT("Rx FIFO size: %d(0x%06X) DWord, %d(0x%06X) Bytes\n",
3772 params->rx_fifo_size,params->rx_fifo_size,
3773 params->rx_fifo_size*4, params->rx_fifo_size*4
3777 for(i=0;i<MAX_EPS_CHANNELS;i++)
3779 IFX_PRINT("Tx FIFO #%d size: %d(0x%06X) DWord, %d(0x%06X) Bytes\n",i,
3780 params->tx_fifo_size[i],params->tx_fifo_size[i],
3781 params->tx_fifo_size[i]*4, params->tx_fifo_size[i]*4
3786 IFX_PRINT("Treshold : %s Rx:%d Tx:%d \n",
3787 (params->thr_ctl)?"On":"Off",params->tx_thr_length,params->rx_thr_length);
3790 IFX_PRINT("Host Channels: %d\n",params->host_channels);
3792 IFX_PRINT("Rx FIFO size: %d(0x%06X) DWord, %d(0x%06X) Bytes\n",
3793 params->data_fifo_size,params->data_fifo_size,
3794 params->data_fifo_size*4, params->data_fifo_size*4
3797 IFX_PRINT("NP Tx FIFO size: %d(0x%06X) DWord, %d(0x%06X) Bytes\n",
3798 params->nperio_tx_fifo_size,params->nperio_tx_fifo_size,
3799 params->nperio_tx_fifo_size*4, params->nperio_tx_fifo_size*4
3802 IFX_PRINT(" P Tx FIFO size: %d(0x%06X) DWord, %d(0x%06X) Bytes\n",
3803 params->perio_tx_fifo_size,params->perio_tx_fifo_size,
3804 params->perio_tx_fifo_size*4, params->perio_tx_fifo_size*4
3806 #endif //__IS_HOST__
3808 IFX_PRINT("Max Transfer size: %d(0x%06X) Bytes\n",
3809 params->max_transfer_size,params->max_transfer_size
3811 IFX_PRINT("Max Packet Count: %d(0x%06X)\n",
3812 params->max_packet_count,params->max_packet_count
3815 IFX_PRINT("PHY UTMI Width: %d\n",params->phy_utmi_width);
3817 IFX_PRINT("Turn Around Time: HS:%d FS:%d\n",params->turn_around_time_hs,params->turn_around_time_fs);
3818 IFX_PRINT("Timeout Calibration: HS:%d FS:%d\n",params->timeout_cal_hs,params->timeout_cal_fs);
3821 IFX_PRINT("==================================================\n");
3822 IFX_PRINT("End of Parameters Dump\n");
3823 IFX_PRINT("==================================================\n");