Lines Matching refs:td

134 static int	musbotg_channel_alloc(struct musbotg_softc *, struct musbotg_td *td, uint8_t);
135 static void musbotg_channel_free(struct musbotg_softc *, struct musbotg_td *td);
172 musbotg_channel_alloc(struct musbotg_softc *sc, struct musbotg_td *td, uint8_t is_tx) in musbotg_channel_alloc() argument
177 ep = td->ep_no; in musbotg_channel_alloc()
202 if (td->max_frame_size > in musbotg_channel_alloc()
206 if (td->max_frame_size > in musbotg_channel_alloc()
221 musbotg_channel_free(struct musbotg_softc *sc, struct musbotg_td *td) in musbotg_channel_free() argument
224 DPRINTFN(1, "ep_no=%d\n", td->channel); in musbotg_channel_free()
229 if (td == NULL) 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()
398 musbotg_dev_ctrl_setup_rx(struct musbotg_td *td) in musbotg_dev_ctrl_setup_rx() argument
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()
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()
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()
510 musbotg_channel_free(sc, td); 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()
525 musbotg_host_ctrl_setup_tx(struct musbotg_td *td) in musbotg_host_ctrl_setup_tx() argument
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()
587 musbotg_channel_free(sc, td); in musbotg_host_ctrl_setup_tx()
596 if (td->remainder == 0) { in musbotg_host_ctrl_setup_tx()
598 musbotg_channel_free(sc, td); in musbotg_host_ctrl_setup_tx()
603 usbd_copy_out(td->pc, 0, &req, sizeof(req)); 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()
633 musbotg_dev_ctrl_data_rx(struct musbotg_td *td) in musbotg_dev_ctrl_data_rx() argument
642 sc = MUSBOTG_PC2SC(td->pc); 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()
725 usbd_copy_in(td->pc, td->offset, 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()
744 td->offset += temp; in musbotg_dev_ctrl_data_rx()
745 td->remainder -= temp; 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()
774 musbotg_dev_ctrl_data_tx(struct musbotg_td *td) in musbotg_dev_ctrl_data_tx() argument
782 sc = MUSBOTG_PC2SC(td->pc); 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()
845 td->offset += count; in musbotg_dev_ctrl_data_tx()
846 td->remainder -= count; 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()
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()
890 musbotg_host_ctrl_data_rx(struct musbotg_td *td) in musbotg_host_ctrl_data_rx() argument
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()
957 musbotg_channel_free(sc, td); 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()
976 musbotg_channel_free(sc, td); 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()
984 musbotg_channel_free(sc, td); in musbotg_host_ctrl_data_rx()
990 usbd_get_page(td->pc, td->offset, &buf_res); in musbotg_host_ctrl_data_rx()
1013 usbd_copy_in(td->pc, td->offset, 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()
1032 td->offset += temp; in musbotg_host_ctrl_data_rx()
1033 td->remainder -= temp; 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()
1054 musbotg_channel_free(sc, td); in musbotg_host_ctrl_data_rx()
1060 td->transaction_started = 1; in musbotg_host_ctrl_data_rx()
1068 musbotg_host_ctrl_data_tx(struct musbotg_td *td) in musbotg_host_ctrl_data_tx() argument
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()
1122 musbotg_channel_free(sc, td); 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()
1143 musbotg_channel_free(sc, td); 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()
1191 td->offset += count; in musbotg_host_ctrl_data_tx()
1192 td->remainder -= count; 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()
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()
1240 musbotg_dev_ctrl_status(struct musbotg_td *td) in musbotg_dev_ctrl_status() argument
1246 sc = MUSBOTG_PC2SC(td->pc); in musbotg_dev_ctrl_status()
1271 musbotg_channel_free(sc, td); in musbotg_dev_ctrl_status()
1276 musbotg_host_ctrl_status_rx(struct musbotg_td *td) in musbotg_host_ctrl_status_rx() argument
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()
1329 musbotg_channel_free(sc, td); 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()
1354 musbotg_channel_free(sc, td); in musbotg_host_ctrl_status_rx()
1362 musbotg_host_ctrl_status_tx(struct musbotg_td *td) in musbotg_host_ctrl_status_tx() argument
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()
1398 musbotg_channel_free(sc, td); in musbotg_host_ctrl_status_tx()
1402 if (td->transaction_started) { in musbotg_host_ctrl_status_tx()
1403 musbotg_channel_free(sc, td); 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()
1428 musbotg_dev_data_rx(struct musbotg_td *td) in musbotg_dev_data_rx() argument
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()
1486 musbotg_channel_free(sc, td); in musbotg_dev_data_rx()
1491 if (count > td->remainder) { in musbotg_dev_data_rx()
1493 td->error = 1; in musbotg_dev_data_rx()
1494 musbotg_channel_free(sc, td); in musbotg_dev_data_rx()
1500 usbd_get_page(td->pc, td->offset, &buf_res); in musbotg_dev_data_rx()
1513 MUSB2_REG_EPFIFO(td->channel), sc->sc_bounce_buf, in musbotg_dev_data_rx()
1520 sc->sc_io_hdl, MUSB2_REG_EPFIFO(td->channel), in musbotg_dev_data_rx()
1523 usbd_copy_in(td->pc, td->offset, in musbotg_dev_data_rx()
1527 td->offset += count; in musbotg_dev_data_rx()
1528 td->remainder -= count; in musbotg_dev_data_rx()
1535 MUSB2_REG_EPFIFO(td->channel), buf_res.buffer, in musbotg_dev_data_rx()
1542 td->offset += temp; in musbotg_dev_data_rx()
1543 td->remainder -= temp; in musbotg_dev_data_rx()
1548 MUSB2_REG_EPFIFO(td->channel), buf_res.buffer, 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()
1564 musbotg_channel_free(sc, td); in musbotg_dev_data_rx()
1576 musbotg_dev_data_tx(struct musbotg_td *td) in musbotg_dev_data_tx() argument
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()
1640 sc->sc_io_hdl, MUSB2_REG_EPFIFO(td->channel), in musbotg_dev_data_tx()
1647 MUSB2_REG_EPFIFO(td->channel), in musbotg_dev_data_tx()
1651 td->offset += count; in musbotg_dev_data_tx()
1652 td->remainder -= count; in musbotg_dev_data_tx()
1659 MUSB2_REG_EPFIFO(td->channel), buf_res.buffer, in musbotg_dev_data_tx()
1666 td->offset += temp; in musbotg_dev_data_tx()
1667 td->remainder -= temp; in musbotg_dev_data_tx()
1672 MUSB2_REG_EPFIFO(td->channel), buf_res.buffer, 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()
1691 musbotg_channel_free(sc, td); in musbotg_dev_data_tx()
1703 musbotg_host_data_rx(struct musbotg_td *td) in musbotg_host_data_rx() argument
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()
1804 musbotg_channel_free(sc, td); 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()
1829 musbotg_channel_free(sc, td); in musbotg_host_data_rx()
1835 if (count > td->remainder) { in musbotg_host_data_rx()
1837 td->error = 1; in musbotg_host_data_rx()
1838 musbotg_channel_free(sc, td); in musbotg_host_data_rx()
1845 usbd_get_page(td->pc, td->offset, &buf_res); in musbotg_host_data_rx()
1858 MUSB2_REG_EPFIFO(td->channel), sc->sc_bounce_buf, in musbotg_host_data_rx()
1865 sc->sc_io_hdl, MUSB2_REG_EPFIFO(td->channel), in musbotg_host_data_rx()
1868 usbd_copy_in(td->pc, td->offset, in musbotg_host_data_rx()
1872 td->offset += count; in musbotg_host_data_rx()
1873 td->remainder -= count; in musbotg_host_data_rx()
1880 MUSB2_REG_EPFIFO(td->channel), buf_res.buffer, in musbotg_host_data_rx()
1887 td->offset += temp; in musbotg_host_data_rx()
1888 td->remainder -= temp; in musbotg_host_data_rx()
1893 MUSB2_REG_EPFIFO(td->channel), buf_res.buffer, 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()
1909 musbotg_channel_free(sc, td); in musbotg_host_data_rx()
1916 td->transaction_started = 0; in musbotg_host_data_rx()
1925 musbotg_host_data_tx(struct musbotg_td *td) in musbotg_host_data_tx() argument
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()
1956 musbotg_channel_free(sc, td); in musbotg_host_data_tx()
1978 td->error = 1; in musbotg_host_data_tx()
1979 musbotg_channel_free(sc, td); 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()
2000 musbotg_channel_free(sc, td); 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()
2037 sc->sc_io_hdl, MUSB2_REG_EPFIFO(td->channel), in musbotg_host_data_tx()
2044 MUSB2_REG_EPFIFO(td->channel), in musbotg_host_data_tx()
2048 td->offset += count; in musbotg_host_data_tx()
2049 td->remainder -= count; in musbotg_host_data_tx()
2056 MUSB2_REG_EPFIFO(td->channel), buf_res.buffer, in musbotg_host_data_tx()
2063 td->offset += temp; in musbotg_host_data_tx()
2064 td->remainder -= temp; in musbotg_host_data_tx()
2069 MUSB2_REG_EPFIFO(td->channel), buf_res.buffer, 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()
2128 struct musbotg_td *td; in musbotg_xfer_do_fifo() local
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()
2360 struct musbotg_td *td; in musbotg_setup_standard_chain_sub() local
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()
2391 struct musbotg_td *td; in musbotg_setup_standard_chain() local
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()
2418 temp.td = NULL; in musbotg_setup_standard_chain()
2468 td->toggle = xfer->endpoint->toggle_next; in musbotg_setup_standard_chain()
2597 td = temp.td; in musbotg_setup_standard_chain()
2598 xfer->td_transfer_last = td; in musbotg_setup_standard_chain()
2694 struct musbotg_td *td; in musbotg_standard_done_sub() local
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()
2713 td->error = 1; in musbotg_standard_done_sub()
2719 if (td->error) { in musbotg_standard_done_sub()
2722 td = NULL; 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()
2733 td = NULL; in musbotg_standard_done_sub()
2737 td = NULL; 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()
2806 struct musbotg_td *td; in musbotg_device_done() local
2817 td = xfer->td_transfer_cache; in musbotg_device_done()
2819 if (td && (td->channel != -1)) in musbotg_device_done()
2820 musbotg_channel_free(sc, td); in musbotg_device_done()
4086 struct musbotg_td *td; in musbotg_xfer_setup() local
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()
4095 td->ep_no = ep_no; in musbotg_xfer_setup()
4096 td->obj_next = last_obj; in musbotg_xfer_setup()
4098 last_obj = td; in musbotg_xfer_setup()
4100 parm->size[0] += sizeof(*td); in musbotg_xfer_setup()