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.
84 ATMEGA_BUS2SC(USB_DMATAG_TO_XROOT((pc)->tag_parent)->bus)
150 if (sc->sc_flags.clocks_off && in atmegadci_clocks_on()
151 sc->sc_flags.port_powered) { in atmegadci_clocks_on()
155 (sc->sc_clocks_on) (&sc->sc_bus); in atmegadci_clocks_on()
162 sc->sc_flags.clocks_off = 0; in atmegadci_clocks_on()
171 if (!sc->sc_flags.clocks_off) { in atmegadci_clocks_off()
183 (sc->sc_clocks_off) (&sc->sc_bus); in atmegadci_clocks_off()
185 sc->sc_flags.clocks_off = 1; in atmegadci_clocks_off()
194 if (!sc->sc_flags.d_pulled_up && in atmegadci_pull_up()
195 sc->sc_flags.port_powered) { in atmegadci_pull_up()
196 sc->sc_flags.d_pulled_up = 1; in atmegadci_pull_up()
206 if (sc->sc_flags.d_pulled_up) { in atmegadci_pull_down()
207 sc->sc_flags.d_pulled_up = 0; in atmegadci_pull_down()
215 uint8_t temp; in atmegadci_wakeup_peer() local
217 if (!sc->sc_flags.status_suspend) { in atmegadci_wakeup_peer()
221 temp = ATMEGA_READ_1(sc, ATMEGA_UDCON); in atmegadci_wakeup_peer()
222 ATMEGA_WRITE_1(sc, ATMEGA_UDCON, temp | ATMEGA_UDCON_RMWKUP); in atmegadci_wakeup_peer()
226 usb_pause_mtx(&sc->sc_bus.bus_mtx, hz / 125); in atmegadci_wakeup_peer()
247 uint8_t temp; in atmegadci_setup_rx() local
250 sc = ATMEGA_PC2SC(td->pc); in atmegadci_setup_rx()
253 ATMEGA_WRITE_1(sc, ATMEGA_UENUM, td->ep_no); in atmegadci_setup_rx()
256 temp = ATMEGA_READ_1(sc, ATMEGA_UEINTX); in atmegadci_setup_rx()
258 DPRINTFN(5, "UEINTX=0x%02x\n", temp); in atmegadci_setup_rx()
260 if (!(temp & ATMEGA_UEINTX_RXSTPI)) { in atmegadci_setup_rx()
264 td->did_stall = 0; in atmegadci_setup_rx()
274 if (count != td->remainder) { in atmegadci_setup_rx()
289 usbd_copy_in(td->pc, 0, &req, sizeof(req)); in atmegadci_setup_rx()
291 td->offset = sizeof(req); in atmegadci_setup_rx()
292 td->remainder = 0; in atmegadci_setup_rx()
297 sc->sc_dv_addr = req.wValue[0] & 0x7F; in atmegadci_setup_rx()
299 ATMEGA_WRITE_1(sc, ATMEGA_UDADDR, sc->sc_dv_addr); in atmegadci_setup_rx()
301 sc->sc_dv_addr = 0xFF; in atmegadci_setup_rx()
310 if (!td->did_stall) { in atmegadci_setup_rx()
315 td->did_stall = 1; in atmegadci_setup_rx()
317 if (temp & ATMEGA_UEINTX_RXSTPI) { in atmegadci_setup_rx()
332 uint8_t temp; in atmegadci_data_rx() local
340 sc = ATMEGA_PC2SC(td->pc); in atmegadci_data_rx()
343 ATMEGA_WRITE_1(sc, ATMEGA_UENUM, td->ep_no); in atmegadci_data_rx()
348 temp = ATMEGA_READ_1(sc, ATMEGA_UEINTX); in atmegadci_data_rx()
350 DPRINTFN(5, "temp=0x%02x rem=%u\n", temp, td->remainder); in atmegadci_data_rx()
352 if (temp & ATMEGA_UEINTX_RXSTPI) { in atmegadci_data_rx()
353 if (td->remainder == 0) { in atmegadci_data_rx()
364 td->error = 1; in atmegadci_data_rx()
368 if (!(temp & (ATMEGA_UEINTX_FIFOCON | in atmegadci_data_rx()
370 /* no data */ in atmegadci_data_rx()
382 if (count != td->max_packet_size) { in atmegadci_data_rx()
383 if (count < td->max_packet_size) { in atmegadci_data_rx()
385 td->short_pkt = 1; in atmegadci_data_rx()
389 td->error = 1; in atmegadci_data_rx()
394 if (count > td->remainder) { in atmegadci_data_rx()
396 td->error = 1; in atmegadci_data_rx()
400 usbd_get_page(td->pc, td->offset, &buf_res); in atmegadci_data_rx()
411 count -= buf_res.length; in atmegadci_data_rx()
412 td->offset += buf_res.length; in atmegadci_data_rx()
413 td->remainder -= buf_res.length; in atmegadci_data_rx()
423 if ((td->remainder == 0) || got_short) { in atmegadci_data_rx()
424 if (td->short_pkt) { in atmegadci_data_rx()
430 if (--to) { in atmegadci_data_rx()
447 uint8_t temp; in atmegadci_data_tx() local
452 sc = ATMEGA_PC2SC(td->pc); in atmegadci_data_tx()
455 ATMEGA_WRITE_1(sc, ATMEGA_UENUM, td->ep_no); in atmegadci_data_tx()
460 temp = ATMEGA_READ_1(sc, ATMEGA_UEINTX); in atmegadci_data_tx()
462 DPRINTFN(5, "temp=0x%02x rem=%u\n", temp, td->remainder); in atmegadci_data_tx()
464 if (temp & ATMEGA_UEINTX_RXSTPI) { in atmegadci_data_tx()
469 td->error = 1; in atmegadci_data_tx()
473 temp = ATMEGA_READ_1(sc, ATMEGA_UESTA0X); in atmegadci_data_tx()
474 if (temp & 3) { in atmegadci_data_tx()
475 /* cannot write any data - a bank is busy */ in atmegadci_data_tx()
479 count = td->max_packet_size; in atmegadci_data_tx()
480 if (td->remainder < count) { in atmegadci_data_tx()
482 td->short_pkt = 1; in atmegadci_data_tx()
483 count = td->remainder; in atmegadci_data_tx()
486 usbd_get_page(td->pc, td->offset, &buf_res); in atmegadci_data_tx()
497 count -= buf_res.length; in atmegadci_data_tx()
498 td->offset += buf_res.length; in atmegadci_data_tx()
499 td->remainder -= buf_res.length; in atmegadci_data_tx()
509 if (td->remainder == 0) { in atmegadci_data_tx()
510 if (td->short_pkt) { in atmegadci_data_tx()
515 if (--to) { in atmegadci_data_tx()
529 uint8_t temp; in atmegadci_data_tx_sync() local
532 sc = ATMEGA_PC2SC(td->pc); in atmegadci_data_tx_sync()
535 ATMEGA_WRITE_1(sc, ATMEGA_UENUM, td->ep_no); in atmegadci_data_tx_sync()
538 temp = ATMEGA_READ_1(sc, ATMEGA_UEINTX); in atmegadci_data_tx_sync()
540 DPRINTFN(5, "temp=0x%02x\n", temp); in atmegadci_data_tx_sync()
542 if (temp & ATMEGA_UEINTX_RXSTPI) { in atmegadci_data_tx_sync()
551 temp = ATMEGA_READ_1(sc, ATMEGA_UESTA0X); in atmegadci_data_tx_sync()
552 if (temp & 3) { in atmegadci_data_tx_sync()
553 /* cannot write any data - a bank is busy */ in atmegadci_data_tx_sync()
556 if (sc->sc_dv_addr != 0xFF) { in atmegadci_data_tx_sync()
558 atmegadci_set_address(sc, sc->sc_dv_addr); in atmegadci_data_tx_sync()
576 td = xfer->td_transfer_cache; in atmegadci_xfer_do_fifo()
578 if ((td->func) (td)) { in atmegadci_xfer_do_fifo()
582 if (((void *)td) == xfer->td_transfer_last) { in atmegadci_xfer_do_fifo()
585 if (td->error) { in atmegadci_xfer_do_fifo()
587 } else if (td->remainder > 0) { in atmegadci_xfer_do_fifo()
589 * We had a short transfer. If there is no alternate in atmegadci_xfer_do_fifo()
592 if (!td->alt_next) { in atmegadci_xfer_do_fifo()
600 td = td->obj_next; in atmegadci_xfer_do_fifo()
601 xfer->td_transfer_cache = td; in atmegadci_xfer_do_fifo()
618 TAILQ_FOREACH(xfer, &sc->sc_bus.intr_q.head, wait_entry) { in atmegadci_interrupt_poll()
632 if (!sc->sc_flags.status_vbus) { in atmegadci_vbus_interrupt()
633 sc->sc_flags.status_vbus = 1; in atmegadci_vbus_interrupt()
640 if (sc->sc_flags.status_vbus) { in atmegadci_vbus_interrupt()
641 sc->sc_flags.status_vbus = 0; in atmegadci_vbus_interrupt()
642 sc->sc_flags.status_bus_reset = 0; in atmegadci_vbus_interrupt()
643 sc->sc_flags.status_suspend = 0; in atmegadci_vbus_interrupt()
644 sc->sc_flags.change_suspend = 0; in atmegadci_vbus_interrupt()
645 sc->sc_flags.change_connect = 1; in atmegadci_vbus_interrupt()
659 USB_BUS_LOCK(&sc->sc_bus); in atmegadci_interrupt()
674 sc->sc_flags.status_bus_reset = 1; in atmegadci_interrupt()
675 sc->sc_flags.status_suspend = 0; in atmegadci_interrupt()
676 sc->sc_flags.change_suspend = 0; in atmegadci_interrupt()
677 sc->sc_flags.change_connect = 1; in atmegadci_interrupt()
695 if (sc->sc_flags.status_suspend) { in atmegadci_interrupt()
697 sc->sc_flags.status_suspend = 0; in atmegadci_interrupt()
698 sc->sc_flags.change_suspend = 1; in atmegadci_interrupt()
711 if (!sc->sc_flags.status_suspend) { in atmegadci_interrupt()
713 sc->sc_flags.status_suspend = 1; in atmegadci_interrupt()
714 sc->sc_flags.change_suspend = 1; in atmegadci_interrupt()
732 uint8_t temp; in atmegadci_interrupt() local
736 temp = ATMEGA_READ_1(sc, ATMEGA_USBSTA); in atmegadci_interrupt()
737 atmegadci_vbus_interrupt(sc, temp & ATMEGA_USBSTA_VBUS); in atmegadci_interrupt()
747 USB_BUS_UNLOCK(&sc->sc_bus); in atmegadci_interrupt()
751 atmegadci_setup_standard_chain_sub(struct atmegadci_std_temp *temp) in atmegadci_setup_standard_chain_sub() argument
756 td = temp->td_next; in atmegadci_setup_standard_chain_sub()
757 temp->td = td; in atmegadci_setup_standard_chain_sub()
760 temp->td_next = td->obj_next; in atmegadci_setup_standard_chain_sub()
763 td->func = temp->func; in atmegadci_setup_standard_chain_sub()
764 td->pc = temp->pc; in atmegadci_setup_standard_chain_sub()
765 td->offset = temp->offset; in atmegadci_setup_standard_chain_sub()
766 td->remainder = temp->len; in atmegadci_setup_standard_chain_sub()
767 td->error = 0; in atmegadci_setup_standard_chain_sub()
768 td->did_stall = temp->did_stall; in atmegadci_setup_standard_chain_sub()
769 td->short_pkt = temp->short_pkt; in atmegadci_setup_standard_chain_sub()
770 td->alt_next = temp->setup_alt_next; in atmegadci_setup_standard_chain_sub()
776 struct atmegadci_std_temp temp; in atmegadci_setup_standard_chain() local
782 xfer->address, UE_GET_ADDR(xfer->endpointno), in atmegadci_setup_standard_chain()
783 xfer->sumlen, usbd_get_speed(xfer->xroot->udev)); in atmegadci_setup_standard_chain()
785 temp.max_frame_size = xfer->max_frame_size; in atmegadci_setup_standard_chain()
787 td = xfer->td_start[0]; in atmegadci_setup_standard_chain()
788 xfer->td_transfer_first = td; in atmegadci_setup_standard_chain()
789 xfer->td_transfer_cache = td; in atmegadci_setup_standard_chain()
791 /* setup temp */ in atmegadci_setup_standard_chain()
793 temp.pc = NULL; in atmegadci_setup_standard_chain()
794 temp.td = NULL; in atmegadci_setup_standard_chain()
795 temp.td_next = xfer->td_start[0]; in atmegadci_setup_standard_chain()
796 temp.offset = 0; in atmegadci_setup_standard_chain()
797 temp.setup_alt_next = xfer->flags_int.short_frames_ok || in atmegadci_setup_standard_chain()
798 xfer->flags_int.isochronous_xfr; in atmegadci_setup_standard_chain()
799 temp.did_stall = !xfer->flags_int.control_stall; in atmegadci_setup_standard_chain()
803 if (xfer->flags_int.control_xfr) { in atmegadci_setup_standard_chain()
804 if (xfer->flags_int.control_hdr) { in atmegadci_setup_standard_chain()
805 temp.func = &atmegadci_setup_rx; in atmegadci_setup_standard_chain()
806 temp.len = xfer->frlengths[0]; in atmegadci_setup_standard_chain()
807 temp.pc = xfer->frbuffers + 0; in atmegadci_setup_standard_chain()
808 temp.short_pkt = temp.len ? 1 : 0; in atmegadci_setup_standard_chain()
810 if (xfer->nframes == 1) { in atmegadci_setup_standard_chain()
811 /* no STATUS stage yet, SETUP is last */ in atmegadci_setup_standard_chain()
812 if (xfer->flags_int.control_act) in atmegadci_setup_standard_chain()
813 temp.setup_alt_next = 0; in atmegadci_setup_standard_chain()
816 atmegadci_setup_standard_chain_sub(&temp); in atmegadci_setup_standard_chain()
823 if (x != xfer->nframes) { in atmegadci_setup_standard_chain()
824 if (xfer->endpointno & UE_DIR_IN) { in atmegadci_setup_standard_chain()
825 temp.func = &atmegadci_data_tx; in atmegadci_setup_standard_chain()
828 temp.func = &atmegadci_data_rx; in atmegadci_setup_standard_chain()
833 temp.pc = xfer->frbuffers + x; in atmegadci_setup_standard_chain()
837 while (x != xfer->nframes) { in atmegadci_setup_standard_chain()
840 temp.len = xfer->frlengths[x]; in atmegadci_setup_standard_chain()
844 if (x == xfer->nframes) { in atmegadci_setup_standard_chain()
845 if (xfer->flags_int.control_xfr) { in atmegadci_setup_standard_chain()
846 if (xfer->flags_int.control_act) { in atmegadci_setup_standard_chain()
847 temp.setup_alt_next = 0; in atmegadci_setup_standard_chain()
850 temp.setup_alt_next = 0; in atmegadci_setup_standard_chain()
853 if (temp.len == 0) { in atmegadci_setup_standard_chain()
856 temp.short_pkt = 0; in atmegadci_setup_standard_chain()
861 temp.short_pkt = (xfer->flags.force_short_xfer) ? 0 : 1; in atmegadci_setup_standard_chain()
864 atmegadci_setup_standard_chain_sub(&temp); in atmegadci_setup_standard_chain()
866 if (xfer->flags_int.isochronous_xfr) { in atmegadci_setup_standard_chain()
867 temp.offset += temp.len; in atmegadci_setup_standard_chain()
870 temp.pc = xfer->frbuffers + x; in atmegadci_setup_standard_chain()
874 if (xfer->flags_int.control_xfr) { in atmegadci_setup_standard_chain()
876 temp.pc = xfer->frbuffers + 0; in atmegadci_setup_standard_chain()
877 temp.len = 0; in atmegadci_setup_standard_chain()
878 temp.short_pkt = 0; in atmegadci_setup_standard_chain()
879 temp.setup_alt_next = 0; in atmegadci_setup_standard_chain()
884 temp.func = &atmegadci_data_tx_sync; in atmegadci_setup_standard_chain()
885 atmegadci_setup_standard_chain_sub(&temp); in atmegadci_setup_standard_chain()
889 if (!xfer->flags_int.control_act) { in atmegadci_setup_standard_chain()
894 if (xfer->endpointno & UE_DIR_IN) { in atmegadci_setup_standard_chain()
895 temp.func = &atmegadci_data_rx; in atmegadci_setup_standard_chain()
898 temp.func = &atmegadci_data_tx; in atmegadci_setup_standard_chain()
902 atmegadci_setup_standard_chain_sub(&temp); in atmegadci_setup_standard_chain()
905 temp.func = &atmegadci_data_tx_sync; in atmegadci_setup_standard_chain()
906 atmegadci_setup_standard_chain_sub(&temp); in atmegadci_setup_standard_chain()
911 td = temp.td; in atmegadci_setup_standard_chain()
912 xfer->td_transfer_last = td; in atmegadci_setup_standard_chain()
922 USB_BUS_LOCK_ASSERT(xfer->xroot->bus, MA_OWNED); in atmegadci_timeout()
933 /* poll one time - will turn on interrupts */ in atmegadci_start_standard_chain()
936 usbd_transfer_enqueue(&xfer->xroot->bus->intr_q, xfer); in atmegadci_start_standard_chain()
939 if (xfer->timeout != 0) { in atmegadci_start_standard_chain()
941 &atmegadci_timeout, xfer->timeout); in atmegadci_start_standard_chain()
951 USB_BUS_LOCK_ASSERT(&sc->sc_bus, MA_OWNED); in atmegadci_root_intr()
954 sc->sc_hub_idata[0] = 0x02; /* we only have one port */ in atmegadci_root_intr()
956 uhub_root_intr(&sc->sc_bus, sc->sc_hub_idata, in atmegadci_root_intr()
957 sizeof(sc->sc_hub_idata)); in atmegadci_root_intr()
969 td = xfer->td_transfer_cache; in atmegadci_standard_done_sub()
972 len = td->remainder; in atmegadci_standard_done_sub()
974 if (xfer->aframes != xfer->nframes) { in atmegadci_standard_done_sub()
979 if (len > xfer->frlengths[xfer->aframes]) { in atmegadci_standard_done_sub()
980 td->error = 1; in atmegadci_standard_done_sub()
982 xfer->frlengths[xfer->aframes] -= len; in atmegadci_standard_done_sub()
986 if (td->error) { in atmegadci_standard_done_sub()
994 if (xfer->flags_int.short_frames_ok || in atmegadci_standard_done_sub()
995 xfer->flags_int.isochronous_xfr) { in atmegadci_standard_done_sub()
997 if (td->alt_next) { in atmegadci_standard_done_sub()
998 td = td->obj_next; in atmegadci_standard_done_sub()
1009 td = td->obj_next; in atmegadci_standard_done_sub()
1019 xfer->td_transfer_cache = td; in atmegadci_standard_done_sub()
1031 xfer, xfer->endpoint); in atmegadci_standard_done()
1035 xfer->td_transfer_cache = xfer->td_transfer_first; in atmegadci_standard_done()
1037 if (xfer->flags_int.control_xfr) { in atmegadci_standard_done()
1038 if (xfer->flags_int.control_hdr) { in atmegadci_standard_done()
1041 xfer->aframes = 1; in atmegadci_standard_done()
1043 if (xfer->td_transfer_cache == NULL) { in atmegadci_standard_done()
1047 while (xfer->aframes != xfer->nframes) { in atmegadci_standard_done()
1049 xfer->aframes++; in atmegadci_standard_done()
1051 if (xfer->td_transfer_cache == NULL) { in atmegadci_standard_done()
1056 if (xfer->flags_int.control_xfr && in atmegadci_standard_done()
1057 !xfer->flags_int.control_act) { in atmegadci_standard_done()
1064 /*------------------------------------------------------------------------*
1069 *------------------------------------------------------------------------*/
1073 struct atmegadci_softc *sc = ATMEGA_BUS2SC(xfer->xroot->bus); in atmegadci_device_done()
1076 USB_BUS_LOCK_ASSERT(&sc->sc_bus, MA_OWNED); in atmegadci_device_done()
1079 xfer, xfer->endpoint, error); in atmegadci_device_done()
1081 if (xfer->flags_int.usb_mode == USB_MODE_DEVICE) { in atmegadci_device_done()
1082 ep_no = (xfer->endpointno & UE_ADDR); in atmegadci_device_done()
1109 USB_BUS_LOCK_ASSERT(udev->bus, MA_OWNED); in atmegadci_set_stall()
1113 sc = ATMEGA_BUS2SC(udev->bus); in atmegadci_set_stall()
1115 ep_no = (ep->edesc->bEndpointAddress & UE_ADDR); in atmegadci_set_stall()
1128 uint8_t temp; in atmegadci_clear_stall_sub() local
1160 temp = ATMEGA_UECFG0X_EPTYPE2; in atmegadci_clear_stall_sub()
1162 temp = ATMEGA_UECFG0X_EPTYPE3; in atmegadci_clear_stall_sub()
1164 temp = ATMEGA_UECFG0X_EPTYPE1; in atmegadci_clear_stall_sub()
1167 temp |= ATMEGA_UECFG0X_EPDIR; in atmegadci_clear_stall_sub()
1169 /* two banks, 64-bytes wMaxPacket */ in atmegadci_clear_stall_sub()
1170 ATMEGA_WRITE_1(sc, ATMEGA_UECFG0X, temp); in atmegadci_clear_stall_sub()
1176 temp = ATMEGA_READ_1(sc, ATMEGA_UESTA0X); in atmegadci_clear_stall_sub()
1177 if (!(temp & ATMEGA_UESTA0X_CFGOK)) { in atmegadci_clear_stall_sub()
1178 device_printf(sc->sc_bus.bdev, in atmegadci_clear_stall_sub()
1192 USB_BUS_LOCK_ASSERT(udev->bus, MA_OWNED); in atmegadci_clear_stall()
1195 if (udev->flags.usb_mode != USB_MODE_DEVICE) { in atmegadci_clear_stall()
1200 sc = ATMEGA_BUS2SC(udev->bus); in atmegadci_clear_stall()
1203 ed = ep->edesc; in atmegadci_clear_stall()
1207 (ed->bEndpointAddress & UE_ADDR), in atmegadci_clear_stall()
1208 (ed->bmAttributes & UE_XFERTYPE), in atmegadci_clear_stall()
1209 (ed->bEndpointAddress & (UE_DIR_IN | UE_DIR_OUT))); in atmegadci_clear_stall()
1220 sc->sc_bus.usbrev = USB_REV_1_1; in atmegadci_init()
1221 sc->sc_bus.methods = &atmegadci_bus_methods; in atmegadci_init()
1223 USB_BUS_LOCK(&sc->sc_bus); in atmegadci_init()
1235 /* the following register sets up the USB PLL, assuming 16MHz X-tal */ in atmegadci_init()
1243 usb_pause_mtx(&sc->sc_bus.bus_mtx, hz / 100); in atmegadci_init()
1253 (sc->sc_clocks_on) (&sc->sc_bus); in atmegadci_init()
1255 /* make sure device is re-enumerated */ in atmegadci_init()
1259 usb_pause_mtx(&sc->sc_bus.bus_mtx, hz / 20); in atmegadci_init()
1268 (1 << ATMEGA_EP_MAX) - 1); in atmegadci_init()
1294 USB_BUS_UNLOCK(&sc->sc_bus); in atmegadci_init()
1298 atmegadci_do_poll(&sc->sc_bus); in atmegadci_init()
1306 USB_BUS_LOCK(&sc->sc_bus); in atmegadci_uninit()
1309 (sc->sc_clocks_on) (&sc->sc_bus); in atmegadci_uninit()
1316 (1 << ATMEGA_EP_MAX) - 1); in atmegadci_uninit()
1321 sc->sc_flags.port_powered = 0; in atmegadci_uninit()
1322 sc->sc_flags.status_vbus = 0; in atmegadci_uninit()
1323 sc->sc_flags.status_bus_reset = 0; in atmegadci_uninit()
1324 sc->sc_flags.status_suspend = 0; in atmegadci_uninit()
1325 sc->sc_flags.change_suspend = 0; in atmegadci_uninit()
1326 sc->sc_flags.change_connect = 1; in atmegadci_uninit()
1334 USB_BUS_UNLOCK(&sc->sc_bus); in atmegadci_uninit()
1354 USB_BUS_LOCK(&sc->sc_bus); in atmegadci_do_poll()
1356 USB_BUS_UNLOCK(&sc->sc_bus); in atmegadci_do_poll()
1359 /*------------------------------------------------------------------------*
1360 * atmegadci bulk support
1361 * atmegadci control support
1362 * atmegadci interrupt support
1363 *------------------------------------------------------------------------*/
1398 /*------------------------------------------------------------------------*
1399 * atmegadci full speed isochronous support
1400 *------------------------------------------------------------------------*/
1416 struct atmegadci_softc *sc = ATMEGA_BUS2SC(xfer->xroot->bus); in atmegadci_device_isoc_fs_enter()
1420 xfer, xfer->endpoint->isoc_next, xfer->nframes); in atmegadci_device_isoc_fs_enter()
1430 DPRINTFN(3, "start next=%d\n", xfer->endpoint->isoc_next); in atmegadci_device_isoc_fs_enter()
1451 /*------------------------------------------------------------------------*
1452 * atmegadci root control support
1453 *------------------------------------------------------------------------*
1455 *------------------------------------------------------------------------*/
1524 struct atmegadci_softc *sc = ATMEGA_BUS2SC(udev->bus); in atmegadci_roothub_exec()
1529 uint8_t temp; in atmegadci_roothub_exec() local
1532 USB_BUS_LOCK_ASSERT(&sc->sc_bus, MA_OWNED); in atmegadci_roothub_exec()
1535 ptr = (const void *)&sc->sc_hub_temp; in atmegadci_roothub_exec()
1539 value = UGETW(req->wValue); in atmegadci_roothub_exec()
1540 index = UGETW(req->wIndex); in atmegadci_roothub_exec()
1544 switch (req->bmRequestType) { in atmegadci_roothub_exec()
1546 switch (req->bRequest) { in atmegadci_roothub_exec()
1559 switch (req->bRequest) { in atmegadci_roothub_exec()
1575 switch (req->bRequest) { in atmegadci_roothub_exec()
1577 switch (UGETW(req->wValue)) { in atmegadci_roothub_exec()
1587 switch (UGETW(req->wValue)) { in atmegadci_roothub_exec()
1604 switch (req->bRequest) { in atmegadci_roothub_exec()
1613 switch (req->bRequest) { in atmegadci_roothub_exec()
1625 switch (req->bRequest) { in atmegadci_roothub_exec()
1646 switch (req->bRequest) { in atmegadci_roothub_exec()
1658 switch (req->bRequest) { in atmegadci_roothub_exec()
1674 switch (req->bRequest) { in atmegadci_roothub_exec()
1685 switch (req->bRequest) { in atmegadci_roothub_exec()
1743 sc->sc_hub_temp.wValue[0] = sc->sc_conf; in atmegadci_roothub_exec()
1748 USETW(sc->sc_hub_temp.wValue, UDS_SELF_POWERED); in atmegadci_roothub_exec()
1755 sc->sc_rt_addr = value; in atmegadci_roothub_exec()
1762 sc->sc_conf = value; in atmegadci_roothub_exec()
1767 sc->sc_hub_temp.wValue[0] = 0; in atmegadci_roothub_exec()
1775 USETW(sc->sc_hub_temp.wValue, 0); in atmegadci_roothub_exec()
1797 sc->sc_flags.port_enabled = 0; in atmegadci_roothub_exec()
1808 sc->sc_flags.port_powered = 0; in atmegadci_roothub_exec()
1814 sc->sc_flags.change_connect = 0; in atmegadci_roothub_exec()
1816 if (!sc->sc_flags.status_bus_reset) { in atmegadci_roothub_exec()
1837 /* one bank, 64-bytes wMaxPacket */ in atmegadci_roothub_exec()
1846 temp = ATMEGA_READ_1(sc, ATMEGA_UESTA0X); in atmegadci_roothub_exec()
1847 if (!(temp & ATMEGA_UESTA0X_CFGOK)) { in atmegadci_roothub_exec()
1848 device_printf(sc->sc_bus.bdev, in atmegadci_roothub_exec()
1853 sc->sc_flags.change_suspend = 0; in atmegadci_roothub_exec()
1869 sc->sc_flags.port_enabled = 1; in atmegadci_roothub_exec()
1878 sc->sc_flags.port_powered = 1; in atmegadci_roothub_exec()
1893 if (sc->sc_flags.status_vbus) { in atmegadci_roothub_exec()
1901 /* Select FULL-speed and Device Side Mode */ in atmegadci_roothub_exec()
1905 if (sc->sc_flags.port_powered) { in atmegadci_roothub_exec()
1908 if (sc->sc_flags.port_enabled) { in atmegadci_roothub_exec()
1911 if (sc->sc_flags.status_vbus && in atmegadci_roothub_exec()
1912 sc->sc_flags.status_bus_reset) { in atmegadci_roothub_exec()
1915 if (sc->sc_flags.status_suspend) { in atmegadci_roothub_exec()
1918 USETW(sc->sc_hub_temp.ps.wPortStatus, value); in atmegadci_roothub_exec()
1922 if (sc->sc_flags.change_connect) { in atmegadci_roothub_exec()
1925 if (sc->sc_flags.change_suspend) { in atmegadci_roothub_exec()
1928 USETW(sc->sc_hub_temp.ps.wPortChange, value); in atmegadci_roothub_exec()
1929 len = sizeof(sc->sc_hub_temp.ps); in atmegadci_roothub_exec()
1959 xfer = parm->curr_xfer; in atmegadci_xfer_setup()
1966 parm->hc_max_packet_size = 0x500; in atmegadci_xfer_setup()
1967 parm->hc_max_packet_count = 1; in atmegadci_xfer_setup()
1968 parm->hc_max_frame_size = 0x500; in atmegadci_xfer_setup()
1975 if ((xfer->endpoint->edesc->bmAttributes & UE_XFERTYPE) == UE_CONTROL) { in atmegadci_xfer_setup()
1976 ntd = xfer->nframes + 1 /* STATUS */ + 1 /* SYNC 1 */ in atmegadci_xfer_setup()
1979 ntd = xfer->nframes + 1 /* SYNC */ ; in atmegadci_xfer_setup()
1985 if (parm->err) in atmegadci_xfer_setup()
1996 ep_no = xfer->endpointno & UE_ADDR; in atmegadci_xfer_setup()
1997 atmegadci_get_hw_ep_profile(parm->udev, &pf, ep_no); in atmegadci_xfer_setup()
2001 parm->err = USB_ERR_INVAL; in atmegadci_xfer_setup()
2006 parm->size[0] += ((-parm->size[0]) & (USB_HOST_ALIGN - 1)); in atmegadci_xfer_setup()
2011 if (parm->buf) { in atmegadci_xfer_setup()
2012 td = USB_ADD_BYTES(parm->buf, parm->size[0]); in atmegadci_xfer_setup()
2015 td->max_packet_size = xfer->max_packet_size; in atmegadci_xfer_setup()
2016 td->ep_no = ep_no; in atmegadci_xfer_setup()
2017 if (pf->support_multi_buffer) { in atmegadci_xfer_setup()
2018 td->support_multi_buffer = 1; in atmegadci_xfer_setup()
2020 td->obj_next = last_obj; in atmegadci_xfer_setup()
2024 parm->size[0] += sizeof(*td); in atmegadci_xfer_setup()
2027 xfer->td_start[0] = last_obj; in atmegadci_xfer_setup()
2040 struct atmegadci_softc *sc = ATMEGA_BUS2SC(udev->bus); in atmegadci_ep_init()
2043 ep, udev->address, in atmegadci_ep_init()
2044 edesc->bEndpointAddress, udev->flags.usb_mode, in atmegadci_ep_init()
2045 sc->sc_rt_addr, udev->device_index); in atmegadci_ep_init()
2047 if (udev->device_index != sc->sc_rt_addr) { in atmegadci_ep_init()
2048 if (udev->speed != USB_SPEED_FULL) { in atmegadci_ep_init()
2052 if ((edesc->bmAttributes & UE_XFERTYPE) == UE_ISOCHRONOUS) in atmegadci_ep_init()
2053 ep->methods = &atmegadci_device_isoc_fs_methods; in atmegadci_ep_init()
2055 ep->methods = &atmegadci_device_non_isoc_methods; in atmegadci_ep_init()