Lines Matching +full:double +full:- +full:channel

1 /*-
2 * SPDX-License-Identifier: BSD-2-Clause
35 * 2.0 High Speed Dual-Role controller.
87 MUSBOTG_BUS2SC(USB_DMATAG_TO_XROOT((pc)->tag_parent)->bus)
136 static void musbotg_ep_int_set(struct musbotg_softc *sc, int channel, int on);
167 .ep_end = -1,
177 ep = td->ep_no; in musbotg_channel_alloc()
179 /* In device mode each EP got its own channel */ in musbotg_channel_alloc()
180 if (sc->sc_mode == MUSB2_DEVICE_MODE) { in musbotg_channel_alloc()
189 if (sc->sc_channel_mask & (1 << 0)) in musbotg_channel_alloc()
190 return (-1); in musbotg_channel_alloc()
191 sc->sc_channel_mask |= (1 << 0); in musbotg_channel_alloc()
196 for (ch = sc->sc_ep_max; ch != 0; ch--) { in musbotg_channel_alloc()
197 if (sc->sc_channel_mask & (1 << ch)) in musbotg_channel_alloc()
202 if (td->max_frame_size > in musbotg_channel_alloc()
203 sc->sc_hw_ep_profile[ch].max_in_frame_size) in musbotg_channel_alloc()
206 if (td->max_frame_size > in musbotg_channel_alloc()
207 sc->sc_hw_ep_profile[ch].max_out_frame_size) in musbotg_channel_alloc()
210 sc->sc_channel_mask |= (1 << ch); in musbotg_channel_alloc()
215 DPRINTFN(-1, "No available channels. Mask: %04x\n", sc->sc_channel_mask); in musbotg_channel_alloc()
217 return (-1); in musbotg_channel_alloc()
224 DPRINTFN(1, "ep_no=%d\n", td->channel); in musbotg_channel_free()
226 if (sc->sc_mode == MUSB2_DEVICE_MODE) in musbotg_channel_free()
231 if (td->channel == -1) in musbotg_channel_free()
234 musbotg_ep_int_set(sc, td->channel, 0); in musbotg_channel_free()
235 sc->sc_channel_mask &= ~(1 << td->channel); in musbotg_channel_free()
237 td->channel = -1; in musbotg_channel_free()
246 sc = MUSBOTG_BUS2SC(udev->bus); in musbotg_get_hw_ep_profile()
251 } else if (ep_addr <= sc->sc_ep_max) { in musbotg_get_hw_ep_profile()
253 *ppf = sc->sc_hw_ep_profile + ep_addr; in musbotg_get_hw_ep_profile()
262 if (sc->sc_flags.clocks_off && in musbotg_clocks_on()
263 sc->sc_flags.port_powered) { in musbotg_clocks_on()
266 if (sc->sc_clocks_on) { in musbotg_clocks_on()
267 (sc->sc_clocks_on) (sc->sc_clocks_arg); in musbotg_clocks_on()
269 sc->sc_flags.clocks_off = 0; in musbotg_clocks_on()
278 if (!sc->sc_flags.clocks_off) { in musbotg_clocks_off()
283 if (sc->sc_clocks_off) { in musbotg_clocks_off()
284 (sc->sc_clocks_off) (sc->sc_clocks_arg); in musbotg_clocks_off()
286 sc->sc_flags.clocks_off = 1; in musbotg_clocks_off()
309 if (!sc->sc_flags.d_pulled_up && in musbotg_pull_up()
310 sc->sc_flags.port_powered) { in musbotg_pull_up()
311 sc->sc_flags.d_pulled_up = 1; in musbotg_pull_up()
321 if (sc->sc_flags.d_pulled_up) { in musbotg_pull_down()
322 sc->sc_flags.d_pulled_up = 0; in musbotg_pull_down()
332 if (sc->sc_flags.status_suspend) { in musbotg_suspend_host()
339 sc->sc_flags.status_suspend = 1; in musbotg_suspend_host()
347 if (!(sc->sc_flags.status_suspend)) { in musbotg_wakeup_host()
358 usb_pause_mtx(&sc->sc_bus.bus_mtx, hz / 50); in musbotg_wakeup_host()
364 sc->sc_flags.status_suspend = 0; in musbotg_wakeup_host()
372 if (!(sc->sc_flags.status_suspend)) { in musbotg_wakeup_peer()
382 usb_pause_mtx(&sc->sc_bus.bus_mtx, hz / 125); in musbotg_wakeup_peer()
406 sc = MUSBOTG_PC2SC(td->pc); in musbotg_dev_ctrl_setup_rx()
408 if (td->channel == -1) in musbotg_dev_ctrl_setup_rx()
409 td->channel = musbotg_channel_alloc(sc, td, 0); in musbotg_dev_ctrl_setup_rx()
412 if (td->channel == -1) in musbotg_dev_ctrl_setup_rx()
415 DPRINTFN(1, "ep_no=%d\n", td->channel); in musbotg_dev_ctrl_setup_rx()
431 td->did_stall = 1; in musbotg_dev_ctrl_setup_rx()
443 sc->sc_ep0_busy = 0; in musbotg_dev_ctrl_setup_rx()
452 sc->sc_ep0_busy = 0; in musbotg_dev_ctrl_setup_rx()
454 if (sc->sc_ep0_busy) { in musbotg_dev_ctrl_setup_rx()
465 if (count != td->remainder) { in musbotg_dev_ctrl_setup_rx()
471 td->did_stall = 1; in musbotg_dev_ctrl_setup_rx()
480 td->did_stall = 1; in musbotg_dev_ctrl_setup_rx()
484 td->did_stall = 0; in musbotg_dev_ctrl_setup_rx()
487 bus_space_read_multi_1(sc->sc_io_tag, sc->sc_io_hdl, in musbotg_dev_ctrl_setup_rx()
491 usbd_copy_in(td->pc, 0, &req, sizeof(req)); in musbotg_dev_ctrl_setup_rx()
493 td->offset = sizeof(req); in musbotg_dev_ctrl_setup_rx()
494 td->remainder = 0; in musbotg_dev_ctrl_setup_rx()
497 sc->sc_ep0_cmd = MUSB2_MASK_CSR0L_RXPKTRDY_CLR; in musbotg_dev_ctrl_setup_rx()
500 sc->sc_ep0_busy = 1; in musbotg_dev_ctrl_setup_rx()
505 sc->sc_dv_addr = req.wValue[0] & 0x7F; in musbotg_dev_ctrl_setup_rx()
507 sc->sc_dv_addr = 0xFF; in musbotg_dev_ctrl_setup_rx()
515 if (!td->did_stall) { in musbotg_dev_ctrl_setup_rx()
519 td->did_stall = 1; in musbotg_dev_ctrl_setup_rx()
532 sc = MUSBOTG_PC2SC(td->pc); in musbotg_host_ctrl_setup_tx()
534 if (td->channel == -1) in musbotg_host_ctrl_setup_tx()
535 td->channel = musbotg_channel_alloc(sc, td, 1); in musbotg_host_ctrl_setup_tx()
538 if (td->channel == -1) in musbotg_host_ctrl_setup_tx()
541 DPRINTFN(1, "ep_no=%d\n", td->channel); in musbotg_host_ctrl_setup_tx()
561 td->error = 1; in musbotg_host_ctrl_setup_tx()
583 td->error = 1; in musbotg_host_ctrl_setup_tx()
586 if (td->error) { in musbotg_host_ctrl_setup_tx()
596 if (td->remainder == 0) { in musbotg_host_ctrl_setup_tx()
603 usbd_copy_out(td->pc, 0, &req, sizeof(req)); in musbotg_host_ctrl_setup_tx()
606 bus_space_write_multi_1(sc->sc_io_tag, sc->sc_io_hdl, in musbotg_host_ctrl_setup_tx()
610 td->offset += sizeof(req); in musbotg_host_ctrl_setup_tx()
611 td->remainder -= sizeof(req); in musbotg_host_ctrl_setup_tx()
614 MUSB2_WRITE_1(sc, MUSB2_REG_TXFADDR(0), td->dev_addr); in musbotg_host_ctrl_setup_tx()
615 MUSB2_WRITE_1(sc, MUSB2_REG_TXHADDR(0), td->haddr); in musbotg_host_ctrl_setup_tx()
616 MUSB2_WRITE_1(sc, MUSB2_REG_TXHUBPORT(0), td->hport); in musbotg_host_ctrl_setup_tx()
617 MUSB2_WRITE_1(sc, MUSB2_REG_TXTI, td->transfer_type); in musbotg_host_ctrl_setup_tx()
625 td->transaction_started = 1; in musbotg_host_ctrl_setup_tx()
642 sc = MUSBOTG_PC2SC(td->pc); in musbotg_dev_ctrl_data_rx()
648 if (sc->sc_ep0_cmd) { in musbotg_dev_ctrl_data_rx()
649 MUSB2_WRITE_1(sc, MUSB2_REG_TXCSRL, sc->sc_ep0_cmd); in musbotg_dev_ctrl_data_rx()
650 sc->sc_ep0_cmd = 0; in musbotg_dev_ctrl_data_rx()
661 if (td->remainder == 0) { in musbotg_dev_ctrl_data_rx()
672 td->error = 1; in musbotg_dev_ctrl_data_rx()
682 if (count != td->max_frame_size) { in musbotg_dev_ctrl_data_rx()
683 if (count < td->max_frame_size) { in musbotg_dev_ctrl_data_rx()
685 td->short_pkt = 1; in musbotg_dev_ctrl_data_rx()
689 td->error = 1; in musbotg_dev_ctrl_data_rx()
694 if (count > td->remainder) { in musbotg_dev_ctrl_data_rx()
696 td->error = 1; in musbotg_dev_ctrl_data_rx()
702 usbd_get_page(td->pc, td->offset, &buf_res); in musbotg_dev_ctrl_data_rx()
714 bus_space_read_multi_4(sc->sc_io_tag, sc->sc_io_hdl, in musbotg_dev_ctrl_data_rx()
715 MUSB2_REG_EPFIFO(0), sc->sc_bounce_buf, in musbotg_dev_ctrl_data_rx()
721 bus_space_read_multi_1(sc->sc_io_tag, sc->sc_io_hdl, in musbotg_dev_ctrl_data_rx()
723 (void *)(&sc->sc_bounce_buf[count / 4]), temp); in musbotg_dev_ctrl_data_rx()
725 usbd_copy_in(td->pc, td->offset, in musbotg_dev_ctrl_data_rx()
726 sc->sc_bounce_buf, count); in musbotg_dev_ctrl_data_rx()
729 td->offset += count; in musbotg_dev_ctrl_data_rx()
730 td->remainder -= count; in musbotg_dev_ctrl_data_rx()
736 bus_space_read_multi_4(sc->sc_io_tag, sc->sc_io_hdl, in musbotg_dev_ctrl_data_rx()
743 count -= temp; in musbotg_dev_ctrl_data_rx()
744 td->offset += temp; in musbotg_dev_ctrl_data_rx()
745 td->remainder -= temp; in musbotg_dev_ctrl_data_rx()
749 bus_space_read_multi_1(sc->sc_io_tag, sc->sc_io_hdl, in musbotg_dev_ctrl_data_rx()
753 count -= buf_res.length; in musbotg_dev_ctrl_data_rx()
754 td->offset += buf_res.length; in musbotg_dev_ctrl_data_rx()
755 td->remainder -= buf_res.length; in musbotg_dev_ctrl_data_rx()
759 if ((td->remainder == 0) || got_short) { in musbotg_dev_ctrl_data_rx()
760 if (td->short_pkt) { in musbotg_dev_ctrl_data_rx()
762 sc->sc_ep0_cmd = MUSB2_MASK_CSR0L_RXPKTRDY_CLR; in musbotg_dev_ctrl_data_rx()
767 /* write command - need more data */ in musbotg_dev_ctrl_data_rx()
782 sc = MUSBOTG_PC2SC(td->pc); in musbotg_dev_ctrl_data_tx()
788 if (sc->sc_ep0_cmd) { in musbotg_dev_ctrl_data_tx()
789 MUSB2_WRITE_1(sc, MUSB2_REG_TXCSRL, sc->sc_ep0_cmd); in musbotg_dev_ctrl_data_tx()
790 sc->sc_ep0_cmd = 0; in musbotg_dev_ctrl_data_tx()
803 td->error = 1; in musbotg_dev_ctrl_data_tx()
809 count = td->max_frame_size; in musbotg_dev_ctrl_data_tx()
810 if (td->remainder < count) { in musbotg_dev_ctrl_data_tx()
812 td->short_pkt = 1; in musbotg_dev_ctrl_data_tx()
813 count = td->remainder; in musbotg_dev_ctrl_data_tx()
818 usbd_get_page(td->pc, td->offset, &buf_res); in musbotg_dev_ctrl_data_tx()
826 usbd_copy_out(td->pc, td->offset, in musbotg_dev_ctrl_data_tx()
827 sc->sc_bounce_buf, count); in musbotg_dev_ctrl_data_tx()
833 bus_space_write_multi_4(sc->sc_io_tag, sc->sc_io_hdl, in musbotg_dev_ctrl_data_tx()
834 MUSB2_REG_EPFIFO(0), sc->sc_bounce_buf, in musbotg_dev_ctrl_data_tx()
840 bus_space_write_multi_1(sc->sc_io_tag, sc->sc_io_hdl, in musbotg_dev_ctrl_data_tx()
842 ((void *)&sc->sc_bounce_buf[count / 4]), temp); in musbotg_dev_ctrl_data_tx()
845 td->offset += count; in musbotg_dev_ctrl_data_tx()
846 td->remainder -= count; in musbotg_dev_ctrl_data_tx()
852 bus_space_write_multi_4(sc->sc_io_tag, sc->sc_io_hdl, in musbotg_dev_ctrl_data_tx()
859 count -= temp; in musbotg_dev_ctrl_data_tx()
860 td->offset += temp; in musbotg_dev_ctrl_data_tx()
861 td->remainder -= temp; in musbotg_dev_ctrl_data_tx()
865 bus_space_write_multi_1(sc->sc_io_tag, sc->sc_io_hdl, in musbotg_dev_ctrl_data_tx()
869 count -= buf_res.length; in musbotg_dev_ctrl_data_tx()
870 td->offset += buf_res.length; in musbotg_dev_ctrl_data_tx()
871 td->remainder -= buf_res.length; in musbotg_dev_ctrl_data_tx()
875 if (td->remainder == 0) { in musbotg_dev_ctrl_data_tx()
876 if (td->short_pkt) { in musbotg_dev_ctrl_data_tx()
877 sc->sc_ep0_cmd = MUSB2_MASK_CSR0L_TXPKTRDY; in musbotg_dev_ctrl_data_tx()
899 sc = MUSBOTG_PC2SC(td->pc); in musbotg_host_ctrl_data_rx()
901 if (td->channel == -1) in musbotg_host_ctrl_data_rx()
902 td->channel = musbotg_channel_alloc(sc, td, 0); in musbotg_host_ctrl_data_rx()
905 if (td->channel == -1) in musbotg_host_ctrl_data_rx()
908 DPRINTFN(1, "ep_no=%d\n", td->channel); in musbotg_host_ctrl_data_rx()
919 if (!td->transaction_started) { in musbotg_host_ctrl_data_rx()
920 td->transaction_started = 1; in musbotg_host_ctrl_data_rx()
925 td->dev_addr); in musbotg_host_ctrl_data_rx()
926 MUSB2_WRITE_1(sc, MUSB2_REG_RXHADDR(0), td->haddr); in musbotg_host_ctrl_data_rx()
927 MUSB2_WRITE_1(sc, MUSB2_REG_RXHUBPORT(0), td->hport); in musbotg_host_ctrl_data_rx()
928 MUSB2_WRITE_1(sc, MUSB2_REG_RXTI, td->transfer_type); in musbotg_host_ctrl_data_rx()
943 td->error = 1; in musbotg_host_ctrl_data_rx()
953 td->error = 1; in musbotg_host_ctrl_data_rx()
956 if (td->error) { in musbotg_host_ctrl_data_rx()
968 if (count != td->max_frame_size) { in musbotg_host_ctrl_data_rx()
969 if (count < td->max_frame_size) { in musbotg_host_ctrl_data_rx()
971 td->short_pkt = 1; in musbotg_host_ctrl_data_rx()
975 td->error = 1; in musbotg_host_ctrl_data_rx()
981 if (count > td->remainder) { in musbotg_host_ctrl_data_rx()
983 td->error = 1; in musbotg_host_ctrl_data_rx()
990 usbd_get_page(td->pc, td->offset, &buf_res); in musbotg_host_ctrl_data_rx()
1002 bus_space_read_multi_4(sc->sc_io_tag, sc->sc_io_hdl, in musbotg_host_ctrl_data_rx()
1003 MUSB2_REG_EPFIFO(0), sc->sc_bounce_buf, in musbotg_host_ctrl_data_rx()
1009 bus_space_read_multi_1(sc->sc_io_tag, sc->sc_io_hdl, in musbotg_host_ctrl_data_rx()
1011 (void *)(&sc->sc_bounce_buf[count / 4]), temp); in musbotg_host_ctrl_data_rx()
1013 usbd_copy_in(td->pc, td->offset, in musbotg_host_ctrl_data_rx()
1014 sc->sc_bounce_buf, count); in musbotg_host_ctrl_data_rx()
1017 td->offset += count; in musbotg_host_ctrl_data_rx()
1018 td->remainder -= count; in musbotg_host_ctrl_data_rx()
1024 bus_space_read_multi_4(sc->sc_io_tag, sc->sc_io_hdl, in musbotg_host_ctrl_data_rx()
1031 count -= temp; in musbotg_host_ctrl_data_rx()
1032 td->offset += temp; in musbotg_host_ctrl_data_rx()
1033 td->remainder -= temp; in musbotg_host_ctrl_data_rx()
1037 bus_space_read_multi_1(sc->sc_io_tag, sc->sc_io_hdl, in musbotg_host_ctrl_data_rx()
1041 count -= buf_res.length; in musbotg_host_ctrl_data_rx()
1042 td->offset += buf_res.length; in musbotg_host_ctrl_data_rx()
1043 td->remainder -= buf_res.length; in musbotg_host_ctrl_data_rx()
1050 if ((td->remainder == 0) || got_short) { in musbotg_host_ctrl_data_rx()
1051 if (td->short_pkt) { in musbotg_host_ctrl_data_rx()
1060 td->transaction_started = 1; in musbotg_host_ctrl_data_rx()
1076 sc = MUSBOTG_PC2SC(td->pc); in musbotg_host_ctrl_data_tx()
1078 if (td->channel == -1) in musbotg_host_ctrl_data_tx()
1079 td->channel = musbotg_channel_alloc(sc, td, 1); in musbotg_host_ctrl_data_tx()
1082 if (td->channel == -1) in musbotg_host_ctrl_data_tx()
1085 DPRINTFN(1, "ep_no=%d\n", td->channel); in musbotg_host_ctrl_data_tx()
1098 td->error = 1; in musbotg_host_ctrl_data_tx()
1118 td->error = 1; in musbotg_host_ctrl_data_tx()
1121 if (td->error) { in musbotg_host_ctrl_data_tx()
1139 if (td->transaction_started) { in musbotg_host_ctrl_data_tx()
1141 if (td->remainder == 0) { in musbotg_host_ctrl_data_tx()
1142 if (td->short_pkt) { in musbotg_host_ctrl_data_tx()
1149 /* We're not complete - more transactions required */ in musbotg_host_ctrl_data_tx()
1150 td->transaction_started = 0; in musbotg_host_ctrl_data_tx()
1154 count = td->max_frame_size; in musbotg_host_ctrl_data_tx()
1155 if (td->remainder < count) { in musbotg_host_ctrl_data_tx()
1157 td->short_pkt = 1; in musbotg_host_ctrl_data_tx()
1158 count = td->remainder; in musbotg_host_ctrl_data_tx()
1164 usbd_get_page(td->pc, td->offset, &buf_res); in musbotg_host_ctrl_data_tx()
1172 usbd_copy_out(td->pc, td->offset, in musbotg_host_ctrl_data_tx()
1173 sc->sc_bounce_buf, count); in musbotg_host_ctrl_data_tx()
1179 bus_space_write_multi_4(sc->sc_io_tag, in musbotg_host_ctrl_data_tx()
1180 sc->sc_io_hdl, MUSB2_REG_EPFIFO(0), in musbotg_host_ctrl_data_tx()
1181 sc->sc_bounce_buf, temp / 4); in musbotg_host_ctrl_data_tx()
1186 bus_space_write_multi_1(sc->sc_io_tag, sc->sc_io_hdl, in musbotg_host_ctrl_data_tx()
1188 ((void *)&sc->sc_bounce_buf[count / 4]), temp); in musbotg_host_ctrl_data_tx()
1191 td->offset += count; in musbotg_host_ctrl_data_tx()
1192 td->remainder -= count; in musbotg_host_ctrl_data_tx()
1198 bus_space_write_multi_4(sc->sc_io_tag, sc->sc_io_hdl, in musbotg_host_ctrl_data_tx()
1205 count -= temp; in musbotg_host_ctrl_data_tx()
1206 td->offset += temp; in musbotg_host_ctrl_data_tx()
1207 td->remainder -= temp; in musbotg_host_ctrl_data_tx()
1211 bus_space_write_multi_1(sc->sc_io_tag, sc->sc_io_hdl, in musbotg_host_ctrl_data_tx()
1216 count -= buf_res.length; in musbotg_host_ctrl_data_tx()
1217 td->offset += buf_res.length; in musbotg_host_ctrl_data_tx()
1218 td->remainder -= buf_res.length; in musbotg_host_ctrl_data_tx()
1222 MUSB2_WRITE_1(sc, MUSB2_REG_TXFADDR(0), td->dev_addr); in musbotg_host_ctrl_data_tx()
1223 MUSB2_WRITE_1(sc, MUSB2_REG_TXHADDR(0), td->haddr); in musbotg_host_ctrl_data_tx()
1224 MUSB2_WRITE_1(sc, MUSB2_REG_TXHUBPORT(0), td->hport); in musbotg_host_ctrl_data_tx()
1225 MUSB2_WRITE_1(sc, MUSB2_REG_TXTI, td->transfer_type); in musbotg_host_ctrl_data_tx()
1234 td->transaction_started = 1; in musbotg_host_ctrl_data_tx()
1246 sc = MUSBOTG_PC2SC(td->pc); in musbotg_dev_ctrl_status()
1251 if (sc->sc_ep0_busy) { in musbotg_dev_ctrl_status()
1252 sc->sc_ep0_busy = 0; in musbotg_dev_ctrl_status()
1253 sc->sc_ep0_cmd |= MUSB2_MASK_CSR0L_DATAEND; in musbotg_dev_ctrl_status()
1254 MUSB2_WRITE_1(sc, MUSB2_REG_TXCSRL, sc->sc_ep0_cmd); in musbotg_dev_ctrl_status()
1255 sc->sc_ep0_cmd = 0; in musbotg_dev_ctrl_status()
1266 if (sc->sc_dv_addr != 0xFF) { in musbotg_dev_ctrl_status()
1268 musbotg_set_address(sc, sc->sc_dv_addr); in musbotg_dev_ctrl_status()
1282 sc = MUSBOTG_PC2SC(td->pc); in musbotg_host_ctrl_status_rx()
1284 if (td->channel == -1) in musbotg_host_ctrl_status_rx()
1285 td->channel = musbotg_channel_alloc(sc, td, 0); in musbotg_host_ctrl_status_rx()
1288 if (td->channel == -1) in musbotg_host_ctrl_status_rx()
1291 DPRINTFN(1, "ep_no=%d\n", td->channel); in musbotg_host_ctrl_status_rx()
1296 if (!td->transaction_started) { in musbotg_host_ctrl_status_rx()
1298 td->dev_addr); in musbotg_host_ctrl_status_rx()
1300 MUSB2_WRITE_1(sc, MUSB2_REG_RXHADDR(0), td->haddr); in musbotg_host_ctrl_status_rx()
1301 MUSB2_WRITE_1(sc, MUSB2_REG_RXHUBPORT(0), td->hport); in musbotg_host_ctrl_status_rx()
1302 MUSB2_WRITE_1(sc, MUSB2_REG_RXTI, td->transfer_type); in musbotg_host_ctrl_status_rx()
1307 td->transaction_started = 1; in musbotg_host_ctrl_status_rx()
1340 td->error = 1; in musbotg_host_ctrl_status_rx()
1350 td->error = 1; in musbotg_host_ctrl_status_rx()
1353 if (td->error) { in musbotg_host_ctrl_status_rx()
1368 sc = MUSBOTG_PC2SC(td->pc); in musbotg_host_ctrl_status_tx()
1370 if (td->channel == -1) in musbotg_host_ctrl_status_tx()
1371 td->channel = musbotg_channel_alloc(sc, td, 1); in musbotg_host_ctrl_status_tx()
1374 if (td->channel == -1) in musbotg_host_ctrl_status_tx()
1377 DPRINTFN(1, "ep_no=%d/%d [%d@%d.%d/%02x]\n", td->channel, td->transaction_started, in musbotg_host_ctrl_status_tx()
1378 td->dev_addr,td->haddr,td->hport, td->transfer_type); in musbotg_host_ctrl_status_tx()
1397 td->error = 1; in musbotg_host_ctrl_status_tx()
1402 if (td->transaction_started) { in musbotg_host_ctrl_status_tx()
1409 MUSB2_WRITE_1(sc, MUSB2_REG_TXFADDR(0), td->dev_addr); in musbotg_host_ctrl_status_tx()
1410 MUSB2_WRITE_1(sc, MUSB2_REG_TXHADDR(0), td->haddr); in musbotg_host_ctrl_status_tx()
1411 MUSB2_WRITE_1(sc, MUSB2_REG_TXHUBPORT(0), td->hport); in musbotg_host_ctrl_status_tx()
1412 MUSB2_WRITE_1(sc, MUSB2_REG_TXTI, td->transfer_type); in musbotg_host_ctrl_status_tx()
1417 td->transaction_started = 1; in musbotg_host_ctrl_status_tx()
1441 sc = MUSBOTG_PC2SC(td->pc); in musbotg_dev_data_rx()
1443 if (td->channel == -1) in musbotg_dev_data_rx()
1444 td->channel = musbotg_channel_alloc(sc, td, 0); in musbotg_dev_data_rx()
1447 if (td->channel == -1) in musbotg_dev_data_rx()
1451 MUSB2_WRITE_1(sc, MUSB2_REG_EPINDEX, td->channel); in musbotg_dev_data_rx()
1478 if (count != td->max_frame_size) { in musbotg_dev_data_rx()
1479 if (count < td->max_frame_size) { in musbotg_dev_data_rx()
1481 td->short_pkt = 1; in musbotg_dev_data_rx()
1485 td->error = 1; in musbotg_dev_data_rx()
1491 if (count > td->remainder) { in musbotg_dev_data_rx()
1493 td->error = 1; in musbotg_dev_data_rx()
1500 usbd_get_page(td->pc, td->offset, &buf_res); in musbotg_dev_data_rx()
1512 bus_space_read_multi_4(sc->sc_io_tag, sc->sc_io_hdl, in musbotg_dev_data_rx()
1513 MUSB2_REG_EPFIFO(td->channel), sc->sc_bounce_buf, in musbotg_dev_data_rx()
1519 bus_space_read_multi_1(sc->sc_io_tag, in musbotg_dev_data_rx()
1520 sc->sc_io_hdl, MUSB2_REG_EPFIFO(td->channel), in musbotg_dev_data_rx()
1521 ((void *)&sc->sc_bounce_buf[count / 4]), temp); in musbotg_dev_data_rx()
1523 usbd_copy_in(td->pc, td->offset, in musbotg_dev_data_rx()
1524 sc->sc_bounce_buf, count); in musbotg_dev_data_rx()
1527 td->offset += count; in musbotg_dev_data_rx()
1528 td->remainder -= count; in musbotg_dev_data_rx()
1534 bus_space_read_multi_4(sc->sc_io_tag, sc->sc_io_hdl, in musbotg_dev_data_rx()
1535 MUSB2_REG_EPFIFO(td->channel), buf_res.buffer, in musbotg_dev_data_rx()
1541 count -= temp; in musbotg_dev_data_rx()
1542 td->offset += temp; in musbotg_dev_data_rx()
1543 td->remainder -= temp; in musbotg_dev_data_rx()
1547 bus_space_read_multi_1(sc->sc_io_tag, sc->sc_io_hdl, in musbotg_dev_data_rx()
1548 MUSB2_REG_EPFIFO(td->channel), buf_res.buffer, in musbotg_dev_data_rx()
1552 count -= buf_res.length; in musbotg_dev_data_rx()
1553 td->offset += buf_res.length; in musbotg_dev_data_rx()
1554 td->remainder -= buf_res.length; in musbotg_dev_data_rx()
1561 if ((td->remainder == 0) || got_short) { in musbotg_dev_data_rx()
1562 if (td->short_pkt) { in musbotg_dev_data_rx()
1569 if (--to) { in musbotg_dev_data_rx()
1587 sc = MUSBOTG_PC2SC(td->pc); in musbotg_dev_data_tx()
1589 if (td->channel == -1) in musbotg_dev_data_tx()
1590 td->channel = musbotg_channel_alloc(sc, td, 1); in musbotg_dev_data_tx()
1593 if (td->channel == -1) in musbotg_dev_data_tx()
1597 MUSB2_WRITE_1(sc, MUSB2_REG_EPINDEX, td->channel); in musbotg_dev_data_tx()
1615 count = td->max_frame_size; in musbotg_dev_data_tx()
1616 if (td->remainder < count) { in musbotg_dev_data_tx()
1618 td->short_pkt = 1; in musbotg_dev_data_tx()
1619 count = td->remainder; in musbotg_dev_data_tx()
1624 usbd_get_page(td->pc, td->offset, &buf_res); in musbotg_dev_data_tx()
1632 usbd_copy_out(td->pc, td->offset, in musbotg_dev_data_tx()
1633 sc->sc_bounce_buf, count); in musbotg_dev_data_tx()
1639 bus_space_write_multi_4(sc->sc_io_tag, in musbotg_dev_data_tx()
1640 sc->sc_io_hdl, MUSB2_REG_EPFIFO(td->channel), in musbotg_dev_data_tx()
1641 sc->sc_bounce_buf, temp / 4); in musbotg_dev_data_tx()
1646 bus_space_write_multi_1(sc->sc_io_tag, sc->sc_io_hdl, in musbotg_dev_data_tx()
1647 MUSB2_REG_EPFIFO(td->channel), in musbotg_dev_data_tx()
1648 ((void *)&sc->sc_bounce_buf[count / 4]), temp); in musbotg_dev_data_tx()
1651 td->offset += count; in musbotg_dev_data_tx()
1652 td->remainder -= count; in musbotg_dev_data_tx()
1658 bus_space_write_multi_4(sc->sc_io_tag, sc->sc_io_hdl, in musbotg_dev_data_tx()
1659 MUSB2_REG_EPFIFO(td->channel), buf_res.buffer, in musbotg_dev_data_tx()
1665 count -= temp; in musbotg_dev_data_tx()
1666 td->offset += temp; in musbotg_dev_data_tx()
1667 td->remainder -= temp; in musbotg_dev_data_tx()
1671 bus_space_write_multi_1(sc->sc_io_tag, sc->sc_io_hdl, in musbotg_dev_data_tx()
1672 MUSB2_REG_EPFIFO(td->channel), buf_res.buffer, in musbotg_dev_data_tx()
1676 count -= buf_res.length; in musbotg_dev_data_tx()
1677 td->offset += buf_res.length; in musbotg_dev_data_tx()
1678 td->remainder -= buf_res.length; in musbotg_dev_data_tx()
1682 MUSB2_WRITE_2(sc, MUSB2_REG_TXMAXP, td->reg_max_packet); in musbotg_dev_data_tx()
1689 if (td->remainder == 0) { in musbotg_dev_data_tx()
1690 if (td->short_pkt) { in musbotg_dev_data_tx()
1696 if (--to) { in musbotg_dev_data_tx()
1713 sc = MUSBOTG_PC2SC(td->pc); in musbotg_host_data_rx()
1715 if (td->channel == -1) in musbotg_host_data_rx()
1716 td->channel = musbotg_channel_alloc(sc, td, 0); in musbotg_host_data_rx()
1719 if (td->channel == -1) in musbotg_host_data_rx()
1722 DPRINTFN(1, "ep_no=%d\n", td->channel); in musbotg_host_data_rx()
1728 MUSB2_WRITE_1(sc, MUSB2_REG_EPINDEX, td->channel); in musbotg_host_data_rx()
1735 if (!td->transaction_started) { in musbotg_host_data_rx()
1737 MUSB2_WRITE_1(sc, MUSB2_REG_RXFADDR(td->channel), in musbotg_host_data_rx()
1738 td->dev_addr); in musbotg_host_data_rx()
1741 MUSB2_WRITE_1(sc, MUSB2_REG_RXHADDR(td->channel), in musbotg_host_data_rx()
1742 td->haddr); in musbotg_host_data_rx()
1743 MUSB2_WRITE_1(sc, MUSB2_REG_RXHUBPORT(td->channel), in musbotg_host_data_rx()
1744 td->hport); in musbotg_host_data_rx()
1747 if (td->transfer_type & MUSB2_MASK_TI_PROTO_ISOC) in musbotg_host_data_rx()
1753 MUSB2_WRITE_1(sc, MUSB2_REG_RXTI, td->transfer_type); in musbotg_host_data_rx()
1756 MUSB2_WRITE_2(sc, MUSB2_REG_RXMAXP, td->reg_max_packet); in musbotg_host_data_rx()
1763 if (td->toggle) in musbotg_host_data_rx()
1775 td->transaction_started = 1; in musbotg_host_data_rx()
1790 td->error = 1; in musbotg_host_data_rx()
1795 td->error = 1; in musbotg_host_data_rx()
1800 td->error = 1; in musbotg_host_data_rx()
1803 if (td->error) { in musbotg_host_data_rx()
1813 td->toggle ^= 1; in musbotg_host_data_rx()
1821 if (count != td->max_frame_size) { in musbotg_host_data_rx()
1822 if (count < td->max_frame_size) { in musbotg_host_data_rx()
1824 td->short_pkt = 1; in musbotg_host_data_rx()
1828 td->error = 1; in musbotg_host_data_rx()
1835 if (count > td->remainder) { in musbotg_host_data_rx()
1837 td->error = 1; in musbotg_host_data_rx()
1845 usbd_get_page(td->pc, td->offset, &buf_res); in musbotg_host_data_rx()
1857 bus_space_read_multi_4(sc->sc_io_tag, sc->sc_io_hdl, in musbotg_host_data_rx()
1858 MUSB2_REG_EPFIFO(td->channel), sc->sc_bounce_buf, in musbotg_host_data_rx()
1864 bus_space_read_multi_1(sc->sc_io_tag, in musbotg_host_data_rx()
1865 sc->sc_io_hdl, MUSB2_REG_EPFIFO(td->channel), in musbotg_host_data_rx()
1866 ((void *)&sc->sc_bounce_buf[count / 4]), temp); in musbotg_host_data_rx()
1868 usbd_copy_in(td->pc, td->offset, in musbotg_host_data_rx()
1869 sc->sc_bounce_buf, count); in musbotg_host_data_rx()
1872 td->offset += count; in musbotg_host_data_rx()
1873 td->remainder -= count; in musbotg_host_data_rx()
1879 bus_space_read_multi_4(sc->sc_io_tag, sc->sc_io_hdl, in musbotg_host_data_rx()
1880 MUSB2_REG_EPFIFO(td->channel), buf_res.buffer, in musbotg_host_data_rx()
1886 count -= temp; in musbotg_host_data_rx()
1887 td->offset += temp; in musbotg_host_data_rx()
1888 td->remainder -= temp; in musbotg_host_data_rx()
1892 bus_space_read_multi_1(sc->sc_io_tag, sc->sc_io_hdl, in musbotg_host_data_rx()
1893 MUSB2_REG_EPFIFO(td->channel), buf_res.buffer, in musbotg_host_data_rx()
1897 count -= buf_res.length; in musbotg_host_data_rx()
1898 td->offset += buf_res.length; in musbotg_host_data_rx()
1899 td->remainder -= buf_res.length; in musbotg_host_data_rx()
1906 if ((td->remainder == 0) || got_short) { in musbotg_host_data_rx()
1907 if (td->short_pkt) { in musbotg_host_data_rx()
1916 td->transaction_started = 0; in musbotg_host_data_rx()
1918 if (--to) in musbotg_host_data_rx()
1933 sc = MUSBOTG_PC2SC(td->pc); in musbotg_host_data_tx()
1935 if (td->channel == -1) in musbotg_host_data_tx()
1936 td->channel = musbotg_channel_alloc(sc, td, 1); in musbotg_host_data_tx()
1939 if (td->channel == -1) in musbotg_host_data_tx()
1942 DPRINTFN(1, "ep_no=%d\n", td->channel); in musbotg_host_data_tx()
1945 MUSB2_WRITE_1(sc, MUSB2_REG_EPINDEX, td->channel); in musbotg_host_data_tx()
1955 td->error = 1; in musbotg_host_data_tx()
1978 td->error = 1; in musbotg_host_data_tx()
1996 if (td->transaction_started) { in musbotg_host_data_tx()
1998 if (td->remainder == 0) { in musbotg_host_data_tx()
1999 if (td->short_pkt) { in musbotg_host_data_tx()
2006 /* We're not complete - more transactions required */ in musbotg_host_data_tx()
2007 td->transaction_started = 0; in musbotg_host_data_tx()
2011 count = td->max_frame_size; in musbotg_host_data_tx()
2012 if (td->remainder < count) { in musbotg_host_data_tx()
2014 td->short_pkt = 1; in musbotg_host_data_tx()
2015 count = td->remainder; in musbotg_host_data_tx()
2021 usbd_get_page(td->pc, td->offset, &buf_res); in musbotg_host_data_tx()
2029 usbd_copy_out(td->pc, td->offset, in musbotg_host_data_tx()
2030 sc->sc_bounce_buf, count); in musbotg_host_data_tx()
2036 bus_space_write_multi_4(sc->sc_io_tag, in musbotg_host_data_tx()
2037 sc->sc_io_hdl, MUSB2_REG_EPFIFO(td->channel), in musbotg_host_data_tx()
2038 sc->sc_bounce_buf, temp / 4); in musbotg_host_data_tx()
2043 bus_space_write_multi_1(sc->sc_io_tag, sc->sc_io_hdl, in musbotg_host_data_tx()
2044 MUSB2_REG_EPFIFO(td->channel), in musbotg_host_data_tx()
2045 ((void *)&sc->sc_bounce_buf[count / 4]), temp); in musbotg_host_data_tx()
2048 td->offset += count; in musbotg_host_data_tx()
2049 td->remainder -= count; in musbotg_host_data_tx()
2055 bus_space_write_multi_4(sc->sc_io_tag, sc->sc_io_hdl, in musbotg_host_data_tx()
2056 MUSB2_REG_EPFIFO(td->channel), buf_res.buffer, in musbotg_host_data_tx()
2062 count -= temp; in musbotg_host_data_tx()
2063 td->offset += temp; in musbotg_host_data_tx()
2064 td->remainder -= temp; in musbotg_host_data_tx()
2068 bus_space_write_multi_1(sc->sc_io_tag, sc->sc_io_hdl, in musbotg_host_data_tx()
2069 MUSB2_REG_EPFIFO(td->channel), buf_res.buffer, in musbotg_host_data_tx()
2073 count -= buf_res.length; in musbotg_host_data_tx()
2074 td->offset += buf_res.length; in musbotg_host_data_tx()
2075 td->remainder -= buf_res.length; in musbotg_host_data_tx()
2079 MUSB2_WRITE_1(sc, MUSB2_REG_TXFADDR(td->channel), in musbotg_host_data_tx()
2080 td->dev_addr); in musbotg_host_data_tx()
2083 MUSB2_WRITE_1(sc, MUSB2_REG_TXHADDR(td->channel), in musbotg_host_data_tx()
2084 td->haddr); in musbotg_host_data_tx()
2085 MUSB2_WRITE_1(sc, MUSB2_REG_TXHUBPORT(td->channel), in musbotg_host_data_tx()
2086 td->hport); in musbotg_host_data_tx()
2089 if (td->transfer_type & MUSB2_MASK_TI_PROTO_ISOC) in musbotg_host_data_tx()
2095 MUSB2_WRITE_1(sc, MUSB2_REG_TXTI, td->transfer_type); in musbotg_host_data_tx()
2098 MUSB2_WRITE_2(sc, MUSB2_REG_TXMAXP, td->reg_max_packet); in musbotg_host_data_tx()
2100 if (!td->transaction_started) { in musbotg_host_data_tx()
2105 if (td->toggle) in musbotg_host_data_tx()
2119 td->toggle ^= 1; in musbotg_host_data_tx()
2120 td->transaction_started = 1; in musbotg_host_data_tx()
2131 td = xfer->td_transfer_cache; in musbotg_xfer_do_fifo()
2133 if ((td->func) (td)) { in musbotg_xfer_do_fifo()
2138 if (((void *)td) == xfer->td_transfer_last) { in musbotg_xfer_do_fifo()
2141 if (td->error) { in musbotg_xfer_do_fifo()
2143 } else if (td->remainder > 0) { in musbotg_xfer_do_fifo()
2148 if (!td->alt_next) { in musbotg_xfer_do_fifo()
2156 td = td->obj_next; in musbotg_xfer_do_fifo()
2157 xfer->td_transfer_cache = td; in musbotg_xfer_do_fifo()
2174 TAILQ_FOREACH(xfer, &sc->sc_bus.intr_q.head, wait_entry) { in musbotg_interrupt_poll()
2187 USB_BUS_LOCK(&sc->sc_bus); in musbotg_vbus_interrupt()
2189 if (!sc->sc_flags.status_vbus) { in musbotg_vbus_interrupt()
2190 sc->sc_flags.status_vbus = 1; in musbotg_vbus_interrupt()
2196 if (sc->sc_flags.status_vbus) { in musbotg_vbus_interrupt()
2197 sc->sc_flags.status_vbus = 0; in musbotg_vbus_interrupt()
2198 sc->sc_flags.status_bus_reset = 0; in musbotg_vbus_interrupt()
2199 sc->sc_flags.status_suspend = 0; in musbotg_vbus_interrupt()
2200 sc->sc_flags.change_suspend = 0; in musbotg_vbus_interrupt()
2201 sc->sc_flags.change_connect = 1; in musbotg_vbus_interrupt()
2208 USB_BUS_UNLOCK(&sc->sc_bus); in musbotg_vbus_interrupt()
2214 USB_BUS_LOCK(&sc->sc_bus); in musbotg_connect_interrupt()
2215 sc->sc_flags.change_connect = 1; in musbotg_connect_interrupt()
2219 USB_BUS_UNLOCK(&sc->sc_bus); in musbotg_connect_interrupt()
2232 USB_BUS_LOCK(&sc->sc_bus); in musbotg_interrupt()
2261 sc->sc_flags.status_bus_reset = 1; in musbotg_interrupt()
2262 sc->sc_flags.status_suspend = 0; in musbotg_interrupt()
2263 sc->sc_flags.change_suspend = 0; in musbotg_interrupt()
2264 sc->sc_flags.change_connect = 1; in musbotg_interrupt()
2269 sc->sc_flags.status_high_speed = 1; in musbotg_interrupt()
2271 sc->sc_flags.status_high_speed = 0; in musbotg_interrupt()
2293 if (sc->sc_flags.status_suspend) { in musbotg_interrupt()
2294 sc->sc_flags.status_suspend = 0; in musbotg_interrupt()
2295 sc->sc_flags.change_suspend = 1; in musbotg_interrupt()
2305 if (!sc->sc_flags.status_suspend) { in musbotg_interrupt()
2306 sc->sc_flags.status_suspend = 1; in musbotg_interrupt()
2307 sc->sc_flags.change_suspend = 1; in musbotg_interrupt()
2319 sc->sc_flags.change_connect = 1; in musbotg_interrupt()
2325 if (sc->sc_mode == MUSB2_HOST_MODE) { in musbotg_interrupt()
2333 sc->sc_flags.status_bus_reset = 1; in musbotg_interrupt()
2335 sc->sc_flags.status_bus_reset = 0; in musbotg_interrupt()
2351 if (--to) in musbotg_interrupt()
2354 USB_BUS_UNLOCK(&sc->sc_bus); in musbotg_interrupt()
2363 td = temp->td_next; in musbotg_setup_standard_chain_sub()
2364 temp->td = td; in musbotg_setup_standard_chain_sub()
2367 temp->td_next = td->obj_next; in musbotg_setup_standard_chain_sub()
2370 td->func = temp->func; in musbotg_setup_standard_chain_sub()
2371 td->pc = temp->pc; in musbotg_setup_standard_chain_sub()
2372 td->offset = temp->offset; in musbotg_setup_standard_chain_sub()
2373 td->remainder = temp->len; in musbotg_setup_standard_chain_sub()
2374 td->error = 0; in musbotg_setup_standard_chain_sub()
2375 td->transaction_started = 0; in musbotg_setup_standard_chain_sub()
2376 td->did_stall = temp->did_stall; in musbotg_setup_standard_chain_sub()
2377 td->short_pkt = temp->short_pkt; in musbotg_setup_standard_chain_sub()
2378 td->alt_next = temp->setup_alt_next; in musbotg_setup_standard_chain_sub()
2379 td->channel = temp->channel; in musbotg_setup_standard_chain_sub()
2380 td->dev_addr = temp->dev_addr; in musbotg_setup_standard_chain_sub()
2381 td->haddr = temp->haddr; in musbotg_setup_standard_chain_sub()
2382 td->hport = temp->hport; in musbotg_setup_standard_chain_sub()
2383 td->transfer_type = temp->transfer_type; in musbotg_setup_standard_chain_sub()
2400 xfer->address, UE_GET_ADDR(xfer->endpointno), in musbotg_setup_standard_chain()
2401 xfer->sumlen, usbd_get_speed(xfer->xroot->udev)); in musbotg_setup_standard_chain()
2403 sc = MUSBOTG_BUS2SC(xfer->xroot->bus); in musbotg_setup_standard_chain()
2404 ep_no = (xfer->endpointno & UE_ADDR); in musbotg_setup_standard_chain()
2406 temp.max_frame_size = xfer->max_frame_size; in musbotg_setup_standard_chain()
2408 td = xfer->td_start[0]; in musbotg_setup_standard_chain()
2409 xfer->td_transfer_first = td; in musbotg_setup_standard_chain()
2410 xfer->td_transfer_cache = td; in musbotg_setup_standard_chain()
2413 dev_addr = xfer->address; in musbotg_setup_standard_chain()
2415 xfer_type = xfer->endpoint->edesc->bmAttributes & UE_XFERTYPE; in musbotg_setup_standard_chain()
2419 temp.td_next = xfer->td_start[0]; in musbotg_setup_standard_chain()
2421 temp.setup_alt_next = xfer->flags_int.short_frames_ok || in musbotg_setup_standard_chain()
2422 xfer->flags_int.isochronous_xfr; in musbotg_setup_standard_chain()
2423 temp.did_stall = !xfer->flags_int.control_stall; in musbotg_setup_standard_chain()
2424 temp.channel = -1; in musbotg_setup_standard_chain()
2426 temp.haddr = xfer->xroot->udev->hs_hub_addr; in musbotg_setup_standard_chain()
2427 temp.hport = xfer->xroot->udev->hs_port_no; in musbotg_setup_standard_chain()
2429 if (xfer->flags_int.usb_mode == USB_MODE_HOST) { in musbotg_setup_standard_chain()
2430 speed = usbd_get_speed(xfer->xroot->udev); in musbotg_setup_standard_chain()
2444 DPRINTFN(-1, "Invalid USB speed: %d\n", speed); in musbotg_setup_standard_chain()
2462 DPRINTFN(-1, "Invalid USB transfer type: %d\n", in musbotg_setup_standard_chain()
2468 td->toggle = xfer->endpoint->toggle_next; in musbotg_setup_standard_chain()
2473 if (xfer->flags_int.control_xfr) { in musbotg_setup_standard_chain()
2474 if (xfer->flags_int.control_hdr) { in musbotg_setup_standard_chain()
2475 if (xfer->flags_int.usb_mode == USB_MODE_DEVICE) in musbotg_setup_standard_chain()
2480 temp.len = xfer->frlengths[0]; in musbotg_setup_standard_chain()
2481 temp.pc = xfer->frbuffers + 0; in musbotg_setup_standard_chain()
2493 if (x != xfer->nframes) { in musbotg_setup_standard_chain()
2494 if (xfer->endpointno & UE_DIR_IN) in musbotg_setup_standard_chain()
2497 if (xfer->flags_int.usb_mode == USB_MODE_HOST) { in musbotg_setup_standard_chain()
2501 if (xfer->flags_int.control_xfr) in musbotg_setup_standard_chain()
2506 if (xfer->flags_int.control_xfr) in musbotg_setup_standard_chain()
2514 if (xfer->flags_int.control_xfr) in musbotg_setup_standard_chain()
2519 if (xfer->flags_int.control_xfr) in musbotg_setup_standard_chain()
2527 temp.pc = xfer->frbuffers + x; in musbotg_setup_standard_chain()
2529 while (x != xfer->nframes) { in musbotg_setup_standard_chain()
2532 temp.len = xfer->frlengths[x]; in musbotg_setup_standard_chain()
2536 if (x == xfer->nframes) { in musbotg_setup_standard_chain()
2537 if (xfer->flags_int.control_xfr) { in musbotg_setup_standard_chain()
2538 if (xfer->flags_int.control_act) { in musbotg_setup_standard_chain()
2551 if (xfer->flags_int.isochronous_xfr) { in musbotg_setup_standard_chain()
2557 temp.short_pkt = (xfer->flags.force_short_xfer ? 0 : 1); in musbotg_setup_standard_chain()
2563 if (xfer->flags_int.isochronous_xfr) { in musbotg_setup_standard_chain()
2567 temp.pc = xfer->frbuffers + x; in musbotg_setup_standard_chain()
2572 if (xfer->flags_int.control_xfr) { in musbotg_setup_standard_chain()
2574 temp.pc = xfer->frbuffers + 0; in musbotg_setup_standard_chain()
2580 if (!xfer->flags_int.control_act) { in musbotg_setup_standard_chain()
2585 if (sc->sc_mode == MUSB2_DEVICE_MODE) in musbotg_setup_standard_chain()
2588 if (xfer->endpointno & UE_DIR_IN) in musbotg_setup_standard_chain()
2598 xfer->td_transfer_last = td; in musbotg_setup_standard_chain()
2608 USB_BUS_LOCK_ASSERT(xfer->xroot->bus, MA_OWNED); in musbotg_timeout()
2615 musbotg_ep_int_set(struct musbotg_softc *sc, int channel, int on) in musbotg_ep_int_set() argument
2624 DPRINTFN(1, "ep_no=%d, on=%d\n", channel, on); in musbotg_ep_int_set()
2626 if (channel == -1) in musbotg_ep_int_set()
2629 if (channel == 0) { in musbotg_ep_int_set()
2640 temp |= MUSB2_MASK_EPINT(channel); in musbotg_ep_int_set()
2642 temp &= ~MUSB2_MASK_EPINT(channel); in musbotg_ep_int_set()
2647 temp |= MUSB2_MASK_EPINT(channel); in musbotg_ep_int_set()
2649 temp &= ~MUSB2_MASK_EPINT(channel); in musbotg_ep_int_set()
2653 if (sc->sc_ep_int_set) in musbotg_ep_int_set()
2654 sc->sc_ep_int_set(sc, channel, on); in musbotg_ep_int_set()
2667 usbd_transfer_enqueue(&xfer->xroot->bus->intr_q, xfer); in musbotg_start_standard_chain()
2670 if (xfer->timeout != 0) { in musbotg_start_standard_chain()
2672 &musbotg_timeout, xfer->timeout); in musbotg_start_standard_chain()
2682 USB_BUS_LOCK_ASSERT(&sc->sc_bus, MA_OWNED); in musbotg_root_intr()
2685 sc->sc_hub_idata[0] = 0x02; /* we only have one port */ in musbotg_root_intr()
2687 uhub_root_intr(&sc->sc_bus, sc->sc_hub_idata, in musbotg_root_intr()
2688 sizeof(sc->sc_hub_idata)); in musbotg_root_intr()
2700 td = xfer->td_transfer_cache; in musbotg_standard_done_sub()
2703 len = td->remainder; in musbotg_standard_done_sub()
2705 xfer->endpoint->toggle_next = td->toggle; in musbotg_standard_done_sub()
2707 if (xfer->aframes != xfer->nframes) { in musbotg_standard_done_sub()
2712 if (len > xfer->frlengths[xfer->aframes]) { in musbotg_standard_done_sub()
2713 td->error = 1; in musbotg_standard_done_sub()
2715 xfer->frlengths[xfer->aframes] -= len; in musbotg_standard_done_sub()
2719 if (td->error) { in musbotg_standard_done_sub()
2727 if (xfer->flags_int.short_frames_ok || in musbotg_standard_done_sub()
2728 xfer->flags_int.isochronous_xfr) { in musbotg_standard_done_sub()
2730 if (td->alt_next) { in musbotg_standard_done_sub()
2731 td = td->obj_next; in musbotg_standard_done_sub()
2742 td = td->obj_next; in musbotg_standard_done_sub()
2752 xfer->td_transfer_cache = td; in musbotg_standard_done_sub()
2764 xfer, xfer->endpoint); in musbotg_standard_done()
2768 xfer->td_transfer_cache = xfer->td_transfer_first; in musbotg_standard_done()
2770 if (xfer->flags_int.control_xfr) { in musbotg_standard_done()
2771 if (xfer->flags_int.control_hdr) { in musbotg_standard_done()
2774 xfer->aframes = 1; in musbotg_standard_done()
2776 if (xfer->td_transfer_cache == NULL) { in musbotg_standard_done()
2780 while (xfer->aframes != xfer->nframes) { in musbotg_standard_done()
2782 xfer->aframes++; in musbotg_standard_done()
2784 if (xfer->td_transfer_cache == NULL) { in musbotg_standard_done()
2789 if (xfer->flags_int.control_xfr && in musbotg_standard_done()
2790 !xfer->flags_int.control_act) { in musbotg_standard_done()
2797 /*------------------------------------------------------------------------*
2802 *------------------------------------------------------------------------*/
2809 USB_BUS_LOCK_ASSERT(xfer->xroot->bus, MA_OWNED); in musbotg_device_done()
2812 xfer, xfer->endpoint, error); in musbotg_device_done()
2816 sc = MUSBOTG_BUS2SC(xfer->xroot->bus); in musbotg_device_done()
2817 td = xfer->td_transfer_cache; in musbotg_device_done()
2819 if (td && (td->channel != -1)) in musbotg_device_done()
2839 USB_BUS_LOCK_ASSERT(udev->bus, MA_OWNED); in musbotg_set_stall()
2844 sc = MUSBOTG_BUS2SC(udev->bus); in musbotg_set_stall()
2846 ep_no = (ep->edesc->bEndpointAddress & UE_ADDR); in musbotg_set_stall()
2851 if (ep->edesc->bEndpointAddress & UE_DIR_IN) { in musbotg_set_stall()
2913 /* Need to flush twice in case of double bufring */ in musbotg_clear_stall_sub()
2931 /* set double/single buffering */ in musbotg_clear_stall_sub()
2933 if (mps <= (sc->sc_hw_ep_profile[ep_no]. in musbotg_clear_stall_sub()
2935 /* double buffer */ in musbotg_clear_stall_sub()
2972 /* Need to flush twice in case of double bufring */ in musbotg_clear_stall_sub()
2990 /* set double/single buffering */ in musbotg_clear_stall_sub()
2992 if (mps <= (sc->sc_hw_ep_profile[ep_no]. in musbotg_clear_stall_sub()
2994 /* double buffer */ in musbotg_clear_stall_sub()
3017 USB_BUS_LOCK_ASSERT(udev->bus, MA_OWNED); in musbotg_clear_stall()
3020 if (udev->flags.usb_mode != USB_MODE_DEVICE) { in musbotg_clear_stall()
3025 sc = MUSBOTG_BUS2SC(udev->bus); in musbotg_clear_stall()
3028 ed = ep->edesc; in musbotg_clear_stall()
3032 UGETW(ed->wMaxPacketSize), in musbotg_clear_stall()
3033 (ed->bEndpointAddress & UE_ADDR), in musbotg_clear_stall()
3034 (ed->bmAttributes & UE_XFERTYPE), in musbotg_clear_stall()
3035 (ed->bEndpointAddress & (UE_DIR_IN | UE_DIR_OUT))); in musbotg_clear_stall()
3056 sc->sc_bus.usbrev = USB_REV_2_0; in musbotg_init()
3057 sc->sc_bus.methods = &musbotg_bus_methods; in musbotg_init()
3060 if (sc->sc_ep_cfg == NULL) in musbotg_init()
3061 sc->sc_ep_cfg = musbotg_ep_default; in musbotg_init()
3063 USB_BUS_LOCK(&sc->sc_bus); in musbotg_init()
3067 if (sc->sc_clocks_on) { in musbotg_init()
3068 (sc->sc_clocks_on) (sc->sc_clocks_arg); in musbotg_init()
3072 usb_pause_mtx(&sc->sc_bus.bus_mtx, hz / 1000); in musbotg_init()
3077 DPRINTF("pre-DEVCTL=0x%02x\n", temp); in musbotg_init()
3088 usb_pause_mtx(&sc->sc_bus.bus_mtx, hz / 100); in musbotg_init()
3090 /* disable double packet buffering */ in musbotg_init()
3099 if (sc->sc_mode == MUSB2_DEVICE_MODE) { in musbotg_init()
3112 usb_pause_mtx(&sc->sc_bus.bus_mtx, hz / 10); in musbotg_init()
3128 if (sc->sc_ep_max == 0) { in musbotg_init()
3137 sc->sc_ep_max = (nrx > ntx) ? nrx : ntx; in musbotg_init()
3139 nrx = ntx = sc->sc_ep_max; in musbotg_init()
3146 if (sc->sc_ep_max == 0) { in musbotg_init()
3151 sc->sc_conf_data = MUSB2_READ_1(sc, MUSB2_REG_CONFDATA); in musbotg_init()
3154 sc->sc_conf_data); in musbotg_init()
3156 dynfifo = (sc->sc_conf_data & MUSB2_MASK_CD_DYNFIFOSZ) ? 1 : 0; in musbotg_init()
3159 device_printf(sc->sc_bus.bdev, "Dynamic FIFO sizing detected, " in musbotg_init()
3170 for (temp = 1; temp <= sc->sc_ep_max; temp++) { in musbotg_init()
3171 pf = sc->sc_hw_ep_profile + temp; in musbotg_init()
3185 for (i = 0; sc->sc_ep_cfg[i].ep_end >= 0; i++) { in musbotg_init()
3186 cfg = &sc->sc_ep_cfg[i]; in musbotg_init()
3187 if (temp <= cfg->ep_end) { in musbotg_init()
3188 frx = cfg->ep_fifosz_shift; in musbotg_init()
3191 cfg->ep_fifosz_reg); in musbotg_init()
3202 for (i = 0; sc->sc_ep_cfg[i].ep_end >= 0; i++) { in musbotg_init()
3203 cfg = &sc->sc_ep_cfg[i]; in musbotg_init()
3204 if (temp <= cfg->ep_end) { in musbotg_init()
3205 ftx = cfg->ep_fifosz_shift; in musbotg_init()
3208 cfg->ep_fifosz_reg); in musbotg_init()
3221 pf->max_in_frame_size = 1 << ftx; in musbotg_init()
3222 pf->max_out_frame_size = 1 << frx; in musbotg_init()
3223 pf->is_simplex = 0; /* duplex */ in musbotg_init()
3224 pf->support_multi_buffer = 1; in musbotg_init()
3225 pf->support_bulk = 1; in musbotg_init()
3226 pf->support_interrupt = 1; in musbotg_init()
3227 pf->support_isochronous = 1; in musbotg_init()
3228 pf->support_in = 1; in musbotg_init()
3229 pf->support_out = 1; in musbotg_init()
3231 pf->max_out_frame_size = 1 << frx; in musbotg_init()
3232 pf->max_in_frame_size = 0; in musbotg_init()
3233 pf->is_simplex = 1; /* simplex */ in musbotg_init()
3234 pf->support_multi_buffer = 1; in musbotg_init()
3235 pf->support_bulk = 1; in musbotg_init()
3236 pf->support_interrupt = 1; in musbotg_init()
3237 pf->support_isochronous = 1; in musbotg_init()
3238 pf->support_out = 1; in musbotg_init()
3240 pf->max_in_frame_size = 1 << ftx; in musbotg_init()
3241 pf->max_out_frame_size = 0; in musbotg_init()
3242 pf->is_simplex = 1; /* simplex */ in musbotg_init()
3243 pf->support_multi_buffer = 1; in musbotg_init()
3244 pf->support_bulk = 1; in musbotg_init()
3245 pf->support_interrupt = 1; in musbotg_init()
3246 pf->support_isochronous = 1; in musbotg_init()
3247 pf->support_in = 1; in musbotg_init()
3255 if (sc->sc_mode == MUSB2_HOST_MODE) in musbotg_init()
3263 USB_BUS_UNLOCK(&sc->sc_bus); in musbotg_init()
3267 musbotg_do_poll(&sc->sc_bus); in musbotg_init()
3275 USB_BUS_LOCK(&sc->sc_bus); in musbotg_uninit()
3282 sc->sc_flags.port_powered = 0; in musbotg_uninit()
3283 sc->sc_flags.status_vbus = 0; in musbotg_uninit()
3284 sc->sc_flags.status_bus_reset = 0; in musbotg_uninit()
3285 sc->sc_flags.status_suspend = 0; in musbotg_uninit()
3286 sc->sc_flags.change_suspend = 0; in musbotg_uninit()
3287 sc->sc_flags.change_connect = 1; in musbotg_uninit()
3291 USB_BUS_UNLOCK(&sc->sc_bus); in musbotg_uninit()
3299 USB_BUS_LOCK(&sc->sc_bus); in musbotg_do_poll()
3301 USB_BUS_UNLOCK(&sc->sc_bus); in musbotg_do_poll()
3304 /*------------------------------------------------------------------------*
3306 *------------------------------------------------------------------------*/
3341 /*------------------------------------------------------------------------*
3343 *------------------------------------------------------------------------*/
3378 /*------------------------------------------------------------------------*
3380 *------------------------------------------------------------------------*/
3415 /*------------------------------------------------------------------------*
3417 *------------------------------------------------------------------------*/
3433 struct musbotg_softc *sc = MUSBOTG_BUS2SC(xfer->xroot->bus); in musbotg_device_isoc_enter()
3437 xfer, xfer->endpoint->isoc_next, xfer->nframes); in musbotg_device_isoc_enter()
3445 DPRINTFN(2, "start next=%d\n", xfer->endpoint->isoc_next); in musbotg_device_isoc_enter()
3466 /*------------------------------------------------------------------------*
3468 *------------------------------------------------------------------------*
3470 *------------------------------------------------------------------------*/
3550 struct musbotg_softc *sc = MUSBOTG_BUS2SC(udev->bus); in musbotg_roothub_exec()
3558 USB_BUS_LOCK_ASSERT(&sc->sc_bus, MA_OWNED); in musbotg_roothub_exec()
3561 ptr = (const void *)&sc->sc_hub_temp; in musbotg_roothub_exec()
3565 value = UGETW(req->wValue); in musbotg_roothub_exec()
3566 index = UGETW(req->wIndex); in musbotg_roothub_exec()
3570 switch (req->bmRequestType) { in musbotg_roothub_exec()
3572 switch (req->bRequest) { in musbotg_roothub_exec()
3585 switch (req->bRequest) { in musbotg_roothub_exec()
3601 switch (req->bRequest) { in musbotg_roothub_exec()
3603 switch (UGETW(req->wValue)) { in musbotg_roothub_exec()
3613 switch (UGETW(req->wValue)) { in musbotg_roothub_exec()
3630 switch (req->bRequest) { in musbotg_roothub_exec()
3639 switch (req->bRequest) { in musbotg_roothub_exec()
3651 switch (req->bRequest) { in musbotg_roothub_exec()
3672 switch (req->bRequest) { in musbotg_roothub_exec()
3684 switch (req->bRequest) { in musbotg_roothub_exec()
3700 switch (req->bRequest) { in musbotg_roothub_exec()
3711 switch (req->bRequest) { in musbotg_roothub_exec()
3776 sc->sc_hub_temp.wValue[0] = sc->sc_conf; in musbotg_roothub_exec()
3781 USETW(sc->sc_hub_temp.wValue, UDS_SELF_POWERED); in musbotg_roothub_exec()
3788 sc->sc_rt_addr = value; in musbotg_roothub_exec()
3795 sc->sc_conf = value; in musbotg_roothub_exec()
3800 sc->sc_hub_temp.wValue[0] = 0; in musbotg_roothub_exec()
3808 USETW(sc->sc_hub_temp.wValue, 0); in musbotg_roothub_exec()
3826 if (sc->sc_mode == MUSB2_HOST_MODE) in musbotg_roothub_exec()
3833 sc->sc_flags.port_enabled = 0; in musbotg_roothub_exec()
3837 sc->sc_flags.change_enabled = 0; in musbotg_roothub_exec()
3841 sc->sc_flags.change_over_current = 0; in musbotg_roothub_exec()
3845 sc->sc_flags.change_reset = 0; in musbotg_roothub_exec()
3854 sc->sc_flags.port_powered = 0; in musbotg_roothub_exec()
3859 sc->sc_flags.change_connect = 0; in musbotg_roothub_exec()
3862 sc->sc_flags.change_suspend = 0; in musbotg_roothub_exec()
3878 sc->sc_flags.port_enabled = 1; in musbotg_roothub_exec()
3881 if (sc->sc_mode == MUSB2_HOST_MODE) in musbotg_roothub_exec()
3886 if (sc->sc_mode == MUSB2_HOST_MODE) { in musbotg_roothub_exec()
3892 usb_pause_mtx(&sc->sc_bus.bus_mtx, hz / 5); in musbotg_roothub_exec()
3901 sc->sc_flags.status_high_speed = 1; in musbotg_roothub_exec()
3903 sc->sc_flags.status_high_speed = 0; in musbotg_roothub_exec()
3905 sc->sc_flags.change_reset = 1; in musbotg_roothub_exec()
3915 sc->sc_flags.port_powered = 1; in musbotg_roothub_exec()
3930 if (sc->sc_flags.status_vbus) { in musbotg_roothub_exec()
3939 if (sc->sc_mode == MUSB2_DEVICE_MODE) in musbotg_roothub_exec()
3944 if (sc->sc_flags.status_high_speed) { in musbotg_roothub_exec()
3947 if (sc->sc_flags.port_powered) { in musbotg_roothub_exec()
3950 if (sc->sc_flags.port_enabled) { in musbotg_roothub_exec()
3954 if (sc->sc_flags.port_over_current) in musbotg_roothub_exec()
3957 if (sc->sc_flags.status_vbus && in musbotg_roothub_exec()
3958 sc->sc_flags.status_bus_reset) { in musbotg_roothub_exec()
3961 if (sc->sc_flags.status_suspend) { in musbotg_roothub_exec()
3964 USETW(sc->sc_hub_temp.ps.wPortStatus, value); in musbotg_roothub_exec()
3968 if (sc->sc_flags.change_connect) { in musbotg_roothub_exec()
3971 if (sc->sc_mode == MUSB2_DEVICE_MODE) { in musbotg_roothub_exec()
3972 if (sc->sc_flags.status_vbus && in musbotg_roothub_exec()
3973 sc->sc_flags.status_bus_reset) { in musbotg_roothub_exec()
3975 sc->sc_ep0_busy = 0; in musbotg_roothub_exec()
3976 sc->sc_ep0_cmd = 0; in musbotg_roothub_exec()
3980 if (sc->sc_flags.change_suspend) in musbotg_roothub_exec()
3982 if (sc->sc_flags.change_reset) in musbotg_roothub_exec()
3984 if (sc->sc_flags.change_over_current) in musbotg_roothub_exec()
3987 USETW(sc->sc_hub_temp.ps.wPortChange, value); in musbotg_roothub_exec()
3988 len = sizeof(sc->sc_hub_temp.ps); in musbotg_roothub_exec()
4017 xfer = parm->curr_xfer; in musbotg_xfer_setup()
4024 parm->hc_max_packet_size = 0x400; in musbotg_xfer_setup()
4025 parm->hc_max_frame_size = 0xc00; in musbotg_xfer_setup()
4027 if ((parm->methods == &musbotg_device_isoc_methods) || in musbotg_xfer_setup()
4028 (parm->methods == &musbotg_device_intr_methods)) in musbotg_xfer_setup()
4029 parm->hc_max_packet_count = 3; in musbotg_xfer_setup()
4031 parm->hc_max_packet_count = 1; in musbotg_xfer_setup()
4038 if (parm->methods == &musbotg_device_ctrl_methods) { in musbotg_xfer_setup()
4039 ntd = xfer->nframes + 1 /* STATUS */ + 1 /* SYNC */ ; in musbotg_xfer_setup()
4041 } else if (parm->methods == &musbotg_device_bulk_methods) { in musbotg_xfer_setup()
4042 ntd = xfer->nframes + 1 /* SYNC */ ; in musbotg_xfer_setup()
4044 } else if (parm->methods == &musbotg_device_intr_methods) { in musbotg_xfer_setup()
4045 ntd = xfer->nframes + 1 /* SYNC */ ; in musbotg_xfer_setup()
4047 } else if (parm->methods == &musbotg_device_isoc_methods) { in musbotg_xfer_setup()
4048 ntd = xfer->nframes + 1 /* SYNC */ ; in musbotg_xfer_setup()
4057 if (parm->err) { in musbotg_xfer_setup()
4065 ep_no = xfer->endpointno & UE_ADDR; in musbotg_xfer_setup()
4070 if (xfer->flags_int.usb_mode == USB_MODE_DEVICE) { in musbotg_xfer_setup()
4073 musbotg_get_hw_ep_profile(parm->udev, &pf, ep_no); in musbotg_xfer_setup()
4077 parm->err = USB_ERR_INVAL; in musbotg_xfer_setup()
4083 parm->size[0] += ((-parm->size[0]) & (USB_HOST_ALIGN - 1)); in musbotg_xfer_setup()
4088 if (parm->buf) { in musbotg_xfer_setup()
4089 td = USB_ADD_BYTES(parm->buf, parm->size[0]); in musbotg_xfer_setup()
4092 td->max_frame_size = xfer->max_frame_size; in musbotg_xfer_setup()
4093 td->reg_max_packet = xfer->max_packet_size | in musbotg_xfer_setup()
4094 ((xfer->max_packet_count - 1) << 11); in musbotg_xfer_setup()
4095 td->ep_no = ep_no; in musbotg_xfer_setup()
4096 td->obj_next = last_obj; in musbotg_xfer_setup()
4100 parm->size[0] += sizeof(*td); in musbotg_xfer_setup()
4103 xfer->td_start[0] = last_obj; in musbotg_xfer_setup()
4115 struct musbotg_softc *sc = MUSBOTG_BUS2SC(udev->bus); in musbotg_get_dma_delay()
4117 if (sc->sc_mode == MUSB2_HOST_MODE) in musbotg_get_dma_delay()
4127 struct musbotg_softc *sc = MUSBOTG_BUS2SC(udev->bus); in musbotg_ep_init()
4130 ep, udev->address, in musbotg_ep_init()
4131 edesc->bEndpointAddress, udev->flags.usb_mode, in musbotg_ep_init()
4132 sc->sc_rt_addr); in musbotg_ep_init()
4134 if (udev->device_index != sc->sc_rt_addr) { in musbotg_ep_init()
4135 switch (edesc->bmAttributes & UE_XFERTYPE) { in musbotg_ep_init()
4137 ep->methods = &musbotg_device_ctrl_methods; in musbotg_ep_init()
4140 ep->methods = &musbotg_device_intr_methods; in musbotg_ep_init()
4143 ep->methods = &musbotg_device_isoc_methods; in musbotg_ep_init()
4146 ep->methods = &musbotg_device_bulk_methods; in musbotg_ep_init()