aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/chipidea/debug.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/usb/chipidea/debug.c')
-rw-r--r--drivers/usb/chipidea/debug.c146
1 files changed, 73 insertions, 73 deletions
diff --git a/drivers/usb/chipidea/debug.c b/drivers/usb/chipidea/debug.c
index c4b3e15532db..c6f50a257565 100644
--- a/drivers/usb/chipidea/debug.c
+++ b/drivers/usb/chipidea/debug.c
@@ -68,15 +68,15 @@ void dbg_interrupt(u32 intmask)
68 * 68 *
69 * This function returns number of registers read 69 * This function returns number of registers read
70 */ 70 */
71static size_t hw_register_read(struct ci13xxx *udc, u32 *buf, size_t size) 71static size_t hw_register_read(struct ci13xxx *ci, u32 *buf, size_t size)
72{ 72{
73 unsigned i; 73 unsigned i;
74 74
75 if (size > udc->hw_bank.size) 75 if (size > ci->hw_bank.size)
76 size = udc->hw_bank.size; 76 size = ci->hw_bank.size;
77 77
78 for (i = 0; i < size; i++) 78 for (i = 0; i < size; i++)
79 buf[i] = hw_read(udc, i * sizeof(u32), ~0); 79 buf[i] = hw_read(ci, i * sizeof(u32), ~0);
80 80
81 return size; 81 return size;
82} 82}
@@ -88,18 +88,18 @@ static size_t hw_register_read(struct ci13xxx *udc, u32 *buf, size_t size)
88 * 88 *
89 * This function returns an error code 89 * This function returns an error code
90 */ 90 */
91static int hw_register_write(struct ci13xxx *udc, u16 addr, u32 data) 91static int hw_register_write(struct ci13xxx *ci, u16 addr, u32 data)
92{ 92{
93 /* align */ 93 /* align */
94 addr /= sizeof(u32); 94 addr /= sizeof(u32);
95 95
96 if (addr >= udc->hw_bank.size) 96 if (addr >= ci->hw_bank.size)
97 return -EINVAL; 97 return -EINVAL;
98 98
99 /* align */ 99 /* align */
100 addr *= sizeof(u32); 100 addr *= sizeof(u32);
101 101
102 hw_write(udc, addr, ~0, data); 102 hw_write(ci, addr, ~0, data);
103 return 0; 103 return 0;
104} 104}
105 105
@@ -110,13 +110,13 @@ static int hw_register_write(struct ci13xxx *udc, u16 addr, u32 data)
110 * 110 *
111 * This function returns an error code 111 * This function returns an error code
112 */ 112 */
113static int hw_intr_clear(struct ci13xxx *udc, int n) 113static int hw_intr_clear(struct ci13xxx *ci, int n)
114{ 114{
115 if (n >= REG_BITS) 115 if (n >= REG_BITS)
116 return -EINVAL; 116 return -EINVAL;
117 117
118 hw_write(udc, OP_USBINTR, BIT(n), 0); 118 hw_write(ci, OP_USBINTR, BIT(n), 0);
119 hw_write(udc, OP_USBSTS, BIT(n), BIT(n)); 119 hw_write(ci, OP_USBSTS, BIT(n), BIT(n));
120 return 0; 120 return 0;
121} 121}
122 122
@@ -127,15 +127,15 @@ static int hw_intr_clear(struct ci13xxx *udc, int n)
127 * 127 *
128 * This function returns an error code 128 * This function returns an error code
129 */ 129 */
130static int hw_intr_force(struct ci13xxx *udc, int n) 130static int hw_intr_force(struct ci13xxx *ci, int n)
131{ 131{
132 if (n >= REG_BITS) 132 if (n >= REG_BITS)
133 return -EINVAL; 133 return -EINVAL;
134 134
135 hw_write(udc, CAP_TESTMODE, TESTMODE_FORCE, TESTMODE_FORCE); 135 hw_write(ci, CAP_TESTMODE, TESTMODE_FORCE, TESTMODE_FORCE);
136 hw_write(udc, OP_USBINTR, BIT(n), BIT(n)); 136 hw_write(ci, OP_USBINTR, BIT(n), BIT(n));
137 hw_write(udc, OP_USBSTS, BIT(n), BIT(n)); 137 hw_write(ci, OP_USBSTS, BIT(n), BIT(n));
138 hw_write(udc, CAP_TESTMODE, TESTMODE_FORCE, 0); 138 hw_write(ci, CAP_TESTMODE, TESTMODE_FORCE, 0);
139 return 0; 139 return 0;
140} 140}
141 141
@@ -147,12 +147,12 @@ static int hw_intr_force(struct ci13xxx *udc, int n)
147static ssize_t show_device(struct device *dev, struct device_attribute *attr, 147static ssize_t show_device(struct device *dev, struct device_attribute *attr,
148 char *buf) 148 char *buf)
149{ 149{
150 struct ci13xxx *udc = container_of(dev, struct ci13xxx, gadget.dev); 150 struct ci13xxx *ci = container_of(dev, struct ci13xxx, gadget.dev);
151 struct usb_gadget *gadget = &udc->gadget; 151 struct usb_gadget *gadget = &ci->gadget;
152 int n = 0; 152 int n = 0;
153 153
154 if (attr == NULL || buf == NULL) { 154 if (attr == NULL || buf == NULL) {
155 dev_err(udc->dev, "[%s] EINVAL\n", __func__); 155 dev_err(ci->dev, "[%s] EINVAL\n", __func__);
156 return 0; 156 return 0;
157 } 157 }
158 158
@@ -188,8 +188,8 @@ static DEVICE_ATTR(device, S_IRUSR, show_device, NULL);
188static ssize_t show_driver(struct device *dev, struct device_attribute *attr, 188static ssize_t show_driver(struct device *dev, struct device_attribute *attr,
189 char *buf) 189 char *buf)
190{ 190{
191 struct ci13xxx *udc = container_of(dev, struct ci13xxx, gadget.dev); 191 struct ci13xxx *ci = container_of(dev, struct ci13xxx, gadget.dev);
192 struct usb_gadget_driver *driver = udc->driver; 192 struct usb_gadget_driver *driver = ci->driver;
193 int n = 0; 193 int n = 0;
194 194
195 if (attr == NULL || buf == NULL) { 195 if (attr == NULL || buf == NULL) {
@@ -412,22 +412,22 @@ static DEVICE_ATTR(events, S_IRUSR | S_IWUSR, show_events, store_events);
412static ssize_t show_inters(struct device *dev, struct device_attribute *attr, 412static ssize_t show_inters(struct device *dev, struct device_attribute *attr,
413 char *buf) 413 char *buf)
414{ 414{
415 struct ci13xxx *udc = container_of(dev, struct ci13xxx, gadget.dev); 415 struct ci13xxx *ci = container_of(dev, struct ci13xxx, gadget.dev);
416 unsigned long flags; 416 unsigned long flags;
417 u32 intr; 417 u32 intr;
418 unsigned i, j, n = 0; 418 unsigned i, j, n = 0;
419 419
420 if (attr == NULL || buf == NULL) { 420 if (attr == NULL || buf == NULL) {
421 dev_err(udc->dev, "[%s] EINVAL\n", __func__); 421 dev_err(ci->dev, "[%s] EINVAL\n", __func__);
422 return 0; 422 return 0;
423 } 423 }
424 424
425 spin_lock_irqsave(&udc->lock, flags); 425 spin_lock_irqsave(&ci->lock, flags);
426 426
427 /*n += scnprintf(buf + n, PAGE_SIZE - n, 427 /*n += scnprintf(buf + n, PAGE_SIZE - n,
428 "status = %08x\n", hw_read_intr_status(udc)); 428 "status = %08x\n", hw_read_intr_status(ci));
429 n += scnprintf(buf + n, PAGE_SIZE - n, 429 n += scnprintf(buf + n, PAGE_SIZE - n,
430 "enable = %08x\n", hw_read_intr_enable(udc));*/ 430 "enable = %08x\n", hw_read_intr_enable(ci));*/
431 431
432 n += scnprintf(buf + n, PAGE_SIZE - n, "*test = %d\n", 432 n += scnprintf(buf + n, PAGE_SIZE - n, "*test = %d\n",
433 isr_statistics.test); 433 isr_statistics.test);
@@ -471,7 +471,7 @@ static ssize_t show_inters(struct device *dev, struct device_attribute *attr,
471 n += scnprintf(buf + n, PAGE_SIZE - n, "\n"); 471 n += scnprintf(buf + n, PAGE_SIZE - n, "\n");
472 } 472 }
473 473
474 spin_unlock_irqrestore(&udc->lock, flags); 474 spin_unlock_irqrestore(&ci->lock, flags);
475 475
476 return n; 476 return n;
477} 477}
@@ -485,31 +485,31 @@ static ssize_t show_inters(struct device *dev, struct device_attribute *attr,
485static ssize_t store_inters(struct device *dev, struct device_attribute *attr, 485static ssize_t store_inters(struct device *dev, struct device_attribute *attr,
486 const char *buf, size_t count) 486 const char *buf, size_t count)
487{ 487{
488 struct ci13xxx *udc = container_of(dev, struct ci13xxx, gadget.dev); 488 struct ci13xxx *ci = container_of(dev, struct ci13xxx, gadget.dev);
489 unsigned long flags; 489 unsigned long flags;
490 unsigned en, bit; 490 unsigned en, bit;
491 491
492 if (attr == NULL || buf == NULL) { 492 if (attr == NULL || buf == NULL) {
493 dev_err(udc->dev, "EINVAL\n"); 493 dev_err(ci->dev, "EINVAL\n");
494 goto done; 494 goto done;
495 } 495 }
496 496
497 if (sscanf(buf, "%u %u", &en, &bit) != 2 || en > 1) { 497 if (sscanf(buf, "%u %u", &en, &bit) != 2 || en > 1) {
498 dev_err(udc->dev, "<1|0> <bit>: enable|disable interrupt\n"); 498 dev_err(ci->dev, "<1|0> <bit>: enable|disable interrupt\n");
499 goto done; 499 goto done;
500 } 500 }
501 501
502 spin_lock_irqsave(&udc->lock, flags); 502 spin_lock_irqsave(&ci->lock, flags);
503 if (en) { 503 if (en) {
504 if (hw_intr_force(udc, bit)) 504 if (hw_intr_force(ci, bit))
505 dev_err(dev, "invalid bit number\n"); 505 dev_err(dev, "invalid bit number\n");
506 else 506 else
507 isr_statistics.test++; 507 isr_statistics.test++;
508 } else { 508 } else {
509 if (hw_intr_clear(udc, bit)) 509 if (hw_intr_clear(ci, bit))
510 dev_err(dev, "invalid bit number\n"); 510 dev_err(dev, "invalid bit number\n");
511 } 511 }
512 spin_unlock_irqrestore(&udc->lock, flags); 512 spin_unlock_irqrestore(&ci->lock, flags);
513 513
514 done: 514 done:
515 return count; 515 return count;
@@ -524,18 +524,18 @@ static DEVICE_ATTR(inters, S_IRUSR | S_IWUSR, show_inters, store_inters);
524static ssize_t show_port_test(struct device *dev, 524static ssize_t show_port_test(struct device *dev,
525 struct device_attribute *attr, char *buf) 525 struct device_attribute *attr, char *buf)
526{ 526{
527 struct ci13xxx *udc = container_of(dev, struct ci13xxx, gadget.dev); 527 struct ci13xxx *ci = container_of(dev, struct ci13xxx, gadget.dev);
528 unsigned long flags; 528 unsigned long flags;
529 unsigned mode; 529 unsigned mode;
530 530
531 if (attr == NULL || buf == NULL) { 531 if (attr == NULL || buf == NULL) {
532 dev_err(udc->dev, "EINVAL\n"); 532 dev_err(ci->dev, "EINVAL\n");
533 return 0; 533 return 0;
534 } 534 }
535 535
536 spin_lock_irqsave(&udc->lock, flags); 536 spin_lock_irqsave(&ci->lock, flags);
537 mode = hw_port_test_get(udc); 537 mode = hw_port_test_get(ci);
538 spin_unlock_irqrestore(&udc->lock, flags); 538 spin_unlock_irqrestore(&ci->lock, flags);
539 539
540 return scnprintf(buf, PAGE_SIZE, "mode = %u\n", mode); 540 return scnprintf(buf, PAGE_SIZE, "mode = %u\n", mode);
541} 541}
@@ -549,24 +549,24 @@ static ssize_t store_port_test(struct device *dev,
549 struct device_attribute *attr, 549 struct device_attribute *attr,
550 const char *buf, size_t count) 550 const char *buf, size_t count)
551{ 551{
552 struct ci13xxx *udc = container_of(dev, struct ci13xxx, gadget.dev); 552 struct ci13xxx *ci = container_of(dev, struct ci13xxx, gadget.dev);
553 unsigned long flags; 553 unsigned long flags;
554 unsigned mode; 554 unsigned mode;
555 555
556 if (attr == NULL || buf == NULL) { 556 if (attr == NULL || buf == NULL) {
557 dev_err(udc->dev, "[%s] EINVAL\n", __func__); 557 dev_err(ci->dev, "[%s] EINVAL\n", __func__);
558 goto done; 558 goto done;
559 } 559 }
560 560
561 if (sscanf(buf, "%u", &mode) != 1) { 561 if (sscanf(buf, "%u", &mode) != 1) {
562 dev_err(udc->dev, "<mode>: set port test mode"); 562 dev_err(ci->dev, "<mode>: set port test mode");
563 goto done; 563 goto done;
564 } 564 }
565 565
566 spin_lock_irqsave(&udc->lock, flags); 566 spin_lock_irqsave(&ci->lock, flags);
567 if (hw_port_test_set(udc, mode)) 567 if (hw_port_test_set(ci, mode))
568 dev_err(udc->dev, "invalid mode\n"); 568 dev_err(ci->dev, "invalid mode\n");
569 spin_unlock_irqrestore(&udc->lock, flags); 569 spin_unlock_irqrestore(&ci->lock, flags);
570 570
571 done: 571 done:
572 return count; 572 return count;
@@ -582,20 +582,20 @@ static DEVICE_ATTR(port_test, S_IRUSR | S_IWUSR,
582static ssize_t show_qheads(struct device *dev, struct device_attribute *attr, 582static ssize_t show_qheads(struct device *dev, struct device_attribute *attr,
583 char *buf) 583 char *buf)
584{ 584{
585 struct ci13xxx *udc = container_of(dev, struct ci13xxx, gadget.dev); 585 struct ci13xxx *ci = container_of(dev, struct ci13xxx, gadget.dev);
586 unsigned long flags; 586 unsigned long flags;
587 unsigned i, j, n = 0; 587 unsigned i, j, n = 0;
588 588
589 if (attr == NULL || buf == NULL) { 589 if (attr == NULL || buf == NULL) {
590 dev_err(udc->dev, "[%s] EINVAL\n", __func__); 590 dev_err(ci->dev, "[%s] EINVAL\n", __func__);
591 return 0; 591 return 0;
592 } 592 }
593 593
594 spin_lock_irqsave(&udc->lock, flags); 594 spin_lock_irqsave(&ci->lock, flags);
595 for (i = 0; i < udc->hw_ep_max/2; i++) { 595 for (i = 0; i < ci->hw_ep_max/2; i++) {
596 struct ci13xxx_ep *mEpRx = &udc->ci13xxx_ep[i]; 596 struct ci13xxx_ep *mEpRx = &ci->ci13xxx_ep[i];
597 struct ci13xxx_ep *mEpTx = 597 struct ci13xxx_ep *mEpTx =
598 &udc->ci13xxx_ep[i + udc->hw_ep_max/2]; 598 &ci->ci13xxx_ep[i + ci->hw_ep_max/2];
599 n += scnprintf(buf + n, PAGE_SIZE - n, 599 n += scnprintf(buf + n, PAGE_SIZE - n,
600 "EP=%02i: RX=%08X TX=%08X\n", 600 "EP=%02i: RX=%08X TX=%08X\n",
601 i, (u32)mEpRx->qh.dma, (u32)mEpTx->qh.dma); 601 i, (u32)mEpRx->qh.dma, (u32)mEpTx->qh.dma);
@@ -606,7 +606,7 @@ static ssize_t show_qheads(struct device *dev, struct device_attribute *attr,
606 *((u32 *)mEpTx->qh.ptr + j)); 606 *((u32 *)mEpTx->qh.ptr + j));
607 } 607 }
608 } 608 }
609 spin_unlock_irqrestore(&udc->lock, flags); 609 spin_unlock_irqrestore(&ci->lock, flags);
610 610
611 return n; 611 return n;
612} 612}
@@ -621,25 +621,25 @@ static DEVICE_ATTR(qheads, S_IRUSR, show_qheads, NULL);
621static ssize_t show_registers(struct device *dev, 621static ssize_t show_registers(struct device *dev,
622 struct device_attribute *attr, char *buf) 622 struct device_attribute *attr, char *buf)
623{ 623{
624 struct ci13xxx *udc = container_of(dev, struct ci13xxx, gadget.dev); 624 struct ci13xxx *ci = container_of(dev, struct ci13xxx, gadget.dev);
625 unsigned long flags; 625 unsigned long flags;
626 u32 *dump; 626 u32 *dump;
627 unsigned i, k, n = 0; 627 unsigned i, k, n = 0;
628 628
629 if (attr == NULL || buf == NULL) { 629 if (attr == NULL || buf == NULL) {
630 dev_err(udc->dev, "[%s] EINVAL\n", __func__); 630 dev_err(ci->dev, "[%s] EINVAL\n", __func__);
631 return 0; 631 return 0;
632 } 632 }
633 633
634 dump = kmalloc(sizeof(u32) * DUMP_ENTRIES, GFP_KERNEL); 634 dump = kmalloc(sizeof(u32) * DUMP_ENTRIES, GFP_KERNEL);
635 if (!dump) { 635 if (!dump) {
636 dev_err(udc->dev, "%s: out of memory\n", __func__); 636 dev_err(ci->dev, "%s: out of memory\n", __func__);
637 return 0; 637 return 0;
638 } 638 }
639 639
640 spin_lock_irqsave(&udc->lock, flags); 640 spin_lock_irqsave(&ci->lock, flags);
641 k = hw_register_read(udc, dump, DUMP_ENTRIES); 641 k = hw_register_read(ci, dump, DUMP_ENTRIES);
642 spin_unlock_irqrestore(&udc->lock, flags); 642 spin_unlock_irqrestore(&ci->lock, flags);
643 643
644 for (i = 0; i < k; i++) { 644 for (i = 0; i < k; i++) {
645 n += scnprintf(buf + n, PAGE_SIZE - n, 645 n += scnprintf(buf + n, PAGE_SIZE - n,
@@ -660,24 +660,24 @@ static ssize_t store_registers(struct device *dev,
660 struct device_attribute *attr, 660 struct device_attribute *attr,
661 const char *buf, size_t count) 661 const char *buf, size_t count)
662{ 662{
663 struct ci13xxx *udc = container_of(dev, struct ci13xxx, gadget.dev); 663 struct ci13xxx *ci = container_of(dev, struct ci13xxx, gadget.dev);
664 unsigned long addr, data, flags; 664 unsigned long addr, data, flags;
665 665
666 if (attr == NULL || buf == NULL) { 666 if (attr == NULL || buf == NULL) {
667 dev_err(udc->dev, "[%s] EINVAL\n", __func__); 667 dev_err(ci->dev, "[%s] EINVAL\n", __func__);
668 goto done; 668 goto done;
669 } 669 }
670 670
671 if (sscanf(buf, "%li %li", &addr, &data) != 2) { 671 if (sscanf(buf, "%li %li", &addr, &data) != 2) {
672 dev_err(udc->dev, 672 dev_err(ci->dev,
673 "<addr> <data>: write data to register address\n"); 673 "<addr> <data>: write data to register address\n");
674 goto done; 674 goto done;
675 } 675 }
676 676
677 spin_lock_irqsave(&udc->lock, flags); 677 spin_lock_irqsave(&ci->lock, flags);
678 if (hw_register_write(udc, addr, data)) 678 if (hw_register_write(ci, addr, data))
679 dev_err(udc->dev, "invalid address range\n"); 679 dev_err(ci->dev, "invalid address range\n");
680 spin_unlock_irqrestore(&udc->lock, flags); 680 spin_unlock_irqrestore(&ci->lock, flags);
681 681
682 done: 682 done:
683 return count; 683 return count;
@@ -693,34 +693,34 @@ static DEVICE_ATTR(registers, S_IRUSR | S_IWUSR,
693static ssize_t show_requests(struct device *dev, struct device_attribute *attr, 693static ssize_t show_requests(struct device *dev, struct device_attribute *attr,
694 char *buf) 694 char *buf)
695{ 695{
696 struct ci13xxx *udc = container_of(dev, struct ci13xxx, gadget.dev); 696 struct ci13xxx *ci = container_of(dev, struct ci13xxx, gadget.dev);
697 unsigned long flags; 697 unsigned long flags;
698 struct list_head *ptr = NULL; 698 struct list_head *ptr = NULL;
699 struct ci13xxx_req *req = NULL; 699 struct ci13xxx_req *req = NULL;
700 unsigned i, j, n = 0, qSize = sizeof(struct ci13xxx_td)/sizeof(u32); 700 unsigned i, j, n = 0, qSize = sizeof(struct ci13xxx_td)/sizeof(u32);
701 701
702 if (attr == NULL || buf == NULL) { 702 if (attr == NULL || buf == NULL) {
703 dev_err(udc->dev, "[%s] EINVAL\n", __func__); 703 dev_err(ci->dev, "[%s] EINVAL\n", __func__);
704 return 0; 704 return 0;
705 } 705 }
706 706
707 spin_lock_irqsave(&udc->lock, flags); 707 spin_lock_irqsave(&ci->lock, flags);
708 for (i = 0; i < udc->hw_ep_max; i++) 708 for (i = 0; i < ci->hw_ep_max; i++)
709 list_for_each(ptr, &udc->ci13xxx_ep[i].qh.queue) 709 list_for_each(ptr, &ci->ci13xxx_ep[i].qh.queue)
710 { 710 {
711 req = list_entry(ptr, struct ci13xxx_req, queue); 711 req = list_entry(ptr, struct ci13xxx_req, queue);
712 712
713 n += scnprintf(buf + n, PAGE_SIZE - n, 713 n += scnprintf(buf + n, PAGE_SIZE - n,
714 "EP=%02i: TD=%08X %s\n", 714 "EP=%02i: TD=%08X %s\n",
715 i % udc->hw_ep_max/2, (u32)req->dma, 715 i % ci->hw_ep_max/2, (u32)req->dma,
716 ((i < udc->hw_ep_max/2) ? "RX" : "TX")); 716 ((i < ci->hw_ep_max/2) ? "RX" : "TX"));
717 717
718 for (j = 0; j < qSize; j++) 718 for (j = 0; j < qSize; j++)
719 n += scnprintf(buf + n, PAGE_SIZE - n, 719 n += scnprintf(buf + n, PAGE_SIZE - n,
720 " %04X: %08X\n", j, 720 " %04X: %08X\n", j,
721 *((u32 *)req->ptr + j)); 721 *((u32 *)req->ptr + j));
722 } 722 }
723 spin_unlock_irqrestore(&udc->lock, flags); 723 spin_unlock_irqrestore(&ci->lock, flags);
724 724
725 return n; 725 return n;
726} 726}