more changes on original files
[linux-2.4.git] / include / asm-mips / mv64340_dep.h
1 /*
2  * Copyright 2002 Momentum Computer Inc.
3  * Author: Matthew Dharm <mdharm@momenco.com>
4  *
5  * include/asm-mips/mv64340-dep.h
6  *     Board-dependent definitions for MV-64340 chip.
7  *
8  * This program is free software; you can redistribute  it and/or modify it
9  * under  the terms of  the GNU General  Public License as published by the
10  * Free Software Foundation;  either version 2 of the  License, or (at your
11  * option) any later version.
12  */
13
14 #ifndef __MV64340_DEP_H__
15 #define __MV64340_DEP_H__
16
17 #include <asm/addrspace.h>              /* for KSEG1ADDR() */
18 #include <asm/byteorder.h>              /* for cpu_to_le32() */
19
20 extern unsigned long mv64340_base;
21
22 #define MV64340_BASE       (mv64340_base)
23
24 /*
25  * Because of an error/peculiarity in the Galileo chip, we need to swap the
26  * bytes when running bigendian.
27  */
28
29 #define MV_WRITE(ofs, data)  \
30         *(volatile u32 *)(MV64340_BASE+(ofs)) = cpu_to_le32(data)
31 #define MV_READ(ofs, data)   \
32         *(data) = le32_to_cpu(*(volatile u32 *)(MV64340_BASE+(ofs)))
33 #define MV_READ_DATA(ofs)    \
34         le32_to_cpu(*(volatile u32 *)(MV64340_BASE+(ofs)))
35
36 #define MV_WRITE_16(ofs, data)  \
37         *(volatile u16 *)(MV64340_BASE+(ofs)) = cpu_to_le16(data)
38 #define MV_READ_16(ofs, data)   \
39         *(data) = le16_to_cpu(*(volatile u16 *)(MV64340_BASE+(ofs)))
40
41 #define MV_WRITE_8(ofs, data)  \
42         *(volatile u8 *)(MV64340_BASE+(ofs)) = data
43 #define MV_READ_8(ofs, data)   \
44         *(data) = *(volatile u8 *)(MV64340_BASE+(ofs))
45
46 #define MV_SET_REG_BITS(ofs,bits) \
47         (*((volatile u32 *)(MV64340_BASE+(ofs)))) |= ((u32)cpu_to_le32(bits))
48 #define MV_RESET_REG_BITS(ofs,bits) \
49         (*((volatile u32 *)(MV64340_BASE+(ofs)))) &= ~((u32)cpu_to_le32(bits))
50
51 #endif