diff options
author | Arvid Brodin <arvid.brodin@enea.com> | 2011-02-26 16:04:40 -0500 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2011-02-28 22:23:37 -0500 |
commit | a041d8e4375ee6d78409a721221878dcad5eff8a (patch) | |
tree | 9749f4c0e373aace706ac037b2b535e1427ba31a /drivers | |
parent | fd436aee97d157ff6441e7aaff2a2dc802765b5b (diff) |
usb/isp1760: Clean up payload address handling
Encapsulate payload addresses within qtds.
Signed-off-by: Arvid Brodin <arvid.brodin@enea.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/usb/host/isp1760-hcd.c | 197 | ||||
-rw-r--r-- | drivers/usb/host/isp1760-hcd.h | 9 |
2 files changed, 95 insertions, 111 deletions
diff --git a/drivers/usb/host/isp1760-hcd.c b/drivers/usb/host/isp1760-hcd.c index 2342f11d0f30..cfb8e8ab9338 100644 --- a/drivers/usb/host/isp1760-hcd.c +++ b/drivers/usb/host/isp1760-hcd.c | |||
@@ -85,6 +85,8 @@ struct isp1760_qtd { | |||
85 | u8 toggle; | 85 | u8 toggle; |
86 | 86 | ||
87 | void *data_buffer; | 87 | void *data_buffer; |
88 | u32 payload_addr; | ||
89 | |||
88 | /* the rest is HCD-private */ | 90 | /* the rest is HCD-private */ |
89 | struct list_head qtd_list; | 91 | struct list_head qtd_list; |
90 | struct urb *urb; | 92 | struct urb *urb; |
@@ -256,54 +258,56 @@ static void ptd_write(void __iomem *base, u32 ptd_offset, u32 slot, | |||
256 | /* memory management of the 60kb on the chip from 0x1000 to 0xffff */ | 258 | /* memory management of the 60kb on the chip from 0x1000 to 0xffff */ |
257 | static void init_memory(struct isp1760_hcd *priv) | 259 | static void init_memory(struct isp1760_hcd *priv) |
258 | { | 260 | { |
259 | int i; | 261 | int i, curr; |
260 | u32 payload; | 262 | u32 payload_addr; |
261 | 263 | ||
262 | payload = 0x1000; | 264 | payload_addr = PAYLOAD_OFFSET; |
263 | for (i = 0; i < BLOCK_1_NUM; i++) { | 265 | for (i = 0; i < BLOCK_1_NUM; i++) { |
264 | priv->memory_pool[i].start = payload; | 266 | priv->memory_pool[i].start = payload_addr; |
265 | priv->memory_pool[i].size = BLOCK_1_SIZE; | 267 | priv->memory_pool[i].size = BLOCK_1_SIZE; |
266 | priv->memory_pool[i].free = 1; | 268 | priv->memory_pool[i].free = 1; |
267 | payload += priv->memory_pool[i].size; | 269 | payload_addr += priv->memory_pool[i].size; |
268 | } | 270 | } |
269 | 271 | ||
270 | 272 | curr = i; | |
271 | for (i = BLOCK_1_NUM; i < BLOCK_1_NUM + BLOCK_2_NUM; i++) { | 273 | for (i = 0; i < BLOCK_2_NUM; i++) { |
272 | priv->memory_pool[i].start = payload; | 274 | priv->memory_pool[curr + i].start = payload_addr; |
273 | priv->memory_pool[i].size = BLOCK_2_SIZE; | 275 | priv->memory_pool[curr + i].size = BLOCK_2_SIZE; |
274 | priv->memory_pool[i].free = 1; | 276 | priv->memory_pool[curr + i].free = 1; |
275 | payload += priv->memory_pool[i].size; | 277 | payload_addr += priv->memory_pool[curr + i].size; |
276 | } | 278 | } |
277 | 279 | ||
278 | 280 | curr = i; | |
279 | for (i = BLOCK_1_NUM + BLOCK_2_NUM; i < BLOCKS; i++) { | 281 | for (i = 0; i < BLOCK_3_NUM; i++) { |
280 | priv->memory_pool[i].start = payload; | 282 | priv->memory_pool[curr + i].start = payload_addr; |
281 | priv->memory_pool[i].size = BLOCK_3_SIZE; | 283 | priv->memory_pool[curr + i].size = BLOCK_3_SIZE; |
282 | priv->memory_pool[i].free = 1; | 284 | priv->memory_pool[curr + i].free = 1; |
283 | payload += priv->memory_pool[i].size; | 285 | payload_addr += priv->memory_pool[curr + i].size; |
284 | } | 286 | } |
285 | 287 | ||
286 | BUG_ON(payload - priv->memory_pool[i - 1].size > PAYLOAD_SIZE); | 288 | BUG_ON(payload_addr - priv->memory_pool[0].start > PAYLOAD_AREA_SIZE); |
287 | } | 289 | } |
288 | 290 | ||
289 | static u32 alloc_mem(struct isp1760_hcd *priv, u32 size) | 291 | static void alloc_mem(struct isp1760_hcd *priv, struct isp1760_qtd *qtd) |
290 | { | 292 | { |
291 | int i; | 293 | int i; |
292 | 294 | ||
293 | if (!size) | 295 | BUG_ON(qtd->payload_addr); |
294 | return ISP1760_NULL_POINTER; | 296 | |
297 | if (!qtd->length) | ||
298 | return; | ||
295 | 299 | ||
296 | for (i = 0; i < BLOCKS; i++) { | 300 | for (i = 0; i < BLOCKS; i++) { |
297 | if (priv->memory_pool[i].size >= size && | 301 | if (priv->memory_pool[i].size >= qtd->length && |
298 | priv->memory_pool[i].free) { | 302 | priv->memory_pool[i].free) { |
299 | |||
300 | priv->memory_pool[i].free = 0; | 303 | priv->memory_pool[i].free = 0; |
301 | return priv->memory_pool[i].start; | 304 | qtd->payload_addr = priv->memory_pool[i].start; |
305 | return; | ||
302 | } | 306 | } |
303 | } | 307 | } |
304 | 308 | ||
305 | printk(KERN_ERR "ISP1760 MEM: can not allocate %d bytes of memory\n", | 309 | printk(KERN_ERR "ISP1760 MEM: can not allocate %lu bytes of memory\n", |
306 | size); | 310 | qtd->length); |
307 | printk(KERN_ERR "Current memory map:\n"); | 311 | printk(KERN_ERR "Current memory map:\n"); |
308 | for (i = 0; i < BLOCKS; i++) { | 312 | for (i = 0; i < BLOCKS; i++) { |
309 | printk(KERN_ERR "Pool %2d size %4d status: %d\n", | 313 | printk(KERN_ERR "Pool %2d size %4d status: %d\n", |
@@ -312,28 +316,27 @@ static u32 alloc_mem(struct isp1760_hcd *priv, u32 size) | |||
312 | } | 316 | } |
313 | /* XXX maybe -ENOMEM could be possible */ | 317 | /* XXX maybe -ENOMEM could be possible */ |
314 | BUG(); | 318 | BUG(); |
315 | return 0; | 319 | return; |
316 | } | 320 | } |
317 | 321 | ||
318 | static void free_mem(struct isp1760_hcd *priv, u32 mem) | 322 | static void free_mem(struct isp1760_hcd *priv, struct isp1760_qtd *qtd) |
319 | { | 323 | { |
320 | int i; | 324 | int i; |
321 | 325 | ||
322 | if (mem == ISP1760_NULL_POINTER) | 326 | if (!qtd->payload_addr) |
323 | return; | 327 | return; |
324 | 328 | ||
325 | for (i = 0; i < BLOCKS; i++) { | 329 | for (i = 0; i < BLOCKS; i++) { |
326 | if (priv->memory_pool[i].start == mem) { | 330 | if (priv->memory_pool[i].start == qtd->payload_addr) { |
327 | |||
328 | BUG_ON(priv->memory_pool[i].free); | 331 | BUG_ON(priv->memory_pool[i].free); |
329 | |||
330 | priv->memory_pool[i].free = 1; | 332 | priv->memory_pool[i].free = 1; |
331 | return ; | 333 | qtd->payload_addr = 0; |
334 | return; | ||
332 | } | 335 | } |
333 | } | 336 | } |
334 | 337 | ||
335 | printk(KERN_ERR "Trying to free not-here-allocated memory :%08x\n", | 338 | printk(KERN_ERR "%s: Invalid pointer: %08x\n", __func__, |
336 | mem); | 339 | qtd->payload_addr); |
337 | BUG(); | 340 | BUG(); |
338 | } | 341 | } |
339 | 342 | ||
@@ -596,8 +599,7 @@ static u32 base_to_chip(u32 base) | |||
596 | } | 599 | } |
597 | 600 | ||
598 | static void transform_into_atl(struct isp1760_hcd *priv, struct isp1760_qh *qh, | 601 | static void transform_into_atl(struct isp1760_hcd *priv, struct isp1760_qh *qh, |
599 | struct isp1760_qtd *qtd, struct urb *urb, | 602 | struct isp1760_qtd *qtd, struct ptd *ptd) |
600 | u32 payload, struct ptd *ptd) | ||
601 | { | 603 | { |
602 | u32 maxpacket; | 604 | u32 maxpacket; |
603 | u32 multi; | 605 | u32 multi; |
@@ -608,7 +610,8 @@ static void transform_into_atl(struct isp1760_hcd *priv, struct isp1760_qh *qh, | |||
608 | memset(ptd, 0, sizeof(*ptd)); | 610 | memset(ptd, 0, sizeof(*ptd)); |
609 | 611 | ||
610 | /* according to 3.6.2, max packet len can not be > 0x400 */ | 612 | /* according to 3.6.2, max packet len can not be > 0x400 */ |
611 | maxpacket = usb_maxpacket(urb->dev, urb->pipe, usb_pipeout(urb->pipe)); | 613 | maxpacket = usb_maxpacket(qtd->urb->dev, qtd->urb->pipe, |
614 | usb_pipeout(qtd->urb->pipe)); | ||
612 | multi = 1 + ((maxpacket >> 11) & 0x3); | 615 | multi = 1 + ((maxpacket >> 11) & 0x3); |
613 | maxpacket &= 0x7ff; | 616 | maxpacket &= 0x7ff; |
614 | 617 | ||
@@ -616,33 +619,33 @@ static void transform_into_atl(struct isp1760_hcd *priv, struct isp1760_qh *qh, | |||
616 | ptd->dw0 = PTD_VALID; | 619 | ptd->dw0 = PTD_VALID; |
617 | ptd->dw0 |= PTD_LENGTH(qtd->length); | 620 | ptd->dw0 |= PTD_LENGTH(qtd->length); |
618 | ptd->dw0 |= PTD_MAXPACKET(maxpacket); | 621 | ptd->dw0 |= PTD_MAXPACKET(maxpacket); |
619 | ptd->dw0 |= PTD_ENDPOINT(usb_pipeendpoint(urb->pipe)); | 622 | ptd->dw0 |= PTD_ENDPOINT(usb_pipeendpoint(qtd->urb->pipe)); |
620 | ptd->dw1 = usb_pipeendpoint(urb->pipe) >> 1; | ||
621 | 623 | ||
622 | /* DW1 */ | 624 | /* DW1 */ |
623 | ptd->dw1 |= PTD_DEVICE_ADDR(usb_pipedevice(urb->pipe)); | 625 | ptd->dw1 = usb_pipeendpoint(qtd->urb->pipe) >> 1; |
626 | ptd->dw1 |= PTD_DEVICE_ADDR(usb_pipedevice(qtd->urb->pipe)); | ||
624 | 627 | ||
625 | pid_code = qtd->packet_type; | 628 | pid_code = qtd->packet_type; |
626 | ptd->dw1 |= PTD_PID_TOKEN(pid_code); | 629 | ptd->dw1 |= PTD_PID_TOKEN(pid_code); |
627 | 630 | ||
628 | if (usb_pipebulk(urb->pipe)) | 631 | if (usb_pipebulk(qtd->urb->pipe)) |
629 | ptd->dw1 |= PTD_TRANS_BULK; | 632 | ptd->dw1 |= PTD_TRANS_BULK; |
630 | else if (usb_pipeint(urb->pipe)) | 633 | else if (usb_pipeint(qtd->urb->pipe)) |
631 | ptd->dw1 |= PTD_TRANS_INT; | 634 | ptd->dw1 |= PTD_TRANS_INT; |
632 | 635 | ||
633 | if (urb->dev->speed != USB_SPEED_HIGH) { | 636 | if (qtd->urb->dev->speed != USB_SPEED_HIGH) { |
634 | /* split transaction */ | 637 | /* split transaction */ |
635 | 638 | ||
636 | ptd->dw1 |= PTD_TRANS_SPLIT; | 639 | ptd->dw1 |= PTD_TRANS_SPLIT; |
637 | if (urb->dev->speed == USB_SPEED_LOW) | 640 | if (qtd->urb->dev->speed == USB_SPEED_LOW) |
638 | ptd->dw1 |= PTD_SE_USB_LOSPEED; | 641 | ptd->dw1 |= PTD_SE_USB_LOSPEED; |
639 | 642 | ||
640 | ptd->dw1 |= PTD_PORT_NUM(urb->dev->ttport); | 643 | ptd->dw1 |= PTD_PORT_NUM(qtd->urb->dev->ttport); |
641 | ptd->dw1 |= PTD_HUB_NUM(urb->dev->tt->hub->devnum); | 644 | ptd->dw1 |= PTD_HUB_NUM(qtd->urb->dev->tt->hub->devnum); |
642 | 645 | ||
643 | /* SE bit for Split INT transfers */ | 646 | /* SE bit for Split INT transfers */ |
644 | if (usb_pipeint(urb->pipe) && | 647 | if (usb_pipeint(qtd->urb->pipe) && |
645 | (urb->dev->speed == USB_SPEED_LOW)) | 648 | (qtd->urb->dev->speed == USB_SPEED_LOW)) |
646 | ptd->dw1 |= 2 << 16; | 649 | ptd->dw1 |= 2 << 16; |
647 | 650 | ||
648 | ptd->dw3 = 0; | 651 | ptd->dw3 = 0; |
@@ -650,19 +653,20 @@ static void transform_into_atl(struct isp1760_hcd *priv, struct isp1760_qh *qh, | |||
650 | nak = 0; | 653 | nak = 0; |
651 | } else { | 654 | } else { |
652 | ptd->dw0 |= PTD_MULTI(multi); | 655 | ptd->dw0 |= PTD_MULTI(multi); |
653 | if (usb_pipecontrol(urb->pipe) || usb_pipebulk(urb->pipe)) | 656 | if (usb_pipecontrol(qtd->urb->pipe) || |
657 | usb_pipebulk(qtd->urb->pipe)) | ||
654 | ptd->dw3 = qh->ping; | 658 | ptd->dw3 = qh->ping; |
655 | else | 659 | else |
656 | ptd->dw3 = 0; | 660 | ptd->dw3 = 0; |
657 | } | 661 | } |
658 | /* DW2 */ | 662 | /* DW2 */ |
659 | ptd->dw2 = 0; | 663 | ptd->dw2 = 0; |
660 | ptd->dw2 |= PTD_DATA_START_ADDR(base_to_chip(payload)); | 664 | ptd->dw2 |= PTD_DATA_START_ADDR(base_to_chip(qtd->payload_addr)); |
661 | ptd->dw2 |= PTD_RL_CNT(rl); | 665 | ptd->dw2 |= PTD_RL_CNT(rl); |
662 | ptd->dw3 |= PTD_NAC_CNT(nak); | 666 | ptd->dw3 |= PTD_NAC_CNT(nak); |
663 | 667 | ||
664 | /* DW3 */ | 668 | /* DW3 */ |
665 | if (usb_pipecontrol(urb->pipe)) | 669 | if (usb_pipecontrol(qtd->urb->pipe)) |
666 | ptd->dw3 |= PTD_DATA_TOGGLE(qtd->toggle); | 670 | ptd->dw3 |= PTD_DATA_TOGGLE(qtd->toggle); |
667 | else | 671 | else |
668 | ptd->dw3 |= qh->toggle; | 672 | ptd->dw3 |= qh->toggle; |
@@ -674,8 +678,7 @@ static void transform_into_atl(struct isp1760_hcd *priv, struct isp1760_qh *qh, | |||
674 | } | 678 | } |
675 | 679 | ||
676 | static void transform_add_int(struct isp1760_hcd *priv, struct isp1760_qh *qh, | 680 | static void transform_add_int(struct isp1760_hcd *priv, struct isp1760_qh *qh, |
677 | struct isp1760_qtd *qtd, struct urb *urb, | 681 | struct isp1760_qtd *qtd, struct ptd *ptd) |
678 | u32 payload, struct ptd *ptd) | ||
679 | { | 682 | { |
680 | u32 maxpacket; | 683 | u32 maxpacket; |
681 | u32 multi; | 684 | u32 multi; |
@@ -684,14 +687,15 @@ static void transform_add_int(struct isp1760_hcd *priv, struct isp1760_qh *qh, | |||
684 | u32 usofmask, usof; | 687 | u32 usofmask, usof; |
685 | u32 period; | 688 | u32 period; |
686 | 689 | ||
687 | maxpacket = usb_maxpacket(urb->dev, urb->pipe, usb_pipeout(urb->pipe)); | 690 | maxpacket = usb_maxpacket(qtd->urb->dev, qtd->urb->pipe, |
691 | usb_pipeout(qtd->urb->pipe)); | ||
688 | multi = 1 + ((maxpacket >> 11) & 0x3); | 692 | multi = 1 + ((maxpacket >> 11) & 0x3); |
689 | maxpacket &= 0x7ff; | 693 | maxpacket &= 0x7ff; |
690 | /* length of the data per uframe */ | 694 | /* length of the data per uframe */ |
691 | maxpacket = multi * maxpacket; | 695 | maxpacket = multi * maxpacket; |
692 | 696 | ||
693 | numberofusofs = urb->transfer_buffer_length / maxpacket; | 697 | numberofusofs = qtd->urb->transfer_buffer_length / maxpacket; |
694 | if (urb->transfer_buffer_length % maxpacket) | 698 | if (qtd->urb->transfer_buffer_length % maxpacket) |
695 | numberofusofs += 1; | 699 | numberofusofs += 1; |
696 | 700 | ||
697 | usofmask = 1; | 701 | usofmask = 1; |
@@ -701,7 +705,7 @@ static void transform_add_int(struct isp1760_hcd *priv, struct isp1760_qh *qh, | |||
701 | usofmask <<= 1; | 705 | usofmask <<= 1; |
702 | } | 706 | } |
703 | 707 | ||
704 | if (urb->dev->speed != USB_SPEED_HIGH) { | 708 | if (qtd->urb->dev->speed != USB_SPEED_HIGH) { |
705 | /* split */ | 709 | /* split */ |
706 | ptd->dw5 = 0x1c; | 710 | ptd->dw5 = 0x1c; |
707 | 711 | ||
@@ -735,11 +739,10 @@ static void transform_add_int(struct isp1760_hcd *priv, struct isp1760_qh *qh, | |||
735 | } | 739 | } |
736 | 740 | ||
737 | static void transform_into_int(struct isp1760_hcd *priv, struct isp1760_qh *qh, | 741 | static void transform_into_int(struct isp1760_hcd *priv, struct isp1760_qh *qh, |
738 | struct isp1760_qtd *qtd, struct urb *urb, | 742 | struct isp1760_qtd *qtd, struct ptd *ptd) |
739 | u32 payload, struct ptd *ptd) | ||
740 | { | 743 | { |
741 | transform_into_atl(priv, qh, qtd, urb, payload, ptd); | 744 | transform_into_atl(priv, qh, qtd, ptd); |
742 | transform_add_int(priv, qh, qtd, urb, payload, ptd); | 745 | transform_add_int(priv, qh, qtd, ptd); |
743 | } | 746 | } |
744 | 747 | ||
745 | static int qtd_fill(struct isp1760_qtd *qtd, void *databuffer, size_t len, | 748 | static int qtd_fill(struct isp1760_qtd *qtd, void *databuffer, size_t len, |
@@ -751,8 +754,8 @@ static int qtd_fill(struct isp1760_qtd *qtd, void *databuffer, size_t len, | |||
751 | qtd->packet_type = GET_QTD_TOKEN_TYPE(token); | 754 | qtd->packet_type = GET_QTD_TOKEN_TYPE(token); |
752 | qtd->toggle = GET_DATA_TOGGLE(token); | 755 | qtd->toggle = GET_DATA_TOGGLE(token); |
753 | 756 | ||
754 | if (len > HC_ATL_PL_SIZE) | 757 | if (len > MAX_PAYLOAD_SIZE) |
755 | count = HC_ATL_PL_SIZE; | 758 | count = MAX_PAYLOAD_SIZE; |
756 | else | 759 | else |
757 | count = len; | 760 | count = len; |
758 | 761 | ||
@@ -804,60 +807,56 @@ static void check_int_err_status(u32 dw4) | |||
804 | } | 807 | } |
805 | } | 808 | } |
806 | 809 | ||
807 | static void enqueue_one_qtd(struct isp1760_qtd *qtd, struct isp1760_hcd *priv, | 810 | static void enqueue_one_qtd(struct isp1760_qtd *qtd, struct isp1760_hcd *priv) |
808 | u32 payload) | ||
809 | { | 811 | { |
810 | u32 token; | ||
811 | struct usb_hcd *hcd = priv_to_hcd(priv); | 812 | struct usb_hcd *hcd = priv_to_hcd(priv); |
812 | 813 | ||
813 | token = qtd->packet_type; | 814 | if (qtd->length && (qtd->length <= MAX_PAYLOAD_SIZE)) { |
814 | 815 | switch (qtd->packet_type) { | |
815 | if (qtd->length && (qtd->length <= HC_ATL_PL_SIZE)) { | ||
816 | switch (token) { | ||
817 | case IN_PID: | 816 | case IN_PID: |
818 | break; | 817 | break; |
819 | case OUT_PID: | 818 | case OUT_PID: |
820 | case SETUP_PID: | 819 | case SETUP_PID: |
821 | mem_writes8(hcd->regs, payload, qtd->data_buffer, | 820 | mem_writes8(hcd->regs, qtd->payload_addr, |
822 | qtd->length); | 821 | qtd->data_buffer, qtd->length); |
823 | } | 822 | } |
824 | } | 823 | } |
825 | } | 824 | } |
826 | 825 | ||
827 | static void enqueue_one_atl_qtd(u32 payload, | 826 | static void enqueue_one_atl_qtd(struct isp1760_hcd *priv, |
828 | struct isp1760_hcd *priv, struct isp1760_qh *qh, | 827 | struct isp1760_qh *qh, u32 slot, |
829 | struct urb *urb, u32 slot, struct isp1760_qtd *qtd) | 828 | struct isp1760_qtd *qtd) |
830 | { | 829 | { |
831 | struct ptd ptd; | 830 | struct ptd ptd; |
832 | struct usb_hcd *hcd = priv_to_hcd(priv); | 831 | struct usb_hcd *hcd = priv_to_hcd(priv); |
833 | 832 | ||
834 | transform_into_atl(priv, qh, qtd, urb, payload, &ptd); | 833 | alloc_mem(priv, qtd); |
834 | transform_into_atl(priv, qh, qtd, &ptd); | ||
835 | ptd_write(hcd->regs, ATL_PTD_OFFSET, slot, &ptd); | 835 | ptd_write(hcd->regs, ATL_PTD_OFFSET, slot, &ptd); |
836 | enqueue_one_qtd(qtd, priv, payload); | 836 | enqueue_one_qtd(qtd, priv); |
837 | 837 | ||
838 | priv->atl_ints[slot].qh = qh; | 838 | priv->atl_ints[slot].qh = qh; |
839 | priv->atl_ints[slot].qtd = qtd; | 839 | priv->atl_ints[slot].qtd = qtd; |
840 | priv->atl_ints[slot].data_buffer = qtd->data_buffer; | 840 | priv->atl_ints[slot].data_buffer = qtd->data_buffer; |
841 | priv->atl_ints[slot].payload = payload; | ||
842 | qtd->status |= URB_ENQUEUED; | 841 | qtd->status |= URB_ENQUEUED; |
843 | qtd->status |= slot << 16; | 842 | qtd->status |= slot << 16; |
844 | } | 843 | } |
845 | 844 | ||
846 | static void enqueue_one_int_qtd(u32 payload, | 845 | static void enqueue_one_int_qtd(struct isp1760_hcd *priv, |
847 | struct isp1760_hcd *priv, struct isp1760_qh *qh, | 846 | struct isp1760_qh *qh, u32 slot, |
848 | struct urb *urb, u32 slot, struct isp1760_qtd *qtd) | 847 | struct isp1760_qtd *qtd) |
849 | { | 848 | { |
850 | struct ptd ptd; | 849 | struct ptd ptd; |
851 | struct usb_hcd *hcd = priv_to_hcd(priv); | 850 | struct usb_hcd *hcd = priv_to_hcd(priv); |
852 | 851 | ||
853 | transform_into_int(priv, qh, qtd, urb, payload, &ptd); | 852 | alloc_mem(priv, qtd); |
853 | transform_into_int(priv, qh, qtd, &ptd); | ||
854 | ptd_write(hcd->regs, INT_PTD_OFFSET, slot, &ptd); | 854 | ptd_write(hcd->regs, INT_PTD_OFFSET, slot, &ptd); |
855 | enqueue_one_qtd(qtd, priv, payload); | 855 | enqueue_one_qtd(qtd, priv); |
856 | 856 | ||
857 | priv->int_ints[slot].qh = qh; | 857 | priv->int_ints[slot].qh = qh; |
858 | priv->int_ints[slot].qtd = qtd; | 858 | priv->int_ints[slot].qtd = qtd; |
859 | priv->int_ints[slot].data_buffer = qtd->data_buffer; | 859 | priv->int_ints[slot].data_buffer = qtd->data_buffer; |
860 | priv->int_ints[slot].payload = payload; | ||
861 | qtd->status |= URB_ENQUEUED; | 860 | qtd->status |= URB_ENQUEUED; |
862 | qtd->status |= slot << 16; | 861 | qtd->status |= slot << 16; |
863 | } | 862 | } |
@@ -869,7 +868,6 @@ static void enqueue_an_ATL_packet(struct usb_hcd *hcd, struct isp1760_qh *qh, | |||
869 | u32 skip_map, or_map; | 868 | u32 skip_map, or_map; |
870 | u32 queue_entry; | 869 | u32 queue_entry; |
871 | u32 slot; | 870 | u32 slot; |
872 | u32 payload; | ||
873 | u32 buffstatus; | 871 | u32 buffstatus; |
874 | 872 | ||
875 | /* | 873 | /* |
@@ -886,9 +884,7 @@ static void enqueue_an_ATL_packet(struct usb_hcd *hcd, struct isp1760_qh *qh, | |||
886 | slot = __ffs(skip_map); | 884 | slot = __ffs(skip_map); |
887 | queue_entry = 1 << slot; | 885 | queue_entry = 1 << slot; |
888 | 886 | ||
889 | payload = alloc_mem(priv, qtd->length); | 887 | enqueue_one_atl_qtd(priv, qh, slot, qtd); |
890 | |||
891 | enqueue_one_atl_qtd(payload, priv, qh, qtd->urb, slot, qtd); | ||
892 | 888 | ||
893 | or_map = reg_read32(hcd->regs, HC_ATL_IRQ_MASK_OR_REG); | 889 | or_map = reg_read32(hcd->regs, HC_ATL_IRQ_MASK_OR_REG); |
894 | or_map |= queue_entry; | 890 | or_map |= queue_entry; |
@@ -914,7 +910,6 @@ static void enqueue_an_INT_packet(struct usb_hcd *hcd, struct isp1760_qh *qh, | |||
914 | u32 skip_map, or_map; | 910 | u32 skip_map, or_map; |
915 | u32 queue_entry; | 911 | u32 queue_entry; |
916 | u32 slot; | 912 | u32 slot; |
917 | u32 payload; | ||
918 | u32 buffstatus; | 913 | u32 buffstatus; |
919 | 914 | ||
920 | /* | 915 | /* |
@@ -931,9 +926,7 @@ static void enqueue_an_INT_packet(struct usb_hcd *hcd, struct isp1760_qh *qh, | |||
931 | slot = __ffs(skip_map); | 926 | slot = __ffs(skip_map); |
932 | queue_entry = 1 << slot; | 927 | queue_entry = 1 << slot; |
933 | 928 | ||
934 | payload = alloc_mem(priv, qtd->length); | 929 | enqueue_one_int_qtd(priv, qh, slot, qtd); |
935 | |||
936 | enqueue_one_int_qtd(payload, priv, qh, qtd->urb, slot, qtd); | ||
937 | 930 | ||
938 | or_map = reg_read32(hcd->regs, HC_INT_IRQ_MASK_OR_REG); | 931 | or_map = reg_read32(hcd->regs, HC_INT_IRQ_MASK_OR_REG); |
939 | or_map |= queue_entry; | 932 | or_map |= queue_entry; |
@@ -974,6 +967,7 @@ __acquires(priv->lock) | |||
974 | 967 | ||
975 | static void isp1760_qtd_free(struct isp1760_qtd *qtd) | 968 | static void isp1760_qtd_free(struct isp1760_qtd *qtd) |
976 | { | 969 | { |
970 | BUG_ON(qtd->payload_addr); | ||
977 | kmem_cache_free(qtd_cachep, qtd); | 971 | kmem_cache_free(qtd_cachep, qtd); |
978 | } | 972 | } |
979 | 973 | ||
@@ -1029,7 +1023,6 @@ static void do_atl_int(struct usb_hcd *hcd) | |||
1029 | struct ptd ptd; | 1023 | struct ptd ptd; |
1030 | struct urb *urb = NULL; | 1024 | struct urb *urb = NULL; |
1031 | u32 queue_entry; | 1025 | u32 queue_entry; |
1032 | u32 payload; | ||
1033 | u32 length; | 1026 | u32 length; |
1034 | u32 or_map; | 1027 | u32 or_map; |
1035 | u32 status = -EINVAL; | 1028 | u32 status = -EINVAL; |
@@ -1057,7 +1050,6 @@ static void do_atl_int(struct usb_hcd *hcd) | |||
1057 | qtd = priv->atl_ints[queue_entry].qtd; | 1050 | qtd = priv->atl_ints[queue_entry].qtd; |
1058 | urb = qtd->urb; | 1051 | urb = qtd->urb; |
1059 | qh = priv->atl_ints[queue_entry].qh; | 1052 | qh = priv->atl_ints[queue_entry].qh; |
1060 | payload = priv->atl_ints[queue_entry].payload; | ||
1061 | 1053 | ||
1062 | if (!qh) { | 1054 | if (!qh) { |
1063 | printk(KERN_ERR "qh is 0\n"); | 1055 | printk(KERN_ERR "qh is 0\n"); |
@@ -1154,7 +1146,7 @@ static void do_atl_int(struct usb_hcd *hcd) | |||
1154 | if (length) { | 1146 | if (length) { |
1155 | switch (DW1_GET_PID(ptd.dw1)) { | 1147 | switch (DW1_GET_PID(ptd.dw1)) { |
1156 | case IN_PID: | 1148 | case IN_PID: |
1157 | mem_reads8(hcd->regs, payload, | 1149 | mem_reads8(hcd->regs, qtd->payload_addr, |
1158 | priv->atl_ints[queue_entry].data_buffer, | 1150 | priv->atl_ints[queue_entry].data_buffer, |
1159 | length); | 1151 | length); |
1160 | 1152 | ||
@@ -1171,7 +1163,7 @@ static void do_atl_int(struct usb_hcd *hcd) | |||
1171 | priv->atl_ints[queue_entry].qtd = NULL; | 1163 | priv->atl_ints[queue_entry].qtd = NULL; |
1172 | priv->atl_ints[queue_entry].qh = NULL; | 1164 | priv->atl_ints[queue_entry].qh = NULL; |
1173 | 1165 | ||
1174 | free_mem(priv, payload); | 1166 | free_mem(priv, qtd); |
1175 | 1167 | ||
1176 | reg_write32(hcd->regs, HC_ATL_PTD_SKIPMAP_REG, skip_map); | 1168 | reg_write32(hcd->regs, HC_ATL_PTD_SKIPMAP_REG, skip_map); |
1177 | 1169 | ||
@@ -1230,7 +1222,6 @@ static void do_intl_int(struct usb_hcd *hcd) | |||
1230 | u32 done_map, skip_map; | 1222 | u32 done_map, skip_map; |
1231 | struct ptd ptd; | 1223 | struct ptd ptd; |
1232 | struct urb *urb = NULL; | 1224 | struct urb *urb = NULL; |
1233 | u32 payload; | ||
1234 | u32 length; | 1225 | u32 length; |
1235 | u32 or_map; | 1226 | u32 or_map; |
1236 | int error; | 1227 | int error; |
@@ -1253,7 +1244,6 @@ static void do_intl_int(struct usb_hcd *hcd) | |||
1253 | qtd = priv->int_ints[queue_entry].qtd; | 1244 | qtd = priv->int_ints[queue_entry].qtd; |
1254 | urb = qtd->urb; | 1245 | urb = qtd->urb; |
1255 | qh = priv->int_ints[queue_entry].qh; | 1246 | qh = priv->int_ints[queue_entry].qh; |
1256 | payload = priv->int_ints[queue_entry].payload; | ||
1257 | 1247 | ||
1258 | if (!qh) { | 1248 | if (!qh) { |
1259 | printk(KERN_ERR "(INT) qh is 0\n"); | 1249 | printk(KERN_ERR "(INT) qh is 0\n"); |
@@ -1292,7 +1282,7 @@ static void do_intl_int(struct usb_hcd *hcd) | |||
1292 | if (length) { | 1282 | if (length) { |
1293 | switch (DW1_GET_PID(ptd.dw1)) { | 1283 | switch (DW1_GET_PID(ptd.dw1)) { |
1294 | case IN_PID: | 1284 | case IN_PID: |
1295 | mem_reads8(hcd->regs, payload, | 1285 | mem_reads8(hcd->regs, qtd->payload_addr, |
1296 | priv->int_ints[queue_entry].data_buffer, | 1286 | priv->int_ints[queue_entry].data_buffer, |
1297 | length); | 1287 | length); |
1298 | case OUT_PID: | 1288 | case OUT_PID: |
@@ -1309,7 +1299,7 @@ static void do_intl_int(struct usb_hcd *hcd) | |||
1309 | priv->int_ints[queue_entry].qh = NULL; | 1299 | priv->int_ints[queue_entry].qh = NULL; |
1310 | 1300 | ||
1311 | reg_write32(hcd->regs, HC_INT_PTD_SKIPMAP_REG, skip_map); | 1301 | reg_write32(hcd->regs, HC_INT_PTD_SKIPMAP_REG, skip_map); |
1312 | free_mem(priv, payload); | 1302 | free_mem(priv, qtd); |
1313 | 1303 | ||
1314 | if (urb->status == -EPIPE) { | 1304 | if (urb->status == -EPIPE) { |
1315 | /* HALT received */ | 1305 | /* HALT received */ |
@@ -1704,14 +1694,13 @@ static int isp1760_urb_dequeue(struct usb_hcd *hcd, struct urb *urb, | |||
1704 | 1694 | ||
1705 | qtd = ints->qtd; | 1695 | qtd = ints->qtd; |
1706 | qh = ints[i].qh; | 1696 | qh = ints[i].qh; |
1707 | qtd = clean_up_qtdlist(qtd, qh); | ||
1708 | 1697 | ||
1709 | free_mem(priv, ints->payload); | 1698 | free_mem(priv, qtd); |
1699 | qtd = clean_up_qtdlist(qtd, qh); | ||
1710 | 1700 | ||
1711 | ints->qh = NULL; | 1701 | ints->qh = NULL; |
1712 | ints->qtd = NULL; | 1702 | ints->qtd = NULL; |
1713 | ints->data_buffer = NULL; | 1703 | ints->data_buffer = NULL; |
1714 | ints->payload = 0; | ||
1715 | 1704 | ||
1716 | isp1760_urb_done(priv, urb, status); | 1705 | isp1760_urb_done(priv, urb, status); |
1717 | if (qtd) | 1706 | if (qtd) |
diff --git a/drivers/usb/host/isp1760-hcd.h b/drivers/usb/host/isp1760-hcd.h index a0599183b28b..587adbaa111a 100644 --- a/drivers/usb/host/isp1760-hcd.h +++ b/drivers/usb/host/isp1760-hcd.h | |||
@@ -108,7 +108,6 @@ struct ptd { | |||
108 | 108 | ||
109 | struct inter_packet_info { | 109 | struct inter_packet_info { |
110 | void *data_buffer; | 110 | void *data_buffer; |
111 | u32 payload; | ||
112 | #define PTD_FIRE_NEXT (1 << 0) | 111 | #define PTD_FIRE_NEXT (1 << 0) |
113 | #define PTD_URB_FINISHED (1 << 1) | 112 | #define PTD_URB_FINISHED (1 << 1) |
114 | struct isp1760_qh *qh; | 113 | struct isp1760_qh *qh; |
@@ -164,10 +163,8 @@ struct memory_chunk { | |||
164 | #define BLOCK_2_SIZE 1024 | 163 | #define BLOCK_2_SIZE 1024 |
165 | #define BLOCK_3_SIZE 8192 | 164 | #define BLOCK_3_SIZE 8192 |
166 | #define BLOCKS (BLOCK_1_NUM + BLOCK_2_NUM + BLOCK_3_NUM) | 165 | #define BLOCKS (BLOCK_1_NUM + BLOCK_2_NUM + BLOCK_3_NUM) |
167 | #define PAYLOAD_SIZE 0xf000 | 166 | #define MAX_PAYLOAD_SIZE BLOCK_3_SIZE |
168 | 167 | #define PAYLOAD_AREA_SIZE 0xf000 | |
169 | /* I saw if some reloads if the pointer was negative */ | ||
170 | #define ISP1760_NULL_POINTER (0x400) | ||
171 | 168 | ||
172 | /* ATL */ | 169 | /* ATL */ |
173 | /* DW0 */ | 170 | /* DW0 */ |
@@ -221,6 +218,4 @@ struct memory_chunk { | |||
221 | #define NAK_COUNTER (0) | 218 | #define NAK_COUNTER (0) |
222 | #define ERR_COUNTER (2) | 219 | #define ERR_COUNTER (2) |
223 | 220 | ||
224 | #define HC_ATL_PL_SIZE (8192) | ||
225 | |||
226 | #endif | 221 | #endif |