| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: xhci.c,v 1.23.2.5 2017/04/05 19:54:21 snj Exp $ */ | | 1 | /* $NetBSD: xhci.c,v 1.23.2.6 2018/01/03 19:48:45 snj Exp $ */ |
2 | | | 2 | |
3 | /* | | 3 | /* |
4 | * Copyright (c) 2013 Jonathan A. Kollasch | | 4 | * Copyright (c) 2013 Jonathan A. Kollasch |
5 | * All rights reserved. | | 5 | * All rights reserved. |
6 | * | | 6 | * |
7 | * Redistribution and use in source and binary forms, with or without | | 7 | * Redistribution and use in source and binary forms, with or without |
8 | * modification, are permitted provided that the following conditions | | 8 | * modification, are permitted provided that the following conditions |
9 | * are met: | | 9 | * are met: |
10 | * 1. Redistributions of source code must retain the above copyright | | 10 | * 1. Redistributions of source code must retain the above copyright |
11 | * notice, this list of conditions and the following disclaimer. | | 11 | * notice, this list of conditions and the following disclaimer. |
12 | * 2. Redistributions in binary form must reproduce the above copyright | | 12 | * 2. Redistributions in binary form must reproduce the above copyright |
13 | * notice, this list of conditions and the following disclaimer in the | | 13 | * notice, this list of conditions and the following disclaimer in the |
14 | * documentation and/or other materials provided with the distribution. | | 14 | * documentation and/or other materials provided with the distribution. |
| @@ -24,27 +24,27 @@ | | | @@ -24,27 +24,27 @@ |
24 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR | | 24 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR |
25 | * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF | | 25 | * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF |
26 | * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | | 26 | * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
27 | */ | | 27 | */ |
28 | | | 28 | |
29 | /* | | 29 | /* |
30 | * USB rev 2.0 and rev 3.1 specification | | 30 | * USB rev 2.0 and rev 3.1 specification |
31 | * http://www.usb.org/developers/docs/ | | 31 | * http://www.usb.org/developers/docs/ |
32 | * xHCI rev 1.1 specification | | 32 | * xHCI rev 1.1 specification |
33 | * http://www.intel.com/technology/usb/spec.htm | | 33 | * http://www.intel.com/technology/usb/spec.htm |
34 | */ | | 34 | */ |
35 | | | 35 | |
36 | #include <sys/cdefs.h> | | 36 | #include <sys/cdefs.h> |
37 | __KERNEL_RCSID(0, "$NetBSD: xhci.c,v 1.23.2.5 2017/04/05 19:54:21 snj Exp $"); | | 37 | __KERNEL_RCSID(0, "$NetBSD: xhci.c,v 1.23.2.6 2018/01/03 19:48:45 snj Exp $"); |
38 | | | 38 | |
39 | #ifdef _KERNEL_OPT | | 39 | #ifdef _KERNEL_OPT |
40 | #include "opt_usb.h" | | 40 | #include "opt_usb.h" |
41 | #endif | | 41 | #endif |
42 | | | 42 | |
43 | #include <sys/param.h> | | 43 | #include <sys/param.h> |
44 | #include <sys/systm.h> | | 44 | #include <sys/systm.h> |
45 | #include <sys/kernel.h> | | 45 | #include <sys/kernel.h> |
46 | #include <sys/kmem.h> | | 46 | #include <sys/kmem.h> |
47 | #include <sys/device.h> | | 47 | #include <sys/device.h> |
48 | #include <sys/select.h> | | 48 | #include <sys/select.h> |
49 | #include <sys/proc.h> | | 49 | #include <sys/proc.h> |
50 | #include <sys/queue.h> | | 50 | #include <sys/queue.h> |
| @@ -679,30 +679,34 @@ xhci_hc_reset(struct xhci_softc * const | | | @@ -679,30 +679,34 @@ xhci_hc_reset(struct xhci_softc * const |
679 | aprint_error_dev(sc->sc_dev, "controller not ready timeout\n"); | | 679 | aprint_error_dev(sc->sc_dev, "controller not ready timeout\n"); |
680 | return EIO; | | 680 | return EIO; |
681 | } | | 681 | } |
682 | | | 682 | |
683 | /* Halt controller */ | | 683 | /* Halt controller */ |
684 | usbcmd = 0; | | 684 | usbcmd = 0; |
685 | xhci_op_write_4(sc, XHCI_USBCMD, usbcmd); | | 685 | xhci_op_write_4(sc, XHCI_USBCMD, usbcmd); |
686 | usb_delay_ms(&sc->sc_bus, 1); | | 686 | usb_delay_ms(&sc->sc_bus, 1); |
687 | | | 687 | |
688 | /* Reset controller */ | | 688 | /* Reset controller */ |
689 | usbcmd = XHCI_CMD_HCRST; | | 689 | usbcmd = XHCI_CMD_HCRST; |
690 | xhci_op_write_4(sc, XHCI_USBCMD, usbcmd); | | 690 | xhci_op_write_4(sc, XHCI_USBCMD, usbcmd); |
691 | for (i = 0; i < XHCI_WAIT_HCRST; i++) { | | 691 | for (i = 0; i < XHCI_WAIT_HCRST; i++) { |
| | | 692 | /* |
| | | 693 | * Wait 1ms first. Existing Intel xHCI requies 1ms delay to |
| | | 694 | * prevent system hang (Errata). |
| | | 695 | */ |
| | | 696 | usb_delay_ms(&sc->sc_bus, 1); |
692 | usbcmd = xhci_op_read_4(sc, XHCI_USBCMD); | | 697 | usbcmd = xhci_op_read_4(sc, XHCI_USBCMD); |
693 | if ((usbcmd & XHCI_CMD_HCRST) == 0) | | 698 | if ((usbcmd & XHCI_CMD_HCRST) == 0) |
694 | break; | | 699 | break; |
695 | usb_delay_ms(&sc->sc_bus, 1); | | | |
696 | } | | 700 | } |
697 | if (i >= XHCI_WAIT_HCRST) { | | 701 | if (i >= XHCI_WAIT_HCRST) { |
698 | aprint_error_dev(sc->sc_dev, "host controller reset timeout\n"); | | 702 | aprint_error_dev(sc->sc_dev, "host controller reset timeout\n"); |
699 | return EIO; | | 703 | return EIO; |
700 | } | | 704 | } |
701 | | | 705 | |
702 | /* Check controller not ready */ | | 706 | /* Check controller not ready */ |
703 | for (i = 0; i < XHCI_WAIT_CNR; i++) { | | 707 | for (i = 0; i < XHCI_WAIT_CNR; i++) { |
704 | usbsts = xhci_op_read_4(sc, XHCI_USBSTS); | | 708 | usbsts = xhci_op_read_4(sc, XHCI_USBSTS); |
705 | if ((usbsts & XHCI_STS_CNR) == 0) | | 709 | if ((usbsts & XHCI_STS_CNR) == 0) |
706 | break; | | 710 | break; |
707 | usb_delay_ms(&sc->sc_bus, 1); | | 711 | usb_delay_ms(&sc->sc_bus, 1); |
708 | } | | 712 | } |