~ubuntu-branches/ubuntu/karmic/linux-mvl-dove/karmic-proposed

« back to all changes in this revision

Viewing changes to arch/arm/plat-orion/mv_hal_drivers/mv_hal/usb/device/mvUsbHsDevUtl.c

  • Committer: Bazaar Package Importer
  • Author(s): Stefan Bader
  • Date: 2010-03-10 22:24:12 UTC
  • mto: (15.1.2 karmic-security)
  • mto: This revision was merged to the branch mainline in revision 18.
  • Revision ID: james.westby@ubuntu.com-20100310222412-k86m3r53jw0je7x1
Tags: upstream-2.6.31
ImportĀ upstreamĀ versionĀ 2.6.31

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*******************************************************************************
2
 
 
3
 
This software file (the "File") is distributed by Marvell International Ltd. 
4
 
or its affiliate(s) under the terms of the GNU General Public License Version 2, 
5
 
June 1991 (the "License").  You may use, redistribute and/or modify this File 
6
 
in accordance with the terms and conditions of the License, a copy of which 
7
 
is available along with the File in the license.txt file or by writing to the 
8
 
Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 
9
 
or on the worldwide web at http://www.gnu.org/licenses/gpl.txt.
10
 
 
11
 
THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE IMPLIED 
12
 
WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE ARE EXPRESSLY 
13
 
DISCLAIMED.  The GPL License provides additional details about this warranty 
14
 
disclaimer.
15
 
 
16
 
(C) Copyright 2004 - 2007 Marvell Semiconductor Israel Ltd. All Rights Reserved.
17
 
(C) Copyright 1999 - 2004 Chipidea Microelectronica, S.A. All Rights Reserved.
18
 
 
19
 
*******************************************************************************/
20
 
 
21
 
#include "mvUsbDevApi.h"
22
 
#include "mvUsbDevPrv.h"
23
 
#include "mvUsbDefs.h"
24
 
 
25
 
/* Test packet for Test Mode : TEST_PACKET. USB 2.0 Specification section 7.1.20 */
26
 
uint_8 test_packet[USB_TEST_MODE_TEST_PACKET_LENGTH] = 
27
 
{
28
 
   /* Synch */
29
 
   /* DATA 0 PID */
30
 
   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
31
 
   0x00, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 
32
 
   0xAA, 0xEE, 0xEE, 0xEE, 0xEE, 0xEE, 0xEE, 0xEE, 
33
 
   0xEE, 0xFE, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 
34
 
   0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x7F, 0xBF, 0xDF, 
35
 
   0xEF, 0xF7, 0xFB, 0xFD, 0xFC, 0x7E, 0xBF, 0xDF, 
36
 
   0xEF, 0xF7, 0xFB, 0xFD, 0x7E
37
 
};
38
 
 
39
 
/*FUNCTION*-------------------------------------------------------------
40
 
*
41
 
*  Function Name  : _usb_dci_vusb20_assert_resume
42
 
*  Returned Value : None
43
 
*  Comments       :
44
 
*        Resume signalling for remote wakeup
45
 
*
46
 
*END*-----------------------------------------------------------------*/
47
 
void _usb_dci_vusb20_assert_resume
48
 
   (
49
 
      /* [IN] the USB_dev_initialize state structure */
50
 
      _usb_device_handle         handle
51
 
   )
52
 
{ /* Body */
53
 
   USB_DEV_STATE_STRUCT_PTR                     usb_dev_ptr;
54
 
   VUSB20_REG_STRUCT_PTR             dev_ptr;
55
 
   uint_32                                      temp;
56
 
 
57
 
   usb_dev_ptr = (USB_DEV_STATE_STRUCT_PTR)handle;
58
 
   dev_ptr = (VUSB20_REG_STRUCT_PTR)usb_dev_ptr->DEV_PTR;
59
 
 
60
 
   /* Assert the Resume signal */   
61
 
   temp = USB_32BIT_LE(dev_ptr->REGISTERS.OPERATIONAL_DEVICE_REGISTERS.PORTSCX[0]);
62
 
   temp &= ~EHCI_PORTSCX_W1C_BITS;
63
 
   temp |= EHCI_PORTSCX_PORT_FORCE_RESUME;
64
 
   dev_ptr->REGISTERS.OPERATIONAL_DEVICE_REGISTERS.PORTSCX[0] = USB_32BIT_LE(temp);
65
 
   
66
 
   /* Port change interrupt will be asserted at the end of resume 
67
 
   ** operation 
68
 
   */
69
 
 
70
 
} /* EndBody */
71
 
 
72
 
/*FUNCTION*-------------------------------------------------------------
73
 
*
74
 
*  Function Name  : _usb_dci_vusb20_stall_endpoint
75
 
*  Returned Value : None
76
 
*  Comments       :
77
 
*        Stalls the specified endpoint
78
 
*
79
 
*END*-----------------------------------------------------------------*/
80
 
void _usb_dci_vusb20_stall_endpoint
81
 
   (
82
 
      /* [IN] the USB_dev_initialize state structure */
83
 
      _usb_device_handle         handle,
84
 
            
85
 
      /* [IN] the Endpoint number */
86
 
      uint_8                     ep_num,
87
 
            
88
 
      /* [IN] direction */
89
 
      uint_8                     direction
90
 
   )
91
 
{ /* Body */
92
 
   USB_DEV_STATE_STRUCT_PTR             usb_dev_ptr;
93
 
   VUSB20_REG_STRUCT_PTR                dev_ptr;
94
 
   VUSB20_EP_QUEUE_HEAD_STRUCT _PTR_    ep_queue_head_ptr;
95
 
      
96
 
   usb_dev_ptr = (USB_DEV_STATE_STRUCT_PTR)handle;
97
 
   dev_ptr = (VUSB20_REG_STRUCT_PTR)usb_dev_ptr->DEV_PTR;
98
 
   
99
 
   /* Get the endpoint queue head address */
100
 
   ep_queue_head_ptr = (VUSB20_EP_QUEUE_HEAD_STRUCT_PTR)usb_dev_ptr->EP_QUEUE_HEAD_PTR + 
101
 
                                                                    2*ep_num + direction;
102
 
   /* Stall the endpoint for Rx or Tx and set the endpoint type */
103
 
   if (ep_queue_head_ptr->MAX_PKT_LENGTH & USB_32BIT_LE(VUSB_EP_QUEUE_HEAD_IOS)) 
104
 
   {
105
 
      /* This is a control endpoint so STALL both directions */
106
 
      dev_ptr->REGISTERS.OPERATIONAL_DEVICE_REGISTERS.ENDPTCTRLX[ep_num] |= 
107
 
         USB_32BIT_LE((EHCI_EPCTRL_TX_EP_STALL | EHCI_EPCTRL_RX_EP_STALL));
108
 
   } 
109
 
   else 
110
 
   {   
111
 
       if(direction) 
112
 
       {
113
 
            dev_ptr->REGISTERS.OPERATIONAL_DEVICE_REGISTERS.ENDPTCTRLX[ep_num] |= 
114
 
                        USB_32BIT_LE(EHCI_EPCTRL_TX_EP_STALL);
115
 
       }
116
 
       else {
117
 
            dev_ptr->REGISTERS.OPERATIONAL_DEVICE_REGISTERS.ENDPTCTRLX[ep_num] |= 
118
 
                        USB_32BIT_LE(EHCI_EPCTRL_RX_EP_STALL);
119
 
       }
120
 
   } /* Endif */
121
 
 
122
 
   ARC_DEBUG_TRACE(ARC_DEBUG_FLAG_STALL, 
123
 
                    "STALL ep=%d %s: EPCTRLX=0x%x, CURR_dTD=0x%x, NEXT_dTD=0x%x, SIZE=0x%x\n", 
124
 
                    ep_num, direction ? "SEND" : "RECV",
125
 
                    (unsigned)USB_32BIT_LE(dev_ptr->REGISTERS.OPERATIONAL_DEVICE_REGISTERS.ENDPTCTRLX[ep_num]),
126
 
                    (unsigned)USB_32BIT_LE(ep_queue_head_ptr->CURR_DTD_PTR), 
127
 
                    (unsigned)USB_32BIT_LE(ep_queue_head_ptr->NEXT_DTD_PTR),
128
 
                    (unsigned)USB_32BIT_LE(ep_queue_head_ptr->SIZE_IOC_INT_STS));
129
 
      
130
 
} /* EndBody */
131
 
 
132
 
/*FUNCTION*-------------------------------------------------------------
133
 
*
134
 
*  Function Name  : _usb_dci_vusb20_unstall_endpoint
135
 
*  Returned Value : None
136
 
*  Comments       :
137
 
*        Unstall the specified endpoint in the specified direction
138
 
*
139
 
*END*-----------------------------------------------------------------*/
140
 
void _usb_dci_vusb20_unstall_endpoint
141
 
   (
142
 
      /* [IN] the USB_dev_initialize state structure */
143
 
      _usb_device_handle         handle,
144
 
            
145
 
      /* [IN] the Endpoint number */
146
 
      uint_8                     ep_num,
147
 
            
148
 
      /* [IN] direction */
149
 
      uint_8                     direction
150
 
   )
151
 
{ /* Body */
152
 
   USB_DEV_STATE_STRUCT_PTR     usb_dev_ptr;
153
 
   VUSB20_REG_STRUCT_PTR        dev_ptr;
154
 
 
155
 
   usb_dev_ptr = (USB_DEV_STATE_STRUCT_PTR)handle;
156
 
   dev_ptr = (VUSB20_REG_STRUCT_PTR)usb_dev_ptr->DEV_PTR;
157
 
   
158
 
   /* Enable the endpoint for Rx or Tx and set the endpoint type */
159
 
   if(direction)
160
 
   {
161
 
        dev_ptr->REGISTERS.OPERATIONAL_DEVICE_REGISTERS.ENDPTCTRLX[ep_num] |= 
162
 
              USB_32BIT_LE(EHCI_EPCTRL_TX_DATA_TOGGLE_RST);
163
 
 
164
 
        dev_ptr->REGISTERS.OPERATIONAL_DEVICE_REGISTERS.ENDPTCTRLX[ep_num] &= 
165
 
                ~(USB_32BIT_LE(EHCI_EPCTRL_TX_EP_STALL));
166
 
   }
167
 
   else
168
 
   {
169
 
        dev_ptr->REGISTERS.OPERATIONAL_DEVICE_REGISTERS.ENDPTCTRLX[ep_num] |= 
170
 
              USB_32BIT_LE(EHCI_EPCTRL_RX_DATA_TOGGLE_RST);
171
 
 
172
 
        dev_ptr->REGISTERS.OPERATIONAL_DEVICE_REGISTERS.ENDPTCTRLX[ep_num] &= 
173
 
                ~(USB_32BIT_LE(EHCI_EPCTRL_RX_EP_STALL));
174
 
   }     
175
 
 
176
 
   ARC_DEBUG_TRACE(ARC_DEBUG_FLAG_STALL, 
177
 
                    "UNSTALL ep=%d %s: EPCTRLX=0x%x\n", 
178
 
                    ep_num, direction ? "SEND" : "RECV",
179
 
                    (unsigned)USB_32BIT_LE(dev_ptr->REGISTERS.OPERATIONAL_DEVICE_REGISTERS.ENDPTCTRLX[ep_num]));
180
 
 
181
 
 
182
 
} /* EndBody */
183
 
 
184
 
/*FUNCTION*----------------------------------------------------------------
185
 
186
 
* Function Name  : _usb_dci_vusb20_is_endpoint_stalled
187
 
* Returned Value : None
188
 
* Comments       :
189
 
*     Gets the endpoint status
190
 
191
 
*END*--------------------------------------------------------------------*/
192
 
uint_8 _usb_dci_vusb20_is_endpoint_stalled
193
 
   (
194
 
      /* [IN] Handle to the USB device */
195
 
      _usb_device_handle   handle,
196
 
      
197
 
      /* [IN] Endpoint number */
198
 
      uint_8               ep,
199
 
 
200
 
      /* [IN] Endpoint direction */
201
 
      uint_8               dir
202
 
   )
203
 
{ /* Body */
204
 
   USB_DEV_STATE_STRUCT_PTR     usb_dev_ptr;
205
 
   VUSB20_REG_STRUCT_PTR        dev_ptr;
206
 
   uint_32                      value;
207
 
 
208
 
   ARC_DEBUG_TRACE(ARC_DEBUG_FLAG_TRACE, "is_endpoint_stalled\n");
209
 
   
210
 
   usb_dev_ptr = (USB_DEV_STATE_STRUCT_PTR)handle;
211
 
   dev_ptr = (VUSB20_REG_STRUCT_PTR)usb_dev_ptr->DEV_PTR;
212
 
  
213
 
   if(dir)
214
 
   {
215
 
        value = dev_ptr->REGISTERS.OPERATIONAL_DEVICE_REGISTERS.ENDPTCTRLX[ep] & 
216
 
                                    (USB_32BIT_LE(EHCI_EPCTRL_TX_EP_STALL));
217
 
   }
218
 
   else
219
 
   {
220
 
        value = dev_ptr->REGISTERS.OPERATIONAL_DEVICE_REGISTERS.ENDPTCTRLX[ep] & 
221
 
                                    (USB_32BIT_LE(EHCI_EPCTRL_RX_EP_STALL));
222
 
   }
223
 
   return (value) ? 1 : 0;
224
 
} /* EndBody */
225
 
 
226
 
/*FUNCTION*----------------------------------------------------------------
227
 
228
 
* Function Name  : _usb_dci_vusb20_set_test_mode
229
 
* Returned Value : None
230
 
* Comments       :
231
 
*     sets/resets the test mode
232
 
233
 
*END*--------------------------------------------------------------------*/
234
 
void _usb_dci_vusb20_set_test_mode
235
 
   (
236
 
      /* [IN] Handle to the USB device */
237
 
      _usb_device_handle handle,
238
 
      
239
 
      /* [IN] Test mode */
240
 
      uint_16 test_mode
241
 
   )
242
 
{ /* Body */
243
 
   USB_DEV_STATE_STRUCT_PTR                     usb_dev_ptr;
244
 
   VUSB20_REG_STRUCT_PTR                        dev_ptr;
245
 
   uint_32                                      temp;
246
 
 
247
 
   ARC_DEBUG_TRACE(ARC_DEBUG_FLAG_ANY, "set_test_mode\n");
248
 
   
249
 
   usb_dev_ptr = (USB_DEV_STATE_STRUCT_PTR)handle;
250
 
   dev_ptr = (VUSB20_REG_STRUCT_PTR)usb_dev_ptr->DEV_PTR;
251
 
   
252
 
   temp = USB_32BIT_LE(dev_ptr->REGISTERS.OPERATIONAL_DEVICE_REGISTERS.ENDPTCTRLX[0]);
253
 
   
254
 
   dev_ptr->REGISTERS.OPERATIONAL_DEVICE_REGISTERS.ENDPTCTRLX[0] = 
255
 
                                USB_32BIT_LE((temp | EHCI_EPCTRL_TX_DATA_TOGGLE_RST));
256
 
 
257
 
   if (test_mode == ARC_USB_TEST_MODE_TEST_PACKET) 
258
 
   {
259
 
       USB_memcopy(test_packet, usb_dev_ptr->TEST_PKT_PTR, USB_TEST_MODE_TEST_PACKET_LENGTH); 
260
 
      _usb_device_send_data(handle, 0, usb_dev_ptr->TEST_PKT_PTR, USB_TEST_MODE_TEST_PACKET_LENGTH);
261
 
 
262
 
   } /* Endif */
263
 
   
264
 
   temp = USB_32BIT_LE(dev_ptr->REGISTERS.OPERATIONAL_DEVICE_REGISTERS.PORTSCX[0]);
265
 
   temp &= ~EHCI_PORTSCX_W1C_BITS;
266
 
   
267
 
   dev_ptr->REGISTERS.OPERATIONAL_DEVICE_REGISTERS.PORTSCX[0] = 
268
 
                                    USB_32BIT_LE(temp | ((uint_32)test_mode << 8));
269
 
             
270
 
} /* EndBody */
271