1
/*******************************************************************************
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.
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
16
(C) Copyright 2004 - 2007 Marvell Semiconductor Israel Ltd. All Rights Reserved.
17
(C) Copyright 1999 - 2004 Chipidea Microelectronica, S.A. All Rights Reserved.
19
*******************************************************************************/
21
#ifndef __mvUsbTypes_h__
22
#define __mvUsbTypes_h__
27
typedef char _PTR_ char_ptr; /* signed character */
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 */
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*/
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*/
38
typedef unsigned long boolean; /* Machine representation of a boolean */
40
typedef void _PTR_ pointer; /* Machine representation of a pointer */
42
/*--------------------------------------------------------------------------*/
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.
52
# define FALSE ((boolean)0)
56
# define TRUE ((boolean)!FALSE)
63
# define NULL ((pointer)0)
70
#define ASSERT(X,Y) if(Y) { USB_printf(X); exit(1);}
74
# define MIN(a,b) ((a) < (b) ? (a) : (b))
77
#define USB_MEM_ALIGN(n, align) ((n) + (-(n) & (align-1)))
79
/* Macro for aligning the EP queue head to 32 byte boundary */
80
#define USB_MEM32_ALIGN(n) USB_MEM_ALIGN(n, 32)
82
/* Macro for aligning the EP queue head to 1024 byte boundary */
83
#define USB_MEM1024_ALIGN(n) USB_MEM_ALIGN(n, 1024)
85
/* Macro for aligning the EP queue head to 1024 byte boundary */
86
#define USB_MEM2048_ALIGN(n) USB_MEM_ALIGN(n, 2048)
88
#define PSP_CACHE_LINE_SIZE 32
90
#define USB_uint_16_low(x) ((x) & 0xFF)
91
#define USB_uint_16_high(x) (((x) >> 8) & 0xFF)
93
#define USB_CACHE_ALIGN(n) USB_MEM_ALIGN(n, PSP_CACHE_LINE_SIZE)
96
# if defined(MV_VXWORKS)
97
# define INLINE __inline
99
# define INLINE inline
100
# endif /* MV_VXWORKS */
103
/* 16bit byte swap. For example 0x1122 -> 0x2211 */
104
static INLINE uint_16 USB_BYTE_SWAP_16BIT(uint_16 value)
106
return ( ((value & 0x00ff) << 8) |
107
((value & 0xff00) >> 8) );
110
/* 32bit byte swap. For example 0x11223344 -> 0x44332211 */
111
static INLINE uint_32 USB_BYTE_SWAP_32BIT(uint_32 value)
113
return ( ((value & 0x000000ff) << 24) |
114
((value & 0x0000ff00) << 8) |
115
((value & 0x00ff0000) >> 8) |
116
((value & 0xff000000) >> 24));
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)
132
#error "CPU endianess isn't defined!\n"
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,
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);
157
extern USB_IMPORT_FUNCS* global_import_funcs;
159
#define USB_sprintf(frmt, x...) if( (global_import_funcs != NULL) && \
160
global_import_funcs->bspSprintf != NULL) \
161
global_import_funcs->bspSprintf(frmt, ##x)
163
#define USB_printf(frmt, x...) if( (global_import_funcs != NULL) && \
164
(global_import_funcs->bspPrintf != NULL) ) \
165
global_import_funcs->bspPrintf(frmt, ##x)
168
#define USB_virt_to_phys(pVirt) (global_import_funcs->bspVirtToPhys == NULL) ? \
169
(uint_32)(pVirt) : global_import_funcs->bspVirtToPhys(NULL, pVirt)
171
#define USB_get_cap_reg_addr(dev) global_import_funcs->bspGetCapRegAddr(dev)
173
static INLINE void* USB_uncached_memalloc(uint_32 size, uint_32 align, unsigned long* pPhyAddr)
175
/*USB_printf("**** USB_uncached_memalloc: size=%d\n", (size)); */
176
return global_import_funcs->bspUncachedMalloc(NULL, size, align, pPhyAddr);
179
static INLINE void* USB_memalloc(uint_32 size)
181
/*USB_printf("**** USB_memalloc: size=%d\n", (size)); */
182
return global_import_funcs->bspMalloc(size);
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);
189
#define USB_memfree(ptr) \
190
/*USB_printf("#### USB_memfree: ptr=0x%x\n", (ptr));*/ \
191
global_import_funcs->bspFree(ptr);
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)
196
#define USB_dcache_inv(ptr, size) if(global_import_funcs->bspCacheInv != NULL) \
197
global_import_funcs->bspCacheInv(NULL, ptr, size)
199
#define USB_dcache_flush(ptr, size) if(global_import_funcs->bspCacheFlush != NULL) \
200
global_import_funcs->bspCacheFlush(NULL, ptr, size)
202
#define USB_lock() (global_import_funcs->bspLock == NULL) ? \
203
0 : global_import_funcs->bspLock()
205
#define USB_unlock(key) if(global_import_funcs->bspUnlock != NULL) \
206
global_import_funcs->bspUnlock(key)
208
#define USB_reset_complete(dev) if(global_import_funcs->bspResetComplete) \
209
global_import_funcs->bspResetComplete(dev)
212
#if defined(USB_UNDERRUN_WA)
214
#define USB_SRAM_MAX_PARTS 16
218
uint_32 (*bspGetSramAddr) (uint_32* pSize);
219
void (*bspIdmaCopy) (void* dst, void* src, unsigned int size);
223
extern USB_WA_FUNCS* global_wa_funcs;
224
extern int global_wa_sram_parts;
225
extern int global_wa_threshold;
227
#define USB_get_sram_addr(pSize) global_wa_funcs->bspGetSramAddr(pSize)
229
#define USB_idma_copy(dst, src, size) \
230
if(global_wa_funcs->bspIdmaCopy != NULL) \
231
global_wa_funcs->bspIdmaCopy(dst, src, size)
233
#endif /* USB_UNDERRUN_WA */
235
#endif /* __mvUsbTypes_h__ */