ehci.c (254238) | ehci.c (259218) |
---|---|
1/* $FreeBSD: head/sys/dev/usb/controller/ehci.c 254238 2013-08-12 06:09:28Z hselasky $ */ | 1/* $FreeBSD: head/sys/dev/usb/controller/ehci.c 259218 2013-12-11 13:20:32Z hselasky $ */ |
2/*- 3 * Copyright (c) 2008 Hans Petter Selasky. All rights reserved. 4 * Copyright (c) 2004 The NetBSD Foundation, Inc. All rights reserved. 5 * Copyright (c) 2004 Lennart Augustsson. All rights reserved. 6 * Copyright (c) 2004 Charles M. Hannum. All rights reserved. 7 * 8 * Redistribution and use in source and binary forms, with or without 9 * modification, are permitted provided that the following conditions --- 104 unchanged lines hidden (view full) --- 114 115static void ehci_dump_regs(ehci_softc_t *sc); 116static void ehci_dump_sqh(ehci_softc_t *sc, ehci_qh_t *sqh); 117 118#endif 119 120#define EHCI_INTR_ENDPT 1 121 | 2/*- 3 * Copyright (c) 2008 Hans Petter Selasky. All rights reserved. 4 * Copyright (c) 2004 The NetBSD Foundation, Inc. All rights reserved. 5 * Copyright (c) 2004 Lennart Augustsson. All rights reserved. 6 * Copyright (c) 2004 Charles M. Hannum. All rights reserved. 7 * 8 * Redistribution and use in source and binary forms, with or without 9 * modification, are permitted provided that the following conditions --- 104 unchanged lines hidden (view full) --- 114 115static void ehci_dump_regs(ehci_softc_t *sc); 116static void ehci_dump_sqh(ehci_softc_t *sc, ehci_qh_t *sqh); 117 118#endif 119 120#define EHCI_INTR_ENDPT 1 121 |
122extern struct usb_bus_methods ehci_bus_methods; 123extern struct usb_pipe_methods ehci_device_bulk_methods; 124extern struct usb_pipe_methods ehci_device_ctrl_methods; 125extern struct usb_pipe_methods ehci_device_intr_methods; 126extern struct usb_pipe_methods ehci_device_isoc_fs_methods; 127extern struct usb_pipe_methods ehci_device_isoc_hs_methods; | 122static const struct usb_bus_methods ehci_bus_methods; 123static const struct usb_pipe_methods ehci_device_bulk_methods; 124static const struct usb_pipe_methods ehci_device_ctrl_methods; 125static const struct usb_pipe_methods ehci_device_intr_methods; 126static const struct usb_pipe_methods ehci_device_isoc_fs_methods; 127static const struct usb_pipe_methods ehci_device_isoc_hs_methods; |
128 129static void ehci_do_poll(struct usb_bus *); 130static void ehci_device_done(struct usb_xfer *, usb_error_t); 131static uint8_t ehci_check_transfer(struct usb_xfer *); 132static void ehci_timeout(void *); 133static void ehci_poll_timeout(void *); 134 135static void ehci_root_intr(ehci_softc_t *sc); --- 1134 unchanged lines hidden (view full) --- 1270 * 1271 * Return values: 1272 * 0: USB transfer is not finished 1273 * Else: USB transfer is finished 1274 *------------------------------------------------------------------------*/ 1275static uint8_t 1276ehci_check_transfer(struct usb_xfer *xfer) 1277{ | 128 129static void ehci_do_poll(struct usb_bus *); 130static void ehci_device_done(struct usb_xfer *, usb_error_t); 131static uint8_t ehci_check_transfer(struct usb_xfer *); 132static void ehci_timeout(void *); 133static void ehci_poll_timeout(void *); 134 135static void ehci_root_intr(ehci_softc_t *sc); --- 1134 unchanged lines hidden (view full) --- 1270 * 1271 * Return values: 1272 * 0: USB transfer is not finished 1273 * Else: USB transfer is finished 1274 *------------------------------------------------------------------------*/ 1275static uint8_t 1276ehci_check_transfer(struct usb_xfer *xfer) 1277{ |
1278 struct usb_pipe_methods *methods = xfer->endpoint->methods; | 1278 const struct usb_pipe_methods *methods = xfer->endpoint->methods; |
1279 ehci_softc_t *sc = EHCI_BUS2SC(xfer->xroot->bus); 1280 1281 uint32_t status; 1282 1283 DPRINTFN(13, "xfer=%p checking transfer\n", xfer); 1284 1285 if (methods == &ehci_device_isoc_fs_methods) { 1286 ehci_sitd_t *td; --- 464 unchanged lines hidden (view full) --- 1751 temp->td = td; 1752 temp->td_next = td_next; 1753} 1754 1755static void 1756ehci_setup_standard_chain(struct usb_xfer *xfer, ehci_qh_t **qh_last) 1757{ 1758 struct ehci_std_temp temp; | 1279 ehci_softc_t *sc = EHCI_BUS2SC(xfer->xroot->bus); 1280 1281 uint32_t status; 1282 1283 DPRINTFN(13, "xfer=%p checking transfer\n", xfer); 1284 1285 if (methods == &ehci_device_isoc_fs_methods) { 1286 ehci_sitd_t *td; --- 464 unchanged lines hidden (view full) --- 1751 temp->td = td; 1752 temp->td_next = td_next; 1753} 1754 1755static void 1756ehci_setup_standard_chain(struct usb_xfer *xfer, ehci_qh_t **qh_last) 1757{ 1758 struct ehci_std_temp temp; |
1759 struct usb_pipe_methods *methods; | 1759 const struct usb_pipe_methods *methods; |
1760 ehci_qh_t *qh; 1761 ehci_qtd_t *td; 1762 uint32_t qh_endp; 1763 uint32_t qh_endphub; 1764 uint32_t x; 1765 1766 DPRINTFN(9, "addr=%d endpt=%d sumlen=%d speed=%d\n", 1767 xfer->address, UE_GET_ADDR(xfer->endpointno), --- 391 unchanged lines hidden (view full) --- 2159} 2160 2161/* NOTE: "done" can be run two times in a row, 2162 * from close and from interrupt 2163 */ 2164static void 2165ehci_device_done(struct usb_xfer *xfer, usb_error_t error) 2166{ | 1760 ehci_qh_t *qh; 1761 ehci_qtd_t *td; 1762 uint32_t qh_endp; 1763 uint32_t qh_endphub; 1764 uint32_t x; 1765 1766 DPRINTFN(9, "addr=%d endpt=%d sumlen=%d speed=%d\n", 1767 xfer->address, UE_GET_ADDR(xfer->endpointno), --- 391 unchanged lines hidden (view full) --- 2159} 2160 2161/* NOTE: "done" can be run two times in a row, 2162 * from close and from interrupt 2163 */ 2164static void 2165ehci_device_done(struct usb_xfer *xfer, usb_error_t error) 2166{ |
2167 struct usb_pipe_methods *methods = xfer->endpoint->methods; | 2167 const struct usb_pipe_methods *methods = xfer->endpoint->methods; |
2168 ehci_softc_t *sc = EHCI_BUS2SC(xfer->xroot->bus); 2169 2170 USB_BUS_LOCK_ASSERT(&sc->sc_bus, MA_OWNED); 2171 2172 DPRINTFN(2, "xfer=%p, endpoint=%p, error=%d\n", 2173 xfer, xfer->endpoint, error); 2174 2175 if ((methods == &ehci_device_bulk_methods) || --- 77 unchanged lines hidden (view full) --- 2253 * interrupt rate. Issue an IAAD to stimulate the Host 2254 * Controller after queueing the BULK transfer. 2255 */ 2256 temp = EOREAD4(sc, EHCI_USBCMD); 2257 if (!(temp & EHCI_CMD_IAAD)) 2258 EOWRITE4(sc, EHCI_USBCMD, temp | EHCI_CMD_IAAD); 2259} 2260 | 2168 ehci_softc_t *sc = EHCI_BUS2SC(xfer->xroot->bus); 2169 2170 USB_BUS_LOCK_ASSERT(&sc->sc_bus, MA_OWNED); 2171 2172 DPRINTFN(2, "xfer=%p, endpoint=%p, error=%d\n", 2173 xfer, xfer->endpoint, error); 2174 2175 if ((methods == &ehci_device_bulk_methods) || --- 77 unchanged lines hidden (view full) --- 2253 * interrupt rate. Issue an IAAD to stimulate the Host 2254 * Controller after queueing the BULK transfer. 2255 */ 2256 temp = EOREAD4(sc, EHCI_USBCMD); 2257 if (!(temp & EHCI_CMD_IAAD)) 2258 EOWRITE4(sc, EHCI_USBCMD, temp | EHCI_CMD_IAAD); 2259} 2260 |
2261struct usb_pipe_methods ehci_device_bulk_methods = | 2261static const struct usb_pipe_methods ehci_device_bulk_methods = |
2262{ 2263 .open = ehci_device_bulk_open, 2264 .close = ehci_device_bulk_close, 2265 .enter = ehci_device_bulk_enter, 2266 .start = ehci_device_bulk_start, 2267}; 2268 2269/*------------------------------------------------------------------------* --- 24 unchanged lines hidden (view full) --- 2294 2295 /* setup TD's and QH */ 2296 ehci_setup_standard_chain(xfer, &sc->sc_async_p_last); 2297 2298 /* put transfer on interrupt queue */ 2299 ehci_transfer_intr_enqueue(xfer); 2300} 2301 | 2262{ 2263 .open = ehci_device_bulk_open, 2264 .close = ehci_device_bulk_close, 2265 .enter = ehci_device_bulk_enter, 2266 .start = ehci_device_bulk_start, 2267}; 2268 2269/*------------------------------------------------------------------------* --- 24 unchanged lines hidden (view full) --- 2294 2295 /* setup TD's and QH */ 2296 ehci_setup_standard_chain(xfer, &sc->sc_async_p_last); 2297 2298 /* put transfer on interrupt queue */ 2299 ehci_transfer_intr_enqueue(xfer); 2300} 2301 |
2302struct usb_pipe_methods ehci_device_ctrl_methods = | 2302static const struct usb_pipe_methods ehci_device_ctrl_methods = |
2303{ 2304 .open = ehci_device_ctrl_open, 2305 .close = ehci_device_ctrl_close, 2306 .enter = ehci_device_ctrl_enter, 2307 .start = ehci_device_ctrl_start, 2308}; 2309 2310/*------------------------------------------------------------------------* --- 64 unchanged lines hidden (view full) --- 2375 2376 /* setup TD's and QH */ 2377 ehci_setup_standard_chain(xfer, &sc->sc_intr_p_last[xfer->qh_pos]); 2378 2379 /* put transfer on interrupt queue */ 2380 ehci_transfer_intr_enqueue(xfer); 2381} 2382 | 2303{ 2304 .open = ehci_device_ctrl_open, 2305 .close = ehci_device_ctrl_close, 2306 .enter = ehci_device_ctrl_enter, 2307 .start = ehci_device_ctrl_start, 2308}; 2309 2310/*------------------------------------------------------------------------* --- 64 unchanged lines hidden (view full) --- 2375 2376 /* setup TD's and QH */ 2377 ehci_setup_standard_chain(xfer, &sc->sc_intr_p_last[xfer->qh_pos]); 2378 2379 /* put transfer on interrupt queue */ 2380 ehci_transfer_intr_enqueue(xfer); 2381} 2382 |
2383struct usb_pipe_methods ehci_device_intr_methods = | 2383static const struct usb_pipe_methods ehci_device_intr_methods = |
2384{ 2385 .open = ehci_device_intr_open, 2386 .close = ehci_device_intr_close, 2387 .enter = ehci_device_intr_enter, 2388 .start = ehci_device_intr_start, 2389}; 2390 2391/*------------------------------------------------------------------------* --- 275 unchanged lines hidden (view full) --- 2667 /* set a default timeout */ 2668 if (xfer->timeout == 0) 2669 xfer->timeout = 500; /* ms */ 2670 2671 /* put transfer on interrupt queue */ 2672 ehci_transfer_intr_enqueue(xfer); 2673} 2674 | 2384{ 2385 .open = ehci_device_intr_open, 2386 .close = ehci_device_intr_close, 2387 .enter = ehci_device_intr_enter, 2388 .start = ehci_device_intr_start, 2389}; 2390 2391/*------------------------------------------------------------------------* --- 275 unchanged lines hidden (view full) --- 2667 /* set a default timeout */ 2668 if (xfer->timeout == 0) 2669 xfer->timeout = 500; /* ms */ 2670 2671 /* put transfer on interrupt queue */ 2672 ehci_transfer_intr_enqueue(xfer); 2673} 2674 |
2675struct usb_pipe_methods ehci_device_isoc_fs_methods = | 2675static const struct usb_pipe_methods ehci_device_isoc_fs_methods = |
2676{ 2677 .open = ehci_device_isoc_fs_open, 2678 .close = ehci_device_isoc_fs_close, 2679 .enter = ehci_device_isoc_fs_enter, 2680 .start = ehci_device_isoc_fs_start, 2681}; 2682 2683/*------------------------------------------------------------------------* --- 263 unchanged lines hidden (view full) --- 2947 2948static void 2949ehci_device_isoc_hs_start(struct usb_xfer *xfer) 2950{ 2951 /* put transfer on interrupt queue */ 2952 ehci_transfer_intr_enqueue(xfer); 2953} 2954 | 2676{ 2677 .open = ehci_device_isoc_fs_open, 2678 .close = ehci_device_isoc_fs_close, 2679 .enter = ehci_device_isoc_fs_enter, 2680 .start = ehci_device_isoc_fs_start, 2681}; 2682 2683/*------------------------------------------------------------------------* --- 263 unchanged lines hidden (view full) --- 2947 2948static void 2949ehci_device_isoc_hs_start(struct usb_xfer *xfer) 2950{ 2951 /* put transfer on interrupt queue */ 2952 ehci_transfer_intr_enqueue(xfer); 2953} 2954 |
2955struct usb_pipe_methods ehci_device_isoc_hs_methods = | 2955static const struct usb_pipe_methods ehci_device_isoc_hs_methods = |
2956{ 2957 .open = ehci_device_isoc_hs_open, 2958 .close = ehci_device_isoc_hs_close, 2959 .enter = ehci_device_isoc_hs_enter, 2960 .start = ehci_device_isoc_hs_start, 2961}; 2962 2963/*------------------------------------------------------------------------* --- 790 unchanged lines hidden (view full) --- 3754 *pus = (188); /* microseconds */ 3755} 3756 3757static void 3758ehci_device_resume(struct usb_device *udev) 3759{ 3760 ehci_softc_t *sc = EHCI_BUS2SC(udev->bus); 3761 struct usb_xfer *xfer; | 2956{ 2957 .open = ehci_device_isoc_hs_open, 2958 .close = ehci_device_isoc_hs_close, 2959 .enter = ehci_device_isoc_hs_enter, 2960 .start = ehci_device_isoc_hs_start, 2961}; 2962 2963/*------------------------------------------------------------------------* --- 790 unchanged lines hidden (view full) --- 3754 *pus = (188); /* microseconds */ 3755} 3756 3757static void 3758ehci_device_resume(struct usb_device *udev) 3759{ 3760 ehci_softc_t *sc = EHCI_BUS2SC(udev->bus); 3761 struct usb_xfer *xfer; |
3762 struct usb_pipe_methods *methods; | 3762 const struct usb_pipe_methods *methods; |
3763 3764 DPRINTF("\n"); 3765 3766 USB_BUS_LOCK(udev->bus); 3767 3768 TAILQ_FOREACH(xfer, &sc->sc_bus.intr_q.head, wait_entry) { 3769 3770 if (xfer->xroot->udev == udev) { --- 17 unchanged lines hidden (view full) --- 3788 return; 3789} 3790 3791static void 3792ehci_device_suspend(struct usb_device *udev) 3793{ 3794 ehci_softc_t *sc = EHCI_BUS2SC(udev->bus); 3795 struct usb_xfer *xfer; | 3763 3764 DPRINTF("\n"); 3765 3766 USB_BUS_LOCK(udev->bus); 3767 3768 TAILQ_FOREACH(xfer, &sc->sc_bus.intr_q.head, wait_entry) { 3769 3770 if (xfer->xroot->udev == udev) { --- 17 unchanged lines hidden (view full) --- 3788 return; 3789} 3790 3791static void 3792ehci_device_suspend(struct usb_device *udev) 3793{ 3794 ehci_softc_t *sc = EHCI_BUS2SC(udev->bus); 3795 struct usb_xfer *xfer; |
3796 struct usb_pipe_methods *methods; | 3796 const struct usb_pipe_methods *methods; |
3797 3798 DPRINTF("\n"); 3799 3800 USB_BUS_LOCK(udev->bus); 3801 3802 TAILQ_FOREACH(xfer, &sc->sc_bus.intr_q.head, wait_entry) { 3803 3804 if (xfer->xroot->udev == udev) { --- 62 unchanged lines hidden (view full) --- 3867 } 3868 EOWRITE4(sc, EHCI_USBCMD, temp); 3869 3870 USB_BUS_UNLOCK(bus); 3871 3872 return; 3873} 3874 | 3797 3798 DPRINTF("\n"); 3799 3800 USB_BUS_LOCK(udev->bus); 3801 3802 TAILQ_FOREACH(xfer, &sc->sc_bus.intr_q.head, wait_entry) { 3803 3804 if (xfer->xroot->udev == udev) { --- 62 unchanged lines hidden (view full) --- 3867 } 3868 EOWRITE4(sc, EHCI_USBCMD, temp); 3869 3870 USB_BUS_UNLOCK(bus); 3871 3872 return; 3873} 3874 |
3875struct usb_bus_methods ehci_bus_methods = | 3875static const struct usb_bus_methods ehci_bus_methods = |
3876{ 3877 .endpoint_init = ehci_ep_init, 3878 .xfer_setup = ehci_xfer_setup, 3879 .xfer_unsetup = ehci_xfer_unsetup, 3880 .get_dma_delay = ehci_get_dma_delay, 3881 .device_resume = ehci_device_resume, 3882 .device_suspend = ehci_device_suspend, 3883 .set_hw_power = ehci_set_hw_power, 3884 .set_hw_power_sleep = ehci_set_hw_power_sleep, 3885 .roothub_exec = ehci_roothub_exec, 3886 .xfer_poll = ehci_do_poll, 3887}; | 3876{ 3877 .endpoint_init = ehci_ep_init, 3878 .xfer_setup = ehci_xfer_setup, 3879 .xfer_unsetup = ehci_xfer_unsetup, 3880 .get_dma_delay = ehci_get_dma_delay, 3881 .device_resume = ehci_device_resume, 3882 .device_suspend = ehci_device_suspend, 3883 .set_hw_power = ehci_set_hw_power, 3884 .set_hw_power_sleep = ehci_set_hw_power_sleep, 3885 .roothub_exec = ehci_roothub_exec, 3886 .xfer_poll = ehci_do_poll, 3887}; |