Lines Matching refs:d
176 static void dma_trm_reset(struct dma_trm_ctx *d);
178 static int alloc_dma_rcv_ctx(struct ti_ohci *ohci, struct dma_rcv_ctx *d,
181 static void free_dma_rcv_ctx(struct dma_rcv_ctx *d);
183 static int alloc_dma_trm_ctx(struct ti_ohci *ohci, struct dma_trm_ctx *d,
400 static void initialize_dma_rcv_ctx(struct dma_rcv_ctx *d, int generate_irq) in initialize_dma_rcv_ctx() argument
402 struct ti_ohci *ohci = (struct ti_ohci*)(d->ohci); in initialize_dma_rcv_ctx()
405 ohci1394_stop_context(ohci, d->ctrlClear, NULL); in initialize_dma_rcv_ctx()
407 for (i=0; i<d->num_desc; i++) { in initialize_dma_rcv_ctx()
414 d->prg_cpu[i]->control = cpu_to_le32(c | d->buf_size); in initialize_dma_rcv_ctx()
417 if (i + 1 < d->num_desc) { in initialize_dma_rcv_ctx()
418 d->prg_cpu[i]->branchAddress = in initialize_dma_rcv_ctx()
419 cpu_to_le32((d->prg_bus[i+1] & 0xfffffff0) | 0x1); in initialize_dma_rcv_ctx()
421 d->prg_cpu[i]->branchAddress = in initialize_dma_rcv_ctx()
422 cpu_to_le32((d->prg_bus[0] & 0xfffffff0)); in initialize_dma_rcv_ctx()
425 d->prg_cpu[i]->address = cpu_to_le32(d->buf_bus[i]); in initialize_dma_rcv_ctx()
426 d->prg_cpu[i]->status = cpu_to_le32(d->buf_size); in initialize_dma_rcv_ctx()
429 d->buf_ind = 0; in initialize_dma_rcv_ctx()
430 d->buf_offset = 0; in initialize_dma_rcv_ctx()
432 if (d->type == DMA_CTX_ISO) { in initialize_dma_rcv_ctx()
434 reg_write(ohci, d->ctrlClear, 0xffffffff); in initialize_dma_rcv_ctx()
437 reg_write(ohci, d->ctrlSet, 0xd0000000); in initialize_dma_rcv_ctx()
440 reg_write(ohci, d->ctxtMatch, 0xf0000000); in initialize_dma_rcv_ctx()
447 reg_write(ohci, OHCI1394_IsoRecvIntMaskSet, 1 << d->ctx); in initialize_dma_rcv_ctx()
451 reg_write(ohci, d->cmdPtr, d->prg_bus[0] | 0x1); in initialize_dma_rcv_ctx()
454 reg_write(ohci, d->ctrlSet, 0x00008000); in initialize_dma_rcv_ctx()
456 DBGMSG(ohci->id, "Receive DMA ctx=%d initialized", d->ctx); in initialize_dma_rcv_ctx()
460 static void initialize_dma_trm_ctx(struct dma_trm_ctx *d) in initialize_dma_trm_ctx() argument
462 struct ti_ohci *ohci = (struct ti_ohci*)(d->ohci); in initialize_dma_trm_ctx()
465 ohci1394_stop_context(ohci, d->ctrlClear, NULL); in initialize_dma_trm_ctx()
467 d->prg_ind = 0; in initialize_dma_trm_ctx()
468 d->sent_ind = 0; in initialize_dma_trm_ctx()
469 d->free_prgs = d->num_desc; in initialize_dma_trm_ctx()
470 d->branchAddrPtr = NULL; in initialize_dma_trm_ctx()
471 INIT_LIST_HEAD(&d->fifo_list); in initialize_dma_trm_ctx()
472 INIT_LIST_HEAD(&d->pending_list); in initialize_dma_trm_ctx()
474 if (d->type == DMA_CTX_ISO) { in initialize_dma_trm_ctx()
476 reg_write(ohci, OHCI1394_IsoXmitIntMaskSet, 1 << d->ctx); in initialize_dma_trm_ctx()
479 DBGMSG(ohci->id, "Transmit DMA ctx=%d initialized", d->ctx); in initialize_dma_trm_ctx()
628 struct dma_trm_ctx *d, struct hpsb_packet *packet) in insert_packet() argument
631 int idx = d->prg_ind; in insert_packet()
638 d->prg_cpu[idx]->begin.address = 0; in insert_packet()
639 d->prg_cpu[idx]->begin.branchAddress = 0; in insert_packet()
641 if (d->type == DMA_CTX_ASYNC_RESP) { in insert_packet()
647 d->prg_cpu[idx]->begin.status = cpu_to_le32( in insert_packet()
652 cycleTimer, d->prg_cpu[idx]->begin.status); in insert_packet()
654 d->prg_cpu[idx]->begin.status = 0; in insert_packet()
659 d->prg_cpu[idx]->data[0] = cpu_to_le32(OHCI1394_TCODE_PHY<<4); in insert_packet()
660 d->prg_cpu[idx]->data[1] = cpu_to_le32(packet->header[0]); in insert_packet()
661 d->prg_cpu[idx]->data[2] = cpu_to_le32(packet->header[1]); in insert_packet()
663 d->prg_cpu[idx]->data[0] = packet->speed_code<<16 | in insert_packet()
668 d->prg_cpu[idx]->data[1] = packet->header[0] & 0xFFFF0000; in insert_packet()
671 d->prg_cpu[idx]->data[1] = in insert_packet()
674 d->prg_cpu[idx]->data[2] = packet->header[2]; in insert_packet()
675 d->prg_cpu[idx]->data[3] = packet->header[3]; in insert_packet()
677 packet_swab(d->prg_cpu[idx]->data, packet->tcode); in insert_packet()
682 d->prg_cpu[idx]->begin.control = in insert_packet()
686 d->prg_cpu[idx]->begin.control = in insert_packet()
690 d->prg_cpu[idx]->end.control = in insert_packet()
708 d->prg_cpu[idx]->end.address = cpu_to_le32( in insert_packet()
714 d->prg_cpu[idx]->end.branchAddress = 0; in insert_packet()
715 d->prg_cpu[idx]->end.status = 0; in insert_packet()
716 if (d->branchAddrPtr) in insert_packet()
717 *(d->branchAddrPtr) = in insert_packet()
718 cpu_to_le32(d->prg_bus[idx] | 0x3); in insert_packet()
719 d->branchAddrPtr = in insert_packet()
720 &(d->prg_cpu[idx]->end.branchAddress); in insert_packet()
723 d->prg_cpu[idx]->begin.control = in insert_packet()
730 d->prg_cpu[idx]->begin.control = in insert_packet()
737 if (d->branchAddrPtr) in insert_packet()
738 *(d->branchAddrPtr) = in insert_packet()
739 cpu_to_le32(d->prg_bus[idx] | 0x2); in insert_packet()
740 d->branchAddrPtr = in insert_packet()
741 &(d->prg_cpu[idx]->begin.branchAddress); in insert_packet()
745 d->prg_cpu[idx]->data[0] = packet->speed_code<<16 | in insert_packet()
747 d->prg_cpu[idx]->data[1] = packet->header[0] & 0xFFFF0000; in insert_packet()
748 packet_swab(d->prg_cpu[idx]->data, packet->tcode); in insert_packet()
750 d->prg_cpu[idx]->begin.control = in insert_packet()
753 d->prg_cpu[idx]->end.control = in insert_packet()
759 d->prg_cpu[idx]->end.address = cpu_to_le32( in insert_packet()
764 d->prg_cpu[idx]->end.branchAddress = 0; in insert_packet()
765 d->prg_cpu[idx]->end.status = 0; in insert_packet()
770 d->prg_cpu[idx]->data[0], d->prg_cpu[idx]->data[1], in insert_packet()
771 d->prg_cpu[idx]->begin.control, in insert_packet()
772 d->prg_cpu[idx]->begin.address, in insert_packet()
773 d->prg_cpu[idx]->begin.branchAddress, in insert_packet()
774 d->prg_cpu[idx]->begin.status, in insert_packet()
775 d->prg_cpu[idx]->data[0], in insert_packet()
776 d->prg_cpu[idx]->data[1], in insert_packet()
777 d->prg_cpu[idx]->data[2], in insert_packet()
778 d->prg_cpu[idx]->data[3], in insert_packet()
779 d->prg_cpu[idx]->end.control, in insert_packet()
780 d->prg_cpu[idx]->end.address, in insert_packet()
781 d->prg_cpu[idx]->end.branchAddress, in insert_packet()
782 d->prg_cpu[idx]->end.status); in insert_packet()
783 if (d->branchAddrPtr) in insert_packet()
784 *(d->branchAddrPtr) = cpu_to_le32(d->prg_bus[idx] | 0x3); in insert_packet()
785 d->branchAddrPtr = &(d->prg_cpu[idx]->end.branchAddress); in insert_packet()
787 d->free_prgs--; in insert_packet()
790 list_add_tail(&packet->driver_list, &d->fifo_list); in insert_packet()
791 d->prg_ind = (d->prg_ind+1)%d->num_desc; in insert_packet()
800 static int dma_trm_flush(struct ti_ohci *ohci, struct dma_trm_ctx *d) in dma_trm_flush() argument
805 if (list_empty(&d->pending_list) || d->free_prgs == 0) in dma_trm_flush()
808 p = driver_packet(d->pending_list.next); in dma_trm_flush()
809 idx = d->prg_ind; in dma_trm_flush()
813 while (d->free_prgs > 0 && !list_empty(&d->pending_list)) { in dma_trm_flush()
814 struct hpsb_packet *p = driver_packet(d->pending_list.next); in dma_trm_flush()
816 insert_packet(ohci, d, p); in dma_trm_flush()
819 if (d->free_prgs == 0) in dma_trm_flush()
820 DBGMSG(ohci->id, "Transmit DMA FIFO ctx=%d is full... waiting", d->ctx); in dma_trm_flush()
824 if (!(reg_read(ohci, d->ctrlSet) & 0x8000)) { in dma_trm_flush()
825 DBGMSG(ohci->id,"Starting transmit DMA ctx=%d",d->ctx); in dma_trm_flush()
826 reg_write(ohci, d->cmdPtr, d->prg_bus[idx]|z); in dma_trm_flush()
827 run_context(ohci, d->ctrlSet, NULL); in dma_trm_flush()
831 if (!(reg_read(ohci, d->ctrlSet) & 0x400)) { in dma_trm_flush()
832 DBGMSG(ohci->id,"Waking transmit DMA ctx=%d",d->ctx); in dma_trm_flush()
836 reg_write(ohci, d->ctrlSet, 0x1000); in dma_trm_flush()
845 struct dma_trm_ctx *d; in ohci_transmit() local
857 d = &ohci->at_req_context; in ohci_transmit()
883 d = &ohci->it_legacy_context; in ohci_transmit()
885 d = &ohci->at_resp_context; in ohci_transmit()
887 d = &ohci->at_req_context; in ohci_transmit()
889 spin_lock_irqsave(&d->lock,flags); in ohci_transmit()
891 list_add_tail(&packet->driver_list, &d->pending_list); in ohci_transmit()
893 dma_trm_flush(ohci, d); in ohci_transmit()
895 spin_unlock_irqrestore(&d->lock,flags); in ohci_transmit()
2177 static void dma_trm_reset(struct dma_trm_ctx *d) in dma_trm_reset() argument
2182 ohci1394_stop_context(d->ohci, d->ctrlClear, NULL); in dma_trm_reset()
2188 spin_lock_irqsave(&d->lock, flags); in dma_trm_reset()
2190 list_splice(&d->fifo_list, &packet_list); in dma_trm_reset()
2191 list_splice(&d->pending_list, &packet_list); in dma_trm_reset()
2192 INIT_LIST_HEAD(&d->fifo_list); in dma_trm_reset()
2193 INIT_LIST_HEAD(&d->pending_list); in dma_trm_reset()
2195 d->branchAddrPtr = NULL; in dma_trm_reset()
2196 d->sent_ind = d->prg_ind; in dma_trm_reset()
2197 d->free_prgs = d->num_desc; in dma_trm_reset()
2199 spin_unlock_irqrestore(&d->lock, flags); in dma_trm_reset()
2206 PRINT(KERN_INFO, d->ohci->id, in dma_trm_reset()
2207 "AT dma reset ctx=%d, aborting transmission", d->ctx); in dma_trm_reset()
2209 hpsb_packet_sent(d->ohci->host, p, ACKX_ABORTED); in dma_trm_reset()
2363 struct dma_trm_ctx *d = &ohci->at_req_context; in ohci_irq_handler() local
2365 "status=0x%08X", reg_read(ohci, d->ctrlSet)); in ohci_irq_handler()
2366 if (reg_read(ohci, d->ctrlSet) & 0x800) in ohci_irq_handler()
2367 ohci1394_stop_context(ohci, d->ctrlClear, in ohci_irq_handler()
2370 dma_trm_tasklet ((unsigned long)d); in ohci_irq_handler()
2374 struct dma_trm_ctx *d = &ohci->at_resp_context; in ohci_irq_handler() local
2376 "status=0x%08X", reg_read(ohci, d->ctrlSet)); in ohci_irq_handler()
2377 if (reg_read(ohci, d->ctrlSet) & 0x800) in ohci_irq_handler()
2378 ohci1394_stop_context(ohci, d->ctrlClear, in ohci_irq_handler()
2381 tasklet_schedule(&d->task); in ohci_irq_handler()
2385 struct dma_rcv_ctx *d = &ohci->ar_req_context; in ohci_irq_handler() local
2387 reg_read(ohci, d->ctrlSet)); in ohci_irq_handler()
2388 if (reg_read(ohci, d->ctrlSet) & 0x800) in ohci_irq_handler()
2389 ohci1394_stop_context(ohci, d->ctrlClear, "RQPkt"); in ohci_irq_handler()
2391 tasklet_schedule(&d->task); in ohci_irq_handler()
2395 struct dma_rcv_ctx *d = &ohci->ar_resp_context; in ohci_irq_handler() local
2397 reg_read(ohci, d->ctrlSet)); in ohci_irq_handler()
2398 if (reg_read(ohci, d->ctrlSet) & 0x800) in ohci_irq_handler()
2399 ohci1394_stop_context(ohci, d->ctrlClear, "RSPkt"); in ohci_irq_handler()
2401 tasklet_schedule(&d->task); in ohci_irq_handler()
2489 static void insert_dma_buffer(struct dma_rcv_ctx *d, int idx) in insert_dma_buffer() argument
2491 struct ti_ohci *ohci = (struct ti_ohci*)(d->ohci); in insert_dma_buffer()
2492 DBGMSG(ohci->id, "Inserting dma buf ctx=%d idx=%d", d->ctx, idx); in insert_dma_buffer()
2494 d->prg_cpu[idx]->status = cpu_to_le32(d->buf_size); in insert_dma_buffer()
2495 d->prg_cpu[idx]->branchAddress &= le32_to_cpu(0xfffffff0); in insert_dma_buffer()
2496 idx = (idx + d->num_desc - 1 ) % d->num_desc; in insert_dma_buffer()
2497 d->prg_cpu[idx]->branchAddress |= le32_to_cpu(0x00000001); in insert_dma_buffer()
2500 if (!(reg_read(ohci, d->ctrlSet) & 0x400)) { in insert_dma_buffer()
2503 d->ctx); in insert_dma_buffer()
2507 reg_write(ohci, d->ctrlSet, 0x1000); in insert_dma_buffer()
2520 static __inline__ int packet_length(struct dma_rcv_ctx *d, int idx, quadlet_t *buf_ptr, in packet_length() argument
2525 if (d->type == DMA_CTX_ASYNC_REQ || d->type == DMA_CTX_ASYNC_RESP) { in packet_length()
2528 if (offset + 12 >= d->buf_size) { in packet_length()
2529 length = (cond_le32_to_cpu(d->buf_cpu[(idx + 1) % d->num_desc] in packet_length()
2530 [3 - ((d->buf_size - offset) >> 2)], noswap) >> 16); in packet_length()
2536 } else if (d->type == DMA_CTX_ISO) { in packet_length()
2550 struct dma_rcv_ctx *d = (struct dma_rcv_ctx*)data; in dma_rcv_tasklet() local
2551 struct ti_ohci *ohci = (struct ti_ohci*)(d->ohci); in dma_rcv_tasklet()
2560 spin_lock_irqsave(&d->lock, flags); in dma_rcv_tasklet()
2562 idx = d->buf_ind; in dma_rcv_tasklet()
2563 offset = d->buf_offset; in dma_rcv_tasklet()
2564 buf_ptr = d->buf_cpu[idx] + offset/4; in dma_rcv_tasklet()
2566 rescount = le32_to_cpu(d->prg_cpu[idx]->status) & 0xffff; in dma_rcv_tasklet()
2567 bytes_left = d->buf_size - rescount - offset; in dma_rcv_tasklet()
2573 length = packet_length(d, idx, buf_ptr, offset, tcode, ohci->no_swap_incoming); in dma_rcv_tasklet()
2578 d->ctx, length); in dma_rcv_tasklet()
2579 ohci1394_stop_context(ohci, d->ctrlClear, msg); in dma_rcv_tasklet()
2580 spin_unlock_irqrestore(&d->lock, flags); in dma_rcv_tasklet()
2587 if ((offset + length) > d->buf_size) { in dma_rcv_tasklet()
2589 if (length > d->split_buf_size) { in dma_rcv_tasklet()
2590 ohci1394_stop_context(ohci, d->ctrlClear, in dma_rcv_tasklet()
2592 d->buf_ind = idx; in dma_rcv_tasklet()
2593 d->buf_offset = offset; in dma_rcv_tasklet()
2594 spin_unlock_irqrestore(&d->lock, flags); in dma_rcv_tasklet()
2598 if (le32_to_cpu(d->prg_cpu[(idx+1)%d->num_desc]->status) in dma_rcv_tasklet()
2599 == d->buf_size) { in dma_rcv_tasklet()
2605 d->buf_ind = idx; in dma_rcv_tasklet()
2606 d->buf_offset = offset; in dma_rcv_tasklet()
2607 spin_unlock_irqrestore(&d->lock, flags); in dma_rcv_tasklet()
2612 split_ptr = (char *)d->spb; in dma_rcv_tasklet()
2613 memcpy(split_ptr,buf_ptr,d->buf_size-offset); in dma_rcv_tasklet()
2614 split_left -= d->buf_size-offset; in dma_rcv_tasklet()
2615 split_ptr += d->buf_size-offset; in dma_rcv_tasklet()
2616 insert_dma_buffer(d, idx); in dma_rcv_tasklet()
2617 idx = (idx+1) % d->num_desc; in dma_rcv_tasklet()
2618 buf_ptr = d->buf_cpu[idx]; in dma_rcv_tasklet()
2621 while (split_left >= d->buf_size) { in dma_rcv_tasklet()
2622 memcpy(split_ptr,buf_ptr,d->buf_size); in dma_rcv_tasklet()
2623 split_ptr += d->buf_size; in dma_rcv_tasklet()
2624 split_left -= d->buf_size; in dma_rcv_tasklet()
2625 insert_dma_buffer(d, idx); in dma_rcv_tasklet()
2626 idx = (idx+1) % d->num_desc; in dma_rcv_tasklet()
2627 buf_ptr = d->buf_cpu[idx]; in dma_rcv_tasklet()
2637 memcpy(d->spb, buf_ptr, length); in dma_rcv_tasklet()
2640 if (offset==d->buf_size) { in dma_rcv_tasklet()
2641 insert_dma_buffer(d, idx); in dma_rcv_tasklet()
2642 idx = (idx+1) % d->num_desc; in dma_rcv_tasklet()
2643 buf_ptr = d->buf_cpu[idx]; in dma_rcv_tasklet()
2652 packet_swab(d->spb, tcode); in dma_rcv_tasklet()
2656 (d->spb[1]>>16)&0x3f, in dma_rcv_tasklet()
2657 (cond_le32_to_cpu(d->spb[length/4-1], ohci->no_swap_incoming)>>16)&0x1f, in dma_rcv_tasklet()
2658 (cond_le32_to_cpu(d->spb[length/4-1], ohci->no_swap_incoming)>>21)&0x3, in dma_rcv_tasklet()
2659 tcode, length, d->ctx, in dma_rcv_tasklet()
2660 (cond_le32_to_cpu(d->spb[length/4-1], ohci->no_swap_incoming)>>10)&0x3f); in dma_rcv_tasklet()
2662 ack = (((cond_le32_to_cpu(d->spb[length/4-1], ohci->no_swap_incoming)>>16)&0x1f) in dma_rcv_tasklet()
2665 hpsb_packet_received(ohci->host, d->spb, in dma_rcv_tasklet()
2671 d->ctx); in dma_rcv_tasklet()
2674 rescount = le32_to_cpu(d->prg_cpu[idx]->status) & 0xffff; in dma_rcv_tasklet()
2676 bytes_left = d->buf_size - rescount - offset; in dma_rcv_tasklet()
2680 d->buf_ind = idx; in dma_rcv_tasklet()
2681 d->buf_offset = offset; in dma_rcv_tasklet()
2683 spin_unlock_irqrestore(&d->lock, flags); in dma_rcv_tasklet()
2689 struct dma_trm_ctx *d = (struct dma_trm_ctx*)data; in dma_trm_tasklet() local
2690 struct ti_ohci *ohci = (struct ti_ohci*)(d->ohci); in dma_trm_tasklet()
2696 spin_lock_irqsave(&d->lock, flags); in dma_trm_tasklet()
2698 while (!list_empty(&d->fifo_list)) { in dma_trm_tasklet()
2699 packet = driver_packet(d->fifo_list.next); in dma_trm_tasklet()
2703 d->prg_cpu[d->sent_ind]->end.status) >> 16; in dma_trm_tasklet()
2706 d->prg_cpu[d->sent_ind]->begin.status) >> 16; in dma_trm_tasklet()
2714 if (((le32_to_cpu(d->prg_cpu[d->sent_ind]->data[0])>>4)&0xf) == 0xa) in dma_trm_tasklet()
2718 (le32_to_cpu(d->prg_cpu[d->sent_ind]->data[0])>>8)&0x3f, in dma_trm_tasklet()
2719 (le32_to_cpu(d->prg_cpu[d->sent_ind]->data[0])>>4)&0xf, in dma_trm_tasklet()
2721 le32_to_cpu(d->prg_cpu[d->sent_ind]->data[1])>>16, in dma_trm_tasklet()
2722 d->ctx); in dma_trm_tasklet()
2727 (le32_to_cpu(d->prg_cpu[d->sent_ind]->data[1]) in dma_trm_tasklet()
2729 (le32_to_cpu(d->prg_cpu[d->sent_ind]->data[0]) in dma_trm_tasklet()
2731 (le32_to_cpu(d->prg_cpu[d->sent_ind]->data[0]) in dma_trm_tasklet()
2734 le32_to_cpu(d->prg_cpu[d->sent_ind]->data[3]) in dma_trm_tasklet()
2736 d->ctx); in dma_trm_tasklet()
2741 (le32_to_cpu(d->prg_cpu[d->sent_ind]->data[1]) in dma_trm_tasklet()
2743 (le32_to_cpu(d->prg_cpu[d->sent_ind]->data[0]) in dma_trm_tasklet()
2745 (le32_to_cpu(d->prg_cpu[d->sent_ind]->data[0]) in dma_trm_tasklet()
2748 le32_to_cpu(d->prg_cpu[d->sent_ind]->data[3]), in dma_trm_tasklet()
2749 d->ctx); in dma_trm_tasklet()
2808 cpu_to_le32(d->prg_cpu[d->sent_ind]->end.address), in dma_trm_tasklet()
2813 d->sent_ind = (d->sent_ind+1)%d->num_desc; in dma_trm_tasklet()
2814 d->free_prgs++; in dma_trm_tasklet()
2817 dma_trm_flush(ohci, d); in dma_trm_tasklet()
2819 spin_unlock_irqrestore(&d->lock, flags); in dma_trm_tasklet()
2822 static void free_dma_rcv_ctx(struct dma_rcv_ctx *d) in free_dma_rcv_ctx() argument
2826 if (d->ohci == NULL) in free_dma_rcv_ctx()
2829 DBGMSG(d->ohci->id, "Freeing dma_rcv_ctx %d", d->ctx); in free_dma_rcv_ctx()
2831 if (d->ctrlClear) { in free_dma_rcv_ctx()
2832 ohci1394_stop_context(d->ohci, d->ctrlClear, NULL); in free_dma_rcv_ctx()
2834 if (d->type == DMA_CTX_ISO) { in free_dma_rcv_ctx()
2836 reg_write(d->ohci, OHCI1394_IsoRecvIntMaskClear, 1 << d->ctx); in free_dma_rcv_ctx()
2837 ohci1394_unregister_iso_tasklet(d->ohci, &d->ohci->ir_legacy_tasklet); in free_dma_rcv_ctx()
2839 tasklet_kill(&d->task); in free_dma_rcv_ctx()
2843 if (d->buf_cpu) { in free_dma_rcv_ctx()
2844 for (i=0; i<d->num_desc; i++) in free_dma_rcv_ctx()
2845 if (d->buf_cpu[i] && d->buf_bus[i]) { in free_dma_rcv_ctx()
2847 d->ohci->dev, d->buf_size, in free_dma_rcv_ctx()
2848 d->buf_cpu[i], d->buf_bus[i]); in free_dma_rcv_ctx()
2851 kfree(d->buf_cpu); in free_dma_rcv_ctx()
2852 kfree(d->buf_bus); in free_dma_rcv_ctx()
2854 if (d->prg_cpu) { in free_dma_rcv_ctx()
2855 for (i=0; i<d->num_desc; i++) in free_dma_rcv_ctx()
2856 if (d->prg_cpu[i] && d->prg_bus[i]) { in free_dma_rcv_ctx()
2857 pci_pool_free(d->prg_pool, d->prg_cpu[i], d->prg_bus[i]); in free_dma_rcv_ctx()
2860 pci_pool_destroy(d->prg_pool); in free_dma_rcv_ctx()
2862 kfree(d->prg_cpu); in free_dma_rcv_ctx()
2863 kfree(d->prg_bus); in free_dma_rcv_ctx()
2865 if (d->spb) kfree(d->spb); in free_dma_rcv_ctx()
2868 d->ohci = NULL; in free_dma_rcv_ctx()
2872 alloc_dma_rcv_ctx(struct ti_ohci *ohci, struct dma_rcv_ctx *d, in alloc_dma_rcv_ctx() argument
2878 d->ohci = ohci; in alloc_dma_rcv_ctx()
2879 d->type = type; in alloc_dma_rcv_ctx()
2880 d->ctx = ctx; in alloc_dma_rcv_ctx()
2882 d->num_desc = num_desc; in alloc_dma_rcv_ctx()
2883 d->buf_size = buf_size; in alloc_dma_rcv_ctx()
2884 d->split_buf_size = split_buf_size; in alloc_dma_rcv_ctx()
2886 d->ctrlSet = 0; in alloc_dma_rcv_ctx()
2887 d->ctrlClear = 0; in alloc_dma_rcv_ctx()
2888 d->cmdPtr = 0; in alloc_dma_rcv_ctx()
2890 d->buf_cpu = kmalloc(d->num_desc * sizeof(quadlet_t*), GFP_KERNEL); in alloc_dma_rcv_ctx()
2891 d->buf_bus = kmalloc(d->num_desc * sizeof(dma_addr_t), GFP_KERNEL); in alloc_dma_rcv_ctx()
2893 if (d->buf_cpu == NULL || d->buf_bus == NULL) { in alloc_dma_rcv_ctx()
2895 free_dma_rcv_ctx(d); in alloc_dma_rcv_ctx()
2898 memset(d->buf_cpu, 0, d->num_desc * sizeof(quadlet_t*)); in alloc_dma_rcv_ctx()
2899 memset(d->buf_bus, 0, d->num_desc * sizeof(dma_addr_t)); in alloc_dma_rcv_ctx()
2901 d->prg_cpu = kmalloc(d->num_desc * sizeof(struct dma_cmd*), in alloc_dma_rcv_ctx()
2903 d->prg_bus = kmalloc(d->num_desc * sizeof(dma_addr_t), GFP_KERNEL); in alloc_dma_rcv_ctx()
2905 if (d->prg_cpu == NULL || d->prg_bus == NULL) { in alloc_dma_rcv_ctx()
2907 free_dma_rcv_ctx(d); in alloc_dma_rcv_ctx()
2910 memset(d->prg_cpu, 0, d->num_desc * sizeof(struct dma_cmd*)); in alloc_dma_rcv_ctx()
2911 memset(d->prg_bus, 0, d->num_desc * sizeof(dma_addr_t)); in alloc_dma_rcv_ctx()
2913 d->spb = kmalloc(d->split_buf_size, GFP_KERNEL); in alloc_dma_rcv_ctx()
2915 if (d->spb == NULL) { in alloc_dma_rcv_ctx()
2917 free_dma_rcv_ctx(d); in alloc_dma_rcv_ctx()
2921 d->prg_pool = pci_pool_create("ohci1394 rcv prg", ohci->dev, in alloc_dma_rcv_ctx()
2925 for (i=0; i<d->num_desc; i++) { in alloc_dma_rcv_ctx()
2926 d->buf_cpu[i] = pci_alloc_consistent(ohci->dev, in alloc_dma_rcv_ctx()
2927 d->buf_size, in alloc_dma_rcv_ctx()
2928 d->buf_bus+i); in alloc_dma_rcv_ctx()
2931 if (d->buf_cpu[i] != NULL) { in alloc_dma_rcv_ctx()
2932 memset(d->buf_cpu[i], 0, d->buf_size); in alloc_dma_rcv_ctx()
2936 free_dma_rcv_ctx(d); in alloc_dma_rcv_ctx()
2940 d->prg_cpu[i] = pci_pool_alloc(d->prg_pool, SLAB_KERNEL, d->prg_bus+i); in alloc_dma_rcv_ctx()
2943 if (d->prg_cpu[i] != NULL) { in alloc_dma_rcv_ctx()
2944 memset(d->prg_cpu[i], 0, sizeof(struct dma_cmd)); in alloc_dma_rcv_ctx()
2948 free_dma_rcv_ctx(d); in alloc_dma_rcv_ctx()
2953 spin_lock_init(&d->lock); in alloc_dma_rcv_ctx()
2958 dma_rcv_tasklet, (unsigned long) d); in alloc_dma_rcv_ctx()
2962 free_dma_rcv_ctx(d); in alloc_dma_rcv_ctx()
2968 d->ctx = ohci->ir_legacy_tasklet.context; in alloc_dma_rcv_ctx()
2969 d->ctrlSet = OHCI1394_IsoRcvContextControlSet + 32*d->ctx; in alloc_dma_rcv_ctx()
2970 d->ctrlClear = OHCI1394_IsoRcvContextControlClear + 32*d->ctx; in alloc_dma_rcv_ctx()
2971 d->cmdPtr = OHCI1394_IsoRcvCommandPtr + 32*d->ctx; in alloc_dma_rcv_ctx()
2972 d->ctxtMatch = OHCI1394_IsoRcvContextMatch + 32*d->ctx; in alloc_dma_rcv_ctx()
2974 d->ctrlSet = context_base + OHCI1394_ContextControlSet; in alloc_dma_rcv_ctx()
2975 d->ctrlClear = context_base + OHCI1394_ContextControlClear; in alloc_dma_rcv_ctx()
2976 d->cmdPtr = context_base + OHCI1394_ContextCommandPtr; in alloc_dma_rcv_ctx()
2978 tasklet_init (&d->task, dma_rcv_tasklet, (unsigned long) d); in alloc_dma_rcv_ctx()
2984 static void free_dma_trm_ctx(struct dma_trm_ctx *d) in free_dma_trm_ctx() argument
2988 if (d->ohci == NULL) in free_dma_trm_ctx()
2991 DBGMSG(d->ohci->id, "Freeing dma_trm_ctx %d", d->ctx); in free_dma_trm_ctx()
2993 if (d->ctrlClear) { in free_dma_trm_ctx()
2994 ohci1394_stop_context(d->ohci, d->ctrlClear, NULL); in free_dma_trm_ctx()
2996 if (d->type == DMA_CTX_ISO) { in free_dma_trm_ctx()
2998 reg_write(d->ohci, OHCI1394_IsoXmitIntMaskClear, 1 << d->ctx); in free_dma_trm_ctx()
2999 ohci1394_unregister_iso_tasklet(d->ohci, in free_dma_trm_ctx()
3000 &d->ohci->it_legacy_tasklet); in free_dma_trm_ctx()
3002 tasklet_kill(&d->task); in free_dma_trm_ctx()
3006 if (d->prg_cpu) { in free_dma_trm_ctx()
3007 for (i=0; i<d->num_desc; i++) in free_dma_trm_ctx()
3008 if (d->prg_cpu[i] && d->prg_bus[i]) { in free_dma_trm_ctx()
3009 pci_pool_free(d->prg_pool, d->prg_cpu[i], d->prg_bus[i]); in free_dma_trm_ctx()
3012 pci_pool_destroy(d->prg_pool); in free_dma_trm_ctx()
3014 kfree(d->prg_cpu); in free_dma_trm_ctx()
3015 kfree(d->prg_bus); in free_dma_trm_ctx()
3019 d->ohci = NULL; in free_dma_trm_ctx()
3023 alloc_dma_trm_ctx(struct ti_ohci *ohci, struct dma_trm_ctx *d, in alloc_dma_trm_ctx() argument
3029 d->ohci = ohci; in alloc_dma_trm_ctx()
3030 d->type = type; in alloc_dma_trm_ctx()
3031 d->ctx = ctx; in alloc_dma_trm_ctx()
3032 d->num_desc = num_desc; in alloc_dma_trm_ctx()
3033 d->ctrlSet = 0; in alloc_dma_trm_ctx()
3034 d->ctrlClear = 0; in alloc_dma_trm_ctx()
3035 d->cmdPtr = 0; in alloc_dma_trm_ctx()
3037 d->prg_cpu = kmalloc(d->num_desc * sizeof(struct at_dma_prg*), in alloc_dma_trm_ctx()
3039 d->prg_bus = kmalloc(d->num_desc * sizeof(dma_addr_t), GFP_KERNEL); in alloc_dma_trm_ctx()
3041 if (d->prg_cpu == NULL || d->prg_bus == NULL) { in alloc_dma_trm_ctx()
3043 free_dma_trm_ctx(d); in alloc_dma_trm_ctx()
3046 memset(d->prg_cpu, 0, d->num_desc * sizeof(struct at_dma_prg*)); in alloc_dma_trm_ctx()
3047 memset(d->prg_bus, 0, d->num_desc * sizeof(dma_addr_t)); in alloc_dma_trm_ctx()
3049 d->prg_pool = pci_pool_create("ohci1394 trm prg", ohci->dev, in alloc_dma_trm_ctx()
3053 for (i = 0; i < d->num_desc; i++) { in alloc_dma_trm_ctx()
3054 d->prg_cpu[i] = pci_pool_alloc(d->prg_pool, SLAB_KERNEL, d->prg_bus+i); in alloc_dma_trm_ctx()
3057 if (d->prg_cpu[i] != NULL) { in alloc_dma_trm_ctx()
3058 memset(d->prg_cpu[i], 0, sizeof(struct at_dma_prg)); in alloc_dma_trm_ctx()
3062 free_dma_trm_ctx(d); in alloc_dma_trm_ctx()
3067 spin_lock_init(&d->lock); in alloc_dma_trm_ctx()
3072 dma_trm_tasklet, (unsigned long) d); in alloc_dma_trm_ctx()
3076 free_dma_trm_ctx(d); in alloc_dma_trm_ctx()
3081 d->ctx = ohci->it_legacy_tasklet.context; in alloc_dma_trm_ctx()
3082 d->ctrlSet = OHCI1394_IsoXmitContextControlSet + 16 * d->ctx; in alloc_dma_trm_ctx()
3083 d->ctrlClear = OHCI1394_IsoXmitContextControlClear + 16 * d->ctx; in alloc_dma_trm_ctx()
3084 d->cmdPtr = OHCI1394_IsoXmitCommandPtr + 16 * d->ctx; in alloc_dma_trm_ctx()
3086 d->ctrlSet = context_base + OHCI1394_ContextControlSet; in alloc_dma_trm_ctx()
3087 d->ctrlClear = context_base + OHCI1394_ContextControlClear; in alloc_dma_trm_ctx()
3088 d->cmdPtr = context_base + OHCI1394_ContextCommandPtr; in alloc_dma_trm_ctx()
3089 tasklet_init (&d->task, dma_trm_tasklet, (unsigned long)d); in alloc_dma_trm_ctx()