make oldconfig will rebuild these...
[linux-2.4.21-pre4.git] / include / asm-mips64 / sibyte / 64bit.h
1 /*
2  * Copyright (C) 2000, 2001 Broadcom Corporation
3  * Copyright (C) 2002 Ralf Baechle
4  *
5  * This program is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU General Public License
7  * as published by the Free Software Foundation; either version 2
8  * of the License, or (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
18  */
19
20 #ifndef __ASM_SIBYTE_64BIT_H
21 #define __ASM_SIBYTE_64BIT_H
22
23 #include <linux/config.h>
24 #include <linux/types.h>
25
26 #ifdef CONFIG_MIPS32
27
28 #include <asm/system.h>
29
30 /*
31  * This is annoying...we can't actually write the 64-bit IO register properly
32  * without having access to 64-bit registers...  which doesn't work by default
33  * in o32 format...grrr...
34  */
35 static inline void out64(u64 val, unsigned long addr)
36 {
37         u32 low, high;
38         unsigned long flags;
39         high = val >> 32;
40         low = val & 0xffffffff;
41         // save_flags(flags);
42         __save_and_cli(flags);
43         __asm__ __volatile__ (
44                 ".set push\n"
45                 ".set noreorder\n"
46                 ".set noat\n"
47                 ".set mips4\n"
48                 "   dsll32 $2, %1, 0   \n"
49                 "   dsll32 $1, %0, 0   \n"
50                 "   dsrl32 $2, $2, 0   \n"
51                 "   or     $1, $1, $2  \n"
52                 "   sd $1, (%2)\n"
53                 ".set pop\n"
54                 ::"r" (high), "r" (low), "r" (addr)
55                 :"$1", "$2");
56         __restore_flags(flags);
57 }
58
59 static inline u64 in64(unsigned long addr)
60 {
61         u32 low, high;
62         unsigned long flags;
63         __save_and_cli(flags);
64         __asm__ __volatile__ (
65                 ".set push\n"
66                 ".set noreorder\n"
67                 ".set noat     \n"
68                 ".set mips4    \n"
69                 "  ld     %1, (%2)\n"
70                 "  dsra32 %0, %1, 0\n"
71                 "  sll    %1, %1, 0\n"
72                 ".set pop\n"
73                 :"=r" (high), "=r" (low): "r" (addr));
74         __restore_flags(flags);
75         return (((u64)high) << 32) | low;
76 }
77
78 #endif /* CONFIG_MIPS32 */
79
80 #ifdef CONFIG_MIPS64
81
82 /*
83  * These are provided so as to be able to use common
84  * driver code for the 32-bit and 64-bit trees
85  */
86 extern inline void out64(u64 val, unsigned long addr)
87 {
88         *(volatile unsigned long *)addr = val;
89 }
90
91 extern inline u64 in64(unsigned long addr)
92 {
93         return *(volatile unsigned long *)addr;
94 }
95
96 #endif /* CONFIG_MIPS64 */
97
98 /*
99  * Avoid interrupt mucking, just adjust the address for 4-byte access.
100  * Assume the addresses are 8-byte aligned.
101  */
102
103 #ifdef __MIPSEB__
104 #define __CSR_32_ADJUST 4
105 #else
106 #define __CSR_32_ADJUST 0
107 #endif
108
109 #define csr_out32(v,a) (*(u32 *)((unsigned long)(a) + __CSR_32_ADJUST) = (v))
110 #define csr_in32(a)    (*(u32 *)((unsigned long)(a) + __CSR_32_ADJUST))
111
112 #endif /* __ASM_SIBYTE_64BIT_H */