]> git.kernelconcepts.de Git - karo-tx-uboot.git/blob - board/xilinx/common/xio.h
* Patch by Peter Ryser, 20 Feb 2004:
[karo-tx-uboot.git] / board / xilinx / common / xio.h
1 /*
2  * xio.h
3  *
4  * Defines XIo functions for Xilinx OCP in terms of Linux primitives
5  *
6  * Author: MontaVista Software, Inc.
7  *         source@mvista.com
8  *
9  * Copyright 2002 MontaVista Software Inc.
10  *
11  *  This program is free software; you can redistribute it and/or modify it
12  *  under the terms of the GNU General Public License as published by the
13  *  Free Software Foundation; either version 2 of the License, or (at your
14  *  option) any later version.
15  *
16  *  THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
17  *  WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
18  *  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
19  *  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
20  *  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
21  *  BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
22  *  OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23  *  ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
24  *  TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
25  *  USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26  *
27  *  You should have received a copy of the GNU General Public License along
28  *  with this program; if not, write to the Free Software Foundation, Inc.,
29  *  675 Mass Ave, Cambridge, MA 02139, USA.
30  */
31
32 #ifndef XIO_H
33 #define XIO_H
34
35 #include "xbasic_types.h"
36 #include <asm/io.h>
37
38 typedef u32 XIo_Address;
39
40 extern inline u8
41 XIo_In8(XIo_Address InAddress)
42 {
43         return (u8) in_8((volatile unsigned char *) InAddress);
44 }
45 extern inline u16
46 XIo_In16(XIo_Address InAddress)
47 {
48         return (u16) in_be16((volatile unsigned short *) InAddress);
49 }
50 extern inline u32
51 XIo_In32(XIo_Address InAddress)
52 {
53         return (u32) in_be32((volatile unsigned *) InAddress);
54 }
55 extern inline void
56 XIo_Out8(XIo_Address OutAddress, u8 Value)
57 {
58         out_8((volatile unsigned char *) OutAddress, Value);
59 }
60 extern inline void
61 XIo_Out16(XIo_Address OutAddress, u16 Value)
62 {
63         out_be16((volatile unsigned short *) OutAddress, Value);
64 }
65 extern inline void
66 XIo_Out32(XIo_Address OutAddress, u32 Value)
67 {
68         out_be32((volatile unsigned *) OutAddress, Value);
69 }
70
71 #define XIo_ToLittleEndian16(s,d) (*(u16*)(d) = cpu_to_le16((u16)(s)))
72 #define XIo_ToLittleEndian32(s,d) (*(u32*)(d) = cpu_to_le32((u32)(s)))
73 #define XIo_ToBigEndian16(s,d) (*(u16*)(d) = cpu_to_be16((u16)(s)))
74 #define XIo_ToBigEndian32(s,d) (*(u32*)(d) = cpu_to_be32((u32)(s)))
75
76 #define XIo_FromLittleEndian16(s,d) (*(u16*)(d) = le16_to_cpu((u16)(s)))
77 #define XIo_FromLittleEndian32(s,d) (*(u32*)(d) = le32_to_cpu((u32)(s)))
78 #define XIo_FromBigEndian16(s,d) (*(u16*)(d) = be16_to_cpu((u16)(s)))
79 #define XIo_FromBigEndian32(s,d) (*(u32*)(d) = be32_to_cpu((u32)(s)))
80
81 #endif                          /* XIO_H */