uhci.c (187172) | uhci.c (187173) |
---|---|
1/*- 2 * Copyright (c) 2008 Hans Petter Selasky. All rights reserved. 3 * Copyright (c) 1998 The NetBSD Foundation, Inc. All rights reserved. 4 * Copyright (c) 1998 Lennart Augustsson. All rights reserved. 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions 8 * are met: --- 12 unchanged lines hidden (view full) --- 21 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 22 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 23 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 24 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 25 * SUCH DAMAGE. 26 */ 27 28#include <sys/cdefs.h> | 1/*- 2 * Copyright (c) 2008 Hans Petter Selasky. All rights reserved. 3 * Copyright (c) 1998 The NetBSD Foundation, Inc. All rights reserved. 4 * Copyright (c) 1998 Lennart Augustsson. All rights reserved. 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions 8 * are met: --- 12 unchanged lines hidden (view full) --- 21 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 22 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 23 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 24 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 25 * SUCH DAMAGE. 26 */ 27 28#include <sys/cdefs.h> |
29__FBSDID("$FreeBSD: head/sys/dev/usb2/controller/uhci2.c 187172 2009-01-13 19:03:01Z thompsa $"); | 29__FBSDID("$FreeBSD: head/sys/dev/usb2/controller/uhci2.c 187173 2009-01-13 19:03:12Z thompsa $"); |
30 31/* 32 * USB Universal Host Controller driver. 33 * Handles e.g. PIIX3 and PIIX4. 34 * 35 * UHCI spec: http://developer.intel.com/design/USB/UHCI11D.htm 36 * USB spec: http://www.usb.org/developers/docs/usbspec.zip 37 * PIIXn spec: ftp://download.intel.com/design/intarch/datashts/29055002.pdf --- 835 unchanged lines hidden (view full) --- 873static void 874uhci_transfer_intr_enqueue(struct usb2_xfer *xfer) 875{ 876 /* check for early completion */ 877 if (uhci_check_transfer(xfer)) { 878 return; 879 } 880 /* put transfer on interrupt queue */ | 30 31/* 32 * USB Universal Host Controller driver. 33 * Handles e.g. PIIX3 and PIIX4. 34 * 35 * UHCI spec: http://developer.intel.com/design/USB/UHCI11D.htm 36 * USB spec: http://www.usb.org/developers/docs/usbspec.zip 37 * PIIXn spec: ftp://download.intel.com/design/intarch/datashts/29055002.pdf --- 835 unchanged lines hidden (view full) --- 873static void 874uhci_transfer_intr_enqueue(struct usb2_xfer *xfer) 875{ 876 /* check for early completion */ 877 if (uhci_check_transfer(xfer)) { 878 return; 879 } 880 /* put transfer on interrupt queue */ |
881 usb2_transfer_enqueue(&xfer->udev->bus->intr_q, xfer); | 881 usb2_transfer_enqueue(&xfer->xroot->bus->intr_q, xfer); |
882 883 /* start timeout, if any */ 884 if (xfer->timeout != 0) { 885 usb2_transfer_timeout_ms(xfer, &uhci_timeout, xfer->timeout); 886 } 887} 888 889#define UHCI_APPEND_TD(std,last) (last) = _uhci_append_td(std,last) --- 595 unchanged lines hidden (view full) --- 1485 */ 1486static void 1487uhci_timeout(void *arg) 1488{ 1489 struct usb2_xfer *xfer = arg; 1490 1491 DPRINTF("xfer=%p\n", xfer); 1492 | 882 883 /* start timeout, if any */ 884 if (xfer->timeout != 0) { 885 usb2_transfer_timeout_ms(xfer, &uhci_timeout, xfer->timeout); 886 } 887} 888 889#define UHCI_APPEND_TD(std,last) (last) = _uhci_append_td(std,last) --- 595 unchanged lines hidden (view full) --- 1485 */ 1486static void 1487uhci_timeout(void *arg) 1488{ 1489 struct usb2_xfer *xfer = arg; 1490 1491 DPRINTF("xfer=%p\n", xfer); 1492 |
1493 USB_BUS_LOCK_ASSERT(xfer->udev->bus, MA_OWNED); | 1493 USB_BUS_LOCK_ASSERT(xfer->xroot->bus, MA_OWNED); |
1494 1495 /* transfer is transferred */ 1496 uhci_device_done(xfer, USB_ERR_TIMEOUT); 1497} 1498 1499static void 1500uhci_do_poll(struct usb2_bus *bus) 1501{ --- 152 unchanged lines hidden (view full) --- 1654uhci_setup_standard_chain(struct usb2_xfer *xfer) 1655{ 1656 struct uhci_std_temp temp; 1657 uhci_td_t *td; 1658 uint32_t x; 1659 1660 DPRINTFN(9, "addr=%d endpt=%d sumlen=%d speed=%d\n", 1661 xfer->address, UE_GET_ADDR(xfer->endpoint), | 1494 1495 /* transfer is transferred */ 1496 uhci_device_done(xfer, USB_ERR_TIMEOUT); 1497} 1498 1499static void 1500uhci_do_poll(struct usb2_bus *bus) 1501{ --- 152 unchanged lines hidden (view full) --- 1654uhci_setup_standard_chain(struct usb2_xfer *xfer) 1655{ 1656 struct uhci_std_temp temp; 1657 uhci_td_t *td; 1658 uint32_t x; 1659 1660 DPRINTFN(9, "addr=%d endpt=%d sumlen=%d speed=%d\n", 1661 xfer->address, UE_GET_ADDR(xfer->endpoint), |
1662 xfer->sumlen, usb2_get_speed(xfer->udev)); | 1662 xfer->sumlen, usb2_get_speed(xfer->xroot->udev)); |
1663 1664 temp.average = xfer->max_frame_size; 1665 temp.max_frame_size = xfer->max_frame_size; 1666 1667 /* toggle the DMA set we are using */ 1668 xfer->flags_int.curr_dma_set ^= 1; 1669 1670 /* get next DMA set */ --- 7 unchanged lines hidden (view full) --- 1678 temp.short_frames_ok = xfer->flags_int.short_frames_ok; 1679 1680 uhci_mem_layout_init(&temp.ml, xfer); 1681 1682 temp.td_status = 1683 htole32(UHCI_TD_ZERO_ACTLEN(UHCI_TD_SET_ERRCNT(3) | 1684 UHCI_TD_ACTIVE)); 1685 | 1663 1664 temp.average = xfer->max_frame_size; 1665 temp.max_frame_size = xfer->max_frame_size; 1666 1667 /* toggle the DMA set we are using */ 1668 xfer->flags_int.curr_dma_set ^= 1; 1669 1670 /* get next DMA set */ --- 7 unchanged lines hidden (view full) --- 1678 temp.short_frames_ok = xfer->flags_int.short_frames_ok; 1679 1680 uhci_mem_layout_init(&temp.ml, xfer); 1681 1682 temp.td_status = 1683 htole32(UHCI_TD_ZERO_ACTLEN(UHCI_TD_SET_ERRCNT(3) | 1684 UHCI_TD_ACTIVE)); 1685 |
1686 if (xfer->udev->speed == USB_SPEED_LOW) { | 1686 if (xfer->xroot->udev->speed == USB_SPEED_LOW) { |
1687 temp.td_status |= htole32(UHCI_TD_LS); 1688 } 1689 temp.td_token = 1690 htole32(UHCI_TD_SET_ENDPT(xfer->endpoint) | 1691 UHCI_TD_SET_DEVADDR(xfer->address)); 1692 1693 if (xfer->pipe->toggle_next) { 1694 /* DATA1 is next */ --- 116 unchanged lines hidden (view full) --- 1811/* NOTE: "done" can be run two times in a row, 1812 * from close and from interrupt 1813 */ 1814 1815static void 1816uhci_device_done(struct usb2_xfer *xfer, usb2_error_t error) 1817{ 1818 struct usb2_pipe_methods *methods = xfer->pipe->methods; | 1687 temp.td_status |= htole32(UHCI_TD_LS); 1688 } 1689 temp.td_token = 1690 htole32(UHCI_TD_SET_ENDPT(xfer->endpoint) | 1691 UHCI_TD_SET_DEVADDR(xfer->address)); 1692 1693 if (xfer->pipe->toggle_next) { 1694 /* DATA1 is next */ --- 116 unchanged lines hidden (view full) --- 1811/* NOTE: "done" can be run two times in a row, 1812 * from close and from interrupt 1813 */ 1814 1815static void 1816uhci_device_done(struct usb2_xfer *xfer, usb2_error_t error) 1817{ 1818 struct usb2_pipe_methods *methods = xfer->pipe->methods; |
1819 uhci_softc_t *sc = xfer->usb2_sc; | 1819 uhci_softc_t *sc = UHCI_BUS2SC(xfer->xroot->bus); |
1820 uhci_qh_t *qh; 1821 1822 USB_BUS_LOCK_ASSERT(&sc->sc_bus, MA_OWNED); 1823 1824 DPRINTFN(2, "xfer=%p, pipe=%p, error=%d\n", 1825 xfer, xfer->pipe, error); 1826 1827 qh = xfer->qh_start[xfer->flags_int.curr_dma_set]; 1828 if (qh) { 1829 usb2_pc_cpu_invalidate(qh->page_cache); 1830 } 1831 if (xfer->flags_int.bandwidth_reclaimed) { 1832 xfer->flags_int.bandwidth_reclaimed = 0; 1833 uhci_rem_loop(sc); 1834 } 1835 if (methods == &uhci_device_bulk_methods) { 1836 UHCI_REMOVE_QH(qh, sc->sc_bulk_p_last); 1837 } 1838 if (methods == &uhci_device_ctrl_methods) { | 1820 uhci_qh_t *qh; 1821 1822 USB_BUS_LOCK_ASSERT(&sc->sc_bus, MA_OWNED); 1823 1824 DPRINTFN(2, "xfer=%p, pipe=%p, error=%d\n", 1825 xfer, xfer->pipe, error); 1826 1827 qh = xfer->qh_start[xfer->flags_int.curr_dma_set]; 1828 if (qh) { 1829 usb2_pc_cpu_invalidate(qh->page_cache); 1830 } 1831 if (xfer->flags_int.bandwidth_reclaimed) { 1832 xfer->flags_int.bandwidth_reclaimed = 0; 1833 uhci_rem_loop(sc); 1834 } 1835 if (methods == &uhci_device_bulk_methods) { 1836 UHCI_REMOVE_QH(qh, sc->sc_bulk_p_last); 1837 } 1838 if (methods == &uhci_device_ctrl_methods) { |
1839 if (xfer->udev->speed == USB_SPEED_LOW) { | 1839 if (xfer->xroot->udev->speed == USB_SPEED_LOW) { |
1840 UHCI_REMOVE_QH(qh, sc->sc_ls_ctl_p_last); 1841 } else { 1842 UHCI_REMOVE_QH(qh, sc->sc_fs_ctl_p_last); 1843 } 1844 } 1845 if (methods == &uhci_device_intr_methods) { 1846 UHCI_REMOVE_QH(qh, sc->sc_intr_p_last[xfer->qh_pos]); 1847 } --- 32 unchanged lines hidden (view full) --- 1880uhci_device_bulk_enter(struct usb2_xfer *xfer) 1881{ 1882 return; 1883} 1884 1885static void 1886uhci_device_bulk_start(struct usb2_xfer *xfer) 1887{ | 1840 UHCI_REMOVE_QH(qh, sc->sc_ls_ctl_p_last); 1841 } else { 1842 UHCI_REMOVE_QH(qh, sc->sc_fs_ctl_p_last); 1843 } 1844 } 1845 if (methods == &uhci_device_intr_methods) { 1846 UHCI_REMOVE_QH(qh, sc->sc_intr_p_last[xfer->qh_pos]); 1847 } --- 32 unchanged lines hidden (view full) --- 1880uhci_device_bulk_enter(struct usb2_xfer *xfer) 1881{ 1882 return; 1883} 1884 1885static void 1886uhci_device_bulk_start(struct usb2_xfer *xfer) 1887{ |
1888 uhci_softc_t *sc = xfer->usb2_sc; | 1888 uhci_softc_t *sc = UHCI_BUS2SC(xfer->xroot->bus); |
1889 uhci_td_t *td; 1890 uhci_qh_t *qh; 1891 1892 /* setup TD's */ 1893 td = uhci_setup_standard_chain(xfer); 1894 1895 /* setup QH */ 1896 qh = xfer->qh_start[xfer->flags_int.curr_dma_set]; 1897 1898 qh->e_next = td; 1899 qh->qh_e_next = td->td_self; 1900 | 1889 uhci_td_t *td; 1890 uhci_qh_t *qh; 1891 1892 /* setup TD's */ 1893 td = uhci_setup_standard_chain(xfer); 1894 1895 /* setup QH */ 1896 qh = xfer->qh_start[xfer->flags_int.curr_dma_set]; 1897 1898 qh->e_next = td; 1899 qh->qh_e_next = td->td_self; 1900 |
1901 if (xfer->udev->pwr_save.suspended == 0) { | 1901 if (xfer->xroot->udev->pwr_save.suspended == 0) { |
1902 UHCI_APPEND_QH(qh, sc->sc_bulk_p_last); 1903 uhci_add_loop(sc); 1904 xfer->flags_int.bandwidth_reclaimed = 1; 1905 } else { 1906 usb2_pc_cpu_flush(qh->page_cache); 1907 } 1908 1909 /* put transfer on interrupt queue */ --- 29 unchanged lines hidden (view full) --- 1939uhci_device_ctrl_enter(struct usb2_xfer *xfer) 1940{ 1941 return; 1942} 1943 1944static void 1945uhci_device_ctrl_start(struct usb2_xfer *xfer) 1946{ | 1902 UHCI_APPEND_QH(qh, sc->sc_bulk_p_last); 1903 uhci_add_loop(sc); 1904 xfer->flags_int.bandwidth_reclaimed = 1; 1905 } else { 1906 usb2_pc_cpu_flush(qh->page_cache); 1907 } 1908 1909 /* put transfer on interrupt queue */ --- 29 unchanged lines hidden (view full) --- 1939uhci_device_ctrl_enter(struct usb2_xfer *xfer) 1940{ 1941 return; 1942} 1943 1944static void 1945uhci_device_ctrl_start(struct usb2_xfer *xfer) 1946{ |
1947 uhci_softc_t *sc = xfer->usb2_sc; | 1947 uhci_softc_t *sc = UHCI_BUS2SC(xfer->xroot->bus); |
1948 uhci_qh_t *qh; 1949 uhci_td_t *td; 1950 1951 /* setup TD's */ 1952 td = uhci_setup_standard_chain(xfer); 1953 1954 /* setup QH */ 1955 qh = xfer->qh_start[xfer->flags_int.curr_dma_set]; 1956 1957 qh->e_next = td; 1958 qh->qh_e_next = td->td_self; 1959 1960 /* 1961 * NOTE: some devices choke on bandwidth- reclamation for control 1962 * transfers 1963 */ | 1948 uhci_qh_t *qh; 1949 uhci_td_t *td; 1950 1951 /* setup TD's */ 1952 td = uhci_setup_standard_chain(xfer); 1953 1954 /* setup QH */ 1955 qh = xfer->qh_start[xfer->flags_int.curr_dma_set]; 1956 1957 qh->e_next = td; 1958 qh->qh_e_next = td->td_self; 1959 1960 /* 1961 * NOTE: some devices choke on bandwidth- reclamation for control 1962 * transfers 1963 */ |
1964 if (xfer->udev->pwr_save.suspended == 0) { 1965 if (xfer->udev->speed == USB_SPEED_LOW) { | 1964 if (xfer->xroot->udev->pwr_save.suspended == 0) { 1965 if (xfer->xroot->udev->speed == USB_SPEED_LOW) { |
1966 UHCI_APPEND_QH(qh, sc->sc_ls_ctl_p_last); 1967 } else { 1968 UHCI_APPEND_QH(qh, sc->sc_fs_ctl_p_last); 1969 } 1970 } else { 1971 usb2_pc_cpu_flush(qh->page_cache); 1972 } 1973 /* put transfer on interrupt queue */ --- 11 unchanged lines hidden (view full) --- 1985}; 1986 1987/*------------------------------------------------------------------------* 1988 * uhci interrupt support 1989 *------------------------------------------------------------------------*/ 1990static void 1991uhci_device_intr_open(struct usb2_xfer *xfer) 1992{ | 1966 UHCI_APPEND_QH(qh, sc->sc_ls_ctl_p_last); 1967 } else { 1968 UHCI_APPEND_QH(qh, sc->sc_fs_ctl_p_last); 1969 } 1970 } else { 1971 usb2_pc_cpu_flush(qh->page_cache); 1972 } 1973 /* put transfer on interrupt queue */ --- 11 unchanged lines hidden (view full) --- 1985}; 1986 1987/*------------------------------------------------------------------------* 1988 * uhci interrupt support 1989 *------------------------------------------------------------------------*/ 1990static void 1991uhci_device_intr_open(struct usb2_xfer *xfer) 1992{ |
1993 uhci_softc_t *sc = xfer->usb2_sc; | 1993 uhci_softc_t *sc = UHCI_BUS2SC(xfer->xroot->bus); |
1994 uint16_t best; 1995 uint16_t bit; 1996 uint16_t x; 1997 1998 best = 0; 1999 bit = UHCI_IFRAMELIST_COUNT / 2; 2000 while (bit) { 2001 if (xfer->interval >= bit) { --- 16 unchanged lines hidden (view full) --- 2018 2019 DPRINTFN(3, "best=%d interval=%d\n", 2020 best, xfer->interval); 2021} 2022 2023static void 2024uhci_device_intr_close(struct usb2_xfer *xfer) 2025{ | 1994 uint16_t best; 1995 uint16_t bit; 1996 uint16_t x; 1997 1998 best = 0; 1999 bit = UHCI_IFRAMELIST_COUNT / 2; 2000 while (bit) { 2001 if (xfer->interval >= bit) { --- 16 unchanged lines hidden (view full) --- 2018 2019 DPRINTFN(3, "best=%d interval=%d\n", 2020 best, xfer->interval); 2021} 2022 2023static void 2024uhci_device_intr_close(struct usb2_xfer *xfer) 2025{ |
2026 uhci_softc_t *sc = xfer->usb2_sc; | 2026 uhci_softc_t *sc = UHCI_BUS2SC(xfer->xroot->bus); |
2027 2028 sc->sc_intr_stat[xfer->qh_pos]--; 2029 2030 uhci_device_done(xfer, USB_ERR_CANCELLED); 2031} 2032 2033static void 2034uhci_device_intr_enter(struct usb2_xfer *xfer) 2035{ 2036 return; 2037} 2038 2039static void 2040uhci_device_intr_start(struct usb2_xfer *xfer) 2041{ | 2027 2028 sc->sc_intr_stat[xfer->qh_pos]--; 2029 2030 uhci_device_done(xfer, USB_ERR_CANCELLED); 2031} 2032 2033static void 2034uhci_device_intr_enter(struct usb2_xfer *xfer) 2035{ 2036 return; 2037} 2038 2039static void 2040uhci_device_intr_start(struct usb2_xfer *xfer) 2041{ |
2042 uhci_softc_t *sc = xfer->usb2_sc; | 2042 uhci_softc_t *sc = UHCI_BUS2SC(xfer->xroot->bus); |
2043 uhci_qh_t *qh; 2044 uhci_td_t *td; 2045 2046 /* setup TD's */ 2047 td = uhci_setup_standard_chain(xfer); 2048 2049 /* setup QH */ 2050 qh = xfer->qh_start[xfer->flags_int.curr_dma_set]; 2051 2052 qh->e_next = td; 2053 qh->qh_e_next = td->td_self; 2054 | 2043 uhci_qh_t *qh; 2044 uhci_td_t *td; 2045 2046 /* setup TD's */ 2047 td = uhci_setup_standard_chain(xfer); 2048 2049 /* setup QH */ 2050 qh = xfer->qh_start[xfer->flags_int.curr_dma_set]; 2051 2052 qh->e_next = td; 2053 qh->qh_e_next = td->td_self; 2054 |
2055 if (xfer->udev->pwr_save.suspended == 0) { | 2055 if (xfer->xroot->udev->pwr_save.suspended == 0) { |
2056 2057 /* enter QHs into the controller data structures */ 2058 UHCI_APPEND_QH(qh, sc->sc_intr_p_last[xfer->qh_pos]); 2059 2060 } else { 2061 usb2_pc_cpu_flush(qh->page_cache); 2062 } 2063 --- 48 unchanged lines hidden (view full) --- 2112{ 2113 uhci_device_done(xfer, USB_ERR_CANCELLED); 2114} 2115 2116static void 2117uhci_device_isoc_enter(struct usb2_xfer *xfer) 2118{ 2119 struct uhci_mem_layout ml; | 2056 2057 /* enter QHs into the controller data structures */ 2058 UHCI_APPEND_QH(qh, sc->sc_intr_p_last[xfer->qh_pos]); 2059 2060 } else { 2061 usb2_pc_cpu_flush(qh->page_cache); 2062 } 2063 --- 48 unchanged lines hidden (view full) --- 2112{ 2113 uhci_device_done(xfer, USB_ERR_CANCELLED); 2114} 2115 2116static void 2117uhci_device_isoc_enter(struct usb2_xfer *xfer) 2118{ 2119 struct uhci_mem_layout ml; |
2120 uhci_softc_t *sc = xfer->usb2_sc; | 2120 uhci_softc_t *sc = UHCI_BUS2SC(xfer->xroot->bus); |
2121 uint32_t nframes; 2122 uint32_t temp; 2123 uint32_t *plen; 2124 2125#if USB_DEBUG 2126 uint8_t once = 1; 2127 2128#endif --- 167 unchanged lines hidden (view full) --- 2296uhci_root_ctrl_open(struct usb2_xfer *xfer) 2297{ 2298 return; 2299} 2300 2301static void 2302uhci_root_ctrl_close(struct usb2_xfer *xfer) 2303{ | 2121 uint32_t nframes; 2122 uint32_t temp; 2123 uint32_t *plen; 2124 2125#if USB_DEBUG 2126 uint8_t once = 1; 2127 2128#endif --- 167 unchanged lines hidden (view full) --- 2296uhci_root_ctrl_open(struct usb2_xfer *xfer) 2297{ 2298 return; 2299} 2300 2301static void 2302uhci_root_ctrl_close(struct usb2_xfer *xfer) 2303{ |
2304 uhci_softc_t *sc = xfer->usb2_sc; | 2304 uhci_softc_t *sc = UHCI_BUS2SC(xfer->xroot->bus); |
2305 2306 if (sc->sc_root_ctrl.xfer == xfer) { 2307 sc->sc_root_ctrl.xfer = NULL; 2308 } 2309 uhci_device_done(xfer, USB_ERR_CANCELLED); 2310} 2311 2312/* data structures and routines --- 174 unchanged lines hidden (view full) --- 2487uhci_root_ctrl_enter(struct usb2_xfer *xfer) 2488{ 2489 return; 2490} 2491 2492static void 2493uhci_root_ctrl_start(struct usb2_xfer *xfer) 2494{ | 2305 2306 if (sc->sc_root_ctrl.xfer == xfer) { 2307 sc->sc_root_ctrl.xfer = NULL; 2308 } 2309 uhci_device_done(xfer, USB_ERR_CANCELLED); 2310} 2311 2312/* data structures and routines --- 174 unchanged lines hidden (view full) --- 2487uhci_root_ctrl_enter(struct usb2_xfer *xfer) 2488{ 2489 return; 2490} 2491 2492static void 2493uhci_root_ctrl_start(struct usb2_xfer *xfer) 2494{ |
2495 uhci_softc_t *sc = xfer->usb2_sc; | 2495 uhci_softc_t *sc = UHCI_BUS2SC(xfer->xroot->bus); |
2496 2497 DPRINTF("\n"); 2498 2499 sc->sc_root_ctrl.xfer = xfer; 2500 | 2496 2497 DPRINTF("\n"); 2498 2499 sc->sc_root_ctrl.xfer = xfer; 2500 |
2501 usb2_bus_roothub_exec(xfer->udev->bus); | 2501 usb2_bus_roothub_exec(xfer->xroot->bus); |
2502} 2503 2504static void 2505uhci_root_ctrl_task(struct usb2_bus *bus) 2506{ 2507 uhci_root_ctrl_poll(UHCI_BUS2SC(bus)); 2508} 2509 2510static void 2511uhci_root_ctrl_done(struct usb2_xfer *xfer, 2512 struct usb2_sw_transfer *std) 2513{ | 2502} 2503 2504static void 2505uhci_root_ctrl_task(struct usb2_bus *bus) 2506{ 2507 uhci_root_ctrl_poll(UHCI_BUS2SC(bus)); 2508} 2509 2510static void 2511uhci_root_ctrl_done(struct usb2_xfer *xfer, 2512 struct usb2_sw_transfer *std) 2513{ |
2514 uhci_softc_t *sc = xfer->usb2_sc; | 2514 uhci_softc_t *sc = UHCI_BUS2SC(xfer->xroot->bus); |
2515 char *ptr; 2516 uint16_t x; 2517 uint16_t port; 2518 uint16_t value; 2519 uint16_t index; 2520 uint16_t status; 2521 uint16_t change; 2522 uint8_t use_polling; --- 9 unchanged lines hidden (view full) --- 2532 } 2533 /* buffer reset */ 2534 std->ptr = sc->sc_hub_desc.temp; 2535 std->len = 0; 2536 2537 value = UGETW(std->req.wValue); 2538 index = UGETW(std->req.wIndex); 2539 | 2515 char *ptr; 2516 uint16_t x; 2517 uint16_t port; 2518 uint16_t value; 2519 uint16_t index; 2520 uint16_t status; 2521 uint16_t change; 2522 uint8_t use_polling; --- 9 unchanged lines hidden (view full) --- 2532 } 2533 /* buffer reset */ 2534 std->ptr = sc->sc_hub_desc.temp; 2535 std->len = 0; 2536 2537 value = UGETW(std->req.wValue); 2538 index = UGETW(std->req.wIndex); 2539 |
2540 use_polling = mtx_owned(xfer->xfer_mtx) ? 1 : 0; | 2540 use_polling = mtx_owned(xfer->xroot->xfer_mtx) ? 1 : 0; |
2541 2542 DPRINTFN(3, "type=0x%02x request=0x%02x wLen=0x%04x " 2543 "wValue=0x%04x wIndex=0x%04x\n", 2544 std->req.bmRequestType, std->req.bRequest, 2545 UGETW(std->req.wLength), value, index); 2546 2547#define C(x,y) ((x) | ((y) << 8)) 2548 switch (C(std->req.bRequest, std->req.bmRequestType)) { --- 312 unchanged lines hidden (view full) --- 2861uhci_root_intr_open(struct usb2_xfer *xfer) 2862{ 2863 return; 2864} 2865 2866static void 2867uhci_root_intr_close(struct usb2_xfer *xfer) 2868{ | 2541 2542 DPRINTFN(3, "type=0x%02x request=0x%02x wLen=0x%04x " 2543 "wValue=0x%04x wIndex=0x%04x\n", 2544 std->req.bmRequestType, std->req.bRequest, 2545 UGETW(std->req.wLength), value, index); 2546 2547#define C(x,y) ((x) | ((y) << 8)) 2548 switch (C(std->req.bRequest, std->req.bmRequestType)) { --- 312 unchanged lines hidden (view full) --- 2861uhci_root_intr_open(struct usb2_xfer *xfer) 2862{ 2863 return; 2864} 2865 2866static void 2867uhci_root_intr_close(struct usb2_xfer *xfer) 2868{ |
2869 uhci_softc_t *sc = xfer->usb2_sc; | 2869 uhci_softc_t *sc = UHCI_BUS2SC(xfer->xroot->bus); |
2870 2871 if (sc->sc_root_intr.xfer == xfer) { 2872 sc->sc_root_intr.xfer = NULL; 2873 } 2874 uhci_device_done(xfer, USB_ERR_CANCELLED); 2875} 2876 2877static void 2878uhci_root_intr_enter(struct usb2_xfer *xfer) 2879{ 2880 return; 2881} 2882 2883static void 2884uhci_root_intr_start(struct usb2_xfer *xfer) 2885{ | 2870 2871 if (sc->sc_root_intr.xfer == xfer) { 2872 sc->sc_root_intr.xfer = NULL; 2873 } 2874 uhci_device_done(xfer, USB_ERR_CANCELLED); 2875} 2876 2877static void 2878uhci_root_intr_enter(struct usb2_xfer *xfer) 2879{ 2880 return; 2881} 2882 2883static void 2884uhci_root_intr_start(struct usb2_xfer *xfer) 2885{ |
2886 uhci_softc_t *sc = xfer->usb2_sc; | 2886 uhci_softc_t *sc = UHCI_BUS2SC(xfer->xroot->bus); |
2887 2888 sc->sc_root_intr.xfer = xfer; 2889 2890 usb2_transfer_timeout_ms(xfer, 2891 &uhci_root_intr_check, xfer->interval); 2892} 2893 2894static void 2895uhci_root_intr_done(struct usb2_xfer *xfer, 2896 struct usb2_sw_transfer *std) 2897{ | 2887 2888 sc->sc_root_intr.xfer = xfer; 2889 2890 usb2_transfer_timeout_ms(xfer, 2891 &uhci_root_intr_check, xfer->interval); 2892} 2893 2894static void 2895uhci_root_intr_done(struct usb2_xfer *xfer, 2896 struct usb2_sw_transfer *std) 2897{ |
2898 uhci_softc_t *sc = xfer->usb2_sc; | 2898 uhci_softc_t *sc = UHCI_BUS2SC(xfer->xroot->bus); |
2899 2900 USB_BUS_LOCK_ASSERT(&sc->sc_bus, MA_OWNED); 2901 2902 if (std->state != USB_SW_TR_PRE_DATA) { 2903 if (std->state == USB_SW_TR_PRE_CALLBACK) { 2904 /* transfer is transferred */ 2905 uhci_device_done(xfer, std->err); 2906 } --- 9 unchanged lines hidden (view full) --- 2916/* 2917 * this routine is executed periodically and simulates interrupts 2918 * from the root controller interrupt pipe for port status change 2919 */ 2920static void 2921uhci_root_intr_check(void *arg) 2922{ 2923 struct usb2_xfer *xfer = arg; | 2899 2900 USB_BUS_LOCK_ASSERT(&sc->sc_bus, MA_OWNED); 2901 2902 if (std->state != USB_SW_TR_PRE_DATA) { 2903 if (std->state == USB_SW_TR_PRE_CALLBACK) { 2904 /* transfer is transferred */ 2905 uhci_device_done(xfer, std->err); 2906 } --- 9 unchanged lines hidden (view full) --- 2916/* 2917 * this routine is executed periodically and simulates interrupts 2918 * from the root controller interrupt pipe for port status change 2919 */ 2920static void 2921uhci_root_intr_check(void *arg) 2922{ 2923 struct usb2_xfer *xfer = arg; |
2924 uhci_softc_t *sc = xfer->usb2_sc; | 2924 uhci_softc_t *sc = UHCI_BUS2SC(xfer->xroot->bus); |
2925 2926 DPRINTFN(21, "\n"); 2927 2928 USB_BUS_LOCK_ASSERT(&sc->sc_bus, MA_OWNED); 2929 2930 sc->sc_hub_idata[0] = 0; 2931 2932 if (UREAD2(sc, UHCI_PORTSC1) & (UHCI_PORTSC_CSC | --- 37 unchanged lines hidden (view full) --- 2970 uint32_t nqh; 2971 uint32_t nfixup; 2972 uint32_t n; 2973 uint16_t align; 2974 2975 sc = UHCI_BUS2SC(parm->udev->bus); 2976 xfer = parm->curr_xfer; 2977 | 2925 2926 DPRINTFN(21, "\n"); 2927 2928 USB_BUS_LOCK_ASSERT(&sc->sc_bus, MA_OWNED); 2929 2930 sc->sc_hub_idata[0] = 0; 2931 2932 if (UREAD2(sc, UHCI_PORTSC1) & (UHCI_PORTSC_CSC | --- 37 unchanged lines hidden (view full) --- 2970 uint32_t nqh; 2971 uint32_t nfixup; 2972 uint32_t n; 2973 uint16_t align; 2974 2975 sc = UHCI_BUS2SC(parm->udev->bus); 2976 xfer = parm->curr_xfer; 2977 |
2978 /* 2979 * setup xfer 2980 */ 2981 xfer->usb2_sc = sc; 2982 | |
2983 parm->hc_max_packet_size = 0x500; 2984 parm->hc_max_packet_count = 1; 2985 parm->hc_max_frame_size = 0x500; 2986 2987 /* 2988 * compute ntd and nqh 2989 */ 2990 if (parm->methods == &uhci_device_ctrl_methods) { --- 245 unchanged lines hidden (view full) --- 3236 uhci_qh_t *qh; 3237 3238 DPRINTF("\n"); 3239 3240 USB_BUS_LOCK(udev->bus); 3241 3242 TAILQ_FOREACH(xfer, &sc->sc_bus.intr_q.head, wait_entry) { 3243 | 2978 parm->hc_max_packet_size = 0x500; 2979 parm->hc_max_packet_count = 1; 2980 parm->hc_max_frame_size = 0x500; 2981 2982 /* 2983 * compute ntd and nqh 2984 */ 2985 if (parm->methods == &uhci_device_ctrl_methods) { --- 245 unchanged lines hidden (view full) --- 3231 uhci_qh_t *qh; 3232 3233 DPRINTF("\n"); 3234 3235 USB_BUS_LOCK(udev->bus); 3236 3237 TAILQ_FOREACH(xfer, &sc->sc_bus.intr_q.head, wait_entry) { 3238 |
3244 if (xfer->udev == udev) { | 3239 if (xfer->xroot->udev == udev) { |
3245 3246 methods = xfer->pipe->methods; 3247 qh = xfer->qh_start[xfer->flags_int.curr_dma_set]; 3248 3249 if (methods == &uhci_device_bulk_methods) { 3250 UHCI_APPEND_QH(qh, sc->sc_bulk_p_last); 3251 uhci_add_loop(sc); 3252 xfer->flags_int.bandwidth_reclaimed = 1; 3253 } 3254 if (methods == &uhci_device_ctrl_methods) { | 3240 3241 methods = xfer->pipe->methods; 3242 qh = xfer->qh_start[xfer->flags_int.curr_dma_set]; 3243 3244 if (methods == &uhci_device_bulk_methods) { 3245 UHCI_APPEND_QH(qh, sc->sc_bulk_p_last); 3246 uhci_add_loop(sc); 3247 xfer->flags_int.bandwidth_reclaimed = 1; 3248 } 3249 if (methods == &uhci_device_ctrl_methods) { |
3255 if (xfer->udev->speed == USB_SPEED_LOW) { | 3250 if (xfer->xroot->udev->speed == USB_SPEED_LOW) { |
3256 UHCI_APPEND_QH(qh, sc->sc_ls_ctl_p_last); 3257 } else { 3258 UHCI_APPEND_QH(qh, sc->sc_fs_ctl_p_last); 3259 } 3260 } 3261 if (methods == &uhci_device_intr_methods) { 3262 UHCI_APPEND_QH(qh, sc->sc_intr_p_last[xfer->qh_pos]); 3263 } --- 14 unchanged lines hidden (view full) --- 3278 uhci_qh_t *qh; 3279 3280 DPRINTF("\n"); 3281 3282 USB_BUS_LOCK(udev->bus); 3283 3284 TAILQ_FOREACH(xfer, &sc->sc_bus.intr_q.head, wait_entry) { 3285 | 3251 UHCI_APPEND_QH(qh, sc->sc_ls_ctl_p_last); 3252 } else { 3253 UHCI_APPEND_QH(qh, sc->sc_fs_ctl_p_last); 3254 } 3255 } 3256 if (methods == &uhci_device_intr_methods) { 3257 UHCI_APPEND_QH(qh, sc->sc_intr_p_last[xfer->qh_pos]); 3258 } --- 14 unchanged lines hidden (view full) --- 3273 uhci_qh_t *qh; 3274 3275 DPRINTF("\n"); 3276 3277 USB_BUS_LOCK(udev->bus); 3278 3279 TAILQ_FOREACH(xfer, &sc->sc_bus.intr_q.head, wait_entry) { 3280 |
3286 if (xfer->udev == udev) { | 3281 if (xfer->xroot->udev == udev) { |
3287 3288 methods = xfer->pipe->methods; 3289 qh = xfer->qh_start[xfer->flags_int.curr_dma_set]; 3290 3291 if (xfer->flags_int.bandwidth_reclaimed) { 3292 xfer->flags_int.bandwidth_reclaimed = 0; 3293 uhci_rem_loop(sc); 3294 } 3295 if (methods == &uhci_device_bulk_methods) { 3296 UHCI_REMOVE_QH(qh, sc->sc_bulk_p_last); 3297 } 3298 if (methods == &uhci_device_ctrl_methods) { | 3282 3283 methods = xfer->pipe->methods; 3284 qh = xfer->qh_start[xfer->flags_int.curr_dma_set]; 3285 3286 if (xfer->flags_int.bandwidth_reclaimed) { 3287 xfer->flags_int.bandwidth_reclaimed = 0; 3288 uhci_rem_loop(sc); 3289 } 3290 if (methods == &uhci_device_bulk_methods) { 3291 UHCI_REMOVE_QH(qh, sc->sc_bulk_p_last); 3292 } 3293 if (methods == &uhci_device_ctrl_methods) { |
3299 if (xfer->udev->speed == USB_SPEED_LOW) { | 3294 if (xfer->xroot->udev->speed == USB_SPEED_LOW) { |
3300 UHCI_REMOVE_QH(qh, sc->sc_ls_ctl_p_last); 3301 } else { 3302 UHCI_REMOVE_QH(qh, sc->sc_fs_ctl_p_last); 3303 } 3304 } 3305 if (methods == &uhci_device_intr_methods) { 3306 UHCI_REMOVE_QH(qh, sc->sc_intr_p_last[xfer->qh_pos]); 3307 } --- 52 unchanged lines hidden --- | 3295 UHCI_REMOVE_QH(qh, sc->sc_ls_ctl_p_last); 3296 } else { 3297 UHCI_REMOVE_QH(qh, sc->sc_fs_ctl_p_last); 3298 } 3299 } 3300 if (methods == &uhci_device_intr_methods) { 3301 UHCI_REMOVE_QH(qh, sc->sc_intr_p_last[xfer->qh_pos]); 3302 } --- 52 unchanged lines hidden --- |