1/***************************************************************************** 2 ** FILE NAME : ifxusb_ctl.c 3 ** PROJECT : IFX USB sub-system V3 4 ** MODULES : IFX USB sub-system Host and Device driver 5 ** SRC VERSION : 1.0 6 ** SRC VERSION : 3.2 7 ** DATE : 1/Jan/2011 8 ** DESCRIPTION : Implementing the procfs and sysfs for IFX USB driver 9 ** FUNCTIONS : 10 ** COMPILER : gcc 11 ** REFERENCE : Synopsys DWC-OTG Driver 2.7 12 ** COPYRIGHT : Copyright (c) 2010 13 ** LANTIQ DEUTSCHLAND GMBH, 14 ** Am Campeon 3, 85579 Neubiberg, Germany 15 ** 16 ** This program is free software; you can redistribute it and/or modify 17 ** it under the terms of the GNU General Public License as published by 18 ** the Free Software Foundation; either version 2 of the License, or 19 ** (at your option) any later version. 20 ** 21 ** Version Control Section ** 22 ** $Author$ 23 ** $Date$ 24 ** $Revisions$ 25 ** $Log$ Revision history 26 *****************************************************************************/ 27 28/* 29 * This file contains code fragments from Synopsys HS OTG Linux Software Driver. 30 * For this code the following notice is applicable: 31 * 32 * ========================================================================== 33 * 34 * Synopsys HS OTG Linux Software Driver and documentation (hereinafter, 35 * "Software") is an Unsupported proprietary work of Synopsys, Inc. unless 36 * otherwise expressly agreed to in writing between Synopsys and you. 37 * 38 * The Software IS NOT an item of Licensed Software or Licensed Product under 39 * any End User Software License Agreement or Agreement for Licensed Product 40 * with Synopsys or any supplement thereto. You are permitted to use and 41 * redistribute this Software in source and binary forms, with or without 42 * modification, provided that redistributions of source code must retain this 43 * notice. You may not view, use, disclose, copy or distribute this file or 44 * any information contained herein except pursuant to this license grant from 45 * Synopsys. If you do not agree with this notice, including the disclaimer 46 * below, then you are not authorized to use the Software. 47 * 48 * THIS SOFTWARE IS BEING DISTRIBUTED BY SYNOPSYS SOLELY ON AN "AS IS" BASIS 49 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 50 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 51 * ARE HEREBY DISCLAIMED. IN NO EVENT SHALL SYNOPSYS BE LIABLE FOR ANY DIRECT, 52 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 53 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 54 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 55 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 56 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 57 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH 58 * DAMAGE. 59 * ========================================================================== */ 60 61/*! \file ifxusb_ctl.c 62 \ingroup IFXUSB_DRIVER_V3 63 \brief Implementing the procfs and sysfs for IFX USB driver 64*/ 65 66#include <linux/version.h> 67#include "ifxusb_version.h" 68 69 70#include <linux/proc_fs.h> 71#include <asm/byteorder.h> 72#include <asm/unaligned.h> 73#include <asm/uaccess.h> 74 75#include "ifxusb_plat.h" 76#include "ifxusb_regs.h" 77#include "ifxusb_cif.h" 78 79#ifdef __IS_DEVICE__ 80 #include "ifxpcd.h" 81 #ifdef __GADGET_COC__ 82 #include <asm/ifx/ifx_types.h> 83 #include <asm/ifx/ifx_pmcu.h> 84 IFX_PMCU_REGISTER_t pmcuRegisterUSBGadget; 85 #endif 86#endif 87 88#ifdef __IS_HOST__ 89 #include "ifxhcd.h" 90 #ifdef __HOST_COC__ 91 #include <asm/ifx/ifx_types.h> 92 #include <asm/ifx/ifx_pmcu.h> 93 #ifdef __IS_DUAL__ 94 IFX_PMCU_REGISTER_t pmcuRegisterUSBHost_1; 95 IFX_PMCU_REGISTER_t pmcuRegisterUSBHost_2; 96 #else 97 IFX_PMCU_REGISTER_t pmcuRegisterUSBHost; 98 #endif 99 #endif 100#endif 101 102#include <linux/device.h> 103#include <linux/platform_device.h> 104#include <linux/gfp.h> 105 106#ifdef __IS_HOST__ 107 extern char ifxusb_hcd_driver_name[]; 108 109 #ifdef __IS_DUAL__ 110 extern ifxhcd_hcd_t ifxusb_hcd_1; 111 extern ifxhcd_hcd_t ifxusb_hcd_2; 112 extern char ifxusb_hcd_name_1[]; 113 extern char ifxusb_hcd_name_2[]; 114 #else 115 extern ifxhcd_hcd_t ifxusb_hcd; 116 extern char ifxusb_hcd_name[]; 117 #endif 118 119#endif 120 121#ifdef __IS_DEVICE__ 122 extern char ifxusb_pcd_driver_name[]; 123 124 extern ifxpcd_pcd_t ifxusb_pcd; 125 extern char ifxusb_pcd_name[]; 126#endif 127 128 129//Attributes for sysfs (for 2.6 only) 130 131#ifdef __IS_HOST__ 132extern struct device_attribute dev_attr_version_h; 133#else 134extern struct device_attribute dev_attr_version_d; 135#endif 136#ifdef __IS_HOST__ 137extern struct device_attribute dev_attr_dbglevel_h; 138#else 139extern struct device_attribute dev_attr_dbglevel_d; 140#endif 141#ifdef __IS_HOST__ 142 #ifdef __IS_DUAL__ 143 extern struct device_attribute dev_attr_suspend_host_1; 144 extern struct device_attribute dev_attr_suspend_host_2; 145 extern struct device_attribute dev_attr_probe_host_1; 146 extern struct device_attribute dev_attr_probe_host_2; 147 extern struct device_attribute dev_attr_probe_timer1_val_h; 148 extern struct device_attribute dev_attr_probe_timer2_val_h; 149 extern struct device_attribute dev_attr_autoprobe_timer1_val_h; 150 extern struct device_attribute dev_attr_autoprobe_timer2_val_h; 151 #else 152 extern struct device_attribute dev_attr_suspend_host; 153 extern struct device_attribute dev_attr_probe_host; 154 extern struct device_attribute dev_attr_probe_timer_val_h; 155 extern struct device_attribute dev_attr_autoprobe_timer_val_h; 156 #endif 157#endif 158 159#ifdef __IS_DEVICE__ 160 extern struct device_attribute dev_attr_suspend_device; 161 extern struct device_attribute dev_attr_probe_device; 162 extern struct device_attribute dev_attr_probe_timer_val_d; 163 extern struct device_attribute dev_attr_autoprobe_timer_val_d; 164#endif 165 166#ifdef __IS_HOST__ 167 #ifdef __IS_DUAL__ 168 extern struct device_attribute dev_attr_dump_params_h_1; 169 extern struct device_attribute dev_attr_dump_params_h_2; 170 extern struct device_attribute dev_attr_mode_h_1; 171 extern struct device_attribute dev_attr_mode_h_2; 172 #else 173 extern struct device_attribute dev_attr_dump_params_h; 174 extern struct device_attribute dev_attr_mode_h; 175 #endif 176#else 177 extern struct device_attribute dev_attr_dump_params_d; 178 extern struct device_attribute dev_attr_mode_d; 179#endif 180 181#ifdef __IS_HOST__ 182 #ifdef __IS_DUAL__ 183 extern struct device_attribute dev_attr_pkt_count_limit_bi_1; 184 extern struct device_attribute dev_attr_pkt_count_limit_bo_1; 185 extern struct device_attribute dev_attr_pkt_count_limit_bi_2; 186 extern struct device_attribute dev_attr_pkt_count_limit_bo_2; 187 extern struct device_attribute dev_attr_bandwidth_fs_1; 188 extern struct device_attribute dev_attr_bandwidth_ls_1; 189 extern struct device_attribute dev_attr_bandwidth_hs_2; 190 extern struct device_attribute dev_attr_bandwidth_fs_2; 191 extern struct device_attribute dev_attr_bandwidth_ls_2; 192 extern struct device_attribute dev_attr_buspower_1; 193 extern struct device_attribute dev_attr_buspower_2; 194 extern struct device_attribute dev_attr_bussuspend_1; 195 extern struct device_attribute dev_attr_bussuspend_2; 196 extern struct device_attribute dev_attr_busconnected_1; 197 extern struct device_attribute dev_attr_busconnected_2; 198 extern struct device_attribute dev_attr_connectspeed_1; 199 extern struct device_attribute dev_attr_connectspeed_1; 200 #else 201 extern struct device_attribute dev_attr_pkt_count_limit_bi; 202 extern struct device_attribute dev_attr_pkt_count_limit_bo; 203 extern struct device_attribute dev_attr_bandwidth_hs; 204 extern struct device_attribute dev_attr_bandwidth_fs; 205 extern struct device_attribute dev_attr_bandwidth_ls; 206 extern struct device_attribute dev_attr_buspower; 207 extern struct device_attribute dev_attr_bussuspend; 208 extern struct device_attribute dev_attr_busconnected; 209 extern struct device_attribute dev_attr_connectspeed; 210 #endif 211#endif //__IS_HOST__ 212 213#ifdef __IS_DEVICE__ 214 extern struct device_attribute dev_attr_devspeed; 215 extern struct device_attribute dev_attr_enumspeed; 216#endif //__IS_DEVICE__ 217 218#ifdef __ENABLE_DUMP__ 219 #ifdef __IS_HOST__ 220 #ifdef __IS_DUAL__ 221 extern struct device_attribute dev_attr_dump_reg_h_1; 222 extern struct device_attribute dev_attr_dump_reg_h_2; 223 extern struct device_attribute dev_attr_dump_spram_h_1; 224 extern struct device_attribute dev_attr_dump_spram_h_2; 225 extern struct device_attribute dev_attr_dump_host_state_1; 226 extern struct device_attribute dev_attr_dump_host_state_2; 227 #else 228 extern struct device_attribute dev_attr_dump_reg_h; 229 extern struct device_attribute dev_attr_dump_spram_h; 230 extern struct device_attribute dev_attr_dump_host_state; 231 #endif 232 #else 233 extern struct device_attribute dev_attr_dump_reg_d; 234 extern struct device_attribute dev_attr_dump_spram_d; 235 #endif 236#endif //__ENABLE_DUMP__ 237 238 239///////////////////////////////////////////////////////////////////////////////////////////////////// 240///////////////////////////////////////////////////////////////////////////////////////////////////// 241///////////////////////////////////////////////////////////////////////////////////////////////////// 242 243static ssize_t procfs_version_show(char *buf, char **start, off_t offset, int count, int *eof, void *data) 244{ 245 return sprintf( buf, "%s\n",IFXUSB_VERSION ); 246} 247 248#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20) 249 static ssize_t sysfs_version_show( struct device *_dev, struct device_attribute *attr,char *buf) 250#else 251 static ssize_t sysfs_version_show( struct device *_dev, char *buf) 252#endif 253{ 254 return sprintf( buf, "%s\n",IFXUSB_VERSION ); 255} 256 257#ifdef __IS_HOST__ 258DEVICE_ATTR(version_h, S_IRUGO|S_IWUSR, sysfs_version_show, NULL); 259#else 260DEVICE_ATTR(version_d, S_IRUGO|S_IWUSR, sysfs_version_show, NULL); 261#endif 262 263 264///////////////////////////////////////////////////////////////////////////////////////////////////// 265///////////////////////////////////////////////////////////////////////////////////////////////////// 266///////////////////////////////////////////////////////////////////////////////////////////////////// 267///////////////////////////////////////////////////////////////////////////////////////////////////// 268///////////////////////////////////////////////////////////////////////////////////////////////////// 269///////////////////////////////////////////////////////////////////////////////////////////////////// 270 271static ssize_t procfs_dbglevel_show(char *buf, char **start, off_t offset, int count, int *eof, void *data) 272{ 273 #ifdef __IS_HOST__ 274 return sprintf( buf, "%08X\n",h_dbg_lvl ); 275 #else 276 return sprintf( buf, "%08X\n",d_dbg_lvl ); 277 #endif 278} 279 280static ssize_t procfs_dbglevel_store(struct file *file, const char *buffer, unsigned long count, void *data) 281{ 282 char buf[10]; 283 int i = 0; 284 uint32_t value; 285 if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1)) 286 return -EFAULT; 287 value = simple_strtoul(buf, NULL, 16); 288 #ifdef __IS_HOST__ 289 h_dbg_lvl =value; 290 #else 291 d_dbg_lvl =value; 292 #endif 293 //turn on and off power 294 return count; 295} 296 297#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20) 298 static ssize_t sysfs_dbglevel_show( struct device *_dev, struct device_attribute *attr,char *buf) 299#else 300 static ssize_t sysfs_dbglevel_show( struct device *_dev, char *buf) 301#endif 302{ 303 #ifdef __IS_HOST__ 304 return sprintf( buf, "%08X\n",h_dbg_lvl ); 305 #else 306 return sprintf( buf, "%08X\n",d_dbg_lvl ); 307 #endif 308} 309 310#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20) 311 static ssize_t sysfs_dbglevel_store( struct device *_dev, struct device_attribute *attr,const char *buffer, size_t count ) 312#else 313 static ssize_t sysfs_dbglevel_store( struct device *_dev, const char *buffer, size_t count ) 314#endif 315{ 316 char buf[10]; 317 int i = 0; 318 uint32_t value; 319 if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1)) 320 return -EFAULT; 321 value = simple_strtoul(buf, NULL, 16); 322 #ifdef __IS_HOST__ 323 h_dbg_lvl =value; 324 #else 325 d_dbg_lvl =value; 326 #endif 327 //turn on and off power 328 return count; 329} 330 331#ifdef __IS_HOST__ 332DEVICE_ATTR(dbglevel_h, S_IRUGO|S_IWUSR, sysfs_dbglevel_show, sysfs_dbglevel_store); 333#else 334DEVICE_ATTR(dbglevel_d, S_IRUGO|S_IWUSR, sysfs_dbglevel_show, sysfs_dbglevel_store); 335#endif 336 337 338///////////////////////////////////////////////////////////////////////////////////////////////////// 339///////////////////////////////////////////////////////////////////////////////////////////////////// 340///////////////////////////////////////////////////////////////////////////////////////////////////// 341 342static void ifxusb_dump_params(ifxusb_core_if_t *_core_if); 343 344#ifdef __IS_DUAL__ 345 static void dump_params_1(void) 346 { 347 ifxusb_dump_params(&ifxusb_hcd_1.core_if); 348 } 349 static void dump_params_2(void) 350 { 351 ifxusb_dump_params(&ifxusb_hcd_2.core_if); 352 } 353 354 static ssize_t procfs_dump_params_show_1(char *buf, char **start, off_t offset, int count, int *eof, void *data) 355 { 356 dump_params_1(); 357 return 0; 358 } 359 static ssize_t procfs_dump_params_show_2(char *buf, char **start, off_t offset, int count, int *eof, void *data) 360 { 361 dump_params_2(); 362 return 0; 363 } 364 365 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20) 366 static ssize_t sysfs_dump_params_show_1( struct device *_dev, struct device_attribute *attr,char *buf) 367 #else 368 static ssize_t sysfs_dump_params_show_1( struct device *_dev,char *buf) 369 #endif 370 { 371 dump_params_1(); 372 return 0; 373 } 374 DEVICE_ATTR(dump_params_h_1, S_IRUGO|S_IWUSR, sysfs_dump_params_show_1, NULL); 375 376 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20) 377 static ssize_t sysfs_dump_params_show_2( struct device *_dev, struct device_attribute *attr,char *buf) 378 #else 379 static ssize_t sysfs_dump_params_show_2( struct device *_dev,char *buf) 380 #endif 381 { 382 dump_params_2(); 383 return 0; 384 } 385 386 DEVICE_ATTR(dump_params_h_2, S_IRUGO|S_IWUSR, sysfs_dump_params_show_2, NULL); 387#else 388 static void dump_params(void) 389 { 390 #ifdef __IS_HOST__ 391 ifxusb_dump_params(&ifxusb_hcd.core_if); 392 #else 393 ifxusb_dump_params(&ifxusb_pcd.core_if); 394 #endif 395 } 396 397 static ssize_t procfs_dump_params_show(char *buf, char **start, off_t offset, int count, int *eof, void *data) 398 { 399 dump_params(); 400 return 0; 401 } 402 403 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20) 404 static ssize_t sysfs_dump_params_show( struct device *_dev, struct device_attribute *attr,char *buf) 405 #else 406 static ssize_t sysfs_dump_params_show( struct device *_dev,char *buf) 407 #endif 408 { 409 dump_params(); 410 return 0; 411 } 412 413 #ifdef __IS_HOST__ 414 DEVICE_ATTR(dump_params_h, S_IRUGO|S_IWUSR, sysfs_dump_params_show, NULL); 415 #else 416 DEVICE_ATTR(dump_params_d, S_IRUGO|S_IWUSR, sysfs_dump_params_show, NULL); 417 #endif 418#endif 419 420///////////////////////////////////////////////////////////////////////////////////////////////////// 421///////////////////////////////////////////////////////////////////////////////////////////////////// 422///////////////////////////////////////////////////////////////////////////////////////////////////// 423 424#ifdef __IS_DUAL__ 425 static ssize_t mode_show_1(char *buf) 426 { 427 if((ifxusb_rreg(&ifxusb_hcd_1.core_if.core_global_regs->gintsts ) & 0x1) == 1) 428 return sprintf( buf, "HOST\n" ); 429 else 430 return sprintf( buf, "DEVICE(INCORRECT!)\n" ); 431 } 432 433 static ssize_t mode_show_2(char *buf) 434 { 435 if((ifxusb_rreg(&ifxusb_hcd_2.core_if.core_global_regs->gintsts ) & 0x1) == 1) 436 return sprintf( buf, "HOST\n" ); 437 else 438 return sprintf( buf, "DEVICE(INCORRECT!)\n" ); 439 } 440 441 static ssize_t procfs_mode_show_1(char *buf, char **start, off_t offset, int count, int *eof, void *data) 442 { 443 return mode_show_1(buf); 444 } 445 static ssize_t procfs_mode_show_2(char *buf, char **start, off_t offset, int count, int *eof, void *data) 446 { 447 return mode_show_2(buf); 448 } 449 450 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20) 451 static ssize_t sysfs_mode_show_1( struct device *_dev, struct device_attribute *attr,char *buf) 452 #else 453 static ssize_t sysfs_mode_show_1( struct device *_dev,char *buf) 454 #endif 455 { 456 return mode_show_1(buf); 457 } 458 459 DEVICE_ATTR(mode_h_1, S_IRUGO|S_IWUSR, sysfs_mode_show_1, 0); 460 461 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20) 462 static ssize_t sysfs_mode_show_2( struct device *_dev, struct device_attribute *attr,char *buf) 463 #else 464 static ssize_t sysfs_mode_show_2( struct device *_dev,char *buf) 465 #endif 466 { 467 return mode_show_2(buf); 468 } 469 DEVICE_ATTR(mode_h_2, S_IRUGO|S_IWUSR, sysfs_mode_show_2, NULL); 470#else 471 static ssize_t mode_show(char *buf) 472 { 473 #ifdef __IS_HOST__ 474 if((ifxusb_rreg(&ifxusb_hcd.core_if.core_global_regs->gintsts ) & 0x1) == 1) 475 return sprintf( buf, "HOST\n" ); 476 else 477 return sprintf( buf, "DEVICE(INCORRECT!)\n" ); 478 #else 479 if((ifxusb_rreg(&ifxusb_pcd.core_if.core_global_regs->gintsts ) & 0x1) != 1) 480 return sprintf( buf, "DEVICE\n" ); 481 else 482 return sprintf( buf, "HOST(INCORRECT!)\n" ); 483 #endif 484 } 485 static ssize_t procfs_mode_show(char *buf, char **start, off_t offset, int count, int *eof, void *data) 486 { 487 return mode_show(buf); 488 } 489 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20) 490 static ssize_t sysfs_mode_show( struct device *_dev, struct device_attribute *attr,char *buf) 491 #else 492 static ssize_t sysfs_mode_show( struct device *_dev, char *buf) 493 #endif 494 { 495 return mode_show(buf); 496 } 497 #ifdef __IS_HOST__ 498 DEVICE_ATTR(mode_h, S_IRUGO|S_IWUSR, sysfs_mode_show, NULL); 499 #else 500 DEVICE_ATTR(mode_d, S_IRUGO|S_IWUSR, sysfs_mode_show, NULL); 501 #endif 502#endif 503 504///////////////////////////////////////////////////////////////////////////////////////////////////// 505///////////////////////////////////////////////////////////////////////////////////////////////////// 506///////////////////////////////////////////////////////////////////////////////////////////////////// 507 508#ifdef __IS_HOST__ 509///////////////////////////////////////////////////////////////////////////////////////////////////// 510///////////////////////////////////////////////////////////////////////////////////////////////////// 511///////////////////////////////////////////////////////////////////////////////////////////////////// 512 #ifdef __IS_DUAL__ 513 static ssize_t bandwidth_hs_show_1(char *buf) 514 { 515 return sprintf( buf, "%d\n",ifxusb_hcd_1.pkt_remaining_reload_hs ); 516 } 517 static ssize_t bandwidth_fs_show_1(char *buf) 518 { 519 return sprintf( buf, "%d\n",ifxusb_hcd_1.pkt_remaining_reload_fs ); 520 } 521 static ssize_t bandwidth_ls_show_1(char *buf) 522 { 523 return sprintf( buf, "%d\n",ifxusb_hcd_1.pkt_remaining_reload_ls ); 524 } 525 static void bandwidth_hs_store_1(uint32_t value) 526 { 527 if(value>16 && value<120) 528 { 529 hprt0_data_t hprt0; 530 ifxusb_hcd_1.pkt_remaining_reload_hs = value; 531 hprt0.d32 = ifxusb_rreg(ifxusb_hcd_1.core_if.hprt0); 532 if(hprt0.b.prtspd == IFXUSB_HPRT0_PRTSPD_HIGH_SPEED) 533 ifxusb_hcd_1.pkt_remaining_reload=value; 534 } 535 } 536 static void bandwidth_fs_store_1(uint32_t value) 537 { 538 if (value>2 && value<30) 539 { 540 hprt0_data_t hprt0; 541 ifxusb_hcd_1.pkt_remaining_reload_fs = value; 542 hprt0.d32 = ifxusb_rreg(ifxusb_hcd_1.core_if.hprt0); 543 if(hprt0.b.prtspd != IFXUSB_HPRT0_PRTSPD_LOW_SPEED && hprt0.b.prtspd != IFXUSB_HPRT0_PRTSPD_HIGH_SPEED) 544 ifxusb_hcd_1.pkt_remaining_reload=value; 545 } 546 } 547 static void bandwidth_ls_store_1(uint32_t value) 548 { 549 if (value>2 && value<30) 550 { 551 hprt0_data_t hprt0; 552 ifxusb_hcd_1.pkt_remaining_reload_ls = value; 553 hprt0.d32 = ifxusb_rreg(ifxusb_hcd_1.core_if.hprt0); 554 if(hprt0.b.prtspd == IFXUSB_HPRT0_PRTSPD_LOW_SPEED) 555 ifxusb_hcd_1.pkt_remaining_reload=value; 556 } 557 } 558 static ssize_t bandwidth_hs_show_2(char *buf) 559 { 560 return sprintf( buf, "%d\n",ifxusb_hcd_2.pkt_remaining_reload_hs ); 561 } 562 static ssize_t bandwidth_fs_show_2(char *buf) 563 { 564 return sprintf( buf, "%d\n",ifxusb_hcd_2.pkt_remaining_reload_fs ); 565 } 566 static ssize_t bandwidth_ls_show_2(char *buf) 567 { 568 return sprintf( buf, "%d\n",ifxusb_hcd_2.pkt_remaining_reload_ls ); 569 } 570 static void bandwidth_hs_store_2(uint32_t value) 571 { 572 if(value>16 && value<120) 573 { 574 hprt0_data_t hprt0; 575 ifxusb_hcd_2.pkt_remaining_reload_hs = value; 576 hprt0.d32 = ifxusb_rreg(ifxusb_hcd_2.core_if.hprt0); 577 if(hprt0.b.prtspd == IFXUSB_HPRT0_PRTSPD_HIGH_SPEED) 578 ifxusb_hcd_2.pkt_remaining_reload=value; 579 } 580 } 581 static void bandwidth_fs_store_2(uint32_t value) 582 { 583 if (value>2 && value<30) 584 { 585 hprt0_data_t hprt0; 586 ifxusb_hcd_2.pkt_remaining_reload_fs = value; 587 hprt0.d32 = ifxusb_rreg(ifxusb_hcd_2.core_if.hprt0); 588 if(hprt0.b.prtspd != IFXUSB_HPRT0_PRTSPD_LOW_SPEED && hprt0.b.prtspd != IFXUSB_HPRT0_PRTSPD_HIGH_SPEED) 589 ifxusb_hcd_2.pkt_remaining_reload=value; 590 } 591 } 592 static void bandwidth_ls_store_2(uint32_t value) 593 { 594 if (value>2 && value<30) 595 { 596 hprt0_data_t hprt0; 597 ifxusb_hcd_2.pkt_remaining_reload_ls = value; 598 hprt0.d32 = ifxusb_rreg(ifxusb_hcd_2.core_if.hprt0); 599 if(hprt0.b.prtspd == IFXUSB_HPRT0_PRTSPD_LOW_SPEED) 600 ifxusb_hcd_2.pkt_remaining_reload=value; 601 } 602 } 603 static ssize_t procfs_bandwidth_hs_show_1(char *buf, char **start, off_t offset, int count, int *eof, void *data) 604 { 605 return bandwidth_hs_show_1(buf); 606 } 607 static ssize_t procfs_bandwidth_fs_show_1(char *buf, char **start, off_t offset, int count, int *eof, void *data) 608 { 609 return bandwidth_fs_show_1(buf); 610 } 611 static ssize_t procfs_bandwidth_ls_show_1(char *buf, char **start, off_t offset, int count, int *eof, void *data) 612 { 613 return bandwidth_ls_show_1(buf); 614 } 615 static ssize_t procfs_bandwidth_hs_store_1(struct file *file, const char *buffer, unsigned long count, void *data) 616 { 617 char buf[10]; 618 int i = 0; 619 uint32_t value; 620 if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1)) 621 return -EFAULT; 622 value = simple_strtoul(buf, NULL, 10); 623 bandwidth_hs_store_1(value); 624 return count; 625 } 626 static ssize_t procfs_bandwidth_fs_store_1(struct file *file, const char *buffer, unsigned long count, void *data) 627 { 628 char buf[10]; 629 int i = 0; 630 uint32_t value; 631 if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1)) 632 return -EFAULT; 633 value = simple_strtoul(buf, NULL, 10); 634 bandwidth_fs_store_1(value); 635 return count; 636 } 637 static ssize_t procfs_bandwidth_ls_store_1(struct file *file, const char *buffer, unsigned long count, void *data) 638 { 639 char buf[10]; 640 int i = 0; 641 uint32_t value; 642 if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1)) 643 return -EFAULT; 644 value = simple_strtoul(buf, NULL, 10); 645 bandwidth_ls_store_1(value); 646 return count; 647 } 648 static ssize_t procfs_bandwidth_hs_show_2(char *buf, char **start, off_t offset, int count, int *eof, void *data) 649 { 650 return bandwidth_hs_show_2(buf); 651 } 652 static ssize_t procfs_bandwidth_fs_show_2(char *buf, char **start, off_t offset, int count, int *eof, void *data) 653 { 654 return bandwidth_fs_show_2(buf); 655 } 656 static ssize_t procfs_bandwidth_ls_show_2(char *buf, char **start, off_t offset, int count, int *eof, void *data) 657 { 658 return bandwidth_ls_show_2(buf); 659 } 660 static ssize_t procfs_bandwidth_hs_store_2(struct file *file, const char *buffer, unsigned long count, void *data) 661 { 662 char buf[10]; 663 int i = 0; 664 uint32_t value; 665 if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1)) 666 return -EFAULT; 667 value = simple_strtoul(buf, NULL, 10); 668 bandwidth_hs_store_2(value); 669 return count; 670 } 671 static ssize_t procfs_bandwidth_fs_store_2(struct file *file, const char *buffer, unsigned long count, void *data) 672 { 673 char buf[10]; 674 int i = 0; 675 uint32_t value; 676 if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1)) 677 return -EFAULT; 678 value = simple_strtoul(buf, NULL, 10); 679 bandwidth_fs_store_2(value); 680 return count; 681 } 682 static ssize_t procfs_bandwidth_ls_store_2(struct file *file, const char *buffer, unsigned long count, void *data) 683 { 684 char buf[10]; 685 int i = 0; 686 uint32_t value; 687 if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1)) 688 return -EFAULT; 689 value = simple_strtoul(buf, NULL, 10); 690 bandwidth_ls_store_2(value); 691 return count; 692 } 693 694 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20) 695 static ssize_t sysfs_bandwidth_hs_show_1( struct device *_dev, struct device_attribute *attr,char *buf) 696 #else 697 static ssize_t sysfs_bandwidth_hs_show_1( struct device *_dev,char *buf) 698 #endif 699 { 700 return bandwidth_hs_show_1(buf); 701 } 702 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20) 703 static ssize_t sysfs_bandwidth_hs_store_1( struct device *_dev, struct device_attribute *attr,const char *buffer, size_t count ) 704 #else 705 static ssize_t sysfs_bandwidth_hs_store_1( struct device *_dev, const char *buffer, size_t count ) 706 #endif 707 { 708 char buf[10]; 709 int i = 0; 710 uint32_t value; 711 if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1)) 712 return -EFAULT; 713 value = simple_strtoul(buf, NULL, 10); 714 bandwidth_hs_store_1(value); 715 return count; 716 } 717 DEVICE_ATTR(bandwidth_hs_1, S_IRUGO|S_IWUSR, sysfs_bandwidth_hs_show_1, sysfs_bandwidth_hs_store_1); 718 719 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20) 720 static ssize_t sysfs_bandwidth_fs_show_1( struct device *_dev, struct device_attribute *attr,char *buf) 721 #else 722 static ssize_t sysfs_bandwidth_fs_show_1( struct device *_dev,char *buf) 723 #endif 724 { 725 return bandwidth_fs_show_1(buf); 726 } 727 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20) 728 static ssize_t sysfs_bandwidth_fs_store_1( struct device *_dev, struct device_attribute *attr,const char *buffer, size_t count ) 729 #else 730 static ssize_t sysfs_bandwidth_fs_store_1( struct device *_dev, const char *buffer, size_t count ) 731 #endif 732 { 733 char buf[10]; 734 int i = 0; 735 uint32_t value; 736 if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1)) 737 return -EFAULT; 738 value = simple_strtoul(buf, NULL, 10); 739 bandwidth_fs_store_1(value); 740 return count; 741 } 742 DEVICE_ATTR(bandwidth_fs_1, S_IRUGO|S_IWUSR, sysfs_bandwidth_fs_show_1, sysfs_bandwidth_fs_store_1); 743 744 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20) 745 static ssize_t sysfs_bandwidth_ls_show_1( struct device *_dev, struct device_attribute *attr,char *buf) 746 #else 747 static ssize_t sysfs_bandwidth_ls_show_1( struct device *_dev,char *buf) 748 #endif 749 { 750 return bandwidth_ls_show_1(buf); 751 } 752 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20) 753 static ssize_t sysfs_bandwidth_ls_store_1( struct device *_dev, struct device_attribute *attr,const char *buffer, size_t count ) 754 #else 755 static ssize_t sysfs_bandwidth_ls_store_1( struct device *_dev, const char *buffer, size_t count ) 756 #endif 757 { 758 char buf[10]; 759 int i = 0; 760 uint32_t value; 761 if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1)) 762 return -EFAULT; 763 value = simple_strtoul(buf, NULL, 10); 764 bandwidth_ls_store_1(value); 765 return count; 766 } 767 DEVICE_ATTR(bandwidth_ls_1, S_IRUGO|S_IWUSR, sysfs_bandwidth_ls_show_1, sysfs_bandwidth_ls_store_1); 768 769 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20) 770 static ssize_t sysfs_bandwidth_hs_show_2( struct device *_dev, struct device_attribute *attr,char *buf) 771 #else 772 static ssize_t sysfs_bandwidth_hs_show_2( struct device *_dev,char *buf) 773 #endif 774 { 775 return bandwidth_hs_show_2(buf); 776 } 777 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20) 778 static ssize_t sysfs_bandwidth_hs_store_2( struct device *_dev, struct device_attribute *attr,const char *buffer, size_t count ) 779 #else 780 static ssize_t sysfs_bandwidth_hs_store_2( struct device *_dev, const char *buffer, size_t count ) 781 #endif 782 { 783 char buf[10]; 784 int i = 0; 785 uint32_t value; 786 if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1)) 787 return -EFAULT; 788 value = simple_strtoul(buf, NULL, 10); 789 bandwidth_hs_store_2(value); 790 return count; 791 } 792 DEVICE_ATTR(bandwidth_hs_2, S_IRUGO|S_IWUSR, sysfs_bandwidth_hs_show_2, sysfs_bandwidth_hs_store_2); 793 794 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20) 795 static ssize_t sysfs_bandwidth_fs_show_2( struct device *_dev, struct device_attribute *attr,char *buf) 796 #else 797 static ssize_t sysfs_bandwidth_fs_show_2( struct device *_dev,char *buf) 798 #endif 799 { 800 return bandwidth_fs_show_2(buf); 801 } 802 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20) 803 static ssize_t sysfs_bandwidth_fs_store_2( struct device *_dev, struct device_attribute *attr,const char *buffer, size_t count ) 804 #else 805 static ssize_t sysfs_bandwidth_fs_store_2( struct device *_dev, const char *buffer, size_t count ) 806 #endif 807 { 808 char buf[10]; 809 int i = 0; 810 uint32_t value; 811 if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1)) 812 return -EFAULT; 813 value = simple_strtoul(buf, NULL, 10); 814 bandwidth_fs_store_2(value); 815 return count; 816 } 817 DEVICE_ATTR(bandwidth_fs_2, S_IRUGO|S_IWUSR, sysfs_bandwidth_fs_show_2, sysfs_bandwidth_fs_store_2); 818 819 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20) 820 static ssize_t sysfs_bandwidth_ls_show_2( struct device *_dev, struct device_attribute *attr,char *buf) 821 #else 822 static ssize_t sysfs_bandwidth_ls_show_2( struct device *_dev,char *buf) 823 #endif 824 { 825 return bandwidth_ls_show_2(buf); 826 } 827 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20) 828 static ssize_t sysfs_bandwidth_ls_store_2( struct device *_dev, struct device_attribute *attr,const char *buffer, size_t count ) 829 #else 830 static ssize_t sysfs_bandwidth_ls_store_2( struct device *_dev, const char *buffer, size_t count ) 831 #endif 832 { 833 char buf[10]; 834 int i = 0; 835 uint32_t value; 836 if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1)) 837 return -EFAULT; 838 value = simple_strtoul(buf, NULL, 10); 839 bandwidth_ls_store_2(value); 840 return count; 841 } 842 DEVICE_ATTR(bandwidth_ls_2, S_IRUGO|S_IWUSR, sysfs_bandwidth_ls_show_2, sysfs_bandwidth_ls_store_2); 843 #else 844 static ssize_t bandwidth_hs_show(char *buf) 845 { 846 return sprintf( buf, "%d\n",ifxusb_hcd.pkt_remaining_reload_hs ); 847 } 848 static ssize_t bandwidth_fs_show(char *buf) 849 { 850 return sprintf( buf, "%d\n",ifxusb_hcd.pkt_remaining_reload_fs ); 851 } 852 static ssize_t bandwidth_ls_show(char *buf) 853 { 854 return sprintf( buf, "%d\n",ifxusb_hcd.pkt_remaining_reload_ls ); 855 } 856 static void bandwidth_hs_store(uint32_t value) 857 { 858 if (value>16 && value<120) 859 { 860 hprt0_data_t hprt0; 861 ifxusb_hcd.pkt_remaining_reload_hs = value; 862 hprt0.d32 = ifxusb_rreg(ifxusb_hcd.core_if.hprt0); 863 if(hprt0.b.prtspd == IFXUSB_HPRT0_PRTSPD_HIGH_SPEED) 864 ifxusb_hcd.pkt_remaining_reload=value; 865 } 866 } 867 static void bandwidth_fs_store(uint32_t value) 868 { 869 if (value>2 && value<30) 870 { 871 hprt0_data_t hprt0; 872 ifxusb_hcd.pkt_remaining_reload_fs = value; 873 hprt0.d32 = ifxusb_rreg(ifxusb_hcd.core_if.hprt0); 874 if(hprt0.b.prtspd != IFXUSB_HPRT0_PRTSPD_LOW_SPEED && hprt0.b.prtspd != IFXUSB_HPRT0_PRTSPD_HIGH_SPEED) 875 ifxusb_hcd.pkt_remaining_reload=value; 876 } 877 } 878 static void bandwidth_ls_store(uint32_t value) 879 { 880 if (value>2 && value<30) 881 { 882 hprt0_data_t hprt0; 883 ifxusb_hcd.pkt_remaining_reload_hs = value; 884 hprt0.d32 = ifxusb_rreg(ifxusb_hcd.core_if.hprt0); 885 if(hprt0.b.prtspd == IFXUSB_HPRT0_PRTSPD_LOW_SPEED) 886 ifxusb_hcd.pkt_remaining_reload=value; 887 } 888 } 889 static ssize_t procfs_bandwidth_hs_show(char *buf, char **start, off_t offset, int count, int *eof, void *data) 890 { 891 return bandwidth_hs_show(buf); 892 } 893 static ssize_t procfs_bandwidth_fs_show(char *buf, char **start, off_t offset, int count, int *eof, void *data) 894 { 895 return bandwidth_fs_show(buf); 896 } 897 static ssize_t procfs_bandwidth_ls_show(char *buf, char **start, off_t offset, int count, int *eof, void *data) 898 { 899 return bandwidth_ls_show(buf); 900 } 901 static ssize_t procfs_bandwidth_hs_store(struct file *file, const char *buffer, unsigned long count, void *data) 902 { 903 char buf[10]; 904 int i = 0; 905 uint32_t value; 906 if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1)) 907 return -EFAULT; 908 value = simple_strtoul(buf, NULL, 10); 909 bandwidth_hs_store(value); 910 return count; 911 } 912 static ssize_t procfs_bandwidth_fs_store(struct file *file, const char *buffer, unsigned long count, void *data) 913 { 914 char buf[10]; 915 int i = 0; 916 uint32_t value; 917 if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1)) 918 return -EFAULT; 919 value = simple_strtoul(buf, NULL, 10); 920 bandwidth_fs_store(value); 921 return count; 922 } 923 static ssize_t procfs_bandwidth_ls_store(struct file *file, const char *buffer, unsigned long count, void *data) 924 { 925 char buf[10]; 926 int i = 0; 927 uint32_t value; 928 if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1)) 929 return -EFAULT; 930 value = simple_strtoul(buf, NULL, 10); 931 bandwidth_ls_store(value); 932 return count; 933 } 934 935 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20) 936 static ssize_t sysfs_bandwidth_hs_show( struct device *_dev, struct device_attribute *attr,char *buf) 937 #else 938 static ssize_t sysfs_bandwidth_hs_show( struct device *_dev,char *buf) 939 #endif 940 { 941 return bandwidth_hs_show(buf); 942 } 943 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20) 944 static ssize_t sysfs_bandwidth_hs_store( struct device *_dev, struct device_attribute *attr,const char *buffer, size_t count ) 945 #else 946 static ssize_t sysfs_bandwidth_hs_store( struct device *_dev, const char *buffer, size_t count ) 947 #endif 948 { 949 char buf[10]; 950 int i = 0; 951 uint32_t value; 952 if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1)) 953 return -EFAULT; 954 value = simple_strtoul(buf, NULL, 10); 955 bandwidth_hs_store(value); 956 return count; 957 } 958 DEVICE_ATTR(bandwidth_hs, S_IRUGO|S_IWUSR, sysfs_bandwidth_hs_show, sysfs_bandwidth_hs_store); 959 960 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20) 961 static ssize_t sysfs_bandwidth_fs_show( struct device *_dev, struct device_attribute *attr,char *buf) 962 #else 963 static ssize_t sysfs_bandwidth_fs_show( struct device *_dev,char *buf) 964 #endif 965 { 966 return bandwidth_fs_show(buf); 967 } 968 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20) 969 static ssize_t sysfs_bandwidth_fs_store( struct device *_dev, struct device_attribute *attr,const char *buffer, size_t count ) 970 #else 971 static ssize_t sysfs_bandwidth_fs_store( struct device *_dev, const char *buffer, size_t count ) 972 #endif 973 { 974 char buf[10]; 975 int i = 0; 976 uint32_t value; 977 if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1)) 978 return -EFAULT; 979 value = simple_strtoul(buf, NULL, 10); 980 bandwidth_fs_store(value); 981 return count; 982 } 983 DEVICE_ATTR(bandwidth_fs, S_IRUGO|S_IWUSR, sysfs_bandwidth_fs_show, sysfs_bandwidth_fs_store); 984 985 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20) 986 static ssize_t sysfs_bandwidth_ls_show( struct device *_dev, struct device_attribute *attr,char *buf) 987 #else 988 static ssize_t sysfs_bandwidth_ls_show( struct device *_dev,char *buf) 989 #endif 990 { 991 return bandwidth_ls_show(buf); 992 } 993 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20) 994 static ssize_t sysfs_bandwidth_ls_store( struct device *_dev, struct device_attribute *attr,const char *buffer, size_t count ) 995 #else 996 static ssize_t sysfs_bandwidth_ls_store( struct device *_dev, const char *buffer, size_t count ) 997 #endif 998 { 999 char buf[10]; 1000 int i = 0; 1001 uint32_t value; 1002 if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1)) 1003 return -EFAULT; 1004 value = simple_strtoul(buf, NULL, 10); 1005 bandwidth_ls_store(value); 1006 return count; 1007 } 1008 DEVICE_ATTR(bandwidth_ls, S_IRUGO|S_IWUSR, sysfs_bandwidth_ls_show, sysfs_bandwidth_ls_store); 1009 #endif 1010 1011///////////////////////////////////////////////////////////////////////////////////////////////////// 1012///////////////////////////////////////////////////////////////////////////////////////////////////// 1013 #ifdef __IS_DUAL__ 1014 static ssize_t pkt_count_limit_bi_show_1(char *buf) 1015 { 1016 return sprintf( buf, "%d\n",ifxusb_hcd_1.pkt_count_limit_bi ); 1017 } 1018 static ssize_t pkt_count_limit_bo_show_1(char *buf) 1019 { 1020 return sprintf( buf, "%d\n",ifxusb_hcd_1.pkt_count_limit_bo ); 1021 } 1022 static void pkt_count_limit_bi_store_1(uint32_t value) 1023 { 1024 if(value<=13) 1025 ifxusb_hcd_1.pkt_count_limit_bi = value; 1026 } 1027 static void pkt_count_limit_bo_store_1(uint32_t value) 1028 { 1029 if (value<=13) 1030 ifxusb_hcd_1.pkt_count_limit_bo = value; 1031 } 1032 static ssize_t pkt_count_limit_bi_show_2(char *buf) 1033 { 1034 return sprintf( buf, "%d\n",ifxusb_hcd_2.pkt_count_limit_bi ); 1035 } 1036 static ssize_t pkt_count_limit_bo_show_2(char *buf) 1037 { 1038 return sprintf( buf, "%d\n",ifxusb_hcd_2.pkt_count_limit_bo ); 1039 } 1040 static void pkt_count_limit_bi_store_2(uint32_t value) 1041 { 1042 if(value<=13) 1043 ifxusb_hcd_2.pkt_count_limit_bi = value; 1044 } 1045 static void pkt_count_limit_bo_store_2(uint32_t value) 1046 { 1047 if(value<=13) 1048 ifxusb_hcd_2.pkt_count_limit_bo = value; 1049 } 1050 static ssize_t procfs_pkt_count_limit_bi_show_1(char *buf, char **start, off_t offset, int count, int *eof, void *data) 1051 { 1052 return pkt_count_limit_bi_show_1(buf); 1053 } 1054 static ssize_t procfs_pkt_count_limit_bo_show_1(char *buf, char **start, off_t offset, int count, int *eof, void *data) 1055 { 1056 return pkt_count_limit_bo_show_1(buf); 1057 } 1058 static ssize_t procfs_pkt_count_limit_bi_store_1(struct file *file, const char *buffer, unsigned long count, void *data) 1059 { 1060 char buf[10]; 1061 int i = 0; 1062 uint32_t value; 1063 if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1)) 1064 return -EFAULT; 1065 value = simple_strtoul(buf, NULL, 10); 1066 pkt_count_limit_bi_store_1(value); 1067 return count; 1068 } 1069 static ssize_t procfs_pkt_count_limit_bo_store_1(struct file *file, const char *buffer, unsigned long count, void *data) 1070 { 1071 char buf[10]; 1072 int i = 0; 1073 uint32_t value; 1074 if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1)) 1075 return -EFAULT; 1076 value = simple_strtoul(buf, NULL, 10); 1077 pkt_count_limit_bo_store_1(value); 1078 return count; 1079 } 1080 static ssize_t procfs_pkt_count_limit_bi_show_2(char *buf, char **start, off_t offset, int count, int *eof, void *data) 1081 { 1082 return pkt_count_limit_bi_show_2(buf); 1083 } 1084 static ssize_t procfs_pkt_count_limit_bo_show_2(char *buf, char **start, off_t offset, int count, int *eof, void *data) 1085 { 1086 return pkt_count_limit_bo_show_2(buf); 1087 } 1088 static ssize_t procfs_pkt_count_limit_bi_store_2(struct file *file, const char *buffer, unsigned long count, void *data) 1089 { 1090 char buf[10]; 1091 int i = 0; 1092 uint32_t value; 1093 if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1)) 1094 return -EFAULT; 1095 value = simple_strtoul(buf, NULL, 10); 1096 pkt_count_limit_bi_store_2(value); 1097 return count; 1098 } 1099 static ssize_t procfs_pkt_count_limit_bo_store_2(struct file *file, const char *buffer, unsigned long count, void *data) 1100 { 1101 char buf[10]; 1102 int i = 0; 1103 uint32_t value; 1104 if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1)) 1105 return -EFAULT; 1106 value = simple_strtoul(buf, NULL, 10); 1107 pkt_count_limit_bo_store_2(value); 1108 return count; 1109 } 1110 1111 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20) 1112 static ssize_t sysfs_pkt_count_limit_bi_show_1( struct device *_dev, struct device_attribute *attr,char *buf) 1113 #else 1114 static ssize_t sysfs_pkt_count_limit_bi_show_1( struct device *_dev,char *buf) 1115 #endif 1116 { 1117 return pkt_count_limit_bi_show_1(buf); 1118 } 1119 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20) 1120 static ssize_t sysfs_pkt_count_limit_bi_store_1( struct device *_dev, struct device_attribute *attr,const char *buffer, size_t count ) 1121 #else 1122 static ssize_t sysfs_pkt_count_limit_bi_store_1( struct device *_dev, const char *buffer, size_t count ) 1123 #endif 1124 { 1125 char buf[10]; 1126 int i = 0; 1127 uint32_t value; 1128 if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1)) 1129 return -EFAULT; 1130 value = simple_strtoul(buf, NULL, 10); 1131 pkt_count_limit_bi_store_1(value); 1132 return count; 1133 } 1134 DEVICE_ATTR(pkt_count_limit_bi_1, S_IRUGO|S_IWUSR, sysfs_pkt_count_limit_bi_show_1, sysfs_pkt_count_limit_bi_store_1); 1135 1136 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20) 1137 static ssize_t sysfs_pkt_count_limit_bo_show_1( struct device *_dev, struct device_attribute *attr,char *buf) 1138 #else 1139 static ssize_t sysfs_pkt_count_limit_bo_show_1( struct device *_dev,char *buf) 1140 #endif 1141 { 1142 return pkt_count_limit_bo_show_1(buf); 1143 } 1144 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20) 1145 static ssize_t sysfs_pkt_count_limit_bo_store_1( struct device *_dev, struct device_attribute *attr,const char *buffer, size_t count ) 1146 #else 1147 static ssize_t sysfs_pkt_count_limit_bo_store_1( struct device *_dev, const char *buffer, size_t count ) 1148 #endif 1149 { 1150 char buf[10]; 1151 int i = 0; 1152 uint32_t value; 1153 if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1)) 1154 return -EFAULT; 1155 value = simple_strtoul(buf, NULL, 10); 1156 pkt_count_limit_bo_store_1(value); 1157 return count; 1158 } 1159 DEVICE_ATTR(pkt_count_limit_bo_1, S_IRUGO|S_IWUSR, sysfs_pkt_count_limit_bo_show_1, sysfs_pkt_count_limit_bo_store_1); 1160 1161 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20) 1162 static ssize_t sysfs_pkt_count_limit_bi_show_2( struct device *_dev, struct device_attribute *attr,char *buf) 1163 #else 1164 static ssize_t sysfs_pkt_count_limit_bi_show_2( struct device *_dev,char *buf) 1165 #endif 1166 { 1167 return pkt_count_limit_bi_show_2(buf); 1168 } 1169 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20) 1170 static ssize_t sysfs_pkt_count_limit_bi_store_2( struct device *_dev, struct device_attribute *attr,const char *buffer, size_t count ) 1171 #else 1172 static ssize_t sysfs_pkt_count_limit_bi_2( struct device *_dev, const char *buffer, size_t count ) 1173 #endif 1174 { 1175 char buf[10]; 1176 int i = 0; 1177 uint32_t value; 1178 if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1)) 1179 return -EFAULT; 1180 value = simple_strtoul(buf, NULL, 10); 1181 pkt_count_limit_bi_store_2(value); 1182 return count; 1183 } 1184 DEVICE_ATTR(pkt_count_limit_bi_2, S_IRUGO|S_IWUSR, sysfs_pkt_count_limit_bi_show_2, sysfs_pkt_count_limit_bi_store_2); 1185 1186 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20) 1187 static ssize_t sysfs_pkt_count_limit_bo_show_2( struct device *_dev, struct device_attribute *attr,char *buf) 1188 #else 1189 static ssize_t sysfs_pkt_count_limit_bo_show_2( struct device *_dev,char *buf) 1190 #endif 1191 { 1192 return pkt_count_limit_bo_show_2(buf); 1193 } 1194 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20) 1195 static ssize_t sysfs_pkt_count_limit_bo_store_2( struct device *_dev, struct device_attribute *attr,const char *buffer, size_t count ) 1196 #else 1197 static ssize_t sysfs_pkt_count_limit_bo_store_2( struct device *_dev, const char *buffer, size_t count ) 1198 #endif 1199 { 1200 char buf[10]; 1201 int i = 0; 1202 uint32_t value; 1203 if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1)) 1204 return -EFAULT; 1205 value = simple_strtoul(buf, NULL, 10); 1206 pkt_count_limit_bo_store_2(value); 1207 return count; 1208 } 1209 DEVICE_ATTR(pkt_count_limit_bo_2, S_IRUGO|S_IWUSR, sysfs_pkt_count_limit_bo_show_2, sysfs_pkt_count_limit_bo_store_2); 1210 #else 1211 static ssize_t pkt_count_limit_bi_show(char *buf) 1212 { 1213 return sprintf( buf, "%d\n",ifxusb_hcd.pkt_count_limit_bi ); 1214 } 1215 static ssize_t pkt_count_limit_bo_show(char *buf) 1216 { 1217 return sprintf( buf, "%d\n",ifxusb_hcd.pkt_count_limit_bo ); 1218 } 1219 static void pkt_count_limit_bi_store(uint32_t value) 1220 { 1221 if (value<=13) 1222 ifxusb_hcd.pkt_count_limit_bi = value; 1223 } 1224 static void pkt_count_limit_bo_store(uint32_t value) 1225 { 1226 if (value<=13) 1227 ifxusb_hcd.pkt_count_limit_bo = value; 1228 } 1229 static ssize_t procfs_pkt_count_limit_bi_show(char *buf, char **start, off_t offset, int count, int *eof, void *data) 1230 { 1231 return pkt_count_limit_bi_show(buf); 1232 } 1233 static ssize_t procfs_pkt_count_limit_bo_show(char *buf, char **start, off_t offset, int count, int *eof, void *data) 1234 { 1235 return pkt_count_limit_bo_show(buf); 1236 } 1237 static ssize_t procfs_pkt_count_limit_bi_store(struct file *file, const char *buffer, unsigned long count, void *data) 1238 { 1239 char buf[10]; 1240 int i = 0; 1241 uint32_t value; 1242 if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1)) 1243 return -EFAULT; 1244 value = simple_strtoul(buf, NULL, 10); 1245 pkt_count_limit_bi_store(value); 1246 return count; 1247 } 1248 static ssize_t procfs_pkt_count_limit_bo_store(struct file *file, const char *buffer, unsigned long count, void *data) 1249 { 1250 char buf[10]; 1251 int i = 0; 1252 uint32_t value; 1253 if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1)) 1254 return -EFAULT; 1255 value = simple_strtoul(buf, NULL, 10); 1256 pkt_count_limit_bo_store(value); 1257 return count; 1258 } 1259 1260 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20) 1261 static ssize_t sysfs_pkt_count_limit_bi_show( struct device *_dev, struct device_attribute *attr,char *buf) 1262 #else 1263 static ssize_t sysfs_pkt_count_limit_bi_show( struct device *_dev,char *buf) 1264 #endif 1265 { 1266 return pkt_count_limit_bi_show(buf); 1267 } 1268 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20) 1269 static ssize_t sysfs_pkt_count_limit_bi_store( struct device *_dev, struct device_attribute *attr,const char *buffer, size_t count ) 1270 #else 1271 static ssize_t sysfs_pkt_count_limit_bi_store( struct device *_dev, const char *buffer, size_t count ) 1272 #endif 1273 { 1274 char buf[10]; 1275 int i = 0; 1276 uint32_t value; 1277 if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1)) 1278 return -EFAULT; 1279 value = simple_strtoul(buf, NULL, 10); 1280 pkt_count_limit_bi_store(value); 1281 return count; 1282 } 1283 DEVICE_ATTR(pkt_count_limit_bi, S_IRUGO|S_IWUSR, sysfs_pkt_count_limit_bi_show, sysfs_pkt_count_limit_bi_store); 1284 1285 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20) 1286 static ssize_t sysfs_pkt_count_limit_bo_show( struct device *_dev, struct device_attribute *attr,char *buf) 1287 #else 1288 static ssize_t sysfs_pkt_count_limit_bo_show( struct device *_dev,char *buf) 1289 #endif 1290 { 1291 return pkt_count_limit_bo_show(buf); 1292 } 1293 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20) 1294 static ssize_t sysfs_pkt_count_limit_bo_store( struct device *_dev, struct device_attribute *attr,const char *buffer, size_t count ) 1295 #else 1296 static ssize_t sysfs_pkt_count_limit_bo_store( struct device *_dev, const char *buffer, size_t count ) 1297 #endif 1298 { 1299 char buf[10]; 1300 int i = 0; 1301 uint32_t value; 1302 if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1)) 1303 return -EFAULT; 1304 value = simple_strtoul(buf, NULL, 10); 1305 pkt_count_limit_bo_store(value); 1306 return count; 1307 } 1308 DEVICE_ATTR(pkt_count_limit_bo, S_IRUGO|S_IWUSR, sysfs_pkt_count_limit_bo_show, sysfs_pkt_count_limit_bo_store); 1309 #endif 1310 1311///////////////////////////////////////////////////////////////////////////////////////////////////// 1312///////////////////////////////////////////////////////////////////////////////////////////////////// 1313///////////////////////////////////////////////////////////////////////////////////////////////////// 1314 1315 #ifdef __IS_DUAL__ 1316 static ssize_t buspower_show_1(char *buf) 1317 { 1318 if(ifxusb_vbus (&ifxusb_hcd_1.core_if)==1) return sprintf( buf, "1\n" ); 1319 if(ifxusb_vbus (&ifxusb_hcd_1.core_if)==0) return sprintf( buf, "0\n" ); 1320 return sprintf( buf, "UNKNOWN\n" ); 1321 } 1322 static void buspower_store_1(uint32_t value) 1323 { 1324 if (value==1) ifxusb_vbus_on (&ifxusb_hcd_1.core_if); 1325 else if(value==0) ifxusb_vbus_off(&ifxusb_hcd_1.core_if); 1326 } 1327 static ssize_t buspower_show_2(char *buf) 1328 { 1329 if(ifxusb_vbus (&ifxusb_hcd_2.core_if)==1) return sprintf( buf, "1\n" ); 1330 if(ifxusb_vbus (&ifxusb_hcd_2.core_if)==0) return sprintf( buf, "0\n" ); 1331 return sprintf( buf, "UNKNOWN\n" ); 1332 } 1333 static void buspower_store_2(uint32_t value) 1334 { 1335 if (value==1) ifxusb_vbus_on (&ifxusb_hcd_2.core_if); 1336 else if(value==0) ifxusb_vbus_off(&ifxusb_hcd_2.core_if); 1337 } 1338 static ssize_t procfs_buspower_show_1(char *buf, char **start, off_t offset, int count, int *eof, void *data) 1339 { 1340 return buspower_show_1(buf); 1341 } 1342 static ssize_t procfs_buspower_store_1(struct file *file, const char *buffer, unsigned long count, void *data) 1343 { 1344 char buf[10]; 1345 int i = 0; 1346 uint32_t value; 1347 if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1)) 1348 return -EFAULT; 1349 value = simple_strtoul(buf, NULL, 10); 1350 buspower_store_1(value); 1351 return count; 1352 } 1353 static ssize_t procfs_buspower_show_2(char *buf, char **start, off_t offset, int count, int *eof, void *data) 1354 { 1355 return buspower_show_2(buf); 1356 } 1357 static ssize_t procfs_buspower_store_2(struct file *file, const char *buffer, unsigned long count, void *data) 1358 { 1359 char buf[10]; 1360 int i = 0; 1361 uint32_t value; 1362 if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1)) 1363 return -EFAULT; 1364 value = simple_strtoul(buf, NULL, 10); 1365 buspower_store_2(value); 1366 return count; 1367 } 1368 1369 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20) 1370 static ssize_t sysfs_buspower_show_1( struct device *_dev, struct device_attribute *attr,char *buf) 1371 #else 1372 static ssize_t sysfs_buspower_show_1( struct device *_dev,char *buf) 1373 #endif 1374 { 1375 return buspower_show_1(buf); 1376 } 1377 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20) 1378 static ssize_t sysfs_buspower_store_1( struct device *_dev, struct device_attribute *attr,const char *buffer, size_t count ) 1379 #else 1380 static ssize_t sysfs_buspower_store_1( struct device *_dev, const char *buffer, size_t count ) 1381 #endif 1382 { 1383 char buf[10]; 1384 int i = 0; 1385 uint32_t value; 1386 if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1)) 1387 return -EFAULT; 1388 value = simple_strtoul(buf, NULL, 10); 1389 buspower_store_1(value); 1390 return count; 1391 } 1392 DEVICE_ATTR(buspower_1, S_IRUGO|S_IWUSR, sysfs_buspower_show_1, sysfs_buspower_store_1); 1393 1394 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20) 1395 static ssize_t sysfs_buspower_show_2( struct device *_dev, struct device_attribute *attr,char *buf) 1396 #else 1397 static ssize_t sysfs_buspower_show_2( struct device *_dev,char *buf) 1398 #endif 1399 { 1400 return buspower_show_2(buf); 1401 } 1402 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20) 1403 static ssize_t sysfs_buspower_store_2( struct device *_dev, struct device_attribute *attr,const char *buffer, size_t count ) 1404 #else 1405 static ssize_t sysfs_buspower_store_2( struct device *_dev, const char *buffer, size_t count ) 1406 #endif 1407 { 1408 char buf[10]; 1409 int i = 0; 1410 uint32_t value; 1411 if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1)) 1412 return -EFAULT; 1413 value = simple_strtoul(buf, NULL, 10); 1414 buspower_store_2(value); 1415 return count; 1416 } 1417 DEVICE_ATTR(buspower_2, S_IRUGO|S_IWUSR, sysfs_buspower_show_2, sysfs_buspower_store_2); 1418 #else 1419 static ssize_t buspower_show(char *buf) 1420 { 1421 if(ifxusb_vbus (&ifxusb_hcd.core_if)==1) return sprintf( buf, "1\n" ); 1422 if(ifxusb_vbus (&ifxusb_hcd.core_if)==0) return sprintf( buf, "0\n" ); 1423 return sprintf( buf, "UNKNOWN\n" ); 1424 } 1425 static void buspower_store(uint32_t value) 1426 { 1427 if (value==1) ifxusb_vbus_on (&ifxusb_hcd.core_if); 1428 else if(value==0) ifxusb_vbus_off(&ifxusb_hcd.core_if); 1429 } 1430 static ssize_t procfs_buspower_show(char *buf, char **start, off_t offset, int count, int *eof, void *data) 1431 { 1432 return buspower_show(buf); 1433 } 1434 static ssize_t procfs_buspower_store(struct file *file, const char *buffer, unsigned long count, void *data) 1435 { 1436 char buf[10]; 1437 int i = 0; 1438 uint32_t value; 1439 if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1)) 1440 return -EFAULT; 1441 value = simple_strtoul(buf, NULL, 10); 1442 buspower_store(value); 1443 return count; 1444 } 1445 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20) 1446 static ssize_t sysfs_buspower_show( struct device *_dev, struct device_attribute *attr,char *buf) 1447 #else 1448 static ssize_t sysfs_buspower_show( struct device *_dev, char *buf) 1449 #endif 1450 { 1451 return buspower_show(buf); 1452 } 1453 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20) 1454 static ssize_t sysfs_buspower_store( struct device *_dev, struct device_attribute *attr,const char *buffer, size_t count ) 1455 #else 1456 static ssize_t sysfs_buspower_store( struct device *_dev, const char *buffer, size_t count ) 1457 #endif 1458 { 1459 char buf[10]; 1460 int i = 0; 1461 uint32_t value; 1462 if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1)) 1463 return -EFAULT; 1464 value = simple_strtoul(buf, NULL, 10); 1465 buspower_store(value); 1466 return count; 1467 } 1468 DEVICE_ATTR(buspower, S_IRUGO|S_IWUSR, sysfs_buspower_show, sysfs_buspower_store); 1469 #endif 1470 1471///////////////////////////////////////////////////////////////////////////////////////////////////// 1472///////////////////////////////////////////////////////////////////////////////////////////////////// 1473///////////////////////////////////////////////////////////////////////////////////////////////////// 1474 1475 1476 #ifdef __IS_DUAL__ 1477 static ssize_t bussuspend_show_1(char *buf) 1478 { 1479 hprt0_data_t val; 1480 val.d32 = ifxusb_rreg(ifxusb_hcd_1.core_if.hprt0); 1481 return sprintf (buf, "Bus Suspend = 0x%x\n", val.b.prtsusp); 1482 } 1483 static ssize_t bussuspend_show_2(char *buf) 1484 { 1485 hprt0_data_t val; 1486 val.d32 = ifxusb_rreg(ifxusb_hcd_2.core_if.hprt0); 1487 return sprintf (buf, "Bus Suspend = 0x%x\n", val.b.prtsusp); 1488 } 1489 1490 static ssize_t procfs_bussuspend_show_1(char *buf, char **start, off_t offset, int count, int *eof, void *data) 1491 { 1492 return bussuspend_show_1(buf); 1493 } 1494 static ssize_t procfs_bussuspend_show_2(char *buf, char **start, off_t offset, int count, int *eof, void *data) 1495 { 1496 return bussuspend_show_2(buf); 1497 } 1498 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20) 1499 static ssize_t sysfs_bussuspend_show_1( struct device *_dev, struct device_attribute *attr,char *buf) 1500 #else 1501 static ssize_t sysfs_bussuspend_show_1( struct device *_dev,char *buf) 1502 #endif 1503 { 1504 return bussuspend_show_1(buf); 1505 } 1506 DEVICE_ATTR(bussuspend_1, S_IRUGO|S_IWUSR, sysfs_bussuspend_show_1, 0); 1507 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20) 1508 static ssize_t sysfs_bussuspend_show_2( struct device *_dev, struct device_attribute *attr,char *buf) 1509 #else 1510 static ssize_t sysfs_bussuspend_show_2( struct device *_dev,char *buf) 1511 #endif 1512 { 1513 return bussuspend_show_2(buf); 1514 } 1515 DEVICE_ATTR(bussuspend_2, S_IRUGO|S_IWUSR, sysfs_bussuspend_show_2, 0); 1516 #else 1517 static ssize_t bussuspend_show(char *buf) 1518 { 1519 hprt0_data_t val; 1520 val.d32 = ifxusb_rreg(ifxusb_hcd.core_if.hprt0); 1521 return sprintf (buf, "Bus Suspend = 0x%x\n", val.b.prtsusp); 1522 } 1523 static ssize_t procfs_bussuspend_show(char *buf, char **start, off_t offset, int count, int *eof, void *data) 1524 { 1525 return bussuspend_show(buf); 1526 } 1527 1528 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20) 1529 static ssize_t sysfs_bussuspend_show( struct device *_dev, struct device_attribute *attr,char *buf) 1530 #else 1531 static ssize_t sysfs_bussuspend_show( struct device *_dev, char *buf) 1532 #endif 1533 { 1534 return bussuspend_show(buf); 1535 } 1536 DEVICE_ATTR(bussuspend, S_IRUGO|S_IWUSR, sysfs_bussuspend_show, 0); 1537 #endif 1538 1539///////////////////////////////////////////////////////////////////////////////////////////////////// 1540///////////////////////////////////////////////////////////////////////////////////////////////////// 1541///////////////////////////////////////////////////////////////////////////////////////////////////// 1542 1543 #ifdef __IS_DUAL__ 1544 static ssize_t busconnected_show_1(char *buf) 1545 { 1546 hprt0_data_t val; 1547 val.d32 = ifxusb_rreg(ifxusb_hcd_1.core_if.hprt0); 1548 return sprintf (buf, "Bus Connected = 0x%x\n", val.b.prtconnsts); 1549 } 1550 static ssize_t busconnected_show_2(char *buf) 1551 { 1552 hprt0_data_t val; 1553 val.d32 = ifxusb_rreg(ifxusb_hcd_2.core_if.hprt0); 1554 return sprintf (buf, "Bus Connected = 0x%x\n", val.b.prtconnsts); 1555 } 1556 1557 static ssize_t procfs_busconnected_show_1(char *buf, char **start, off_t offset, int count, int *eof, void *data) 1558 { 1559 return busconnected_show_1(buf); 1560 } 1561 static ssize_t procfs_busconnected_show_2(char *buf, char **start, off_t offset, int count, int *eof, void *data) 1562 { 1563 return busconnected_show_2(buf); 1564 } 1565 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20) 1566 static ssize_t sysfs_busconnected_show_1( struct device *_dev, struct device_attribute *attr,char *buf) 1567 #else 1568 static ssize_t sysfs_busconnected_show_1( struct device *_dev,char *buf) 1569 #endif 1570 { 1571 return busconnected_show_1(buf); 1572 } 1573 DEVICE_ATTR(busconnected_1, S_IRUGO|S_IWUSR, sysfs_busconnected_show_1, 0); 1574 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20) 1575 static ssize_t sysfs_busconnected_show_2( struct device *_dev, struct device_attribute *attr,char *buf) 1576 #else 1577 static ssize_t sysfs_busconnected_show_2( struct device *_dev,char *buf) 1578 #endif 1579 { 1580 return busconnected_show_2(buf); 1581 } 1582 DEVICE_ATTR(busconnected_2, S_IRUGO|S_IWUSR, sysfs_busconnected_show_2, 0); 1583 #else 1584 static ssize_t busconnected_show(char *buf) 1585 { 1586 hprt0_data_t val; 1587 val.d32 = ifxusb_rreg(ifxusb_hcd.core_if.hprt0); 1588 return sprintf (buf, "Bus Connected = 0x%x\n", val.b.prtconnsts); 1589 } 1590 static ssize_t procfs_busconnected_show(char *buf, char **start, off_t offset, int count, int *eof, void *data) 1591 { 1592 return busconnected_show(buf); 1593 } 1594 1595 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20) 1596 static ssize_t sysfs_busconnected_show( struct device *_dev, struct device_attribute *attr,char *buf) 1597 #else 1598 static ssize_t sysfs_busconnected_show( struct device *_dev, char *buf) 1599 #endif 1600 { 1601 return busconnected_show(buf); 1602 } 1603 DEVICE_ATTR(busconnected, S_IRUGO|S_IWUSR, sysfs_busconnected_show, 0); 1604 #endif 1605 1606///////////////////////////////////////////////////////////////////////////////////////////////////// 1607///////////////////////////////////////////////////////////////////////////////////////////////////// 1608///////////////////////////////////////////////////////////////////////////////////////////////////// 1609 1610 #ifdef __IS_DUAL__ 1611 static ssize_t connectspeed_show_1(char *buf) 1612 { 1613 hprt0_data_t val; 1614 val.d32 = ifxusb_rreg(ifxusb_hcd_1.core_if.hprt0); 1615 if( val.b.prtspd ==0) return sprintf (buf, "Bus Speed = High (%d)\n", val.b.prtspd); 1616 if( val.b.prtspd ==1) return sprintf (buf, "Bus Speed = Full (%d)\n", val.b.prtspd); 1617 if( val.b.prtspd ==2) return sprintf (buf, "Bus Speed = Low (%d)\n", val.b.prtspd); 1618 return sprintf (buf, "Bus Speed = Unknown (%d)\n", val.b.prtspd); 1619 } 1620 static ssize_t connectspeed_show_2(char *buf) 1621 { 1622 hprt0_data_t val; 1623 val.d32 = ifxusb_rreg(ifxusb_hcd_2.core_if.hprt0); 1624 if( val.b.prtspd ==0) return sprintf (buf, "Bus Speed = High (%d)\n", val.b.prtspd); 1625 if( val.b.prtspd ==1) return sprintf (buf, "Bus Speed = Full (%d)\n", val.b.prtspd); 1626 if( val.b.prtspd ==2) return sprintf (buf, "Bus Speed = Low (%d)\n", val.b.prtspd); 1627 return sprintf (buf, "Bus Speed = Unknown (%d)\n", val.b.prtspd); 1628 } 1629 1630 static ssize_t procfs_connectspeed_show_1(char *buf, char **start, off_t offset, int count, int *eof, void *data) 1631 { 1632 return connectspeed_show_1(buf); 1633 } 1634 static ssize_t procfs_connectspeed_show_2(char *buf, char **start, off_t offset, int count, int *eof, void *data) 1635 { 1636 return connectspeed_show_2(buf); 1637 } 1638 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20) 1639 static ssize_t sysfs_connectspeed_show_1( struct device *_dev, struct device_attribute *attr,char *buf) 1640 #else 1641 static ssize_t sysfs_connectspeed_show_1( struct device *_dev,char *buf) 1642 #endif 1643 { 1644 return connectspeed_show_1(buf); 1645 } 1646 DEVICE_ATTR(connectspeed_1, S_IRUGO|S_IWUSR, sysfs_connectspeed_show_1, 0); 1647 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20) 1648 static ssize_t sysfs_connectspeed_show_2( struct device *_dev, struct device_attribute *attr,char *buf) 1649 #else 1650 static ssize_t sysfs_connectspeed_show_2( struct device *_dev,char *buf) 1651 #endif 1652 { 1653 return connectspeed_show_2(buf); 1654 } 1655 DEVICE_ATTR(connectspeed_2, S_IRUGO|S_IWUSR, sysfs_connectspeed_show_2, 0); 1656 #else 1657 static ssize_t connectspeed_show(char *buf) 1658 { 1659 hprt0_data_t val; 1660 val.d32 = ifxusb_rreg(ifxusb_hcd.core_if.hprt0); 1661 if( val.b.prtspd ==0) return sprintf (buf, "Bus Speed = High (%d)\n", val.b.prtspd); 1662 if( val.b.prtspd ==1) return sprintf (buf, "Bus Speed = Full (%d)\n", val.b.prtspd); 1663 if( val.b.prtspd ==2) return sprintf (buf, "Bus Speed = Low (%d)\n", val.b.prtspd); 1664 return sprintf (buf, "Bus Speed = Unknown (%d)\n", val.b.prtspd); 1665 } 1666 1667 static ssize_t procfs_connectspeed_show(char *buf, char **start, off_t offset, int count, int *eof, void *data) 1668 { 1669 return connectspeed_show(buf); 1670 } 1671 1672 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20) 1673 static ssize_t sysfs_connectspeed_show( struct device *_dev, struct device_attribute *attr,char *buf) 1674 #else 1675 static ssize_t sysfs_connectspeed_show( struct device *_dev, char *buf) 1676 #endif 1677 { 1678 return connectspeed_show(buf); 1679 } 1680 DEVICE_ATTR(connectspeed, S_IRUGO|S_IWUSR, sysfs_connectspeed_show, 0); 1681 #endif 1682///////////////////////////////////////////////////////////////////////////////////////////////////// 1683///////////////////////////////////////////////////////////////////////////////////////////////////// 1684///////////////////////////////////////////////////////////////////////////////////////////////////// 1685#endif 1686 1687 1688#ifdef __IS_DEVICE__ 1689///////////////////////////////////////////////////////////////////////////////////////////////////// 1690///////////////////////////////////////////////////////////////////////////////////////////////////// 1691///////////////////////////////////////////////////////////////////////////////////////////////////// 1692 static ssize_t devspeed_show(char *buf) 1693 { 1694 dcfg_data_t val; 1695 val.d32 = ifxusb_rreg(&ifxusb_pcd.core_if.dev_global_regs->dcfg); 1696 if( val.b.devspd ==0) return sprintf (buf, "Dev Speed = High (%d)\n", val.b.devspd); 1697 if( val.b.devspd ==1) return sprintf (buf, "Dev Speed = Full (%d)\n", val.b.devspd); 1698 if( val.b.devspd ==3) return sprintf (buf, "Dev Speed = Full (%d)\n", val.b.devspd); 1699 return sprintf (buf, "Dev Speed = Unknown (%d)\n", val.b.devspd); 1700 } 1701 1702 static ssize_t procfs_devspeed_show(char *buf, char **start, off_t offset, int count, int *eof, void *data) 1703 { 1704 return devspeed_show(buf); 1705 } 1706 1707 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20) 1708 static ssize_t sysfs_devspeed_show( struct device *_dev, struct device_attribute *attr,char *buf) 1709 #else 1710 static ssize_t sysfs_devspeed_show( struct device *_dev, char *buf) 1711 #endif 1712 { 1713 return devspeed_show(buf); 1714 } 1715 DEVICE_ATTR(devspeed, S_IRUGO|S_IWUSR, sysfs_devspeed_show, 0); 1716 1717 static ssize_t enumspeed_show(char *buf) 1718 { 1719 dsts_data_t val; 1720 val.d32 = ifxusb_rreg(&ifxusb_pcd.core_if.dev_global_regs->dsts); 1721 if( val.b.enumspd ==0) return sprintf (buf, "Enum Speed = High (%d)\n", val.b.enumspd); 1722 if( val.b.enumspd ==1) return sprintf (buf, "Enum Speed = Full (%d)\n", val.b.enumspd); 1723 if( val.b.enumspd ==2) return sprintf (buf, "Enum Speed = Low (%d)\n", val.b.enumspd); 1724 return sprintf (buf, "Enum Speed = invalid(%d)\n", val.b.enumspd); 1725 } 1726 1727 static ssize_t procfs_enumspeed_show(char *buf, char **start, off_t offset, int count, int *eof, void *data) 1728 { 1729 return enumspeed_show(buf); 1730 } 1731 1732 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20) 1733 static ssize_t sysfs_enumspeed_show( struct device *_dev, struct device_attribute *attr,char *buf) 1734 #else 1735 static ssize_t sysfs_enumspeed_show( struct device *_dev, char *buf) 1736 #endif 1737 { 1738 return enumspeed_show(buf); 1739 } 1740 DEVICE_ATTR(enumspeed, S_IRUGO|S_IWUSR, sysfs_enumspeed_show, 0); 1741///////////////////////////////////////////////////////////////////////////////////////////////////// 1742///////////////////////////////////////////////////////////////////////////////////////////////////// 1743///////////////////////////////////////////////////////////////////////////////////////////////////// 1744#endif 1745 1746 1747////////////////////////////////////////////////////////////////////////////////// 1748#ifdef __ENABLE_DUMP__ 1749 1750 #ifdef __IS_DUAL__ 1751 static void dump_reg_1(void) 1752 { 1753 ifxusb_dump_registers_h(&ifxusb_hcd_1.core_if); 1754 } 1755 static void dump_reg_2(void) 1756 { 1757 ifxusb_dump_registers_h(&ifxusb_hcd_2.core_if); 1758 } 1759 1760 static ssize_t procfs_dump_reg_show_1(char *buf, char **start, off_t offset, int count, int *eof, void *data) 1761 { 1762 dump_reg_1(); 1763 return 0; 1764 } 1765 static ssize_t procfs_dump_reg_show_2(char *buf, char **start, off_t offset, int count, int *eof, void *data) 1766 { 1767 dump_reg_2(); 1768 return 0; 1769 } 1770 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20) 1771 static ssize_t sysfs_dump_reg_show_1( struct device *_dev, struct device_attribute *attr,char *buf) 1772 #else 1773 static ssize_t sysfs_dump_reg_show_1( struct device *_dev,char *buf) 1774 #endif 1775 { 1776 dump_reg_1(); 1777 return 0; 1778 } 1779 DEVICE_ATTR(dump_reg_h_1, S_IRUGO|S_IWUSR, sysfs_dump_reg_show_1, 0); 1780 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20) 1781 static ssize_t sysfs_dump_reg_show_2( struct device *_dev, struct device_attribute *attr,char *buf) 1782 #else 1783 static ssize_t sysfs_dump_reg_show_2( struct device *_dev,char *buf) 1784 #endif 1785 { 1786 dump_reg_2(); 1787 return 0; 1788 } 1789 DEVICE_ATTR(dump_reg_h_2, S_IRUGO|S_IWUSR, sysfs_dump_reg_show_2, 0); 1790 #else 1791 static void dump_reg(void) 1792 { 1793 #ifdef __IS_HOST__ 1794 ifxusb_dump_registers_h(&ifxusb_hcd.core_if); 1795 #endif 1796 #ifdef __IS_DEVICE__ 1797 ifxusb_dump_registers_d(&ifxusb_pcd.core_if); 1798 #endif 1799 } 1800 static ssize_t procfs_dump_reg_show(char *buf, char **start, off_t offset, int count, int *eof, void *data) 1801 { 1802 dump_reg(); 1803 return 0; 1804 } 1805 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20) 1806 static ssize_t sysfs_dump_reg_show( struct device *_dev, struct device_attribute *attr,char *buf) 1807 #else 1808 static ssize_t sysfs_dump_reg_show( struct device *_dev,char *buf) 1809 #endif 1810 { 1811 dump_reg(); 1812 return 0; 1813 } 1814 #ifdef __IS_HOST__ 1815 DEVICE_ATTR(dump_reg_h, S_IRUGO|S_IWUSR, sysfs_dump_reg_show, 0); 1816 #else 1817 DEVICE_ATTR(dump_reg_d, S_IRUGO|S_IWUSR, sysfs_dump_reg_show, 0); 1818 #endif 1819 #endif 1820 1821 1822///////////////////////////////////////////////////////////////////////////////////////////////////// 1823///////////////////////////////////////////////////////////////////////////////////////////////////// 1824///////////////////////////////////////////////////////////////////////////////////////////////////// 1825 1826 #ifdef __IS_DUAL__ 1827 static void dump_spram_1(void) 1828 { 1829 ifxusb_dump_spram_h(&ifxusb_hcd_1.core_if); 1830 } 1831 static void dump_spram_2(void) 1832 { 1833 ifxusb_dump_spram_h(&ifxusb_hcd_2.core_if); 1834 } 1835 1836 static ssize_t procfs_dump_spram_show_1(char *buf, char **start, off_t offset, int count, int *eof, void *data) 1837 { 1838 dump_spram_1(); 1839 return 0; 1840 } 1841 static ssize_t procfs_dump_spram_show_2(char *buf, char **start, off_t offset, int count, int *eof, void *data) 1842 { 1843 dump_spram_2(); 1844 return 0; 1845 } 1846 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20) 1847 static ssize_t sysfs_dump_spram_show_1( struct device *_dev, struct device_attribute *attr,char *buf) 1848 #else 1849 static ssize_t sysfs_dump_spram_show_1( struct device *_dev,char *buf) 1850 #endif 1851 { 1852 dump_spram_1(); 1853 return 0; 1854 } 1855 DEVICE_ATTR(dump_spram_h_1, S_IRUGO|S_IWUSR, sysfs_dump_spram_show_1, 0); 1856 1857 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20) 1858 static ssize_t sysfs_dump_spram_show_2( struct device *_dev, struct device_attribute *attr,char *buf) 1859 #else 1860 static ssize_t sysfs_dump_spram_show_2( struct device *_dev,char *buf) 1861 #endif 1862 { 1863 dump_spram_2(); 1864 return 0; 1865 } 1866 DEVICE_ATTR(dump_spram_h_2, S_IRUGO|S_IWUSR, sysfs_dump_spram_show_2, 0); 1867 #else 1868 static void dump_spram(void) 1869 { 1870 #ifdef __IS_HOST__ 1871 ifxusb_dump_spram_h(&ifxusb_hcd.core_if); 1872 #endif 1873 #ifdef __IS_DEVICE__ 1874 ifxusb_dump_spram_d(&ifxusb_pcd.core_if); 1875 #endif 1876 } 1877 static ssize_t procfs_dump_spram_show(char *buf, char **start, off_t offset, int count, int *eof, void *data) 1878 { 1879 dump_spram(); 1880 return 0; 1881 } 1882 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20) 1883 static ssize_t sysfs_dump_spram_show( struct device *_dev, struct device_attribute *attr,char *buf) 1884 #else 1885 static ssize_t sysfs_dump_spram_show( struct device *_dev,char *buf) 1886 #endif 1887 { 1888 dump_spram(); 1889 return 0; 1890 } 1891 #ifdef __IS_HOST__ 1892 DEVICE_ATTR(dump_spram_h, S_IRUGO|S_IWUSR, sysfs_dump_spram_show, 0); 1893 #else 1894 DEVICE_ATTR(dump_spram_d, S_IRUGO|S_IWUSR, sysfs_dump_spram_show, 0); 1895 #endif 1896 1897 #endif 1898///////////////////////////////////////////////////////////////////////////////////////////////////// 1899///////////////////////////////////////////////////////////////////////////////////////////////////// 1900///////////////////////////////////////////////////////////////////////////////////////////////////// 1901 1902 #ifdef __IS_HOST__ 1903 #ifdef __IS_DUAL__ 1904 static ssize_t procfs_dump_host_state_show_1(char *buf, char **start, off_t offset, int count, int *eof, void *data) 1905 { 1906 ifxhcd_dump_state(&ifxusb_hcd_1); 1907 return 0; 1908 } 1909 static ssize_t procfs_dump_host_state_show_2(char *buf, char **start, off_t offset, int count, int *eof, void *data) 1910 { 1911 ifxhcd_dump_state(&ifxusb_hcd_2); 1912 return 0; 1913 } 1914 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20) 1915 static ssize_t sysfs_dump_host_state_show_1( struct device *_dev, struct device_attribute *attr,char *buf) 1916 #else 1917 static ssize_t sysfs_dump_host_state_show_1( struct device *_dev,char *buf) 1918 #endif 1919 { 1920 ifxhcd_dump_state(&ifxusb_hcd_1); 1921 return 0; 1922 } 1923 DEVICE_ATTR(dump_host_state_1, S_IRUGO|S_IWUSR, sysfs_dump_host_state_show_1, 0); 1924 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20) 1925 static ssize_t sysfs_dump_host_state_show_2( struct device *_dev, struct device_attribute *attr,char *buf) 1926 #else 1927 static ssize_t sysfs_dump_host_state_show_2( struct device *_dev,char *buf) 1928 #endif 1929 { 1930 ifxhcd_dump_state(&ifxusb_hcd_2); 1931 return 0; 1932 } 1933 DEVICE_ATTR(dump_host_state_2, S_IRUGO|S_IWUSR, sysfs_dump_host_state_show_2, 0); 1934 #else 1935 static ssize_t procfs_dump_host_state_show(char *buf, char **start, off_t offset, int count, int *eof, void *data) 1936 { 1937 ifxhcd_dump_state(&ifxusb_hcd); 1938 return 0; 1939 } 1940 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20) 1941 static ssize_t sysfs_dump_host_state_show( struct device *_dev, struct device_attribute *attr,char *buf) 1942 #else 1943 static ssize_t sysfs_dump_host_state_show( struct device *_dev,char *buf) 1944 #endif 1945 { 1946 ifxhcd_dump_state(&ifxusb_hcd); 1947 return 0; 1948 } 1949 DEVICE_ATTR(dump_host_state, S_IRUGO|S_IWUSR, sysfs_dump_host_state_show, 0); 1950 #endif 1951 1952///////////////////////////////////////////////////////////////////////////////////////////////////// 1953///////////////////////////////////////////////////////////////////////////////////////////////////// 1954///////////////////////////////////////////////////////////////////////////////////////////////////// 1955 1956 #endif //IS_HOST_ 1957 1958#endif //__ENABLE_DUMP__ 1959///////////////////////////////////////////////////////////////////////////////////////////////////// 1960///////////////////////////////////////////////////////////////////////////////////////////////////// 1961#ifdef __IS_HOST__ 1962 static void host_probe(unsigned long _ptr) 1963 { 1964 ifxhcd_hcd_t *ifxhcd = (ifxhcd_hcd_t *)_ptr; 1965 1966 if(ifxhcd->flags.b.port_connect_status) 1967 { 1968 del_timer(&ifxhcd->host_probe_timer); 1969 del_timer(&ifxhcd->autoprobe_timer); 1970 ifxhcd->power_status = 0; 1971 } 1972 else 1973 { 1974 del_timer(&ifxhcd->autoprobe_timer); 1975 ifxhcd->autoprobe_timer.expires = jiffies + (HZ*ifxhcd->autoprobe_sec); 1976 add_timer(&ifxhcd->autoprobe_timer); 1977 ifxhcd->power_status = 2; 1978 del_timer(&ifxhcd->host_probe_timer); 1979 do_suspend_h(&ifxhcd->core_if); 1980 } 1981 } 1982 1983 static void host_autoprobe(unsigned long _ptr) 1984 { 1985 ifxhcd_hcd_t *ifxhcd = (ifxhcd_hcd_t *)_ptr; 1986 del_timer(&ifxhcd->host_probe_timer); 1987 ifxhcd->host_probe_timer.function = host_probe; 1988 ifxhcd->host_probe_timer.expires = jiffies + (HZ*ifxhcd->probe_sec); 1989 ifxhcd->host_probe_timer.data = (unsigned long)ifxhcd; 1990 add_timer(&ifxhcd->host_probe_timer); 1991 do_resume_h(&ifxhcd->core_if); 1992 } 1993 1994 static void suspend_host_store(ifxhcd_hcd_t *ifxhcd , uint32_t value) 1995 { 1996 if(value==2) 1997 { 1998 del_timer(&ifxhcd->autoprobe_timer); 1999 ifxhcd->autoprobe_timer.function = host_autoprobe; 2000 ifxhcd->autoprobe_timer.expires = jiffies + (HZ*ifxhcd->autoprobe_sec); 2001 ifxhcd->autoprobe_timer.data = (unsigned long)ifxhcd; 2002 add_timer(&ifxhcd->autoprobe_timer); 2003 ifxhcd->power_status = 2; 2004 } 2005 else if(value==1) 2006 { 2007 do_suspend_h(&ifxhcd->core_if); 2008 ifxhcd->power_status = 1; 2009 del_timer(&ifxhcd->host_probe_timer); 2010 del_timer(&ifxhcd->autoprobe_timer); 2011 } 2012 else if(value==0) 2013 { 2014 do_resume_h(&ifxhcd->core_if); 2015 ifxhcd->power_status = 0; 2016 del_timer(&ifxhcd->host_probe_timer); 2017 del_timer(&ifxhcd->autoprobe_timer); 2018 } 2019 } 2020 #ifdef __IS_DUAL__ 2021 static ssize_t procfs_suspend_host_2_store(struct file *file, const char *buffer, unsigned long count, void *data) 2022 { 2023 char buf[10]; 2024 int i = 0; 2025 uint32_t value; 2026 if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1)) 2027 return -EFAULT; 2028 value = simple_strtoul(buf, NULL, 10); 2029 suspend_host_store(&ifxusb_hcd_2,value); 2030 return count; 2031 } 2032 2033 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20) 2034 static ssize_t sysfs_suspend_host_2_store( struct device *_dev, struct device_attribute *attr,const char *buffer, size_t count ) 2035 #else 2036 static ssize_t sysfs_suspend_host_2_store( struct device *_dev, const char *buffer, size_t count ) 2037 #endif 2038 { 2039 char buf[10]; 2040 int i = 0; 2041 uint32_t value; 2042 if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1)) 2043 return -EFAULT; 2044 value = simple_strtoul(buf, NULL, 10); 2045 suspend_host_store(&ifxusb_hcd_2,value); 2046 return count; 2047 } 2048 2049 static ssize_t procfs_suspend_host_1_store(struct file *file, const char *buffer, unsigned long count, void *data) 2050 { 2051 char buf[10]; 2052 int i = 0; 2053 uint32_t value; 2054 if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1)) 2055 return -EFAULT; 2056 value = simple_strtoul(buf, NULL, 10); 2057 suspend_host_store(&ifxusb_hcd_1,value); 2058 return count; 2059 } 2060 2061 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20) 2062 static ssize_t sysfs_suspend_host_1_store( struct device *_dev, struct device_attribute *attr,const char *buffer, size_t count ) 2063 #else 2064 static ssize_t sysfs_suspend_host_1_store( struct device *_dev, const char *buffer, size_t count ) 2065 #endif 2066 { 2067 char buf[10]; 2068 int i = 0; 2069 uint32_t value; 2070 if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1)) 2071 return -EFAULT; 2072 value = simple_strtoul(buf, NULL, 10); 2073 suspend_host_store(&ifxusb_hcd_1,value); 2074 return count; 2075 } 2076 DEVICE_ATTR(suspend_host_2, S_IWUSR,NULL, sysfs_suspend_host_2_store); 2077 DEVICE_ATTR(suspend_host_1, S_IWUSR,NULL, sysfs_suspend_host_1_store); 2078///////////////////////////////////////////////////////////////////////////////////////////////////// 2079 #else 2080 static ssize_t procfs_suspend_host_store(struct file *file, const char *buffer, unsigned long count, void *data) 2081 { 2082 char buf[10]; 2083 int i = 0; 2084 uint32_t value; 2085 if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1)) 2086 return -EFAULT; 2087 value = simple_strtoul(buf, NULL, 10); 2088 suspend_host_store(&ifxusb_hcd,value); 2089 return count; 2090 } 2091 2092 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20) 2093 static ssize_t sysfs_suspend_host_store( struct device *_dev, struct device_attribute *attr,const char *buffer, size_t count ) 2094 #else 2095 static ssize_t sysfs_suspend_host_store( struct device *_dev, const char *buffer, size_t count ) 2096 #endif 2097 { 2098 char buf[10]; 2099 int i = 0; 2100 uint32_t value; 2101 if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1)) 2102 return -EFAULT; 2103 value = simple_strtoul(buf, NULL, 10); 2104 suspend_host_store(&ifxusb_hcd,value); 2105 return count; 2106 } 2107 DEVICE_ATTR(suspend_host, S_IWUSR,NULL, sysfs_suspend_host_store); 2108 #endif 2109#endif 2110 2111///////////////////////////////////////////////////////////////////////////////////////////////////// 2112///////////////////////////////////////////////////////////////////////////////////////////////////// 2113#ifdef __IS_HOST__ 2114 static void probe_host_store(ifxhcd_hcd_t *ifxhcd, uint32_t value) 2115 { 2116 if(ifxhcd->power_status == 1) 2117 { 2118 del_timer(&ifxhcd->host_probe_timer); 2119 ifxhcd->host_probe_timer.function = host_probe; 2120 ifxhcd->host_probe_timer.expires = jiffies + (HZ*ifxhcd->probe_sec); 2121 ifxhcd->host_probe_timer.data = (unsigned long) ifxhcd; 2122 add_timer(&ifxhcd->host_probe_timer); 2123 do_resume_h(&ifxhcd->core_if); 2124 } 2125 } 2126 #ifdef __IS_DUAL__ 2127 static ssize_t probe_host_2_show(char *buf) 2128 { 2129 if(ifxusb_hcd_2.power_status == 0) 2130 return sprintf (buf,"Host 2 power status is ON\n"); 2131 else if(ifxusb_hcd_2.power_status == 1) 2132 return sprintf (buf,"Host 2 power status is Suspend\n"); 2133 else 2134 return sprintf (buf,"Host 2 power status is Auto-probing\n"); 2135 } 2136 static ssize_t probe_host_1_show(char *buf) 2137 { 2138 if(ifxusb_hcd_1.power_status == 0) 2139 return sprintf (buf,"Host 1 power status is ON\n"); 2140 else if(ifxusb_hcd_1.power_status == 1) 2141 return sprintf (buf,"Host 1 power status is Suspend\n"); 2142 else 2143 return sprintf (buf,"Host 1 power status is Auto-probing\n"); 2144 } 2145 static ssize_t procfs_probe_host_2_store(struct file *file, const char *buffer, unsigned long count, void *data) 2146 { 2147 char buf[10]; 2148 int i = 0; 2149 uint32_t value; 2150 if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1)) 2151 return -EFAULT; 2152 value = simple_strtoul(buf, NULL, 10); 2153 probe_host_store(&ifxusb_hcd_2,value); 2154 return count; 2155 } 2156 static ssize_t procfs_probe_host_2_show(char *buf, char **start, off_t offset, int count, int *eof, void *data) 2157 { 2158 return probe_host_2_show(buf); 2159 } 2160 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20) 2161 static ssize_t sysfs_probe_host_2_show( struct device *_dev, struct device_attribute *attr,char *buf) 2162 #else 2163 static ssize_t sysfs_probe_host_2_show( struct device *_dev, char *buf) 2164 #endif 2165 { 2166 return probe_host_2_show(buf); 2167 } 2168 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20) 2169 static ssize_t sysfs_probe_host_2_store( struct device *_dev, struct device_attribute *attr,const char *buffer, size_t count ) 2170 #else 2171 static ssize_t sysfs_probe_host_2_store( struct device *_dev, const char *buffer, size_t count ) 2172 #endif 2173 { 2174 char buf[10]; 2175 int i = 0; 2176 uint32_t value; 2177 if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1)) 2178 return -EFAULT; 2179 value = simple_strtoul(buf, NULL, 10); 2180 probe_host_store(&ifxusb_hcd_2,value); 2181 return count; 2182 } 2183 2184 static ssize_t procfs_probe_host_1_store(struct file *file, const char *buffer, unsigned long count, void *data) 2185 { 2186 char buf[10]; 2187 int i = 0; 2188 uint32_t value; 2189 if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1)) 2190 return -EFAULT; 2191 value = simple_strtoul(buf, NULL, 10); 2192 probe_host_store(&ifxusb_hcd_1,value); 2193 return count; 2194 } 2195 static ssize_t procfs_probe_host_1_show(char *buf, char **start, off_t offset, int count, int *eof, void *data) 2196 { 2197 return probe_host_1_show(buf); 2198 } 2199 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20) 2200 static ssize_t sysfs_probe_host_1_show( struct device *_dev, struct device_attribute *attr,char *buf) 2201 #else 2202 static ssize_t sysfs_probe_host_1_show( struct device *_dev, char *buf) 2203 #endif 2204 { 2205 return probe_host_1_show(buf); 2206 } 2207 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20) 2208 static ssize_t sysfs_probe_host_1_store( struct device *_dev, struct device_attribute *attr,const char *buffer, size_t count ) 2209 #else 2210 static ssize_t sysfs_probe_host_1_store( struct device *_dev, const char *buffer, size_t count ) 2211 #endif 2212 { 2213 char buf[10]; 2214 int i = 0; 2215 uint32_t value; 2216 if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1)) 2217 return -EFAULT; 2218 value = simple_strtoul(buf, NULL, 10); 2219 probe_host_store(&ifxusb_hcd_1,value); 2220 return count; 2221 } 2222 DEVICE_ATTR(probe_host_2, S_IRUGO|S_IWUSR, sysfs_probe_host_2_show, sysfs_probe_host_2_store); 2223 DEVICE_ATTR(probe_host_1, S_IRUGO|S_IWUSR, sysfs_probe_host_1_show, sysfs_probe_host_1_store); 2224///////////////////////////////////////////////////////////////////////////////////////////////////// 2225 #else 2226 static ssize_t probe_host_show(char *buf) 2227 { 2228 if(ifxusb_hcd.power_status == 0) 2229 return sprintf (buf,"Host power status is ON\n"); 2230 else if(ifxusb_hcd.power_status == 1) 2231 return sprintf (buf,"Host power status is Suspend\n"); 2232 else 2233 return sprintf (buf,"Host power status is Auto-probing\n"); 2234 } 2235 static ssize_t procfs_probe_host_store(struct file *file, const char *buffer, unsigned long count, void *data) 2236 { 2237 char buf[10]; 2238 int i = 0; 2239 uint32_t value; 2240 if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1)) 2241 return -EFAULT; 2242 value = simple_strtoul(buf, NULL, 10); 2243 probe_host_store(&ifxusb_hcd,value); 2244 return count; 2245 } 2246 static ssize_t procfs_probe_host_show(char *buf, char **start, off_t offset, int count, int *eof, void *data) 2247 { 2248 return probe_host_show(buf); 2249 } 2250 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20) 2251 static ssize_t sysfs_probe_host_show( struct device *_dev, struct device_attribute *attr,char *buf) 2252 #else 2253 static ssize_t sysfs_probe_host_show( struct device *_dev, char *buf) 2254 #endif 2255 { 2256 return probe_host_show(buf); 2257 } 2258 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20) 2259 static ssize_t sysfs_probe_host_store( struct device *_dev, struct device_attribute *attr,const char *buffer, size_t count ) 2260 #else 2261 static ssize_t sysfs_probe_host_store( struct device *_dev, const char *buffer, size_t count ) 2262 #endif 2263 { 2264 char buf[10]; 2265 int i = 0; 2266 uint32_t value; 2267 if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1)) 2268 return -EFAULT; 2269 value = simple_strtoul(buf, NULL, 10); 2270 probe_host_store(&ifxusb_hcd,value); 2271 return count; 2272 } 2273 DEVICE_ATTR(probe_host, S_IRUGO|S_IWUSR, sysfs_probe_host_show, sysfs_probe_host_store); 2274 #endif 2275#endif 2276///////////////////////////////////////////////////////////////////////////////////////////////////// 2277///////////////////////////////////////////////////////////////////////////////////////////////////// 2278#ifdef __IS_DEVICE__ 2279 static void device_probe(unsigned long _ptr) 2280 { 2281 if(ifxusb_pcd.power_status == 2) 2282 { 2283 del_timer(&ifxusb_pcd.device_autoprobe_timer); 2284 ifxusb_pcd.device_autoprobe_timer.expires = jiffies + (HZ*ifxusb_pcd.autoprobe_sec); 2285 add_timer(&ifxusb_pcd.device_autoprobe_timer); 2286 ifxusb_pcd.power_status = 2; 2287 do_suspend_d(&ifxusb_pcd.core_if); 2288 } 2289 else if(ifxusb_pcd.power_status == 1) 2290 { 2291 do_suspend_d(&ifxusb_pcd.core_if); 2292 ifxusb_pcd.power_status = 1; 2293 } 2294 } 2295 static void device_autoprobe(unsigned long _ptr) 2296 { 2297 init_timer(&ifxusb_pcd.device_probe_timer); 2298 ifxusb_pcd.device_probe_timer.function = device_probe; 2299 ifxusb_pcd.device_probe_timer.expires = jiffies + (HZ*ifxusb_pcd.probe_sec); 2300 add_timer(&ifxusb_pcd.device_probe_timer); 2301 do_resume_d(&ifxusb_pcd.core_if); 2302 } 2303 static void suspend_device_store(uint32_t value) 2304 { 2305 if(value==2) 2306 { 2307 del_timer(&ifxusb_pcd.device_autoprobe_timer); 2308 ifxusb_pcd.device_autoprobe_timer.function = device_autoprobe; 2309 ifxusb_pcd.device_autoprobe_timer.expires = jiffies + (HZ*ifxusb_pcd.autoprobe_sec); 2310 add_timer(&ifxusb_pcd.device_autoprobe_timer); 2311 ifxusb_pcd.power_status = 2; 2312 } 2313 else if(value==1) 2314 { 2315 do_suspend_d(&ifxusb_pcd.core_if); 2316 ifxusb_pcd.power_status = 1; 2317 del_timer(&ifxusb_pcd.device_autoprobe_timer); 2318 del_timer(&ifxusb_pcd.device_probe_timer); 2319 } 2320 else if(value==0) 2321 { 2322 do_resume_d(&ifxusb_pcd.core_if); 2323 ifxusb_pcd.power_status = 0; 2324 del_timer(&ifxusb_pcd.device_autoprobe_timer); 2325 del_timer(&ifxusb_pcd.device_probe_timer); 2326 } 2327 } 2328 static ssize_t procfs_suspend_device_store(struct file *file, const char *buffer, unsigned long count, void *data) 2329 { 2330 char buf[10]; 2331 int i = 0; 2332 uint32_t value; 2333 if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1)) 2334 return -EFAULT; 2335 value = simple_strtoul(buf, NULL, 10); 2336 suspend_device_store(value); 2337 return count; 2338 } 2339 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20) 2340 static ssize_t sysfs_suspend_device_store( struct device *_dev, struct device_attribute *attr,const char *buffer, size_t count ) 2341 #else 2342 static ssize_t sysfs_suspend_device_store( struct device *_dev, const char *buffer, size_t count ) 2343 #endif 2344 { 2345 char buf[10]; 2346 int i = 0; 2347 uint32_t value; 2348 if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1)) 2349 return -EFAULT; 2350 value = simple_strtoul(buf, NULL, 10); 2351 suspend_device_store(value); 2352 return count; 2353 } 2354 DEVICE_ATTR(suspend_device, S_IWUSR,NULL,sysfs_suspend_device_store); 2355#endif 2356///////////////////////////////////////////////////////////////////////////////////////////////////// 2357#ifdef __IS_DEVICE__ 2358 static ssize_t probe_device_show(char *buf) 2359 { 2360 if(ifxusb_pcd.power_status == 0) 2361 return sprintf (buf,"Device power status is ON\n"); 2362 else if(ifxusb_pcd.power_status == 1) 2363 return sprintf (buf,"Device power status is Suspend\n"); 2364 else 2365 return printk(buf,"Device power status is Auto-probing\n"); 2366 } 2367 static void probe_device_store(uint32_t value) 2368 { 2369 2370 if(ifxusb_pcd.power_status == 1) 2371 { 2372 del_timer(&ifxusb_pcd.device_probe_timer); 2373 ifxusb_pcd.device_probe_timer.function = device_probe; 2374 ifxusb_pcd.device_probe_timer.expires = jiffies + (HZ*ifxusb_pcd.probe_sec); 2375 add_timer(&ifxusb_pcd.device_probe_timer); 2376 do_resume_d(&ifxusb_pcd.core_if); 2377 } 2378 } 2379 static ssize_t procfs_probe_device_store(struct file *file, const char *buffer, unsigned long count, void *data) 2380 { 2381 char buf[10]; 2382 int i = 0; 2383 uint32_t value; 2384 if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1)) 2385 return -EFAULT; 2386 value = simple_strtoul(buf, NULL, 10); 2387 probe_device_store(value); 2388 return count; 2389 } 2390 static ssize_t procfs_probe_device_show(char *buf, char **start, off_t offset, int count, int *eof, void *data) 2391 { 2392 return probe_device_show(buf); 2393 } 2394 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20) 2395 static ssize_t sysfs_probe_device_show( struct device *_dev, struct device_attribute *attr,char *buf) 2396 #else 2397 static ssize_t sysfs_probe_device_show( struct device *_dev, char *buf) 2398 #endif 2399 { 2400 return probe_device_show(buf); 2401 } 2402 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20) 2403 static ssize_t sysfs_probe_device_store( struct device *_dev, struct device_attribute *attr,const char *buffer, size_t count ) 2404 #else 2405 static ssize_t sysfs_probe_device_store( struct device *_dev, const char *buffer, size_t count ) 2406 #endif 2407 { 2408 char buf[10]; 2409 int i = 0; 2410 uint32_t value; 2411 if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1)) 2412 return -EFAULT; 2413 value = simple_strtoul(buf, NULL, 10); 2414 probe_device_store(value); 2415 return count; 2416 } 2417 DEVICE_ATTR(probe_device, S_IRUGO|S_IWUSR, sysfs_probe_device_show, sysfs_probe_device_store); 2418#endif 2419///////////////////////////////////////////////////////////////////////////////////////////////////// 2420///////////////////////////////////////////////////////////////////////////////////////////////////// 2421#ifdef __IS_HOST__ 2422 #ifdef __IS_DUAL__ 2423 static ssize_t autoprobe_timer2_val_show(char *buf) 2424 { 2425 return sprintf (buf,"Host 2 auto-probe timer is %d second\n",ifxusb_hcd_2.autoprobe_sec); 2426 } 2427 static ssize_t procfs_autoprobe_timer2_val_store(struct file *file, const char *buffer, unsigned long count, void *data) 2428 { 2429 char buf[10]; 2430 int i = 0; 2431 uint32_t value; 2432 if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1)) 2433 return -EFAULT; 2434 value = simple_strtoul(buf, NULL, 10); 2435 if((value > 0)&&(value < 300)) 2436 ifxusb_hcd_2.autoprobe_sec = value; 2437 return count; 2438 } 2439 static ssize_t procfs_autoprobe_timer2_val_show(char *buf, char **start, off_t offset, int count, int *eof, void *data) 2440 { 2441 return autoprobe_timer2_val_show(buf); 2442 } 2443 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20) 2444 static ssize_t sysfs_autoprobe_timer2_val_show( struct device *_dev, struct device_attribute *attr,char *buf) 2445 #else 2446 static ssize_t sysfs_autoprobe_timer2_val_show( struct device *_dev, char *buf) 2447 #endif 2448 { 2449 return autoprobe_timer2_val_show(buf); 2450 } 2451 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20) 2452 static ssize_t sysfs_autoprobe_timer2_val_store( struct device *_dev, struct device_attribute *attr,const char *buffer, size_t count ) 2453 #else 2454 static ssize_t sysfs_autoprobe_timer2_val_store( struct device *_dev, const char *buffer, size_t count ) 2455 #endif 2456 { 2457 char buf[10]; 2458 int i = 0; 2459 uint32_t value; 2460 if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1)) 2461 return -EFAULT; 2462 value = simple_strtoul(buf, NULL, 10); 2463 if((value > 0)&&(value < 300)) 2464 ifxusb_hcd_2.autoprobe_sec = value; 2465 return count; 2466 } 2467 2468 static ssize_t autoprobe_timer1_val_show(char *buf) 2469 { 2470 return sprintf (buf,"Host 1 auto-probe timer is %d second\n",ifxusb_hcd_1.autoprobe_sec); 2471 } 2472 static ssize_t procfs_autoprobe_timer1_val_store(struct file *file, const char *buffer, unsigned long count, void *data) 2473 { 2474 char buf[10]; 2475 int i = 0; 2476 uint32_t value; 2477 if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1)) 2478 return -EFAULT; 2479 value = simple_strtoul(buf, NULL, 10); 2480 if((value > 0)&&(value < 300)) 2481 ifxusb_hcd_1.autoprobe_sec = value; 2482 return count; 2483 } 2484 static ssize_t procfs_autoprobe_timer1_val_show(char *buf, char **start, off_t offset, int count, int *eof, void *data) 2485 { 2486 return autoprobe_timer1_val_show(buf); 2487 } 2488 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20) 2489 static ssize_t sysfs_autoprobe_timer1_val_show( struct device *_dev, struct device_attribute *attr,char *buf) 2490 #else 2491 static ssize_t sysfs_autoprobe_timer1_val_show( struct device *_dev, char *buf) 2492 #endif 2493 { 2494 return autoprobe_timer1_val_show(buf); 2495 } 2496 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20) 2497 static ssize_t sysfs_autoprobe_timer1_val_store( struct device *_dev, struct device_attribute *attr,const char *buffer, size_t count ) 2498 #else 2499 static ssize_t sysfs_autoautoprobe_timer1_val_store( struct device *_dev, const char *buffer, size_t count ) 2500 #endif 2501 { 2502 char buf[10]; 2503 int i = 0; 2504 uint32_t value; 2505 if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1)) 2506 return -EFAULT; 2507 value = simple_strtoul(buf, NULL, 10); 2508 if((value > 0)&&(value < 300)) 2509 ifxusb_hcd_1.autoprobe_sec = value; 2510 return count; 2511 } 2512 2513 static ssize_t probe_timer2_val_show(char *buf) 2514 { 2515 return sprintf (buf,"Host 2 probe timer is %d second\n",ifxusb_hcd_2.probe_sec); 2516 } 2517 static ssize_t procfs_probe_timer2_val_store(struct file *file, const char *buffer, unsigned long count, void *data) 2518 { 2519 char buf[10]; 2520 int i = 0; 2521 uint32_t value; 2522 if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1)) 2523 return -EFAULT; 2524 value = simple_strtoul(buf, NULL, 10); 2525 if((value > 0)&&(value < 10)) 2526 ifxusb_hcd_2.probe_sec = value; 2527 return count; 2528 } 2529 static ssize_t procfs_probe_timer2_val_show(char *buf, char **start, off_t offset, int count, int *eof, void *data) 2530 { 2531 return probe_timer2_val_show(buf); 2532 } 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) 2535 #else 2536 static ssize_t sysfs_probe_timer2_val_show( struct device *_dev, char *buf) 2537 #endif 2538 { 2539 return probe_timer2_val_show(buf); 2540 } 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 ) 2543 #else 2544 static ssize_t sysfs_probe_timer2_val_store( struct device *_dev, const char *buffer, size_t count ) 2545 #endif 2546 { 2547 char buf[10]; 2548 int i = 0; 2549 uint32_t value; 2550 if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1)) 2551 return -EFAULT; 2552 value = simple_strtoul(buf, NULL, 10); 2553 if((value > 0)&&(value < 10)) 2554 ifxusb_hcd_2.probe_sec = value; 2555 return count; 2556 } 2557 2558 static ssize_t probe_timer1_val_show(char *buf) 2559 { 2560 return sprintf (buf,"Host 1 probe timer is %d second\n",ifxusb_hcd_1.probe_sec); 2561 } 2562 static ssize_t procfs_probe_timer1_val_store(struct file *file, const char *buffer, unsigned long count, void *data) 2563 { 2564 char buf[10]; 2565 int i = 0; 2566 uint32_t value; 2567 if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1)) 2568 return -EFAULT; 2569 value = simple_strtoul(buf, NULL, 10); 2570 if((value > 0)&&(value < 10)) 2571 ifxusb_hcd_1.probe_sec = value; 2572 return count; 2573 } 2574 static ssize_t procfs_probe_timer1_val_show(char *buf, char **start, off_t offset, int count, int *eof, void *data) 2575 { 2576 return probe_timer1_val_show(buf); 2577 } 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) 2580 #else 2581 static ssize_t sysfs_probe_timer1_val_show( struct device *_dev, char *buf) 2582 #endif 2583 { 2584 return probe_timer1_val_show(buf); 2585 } 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 ) 2588 #else 2589 static ssize_t sysfs_probe_timer1_val_store( struct device *_dev, const char *buffer, size_t count ) 2590 #endif 2591 { 2592 char buf[10]; 2593 int i = 0; 2594 uint32_t value; 2595 if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1)) 2596 return -EFAULT; 2597 value = simple_strtoul(buf, NULL, 10); 2598 if((value > 0)&&(value < 10)) 2599 ifxusb_hcd_1.probe_sec = value; 2600 return count; 2601 } 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); 2606 #else 2607 static ssize_t autoprobe_timer_val_show(char *buf) 2608 { 2609 return sprintf (buf,"Host auto-probe timer is %d second\n",ifxusb_hcd.autoprobe_sec); 2610 } 2611 static ssize_t procfs_autoprobe_timer_val_store(struct file *file, const char *buffer, unsigned long count, void *data) 2612 { 2613 char buf[10]; 2614 int i = 0; 2615 uint32_t value; 2616 if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1)) 2617 return -EFAULT; 2618 value = simple_strtoul(buf, NULL, 10); 2619 if((value > 0)&&(value < 300)) 2620 ifxusb_hcd.autoprobe_sec = value; 2621 return count; 2622 } 2623 static ssize_t procfs_autoprobe_timer_val_show(char *buf, char **start, off_t offset, int count, int *eof, void *data) 2624 { 2625 return autoprobe_timer_val_show(buf); 2626 } 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) 2629 #else 2630 static ssize_t sysfs_autoprobe_timer_val_show( struct device *_dev, char *buf) 2631 #endif 2632 { 2633 return autoprobe_timer_val_show(buf); 2634 } 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 ) 2637 #else 2638 static ssize_t sysfs_autoautoprobe_timer_val_store( struct device *_dev, const char *buffer, size_t count ) 2639 #endif 2640 { 2641 char buf[10]; 2642 int i = 0; 2643 uint32_t value; 2644 if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1)) 2645 return -EFAULT; 2646 value = simple_strtoul(buf, NULL, 10); 2647 if((value > 0)&&(value < 300)) 2648 ifxusb_hcd.autoprobe_sec = value; 2649 return count; 2650 } 2651 static ssize_t probe_timer_val_show(char *buf) 2652 { 2653 return sprintf (buf,"Host probe timer is %d second\n",ifxusb_hcd.probe_sec); 2654 } 2655 static ssize_t procfs_probe_timer_val_store(struct file *file, const char *buffer, unsigned long count, void *data) 2656 { 2657 char buf[10]; 2658 int i = 0; 2659 uint32_t value; 2660 if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1)) 2661 return -EFAULT; 2662 value = simple_strtoul(buf, NULL, 10); 2663 if((value > 0)&&(value < 10)) 2664 ifxusb_hcd.probe_sec = value; 2665 return count; 2666 } 2667 static ssize_t procfs_probe_timer_val_show(char *buf, char **start, off_t offset, int count, int *eof, void *data) 2668 { 2669 return probe_timer_val_show(buf); 2670 } 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) 2673 #else 2674 static ssize_t sysfs_probe_timer_val_show( struct device *_dev, char *buf) 2675 #endif 2676 { 2677 return probe_timer_val_show(buf); 2678 } 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 ) 2681 #else 2682 static ssize_t sysfs_probe_timer_val_store( struct device *_dev, const char *buffer, size_t count ) 2683 #endif 2684 { 2685 char buf[10]; 2686 int i = 0; 2687 uint32_t value; 2688 if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1)) 2689 return -EFAULT; 2690 value = simple_strtoul(buf, NULL, 10); 2691 if((value > 0)&&(value < 10)) 2692 ifxusb_hcd.probe_sec = value; 2693 return count; 2694 } 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); 2697 #endif 2698#endif 2699///////////////////////////////////////////////////////////////////////////////////////////////////// 2700///////////////////////////////////////////////////////////////////////////////////////////////////// 2701#ifdef __IS_DEVICE__ 2702 static ssize_t autoprobe_timer_val_show(char *buf) 2703 { 2704 return sprintf (buf,"Device auto-probe timer is %d second\n",ifxusb_pcd.autoprobe_sec); 2705 } 2706 static ssize_t procfs_autoprobe_timer_val_store(struct file *file, const char *buffer, unsigned long count, void *data) 2707 { 2708 char buf[10]; 2709 int i = 0; 2710 uint32_t value; 2711 if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1)) 2712 return -EFAULT; 2713 value = simple_strtoul(buf, NULL, 10); 2714 if((value > 0)&&(value < 300)) 2715 ifxusb_pcd.autoprobe_sec = value; 2716 return count; 2717 } 2718 static ssize_t procfs_autoprobe_timer_val_show(char *buf, char **start, off_t offset, int count, int *eof, void *data) 2719 { 2720 return autoprobe_timer_val_show(buf); 2721 } 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) 2724 #else 2725 static ssize_t sysfs_autoprobe_timer_val_show( struct device *_dev, char *buf) 2726 #endif 2727 { 2728 return autoprobe_timer_val_show(buf); 2729 } 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 ) 2732 #else 2733 static ssize_t sysfs_autoautoprobe_timer_val_store( struct device *_dev, const char *buffer, size_t count ) 2734 #endif 2735 { 2736 char buf[10]; 2737 int i = 0; 2738 uint32_t value; 2739 if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1)) 2740 return -EFAULT; 2741 value = simple_strtoul(buf, NULL, 10); 2742 if((value > 0)&&(value < 300)) 2743 ifxusb_pcd.autoprobe_sec = value; 2744 return count; 2745 } 2746 static ssize_t probe_timer_val_show(char *buf) 2747 { 2748 return sprintf (buf,"Device probe timer is %d second\n",ifxusb_pcd.probe_sec); 2749 } 2750 static ssize_t procfs_probe_timer_val_store(struct file *file, const char *buffer, unsigned long count, void *data) 2751 { 2752 char buf[10]; 2753 int i = 0; 2754 uint32_t value; 2755 if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1)) 2756 return -EFAULT; 2757 value = simple_strtoul(buf, NULL, 10); 2758 if((value > 0)&&(value < 10)) 2759 ifxusb_pcd.probe_sec = value; 2760 return count; 2761 } 2762 static ssize_t procfs_probe_timer_val_show(char *buf, char **start, off_t offset, int count, int *eof, void *data) 2763 { 2764 return probe_timer_val_show(buf); 2765 } 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) 2768 #else 2769 static ssize_t sysfs_probe_timer_val_show( struct device *_dev, char *buf) 2770 #endif 2771 { 2772 return probe_timer_val_show(buf); 2773 } 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 ) 2776 #else 2777 static ssize_t sysfs_probe_timer_val_store( struct device *_dev, const char *buffer, size_t count ) 2778 #endif 2779 { 2780 char buf[10]; 2781 int i = 0; 2782 uint32_t value; 2783 if (copy_from_user(buf, &buffer[i], sizeof("0xFFFFFFFF\n")+1)) 2784 return -EFAULT; 2785 value = simple_strtoul(buf, NULL, 10); 2786 if((value > 0)&&(value < 10)) 2787 ifxusb_pcd.probe_sec = value; 2788 return count; 2789 } 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); 2792#endif 2793////////////////////////////////////////////////////////////////////////////////// 2794////////////////////////////////////////////////////////////////////////////////// 2795 2796static int ifx_proc_addproc(char *funcname, read_proc_t *hookfuncr, write_proc_t *hookfuncw); 2797static void ifx_proc_delproc(char *funcname); 2798 2799////////////////////////////////////////////////////////////////////////////////// 2800 2801#if defined(__IS_HOST__) && defined(__HOST_COC__) 2802 #ifdef __IS_DUAL__ 2803 static IFX_PMCU_MODULE_DEP_t depListUSBHost_1= 2804 { 2805 1, 2806 { 2807 {IFX_PMCU_MODULE_CPU, IFX_PMCU_STATE_D0, IFX_PMCU_STATE_D0D3, IFX_PMCU_STATE_D0D3, IFX_PMCU_STATE_D0D3} 2808 } 2809 }; 2810 static IFX_PMCU_MODULE_DEP_t depListUSBHost_2= 2811 { 2812 1, 2813 { 2814 {IFX_PMCU_MODULE_CPU, IFX_PMCU_STATE_D0, IFX_PMCU_STATE_D0D3, IFX_PMCU_STATE_D0D3, IFX_PMCU_STATE_D0D3} 2815 } 2816 }; 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 2824 } 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 2828 } 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 2832 } 2833 else{ 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 2836 } 2837 return IFX_PMCU_RETURN_SUCCESS; 2838 } 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 2845 } 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 2849 } 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 2853 } 2854 else{ 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 2857 } 2858 return IFX_PMCU_RETURN_SUCCESS; 2859 } 2860 2861 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) 2865 { 2866 if (pmcuPwrStateEna == IFX_PMCU_PWR_STATE_ON) { 2867 suspend_host_store(&ifxusb_hcd_1, 0); 2868 return IFX_PMCU_RETURN_SUCCESS; 2869 } 2870 if (pmcuPwrStateEna == IFX_PMCU_PWR_STATE_OFF) { 2871 suspend_host_store(&ifxusb_hcd_1, 1); 2872 return IFX_PMCU_RETURN_SUCCESS; 2873 } 2874 return IFX_PMCU_RETURN_SUCCESS; 2875 } 2876 static IFX_PMCU_RETURN_t 2877 ifx_usbhost_pwrFeatureSwitch_2(IFX_PMCU_PWR_STATE_ENA_t pmcuPwrStateEna) 2878 { 2879 if (pmcuPwrStateEna == IFX_PMCU_PWR_STATE_ON) { 2880 suspend_host_store(&ifxusb_hcd_2, 0); 2881 return IFX_PMCU_RETURN_SUCCESS; 2882 } 2883 if (pmcuPwrStateEna == IFX_PMCU_PWR_STATE_OFF) { 2884 suspend_host_store(&ifxusb_hcd_2, 1); 2885 return IFX_PMCU_RETURN_SUCCESS; 2886 } 2887 return IFX_PMCU_RETURN_SUCCESS; 2888 } 2889 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) 2895 { 2896 printk(KERN_DEBUG "ifx_usbhost_preChange_1 is called\n"); 2897 return IFX_PMCU_RETURN_SUCCESS; 2898 } 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) 2901 { 2902 printk(KERN_DEBUG "ifx_usbhost_preChange_2 is called\n"); 2903 return IFX_PMCU_RETURN_SUCCESS; 2904 } 2905 2906 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) 2911 { 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; 2916 } 2917 if (newState == IFX_PMCU_STATE_D1) { 2918 suspend_host_store(&ifxusb_hcd_1, 1); 2919 return IFX_PMCU_RETURN_SUCCESS; 2920 } 2921 if (newState == IFX_PMCU_STATE_D2) { 2922 suspend_host_store(&ifxusb_hcd_1, 1); 2923 return IFX_PMCU_RETURN_SUCCESS; 2924 } 2925 if (newState == IFX_PMCU_STATE_D3) { 2926 suspend_host_store(&ifxusb_hcd_1, 1); 2927 return IFX_PMCU_RETURN_SUCCESS; 2928 } 2929 return IFX_PMCU_RETURN_SUCCESS; 2930 } 2931 static IFX_PMCU_RETURN_t 2932 ifx_usbhost_stateChange_2(IFX_PMCU_STATE_t newState) 2933 { 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; 2938 } 2939 if (newState == IFX_PMCU_STATE_D1) { 2940 suspend_host_store(&ifxusb_hcd_2, 1); 2941 return IFX_PMCU_RETURN_SUCCESS; 2942 } 2943 if (newState == IFX_PMCU_STATE_D2) { 2944 suspend_host_store(&ifxusb_hcd_2, 1); 2945 return IFX_PMCU_RETURN_SUCCESS; 2946 } 2947 if (newState == IFX_PMCU_STATE_D3) { 2948 suspend_host_store(&ifxusb_hcd_2, 1); 2949 return IFX_PMCU_RETURN_SUCCESS; 2950 } 2951 return IFX_PMCU_RETURN_SUCCESS; 2952 } 2953 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) 2958 { 2959 printk(KERN_DEBUG "ifx_usbhost_postChange_1 is called\n"); 2960 return IFX_PMCU_RETURN_SUCCESS; 2961 } 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) 2964 { 2965 printk(KERN_DEBUG "ifx_usbhost_postChange_2 is called\n"); 2966 return IFX_PMCU_RETURN_SUCCESS; 2967 } 2968 #else 2969 static IFX_PMCU_MODULE_DEP_t depListUSBHost= 2970 { 2971 1, 2972 { 2973 {IFX_PMCU_MODULE_CPU, IFX_PMCU_STATE_D0, IFX_PMCU_STATE_D0D3, IFX_PMCU_STATE_D0D3, IFX_PMCU_STATE_D0D3} 2974 } 2975 }; 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 2983 } 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 2987 } 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 2991 } 2992 else{ 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 2995 } 2996 return IFX_PMCU_RETURN_SUCCESS; 2997 } 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) 3001 { 3002 if (pmcuPwrStateEna == IFX_PMCU_PWR_STATE_ON) { 3003 suspend_host_store(&ifxusb_hcd, 0); 3004 return IFX_PMCU_RETURN_SUCCESS; 3005 } 3006 if (pmcuPwrStateEna == IFX_PMCU_PWR_STATE_OFF) { 3007 suspend_host_store(&ifxusb_hcd, 1); 3008 return IFX_PMCU_RETURN_SUCCESS; 3009 } 3010 return IFX_PMCU_RETURN_SUCCESS; 3011 } 3012 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) 3018 { 3019 printk(KERN_DEBUG "ifx_usbhost_preChange is called\n"); 3020 return IFX_PMCU_RETURN_SUCCESS; 3021 } 3022 3023 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) 3028 { 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; 3033 } 3034 if (newState == IFX_PMCU_STATE_D1) { 3035 suspend_host_store(&ifxusb_hcd, 1); 3036 return IFX_PMCU_RETURN_SUCCESS; 3037 } 3038 if (newState == IFX_PMCU_STATE_D2) { 3039 suspend_host_store(&ifxusb_hcd, 1); 3040 return IFX_PMCU_RETURN_SUCCESS; 3041 } 3042 if (newState == IFX_PMCU_STATE_D3) { 3043 suspend_host_store(&ifxusb_hcd, 1); 3044 return IFX_PMCU_RETURN_SUCCESS; 3045 } 3046 return IFX_PMCU_RETURN_SUCCESS; 3047 } 3048 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) 3053 { 3054 printk(KERN_DEBUG "ifx_usbhost_postChange is called\n"); 3055 return IFX_PMCU_RETURN_SUCCESS; 3056 } 3057 #endif 3058#endif 3059#if defined(__IS_DEVICE__) && defined(__GADGET_COC__) 3060 static IFX_PMCU_MODULE_DEP_t depListUSBGadget= 3061 { 3062 1, 3063 { 3064 {IFX_PMCU_MODULE_CPU, IFX_PMCU_STATE_D0, IFX_PMCU_STATE_D0D3, IFX_PMCU_STATE_D0D3, IFX_PMCU_STATE_D0D3} 3065 } 3066 }; 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 3074 } 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 3078 } 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 3082 } 3083 else{ 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 3086 } 3087 return IFX_PMCU_RETURN_SUCCESS; 3088 } 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) 3092 { 3093 if (pmcuPwrStateEna == IFX_PMCU_PWR_STATE_ON) { 3094 suspend_device_store(0); 3095 return IFX_PMCU_RETURN_SUCCESS; 3096 } 3097 if (pmcuPwrStateEna == IFX_PMCU_PWR_STATE_OFF) { 3098 suspend_device_store(1); 3099 return IFX_PMCU_RETURN_SUCCESS; 3100 } 3101 return IFX_PMCU_RETURN_SUCCESS; 3102 } 3103 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) 3109 { 3110 printk(KERN_DEBUG "ifx_usbgadget_preChange is called\n"); 3111 return IFX_PMCU_RETURN_SUCCESS; 3112 } 3113 3114 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) 3119 { 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; 3124 } 3125 if (newState == IFX_PMCU_STATE_D1) { 3126 suspend_device_store(1); 3127 return IFX_PMCU_RETURN_SUCCESS; 3128 } 3129 if (newState == IFX_PMCU_STATE_D2) { 3130 suspend_device_store(1); 3131 return IFX_PMCU_RETURN_SUCCESS; 3132 } 3133 if (newState == IFX_PMCU_STATE_D3) { 3134 suspend_device_store(1); 3135 return IFX_PMCU_RETURN_SUCCESS; 3136 } 3137 return IFX_PMCU_RETURN_SUCCESS; 3138 } 3139 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) 3144 { 3145 printk(KERN_DEBUG "ifx_usbgadget_postChange is called\n"); 3146 return IFX_PMCU_RETURN_SUCCESS; 3147 } 3148#endif 3149 3150 3151/*! 3152 \brief This function create the sysfs and procfs entries 3153 \param[in] _dev Pointer of device structure, if applied 3154 */ 3155#ifdef __IS_HOST__ 3156void ifxusb_attr_create_h (void *_dev) 3157#else 3158void ifxusb_attr_create_d (void *_dev) 3159#endif 3160{ 3161 int error; 3162 3163 struct device *dev = (struct device *) _dev; 3164 3165 IFX_DEBUGPL(DBG_ENTRY, "%s() %d\n", __func__, __LINE__ ); 3166 3167 error = ifx_proc_addproc("dbglevel", procfs_dbglevel_show, procfs_dbglevel_store); 3168 #ifdef __IS_HOST__ 3169 error = device_create_file(dev, &dev_attr_dbglevel_h); 3170 #else 3171 error = device_create_file(dev, &dev_attr_dbglevel_d); 3172 #endif 3173 3174 #ifdef __IS_HOST__ 3175 #ifdef __IS_DUAL__ 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); 3180 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); 3185 #else 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); 3190 #endif 3191 #else 3192 error = ifx_proc_addproc("dump_params", procfs_dump_params_show, NULL); 3193 error = device_create_file(dev, &dev_attr_dump_params_d); 3194 3195 error = ifx_proc_addproc("mode", procfs_mode_show, NULL); 3196 error = device_create_file(dev, &dev_attr_mode_d); 3197 #endif 3198 3199 #ifdef __IS_HOST__ 3200 error = ifx_proc_addproc("version", procfs_version_show, NULL); 3201 error = device_create_file(dev, &dev_attr_version_h); 3202 #else 3203 error = ifx_proc_addproc("version", procfs_version_show, NULL); 3204 error = device_create_file(dev, &dev_attr_version_d); 3205 #endif 3206 3207 3208 #ifdef __IS_HOST__ 3209 #ifdef __IS_DUAL__ 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); 3230 #else 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); 3241 #endif 3242 3243 #ifdef __IS_DUAL__ 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); 3248 #else 3249 error = ifx_proc_addproc("buspower", procfs_buspower_show, procfs_buspower_store); 3250 error = device_create_file(dev, &dev_attr_buspower); 3251 #endif 3252 3253 #ifdef __IS_DUAL__ 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); 3258 #else 3259 error = ifx_proc_addproc("bussuspend", procfs_bussuspend_show, NULL); 3260 error = device_create_file(dev, &dev_attr_bussuspend); 3261 #endif 3262 3263 #ifdef __IS_DUAL__ 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); 3268 #else 3269 error = ifx_proc_addproc("busconnected", procfs_busconnected_show, NULL); 3270 error = device_create_file(dev, &dev_attr_busconnected); 3271 #endif 3272 3273 #ifdef __IS_DUAL__ 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); 3278 #else 3279 error = ifx_proc_addproc("connectspeed", procfs_connectspeed_show, NULL); 3280 error = device_create_file(dev, &dev_attr_connectspeed); 3281 #endif 3282 #endif 3283 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); 3289 #endif 3290 3291 ////////////////////////////////////////////////////// 3292 #ifdef __ENABLE_DUMP__ 3293 3294 #ifdef __IS_HOST__ 3295 #ifdef __IS_DUAL__ 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); 3300 #else 3301 error = ifx_proc_addproc("dump_reg", procfs_dump_reg_show, NULL); 3302 error = device_create_file(dev, &dev_attr_dump_reg_h); 3303 #endif 3304 3305 #ifdef __IS_DUAL__ 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); 3310 #else 3311 error = ifx_proc_addproc("dump_spram", procfs_dump_spram_show, NULL); 3312 error = device_create_file(dev, &dev_attr_dump_spram_h); 3313 #endif 3314 3315 #ifdef __IS_DUAL__ 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); 3320 #else 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); 3323 #endif 3324 #else 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); 3329 #endif 3330 #endif //__ENABLE_DUMP__ 3331 ////////////////////////////////////////////////////// 3332#ifdef __IS_HOST__ 3333 #ifdef __IS_DUAL__ 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); 3336 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); 3339 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); 3342 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); 3345 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); 3348 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); 3351 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); 3354 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); 3357 #else 3358 error = ifx_proc_addproc("suspend_host",NULL, procfs_suspend_host_store); 3359 error = device_create_file(dev, &dev_attr_suspend_host); 3360 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); 3363 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); 3366 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); 3369 #endif 3370#endif 3371 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); 3375 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); 3378 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); 3381 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); 3384#endif 3385#if defined(__IS_HOST__) && defined(__HOST_COC__) 3386 #ifdef __IS_DUAL__ 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 ); 3407 #else 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 ); 3418 #endif 3419#endif 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 ); 3431#endif 3432} 3433 3434 3435/*! 3436 \brief This function remove the sysfs and procfs entries 3437 \param[in] _dev Pointer of device structure, if applied 3438 */ 3439#ifdef __IS_HOST__ 3440void ifxusb_attr_remove_h (void *_dev) 3441#else 3442void ifxusb_attr_remove_d (void *_dev) 3443#endif 3444{ 3445 struct device *dev = (struct device *) _dev; 3446 3447 IFX_DEBUGPL(DBG_ENTRY, "%s() %d\n", __func__, __LINE__ ); 3448 ifx_proc_delproc("dbglevel"); 3449 #ifdef __IS_HOST__ 3450 device_remove_file(dev, &dev_attr_dbglevel_h); 3451 #else 3452 device_remove_file(dev, &dev_attr_dbglevel_d); 3453 #endif 3454 3455 #ifdef __IS_HOST__ 3456 #ifdef __IS_DUAL__ 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); 3461 #else 3462 ifx_proc_delproc("dump_params"); 3463 device_remove_file(dev, &dev_attr_dump_params_h); 3464 #endif 3465 3466 #ifdef __IS_DUAL__ 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); 3471 #else 3472 ifx_proc_delproc("mode"); 3473 device_remove_file(dev, &dev_attr_mode_h); 3474 #endif 3475 #else 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); 3480 #endif 3481 3482 #ifdef __IS_HOST__ 3483 ifx_proc_delproc("version"); 3484 device_remove_file(dev, &dev_attr_version_h); 3485 #else 3486 ifx_proc_delproc("version"); 3487 device_remove_file(dev, &dev_attr_version_d); 3488 #endif 3489 3490 3491 #ifdef __IS_HOST__ 3492 #ifdef __IS_DUAL__ 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); 3513 #else 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); 3524 #endif 3525 #endif 3526 3527 #ifdef __IS_HOST__ 3528 #ifdef __IS_DUAL__ 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); 3533 #else 3534 ifx_proc_delproc("buspower"); 3535 device_remove_file(dev, &dev_attr_buspower); 3536 #endif 3537 3538 #ifdef __IS_DUAL__ 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); 3543 #else 3544 ifx_proc_delproc("bussuspend"); 3545 device_remove_file(dev, &dev_attr_bussuspend); 3546 #endif 3547 3548 #ifdef __IS_DUAL__ 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); 3553 #else 3554 ifx_proc_delproc("busconnected"); 3555 device_remove_file(dev, &dev_attr_busconnected); 3556 #endif 3557 3558 #ifdef __IS_DUAL__ 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); 3563 #else 3564 ifx_proc_delproc("connectspeed"); 3565 device_remove_file(dev, &dev_attr_connectspeed); 3566 #endif 3567 #endif 3568 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); 3574 #endif 3575 3576 #ifdef __ENABLE_DUMP__ 3577 #ifdef __IS_HOST__ 3578 #ifdef __IS_DUAL__ 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); 3583 #else 3584 ifx_proc_delproc("dump_reg"); 3585 device_remove_file(dev, &dev_attr_dump_reg_h); 3586 #endif 3587 3588 #ifdef __IS_DUAL__ 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); 3593 #else 3594 ifx_proc_delproc("dump_spram"); 3595 device_remove_file(dev, &dev_attr_dump_spram_h); 3596 #endif 3597 3598 #ifdef __IS_DUAL__ 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); 3603 #else 3604 ifx_proc_delproc("dump_host_state"); 3605 device_remove_file(dev, &dev_attr_dump_host_state); 3606 #endif 3607 #else 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); 3612 #endif 3613 3614 #ifdef __IS_HOST__ 3615 #endif 3616 #endif //__ENABLE_DUMP__ 3617#ifdef __IS_HOST__ 3618 #ifdef __IS_DUAL__ 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); 3635 #else 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); 3644 #endif 3645 remove_proc_entry(ifxusb_hcd_driver_name, (void *)0); 3646#endif 3647 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); 3658#endif 3659#if defined(__IS_HOST__) && defined(__HOST_COC__) 3660 #ifdef __IS_DUAL__ 3661 ifx_pmcu_unregister ( &pmcuRegisterUSBHost_1 ); 3662 ifx_pmcu_unregister ( &pmcuRegisterUSBHost_2 ); 3663 #else 3664 ifx_pmcu_unregister ( &pmcuRegisterUSBHost ); 3665 #endif 3666#endif 3667#if defined(__IS_DEVICE__) && defined(__GADGET_COC__) 3668 ifx_pmcu_unregister ( &pmcuRegisterUSBGadget ); 3669#endif 3670 3671} 3672 3673static struct proc_dir_entry * proc_ifx_root = NULL; 3674 3675/* initialize the proc file system and make a dir named /proc/[name] */ 3676static void ifx_proc_init(void) 3677{ 3678 IFX_DEBUGPL(DBG_ENTRY, "%s() %d\n", __func__, __LINE__ ); 3679#ifdef __IS_HOST__ 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); 3683 return; 3684 } 3685#else 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); 3689 return; 3690 } 3691#endif 3692} 3693 3694/* proc file system add function for debugging. */ 3695static int ifx_proc_addproc(char *funcname, read_proc_t *hookfuncr, write_proc_t *hookfuncw) 3696{ 3697 struct proc_dir_entry *pe; 3698 IFX_DEBUGPL(DBG_ENTRY, "%s() %d\n", __func__, __LINE__ ); 3699 if (!proc_ifx_root) 3700 ifx_proc_init(); 3701 3702 if (hookfuncw == NULL) 3703 { 3704 pe = create_proc_read_entry(funcname, S_IRUGO, proc_ifx_root, hookfuncr, NULL); 3705 if (!pe) 3706 { 3707 IFX_PRINT("ERROR in creating read proc entry (%s)! \n", funcname); 3708 return -1; 3709 } 3710 } 3711 else 3712 { 3713 pe = create_proc_entry(funcname, S_IRUGO | S_IWUGO, proc_ifx_root); 3714 if (pe) 3715 { 3716 pe->read_proc = hookfuncr; 3717 pe->write_proc = hookfuncw; 3718 } 3719 else 3720 { 3721 IFX_PRINT("ERROR in creating proc entry (%s)! \n", funcname); 3722 return -1; 3723 } 3724 } 3725 return 0; 3726} 3727 3728 3729/* proc file system del function for removing module. */ 3730static void ifx_proc_delproc(char *funcname) 3731{ 3732 char pname[30]; 3733 IFX_DEBUGPL(DBG_ENTRY, "%s() %d\n", __func__, __LINE__ ); 3734 sprintf(pname, "%s", funcname); 3735 3736 remove_proc_entry(pname, proc_ifx_root); 3737 3738} 3739 3740static void ifxusb_dump_params(ifxusb_core_if_t *_core_if) 3741{ 3742 ifxusb_params_t *params=&_core_if->params; 3743 3744 #ifdef __IS_HOST__ 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__ 3750 3751 #ifdef __DESC_DMA__ 3752 IFX_PRINT("DMA: Hermes DMA\n"); 3753 #else 3754 IFX_PRINT("DMA: Non-Desc DMA\n"); 3755 #endif 3756 IFX_PRINT(" Burst size: %d\n",params->dma_burst_size); 3757 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"); 3762 else 3763 IFX_PRINT("Unkonwn setting (%d) for Speed\n",params->speed); 3764 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 3768 ); 3769 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 3774 ); 3775 { 3776 int i; 3777 for(i=0;i<MAX_EPS_CHANNELS;i++) 3778 { 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 3782 ); 3783 } 3784 } 3785 #ifdef __DED_FIFO__ 3786 IFX_PRINT("Treshold : %s Rx:%d Tx:%d \n", 3787 (params->thr_ctl)?"On":"Off",params->tx_thr_length,params->rx_thr_length); 3788 #endif 3789 #else //__IS_HOST__ 3790 IFX_PRINT("Host Channels: %d\n",params->host_channels); 3791 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 3795 ); 3796 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 3800 ); 3801 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 3805 ); 3806 #endif //__IS_HOST__ 3807 3808 IFX_PRINT("Max Transfer size: %d(0x%06X) Bytes\n", 3809 params->max_transfer_size,params->max_transfer_size 3810 ); 3811 IFX_PRINT("Max Packet Count: %d(0x%06X)\n", 3812 params->max_packet_count,params->max_packet_count 3813 ); 3814 3815 IFX_PRINT("PHY UTMI Width: %d\n",params->phy_utmi_width); 3816 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); 3819 3820 3821 IFX_PRINT("==================================================\n"); 3822 IFX_PRINT("End of Parameters Dump\n"); 3823 IFX_PRINT("==================================================\n"); 3824} 3825 3826