| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: dwc_otg.c,v 1.32 2013/01/21 13:25:44 skrll Exp $ */ | | 1 | /* $NetBSD: dwc_otg.c,v 1.33 2013/01/22 13:03:25 skrll Exp $ */ |
2 | | | 2 | |
3 | /*- | | 3 | /*- |
4 | * Copyright (c) 2012 Hans Petter Selasky. All rights reserved. | | 4 | * Copyright (c) 2012 Hans Petter Selasky. All rights reserved. |
5 | * Copyright (c) 2010-2011 Aleksandr Rybalko. All rights reserved. | | 5 | * Copyright (c) 2010-2011 Aleksandr Rybalko. 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. |
| @@ -50,27 +50,27 @@ | | | @@ -50,27 +50,27 @@ |
50 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | | 50 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
51 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | | 51 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
52 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | | 52 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
53 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | | 53 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
54 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | | 54 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
55 | * POSSIBILITY OF SUCH DAMAGE. | | 55 | * POSSIBILITY OF SUCH DAMAGE. |
56 | */ | | 56 | */ |
57 | | | 57 | |
58 | /* | | 58 | /* |
59 | * Designware USB 2.0 OTG | | 59 | * Designware USB 2.0 OTG |
60 | */ | | 60 | */ |
61 | | | 61 | |
62 | #include <sys/cdefs.h> | | 62 | #include <sys/cdefs.h> |
63 | __KERNEL_RCSID(0, "$NetBSD: dwc_otg.c,v 1.32 2013/01/21 13:25:44 skrll Exp $"); | | 63 | __KERNEL_RCSID(0, "$NetBSD: dwc_otg.c,v 1.33 2013/01/22 13:03:25 skrll Exp $"); |
64 | | | 64 | |
65 | #include <sys/param.h> | | 65 | #include <sys/param.h> |
66 | #include <sys/systm.h> | | 66 | #include <sys/systm.h> |
67 | #include <sys/kmem.h> | | 67 | #include <sys/kmem.h> |
68 | #include <sys/kernel.h> | | 68 | #include <sys/kernel.h> |
69 | #include <sys/device.h> | | 69 | #include <sys/device.h> |
70 | #include <sys/select.h> | | 70 | #include <sys/select.h> |
71 | #include <sys/proc.h> | | 71 | #include <sys/proc.h> |
72 | #include <sys/queue.h> | | 72 | #include <sys/queue.h> |
73 | #include <sys/cpu.h> | | 73 | #include <sys/cpu.h> |
74 | | | 74 | |
75 | #include <machine/endian.h> | | 75 | #include <machine/endian.h> |
76 | | | 76 | |
| @@ -3686,27 +3686,27 @@ dwc_otg_setup_ctrl_chain(usbd_xfer_handl | | | @@ -3686,27 +3686,27 @@ dwc_otg_setup_ctrl_chain(usbd_xfer_handl |
3686 | | | 3686 | |
3687 | temp.buf = len ? KERNADDR(&xfer->dmabuf, done) : NULL; | | 3687 | temp.buf = len ? KERNADDR(&xfer->dmabuf, done) : NULL; |
3688 | temp.len = len - done; | | 3688 | temp.len = len - done; |
3689 | temp.short_pkt = ( (xfer->flags & USBD_FORCE_SHORT_XFER) ? 0 : 1); | | 3689 | temp.short_pkt = ( (xfer->flags & USBD_FORCE_SHORT_XFER) ? 0 : 1); |
3690 | | | 3690 | |
3691 | if (temp.len > UGETW(ed->wMaxPacketSize)) | | 3691 | if (temp.len > UGETW(ed->wMaxPacketSize)) |
3692 | temp.len = UGETW(ed->wMaxPacketSize); | | 3692 | temp.len = UGETW(ed->wMaxPacketSize); |
3693 | | | 3693 | |
3694 | dwc_otg_setup_standard_chain_sub(&temp); | | 3694 | dwc_otg_setup_standard_chain_sub(&temp); |
3695 | | | 3695 | |
3696 | done += temp.len; | | 3696 | done += temp.len; |
3697 | if (temp.len) | | 3697 | if (temp.len) |
3698 | temp.buf = (char *)KERNADDR(&xfer->dmabuf, 0) + done; | | 3698 | temp.buf = (char *)KERNADDR(&xfer->dmabuf, 0) + done; |
3699 | }; | | 3699 | } |
3700 | | | 3700 | |
3701 | /* Status Stage */ | | 3701 | /* Status Stage */ |
3702 | temp.buf = &req; /* XXXNH not needed */ | | 3702 | temp.buf = &req; /* XXXNH not needed */ |
3703 | temp.len = 0; | | 3703 | temp.len = 0; |
3704 | temp.short_pkt = 0; | | 3704 | temp.short_pkt = 0; |
3705 | temp.setup_alt_next = 0; | | 3705 | temp.setup_alt_next = 0; |
3706 | | | 3706 | |
3707 | /* | | 3707 | /* |
3708 | * Send a DATA1 message and invert the current endpoint direction. | | 3708 | * Send a DATA1 message and invert the current endpoint direction. |
3709 | */ | | 3709 | */ |
3710 | if (dir == UT_READ) { | | 3710 | if (dir == UT_READ) { |
3711 | temp.func = &dwc_otg_host_data_tx; | | 3711 | temp.func = &dwc_otg_host_data_tx; |
3712 | } else { | | 3712 | } else { |
| @@ -3773,27 +3773,27 @@ dwc_otg_setup_data_chain(usbd_xfer_handl | | | @@ -3773,27 +3773,27 @@ dwc_otg_setup_data_chain(usbd_xfer_handl |
3773 | len = xfer->length; | | 3773 | len = xfer->length; |
3774 | while (len > 0) { | | 3774 | while (len > 0) { |
3775 | /* DATA0 / DATA1 message */ | | 3775 | /* DATA0 / DATA1 message */ |
3776 | temp.buf = KERNADDR(&xfer->dmabuf, off); | | 3776 | temp.buf = KERNADDR(&xfer->dmabuf, off); |
3777 | temp.len = MIN(len, UGETW(ed->wMaxPacketSize)); | | 3777 | temp.len = MIN(len, UGETW(ed->wMaxPacketSize)); |
3778 | temp.short_pkt = (xfer->flags & USBD_FORCE_SHORT_XFER) ? 0 : 1; | | 3778 | temp.short_pkt = (xfer->flags & USBD_FORCE_SHORT_XFER) ? 0 : 1; |
3779 | if (len <= UGETW(ed->wMaxPacketSize)) | | 3779 | if (len <= UGETW(ed->wMaxPacketSize)) |
3780 | temp.setup_alt_next = 0; | | 3780 | temp.setup_alt_next = 0; |
3781 | | | 3781 | |
3782 | dwc_otg_setup_standard_chain_sub(&temp); | | 3782 | dwc_otg_setup_standard_chain_sub(&temp); |
3783 | | | 3783 | |
3784 | len -= temp.len; | | 3784 | len -= temp.len; |
3785 | off += temp.len; | | 3785 | off += temp.len; |
3786 | }; | | 3786 | } |
3787 | | | 3787 | |
3788 | /* must have at least one frame! */ | | 3788 | /* must have at least one frame! */ |
3789 | td = temp.td; | | 3789 | td = temp.td; |
3790 | dxfer->td_transfer_last = td; | | 3790 | dxfer->td_transfer_last = td; |
3791 | | | 3791 | |
3792 | dwc_otg_setup_standard_chain(xfer); | | 3792 | dwc_otg_setup_standard_chain(xfer); |
3793 | } | | 3793 | } |
3794 | | | 3794 | |
3795 | Static void | | 3795 | Static void |
3796 | dwc_otg_setup_intr_chain(usbd_xfer_handle xfer) | | 3796 | dwc_otg_setup_intr_chain(usbd_xfer_handle xfer) |
3797 | { | | 3797 | { |
3798 | dwc_otg_setup_data_chain(xfer); | | 3798 | dwc_otg_setup_data_chain(xfer); |
3799 | } | | 3799 | } |
| @@ -4069,27 +4069,27 @@ dwc_otg_standard_done(usbd_xfer_handle x | | | @@ -4069,27 +4069,27 @@ dwc_otg_standard_done(usbd_xfer_handle x |
4069 | /* reset scanner */ | | 4069 | /* reset scanner */ |
4070 | | | 4070 | |
4071 | dxfer->td_transfer_cache = dxfer->td_transfer_first; | | 4071 | dxfer->td_transfer_cache = dxfer->td_transfer_first; |
4072 | td = dxfer->td_transfer_first; | | 4072 | td = dxfer->td_transfer_first; |
4073 | | | 4073 | |
4074 | while (td != NULL) { | | 4074 | while (td != NULL) { |
4075 | err = dwc_otg_standard_done_sub(xfer); | | 4075 | err = dwc_otg_standard_done_sub(xfer); |
4076 | if (dxfer->td_transfer_cache == NULL) { | | 4076 | if (dxfer->td_transfer_cache == NULL) { |
4077 | goto done; | | 4077 | goto done; |
4078 | } | | 4078 | } |
4079 | if (td == dxfer->td_transfer_last) | | 4079 | if (td == dxfer->td_transfer_last) |
4080 | break; | | 4080 | break; |
4081 | td = td->obj_next; | | 4081 | td = td->obj_next; |
4082 | }; | | 4082 | } |
4083 | done: | | 4083 | done: |
4084 | dwc_otg_device_done(xfer, err); | | 4084 | dwc_otg_device_done(xfer, err); |
4085 | } | | 4085 | } |
4086 | | | 4086 | |
4087 | | | 4087 | |
4088 | /*------------------------------------------------------------------------* | | 4088 | /*------------------------------------------------------------------------* |
4089 | * dwc_otg_device_done | | 4089 | * dwc_otg_device_done |
4090 | * | | 4090 | * |
4091 | * NOTE: this function can be called more than one time on the | | 4091 | * NOTE: this function can be called more than one time on the |
4092 | * same USB transfer! | | 4092 | * same USB transfer! |
4093 | *------------------------------------------------------------------------*/ | | 4093 | *------------------------------------------------------------------------*/ |
4094 | Static void | | 4094 | Static void |
4095 | dwc_otg_device_done(usbd_xfer_handle xfer, usbd_status error) | | 4095 | dwc_otg_device_done(usbd_xfer_handle xfer, usbd_status error) |