- Timestamp:
- 07/03/2009 04:48:37 PM (8 months ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
src/linux/rt2880/linux-2.6.23/drivers/usb/dwc_otg/dwc_otg_attr.c
r10741 r12433 1 1 /* ========================================================================== 2 * $File: //dwh/usb_iip/dev/software/otg _ipmate/linux/drivers/dwc_otg_attr.c $3 * $Revision: 1. 1$4 * $Date: 200 7-11-19 05:39:07$5 * $Change: 537387$2 * $File: //dwh/usb_iip/dev/software/otg/linux/drivers/dwc_otg_attr.c $ 3 * $Revision: 1.2 $ 4 * $Date: 2008-11-21 05:39:15 $ 5 * $Change: 1064918 $ 6 6 * 7 7 * Synopsys HS OTG Linux Software Driver and documentation (hereinafter, … … 207 207 208 208 <tr> 209 <td> spramdump </td> 210 <td> Dumps the contents of core registers.</td> 211 <td> Read</td> 212 </tr> 213 214 <tr> 209 215 <td> hcddump </td> 210 216 <td> Dumps the current HCD state.</td> … … 255 261 #include <linux/types.h> 256 262 #include <linux/stat.h> /* permission constants */ 263 #include <linux/version.h> 257 264 258 265 //#include <asm/sizes.h> … … 268 275 #include "dwc_otg_hcd.h" 269 276 277 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20) 270 278 /* 271 279 * MACROs for defining sysfs attribute 272 280 */ 273 281 #define DWC_OTG_DEVICE_ATTR_BITFIELD_SHOW(_otg_attr_name_,_addr_,_mask_,_shift_,_string_) \ 274 static ssize_t _otg_attr_name_##_show (struct device *_dev, char *buf) \282 static ssize_t _otg_attr_name_##_show (struct device *_dev, struct device_attribute *attr, char *buf) \ 275 283 { \ 276 dwc_otg_device_t *otg_dev = dev_get_drvdata(_dev);\ 284 struct lm_device *lm_dev = container_of(_dev, struct lm_device, dev); \ 285 dwc_otg_device_t *otg_dev = lm_get_drvdata(lm_dev); \ 277 286 uint32_t val; \ 278 287 val = dwc_read_reg32 (_addr_); \ … … 281 290 } 282 291 #define DWC_OTG_DEVICE_ATTR_BITFIELD_STORE(_otg_attr_name_,_addr_,_mask_,_shift_,_string_) \ 283 static ssize_t _otg_attr_name_##_store (struct device *_dev, const char *buf, size_t count) \ 292 static ssize_t _otg_attr_name_##_store (struct device *_dev, struct device_attribute *attr, \ 293 const char *buf, size_t count) \ 284 294 { \ 285 dwc_otg_device_t *otg_dev = dev_get_drvdata(_dev);\ 295 struct lm_device *lm_dev = container_of(_dev, struct lm_device, dev); \ 296 dwc_otg_device_t *otg_dev = lm_get_drvdata(lm_dev); \ 286 297 uint32_t set = simple_strtoul(buf, NULL, 16); \ 287 298 uint32_t clear = set; \ … … 293 304 } 294 305 306 /* 307 * MACROs for defining sysfs attribute for 32-bit registers 308 */ 309 #define DWC_OTG_DEVICE_ATTR_REG_SHOW(_otg_attr_name_,_addr_,_string_) \ 310 static ssize_t _otg_attr_name_##_show (struct device *_dev, struct device_attribute *attr, char *buf) \ 311 { \ 312 struct lm_device *lm_dev = container_of(_dev, struct lm_device, dev); \ 313 dwc_otg_device_t *otg_dev = lm_get_drvdata(lm_dev); \ 314 uint32_t val; \ 315 val = dwc_read_reg32 (_addr_); \ 316 return sprintf (buf, "%s = 0x%08x\n", _string_, val); \ 317 } 318 #define DWC_OTG_DEVICE_ATTR_REG_STORE(_otg_attr_name_,_addr_,_string_) \ 319 static ssize_t _otg_attr_name_##_store (struct device *_dev, struct device_attribute *attr, \ 320 const char *buf, size_t count) \ 321 { \ 322 struct lm_device *lm_dev = container_of(_dev, struct lm_device, dev); \ 323 dwc_otg_device_t *otg_dev = lm_get_drvdata(lm_dev); \ 324 uint32_t val = simple_strtoul(buf, NULL, 16); \ 325 dev_dbg(_dev, "Storing Address=0x%08x Val=0x%08x\n", (uint32_t)_addr_, val); \ 326 dwc_write_reg32(_addr_, val); \ 327 return count; \ 328 } 329 330 #else 331 332 /* 333 * MACROs for defining sysfs attribute 334 */ 335 #define DWC_OTG_DEVICE_ATTR_BITFIELD_SHOW(_otg_attr_name_,_addr_,_mask_,_shift_,_string_) \ 336 static ssize_t _otg_attr_name_##_show (struct device *_dev, char *buf) \ 337 { \ 338 dwc_otg_device_t *otg_dev = dev_get_drvdata(_dev);\ 339 uint32_t val; \ 340 val = dwc_read_reg32 (_addr_); \ 341 val = (val & (_mask_)) >> _shift_; \ 342 return sprintf (buf, "%s = 0x%x\n", _string_, val); \ 343 } 344 #define DWC_OTG_DEVICE_ATTR_BITFIELD_STORE(_otg_attr_name_,_addr_,_mask_,_shift_,_string_) \ 345 static ssize_t _otg_attr_name_##_store (struct device *_dev, const char *buf, size_t count) \ 346 { \ 347 dwc_otg_device_t *otg_dev = dev_get_drvdata(_dev);\ 348 uint32_t set = simple_strtoul(buf, NULL, 16); \ 349 uint32_t clear = set; \ 350 clear = ((~clear) << _shift_) & _mask_; \ 351 set = (set << _shift_) & _mask_; \ 352 dev_dbg(_dev, "Storing Address=0x%08x Set=0x%08x Clear=0x%08x\n", (uint32_t)_addr_, set, clear); \ 353 dwc_modify_reg32(_addr_, clear, set); \ 354 return count; \ 355 } 356 357 /* 358 * MACROs for defining sysfs attribute for 32-bit registers 359 */ 360 #define DWC_OTG_DEVICE_ATTR_REG_SHOW(_otg_attr_name_,_addr_,_string_) \ 361 static ssize_t _otg_attr_name_##_show (struct device *_dev, char *buf) \ 362 { \ 363 dwc_otg_device_t *otg_dev = dev_get_drvdata(_dev);\ 364 uint32_t val; \ 365 val = dwc_read_reg32 (_addr_); \ 366 return sprintf (buf, "%s = 0x%08x\n", _string_, val); \ 367 } 368 #define DWC_OTG_DEVICE_ATTR_REG_STORE(_otg_attr_name_,_addr_,_string_) \ 369 static ssize_t _otg_attr_name_##_store (struct device *_dev, const char *buf, size_t count) \ 370 { \ 371 dwc_otg_device_t *otg_dev = dev_get_drvdata(_dev);\ 372 uint32_t val = simple_strtoul(buf, NULL, 16); \ 373 dev_dbg(_dev, "Storing Address=0x%08x Val=0x%08x\n", (uint32_t)_addr_, val); \ 374 dwc_write_reg32(_addr_, val); \ 375 return count; \ 376 } 377 378 #endif 379 295 380 #define DWC_OTG_DEVICE_ATTR_BITFIELD_RW(_otg_attr_name_,_addr_,_mask_,_shift_,_string_) \ 296 381 DWC_OTG_DEVICE_ATTR_BITFIELD_SHOW(_otg_attr_name_,_addr_,_mask_,_shift_,_string_) \ … … 302 387 DEVICE_ATTR(_otg_attr_name_,0444,_otg_attr_name_##_show,NULL); 303 388 304 /*305 * MACROs for defining sysfs attribute for 32-bit registers306 */307 #define DWC_OTG_DEVICE_ATTR_REG_SHOW(_otg_attr_name_,_addr_,_string_) \308 static ssize_t _otg_attr_name_##_show (struct device *_dev, char *buf) \309 { \310 dwc_otg_device_t *otg_dev = dev_get_drvdata(_dev);\311 uint32_t val; \312 val = dwc_read_reg32 (_addr_); \313 return sprintf (buf, "%s = 0x%08x\n", _string_, val); \314 }315 #define DWC_OTG_DEVICE_ATTR_REG_STORE(_otg_attr_name_,_addr_,_string_) \316 static ssize_t _otg_attr_name_##_store (struct device *_dev, const char *buf, size_t count) \317 { \318 dwc_otg_device_t *otg_dev = dev_get_drvdata(_dev);\319 uint32_t val = simple_strtoul(buf, NULL, 16); \320 dev_dbg(_dev, "Storing Address=0x%08x Val=0x%08x\n", (uint32_t)_addr_, val); \321 dwc_write_reg32(_addr_, val); \322 return count; \323 }324 325 389 #define DWC_OTG_DEVICE_ATTR_REG32_RW(_otg_attr_name_,_addr_,_string_) \ 326 390 DWC_OTG_DEVICE_ATTR_REG_SHOW(_otg_attr_name_,_addr_,_string_) \ … … 339 403 * Show the register offset of the Register Access. 340 404 */ 341 static ssize_t regoffset_show( struct device *_dev, char *buf) 342 { 343 dwc_otg_device_t *otg_dev = dev_get_drvdata(_dev); 405 static ssize_t regoffset_show( struct device *_dev, 406 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20) 407 struct device_attribute *attr, 408 #endif 409 char *buf) 410 { 411 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20) 412 struct lm_device *lm_dev = container_of(_dev, struct lm_device, dev); 413 dwc_otg_device_t *otg_dev = lm_get_drvdata(lm_dev); 414 #else 415 dwc_otg_device_t *otg_dev = dev_get_drvdata(_dev); 416 #endif 344 417 return snprintf(buf, sizeof("0xFFFFFFFF\n")+1,"0x%08x\n", otg_dev->reg_offset); 345 418 } … … 348 421 * Set the register offset for the next Register Access Read/Write 349 422 */ 350 static ssize_t regoffset_store( struct device *_dev, const char *buf, 351 size_t count ) 352 { 353 dwc_otg_device_t *otg_dev = dev_get_drvdata(_dev); 423 static ssize_t regoffset_store( struct device *_dev, 424 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20) 425 struct device_attribute *attr, 426 #endif 427 const char *buf, 428 size_t count ) 429 { 430 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20) 431 struct lm_device *lm_dev = container_of(_dev, struct lm_device, dev); 432 dwc_otg_device_t *otg_dev = lm_get_drvdata(lm_dev); 433 #else 434 dwc_otg_device_t *otg_dev = dev_get_drvdata(_dev); 435 #endif 354 436 uint32_t offset = simple_strtoul(buf, NULL, 16); 355 437 //dev_dbg(_dev, "Offset=0x%08x\n", offset); … … 363 445 return count; 364 446 } 365 DEVICE_ATTR(regoffset, S_IRUGO|S_IWUSR, regoffset_show, regoffset_store);447 DEVICE_ATTR(regoffset, S_IRUGO|S_IWUSR, (void *)regoffset_show, regoffset_store); 366 448 367 449 … … 370 452 * attribute. 371 453 */ 372 static ssize_t regvalue_show( struct device *_dev, char *buf) 373 { 374 dwc_otg_device_t *otg_dev = dev_get_drvdata(_dev); 454 static ssize_t regvalue_show( struct device *_dev, 455 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20) 456 struct device_attribute *attr, 457 #endif 458 char *buf) 459 { 460 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20) 461 struct lm_device *lm_dev = container_of(_dev, struct lm_device, dev); 462 dwc_otg_device_t *otg_dev = lm_get_drvdata(lm_dev); 463 #else 464 dwc_otg_device_t *otg_dev = dev_get_drvdata(_dev); 465 #endif 375 466 uint32_t val; 376 467 volatile uint32_t *addr; … … 399 490 * 400 491 */ 401 static ssize_t regvalue_store( struct device *_dev, const char *buf, 402 size_t count ) 403 { 404 dwc_otg_device_t *otg_dev = dev_get_drvdata(_dev); 492 static ssize_t regvalue_store( struct device *_dev, 493 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20) 494 struct device_attribute *attr, 495 #endif 496 const char *buf, 497 size_t count ) 498 { 499 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20) 500 struct lm_device *lm_dev = container_of(_dev, struct lm_device, dev); 501 dwc_otg_device_t *otg_dev = lm_get_drvdata(lm_dev); 502 #else 503 dwc_otg_device_t *otg_dev = dev_get_drvdata(_dev); 504 #endif 405 505 volatile uint32_t * addr; 406 506 uint32_t val = simple_strtoul(buf, NULL, 16); … … 453 553 * Show the HNP status bit 454 554 */ 455 static ssize_t hnp_show( struct device *_dev, char *buf) 456 { 457 dwc_otg_device_t *otg_dev = dev_get_drvdata(_dev); 555 static ssize_t hnp_show( struct device *_dev, 556 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20) 557 struct device_attribute *attr, 558 #endif 559 char *buf) 560 { 561 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20) 562 struct lm_device *lm_dev = container_of(_dev, struct lm_device, dev); 563 dwc_otg_device_t *otg_dev = lm_get_drvdata(lm_dev); 564 #else 565 dwc_otg_device_t *otg_dev = dev_get_drvdata(_dev); 566 #endif 458 567 gotgctl_data_t val; 459 568 val.d32 = dwc_read_reg32 (&(otg_dev->core_if->core_global_regs->gotgctl)); … … 464 573 * Set the HNP Request bit 465 574 */ 466 static ssize_t hnp_store( struct device *_dev, const char *buf, 575 static ssize_t hnp_store( struct device *_dev, 576 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20) 577 struct device_attribute *attr, 578 #endif 579 const char *buf, 467 580 size_t count ) 468 581 { 469 dwc_otg_device_t *otg_dev = dev_get_drvdata(_dev); 582 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20) 583 struct lm_device *lm_dev = container_of(_dev, struct lm_device, dev); 584 dwc_otg_device_t *otg_dev = lm_get_drvdata(lm_dev); 585 #else 586 dwc_otg_device_t *otg_dev = dev_get_drvdata(_dev); 587 #endif 470 588 uint32_t in = simple_strtoul(buf, NULL, 16); 471 589 uint32_t *addr = (uint32_t *)&(otg_dev->core_if->core_global_regs->gotgctl); … … 485 603 * Show the SRP status bit 486 604 */ 487 static ssize_t srp_show( struct device *_dev, char *buf) 605 static ssize_t srp_show( struct device *_dev, 606 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20) 607 struct device_attribute *attr, 608 #endif 609 char *buf) 488 610 { 489 611 #ifndef DWC_HOST_ONLY 490 dwc_otg_device_t *otg_dev = dev_get_drvdata(_dev); 612 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20) 613 struct lm_device *lm_dev = container_of(_dev, struct lm_device, dev); 614 dwc_otg_device_t *otg_dev = lm_get_drvdata(lm_dev); 615 #else 616 dwc_otg_device_t *otg_dev = dev_get_drvdata(_dev); 617 #endif 491 618 gotgctl_data_t val; 492 619 val.d32 = dwc_read_reg32 (&(otg_dev->core_if->core_global_regs->gotgctl)); … … 502 629 * Set the SRP Request bit 503 630 */ 504 static ssize_t srp_store( struct device *_dev, const char *buf, 631 static ssize_t srp_store( struct device *_dev, 632 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20) 633 struct device_attribute *attr, 634 #endif 635 const char *buf, 505 636 size_t count ) 506 637 { 507 638 #ifndef DWC_HOST_ONLY 508 dwc_otg_device_t *otg_dev = dev_get_drvdata(_dev); 639 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20) 640 struct lm_device *lm_dev = container_of(_dev, struct lm_device, dev); 641 dwc_otg_device_t *otg_dev = lm_get_drvdata(lm_dev); 642 #else 643 dwc_otg_device_t *otg_dev = dev_get_drvdata(_dev); 644 #endif 509 645 dwc_otg_pcd_initiate_srp(otg_dev->pcd); 510 646 #endif … … 519 655 * Show the Bus Power status 520 656 */ 521 static ssize_t buspower_show( struct device *_dev, char *buf) 522 { 523 dwc_otg_device_t *otg_dev = dev_get_drvdata(_dev); 657 static ssize_t buspower_show( struct device *_dev, 658 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20) 659 struct device_attribute *attr, 660 #endif 661 char *buf) 662 { 663 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20) 664 struct lm_device *lm_dev = container_of(_dev, struct lm_device, dev); 665 dwc_otg_device_t *otg_dev = lm_get_drvdata(lm_dev); 666 #else 667 dwc_otg_device_t *otg_dev = dev_get_drvdata(_dev); 668 #endif 524 669 hprt0_data_t val; 525 670 val.d32 = dwc_read_reg32 (otg_dev->core_if->host_if->hprt0); … … 531 676 * Set the Bus Power status 532 677 */ 533 static ssize_t buspower_store( struct device *_dev, const char *buf, 534 size_t count ) 535 { 536 dwc_otg_device_t *otg_dev = dev_get_drvdata(_dev); 678 static ssize_t buspower_store( struct device *_dev, 679 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20) 680 struct device_attribute *attr, 681 #endif 682 const char *buf, 683 size_t count ) 684 { 685 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20) 686 struct lm_device *lm_dev = container_of(_dev, struct lm_device, dev); 687 dwc_otg_device_t *otg_dev = lm_get_drvdata(lm_dev); 688 #else 689 dwc_otg_device_t *otg_dev = dev_get_drvdata(_dev); 690 #endif 537 691 uint32_t on = simple_strtoul(buf, NULL, 16); 538 692 uint32_t *addr = (uint32_t *)otg_dev->core_if->host_if->hprt0; … … 555 709 * Show the Bus Suspend status 556 710 */ 557 static ssize_t bussuspend_show( struct device *_dev, char *buf) 558 { 559 dwc_otg_device_t *otg_dev = dev_get_drvdata(_dev); 711 static ssize_t bussuspend_show( struct device *_dev, 712 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20) 713 struct device_attribute *attr, 714 #endif 715 char *buf) 716 { 717 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20) 718 struct lm_device *lm_dev = container_of(_dev, struct lm_device, dev); 719 dwc_otg_device_t *otg_dev = lm_get_drvdata(lm_dev); 720 #else 721 dwc_otg_device_t *otg_dev = dev_get_drvdata(_dev); 722 #endif 560 723 hprt0_data_t val; 561 724 val.d32 = dwc_read_reg32 (otg_dev->core_if->host_if->hprt0); … … 566 729 * Set the Bus Suspend status 567 730 */ 568 static ssize_t bussuspend_store( struct device *_dev, const char *buf, 569 size_t count ) 570 { 571 dwc_otg_device_t *otg_dev = dev_get_drvdata(_dev); 731 static ssize_t bussuspend_store( struct device *_dev, 732 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20) 733 struct device_attribute *attr, 734 #endif 735 const char *buf, 736 size_t count ) 737 { 738 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20) 739 struct lm_device *lm_dev = container_of(_dev, struct lm_device, dev); 740 dwc_otg_device_t *otg_dev = lm_get_drvdata(lm_dev); 741 #else 742 dwc_otg_device_t *otg_dev = dev_get_drvdata(_dev); 743 #endif 572 744 uint32_t in = simple_strtoul(buf, NULL, 16); 573 745 uint32_t *addr = (uint32_t *)otg_dev->core_if->host_if->hprt0; … … 584 756 * Show the status of Remote Wakeup. 585 757 */ 586 static ssize_t remote_wakeup_show( struct device *_dev, char *buf) 758 static ssize_t remote_wakeup_show( struct device *_dev, 759 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20) 760 struct device_attribute *attr, 761 #endif 762 char *buf) 587 763 { 588 764 #ifndef DWC_HOST_ONLY 589 dwc_otg_device_t *otg_dev = dev_get_drvdata(_dev); 765 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20) 766 struct lm_device *lm_dev = container_of(_dev, struct lm_device, dev); 767 dwc_otg_device_t *otg_dev = lm_get_drvdata(lm_dev); 768 #else 769 dwc_otg_device_t *otg_dev = dev_get_drvdata(_dev); 770 #endif 590 771 dctl_data_t val; 591 772 val.d32 = 592 dwc_read_reg32( &otg_dev->core_if->dev_if->dev_global_regs->dctl);773 dwc_read_reg32( &otg_dev->core_if->dev_if->dev_global_regs->dctl); 593 774 return sprintf( buf, "Remote Wakeup = %d Enabled = %d\n", 594 val.b.rmtwkupsig, otg_dev->pcd->remote_wakeup_enable);775 val.b.rmtwkupsig, otg_dev->pcd->remote_wakeup_enable); 595 776 #else 596 777 return sprintf(buf, "Host Only Mode!\n"); … … 603 784 * 604 785 */ 605 static ssize_t remote_wakeup_store( struct device *_dev, const char *buf, 606 size_t count ) 786 static ssize_t remote_wakeup_store( struct device *_dev, 787 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20) 788 struct device_attribute *attr, 789 #endif 790 const char *buf, 791 size_t count ) 607 792 { 608 793 #ifndef DWC_HOST_ONLY 609 uint32_t val = simple_strtoul(buf, NULL, 16); 610 dwc_otg_device_t *otg_dev = dev_get_drvdata(_dev); 794 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20) 795 struct lm_device *lm_dev = container_of(_dev, struct lm_device, dev); 796 dwc_otg_device_t *otg_dev = lm_get_drvdata(lm_dev); 797 #else 798 dwc_otg_device_t *otg_dev = dev_get_drvdata(_dev); 799 #endif 800 uint32_t val = simple_strtoul(buf, NULL, 16); 611 801 if (val&1) { 612 802 dwc_otg_pcd_remote_wakeup(otg_dev->pcd, 1); … … 619 809 } 620 810 DEVICE_ATTR(remote_wakeup, S_IRUGO|S_IWUSR, remote_wakeup_show, 621 remote_wakeup_store);811 remote_wakeup_store); 622 812 623 813 /** … … 625 815 * current mode of the core). 626 816 */ 627 static ssize_t regdump_show( struct device *_dev, char *buf) 628 { 629 dwc_otg_device_t *otg_dev = dev_get_drvdata(_dev); 630 817 static ssize_t regdump_show( struct device *_dev, 818 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20) 819 struct device_attribute *attr, 820 #endif 821 char *buf) 822 { 823 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20) 824 struct lm_device *lm_dev = container_of(_dev, struct lm_device, dev); 825 dwc_otg_device_t *otg_dev = lm_get_drvdata(lm_dev); 826 #else 827 dwc_otg_device_t *otg_dev = dev_get_drvdata(_dev); 828 #endif 631 829 dwc_otg_dump_global_registers( otg_dev->core_if); 632 830 if (dwc_otg_is_host_mode(otg_dev->core_if)) { … … 634 832 } else { 635 833 dwc_otg_dump_dev_registers( otg_dev->core_if); 834 636 835 } 637 836 return sprintf( buf, "Register Dump\n" ); … … 641 840 642 841 /** 842 * Dump global registers and either host or device registers (depending on the 843 * current mode of the core). 844 */ 845 static ssize_t spramdump_show( struct device *_dev, 846 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20) 847 struct device_attribute *attr, 848 #endif 849 char *buf) 850 { 851 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20) 852 struct lm_device *lm_dev = container_of(_dev, struct lm_device, dev); 853 dwc_otg_device_t *otg_dev = lm_get_drvdata(lm_dev); 854 #else 855 dwc_otg_device_t *otg_dev = dev_get_drvdata(_dev); 856 #endif 857 dwc_otg_dump_spram( otg_dev->core_if); 858 859 return sprintf( buf, "SPRAM Dump\n" ); 860 } 861 862 DEVICE_ATTR(spramdump, S_IRUGO|S_IWUSR, spramdump_show, 0); 863 864 /** 643 865 * Dump the current hcd state. 644 866 */ 645 static ssize_t hcddump_show( struct device *_dev, char *buf) 867 static ssize_t hcddump_show( struct device *_dev, 868 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20) 869 struct device_attribute *attr, 870 #endif 871 char *buf) 646 872 { 647 873 #ifndef DWC_DEVICE_ONLY 648 dwc_otg_device_t *otg_dev = dev_get_drvdata(_dev); 874 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20) 875 struct lm_device *lm_dev = container_of(_dev, struct lm_device, dev); 876 dwc_otg_device_t *otg_dev = lm_get_drvdata(lm_dev); 877 #else 878 dwc_otg_device_t *otg_dev = dev_get_drvdata(_dev); 879 #endif 649 880 dwc_otg_hcd_dump_state(otg_dev->hcd); 650 881 #endif … … 659 890 * start transfer and two additional sample points. 660 891 */ 661 static ssize_t hcd_frrem_show( struct device *_dev, char *buf) 892 static ssize_t hcd_frrem_show( struct device *_dev, 893 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20) 894 struct device_attribute *attr, 895 #endif 896 char *buf) 662 897 { 663 898 #ifndef DWC_DEVICE_ONLY 664 dwc_otg_device_t *otg_dev = dev_get_drvdata(_dev); 899 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20) 900 struct lm_device *lm_dev = container_of(_dev, struct lm_device, dev); 901 dwc_otg_device_t *otg_dev = lm_get_drvdata(lm_dev); 902 #else 903 dwc_otg_device_t *otg_dev = dev_get_drvdata(_dev); 904 #endif 665 905 dwc_otg_hcd_dump_frrem(otg_dev->hcd); 666 906 #endif … … 676 916 #define RW_REG_COUNT 10000000 677 917 #define MSEC_PER_JIFFIE 1000/HZ 678 static ssize_t rd_reg_test_show( struct device *_dev, char *buf) 679 { 918 static ssize_t rd_reg_test_show( struct device *_dev, 919 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20) 920 struct device_attribute *attr, 921 #endif 922 char *buf) 923 { 924 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20) 925 struct lm_device *lm_dev = container_of(_dev, struct lm_device, dev); 926 dwc_otg_device_t *otg_dev = lm_get_drvdata(lm_dev); 927 #else 928 dwc_otg_device_t *otg_dev = dev_get_drvdata(_dev); 929 #endif 680 930 int i; 681 931 int time; 682 932 int start_jiffies; 683 dwc_otg_device_t *otg_dev = dev_get_drvdata(_dev);684 933 685 934 printk("HZ %d, MSEC_PER_JIFFIE %d, loops_per_jiffy %lu\n", … … 700 949 * output shows the number of times the register is written). 701 950 */ 702 static ssize_t wr_reg_test_show( struct device *_dev, char *buf) 703 { 951 static ssize_t wr_reg_test_show( struct device *_dev, 952 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20) 953 struct device_attribute *attr, 954 #endif 955 char *buf) 956 { 957 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20) 958 struct lm_device *lm_dev = container_of(_dev, struct lm_device, dev); 959 dwc_otg_device_t *otg_dev = lm_get_drvdata(lm_dev); 960 #else 961 dwc_otg_device_t *otg_dev = dev_get_drvdata(_dev); 962 #endif 963 uint32_t reg_val; 704 964 int i; 705 965 int time; 706 966 int start_jiffies; 707 dwc_otg_device_t *otg_dev = dev_get_drvdata(_dev);708 uint32_t reg_val;709 967 710 968 printk("HZ %d, MSEC_PER_JIFFIE %d, loops_per_jiffy %lu\n", … … 728 986 void dwc_otg_attr_create (struct lm_device *lmdev) 729 987 { 730 device_create_file(&lmdev->dev, &dev_attr_regoffset); 731 device_create_file(&lmdev->dev, &dev_attr_regvalue); 732 device_create_file(&lmdev->dev, &dev_attr_mode); 733 device_create_file(&lmdev->dev, &dev_attr_hnpcapable); 734 device_create_file(&lmdev->dev, &dev_attr_srpcapable); 735 device_create_file(&lmdev->dev, &dev_attr_hnp); 736 device_create_file(&lmdev->dev, &dev_attr_srp); 737 device_create_file(&lmdev->dev, &dev_attr_buspower); 738 device_create_file(&lmdev->dev, &dev_attr_bussuspend); 739 device_create_file(&lmdev->dev, &dev_attr_busconnected); 740 device_create_file(&lmdev->dev, &dev_attr_gotgctl); 741 device_create_file(&lmdev->dev, &dev_attr_gusbcfg); 742 device_create_file(&lmdev->dev, &dev_attr_grxfsiz); 743 device_create_file(&lmdev->dev, &dev_attr_gnptxfsiz); 744 device_create_file(&lmdev->dev, &dev_attr_gpvndctl); 745 device_create_file(&lmdev->dev, &dev_attr_ggpio); 746 device_create_file(&lmdev->dev, &dev_attr_guid); 747 device_create_file(&lmdev->dev, &dev_attr_gsnpsid); 748 device_create_file(&lmdev->dev, &dev_attr_devspeed); 749 device_create_file(&lmdev->dev, &dev_attr_enumspeed); 750 device_create_file(&lmdev->dev, &dev_attr_hptxfsiz); 751 device_create_file(&lmdev->dev, &dev_attr_hprt0); 752 device_create_file(&lmdev->dev, &dev_attr_remote_wakeup); 753 device_create_file(&lmdev->dev, &dev_attr_regdump); 754 device_create_file(&lmdev->dev, &dev_attr_hcddump); 755 device_create_file(&lmdev->dev, &dev_attr_hcd_frrem); 756 device_create_file(&lmdev->dev, &dev_attr_rd_reg_test); 757 device_create_file(&lmdev->dev, &dev_attr_wr_reg_test); 988 int error; 989 990 error = device_create_file(&lmdev->dev, &dev_attr_regoffset); 991 error = device_create_file(&lmdev->dev, &dev_attr_regvalue); 992 error = device_create_file(&lmdev->dev, &dev_attr_mode); 993 error = device_create_file(&lmdev->dev, &dev_attr_hnpcapable); 994 error = device_create_file(&lmdev->dev, &dev_attr_srpcapable); 995 error = device_create_file(&lmdev->dev, &dev_attr_hnp); 996 error = device_create_file(&lmdev->dev, &dev_attr_srp); 997 error = device_create_file(&lmdev->dev, &dev_attr_buspower); 998 error = device_create_file(&lmdev->dev, &dev_attr_bussuspend); 999 error = device_create_file(&lmdev->dev, &dev_attr_busconnected); 1000 error = device_create_file(&lmdev->dev, &dev_attr_gotgctl); 1001 error = device_create_file(&lmdev->dev, &dev_attr_gusbcfg); 1002 error = device_create_file(&lmdev->dev, &dev_attr_grxfsiz); 1003 error = device_create_file(&lmdev->dev, &dev_attr_gnptxfsiz); 1004 error = device_create_file(&lmdev->dev, &dev_attr_gpvndctl); 1005 error = device_create_file(&lmdev->dev, &dev_attr_ggpio); 1006 error = device_create_file(&lmdev->dev, &dev_attr_guid); 1007 error = device_create_file(&lmdev->dev, &dev_attr_gsnpsid); 1008 error = device_create_file(&lmdev->dev, &dev_attr_devspeed); 1009 error = device_create_file(&lmdev->dev, &dev_attr_enumspeed); 1010 error = device_create_file(&lmdev->dev, &dev_attr_hptxfsiz); 1011 error = device_create_file(&lmdev->dev, &dev_attr_hprt0); 1012 error = device_create_file(&lmdev->dev, &dev_attr_remote_wakeup); 1013 error = device_create_file(&lmdev->dev, &dev_attr_regdump); 1014 error = device_create_file(&lmdev->dev, &dev_attr_spramdump); 1015 error = device_create_file(&lmdev->dev, &dev_attr_hcddump); 1016 error = device_create_file(&lmdev->dev, &dev_attr_hcd_frrem); 1017 error = device_create_file(&lmdev->dev, &dev_attr_rd_reg_test); 1018 error = device_create_file(&lmdev->dev, &dev_attr_wr_reg_test); 758 1019 } 759 1020 … … 787 1048 device_remove_file(&lmdev->dev, &dev_attr_remote_wakeup); 788 1049 device_remove_file(&lmdev->dev, &dev_attr_regdump); 1050 device_remove_file(&lmdev->dev, &dev_attr_spramdump); 789 1051 device_remove_file(&lmdev->dev, &dev_attr_hcddump); 790 1052 device_remove_file(&lmdev->dev, &dev_attr_hcd_frrem);
