blob: 7eed327d4a0b2de1deefc243ba6a7bf997c469c7 [file] [log] [blame]
wdenk507bbe32004-04-18 21:13:41 +00001/*
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 * 2002 (c) MontaVista, Software, Inc. This file is licensed under the terms
10 * of the GNU General Public License version 2. This program is licensed
11 * "as is" without any warranty of any kind, whether express or implied.
12 */
13
14#ifndef XIO_H
15#define XIO_H
16
17#include "xbasic_types.h"
18#include <asm/io.h>
19
20typedef u32 XIo_Address;
21
22extern inline u8
23XIo_In8(XIo_Address InAddress)
24{
25 return (u8) in_8((volatile unsigned char *) InAddress);
26}
27extern inline u16
28XIo_In16(XIo_Address InAddress)
29{
30 return (u16) in_be16((volatile unsigned short *) InAddress);
31}
32extern inline u32
33XIo_In32(XIo_Address InAddress)
34{
35 return (u32) in_be32((volatile unsigned *) InAddress);
36}
37extern inline void
38XIo_Out8(XIo_Address OutAddress, u8 Value)
39{
40 out_8((volatile unsigned char *) OutAddress, Value);
41}
42extern inline void
43XIo_Out16(XIo_Address OutAddress, u16 Value)
44{
45 out_be16((volatile unsigned short *) OutAddress, Value);
46}
47extern inline void
48XIo_Out32(XIo_Address OutAddress, u32 Value)
49{
50 out_be32((volatile unsigned *) OutAddress, Value);
51}
52
53#define XIo_ToLittleEndian16(s,d) (*(u16*)(d) = cpu_to_le16((u16)(s)))
54#define XIo_ToLittleEndian32(s,d) (*(u32*)(d) = cpu_to_le32((u32)(s)))
55#define XIo_ToBigEndian16(s,d) (*(u16*)(d) = cpu_to_be16((u16)(s)))
56#define XIo_ToBigEndian32(s,d) (*(u32*)(d) = cpu_to_be32((u32)(s)))
57
58#define XIo_FromLittleEndian16(s,d) (*(u16*)(d) = le16_to_cpu((u16)(s)))
59#define XIo_FromLittleEndian32(s,d) (*(u32*)(d) = le32_to_cpu((u32)(s)))
60#define XIo_FromBigEndian16(s,d) (*(u16*)(d) = be16_to_cpu((u16)(s)))
61#define XIo_FromBigEndian32(s,d) (*(u32*)(d) = be32_to_cpu((u32)(s)))
62
63#endif /* XIO_H */