Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1)

Side by Side Diff: arch/arm/mach-tegra/nv/include/nvrm_drf.h

Issue 3256004: [ARM] tegra: add nvos/nvrm/nvmap drivers (Closed) Base URL: ssh://git@gitrw.chromium.org/kernel.git
Patch Set: remove ap15 headers Created 10 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « arch/arm/mach-tegra/nv/include/nvrm_dma.h ('k') | arch/arm/mach-tegra/nv/include/nvrm_gpio.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 /*
2 * Copyright (c) 2007-2009 NVIDIA Corporation.
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 *
8 * Redistributions of source code must retain the above copyright notice,
9 * this list of conditions and the following disclaimer.
10 *
11 * Redistributions in binary form must reproduce the above copyright notice,
12 * this list of conditions and the following disclaimer in the documentation
13 * and/or other materials provided with the distribution.
14 *
15 * Neither the name of the NVIDIA Corporation nor the names of its contributors
16 * may be used to endorse or promote products derived from this software
17 * without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
23 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 * POSSIBILITY OF SUCH DAMAGE.
30 *
31 */
32
33 #ifndef INCLUDED_NVRM_DRF_H
34 #define INCLUDED_NVRM_DRF_H
35
36 /**
37 * @defgroup nvrm_drf RM DRF Macros
38 *
39 * @ingroup nvddk_rm
40 *
41 * The following suite of macros are used for generating values to write into
42 * hardware registers, or for extracting fields from read registers. The
43 * hardware headers have a RANGE define for each field in the register in the
44 * form of x:y, 'x' being the high bit, 'y' the lower. Through a clever use
45 * of the C ternary operator, x:y may be passed into the macros below to
46 * geneate masks, shift values, etc.
47 *
48 * There are two basic flavors of DRF macros, the first is used to define
49 * a new register value from 0, the other is modifiying a field given a
50 * register value. An example of the first:
51 *
52 * reg = NV_DRF_DEF( HW, REGISTER0, FIELD0, VALUE0 )
53 * | NV_DRF_DEF( HW, REGISTER0, FIELD3, VALUE2 );
54 *
55 * To modify 'reg' from the previous example:
56 *
57 * reg = NV_FLD_SET_DRF_DEF( HW, REGISTER0, FIELD2, VALUE1, reg );
58 *
59 * To pass in numeric values instead of defined values from the header:
60 *
61 * reg = NV_DRF_NUM( HW, REGISTER3, FIELD2, 1024 );
62 *
63 * To read a value from a register:
64 *
65 * val = NV_DRF_VAL( HW, REGISTER3, FIELD2, reg );
66 *
67 * Some registers have non-zero reset values which may be extracted from the
68 * hardware headers via NV_RESETVAL.
69 */
70
71 /*
72 * The NV_FIELD_* macros are helper macros for the public NV_DRF_* macros.
73 */
74 #define NV_FIELD_LOWBIT(x) (0?x)
75 #define NV_FIELD_HIGHBIT(x) (1?x)
76 #define NV_FIELD_SIZE(x) (NV_FIELD_HIGHBIT(x)-NV_FIELD_LOWBIT(x)+1)
77 #define NV_FIELD_SHIFT(x) ((0?x)%32)
78 #define NV_FIELD_MASK(x) (0xFFFFFFFFUL>>(31-((1?x)%32)+((0?x)%32)))
79 #define NV_FIELD_BITS(val, x) (((val) & NV_FIELD_MASK(x))<<NV_FIELD_SHIFT(x))
80 #define NV_FIELD_SHIFTMASK(x) (NV_FIELD_MASK(x)<< (NV_FIELD_SHIFT(x)))
81
82 /** NV_DRF_DEF - define a new register value.
83
84 @ingroup nvrm_drf
85
86 @param d register domain (hardware block)
87 @param r register name
88 @param f register field
89 @param c defined value for the field
90 */
91 #define NV_DRF_DEF(d,r,f,c) \
92 ((d##_##r##_0_##f##_##c) << NV_FIELD_SHIFT(d##_##r##_0_##f##_RANGE))
93
94 /** NV_DRF_NUM - define a new register value.
95
96 @ingroup nvrm_drf
97
98 @param d register domain (hardware block)
99 @param r register name
100 @param f register field
101 @param n numeric value for the field
102 */
103 #define NV_DRF_NUM(d,r,f,n) \
104 (((n)& NV_FIELD_MASK(d##_##r##_0_##f##_RANGE)) << \
105 NV_FIELD_SHIFT(d##_##r##_0_##f##_RANGE))
106
107 /** NV_DRF_VAL - read a field from a register.
108
109 @ingroup nvrm_drf
110
111 @param d register domain (hardware block)
112 @param r register name
113 @param f register field
114 @param v register value
115 */
116 #define NV_DRF_VAL(d,r,f,v) \
117 (((v)>> NV_FIELD_SHIFT(d##_##r##_0_##f##_RANGE)) & \
118 NV_FIELD_MASK(d##_##r##_0_##f##_RANGE))
119
120 /** NV_FLD_SET_DRF_NUM - modify a register field.
121
122 @ingroup nvrm_drf
123
124 @param d register domain (hardware block)
125 @param r register name
126 @param f register field
127 @param n numeric field value
128 @param v register value
129 */
130 #define NV_FLD_SET_DRF_NUM(d,r,f,n,v) \
131 ((v & ~NV_FIELD_SHIFTMASK(d##_##r##_0_##f##_RANGE)) | NV_DRF_NUM(d,r,f,n))
132
133 /** NV_FLD_SET_DRF_DEF - modify a register field.
134
135 @ingroup nvrm_drf
136
137 @param d register domain (hardware block)
138 @param r register name
139 @param f register field
140 @param c defined field value
141 @param v register value
142 */
143 #define NV_FLD_SET_DRF_DEF(d,r,f,c,v) \
144 (((v) & ~NV_FIELD_SHIFTMASK(d##_##r##_0_##f##_RANGE)) | \
145 NV_DRF_DEF(d,r,f,c))
146
147 /** NV_RESETVAL - get the reset value for a register.
148
149 @ingroup nvrm_drf
150
151 @param d register domain (hardware block)
152 @param r register name
153 */
154 #define NV_RESETVAL(d,r) (d##_##r##_0_RESET_VAL)
155
156 #endif // INCLUDED_NVRM_DRF_H
OLDNEW
« no previous file with comments | « arch/arm/mach-tegra/nv/include/nvrm_dma.h ('k') | arch/arm/mach-tegra/nv/include/nvrm_gpio.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698