Xilinx: ARM: I2C: SI570: Driver updated for more error checking
[linux-2.6-xlnx.git] / drivers / xilinx_common / xenv.h
blob45a59e99baa59e5206cf35503393012e19af4005
1 /******************************************************************************
3 * XILINX IS PROVIDING THIS DESIGN, CODE, OR INFORMATION "AS IS"
4 * AS A COURTESY TO YOU, SOLELY FOR USE IN DEVELOPING PROGRAMS AND
5 * SOLUTIONS FOR XILINX DEVICES. BY PROVIDING THIS DESIGN, CODE,
6 * OR INFORMATION AS ONE POSSIBLE IMPLEMENTATION OF THIS FEATURE,
7 * APPLICATION OR STANDARD, XILINX IS MAKING NO REPRESENTATION
8 * THAT THIS IMPLEMENTATION IS FREE FROM ANY CLAIMS OF INFRINGEMENT,
9 * AND YOU ARE RESPONSIBLE FOR OBTAINING ANY RIGHTS YOU MAY REQUIRE
10 * FOR YOUR IMPLEMENTATION. XILINX EXPRESSLY DISCLAIMS ANY
11 * WARRANTY WHATSOEVER WITH RESPECT TO THE ADEQUACY OF THE
12 * IMPLEMENTATION, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OR
13 * REPRESENTATIONS THAT THIS IMPLEMENTATION IS FREE FROM CLAIMS OF
14 * INFRINGEMENT, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
15 * FOR A PARTICULAR PURPOSE.
17 * (c) Copyright 2005-2008 Xilinx Inc.
18 * All rights reserved.
19 * This program is free software; you can redistribute it and/or modify it
20 * under the terms of the GNU General Public License as published by the
21 * Free Software Foundation; either version 2 of the License, or (at your
22 * option) any later version.
24 * You should have received a copy of the GNU General Public License
25 * along with this program; if not, write to the Free Software
26 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
28 ******************************************************************************/
29 /*****************************************************************************/
30 /**
32 * @file xenv_linux.h
34 * Defines common services specified by xenv.h.
36 * @note
37 * This file is not intended to be included directly by driver code.
38 * Instead, the generic xenv.h file is intended to be included by driver
39 * code.
41 * <pre>
42 * MODIFICATION HISTORY:
44 * Ver Who Date Changes
45 * ----- ---- -------- -----------------------------------------------
46 * 1.00a wgr 02/28/07 Added cache handling macros.
47 * 1.00a wgr 02/27/07 Simplified code. Deprecated old-style macro names.
48 * 1.00a xd 11/03/04 Improved support for doxygen.
49 * 1.00a ch 10/24/02 First release
50 * 1.10a wgr 03/22/07 Converted to new coding style.
51 * </pre>
54 ******************************************************************************/
56 #ifndef XENV_LINUX_H
57 #define XENV_LINUX_H
59 #ifdef __cplusplus
60 extern "C" {
61 #endif
64 /***************************** Include Files *********************************/
66 #include <asm/cache.h>
67 #include <asm/cacheflush.h>
68 #include <linux/string.h>
69 #include <linux/delay.h>
72 /******************************************************************************
74 * MEMCPY / MEMSET related macros.
76 * Those macros are defined to catch legacy code in Xilinx drivers. The
77 * XENV_MEM_COPY and XENV_MEM_FILL macros were used in early Xilinx driver
78 * code. They are being replaced by memcpy() and memset() function calls. These
79 * macros are defined to catch any remaining occurences of those macros.
81 ******************************************************************************/
83 /*****************************************************************************/
84 /**
86 * Copies a non-overlapping block of memory.
88 * @param DestPtr
89 * Destination address to copy data to.
91 * @param SrcPtr
92 * Source address to copy data from.
94 * @param Bytes
95 * Number of bytes to copy.
97 * @return None.
99 *****************************************************************************/
101 #define XENV_MEM_COPY(DestPtr, SrcPtr, Bytes) \
102 memcpy(DestPtr, SrcPtr, Bytes)
103 /* do_not_use_XENV_MEM_COPY_use_memcpy_instead */
106 /*****************************************************************************/
109 * Fills an area of memory with constant data.
111 * @param DestPtr
112 * Destination address to copy data to.
114 * @param Data
115 * Value to set.
117 * @param Bytes
118 * Number of bytes to copy.
120 * @return None.
122 *****************************************************************************/
124 #define XENV_MEM_FILL(DestPtr, Data, Bytes) \
125 memset(DestPtr, Data, Bytes)
126 /* do_not_use_XENV_MEM_FILL_use_memset_instead */
129 /******************************************************************************
131 * TIME related macros
133 ******************************************************************************/
135 * A structure that contains a time stamp used by other time stamp macros
136 * defined below. This structure is processor dependent.
138 typedef int XENV_TIME_STAMP;
140 /*****************************************************************************/
143 * Time is derived from the 64 bit PPC timebase register
145 * @param StampPtr is the storage for the retrieved time stamp.
147 * @return None.
149 * @note
151 * Signature: void XENV_TIME_STAMP_GET(XTIME_STAMP *StampPtr)
152 * <br><br>
153 * This macro must be implemented by the user.
155 *****************************************************************************/
156 #define XENV_TIME_STAMP_GET(StampPtr)
158 /*****************************************************************************/
161 * This macro is not yet implemented and always returns 0.
163 * @param Stamp1Ptr is the first sampled time stamp.
164 * @param Stamp2Ptr is the second sampled time stamp.
166 * @return 0
168 * @note
170 * This macro must be implemented by the user.
172 *****************************************************************************/
173 #define XENV_TIME_STAMP_DELTA_US(Stamp1Ptr, Stamp2Ptr) (0)
175 /*****************************************************************************/
178 * This macro is not yet implemented and always returns 0.
180 * @param Stamp1Ptr is the first sampled time stamp.
181 * @param Stamp2Ptr is the second sampled time stamp.
183 * @return 0
185 * @note
187 * This macro must be implemented by the user
189 *****************************************************************************/
190 #define XENV_TIME_STAMP_DELTA_MS(Stamp1Ptr, Stamp2Ptr) (0)
192 /*****************************************************************************/
195 * Delay the specified number of microseconds.
197 * @param delay
198 * Number of microseconds to delay.
200 * @return None.
202 * @note XENV_USLEEP is deprecated. Use udelay() instead.
204 *****************************************************************************/
206 #define XENV_USLEEP(delay) udelay(delay)
207 /* do_not_use_XENV_MEM_COPY_use_memcpy_instead */
210 /******************************************************************************
212 * CACHE handling macros / mappings
214 * The implementation of the cache handling functions can be found in
215 * arch/microblaze.
217 * These #defines are simple mappings to the Linux API.
219 * The underlying Linux implementation will take care of taking the right
220 * actions depending on the configuration of the MicroBlaze processor in the
221 * system.
223 ******************************************************************************/
225 #define XCACHE_ENABLE_DCACHE() __enable_dcache()
226 #define XCACHE_DISABLE_DCACHE() __disable_dcache()
227 #define XCACHE_ENABLE_ICACHE() __enable_icache()
228 #define XCACHE_DISABLE_ICACHE() __disable_icache()
230 #define XCACHE_INVALIDATE_DCACHE_RANGE(Addr, Len) \
231 invalidate_dcache_range((unsigned long)(Addr), ((unsigned long)(Addr)+(Len)))
232 #define XCACHE_FLUSH_DCACHE_RANGE(Addr, Len) \
233 flush_dcache_range((unsigned long)(Addr), ((unsigned long)(Addr)+(Len)))
235 #define XCACHE_INVALIDATE_ICACHE_RANGE(Addr, Len) "XCACHE_INVALIDATE_ICACHE_RANGE unsupported"
236 #define XCACHE_FLUSH_ICACHE_RANGE(Addr, Len) flush_icache_range(Addr, Len)
238 #define XCACHE_ENABLE_CACHE() \
239 { XCACHE_ENABLE_DCACHE(); XCACHE_ENABLE_ICACHE(); }
241 #define XCACHE_DISABLE_CACHE() \
242 { XCACHE_DISABLE_DCACHE(); XCACHE_DISABLE_ICACHE(); }
246 #ifdef __cplusplus
248 #endif
250 #endif /* end of protection macro */