Lines Matching full:usb

3  * Freescale QUICC Engine USB Host Controller Driver
22 #include <linux/usb.h>
23 #include <linux/usb/hcd.h>
28 static void recycle_frame(struct fhci_usb *usb, struct packet *pkt) in recycle_frame() argument
36 cq_put(&usb->ep0->empty_frame_Q, pkt); in recycle_frame()
40 void fhci_transaction_confirm(struct fhci_usb *usb, struct packet *pkt) in fhci_transaction_confirm() argument
48 td = fhci_remove_td_from_frame(usb->actual_frame); in fhci_transaction_confirm()
56 cq_put(&usb->ep0->dummy_packets_Q, pkt->data); in fhci_transaction_confirm()
59 recycle_frame(usb, pkt); in fhci_transaction_confirm()
68 td_next->start_frame = usb->actual_frame->frame_num; in fhci_transaction_confirm()
87 fhci_dbg(usb->fhci, "td err fu\n"); in fhci_transaction_confirm()
91 fhci_dbg(usb->fhci, "td err f!u\n"); in fhci_transaction_confirm()
94 fhci_dbg(usb->fhci, "td err !f\n"); in fhci_transaction_confirm()
102 fhci_vdbg(usb->fhci, "td nack\n"); in fhci_transaction_confirm()
118 fhci_move_td_from_ed_to_done_list(usb, ed); in fhci_transaction_confirm()
123 * This routine is called when disabling the USB port to flush all
126 void fhci_flush_all_transmissions(struct fhci_usb *usb) in fhci_flush_all_transmissions() argument
131 mode = in_8(&usb->fhci->regs->usb_usmod); in fhci_flush_all_transmissions()
132 clrbits8(&usb->fhci->regs->usb_usmod, USB_MODE_EN); in fhci_flush_all_transmissions()
134 fhci_flush_bds(usb); in fhci_flush_all_transmissions()
136 while ((td = fhci_peek_td_from_frame(usb->actual_frame)) != NULL) { in fhci_flush_all_transmissions()
140 fhci_transaction_confirm(usb, pkt); in fhci_flush_all_transmissions()
143 usb->actual_frame->frame_status = FRAME_END_TRANSMISSION; in fhci_flush_all_transmissions()
146 out_be16(&usb->fhci->regs->usb_usber, 0xffff); in fhci_flush_all_transmissions()
147 /* enable the USB controller */ in fhci_flush_all_transmissions()
148 out_8(&usb->fhci->regs->usb_usmod, mode | USB_MODE_EN); in fhci_flush_all_transmissions()
155 static int add_packet(struct fhci_usb *usb, struct ed *ed, struct td *td) in add_packet() argument
188 if (usb->port_status == FHCI_PORT_FULL) in add_packet()
194 if (usb->actual_frame->total_bytes + len + PROTOCOL_OVERHEAD >= in add_packet()
195 usb->max_bytes_per_frame) { in add_packet()
196 fhci_vdbg(usb->fhci, "not enough space in this frame: " in add_packet()
197 "%d %d %d\n", usb->actual_frame->total_bytes, len, in add_packet()
198 usb->max_bytes_per_frame); in add_packet()
203 if (usb->actual_frame->frame_status != FRAME_IS_PREPARED && in add_packet()
204 (usb->actual_frame->frame_status & FRAME_END_TRANSMISSION || in add_packet()
205 (fw_transaction_time + usb->sw_transaction_time >= in add_packet()
206 1000 - fhci_get_sof_timer_count(usb)))) { in add_packet()
207 fhci_dbg(usb->fhci, "not enough time in this frame\n"); in add_packet()
212 pkt = cq_get(&usb->ep0->empty_frame_Q); in add_packet()
214 fhci_dbg(usb->fhci, "there is no empty frame\n"); in add_packet()
221 data = cq_get(&usb->ep0->dummy_packets_Q); in add_packet()
231 usb->actual_frame->total_bytes += (len + PROTOCOL_OVERHEAD); in add_packet()
232 fhci_add_td_to_frame(usb->actual_frame, td); in add_packet()
234 if (usb->port_status != FHCI_PORT_FULL && in add_packet()
235 usb->port_status != FHCI_PORT_LOW) { in add_packet()
238 fhci_transaction_confirm(usb, pkt); in add_packet()
239 } else if (fhci_host_transaction(usb, pkt, td->type, ed->dev_addr, in add_packet()
245 cq_put(&usb->ep0->dummy_packets_Q, pkt->data); in add_packet()
246 recycle_frame(usb, pkt); in add_packet()
247 usb->actual_frame->total_bytes -= (len + PROTOCOL_OVERHEAD); in add_packet()
248 fhci_err(usb->fhci, "host transaction failed\n"); in add_packet()
268 static int scan_ed_list(struct fhci_usb *usb, in scan_ed_list() argument
282 u32 save_transaction_time = usb->sw_transaction_time; in scan_ed_list()
293 fhci_move_td_from_ed_to_done_list(usb, ed); in scan_ed_list()
304 (((usb->actual_frame->frame_num - in scan_ed_list()
308 if (add_packet(usb, ed, td) < 0) in scan_ed_list()
312 td->start_frame = usb->actual_frame->frame_num; in scan_ed_list()
313 usb->sw_transaction_time += save_transaction_time; in scan_ed_list()
315 if (usb->actual_frame->total_bytes >= in scan_ed_list()
316 usb->max_bytes_per_frame) { in scan_ed_list()
317 usb->actual_frame->frame_status = in scan_ed_list()
319 fhci_push_dummy_bd(usb->ep0); in scan_ed_list()
324 if (usb->actual_frame->total_bytes >= frame_part[list_type]) in scan_ed_list()
330 usb->sw_transaction_time = save_transaction_time; in scan_ed_list()
335 static u32 rotate_frames(struct fhci_usb *usb) in rotate_frames() argument
337 struct fhci_hcd *fhci = usb->fhci; in rotate_frames()
339 if (!list_empty(&usb->actual_frame->tds_list)) { in rotate_frames()
341 usb->actual_frame->frame_num) & 0x7ff) > 5) in rotate_frames()
342 fhci_flush_actual_frame(usb); in rotate_frames()
347 usb->actual_frame->frame_status = FRAME_IS_PREPARED; in rotate_frames()
348 usb->actual_frame->frame_num = in_be16(&fhci->pram->frame_num) & 0x7ff; in rotate_frames()
349 usb->actual_frame->total_bytes = 0; in rotate_frames()
355 * This function schedule the USB transaction and will process the
358 void fhci_schedule_transactions(struct fhci_usb *usb) in fhci_schedule_transactions() argument
362 if (usb->actual_frame->frame_status & FRAME_END_TRANSMISSION) in fhci_schedule_transactions()
363 if (rotate_frames(usb) != 0) in fhci_schedule_transactions()
366 if (usb->actual_frame->frame_status & FRAME_END_TRANSMISSION) in fhci_schedule_transactions()
369 if (usb->actual_frame->total_bytes == 0) { in fhci_schedule_transactions()
374 scan_ed_list(usb, &usb->hc_list->iso_list, FHCI_TF_ISO); in fhci_schedule_transactions()
380 scan_ed_list(usb, &usb->hc_list->intr_list, FHCI_TF_INTR); in fhci_schedule_transactions()
386 left = scan_ed_list(usb, &usb->hc_list->ctrl_list, in fhci_schedule_transactions()
395 scan_ed_list(usb, &usb->hc_list->bulk_list, FHCI_TF_BULK); in fhci_schedule_transactions()
401 struct fhci_usb *usb = fhci->usb_lld; in sof_interrupt() local
403 if ((usb->port_status == FHCI_PORT_DISABLED) && in sof_interrupt()
404 (usb->vroot_hub->port.wPortStatus & USB_PORT_STAT_CONNECTION) && in sof_interrupt()
405 !(usb->vroot_hub->port.wPortChange & USB_PORT_STAT_C_CONNECTION)) { in sof_interrupt()
406 if (usb->vroot_hub->port.wPortStatus & USB_PORT_STAT_LOW_SPEED) in sof_interrupt()
407 usb->port_status = FHCI_PORT_LOW; in sof_interrupt()
409 usb->port_status = FHCI_PORT_FULL; in sof_interrupt()
411 usb->saved_msk &= ~USB_E_IDLE_MASK; in sof_interrupt()
412 out_be16(&usb->fhci->regs->usb_usbmr, usb->saved_msk); in sof_interrupt()
415 gtm_set_exact_timer16(fhci->timer, usb->max_frame_usage, false); in sof_interrupt()
417 fhci_host_transmit_actual_frame(usb); in sof_interrupt()
418 usb->actual_frame->frame_status = FRAME_IS_TRANSMITTED; in sof_interrupt()
420 fhci_schedule_transactions(usb); in sof_interrupt()
426 struct fhci_usb *usb = fhci->usb_lld; in fhci_device_disconnected_interrupt() local
430 fhci_usb_disable_interrupt(usb); in fhci_device_disconnected_interrupt()
431 clrbits8(&usb->fhci->regs->usb_usmod, USB_MODE_LSS); in fhci_device_disconnected_interrupt()
432 usb->port_status = FHCI_PORT_DISABLED; in fhci_device_disconnected_interrupt()
437 usb->saved_msk |= USB_E_IDLE_MASK; in fhci_device_disconnected_interrupt()
438 out_be16(&usb->fhci->regs->usb_usbmr, usb->saved_msk); in fhci_device_disconnected_interrupt()
440 usb->vroot_hub->port.wPortStatus &= ~USB_PORT_STAT_CONNECTION; in fhci_device_disconnected_interrupt()
441 usb->vroot_hub->port.wPortChange |= USB_PORT_STAT_C_CONNECTION; in fhci_device_disconnected_interrupt()
442 usb->max_bytes_per_frame = 0; in fhci_device_disconnected_interrupt()
443 fhci_usb_enable_interrupt(usb); in fhci_device_disconnected_interrupt()
448 /* detect a new device connected on the USB port */
452 struct fhci_usb *usb = fhci->usb_lld; in fhci_device_connected_interrupt() local
458 fhci_usb_disable_interrupt(usb); in fhci_device_connected_interrupt()
461 /* low-speed device was connected to the USB port */ in fhci_device_connected_interrupt()
470 usb->port_status = FHCI_PORT_LOW; in fhci_device_connected_interrupt()
471 setbits8(&usb->fhci->regs->usb_usmod, USB_MODE_LSS); in fhci_device_connected_interrupt()
472 usb->vroot_hub->port.wPortStatus |= in fhci_device_connected_interrupt()
475 usb->vroot_hub->port.wPortChange |= in fhci_device_connected_interrupt()
477 usb->max_bytes_per_frame = in fhci_device_connected_interrupt()
479 fhci_port_enable(usb); in fhci_device_connected_interrupt()
488 usb->port_status = FHCI_PORT_FULL; in fhci_device_connected_interrupt()
489 clrbits8(&usb->fhci->regs->usb_usmod, USB_MODE_LSS); in fhci_device_connected_interrupt()
490 usb->vroot_hub->port.wPortStatus &= in fhci_device_connected_interrupt()
492 usb->vroot_hub->port.wPortStatus |= in fhci_device_connected_interrupt()
494 usb->vroot_hub->port.wPortChange |= in fhci_device_connected_interrupt()
496 usb->max_bytes_per_frame = (MAX_BYTES_PER_FRAME - 15); in fhci_device_connected_interrupt()
497 fhci_port_enable(usb); in fhci_device_connected_interrupt()
500 fhci_usb_enable_interrupt(usb); in fhci_device_connected_interrupt()
508 struct fhci_usb *usb = fhci->usb_lld; in fhci_frame_limit_timer_irq() local
514 if (usb->actual_frame->frame_status == FRAME_IS_TRANSMITTED) { in fhci_frame_limit_timer_irq()
515 usb->actual_frame->frame_status = FRAME_TIMER_END_TRANSMISSION; in fhci_frame_limit_timer_irq()
516 fhci_push_dummy_bd(usb->ep0); in fhci_frame_limit_timer_irq()
519 fhci_schedule_transactions(usb); in fhci_frame_limit_timer_irq()
526 /* Cancel transmission on the USB endpoint */
527 static void abort_transmission(struct fhci_usb *usb) in abort_transmission() argument
529 fhci_dbg(usb->fhci, "-> %s\n", __func__); in abort_transmission()
533 out_8(&usb->fhci->regs->usb_uscom, USB_CMD_FLUSH_FIFO | EP_ZERO); in abort_transmission()
536 fhci_flush_bds(usb); in abort_transmission()
539 fhci_dbg(usb->fhci, "<- %s\n", __func__); in abort_transmission()
545 struct fhci_usb *usb; in fhci_irq() local
551 usb = fhci->usb_lld; in fhci_irq()
553 usb_er |= in_be16(&usb->fhci->regs->usb_usber) & in fhci_irq()
554 in_be16(&usb->fhci->regs->usb_usbmr); in fhci_irq()
557 out_be16(&usb->fhci->regs->usb_usber, usb_er); in fhci_irq()
562 if ((usb->port_status == FHCI_PORT_FULL) || in fhci_irq()
563 (usb->port_status == FHCI_PORT_LOW)) { in fhci_irq()
566 } else if (usb->port_status == FHCI_PORT_WAITING) { in fhci_irq()
567 usb->port_status = FHCI_PORT_DISCONNECTING; in fhci_irq()
570 usb->saved_msk |= USB_E_IDLE_MASK; in fhci_irq()
571 out_be16(&usb->fhci->regs->usb_usber, in fhci_irq()
572 usb->saved_msk); in fhci_irq()
573 } else if (usb->port_status == FHCI_PORT_DISABLED) { in fhci_irq()
601 if (usb->port_status == FHCI_PORT_DISABLED) { in fhci_irq()
604 } else if (usb->port_status == in fhci_irq()
606 /* XXX usb->port_status = FHCI_PORT_WAITING; */ in fhci_irq()
608 usb->saved_msk &= ~USB_E_IDLE_MASK; in fhci_irq()
609 out_be16(&usb->fhci->regs->usb_usbmr, in fhci_irq()
610 usb->saved_msk); in fhci_irq()
694 * ep USB Host endpoint data structure
695 * urb USB request block data structure
745 * OHCI handles the DATA toggle itself,we just use the USB in fhci_queue_urb()