root/src/linux/rt2880/linux-2.6.23/drivers/usb/dwc_otg/dwc_otg_pcd.h

Revision 12433, 7.2 kB (checked in by BrainSlayer, 5 months ago)

fixes usb issues with some devices

Line 
1 /* ==========================================================================
2  * $File: //dwh/usb_iip/dev/software/otg/linux/drivers/dwc_otg_pcd.h $
3  * $Revision: 1.2 $
4  * $Date: 2008-11-21 05:39:15 $
5  * $Change: 1103515 $
6  *
7  * Synopsys HS OTG Linux Software Driver and documentation (hereinafter,
8  * "Software") is an Unsupported proprietary work of Synopsys, Inc. unless
9  * otherwise expressly agreed to in writing between Synopsys and you.
10  *
11  * The Software IS NOT an item of Licensed Software or Licensed Product under
12  * any End User Software License Agreement or Agreement for Licensed Product
13  * with Synopsys or any supplement thereto. You are permitted to use and
14  * redistribute this Software in source and binary forms, with or without
15  * modification, provided that redistributions of source code must retain this
16  * notice. You may not view, use, disclose, copy or distribute this file or
17  * any information contained herein except pursuant to this license grant from
18  * Synopsys. If you do not agree with this notice, including the disclaimer
19  * below, then you are not authorized to use the Software.
20  *
21  * THIS SOFTWARE IS BEING DISTRIBUTED BY SYNOPSYS SOLELY ON AN "AS IS" BASIS
22  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24  * ARE HEREBY DISCLAIMED. IN NO EVENT SHALL SYNOPSYS BE LIABLE FOR ANY DIRECT,
25  * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
26  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
27  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
28  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
31  * DAMAGE.
32  * ========================================================================== */
33 #ifndef DWC_HOST_ONLY
34 #if !defined(__DWC_PCD_H__)
35 #define __DWC_PCD_H__
36
37 #include <linux/types.h>
38 #include <linux/list.h>
39 #include <linux/errno.h>
40 #include <linux/device.h>
41
42 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,21)
43 # include <linux/usb/ch9.h>
44 #else
45 # include <linux/usb_ch9.h>
46 #endif
47
48 #include <linux/usb_gadget.h>
49 #include <linux/interrupt.h>
50 #include <linux/dma-mapping.h>
51
52 struct lm_device;
53 struct dwc_otg_device;
54
55 #include "dwc_otg_cil.h"
56
57 /**
58  * @file
59  *
60  * This file contains the structures, constants, and interfaces for
61  * the Perpherial Contoller Driver (PCD).
62  *
63  * The Peripheral Controller Driver (PCD) for Linux will implement the
64  * Gadget API, so that the existing Gadget drivers can be used.  For
65  * the Mass Storage Function driver the File-backed USB Storage Gadget
66  * (FBS) driver will be used.  The FBS driver supports the
67  * Control-Bulk (CB), Control-Bulk-Interrupt (CBI), and Bulk-Only
68  * transports.
69  *
70  */
71
72 /** Invalid DMA Address */
73 #define DMA_ADDR_INVALID        (~(dma_addr_t)0)
74 /** Maxpacket size for EP0 */
75 #define MAX_EP0_SIZE    64                 
76 /** Maxpacket size for any EP */
77 #define MAX_PACKET_SIZE 1024
78
79 /** Max Transfer size for any EP */
80 #define MAX_TRANSFER_SIZE 65535
81
82 /** Max DMA Descriptor count for any EP */
83 #define MAX_DMA_DESC_CNT 64
84
85 /**
86  * Get the pointer to the core_if from the pcd pointer.
87  */
88 #define GET_CORE_IF( _pcd ) (_pcd->otg_dev->core_if)
89
90 /**
91  * States of EP0.
92  */
93 typedef enum ep0_state
94 {
95         EP0_DISCONNECT,         /* no host */
96         EP0_IDLE,
97         EP0_IN_DATA_PHASE,
98         EP0_OUT_DATA_PHASE,
99         EP0_IN_STATUS_PHASE,
100         EP0_OUT_STATUS_PHASE,
101         EP0_STALL,
102 } ep0state_e;
103
104 /** Fordward declaration.*/
105 struct dwc_otg_pcd;
106
107 /** DWC_otg iso request structure.
108  *
109  */
110 typedef struct usb_iso_request  dwc_otg_pcd_iso_request_t;
111
112 /**       PCD EP structure.
113  * This structure describes an EP, there is an array of EPs in the PCD
114  * structure.
115  */
116 typedef struct dwc_otg_pcd_ep
117 {
118         /** USB EP data */
119         struct usb_ep           ep;
120         /** USB EP Descriptor */
121         const struct usb_endpoint_descriptor    *desc; 
122
123         /** queue of dwc_otg_pcd_requests. */
124         struct list_head        queue;
125         unsigned stopped : 1;           
126         unsigned disabling : 1;
127         unsigned dma : 1;
128         unsigned queue_sof : 1;
129
130 #ifdef DWC_EN_ISOC
131         /** DWC_otg Isochronous Transfer */
132         struct usb_iso_request* iso_req;
133 #endif //DWC_EN_ISOC
134
135         /** DWC_otg ep data. */
136         dwc_ep_t dwc_ep;
137
138         /** Pointer to PCD */
139         struct dwc_otg_pcd *pcd;
140 }dwc_otg_pcd_ep_t;
141
142
143
144 /** DWC_otg PCD Structure.
145  * This structure encapsulates the data for the dwc_otg PCD.
146  */
147 typedef struct dwc_otg_pcd
148 {
149         /** USB gadget */
150         struct usb_gadget gadget;
151         /** USB gadget driver pointer*/
152         struct usb_gadget_driver *driver;
153         /** The DWC otg device pointer. */
154         struct dwc_otg_device *otg_dev;
155                
156         /** State of EP0 */
157         ep0state_e      ep0state;
158         /** EP0 Request is pending */
159         unsigned        ep0_pending : 1;
160         /** Indicates when SET CONFIGURATION Request is in process */
161         unsigned        request_config : 1;
162         /** The state of the Remote Wakeup Enable. */
163         unsigned        remote_wakeup_enable : 1;
164         /** The state of the B-Device HNP Enable. */
165         unsigned        b_hnp_enable : 1;
166         /** The state of A-Device HNP Support. */
167         unsigned        a_hnp_support : 1;
168         /** The state of the A-Device Alt HNP support. */
169         unsigned        a_alt_hnp_support : 1;
170         /** Count of pending Requests */
171         unsigned        request_pending;
172                
173                 /** SETUP packet for EP0
174          * This structure is allocated as a DMA buffer on PCD initialization
175          * with enough space for up to 3 setup packets.
176          */
177         union
178         {
179                         struct usb_ctrlrequest  req;
180                         uint32_t        d32[2];
181         } *setup_pkt;
182
183         dma_addr_t setup_pkt_dma_handle;
184
185         /** 2-byte dma buffer used to return status from GET_STATUS */
186         uint16_t *status_buf;
187         dma_addr_t status_buf_dma_handle;
188
189         /** EP0 */
190         dwc_otg_pcd_ep_t ep0;
191
192         /** Array of IN EPs. */
193         dwc_otg_pcd_ep_t in_ep[ MAX_EPS_CHANNELS - 1];
194         /** Array of OUT EPs. */
195         dwc_otg_pcd_ep_t out_ep[ MAX_EPS_CHANNELS - 1];
196         /** number of valid EPs in the above array. */
197 //        unsigned      num_eps : 4;           
198         spinlock_t      lock;
199         /** Timer for SRP.      If it expires before SRP is successful
200          * clear the SRP. */
201         struct timer_list srp_timer;
202
203         /** Tasklet to defer starting of TEST mode transmissions until
204          *      Status Phase has been completed.
205          */
206         struct tasklet_struct test_mode_tasklet;
207
208         /** Tasklet to delay starting of xfer in DMA mode */
209         struct tasklet_struct *start_xfer_tasklet;
210
211         /** The test mode to enter when the tasklet is executed. */
212         unsigned test_mode;
213                
214 } dwc_otg_pcd_t;
215
216
217 /** DWC_otg request structure.
218  * This structure is a list of requests.
219  */
220 typedef struct
221 {
222         struct usb_request      req; /**< USB Request. */
223         struct list_head        queue;  /**< queue of these requests. */
224 } dwc_otg_pcd_request_t;
225
226
227 extern int dwc_otg_pcd_init(struct lm_device *lmdev);
228
229 //extern void dwc_otg_pcd_remove( struct dwc_otg_device *_otg_dev );
230 extern void dwc_otg_pcd_remove( struct lm_device *lmdev );
231 extern int32_t dwc_otg_pcd_handle_intr( dwc_otg_pcd_t *pcd );
232 extern void dwc_otg_pcd_start_srp_timer(dwc_otg_pcd_t *pcd );
233
234 extern void dwc_otg_pcd_initiate_srp(dwc_otg_pcd_t *pcd);
235 extern void dwc_otg_pcd_remote_wakeup(dwc_otg_pcd_t *pcd, int set);
236
237 extern void dwc_otg_iso_buffer_done(dwc_otg_pcd_ep_t *ep, dwc_otg_pcd_iso_request_t *req);
238 extern void dwc_otg_request_done(dwc_otg_pcd_ep_t *_ep, dwc_otg_pcd_request_t *req,
239                                 int status);
240 extern void dwc_otg_request_nuke(dwc_otg_pcd_ep_t *_ep);
241 extern void dwc_otg_pcd_update_otg(dwc_otg_pcd_t *_pcd,
242                                         const unsigned reset);
243
244 #endif
245 #endif /* DWC_HOST_ONLY */
Note: See TracBrowser for help on using the browser.