| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: ehci.c,v 1.234.2.36 2015/03/02 22:16:38 skrll Exp $ */ | | 1 | /* $NetBSD: ehci.c,v 1.234.2.37 2015/03/03 06:36:53 skrll Exp $ */ |
2 | | | 2 | |
3 | /* | | 3 | /* |
4 | * Copyright (c) 2004-2012 The NetBSD Foundation, Inc. | | 4 | * Copyright (c) 2004-2012 The NetBSD Foundation, Inc. |
5 | * All rights reserved. | | 5 | * All rights reserved. |
6 | * | | 6 | * |
7 | * This code is derived from software contributed to The NetBSD Foundation | | 7 | * This code is derived from software contributed to The NetBSD Foundation |
8 | * by Lennart Augustsson (lennart@augustsson.net), Charles M. Hannum, | | 8 | * by Lennart Augustsson (lennart@augustsson.net), Charles M. Hannum, |
9 | * Jeremy Morse (jeremy.morse@gmail.com), Jared D. McNeill | | 9 | * Jeremy Morse (jeremy.morse@gmail.com), Jared D. McNeill |
10 | * (jmcneill@invisible.ca) and Matthew R. Green (mrg@eterna.com.au). | | 10 | * (jmcneill@invisible.ca) and Matthew R. Green (mrg@eterna.com.au). |
11 | * | | 11 | * |
12 | * Redistribution and use in source and binary forms, with or without | | 12 | * Redistribution and use in source and binary forms, with or without |
13 | * modification, are permitted provided that the following conditions | | 13 | * modification, are permitted provided that the following conditions |
14 | * are met: | | 14 | * are met: |
| @@ -43,27 +43,27 @@ | | | @@ -43,27 +43,27 @@ |
43 | | | 43 | |
44 | /* | | 44 | /* |
45 | * TODO: | | 45 | * TODO: |
46 | * 1) hold off explorations by companion controllers until ehci has started. | | 46 | * 1) hold off explorations by companion controllers until ehci has started. |
47 | * | | 47 | * |
48 | * 2) The hub driver needs to handle and schedule the transaction translator, | | 48 | * 2) The hub driver needs to handle and schedule the transaction translator, |
49 | * to assign place in frame where different devices get to go. See chapter | | 49 | * to assign place in frame where different devices get to go. See chapter |
50 | * on hubs in USB 2.0 for details. | | 50 | * on hubs in USB 2.0 for details. |
51 | * | | 51 | * |
52 | * 3) Command failures are not recovered correctly. | | 52 | * 3) Command failures are not recovered correctly. |
53 | */ | | 53 | */ |
54 | | | 54 | |
55 | #include <sys/cdefs.h> | | 55 | #include <sys/cdefs.h> |
56 | __KERNEL_RCSID(0, "$NetBSD: ehci.c,v 1.234.2.36 2015/03/02 22:16:38 skrll Exp $"); | | 56 | __KERNEL_RCSID(0, "$NetBSD: ehci.c,v 1.234.2.37 2015/03/03 06:36:53 skrll Exp $"); |
57 | | | 57 | |
58 | #include "ohci.h" | | 58 | #include "ohci.h" |
59 | #include "uhci.h" | | 59 | #include "uhci.h" |
60 | #include "opt_usb.h" | | 60 | #include "opt_usb.h" |
61 | | | 61 | |
62 | #include <sys/param.h> | | 62 | #include <sys/param.h> |
63 | | | 63 | |
64 | #include <sys/bus.h> | | 64 | #include <sys/bus.h> |
65 | #include <sys/cpu.h> | | 65 | #include <sys/cpu.h> |
66 | #include <sys/device.h> | | 66 | #include <sys/device.h> |
67 | #include <sys/kernel.h> | | 67 | #include <sys/kernel.h> |
68 | #include <sys/kmem.h> | | 68 | #include <sys/kmem.h> |
69 | #include <sys/mutex.h> | | 69 | #include <sys/mutex.h> |
| @@ -2825,32 +2825,32 @@ ehci_alloc_sqtd_chain(struct ehci_pipe * | | | @@ -2825,32 +2825,32 @@ ehci_alloc_sqtd_chain(struct ehci_pipe * |
2825 | if (curoffs + curlen != len || | | 2825 | if (curoffs + curlen != len || |
2826 | ((curlen % mps) == 0 && !rd && curlen != 0 && | | 2826 | ((curlen % mps) == 0 && !rd && curlen != 0 && |
2827 | (flags & USBD_FORCE_SHORT_XFER))) { | | 2827 | (flags & USBD_FORCE_SHORT_XFER))) { |
2828 | next = ehci_alloc_sqtd(sc); | | 2828 | next = ehci_alloc_sqtd(sc); |
2829 | if (next == NULL) | | 2829 | if (next == NULL) |
2830 | goto nomem; | | 2830 | goto nomem; |
2831 | nextphys = htole32(next->physaddr); | | 2831 | nextphys = htole32(next->physaddr); |
2832 | } else { | | 2832 | } else { |
2833 | next = NULL; | | 2833 | next = NULL; |
2834 | nextphys = EHCI_NULL; | | 2834 | nextphys = EHCI_NULL; |
2835 | } | | 2835 | } |
2836 | | | 2836 | |
2837 | /* Find number of pages we'll be using, insert dma addresses */ | | 2837 | /* Find number of pages we'll be using, insert dma addresses */ |
2838 | pages = EHCI_PAGE(curlen + EHCI_PAGE_SIZE - 1) >> 12; | | 2838 | pages = EHCI_NPAGES(curlen); |
2839 | KASSERT(pages <= EHCI_QTD_NBUFFERS); | | 2839 | KASSERT(pages <= EHCI_QTD_NBUFFERS); |
2840 | pageoffs = EHCI_PAGE(curoffs); | | 2840 | pageoffs = EHCI_PAGE(curoffs); |
2841 | for (i = 0; i < pages; i++) { | | 2841 | for (i = 0; i < pages; i++) { |
2842 | a = DMAADDR(dma, pageoffs + i * EHCI_PAGE_SIZE); | | 2842 | a = DMAADDR(dma, pageoffs + i * EHCI_PAGE_SIZE); |
2843 | cur->qtd.qtd_buffer[i] = htole32(a & 0xFFFFF000); | | 2843 | cur->qtd.qtd_buffer[i] = htole32(EHCI_PAGE(a)); |
2844 | /* Cast up to avoid compiler warnings */ | | 2844 | /* Cast up to avoid compiler warnings */ |
2845 | cur->qtd.qtd_buffer_hi[i] = htole32((uint64_t)a >> 32); | | 2845 | cur->qtd.qtd_buffer_hi[i] = htole32((uint64_t)a >> 32); |
2846 | } | | 2846 | } |
2847 | | | 2847 | |
2848 | /* First buffer pointer requires a page offset to start at */ | | 2848 | /* First buffer pointer requires a page offset to start at */ |
2849 | va = (vaddr_t)KERNADDR(dma, curoffs); | | 2849 | va = (vaddr_t)KERNADDR(dma, curoffs); |
2850 | cur->qtd.qtd_buffer[0] |= htole32(EHCI_PAGE_OFFSET(va)); | | 2850 | cur->qtd.qtd_buffer[0] |= htole32(EHCI_PAGE_OFFSET(va)); |
2851 | | | 2851 | |
2852 | cur->nextqtd = next; | | 2852 | cur->nextqtd = next; |
2853 | cur->qtd.qtd_next = cur->qtd.qtd_altnext = nextphys; | | 2853 | cur->qtd.qtd_next = cur->qtd.qtd_altnext = nextphys; |
2854 | cur->qtd.qtd_status = | | 2854 | cur->qtd.qtd_status = |
2855 | htole32(qtdstatus | EHCI_QTD_SET_BYTES(curlen)); | | 2855 | htole32(qtdstatus | EHCI_QTD_SET_BYTES(curlen)); |
2856 | cur->xfer = xfer; | | 2856 | cur->xfer = xfer; |