~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/api/mvUsbTypes.h

  • 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
 
#ifndef __mvUsbTypes_h__
22
 
#define __mvUsbTypes_h__
23
 
 
24
 
#define _PTR_      *
25
 
#define _CODE_PTR_ *
26
 
 
27
 
typedef char _PTR_                    char_ptr;    /* signed character       */
28
 
 
29
 
typedef signed   char  int_8, _PTR_   int_8_ptr;   /* 8-bit signed integer   */
30
 
typedef unsigned char  uint_8, _PTR_   uint_8_ptr;  /* 8-bit signed integer   */
31
 
 
32
 
typedef          short int_16, _PTR_   int_16_ptr;  /* 16-bit signed integer  */
33
 
typedef unsigned short uint_16, _PTR_  uint_16_ptr; /* 16-bit unsigned integer*/
34
 
 
35
 
typedef          int   int_32, _PTR_   int_32_ptr;  /* 32-bit signed integer  */
36
 
typedef unsigned int   uint_32, _PTR_  uint_32_ptr; /* 32-bit unsigned integer*/
37
 
 
38
 
typedef unsigned long  boolean;  /* Machine representation of a boolean */
39
 
 
40
 
typedef void _PTR_     pointer;  /* Machine representation of a pointer */
41
 
 
42
 
/*--------------------------------------------------------------------------*/
43
 
/*
44
 
**                          STANDARD CONSTANTS
45
 
**
46
 
**  Note that if standard 'C' library files are included after types.h,
47
 
**  the defines of TRUE, FALSE and NULL may sometimes conflict, as most
48
 
**  standard library files do not check for previous definitions.
49
 
*/
50
 
 
51
 
#ifndef  FALSE
52
 
#   define FALSE ((boolean)0)   
53
 
#endif
54
 
 
55
 
#ifndef  TRUE
56
 
#   define TRUE ((boolean)!FALSE) 
57
 
#endif
58
 
 
59
 
#ifndef  NULL
60
 
#   ifdef __cplusplus
61
 
#       define NULL (0)
62
 
#   else
63
 
#       define NULL ((pointer)0)
64
 
#   endif
65
 
#endif
66
 
 
67
 
#ifndef _ASSERT_
68
 
   #define ASSERT(X,Y)
69
 
#else
70
 
   #define ASSERT(X,Y) if(Y) { USB_printf(X); exit(1);}
71
 
#endif
72
 
 
73
 
#ifndef  MIN
74
 
#   define MIN(a,b)   ((a) < (b) ? (a) : (b))      
75
 
#endif
76
 
 
77
 
#define USB_MEM_ALIGN(n, align)            ((n) + (-(n) & (align-1)))
78
 
 
79
 
/* Macro for aligning the EP queue head to 32 byte boundary */
80
 
#define USB_MEM32_ALIGN(n)                  USB_MEM_ALIGN(n, 32)
81
 
 
82
 
/* Macro for aligning the EP queue head to 1024 byte boundary */
83
 
#define USB_MEM1024_ALIGN(n)                USB_MEM_ALIGN(n, 1024)
84
 
 
85
 
/* Macro for aligning the EP queue head to 1024 byte boundary */
86
 
#define USB_MEM2048_ALIGN(n)                USB_MEM_ALIGN(n, 2048)
87
 
 
88
 
#define PSP_CACHE_LINE_SIZE                 32
89
 
 
90
 
#define USB_uint_16_low(x)                  ((x) & 0xFF)
91
 
#define USB_uint_16_high(x)                 (((x) >> 8) & 0xFF)
92
 
 
93
 
#define USB_CACHE_ALIGN(n)                  USB_MEM_ALIGN(n, PSP_CACHE_LINE_SIZE)       
94
 
 
95
 
#ifndef INLINE
96
 
#   if defined(MV_VXWORKS)
97
 
#       define INLINE   __inline
98
 
#   else
99
 
#       define INLINE   inline
100
 
#   endif /* MV_VXWORKS */
101
 
#endif /* INLINE */
102
 
 
103
 
/* 16bit byte swap. For example 0x1122 -> 0x2211                            */
104
 
static INLINE uint_16 USB_BYTE_SWAP_16BIT(uint_16 value)
105
 
{
106
 
    return ( ((value & 0x00ff) << 8) | 
107
 
             ((value & 0xff00) >> 8) );
108
 
}
109
 
 
110
 
/* 32bit byte swap. For example 0x11223344 -> 0x44332211                    */
111
 
static INLINE uint_32 USB_BYTE_SWAP_32BIT(uint_32 value)
112
 
{
113
 
    return ( ((value & 0x000000ff) << 24) |                      
114
 
             ((value & 0x0000ff00) << 8)  |                    
115
 
             ((value & 0x00ff0000) >> 8)  |       
116
 
             ((value & 0xff000000) >> 24));
117
 
}
118
 
 
119
 
    
120
 
/* Endianess macros.                                                        */
121
 
#if defined(MV_CPU_LE)
122
 
#   define USB_16BIT_LE(X)  (X) 
123
 
#   define USB_32BIT_LE(X)  (X)
124
 
#   define USB_16BIT_BE(X)  USB_BYTE_SWAP_16BIT(X)
125
 
#   define USB_32BIT_BE(X)  USB_BYTE_SWAP_32BIT(X)
126
 
#elif defined(MV_CPU_BE)
127
 
#   define USB_16BIT_LE(X)  USB_BYTE_SWAP_16BIT(X) 
128
 
#   define USB_32BIT_LE(X)  USB_BYTE_SWAP_32BIT(X)
129
 
#   define USB_16BIT_BE(X)  (X)
130
 
#   define USB_32BIT_BE(X)  (X)
131
 
#else
132
 
    #error "CPU endianess isn't defined!\n"
133
 
#endif 
134
 
 
135
 
typedef struct
136
 
{
137
 
    void    (*bspPrintf)          (const char *  fmt, ...);
138
 
    int     (*bspSprintf)         (char* buffer, const char *  fmt, ...);
139
 
    void*   (*bspUncachedMalloc)  (void* pDev, uint_32 size, uint_32 align,
140
 
                                   unsigned long* pPhyAddr);     
141
 
    void    (*bspUncachedFree)    (void* pDev, uint_32 size, unsigned long phyAddr, 
142
 
                                    void*  pVirtAddr);
143
 
    void*   (*bspMalloc)          (unsigned int size);
144
 
    void    (*bspFree)            (void* ptr);
145
 
    void*   (*bspMemset)          (void* ptr, int val, unsigned int size);
146
 
    void*   (*bspMemcpy)          (void* dst, const void* src, unsigned int size);
147
 
    unsigned long (*bspCacheFlush)      (void* pDev, void* pVirtAddr, int size);
148
 
    unsigned long (*bspCacheInv)        (void* pDev, void* pVirtAddr, int size);
149
 
    unsigned long (*bspVirtToPhys)    (void* pDev, void* pVirtAddr);
150
 
    int     (*bspLock)            (void);
151
 
    void    (*bspUnlock)          (int lockKey);
152
 
    uint_32 (*bspGetCapRegAddr)   (int devNo);
153
 
    void    (*bspResetComplete)   (int devNo);
154
 
 
155
 
} USB_IMPORT_FUNCS;
156
 
 
157
 
extern USB_IMPORT_FUNCS*            global_import_funcs;
158
 
 
159
 
#define USB_sprintf(frmt, x...)     if( (global_import_funcs != NULL) &&                \
160
 
                                         global_import_funcs->bspSprintf != NULL)        \
161
 
                                        global_import_funcs->bspSprintf(frmt, ##x)
162
 
 
163
 
#define USB_printf(frmt, x...)      if( (global_import_funcs != NULL) &&                \
164
 
                                        (global_import_funcs->bspPrintf != NULL) )        \
165
 
                                        global_import_funcs->bspPrintf(frmt, ##x)
166
 
 
167
 
 
168
 
#define USB_virt_to_phys(pVirt)     (global_import_funcs->bspVirtToPhys == NULL) ?      \
169
 
                                        (uint_32)(pVirt) : global_import_funcs->bspVirtToPhys(NULL, pVirt)
170
 
 
171
 
#define USB_get_cap_reg_addr(dev)   global_import_funcs->bspGetCapRegAddr(dev)
172
 
 
173
 
static INLINE void* USB_uncached_memalloc(uint_32 size, uint_32 align, unsigned long* pPhyAddr) 
174
 
{
175
 
    /*USB_printf("**** USB_uncached_memalloc: size=%d\n", (size));       */
176
 
    return global_import_funcs->bspUncachedMalloc(NULL, size, align, pPhyAddr); 
177
 
}
178
 
 
179
 
static INLINE void* USB_memalloc(uint_32 size)                                                                              
180
 
{
181
 
    /*USB_printf("**** USB_memalloc: size=%d\n", (size)); */
182
 
    return global_import_funcs->bspMalloc(size);        
183
 
}
184
 
 
185
 
#define USB_uncached_memfree(pVirt, size, physAddr)                                 \
186
 
                /*USB_printf("#### USB_uncached_memfree: pVirt=0x%x\n", (pVirt)); */\
187
 
                global_import_funcs->bspUncachedFree(NULL, size, physAddr, pVirt);
188
 
 
189
 
#define USB_memfree(ptr)                                                            \
190
 
                /*USB_printf("#### USB_memfree: ptr=0x%x\n", (ptr));*/              \
191
 
                global_import_funcs->bspFree(ptr);
192
 
 
193
 
#define USB_memzero(ptr, n)         global_import_funcs->bspMemset(ptr, 0,  n)
194
 
#define USB_memcopy(src, dst, n)    global_import_funcs->bspMemcpy(dst, src, n)
195
 
 
196
 
#define USB_dcache_inv(ptr, size)   if(global_import_funcs->bspCacheInv != NULL)  \
197
 
                                        global_import_funcs->bspCacheInv(NULL, ptr, size)     
198
 
 
199
 
#define USB_dcache_flush(ptr, size) if(global_import_funcs->bspCacheFlush != NULL)  \
200
 
                                        global_import_funcs->bspCacheFlush(NULL, ptr, size)     
201
 
 
202
 
#define USB_lock()                  (global_import_funcs->bspLock == NULL) ?        \
203
 
                                                    0 : global_import_funcs->bspLock()
204
 
 
205
 
#define USB_unlock(key)             if(global_import_funcs->bspUnlock != NULL)  \
206
 
                                        global_import_funcs->bspUnlock(key)     
207
 
 
208
 
#define USB_reset_complete(dev)     if(global_import_funcs->bspResetComplete)       \
209
 
                                        global_import_funcs->bspResetComplete(dev)
210
 
 
211
 
 
212
 
#if defined(USB_UNDERRUN_WA)
213
 
 
214
 
#define USB_SRAM_MAX_PARTS  16  
215
 
 
216
 
typedef struct
217
 
{
218
 
    uint_32 (*bspGetSramAddr) (uint_32* pSize);
219
 
    void    (*bspIdmaCopy) (void* dst, void* src, unsigned int size);
220
 
 
221
 
} USB_WA_FUNCS;
222
 
 
223
 
extern USB_WA_FUNCS*    global_wa_funcs;
224
 
extern int              global_wa_sram_parts;
225
 
extern int              global_wa_threshold; 
226
 
 
227
 
#define USB_get_sram_addr(pSize)        global_wa_funcs->bspGetSramAddr(pSize)
228
 
 
229
 
#define USB_idma_copy(dst, src, size)                                   \
230
 
            if(global_wa_funcs->bspIdmaCopy != NULL)                    \
231
 
                global_wa_funcs->bspIdmaCopy(dst, src, size)
232
 
 
233
 
#endif /* USB_UNDERRUN_WA */
234
 
 
235
 
#endif /* __mvUsbTypes_h__ */
236
 
 
237
 
/* EOF */
238