avr32dci.c (193644) | avr32dci.c (194228) |
---|---|
1#include <sys/cdefs.h> | 1#include <sys/cdefs.h> |
2__FBSDID("$FreeBSD: head/sys/dev/usb/controller/avr32dci.c 193644 2009-06-07 19:41:11Z thompsa $"); | 2__FBSDID("$FreeBSD: head/sys/dev/usb/controller/avr32dci.c 194228 2009-06-15 01:02:43Z thompsa $"); |
3 4/*- 5 * Copyright (c) 2009 Hans Petter Selasky. All rights reserved. 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions 9 * are met: 10 * 1. Redistributions of source code must retain the above copyright --- 221 unchanged lines hidden (view full) --- 232{ 233 if (!sc->sc_flags.status_suspend) { 234 return; 235 } 236 avr32dci_mod_ctrl(sc, AVR32_CTRL_DEV_REWAKEUP, 0); 237 238 /* wait 8 milliseconds */ 239 /* Wait for reset to complete. */ | 3 4/*- 5 * Copyright (c) 2009 Hans Petter Selasky. All rights reserved. 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions 9 * are met: 10 * 1. Redistributions of source code must retain the above copyright --- 221 unchanged lines hidden (view full) --- 232{ 233 if (!sc->sc_flags.status_suspend) { 234 return; 235 } 236 avr32dci_mod_ctrl(sc, AVR32_CTRL_DEV_REWAKEUP, 0); 237 238 /* wait 8 milliseconds */ 239 /* Wait for reset to complete. */ |
240 usb2_pause_mtx(&sc->sc_bus.bus_mtx, hz / 125); | 240 usb_pause_mtx(&sc->sc_bus.bus_mtx, hz / 125); |
241 242 /* hardware should have cleared RMWKUP bit */ 243} 244 245static void 246avr32dci_set_address(struct avr32dci_softc *sc, uint8_t addr) 247{ 248 DPRINTFN(5, "addr=%d\n", addr); --- 35 unchanged lines hidden (view full) --- 284 DPRINTFN(0, "Unsupported SETUP packet " 285 "length, %d bytes\n", count); 286 goto not_complete; 287 } 288 /* receive data */ 289 memcpy(&req, sc->physdata, sizeof(req)); 290 291 /* copy data into real buffer */ | 241 242 /* hardware should have cleared RMWKUP bit */ 243} 244 245static void 246avr32dci_set_address(struct avr32dci_softc *sc, uint8_t addr) 247{ 248 DPRINTFN(5, "addr=%d\n", addr); --- 35 unchanged lines hidden (view full) --- 284 DPRINTFN(0, "Unsupported SETUP packet " 285 "length, %d bytes\n", count); 286 goto not_complete; 287 } 288 /* receive data */ 289 memcpy(&req, sc->physdata, sizeof(req)); 290 291 /* copy data into real buffer */ |
292 usb2_copy_in(td->pc, 0, &req, sizeof(req)); | 292 usbd_copy_in(td->pc, 0, &req, sizeof(req)); |
293 294 td->offset = sizeof(req); 295 td->remainder = 0; 296 297 /* sneak peek the set address */ 298 if ((req.bmRequestType == UT_WRITE_DEVICE) && 299 (req.bRequest == UR_SET_ADDRESS)) { 300 sc->sc_dv_addr = req.wValue[0] & 0x7F; --- 84 unchanged lines hidden (view full) --- 385 } 386 /* verify the packet byte count */ 387 if (count > td->remainder) { 388 /* invalid USB packet */ 389 td->error = 1; 390 return (0); /* we are complete */ 391 } 392 while (count > 0) { | 293 294 td->offset = sizeof(req); 295 td->remainder = 0; 296 297 /* sneak peek the set address */ 298 if ((req.bmRequestType == UT_WRITE_DEVICE) && 299 (req.bRequest == UR_SET_ADDRESS)) { 300 sc->sc_dv_addr = req.wValue[0] & 0x7F; --- 84 unchanged lines hidden (view full) --- 385 } 386 /* verify the packet byte count */ 387 if (count > td->remainder) { 388 /* invalid USB packet */ 389 td->error = 1; 390 return (0); /* we are complete */ 391 } 392 while (count > 0) { |
393 usb2_get_page(td->pc, td->offset, &buf_res); | 393 usbd_get_page(td->pc, td->offset, &buf_res); |
394 395 /* get correct length */ 396 if (buf_res.length > count) { 397 buf_res.length = count; 398 } 399 /* receive data */ 400 bcopy(sc->physdata + 401 (AVR32_EPTSTA_CURRENT_BANK(temp) << td->bank_shift) + --- 59 unchanged lines hidden (view full) --- 461 count = td->max_packet_size; 462 if (td->remainder < count) { 463 /* we have a short packet */ 464 td->short_pkt = 1; 465 count = td->remainder; 466 } 467 while (count > 0) { 468 | 394 395 /* get correct length */ 396 if (buf_res.length > count) { 397 buf_res.length = count; 398 } 399 /* receive data */ 400 bcopy(sc->physdata + 401 (AVR32_EPTSTA_CURRENT_BANK(temp) << td->bank_shift) + --- 59 unchanged lines hidden (view full) --- 461 count = td->max_packet_size; 462 if (td->remainder < count) { 463 /* we have a short packet */ 464 td->short_pkt = 1; 465 count = td->remainder; 466 } 467 while (count > 0) { 468 |
469 usb2_get_page(td->pc, td->offset, &buf_res); | 469 usbd_get_page(td->pc, td->offset, &buf_res); |
470 471 /* get correct length */ 472 if (buf_res.length > count) { 473 buf_res.length = count; 474 } 475 /* transmit data */ 476 bcopy(buf_res.buffer, sc->physdata + 477 (AVR32_EPTSTA_CURRENT_BANK(temp) << td->bank_shift) + --- 255 unchanged lines hidden (view full) --- 733 struct avr32dci_softc *sc; 734 struct avr32dci_td *td; 735 uint32_t x; 736 uint8_t ep_no; 737 uint8_t need_sync; 738 739 DPRINTFN(9, "addr=%d endpt=%d sumlen=%d speed=%d\n", 740 xfer->address, UE_GET_ADDR(xfer->endpoint), | 470 471 /* get correct length */ 472 if (buf_res.length > count) { 473 buf_res.length = count; 474 } 475 /* transmit data */ 476 bcopy(buf_res.buffer, sc->physdata + 477 (AVR32_EPTSTA_CURRENT_BANK(temp) << td->bank_shift) + --- 255 unchanged lines hidden (view full) --- 733 struct avr32dci_softc *sc; 734 struct avr32dci_td *td; 735 uint32_t x; 736 uint8_t ep_no; 737 uint8_t need_sync; 738 739 DPRINTFN(9, "addr=%d endpt=%d sumlen=%d speed=%d\n", 740 xfer->address, UE_GET_ADDR(xfer->endpoint), |
741 xfer->sumlen, usb2_get_speed(xfer->xroot->udev)); | 741 xfer->sumlen, usbd_get_speed(xfer->xroot->udev)); |
742 743 temp.max_frame_size = xfer->max_frame_size; 744 745 td = xfer->td_start[0]; 746 xfer->td_transfer_first = td; 747 xfer->td_transfer_cache = td; 748 749 /* setup temp */ --- 145 unchanged lines hidden (view full) --- 895 896 /* poll one time - will turn on interrupts */ 897 if (avr32dci_xfer_do_fifo(xfer)) { 898 uint8_t ep_no = xfer->endpoint & UE_ADDR_MASK; 899 900 avr32dci_mod_ien(sc, AVR32_INT_EPT_INT(ep_no), 0); 901 902 /* put transfer on interrupt queue */ | 742 743 temp.max_frame_size = xfer->max_frame_size; 744 745 td = xfer->td_start[0]; 746 xfer->td_transfer_first = td; 747 xfer->td_transfer_cache = td; 748 749 /* setup temp */ --- 145 unchanged lines hidden (view full) --- 895 896 /* poll one time - will turn on interrupts */ 897 if (avr32dci_xfer_do_fifo(xfer)) { 898 uint8_t ep_no = xfer->endpoint & UE_ADDR_MASK; 899 900 avr32dci_mod_ien(sc, AVR32_INT_EPT_INT(ep_no), 0); 901 902 /* put transfer on interrupt queue */ |
903 usb2_transfer_enqueue(&xfer->xroot->bus->intr_q, xfer); | 903 usbd_transfer_enqueue(&xfer->xroot->bus->intr_q, xfer); |
904 905 /* start timeout, if any */ 906 if (xfer->timeout != 0) { | 904 905 /* start timeout, if any */ 906 if (xfer->timeout != 0) { |
907 usb2_transfer_timeout_ms(xfer, | 907 usbd_transfer_timeout_ms(xfer, |
908 &avr32dci_timeout, xfer->timeout); 909 } 910 } 911} 912 913static void 914avr32dci_root_intr(struct avr32dci_softc *sc) 915{ --- 136 unchanged lines hidden (view full) --- 1052 ep_no = (xfer->endpoint & UE_ADDR); 1053 1054 /* disable endpoint interrupt */ 1055 avr32dci_mod_ien(sc, 0, AVR32_INT_EPT_INT(ep_no)); 1056 1057 DPRINTFN(15, "disabled interrupts!\n"); 1058 } 1059 /* dequeue transfer and start next transfer */ | 908 &avr32dci_timeout, xfer->timeout); 909 } 910 } 911} 912 913static void 914avr32dci_root_intr(struct avr32dci_softc *sc) 915{ --- 136 unchanged lines hidden (view full) --- 1052 ep_no = (xfer->endpoint & UE_ADDR); 1053 1054 /* disable endpoint interrupt */ 1055 avr32dci_mod_ien(sc, 0, AVR32_INT_EPT_INT(ep_no)); 1056 1057 DPRINTFN(15, "disabled interrupts!\n"); 1058 } 1059 /* dequeue transfer and start next transfer */ |
1060 usb2_transfer_done(xfer, error); | 1060 usbd_transfer_done(xfer, error); |
1061} 1062 1063static void 1064avr32dci_set_stall(struct usb_device *udev, struct usb_xfer *xfer, 1065 struct usb_endpoint *ep) 1066{ 1067 struct avr32dci_softc *sc; 1068 uint8_t ep_no; --- 124 unchanged lines hidden (view full) --- 1193 1194 /* turn on clocks */ 1195 (sc->sc_clocks_on) (&sc->sc_bus); 1196 1197 /* make sure device is re-enumerated */ 1198 avr32dci_mod_ctrl(sc, AVR32_CTRL_DEV_DETACH, 0); 1199 1200 /* wait a little for things to stabilise */ | 1061} 1062 1063static void 1064avr32dci_set_stall(struct usb_device *udev, struct usb_xfer *xfer, 1065 struct usb_endpoint *ep) 1066{ 1067 struct avr32dci_softc *sc; 1068 uint8_t ep_no; --- 124 unchanged lines hidden (view full) --- 1193 1194 /* turn on clocks */ 1195 (sc->sc_clocks_on) (&sc->sc_bus); 1196 1197 /* make sure device is re-enumerated */ 1198 avr32dci_mod_ctrl(sc, AVR32_CTRL_DEV_DETACH, 0); 1199 1200 /* wait a little for things to stabilise */ |
1201 usb2_pause_mtx(&sc->sc_bus.bus_mtx, hz / 20); | 1201 usb_pause_mtx(&sc->sc_bus.bus_mtx, hz / 20); |
1202 1203 /* disable interrupts */ 1204 avr32dci_mod_ien(sc, 0, 0xFFFFFFFF); 1205 1206 /* enable interrupts */ 1207 avr32dci_mod_ien(sc, AVR32_INT_DET_SUSPD | 1208 AVR32_INT_ENDRESET, 0); 1209 --- 172 unchanged lines hidden (view full) --- 1382 * current frame position: 1383 */ 1384 temp = (xfer->pipe->isoc_next - nframes) & AVR32_FRAME_MASK; 1385 1386 /* 1387 * pre-compute when the isochronous transfer will be finished: 1388 */ 1389 xfer->isoc_time_complete = | 1202 1203 /* disable interrupts */ 1204 avr32dci_mod_ien(sc, 0, 0xFFFFFFFF); 1205 1206 /* enable interrupts */ 1207 avr32dci_mod_ien(sc, AVR32_INT_DET_SUSPD | 1208 AVR32_INT_ENDRESET, 0); 1209 --- 172 unchanged lines hidden (view full) --- 1382 * current frame position: 1383 */ 1384 temp = (xfer->pipe->isoc_next - nframes) & AVR32_FRAME_MASK; 1385 1386 /* 1387 * pre-compute when the isochronous transfer will be finished: 1388 */ 1389 xfer->isoc_time_complete = |
1390 usb2_isoc_time_expand(&sc->sc_bus, nframes) + temp + | 1390 usb_isoc_time_expand(&sc->sc_bus, nframes) + temp + |
1391 xfer->nframes; 1392 1393 /* compute frame number for next insertion */ 1394 xfer->pipe->isoc_next += xfer->nframes; 1395 1396 /* setup TDs */ 1397 avr32dci_setup_standard_chain(xfer); 1398} --- 546 unchanged lines hidden (view full) --- 1945 * NOTE: This driver does not use any of the parameters that 1946 * are computed from the following values. Just set some 1947 * reasonable dummies: 1948 */ 1949 parm->hc_max_packet_size = 0x400; 1950 parm->hc_max_packet_count = 1; 1951 parm->hc_max_frame_size = 0x400; 1952 | 1391 xfer->nframes; 1392 1393 /* compute frame number for next insertion */ 1394 xfer->pipe->isoc_next += xfer->nframes; 1395 1396 /* setup TDs */ 1397 avr32dci_setup_standard_chain(xfer); 1398} --- 546 unchanged lines hidden (view full) --- 1945 * NOTE: This driver does not use any of the parameters that 1946 * are computed from the following values. Just set some 1947 * reasonable dummies: 1948 */ 1949 parm->hc_max_packet_size = 0x400; 1950 parm->hc_max_packet_count = 1; 1951 parm->hc_max_frame_size = 0x400; 1952 |
1953 usb2_transfer_setup_sub(parm); | 1953 usbd_transfer_setup_sub(parm); |
1954 1955 /* 1956 * compute maximum number of TDs 1957 */ 1958 if ((xfer->pipe->edesc->bmAttributes & UE_XFERTYPE) == UE_CONTROL) { 1959 1960 ntd = xfer->nframes + 1 /* STATUS */ + 1 /* SYNC 1 */ 1961 + 1 /* SYNC 2 */ ; 1962 } else { 1963 1964 ntd = xfer->nframes + 1 /* SYNC */ ; 1965 } 1966 1967 /* | 1954 1955 /* 1956 * compute maximum number of TDs 1957 */ 1958 if ((xfer->pipe->edesc->bmAttributes & UE_XFERTYPE) == UE_CONTROL) { 1959 1960 ntd = xfer->nframes + 1 /* STATUS */ + 1 /* SYNC 1 */ 1961 + 1 /* SYNC 2 */ ; 1962 } else { 1963 1964 ntd = xfer->nframes + 1 /* SYNC */ ; 1965 } 1966 1967 /* |
1968 * check if "usb2_transfer_setup_sub" set an error | 1968 * check if "usbd_transfer_setup_sub" set an error |
1969 */ 1970 if (parm->err) 1971 return; 1972 1973 /* 1974 * allocate transfer descriptors 1975 */ 1976 last_obj = NULL; --- 89 unchanged lines hidden --- | 1969 */ 1970 if (parm->err) 1971 return; 1972 1973 /* 1974 * allocate transfer descriptors 1975 */ 1976 last_obj = NULL; --- 89 unchanged lines hidden --- |