make oldconfig will rebuild these...
[linux-2.4.21-pre4.git] / include / asm-mips64 / sibyte / sb1250_defs.h
1 /*  *********************************************************************
2     *  SB1250 Board Support Package
3     *
4     *  Global constants and macros              File: sb1250_defs.h
5     *
6     *  This file contains macros and definitions used by the other
7     *  include files.
8     *
9     *  SB1250 specification level:  User's manual 1/02/02
10     *
11     *  Author:  Mitch Lichtenberg (mpl@broadcom.com)
12     *
13     *********************************************************************
14     *
15     *  Copyright 2000,2001
16     *  Broadcom Corporation. All rights reserved.
17     *
18     *  This program is free software; you can redistribute it and/or
19     *  modify it under the terms of the GNU General Public License as
20     *  published by the Free Software Foundation; either version 2 of
21     *  the License, or (at your option) any later version.
22     *
23     *  This program is distributed in the hope that it will be useful,
24     *  but WITHOUT ANY WARRANTY; without even the implied warranty of
25     *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
26     *  GNU General Public License for more details.
27     *
28     *  You should have received a copy of the GNU General Public License
29     *  along with this program; if not, write to the Free Software
30     *  Foundation, Inc., 59 Temple Place, Suite 330, Boston,
31     *  MA 02111-1307 USA
32     ********************************************************************* */
33
34
35 /*  *********************************************************************
36     *  Naming schemes for constants in these files:
37     *
38     *  M_xxx           MASK constant (identifies bits in a register).
39     *                  For multi-bit fields, all bits in the field will
40     *                  be set.
41     *
42     *  K_xxx           "Code" constant (value for data in a multi-bit
43     *                  field).  The value is right justified.
44     *
45     *  V_xxx           "Value" constant.  This is the same as the
46     *                  corresponding "K_xxx" constant, except it is
47     *                  shifted to the correct position in the register.
48     *
49     *  S_xxx           SHIFT constant.  This is the number of bits that
50     *                  a field value (code) needs to be shifted
51     *                  (towards the left) to put the value in the right
52     *                  position for the register.
53     *
54     *  A_xxx           ADDRESS constant.  This will be a physical
55     *                  address.  Use the PHYS_TO_K1 macro to generate
56     *                  a K1SEG address.
57     *
58     *  R_xxx           RELATIVE offset constant.  This is an offset from
59     *                  an A_xxx constant (usually the first register in
60     *                  a group).
61     *
62     *  G_xxx(X)        GET value.  This macro obtains a multi-bit field
63     *                  from a register, masks it, and shifts it to
64     *                  the bottom of the register (retrieving a K_xxx
65     *                  value, for example).
66     *
67     *  V_xxx(X)        VALUE.  This macro computes the value of a
68     *                  K_xxx constant shifted to the correct position
69     *                  in the register.
70     ********************************************************************* */
71
72
73
74
75 #ifndef _SB1250_DEFS_H
76 #define _SB1250_DEFS_H
77
78 /*
79  * Cast to 64-bit number.  Presumably the syntax is different in
80  * assembly language.
81  *
82  * Note: you'll need to define uint32_t and uint64_t in your headers.
83  */
84
85 #if !defined(__ASSEMBLY__)
86 #define _SB_MAKE64(x) ((uint64_t)(x))
87 #define _SB_MAKE32(x) ((uint32_t)(x))
88 #else
89 #define _SB_MAKE64(x) (x)
90 #define _SB_MAKE32(x) (x)
91 #endif
92
93
94 /*
95  * Make a mask for 1 bit at position 'n'
96  */
97
98 #define _SB_MAKEMASK1(n) (_SB_MAKE64(1) << _SB_MAKE64(n))
99 #define _SB_MAKEMASK1_32(n) (_SB_MAKE32(1) << _SB_MAKE32(n))
100
101 /*
102  * Make a mask for 'v' bits at position 'n'
103  */
104
105 #define _SB_MAKEMASK(v,n) (_SB_MAKE64((_SB_MAKE64(1)<<(v))-1) << _SB_MAKE64(n))
106 #define _SB_MAKEMASK_32(v,n) (_SB_MAKE32((_SB_MAKE32(1)<<(v))-1) << _SB_MAKE32(n))
107
108 /*
109  * Make a value at 'v' at bit position 'n'
110  */
111
112 #define _SB_MAKEVALUE(v,n) (_SB_MAKE64(v) << _SB_MAKE64(n))
113 #define _SB_MAKEVALUE_32(v,n) (_SB_MAKE32(v) << _SB_MAKE32(n))
114
115 #define _SB_GETVALUE(v,n,m) ((_SB_MAKE64(v) & _SB_MAKE64(m)) >> _SB_MAKE64(n))
116 #define _SB_GETVALUE_32(v,n,m) ((_SB_MAKE32(v) & _SB_MAKE32(m)) >> _SB_MAKE32(n))
117
118 /*
119  * Macros to read/write on-chip registers
120  * XXX should we do the PHYS_TO_K1 here?
121  */
122
123
124 #if !defined(__ASSEMBLY__)
125 #define SBWRITECSR(csr,val) *((volatile uint64_t *) PHYS_TO_K1(csr)) = (val)
126 #define SBREADCSR(csr) (*((volatile uint64_t *) PHYS_TO_K1(csr)))
127 #endif /* __ASSEMBLY__ */
128
129 #endif