Lines Matching +full:no +full:- +full:temp +full:- +full:support
1 /*-
2 * SPDX-License-Identifier: BSD-2-Clause
18 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
34 * NOTE: When the chip detects BUS-reset it will also reset the
35 * endpoints, Function-address and more.
83 AVR32_BUS2SC(USB_DMATAG_TO_XROOT((pc)->tag_parent)->bus)
176 uint32_t temp; in avr32dci_mod_ctrl() local
178 temp = AVR32_READ_4(sc, AVR32_CTRL); in avr32dci_mod_ctrl()
179 temp |= set; in avr32dci_mod_ctrl()
180 temp &= ~clear; in avr32dci_mod_ctrl()
181 AVR32_WRITE_4(sc, AVR32_CTRL, temp); in avr32dci_mod_ctrl()
187 uint32_t temp; in avr32dci_mod_ien() local
189 temp = AVR32_READ_4(sc, AVR32_IEN); in avr32dci_mod_ien()
190 temp |= set; in avr32dci_mod_ien()
191 temp &= ~clear; in avr32dci_mod_ien()
192 AVR32_WRITE_4(sc, AVR32_IEN, temp); in avr32dci_mod_ien()
198 if (sc->sc_flags.clocks_off && in avr32dci_clocks_on()
199 sc->sc_flags.port_powered) { in avr32dci_clocks_on()
203 (sc->sc_clocks_on) (&sc->sc_bus); in avr32dci_clocks_on()
207 sc->sc_flags.clocks_off = 0; in avr32dci_clocks_on()
214 if (!sc->sc_flags.clocks_off) { in avr32dci_clocks_off()
220 (sc->sc_clocks_off) (&sc->sc_bus); in avr32dci_clocks_off()
222 sc->sc_flags.clocks_off = 1; in avr32dci_clocks_off()
231 if (!sc->sc_flags.d_pulled_up && in avr32dci_pull_up()
232 sc->sc_flags.port_powered) { in avr32dci_pull_up()
233 sc->sc_flags.d_pulled_up = 1; in avr32dci_pull_up()
243 if (sc->sc_flags.d_pulled_up) { in avr32dci_pull_down()
244 sc->sc_flags.d_pulled_up = 0; in avr32dci_pull_down()
252 if (!sc->sc_flags.status_suspend) { in avr32dci_wakeup_peer()
259 usb_pause_mtx(&sc->sc_bus.bus_mtx, hz / 125); in avr32dci_wakeup_peer()
278 uint32_t temp; in avr32dci_setup_rx() local
281 sc = AVR32_PC2SC(td->pc); in avr32dci_setup_rx()
284 temp = AVR32_READ_4(sc, AVR32_EPTSTA(td->ep_no)); in avr32dci_setup_rx()
286 DPRINTFN(5, "EPTSTA(%u)=0x%08x\n", td->ep_no, temp); in avr32dci_setup_rx()
288 if (!(temp & AVR32_EPTSTA_RX_SETUP)) { in avr32dci_setup_rx()
292 td->did_stall = 0; in avr32dci_setup_rx()
294 count = AVR32_EPTSTA_BYTE_COUNT(temp); in avr32dci_setup_rx()
297 if (count != td->remainder) { in avr32dci_setup_rx()
308 memcpy(&req, sc->physdata, sizeof(req)); in avr32dci_setup_rx()
311 usbd_copy_in(td->pc, 0, &req, sizeof(req)); in avr32dci_setup_rx()
313 td->offset = sizeof(req); in avr32dci_setup_rx()
314 td->remainder = 0; in avr32dci_setup_rx()
319 sc->sc_dv_addr = req.wValue[0] & 0x7F; in avr32dci_setup_rx()
323 avr32dci_mod_ctrl(sc, sc->sc_dv_addr, 0); in avr32dci_setup_rx()
325 sc->sc_dv_addr = 0xFF; in avr32dci_setup_rx()
329 AVR32_WRITE_4(sc, AVR32_EPTCLRSTA(td->ep_no), AVR32_EPTSTA_RX_SETUP); in avr32dci_setup_rx()
333 if (temp & AVR32_EPTSTA_RX_SETUP) { in avr32dci_setup_rx()
335 AVR32_WRITE_4(sc, AVR32_EPTCLRSTA(td->ep_no), AVR32_EPTSTA_RX_SETUP); in avr32dci_setup_rx()
338 if (!td->did_stall) { in avr32dci_setup_rx()
340 AVR32_WRITE_4(sc, AVR32_EPTSETSTA(td->ep_no), in avr32dci_setup_rx()
342 td->did_stall = 1; in avr32dci_setup_rx()
353 uint32_t temp; in avr32dci_data_rx() local
361 sc = AVR32_PC2SC(td->pc); in avr32dci_data_rx()
366 temp = AVR32_READ_4(sc, AVR32_EPTSTA(td->ep_no)); in avr32dci_data_rx()
368 DPRINTFN(5, "EPTSTA(%u)=0x%08x\n", td->ep_no, temp); in avr32dci_data_rx()
370 if (temp & AVR32_EPTSTA_RX_SETUP) { in avr32dci_data_rx()
371 if (td->remainder == 0) { in avr32dci_data_rx()
382 td->error = 1; in avr32dci_data_rx()
386 if (!(temp & AVR32_EPTSTA_RX_BK_RDY)) { in avr32dci_data_rx()
387 /* no data */ in avr32dci_data_rx()
391 count = AVR32_EPTSTA_BYTE_COUNT(temp); in avr32dci_data_rx()
394 if (count != td->max_packet_size) { in avr32dci_data_rx()
395 if (count < td->max_packet_size) { in avr32dci_data_rx()
397 td->short_pkt = 1; in avr32dci_data_rx()
401 td->error = 1; in avr32dci_data_rx()
406 if (count > td->remainder) { in avr32dci_data_rx()
408 td->error = 1; in avr32dci_data_rx()
412 usbd_get_page(td->pc, td->offset, &buf_res); in avr32dci_data_rx()
419 memcpy(buf_res.buffer, sc->physdata + in avr32dci_data_rx()
420 (AVR32_EPTSTA_CURRENT_BANK(temp) << td->bank_shift) + in avr32dci_data_rx()
421 (td->ep_no << 16) + (td->offset % td->max_packet_size), buf_res.length); in avr32dci_data_rx()
423 count -= buf_res.length; in avr32dci_data_rx()
424 td->offset += buf_res.length; in avr32dci_data_rx()
425 td->remainder -= buf_res.length; in avr32dci_data_rx()
429 AVR32_WRITE_4(sc, AVR32_EPTCLRSTA(td->ep_no), AVR32_EPTSTA_RX_BK_RDY); in avr32dci_data_rx()
432 if ((td->remainder == 0) || got_short) { in avr32dci_data_rx()
433 if (td->short_pkt) { in avr32dci_data_rx()
439 if (--to) { in avr32dci_data_rx()
453 uint32_t temp; in avr32dci_data_tx() local
458 sc = AVR32_PC2SC(td->pc); in avr32dci_data_tx()
463 temp = AVR32_READ_4(sc, AVR32_EPTSTA(td->ep_no)); in avr32dci_data_tx()
465 DPRINTFN(5, "EPTSTA(%u)=0x%08x\n", td->ep_no, temp); in avr32dci_data_tx()
467 if (temp & AVR32_EPTSTA_RX_SETUP) { in avr32dci_data_tx()
472 td->error = 1; in avr32dci_data_tx()
475 if (temp & AVR32_EPTSTA_TX_PK_RDY) { in avr32dci_data_tx()
476 /* cannot write any data - all banks are busy */ in avr32dci_data_tx()
479 count = td->max_packet_size; in avr32dci_data_tx()
480 if (td->remainder < count) { in avr32dci_data_tx()
482 td->short_pkt = 1; in avr32dci_data_tx()
483 count = td->remainder; in avr32dci_data_tx()
486 usbd_get_page(td->pc, td->offset, &buf_res); in avr32dci_data_tx()
493 memcpy(sc->physdata + in avr32dci_data_tx()
494 (AVR32_EPTSTA_CURRENT_BANK(temp) << td->bank_shift) + in avr32dci_data_tx()
495 (td->ep_no << 16) + (td->offset % td->max_packet_size), in avr32dci_data_tx()
498 count -= buf_res.length; in avr32dci_data_tx()
499 td->offset += buf_res.length; in avr32dci_data_tx()
500 td->remainder -= buf_res.length; in avr32dci_data_tx()
504 AVR32_WRITE_4(sc, AVR32_EPTCTL(td->ep_no), AVR32_EPTCTL_TX_PK_RDY); in avr32dci_data_tx()
507 if (td->remainder == 0) { in avr32dci_data_tx()
508 if (td->short_pkt) { in avr32dci_data_tx()
513 if (--to) { in avr32dci_data_tx()
524 uint32_t temp; in avr32dci_data_tx_sync() local
527 sc = AVR32_PC2SC(td->pc); in avr32dci_data_tx_sync()
530 temp = AVR32_READ_4(sc, AVR32_EPTSTA(td->ep_no)); in avr32dci_data_tx_sync()
532 DPRINTFN(5, "EPTSTA(%u)=0x%08x\n", td->ep_no, temp); in avr32dci_data_tx_sync()
534 if (temp & AVR32_EPTSTA_RX_SETUP) { in avr32dci_data_tx_sync()
543 if (AVR32_EPTSTA_BUSY_BANK_STA(temp) != 0) { in avr32dci_data_tx_sync()
544 /* cannot write any data - a bank is busy */ in avr32dci_data_tx_sync()
547 if (sc->sc_dv_addr != 0xFF) { in avr32dci_data_tx_sync()
549 avr32dci_set_address(sc, sc->sc_dv_addr); in avr32dci_data_tx_sync()
564 td = xfer->td_transfer_cache; in avr32dci_xfer_do_fifo()
566 if ((td->func) (td)) { in avr32dci_xfer_do_fifo()
570 if (((void *)td) == xfer->td_transfer_last) { in avr32dci_xfer_do_fifo()
573 if (td->error) { in avr32dci_xfer_do_fifo()
575 } else if (td->remainder > 0) { in avr32dci_xfer_do_fifo()
577 * We had a short transfer. If there is no alternate in avr32dci_xfer_do_fifo()
580 if (!td->alt_next) { in avr32dci_xfer_do_fifo()
588 td = td->obj_next; in avr32dci_xfer_do_fifo()
589 xfer->td_transfer_cache = td; in avr32dci_xfer_do_fifo()
606 TAILQ_FOREACH(xfer, &sc->sc_bus.intr_q.head, wait_entry) { in avr32dci_interrupt_poll()
620 if (!sc->sc_flags.status_vbus) { in avr32dci_vbus_interrupt()
621 sc->sc_flags.status_vbus = 1; in avr32dci_vbus_interrupt()
628 if (sc->sc_flags.status_vbus) { in avr32dci_vbus_interrupt()
629 sc->sc_flags.status_vbus = 0; in avr32dci_vbus_interrupt()
630 sc->sc_flags.status_bus_reset = 0; in avr32dci_vbus_interrupt()
631 sc->sc_flags.status_suspend = 0; in avr32dci_vbus_interrupt()
632 sc->sc_flags.change_suspend = 0; in avr32dci_vbus_interrupt()
633 sc->sc_flags.change_connect = 1; in avr32dci_vbus_interrupt()
647 USB_BUS_LOCK(&sc->sc_bus); in avr32dci_interrupt()
662 sc->sc_flags.status_bus_reset = 1; in avr32dci_interrupt()
663 sc->sc_flags.status_suspend = 0; in avr32dci_interrupt()
664 sc->sc_flags.change_suspend = 0; in avr32dci_interrupt()
665 sc->sc_flags.change_connect = 1; in avr32dci_interrupt()
682 if (sc->sc_flags.status_suspend) { in avr32dci_interrupt()
684 sc->sc_flags.status_suspend = 0; in avr32dci_interrupt()
685 sc->sc_flags.change_suspend = 1; in avr32dci_interrupt()
697 if (!sc->sc_flags.status_suspend) { in avr32dci_interrupt()
699 sc->sc_flags.status_suspend = 1; in avr32dci_interrupt()
700 sc->sc_flags.change_suspend = 1; in avr32dci_interrupt()
711 if (status & -AVR32_INT_EPT_INT(0)) { in avr32dci_interrupt()
716 USB_BUS_UNLOCK(&sc->sc_bus); in avr32dci_interrupt()
720 avr32dci_setup_standard_chain_sub(struct avr32dci_std_temp *temp) in avr32dci_setup_standard_chain_sub() argument
725 td = temp->td_next; in avr32dci_setup_standard_chain_sub()
726 temp->td = td; in avr32dci_setup_standard_chain_sub()
729 temp->td_next = td->obj_next; in avr32dci_setup_standard_chain_sub()
732 td->func = temp->func; in avr32dci_setup_standard_chain_sub()
733 td->pc = temp->pc; in avr32dci_setup_standard_chain_sub()
734 td->offset = temp->offset; in avr32dci_setup_standard_chain_sub()
735 td->remainder = temp->len; in avr32dci_setup_standard_chain_sub()
736 td->error = 0; in avr32dci_setup_standard_chain_sub()
737 td->did_stall = temp->did_stall; in avr32dci_setup_standard_chain_sub()
738 td->short_pkt = temp->short_pkt; in avr32dci_setup_standard_chain_sub()
739 td->alt_next = temp->setup_alt_next; in avr32dci_setup_standard_chain_sub()
745 struct avr32dci_std_temp temp; in avr32dci_setup_standard_chain() local
753 xfer->address, UE_GET_ADDR(xfer->endpointno), in avr32dci_setup_standard_chain()
754 xfer->sumlen, usbd_get_speed(xfer->xroot->udev)); in avr32dci_setup_standard_chain()
756 temp.max_frame_size = xfer->max_frame_size; in avr32dci_setup_standard_chain()
758 td = xfer->td_start[0]; in avr32dci_setup_standard_chain()
759 xfer->td_transfer_first = td; in avr32dci_setup_standard_chain()
760 xfer->td_transfer_cache = td; in avr32dci_setup_standard_chain()
762 /* setup temp */ in avr32dci_setup_standard_chain()
764 temp.pc = NULL; in avr32dci_setup_standard_chain()
765 temp.td = NULL; in avr32dci_setup_standard_chain()
766 temp.td_next = xfer->td_start[0]; in avr32dci_setup_standard_chain()
767 temp.offset = 0; in avr32dci_setup_standard_chain()
768 temp.setup_alt_next = xfer->flags_int.short_frames_ok || in avr32dci_setup_standard_chain()
769 xfer->flags_int.isochronous_xfr; in avr32dci_setup_standard_chain()
770 temp.did_stall = !xfer->flags_int.control_stall; in avr32dci_setup_standard_chain()
772 sc = AVR32_BUS2SC(xfer->xroot->bus); in avr32dci_setup_standard_chain()
773 ep_no = (xfer->endpointno & UE_ADDR); in avr32dci_setup_standard_chain()
777 if (xfer->flags_int.control_xfr) { in avr32dci_setup_standard_chain()
778 if (xfer->flags_int.control_hdr) { in avr32dci_setup_standard_chain()
779 temp.func = &avr32dci_setup_rx; in avr32dci_setup_standard_chain()
780 temp.len = xfer->frlengths[0]; in avr32dci_setup_standard_chain()
781 temp.pc = xfer->frbuffers + 0; in avr32dci_setup_standard_chain()
782 temp.short_pkt = temp.len ? 1 : 0; in avr32dci_setup_standard_chain()
784 if (xfer->nframes == 1) { in avr32dci_setup_standard_chain()
785 /* no STATUS stage yet, SETUP is last */ in avr32dci_setup_standard_chain()
786 if (xfer->flags_int.control_act) in avr32dci_setup_standard_chain()
787 temp.setup_alt_next = 0; in avr32dci_setup_standard_chain()
789 avr32dci_setup_standard_chain_sub(&temp); in avr32dci_setup_standard_chain()
796 if (x != xfer->nframes) { in avr32dci_setup_standard_chain()
797 if (xfer->endpointno & UE_DIR_IN) { in avr32dci_setup_standard_chain()
798 temp.func = &avr32dci_data_tx; in avr32dci_setup_standard_chain()
801 temp.func = &avr32dci_data_rx; in avr32dci_setup_standard_chain()
806 temp.pc = xfer->frbuffers + x; in avr32dci_setup_standard_chain()
810 while (x != xfer->nframes) { in avr32dci_setup_standard_chain()
813 temp.len = xfer->frlengths[x]; in avr32dci_setup_standard_chain()
817 if (x == xfer->nframes) { in avr32dci_setup_standard_chain()
818 if (xfer->flags_int.control_xfr) { in avr32dci_setup_standard_chain()
819 if (xfer->flags_int.control_act) { in avr32dci_setup_standard_chain()
820 temp.setup_alt_next = 0; in avr32dci_setup_standard_chain()
823 temp.setup_alt_next = 0; in avr32dci_setup_standard_chain()
826 if (temp.len == 0) { in avr32dci_setup_standard_chain()
829 temp.short_pkt = 0; in avr32dci_setup_standard_chain()
834 temp.short_pkt = (xfer->flags.force_short_xfer) ? 0 : 1; in avr32dci_setup_standard_chain()
837 avr32dci_setup_standard_chain_sub(&temp); in avr32dci_setup_standard_chain()
839 if (xfer->flags_int.isochronous_xfr) { in avr32dci_setup_standard_chain()
840 temp.offset += temp.len; in avr32dci_setup_standard_chain()
843 temp.pc = xfer->frbuffers + x; in avr32dci_setup_standard_chain()
847 if (xfer->flags_int.control_xfr) { in avr32dci_setup_standard_chain()
849 temp.pc = xfer->frbuffers + 0; in avr32dci_setup_standard_chain()
850 temp.len = 0; in avr32dci_setup_standard_chain()
851 temp.short_pkt = 0; in avr32dci_setup_standard_chain()
852 temp.setup_alt_next = 0; in avr32dci_setup_standard_chain()
857 temp.func = &avr32dci_data_tx_sync; in avr32dci_setup_standard_chain()
858 avr32dci_setup_standard_chain_sub(&temp); in avr32dci_setup_standard_chain()
861 if (!xfer->flags_int.control_act) { in avr32dci_setup_standard_chain()
866 if (xfer->endpointno & UE_DIR_IN) { in avr32dci_setup_standard_chain()
867 temp.func = &avr32dci_data_rx; in avr32dci_setup_standard_chain()
870 temp.func = &avr32dci_data_tx; in avr32dci_setup_standard_chain()
874 avr32dci_setup_standard_chain_sub(&temp); in avr32dci_setup_standard_chain()
877 temp.func = &avr32dci_data_tx_sync; in avr32dci_setup_standard_chain()
878 avr32dci_setup_standard_chain_sub(&temp); in avr32dci_setup_standard_chain()
883 td = temp.td; in avr32dci_setup_standard_chain()
884 xfer->td_transfer_last = td; in avr32dci_setup_standard_chain()
894 USB_BUS_LOCK_ASSERT(xfer->xroot->bus, MA_OWNED); in avr32dci_timeout()
905 /* poll one time - will turn on interrupts */ in avr32dci_start_standard_chain()
907 uint8_t ep_no = xfer->endpointno & UE_ADDR; in avr32dci_start_standard_chain()
908 struct avr32dci_softc *sc = AVR32_BUS2SC(xfer->xroot->bus); in avr32dci_start_standard_chain()
913 usbd_transfer_enqueue(&xfer->xroot->bus->intr_q, xfer); in avr32dci_start_standard_chain()
916 if (xfer->timeout != 0) { in avr32dci_start_standard_chain()
918 &avr32dci_timeout, xfer->timeout); in avr32dci_start_standard_chain()
928 USB_BUS_LOCK_ASSERT(&sc->sc_bus, MA_OWNED); in avr32dci_root_intr()
931 sc->sc_hub_idata[0] = 0x02; /* we only have one port */ in avr32dci_root_intr()
933 uhub_root_intr(&sc->sc_bus, sc->sc_hub_idata, in avr32dci_root_intr()
934 sizeof(sc->sc_hub_idata)); in avr32dci_root_intr()
946 td = xfer->td_transfer_cache; in avr32dci_standard_done_sub()
949 len = td->remainder; in avr32dci_standard_done_sub()
951 if (xfer->aframes != xfer->nframes) { in avr32dci_standard_done_sub()
956 if (len > xfer->frlengths[xfer->aframes]) { in avr32dci_standard_done_sub()
957 td->error = 1; in avr32dci_standard_done_sub()
959 xfer->frlengths[xfer->aframes] -= len; in avr32dci_standard_done_sub()
963 if (td->error) { in avr32dci_standard_done_sub()
971 if (xfer->flags_int.short_frames_ok || in avr32dci_standard_done_sub()
972 xfer->flags_int.isochronous_xfr) { in avr32dci_standard_done_sub()
974 if (td->alt_next) { in avr32dci_standard_done_sub()
975 td = td->obj_next; in avr32dci_standard_done_sub()
986 td = td->obj_next; in avr32dci_standard_done_sub()
996 xfer->td_transfer_cache = td; in avr32dci_standard_done_sub()
1008 xfer, xfer->endpoint); in avr32dci_standard_done()
1012 xfer->td_transfer_cache = xfer->td_transfer_first; in avr32dci_standard_done()
1014 if (xfer->flags_int.control_xfr) { in avr32dci_standard_done()
1015 if (xfer->flags_int.control_hdr) { in avr32dci_standard_done()
1018 xfer->aframes = 1; in avr32dci_standard_done()
1020 if (xfer->td_transfer_cache == NULL) { in avr32dci_standard_done()
1024 while (xfer->aframes != xfer->nframes) { in avr32dci_standard_done()
1026 xfer->aframes++; in avr32dci_standard_done()
1028 if (xfer->td_transfer_cache == NULL) { in avr32dci_standard_done()
1033 if (xfer->flags_int.control_xfr && in avr32dci_standard_done()
1034 !xfer->flags_int.control_act) { in avr32dci_standard_done()
1041 /*------------------------------------------------------------------------*
1046 *------------------------------------------------------------------------*/
1050 struct avr32dci_softc *sc = AVR32_BUS2SC(xfer->xroot->bus); in avr32dci_device_done()
1053 USB_BUS_LOCK_ASSERT(&sc->sc_bus, MA_OWNED); in avr32dci_device_done()
1056 xfer, xfer->endpoint, error); in avr32dci_device_done()
1058 if (xfer->flags_int.usb_mode == USB_MODE_DEVICE) { in avr32dci_device_done()
1059 ep_no = (xfer->endpointno & UE_ADDR); in avr32dci_device_done()
1083 USB_BUS_LOCK_ASSERT(udev->bus, MA_OWNED); in avr32dci_set_stall()
1087 sc = AVR32_BUS2SC(udev->bus); in avr32dci_set_stall()
1089 ep_no = (pipe->edesc->bEndpointAddress & UE_ADDR); in avr32dci_set_stall()
1099 uint32_t temp; in avr32dci_clear_stall_sub() local
1120 temp = AVR32_EPTCFG_TYPE_BULK; in avr32dci_clear_stall_sub()
1122 temp = AVR32_EPTCFG_TYPE_INTR; in avr32dci_clear_stall_sub()
1124 temp = AVR32_EPTCFG_TYPE_ISOC | in avr32dci_clear_stall_sub()
1128 temp |= AVR32_EPTCFG_EPDIR_IN; in avr32dci_clear_stall_sub()
1133 epsize = pf->max_in_frame_size | pf->max_out_frame_size; in avr32dci_clear_stall_sub()
1137 temp |= AVR32_EPTCFG_EPSIZE(n); in avr32dci_clear_stall_sub()
1141 temp |= AVR32_EPTCFG_NBANK(1); in avr32dci_clear_stall_sub()
1143 temp |= AVR32_EPTCFG_NBANK(2); in avr32dci_clear_stall_sub()
1145 temp |= AVR32_EPTCFG_NBANK(3); in avr32dci_clear_stall_sub()
1147 AVR32_WRITE_4(sc, AVR32_EPTCFG(ep_no), temp); in avr32dci_clear_stall_sub()
1149 temp = AVR32_READ_4(sc, AVR32_EPTCFG(ep_no)); in avr32dci_clear_stall_sub()
1151 if (!(temp & AVR32_EPTCFG_EPT_MAPD)) { in avr32dci_clear_stall_sub()
1152 device_printf(sc->sc_bus.bdev, "Chip rejected configuration\n"); in avr32dci_clear_stall_sub()
1167 USB_BUS_LOCK_ASSERT(udev->bus, MA_OWNED); in avr32dci_clear_stall()
1170 if (udev->flags.usb_mode != USB_MODE_DEVICE) { in avr32dci_clear_stall()
1175 sc = AVR32_BUS2SC(udev->bus); in avr32dci_clear_stall()
1178 ed = pipe->edesc; in avr32dci_clear_stall()
1182 (ed->bEndpointAddress & UE_ADDR), in avr32dci_clear_stall()
1183 (ed->bmAttributes & UE_XFERTYPE), in avr32dci_clear_stall()
1184 (ed->bEndpointAddress & (UE_DIR_IN | UE_DIR_OUT))); in avr32dci_clear_stall()
1195 sc->sc_bus.usbrev = USB_REV_1_1; in avr32dci_init()
1196 sc->sc_bus.methods = &avr32dci_bus_methods; in avr32dci_init()
1198 USB_BUS_LOCK(&sc->sc_bus); in avr32dci_init()
1204 (sc->sc_clocks_on) (&sc->sc_bus); in avr32dci_init()
1206 /* make sure device is re-enumerated */ in avr32dci_init()
1210 usb_pause_mtx(&sc->sc_bus.bus_mtx, hz / 20); in avr32dci_init()
1220 AVR32_WRITE_4(sc, AVR32_EPTRST, (1 << AVR32_EP_MAX) - 1); in avr32dci_init()
1232 USB_BUS_UNLOCK(&sc->sc_bus); in avr32dci_init()
1236 avr32dci_do_poll(&sc->sc_bus); in avr32dci_init()
1246 USB_BUS_LOCK(&sc->sc_bus); in avr32dci_uninit()
1249 (sc->sc_clocks_on) (&sc->sc_bus); in avr32dci_uninit()
1255 AVR32_WRITE_4(sc, AVR32_EPTRST, (1 << AVR32_EP_MAX) - 1); in avr32dci_uninit()
1263 sc->sc_flags.port_powered = 0; in avr32dci_uninit()
1264 sc->sc_flags.status_vbus = 0; in avr32dci_uninit()
1265 sc->sc_flags.status_bus_reset = 0; in avr32dci_uninit()
1266 sc->sc_flags.status_suspend = 0; in avr32dci_uninit()
1267 sc->sc_flags.change_suspend = 0; in avr32dci_uninit()
1268 sc->sc_flags.change_connect = 1; in avr32dci_uninit()
1273 USB_BUS_UNLOCK(&sc->sc_bus); in avr32dci_uninit()
1293 USB_BUS_LOCK(&sc->sc_bus); in avr32dci_do_poll()
1295 USB_BUS_UNLOCK(&sc->sc_bus); in avr32dci_do_poll()
1298 /*------------------------------------------------------------------------*
1299 * avr32dci bulk support
1300 * avr32dci control support
1301 * avr32dci interrupt support
1302 *------------------------------------------------------------------------*/
1337 /*------------------------------------------------------------------------*
1338 * avr32dci full speed isochronous support
1339 *------------------------------------------------------------------------*/
1355 struct avr32dci_softc *sc = AVR32_BUS2SC(xfer->xroot->bus); in avr32dci_device_isoc_fs_enter()
1360 xfer, xfer->endpoint->isoc_next, xfer->nframes); in avr32dci_device_isoc_fs_enter()
1363 ep_no = xfer->endpointno & UE_ADDR; in avr32dci_device_isoc_fs_enter()
1368 DPRINTFN(3, "start next=%d\n", xfer->endpoint->isoc_next); in avr32dci_device_isoc_fs_enter()
1389 /*------------------------------------------------------------------------*
1390 * avr32dci root control support
1391 *------------------------------------------------------------------------*
1393 *------------------------------------------------------------------------*/
1473 struct avr32dci_softc *sc = AVR32_BUS2SC(udev->bus); in avr32dci_roothub_exec()
1478 uint32_t temp; in avr32dci_roothub_exec() local
1481 USB_BUS_LOCK_ASSERT(&sc->sc_bus, MA_OWNED); in avr32dci_roothub_exec()
1484 ptr = (const void *)&sc->sc_hub_temp; in avr32dci_roothub_exec()
1488 value = UGETW(req->wValue); in avr32dci_roothub_exec()
1489 index = UGETW(req->wIndex); in avr32dci_roothub_exec()
1493 switch (req->bmRequestType) { in avr32dci_roothub_exec()
1495 switch (req->bRequest) { in avr32dci_roothub_exec()
1508 switch (req->bRequest) { in avr32dci_roothub_exec()
1524 switch (req->bRequest) { in avr32dci_roothub_exec()
1526 switch (UGETW(req->wValue)) { in avr32dci_roothub_exec()
1536 switch (UGETW(req->wValue)) { in avr32dci_roothub_exec()
1553 switch (req->bRequest) { in avr32dci_roothub_exec()
1562 switch (req->bRequest) { in avr32dci_roothub_exec()
1574 switch (req->bRequest) { in avr32dci_roothub_exec()
1595 switch (req->bRequest) { in avr32dci_roothub_exec()
1607 switch (req->bRequest) { in avr32dci_roothub_exec()
1623 switch (req->bRequest) { in avr32dci_roothub_exec()
1634 switch (req->bRequest) { in avr32dci_roothub_exec()
1698 sc->sc_hub_temp.wValue[0] = sc->sc_conf; in avr32dci_roothub_exec()
1703 USETW(sc->sc_hub_temp.wValue, UDS_SELF_POWERED); in avr32dci_roothub_exec()
1710 sc->sc_rt_addr = value; in avr32dci_roothub_exec()
1717 sc->sc_conf = value; in avr32dci_roothub_exec()
1722 sc->sc_hub_temp.wValue[0] = 0; in avr32dci_roothub_exec()
1730 USETW(sc->sc_hub_temp.wValue, 0); in avr32dci_roothub_exec()
1752 sc->sc_flags.port_enabled = 0; in avr32dci_roothub_exec()
1763 sc->sc_flags.port_powered = 0; in avr32dci_roothub_exec()
1769 sc->sc_flags.change_connect = 0; in avr32dci_roothub_exec()
1771 if (!sc->sc_flags.status_bus_reset) { in avr32dci_roothub_exec()
1792 temp = AVR32_READ_4(sc, AVR32_EPTCFG(0)); in avr32dci_roothub_exec()
1794 if (!(temp & AVR32_EPTCFG_EPT_MAPD)) { in avr32dci_roothub_exec()
1795 device_printf(sc->sc_bus.bdev, in avr32dci_roothub_exec()
1803 sc->sc_flags.change_suspend = 0; in avr32dci_roothub_exec()
1819 sc->sc_flags.port_enabled = 1; in avr32dci_roothub_exec()
1828 sc->sc_flags.port_powered = 1; in avr32dci_roothub_exec()
1843 if (sc->sc_flags.status_vbus) { in avr32dci_roothub_exec()
1859 if (sc->sc_flags.port_powered) { in avr32dci_roothub_exec()
1862 if (sc->sc_flags.port_enabled) { in avr32dci_roothub_exec()
1865 if (sc->sc_flags.status_vbus && in avr32dci_roothub_exec()
1866 sc->sc_flags.status_bus_reset) { in avr32dci_roothub_exec()
1869 if (sc->sc_flags.status_suspend) { in avr32dci_roothub_exec()
1872 USETW(sc->sc_hub_temp.ps.wPortStatus, value); in avr32dci_roothub_exec()
1876 if (sc->sc_flags.change_connect) { in avr32dci_roothub_exec()
1879 if (sc->sc_flags.change_suspend) { in avr32dci_roothub_exec()
1882 USETW(sc->sc_hub_temp.ps.wPortChange, value); in avr32dci_roothub_exec()
1883 len = sizeof(sc->sc_hub_temp.ps); in avr32dci_roothub_exec()
1914 sc = AVR32_BUS2SC(parm->udev->bus); in avr32dci_xfer_setup()
1915 xfer = parm->curr_xfer; in avr32dci_xfer_setup()
1922 parm->hc_max_packet_size = 0x400; in avr32dci_xfer_setup()
1923 parm->hc_max_packet_count = 1; in avr32dci_xfer_setup()
1924 parm->hc_max_frame_size = 0x400; in avr32dci_xfer_setup()
1931 if ((xfer->endpoint->edesc->bmAttributes & UE_XFERTYPE) == UE_CONTROL) { in avr32dci_xfer_setup()
1932 ntd = xfer->nframes + 1 /* STATUS */ + 1 /* SYNC 1 */ in avr32dci_xfer_setup()
1935 ntd = xfer->nframes + 1 /* SYNC */ ; in avr32dci_xfer_setup()
1941 if (parm->err) in avr32dci_xfer_setup()
1952 ep_no = xfer->endpointno & UE_ADDR; in avr32dci_xfer_setup()
1953 avr32dci_get_hw_ep_profile(parm->udev, &pf, ep_no); in avr32dci_xfer_setup()
1957 parm->err = USB_ERR_INVAL; in avr32dci_xfer_setup()
1961 parm->size[0] += ((-parm->size[0]) & (USB_HOST_ALIGN - 1)); in avr32dci_xfer_setup()
1966 if (parm->buf) { in avr32dci_xfer_setup()
1967 uint32_t temp; in avr32dci_xfer_setup() local
1969 td = USB_ADD_BYTES(parm->buf, parm->size[0]); in avr32dci_xfer_setup()
1972 td->max_packet_size = xfer->max_packet_size; in avr32dci_xfer_setup()
1973 td->ep_no = ep_no; in avr32dci_xfer_setup()
1974 temp = pf->max_in_frame_size | pf->max_out_frame_size; in avr32dci_xfer_setup()
1975 td->bank_shift = 0; in avr32dci_xfer_setup()
1976 while ((temp /= 2)) in avr32dci_xfer_setup()
1977 td->bank_shift++; in avr32dci_xfer_setup()
1978 if (pf->support_multi_buffer) { in avr32dci_xfer_setup()
1979 td->support_multi_buffer = 1; in avr32dci_xfer_setup()
1981 td->obj_next = last_obj; in avr32dci_xfer_setup()
1985 parm->size[0] += sizeof(*td); in avr32dci_xfer_setup()
1988 xfer->td_start[0] = last_obj; in avr32dci_xfer_setup()
2001 struct avr32dci_softc *sc = AVR32_BUS2SC(udev->bus); in avr32dci_ep_init()
2004 pipe, udev->address, in avr32dci_ep_init()
2005 edesc->bEndpointAddress, udev->flags.usb_mode, in avr32dci_ep_init()
2006 sc->sc_rt_addr, udev->device_index); in avr32dci_ep_init()
2008 if (udev->device_index != sc->sc_rt_addr) { in avr32dci_ep_init()
2009 if ((udev->speed != USB_SPEED_FULL) && in avr32dci_ep_init()
2010 (udev->speed != USB_SPEED_HIGH)) { in avr32dci_ep_init()
2014 if ((edesc->bmAttributes & UE_XFERTYPE) == UE_ISOCHRONOUS) in avr32dci_ep_init()
2015 pipe->methods = &avr32dci_device_isoc_fs_methods; in avr32dci_ep_init()
2017 pipe->methods = &avr32dci_device_non_isoc_methods; in avr32dci_ep_init()