sb1250_defs.h revision 1.2.10.3 1 1.2.10.2 jdolecek /* *********************************************************************
2 1.2.10.2 jdolecek * SB1250 Board Support Package
3 1.2.10.3 jdolecek *
4 1.2.10.3 jdolecek * Global constants and macros File: sb1250_defs.h
5 1.2.10.3 jdolecek *
6 1.2.10.2 jdolecek * This file contains macros and definitions used by the other
7 1.2.10.2 jdolecek * include files.
8 1.2.10.2 jdolecek *
9 1.2.10.3 jdolecek * SB1250 specification level: User's manual 1/02/02
10 1.2.10.3 jdolecek *
11 1.2.10.3 jdolecek * Author: Mitch Lichtenberg (mpl (at) broadcom.com)
12 1.2.10.3 jdolecek *
13 1.2.10.3 jdolecek *********************************************************************
14 1.2.10.2 jdolecek *
15 1.2.10.2 jdolecek * Copyright 2000,2001
16 1.2.10.2 jdolecek * Broadcom Corporation. All rights reserved.
17 1.2.10.3 jdolecek *
18 1.2.10.3 jdolecek * This software is furnished under license and may be used and
19 1.2.10.3 jdolecek * copied only in accordance with the following terms and
20 1.2.10.3 jdolecek * conditions. Subject to these conditions, you may download,
21 1.2.10.3 jdolecek * copy, install, use, modify and distribute modified or unmodified
22 1.2.10.3 jdolecek * copies of this software in source and/or binary form. No title
23 1.2.10.2 jdolecek * or ownership is transferred hereby.
24 1.2.10.3 jdolecek *
25 1.2.10.3 jdolecek * 1) Any source code used, modified or distributed must reproduce
26 1.2.10.3 jdolecek * and retain this copyright notice and list of conditions as
27 1.2.10.2 jdolecek * they appear in the source file.
28 1.2.10.3 jdolecek *
29 1.2.10.3 jdolecek * 2) No right is granted to use any trade name, trademark, or
30 1.2.10.3 jdolecek * logo of Broadcom Corporation. Neither the "Broadcom
31 1.2.10.3 jdolecek * Corporation" name nor any trademark or logo of Broadcom
32 1.2.10.3 jdolecek * Corporation may be used to endorse or promote products
33 1.2.10.3 jdolecek * derived from this software without the prior written
34 1.2.10.2 jdolecek * permission of Broadcom Corporation.
35 1.2.10.3 jdolecek *
36 1.2.10.2 jdolecek * 3) THIS SOFTWARE IS PROVIDED "AS-IS" AND ANY EXPRESS OR
37 1.2.10.3 jdolecek * IMPLIED WARRANTIES, INCLUDING BUT NOT LIMITED TO, ANY IMPLIED
38 1.2.10.3 jdolecek * WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
39 1.2.10.3 jdolecek * PURPOSE, OR NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT
40 1.2.10.3 jdolecek * SHALL BROADCOM BE LIABLE FOR ANY DAMAGES WHATSOEVER, AND IN
41 1.2.10.3 jdolecek * PARTICULAR, BROADCOM SHALL NOT BE LIABLE FOR DIRECT, INDIRECT,
42 1.2.10.3 jdolecek * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
43 1.2.10.3 jdolecek * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
44 1.2.10.2 jdolecek * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
45 1.2.10.3 jdolecek * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
46 1.2.10.3 jdolecek * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
47 1.2.10.3 jdolecek * TORT (INCLUDING NEGLIGENCE OR OTHERWISE), EVEN IF ADVISED OF
48 1.2.10.2 jdolecek * THE POSSIBILITY OF SUCH DAMAGE.
49 1.2.10.2 jdolecek ********************************************************************* */
50 1.2.10.2 jdolecek
51 1.2.10.2 jdolecek
52 1.2.10.2 jdolecek /* *********************************************************************
53 1.2.10.2 jdolecek * Naming schemes for constants in these files:
54 1.2.10.3 jdolecek *
55 1.2.10.3 jdolecek * M_xxx MASK constant (identifies bits in a register).
56 1.2.10.3 jdolecek * For multi-bit fields, all bits in the field will
57 1.2.10.3 jdolecek * be set.
58 1.2.10.3 jdolecek *
59 1.2.10.3 jdolecek * K_xxx "Code" constant (value for data in a multi-bit
60 1.2.10.3 jdolecek * field). The value is right justified.
61 1.2.10.3 jdolecek *
62 1.2.10.3 jdolecek * V_xxx "Value" constant. This is the same as the
63 1.2.10.3 jdolecek * corresponding "K_xxx" constant, except it is
64 1.2.10.3 jdolecek * shifted to the correct position in the register.
65 1.2.10.3 jdolecek *
66 1.2.10.3 jdolecek * S_xxx SHIFT constant. This is the number of bits that
67 1.2.10.3 jdolecek * a field value (code) needs to be shifted
68 1.2.10.3 jdolecek * (towards the left) to put the value in the right
69 1.2.10.3 jdolecek * position for the register.
70 1.2.10.3 jdolecek *
71 1.2.10.3 jdolecek * A_xxx ADDRESS constant. This will be a physical
72 1.2.10.3 jdolecek * address. Use the PHYS_TO_K1 macro to generate
73 1.2.10.3 jdolecek * a K1SEG address.
74 1.2.10.3 jdolecek *
75 1.2.10.3 jdolecek * R_xxx RELATIVE offset constant. This is an offset from
76 1.2.10.3 jdolecek * an A_xxx constant (usually the first register in
77 1.2.10.3 jdolecek * a group).
78 1.2.10.3 jdolecek *
79 1.2.10.3 jdolecek * G_xxx(X) GET value. This macro obtains a multi-bit field
80 1.2.10.3 jdolecek * from a register, masks it, and shifts it to
81 1.2.10.3 jdolecek * the bottom of the register (retrieving a K_xxx
82 1.2.10.3 jdolecek * value, for example).
83 1.2.10.3 jdolecek *
84 1.2.10.3 jdolecek * V_xxx(X) VALUE. This macro computes the value of a
85 1.2.10.3 jdolecek * K_xxx constant shifted to the correct position
86 1.2.10.3 jdolecek * in the register.
87 1.2.10.2 jdolecek ********************************************************************* */
88 1.2.10.2 jdolecek
89 1.2.10.2 jdolecek
90 1.2.10.2 jdolecek
91 1.2.10.2 jdolecek
92 1.2.10.2 jdolecek #ifndef _SB1250_DEFS_H
93 1.2.10.3 jdolecek #define _SB1250_DEFS_H
94 1.2.10.2 jdolecek
95 1.2.10.2 jdolecek /*
96 1.2.10.3 jdolecek * Cast to 64-bit number. Presumably the syntax is different in
97 1.2.10.2 jdolecek * assembly language.
98 1.2.10.2 jdolecek *
99 1.2.10.2 jdolecek * Note: you'll need to define uint32_t and uint64_t in your headers.
100 1.2.10.2 jdolecek */
101 1.2.10.2 jdolecek
102 1.2.10.2 jdolecek #if !defined(__ASSEMBLER__)
103 1.2.10.3 jdolecek #define _SB_MAKE64(x) ((uint64_t)(x))
104 1.2.10.3 jdolecek #define _SB_MAKE32(x) ((uint32_t)(x))
105 1.2.10.2 jdolecek #else
106 1.2.10.3 jdolecek #define _SB_MAKE64(x) (x)
107 1.2.10.3 jdolecek #define _SB_MAKE32(x) (x)
108 1.2.10.2 jdolecek #endif
109 1.2.10.2 jdolecek
110 1.2.10.2 jdolecek
111 1.2.10.2 jdolecek /*
112 1.2.10.2 jdolecek * Make a mask for 1 bit at position 'n'
113 1.2.10.2 jdolecek */
114 1.2.10.2 jdolecek
115 1.2.10.3 jdolecek #define _SB_MAKEMASK1(n) (_SB_MAKE64(1) << _SB_MAKE64(n))
116 1.2.10.3 jdolecek #define _SB_MAKEMASK1_32(n) (_SB_MAKE32(1) << _SB_MAKE32(n))
117 1.2.10.2 jdolecek
118 1.2.10.2 jdolecek /*
119 1.2.10.2 jdolecek * Make a mask for 'v' bits at position 'n'
120 1.2.10.2 jdolecek */
121 1.2.10.2 jdolecek
122 1.2.10.3 jdolecek #define _SB_MAKEMASK(v,n) (_SB_MAKE64((_SB_MAKE64(1)<<(v))-1) << _SB_MAKE64(n))
123 1.2.10.3 jdolecek #define _SB_MAKEMASK_32(v,n) (_SB_MAKE32((_SB_MAKE32(1)<<(v))-1) << _SB_MAKE32(n))
124 1.2.10.2 jdolecek
125 1.2.10.2 jdolecek /*
126 1.2.10.2 jdolecek * Make a value at 'v' at bit position 'n'
127 1.2.10.2 jdolecek */
128 1.2.10.2 jdolecek
129 1.2.10.3 jdolecek #define _SB_MAKEVALUE(v,n) (_SB_MAKE64(v) << _SB_MAKE64(n))
130 1.2.10.3 jdolecek #define _SB_MAKEVALUE_32(v,n) (_SB_MAKE32(v) << _SB_MAKE32(n))
131 1.2.10.2 jdolecek
132 1.2.10.3 jdolecek #define _SB_GETVALUE(v,n,m) ((_SB_MAKE64(v) & _SB_MAKE64(m)) >> _SB_MAKE64(n))
133 1.2.10.3 jdolecek #define _SB_GETVALUE_32(v,n,m) ((_SB_MAKE32(v) & _SB_MAKE32(m)) >> _SB_MAKE32(n))
134 1.2.10.2 jdolecek
135 1.2.10.2 jdolecek /*
136 1.2.10.2 jdolecek * Macros to read/write on-chip registers
137 1.2.10.3 jdolecek * XXX should we do the PHYS_TO_K1 here?
138 1.2.10.2 jdolecek */
139 1.2.10.2 jdolecek
140 1.2.10.2 jdolecek
141 1.2.10.2 jdolecek #if !defined(__ASSEMBLER__)
142 1.2.10.3 jdolecek #define SBWRITECSR(csr,val) *((volatile uint64_t *) MIPS_PHYS_TO_KSEG1(csr)) = (val)
143 1.2.10.3 jdolecek #define SBREADCSR(csr) (*((volatile uint64_t *) MIPS_PHYS_TO_KSEG1(csr)))
144 1.2.10.2 jdolecek #endif /* __ASSEMBLER__ */
145 1.2.10.2 jdolecek
146 1.2.10.2 jdolecek #endif
147