xref: /linux/drivers/gpu/host1x/hw/hw_host1x04_uclass.h (revision 762f99f4f3cb41a775b5157dd761217beba65873)
19952f691SThomas Gleixner /* SPDX-License-Identifier: GPL-2.0-only */
2e6fff4aaSThierry Reding /*
3e6fff4aaSThierry Reding  * Copyright (c) 2013 NVIDIA Corporation.
4e6fff4aaSThierry Reding  */
5e6fff4aaSThierry Reding 
6e6fff4aaSThierry Reding  /*
7e6fff4aaSThierry Reding   * Function naming determines intended use:
8e6fff4aaSThierry Reding   *
9e6fff4aaSThierry Reding   *     <x>_r(void) : Returns the offset for register <x>.
10e6fff4aaSThierry Reding   *
11e6fff4aaSThierry Reding   *     <x>_w(void) : Returns the word offset for word (4 byte) element <x>.
12e6fff4aaSThierry Reding   *
13e6fff4aaSThierry Reding   *     <x>_<y>_s(void) : Returns size of field <y> of register <x> in bits.
14e6fff4aaSThierry Reding   *
15e6fff4aaSThierry Reding   *     <x>_<y>_f(u32 v) : Returns a value based on 'v' which has been shifted
16e6fff4aaSThierry Reding   *         and masked to place it at field <y> of register <x>.  This value
17e6fff4aaSThierry Reding   *         can be |'d with others to produce a full register value for
18e6fff4aaSThierry Reding   *         register <x>.
19e6fff4aaSThierry Reding   *
20e6fff4aaSThierry Reding   *     <x>_<y>_m(void) : Returns a mask for field <y> of register <x>.  This
21e6fff4aaSThierry Reding   *         value can be ~'d and then &'d to clear the value of field <y> for
22e6fff4aaSThierry Reding   *         register <x>.
23e6fff4aaSThierry Reding   *
24e6fff4aaSThierry Reding   *     <x>_<y>_<z>_f(void) : Returns the constant value <z> after being shifted
25e6fff4aaSThierry Reding   *         to place it at field <y> of register <x>.  This value can be |'d
26e6fff4aaSThierry Reding   *         with others to produce a full register value for <x>.
27e6fff4aaSThierry Reding   *
28e6fff4aaSThierry Reding   *     <x>_<y>_v(u32 r) : Returns the value of field <y> from a full register
29e6fff4aaSThierry Reding   *         <x> value 'r' after being shifted to place its LSB at bit 0.
30e6fff4aaSThierry Reding   *         This value is suitable for direct comparison with other unshifted
31e6fff4aaSThierry Reding   *         values appropriate for use in field <y> of register <x>.
32e6fff4aaSThierry Reding   *
33e6fff4aaSThierry Reding   *     <x>_<y>_<z>_v(void) : Returns the constant value for <z> defined for
34e6fff4aaSThierry Reding   *         field <y> of register <x>.  This value is suitable for direct
35e6fff4aaSThierry Reding   *         comparison with unshifted values appropriate for use in field <y>
36e6fff4aaSThierry Reding   *         of register <x>.
37e6fff4aaSThierry Reding   */
38e6fff4aaSThierry Reding 
39e6fff4aaSThierry Reding #ifndef HOST1X_HW_HOST1X04_UCLASS_H
40e6fff4aaSThierry Reding #define HOST1X_HW_HOST1X04_UCLASS_H
41e6fff4aaSThierry Reding 
host1x_uclass_incr_syncpt_r(void)42e6fff4aaSThierry Reding static inline u32 host1x_uclass_incr_syncpt_r(void)
43e6fff4aaSThierry Reding {
44e6fff4aaSThierry Reding 	return 0x0;
45e6fff4aaSThierry Reding }
46e6fff4aaSThierry Reding #define HOST1X_UCLASS_INCR_SYNCPT \
47e6fff4aaSThierry Reding 	host1x_uclass_incr_syncpt_r()
host1x_uclass_incr_syncpt_cond_f(u32 v)48e6fff4aaSThierry Reding static inline u32 host1x_uclass_incr_syncpt_cond_f(u32 v)
49e6fff4aaSThierry Reding {
50e6fff4aaSThierry Reding 	return (v & 0xff) << 8;
51e6fff4aaSThierry Reding }
52e6fff4aaSThierry Reding #define HOST1X_UCLASS_INCR_SYNCPT_COND_F(v) \
53e6fff4aaSThierry Reding 	host1x_uclass_incr_syncpt_cond_f(v)
host1x_uclass_incr_syncpt_indx_f(u32 v)54e6fff4aaSThierry Reding static inline u32 host1x_uclass_incr_syncpt_indx_f(u32 v)
55e6fff4aaSThierry Reding {
56e6fff4aaSThierry Reding 	return (v & 0xff) << 0;
57e6fff4aaSThierry Reding }
58e6fff4aaSThierry Reding #define HOST1X_UCLASS_INCR_SYNCPT_INDX_F(v) \
59e6fff4aaSThierry Reding 	host1x_uclass_incr_syncpt_indx_f(v)
host1x_uclass_wait_syncpt_r(void)60e6fff4aaSThierry Reding static inline u32 host1x_uclass_wait_syncpt_r(void)
61e6fff4aaSThierry Reding {
62e6fff4aaSThierry Reding 	return 0x8;
63e6fff4aaSThierry Reding }
64e6fff4aaSThierry Reding #define HOST1X_UCLASS_WAIT_SYNCPT \
65e6fff4aaSThierry Reding 	host1x_uclass_wait_syncpt_r()
host1x_uclass_wait_syncpt_indx_f(u32 v)66e6fff4aaSThierry Reding static inline u32 host1x_uclass_wait_syncpt_indx_f(u32 v)
67e6fff4aaSThierry Reding {
68e6fff4aaSThierry Reding 	return (v & 0xff) << 24;
69e6fff4aaSThierry Reding }
70e6fff4aaSThierry Reding #define HOST1X_UCLASS_WAIT_SYNCPT_INDX_F(v) \
71e6fff4aaSThierry Reding 	host1x_uclass_wait_syncpt_indx_f(v)
host1x_uclass_wait_syncpt_thresh_f(u32 v)72e6fff4aaSThierry Reding static inline u32 host1x_uclass_wait_syncpt_thresh_f(u32 v)
73e6fff4aaSThierry Reding {
74e6fff4aaSThierry Reding 	return (v & 0xffffff) << 0;
75e6fff4aaSThierry Reding }
76e6fff4aaSThierry Reding #define HOST1X_UCLASS_WAIT_SYNCPT_THRESH_F(v) \
77e6fff4aaSThierry Reding 	host1x_uclass_wait_syncpt_thresh_f(v)
host1x_uclass_wait_syncpt_base_r(void)78e6fff4aaSThierry Reding static inline u32 host1x_uclass_wait_syncpt_base_r(void)
79e6fff4aaSThierry Reding {
80e6fff4aaSThierry Reding 	return 0x9;
81e6fff4aaSThierry Reding }
82e6fff4aaSThierry Reding #define HOST1X_UCLASS_WAIT_SYNCPT_BASE \
83e6fff4aaSThierry Reding 	host1x_uclass_wait_syncpt_base_r()
host1x_uclass_wait_syncpt_base_indx_f(u32 v)84e6fff4aaSThierry Reding static inline u32 host1x_uclass_wait_syncpt_base_indx_f(u32 v)
85e6fff4aaSThierry Reding {
86e6fff4aaSThierry Reding 	return (v & 0xff) << 24;
87e6fff4aaSThierry Reding }
88e6fff4aaSThierry Reding #define HOST1X_UCLASS_WAIT_SYNCPT_BASE_INDX_F(v) \
89e6fff4aaSThierry Reding 	host1x_uclass_wait_syncpt_base_indx_f(v)
host1x_uclass_wait_syncpt_base_base_indx_f(u32 v)90e6fff4aaSThierry Reding static inline u32 host1x_uclass_wait_syncpt_base_base_indx_f(u32 v)
91e6fff4aaSThierry Reding {
92e6fff4aaSThierry Reding 	return (v & 0xff) << 16;
93e6fff4aaSThierry Reding }
94e6fff4aaSThierry Reding #define HOST1X_UCLASS_WAIT_SYNCPT_BASE_BASE_INDX_F(v) \
95e6fff4aaSThierry Reding 	host1x_uclass_wait_syncpt_base_base_indx_f(v)
host1x_uclass_wait_syncpt_base_offset_f(u32 v)96e6fff4aaSThierry Reding static inline u32 host1x_uclass_wait_syncpt_base_offset_f(u32 v)
97e6fff4aaSThierry Reding {
98e6fff4aaSThierry Reding 	return (v & 0xffff) << 0;
99e6fff4aaSThierry Reding }
100e6fff4aaSThierry Reding #define HOST1X_UCLASS_WAIT_SYNCPT_BASE_OFFSET_F(v) \
101e6fff4aaSThierry Reding 	host1x_uclass_wait_syncpt_base_offset_f(v)
host1x_uclass_load_syncpt_base_r(void)102e6fff4aaSThierry Reding static inline u32 host1x_uclass_load_syncpt_base_r(void)
103e6fff4aaSThierry Reding {
104e6fff4aaSThierry Reding 	return 0xb;
105e6fff4aaSThierry Reding }
106e6fff4aaSThierry Reding #define HOST1X_UCLASS_LOAD_SYNCPT_BASE \
107e6fff4aaSThierry Reding 	host1x_uclass_load_syncpt_base_r()
host1x_uclass_load_syncpt_base_base_indx_f(u32 v)108e6fff4aaSThierry Reding static inline u32 host1x_uclass_load_syncpt_base_base_indx_f(u32 v)
109e6fff4aaSThierry Reding {
110e6fff4aaSThierry Reding 	return (v & 0xff) << 24;
111e6fff4aaSThierry Reding }
112e6fff4aaSThierry Reding #define HOST1X_UCLASS_LOAD_SYNCPT_BASE_BASE_INDX_F(v) \
113e6fff4aaSThierry Reding 	host1x_uclass_load_syncpt_base_base_indx_f(v)
host1x_uclass_load_syncpt_base_value_f(u32 v)114e6fff4aaSThierry Reding static inline u32 host1x_uclass_load_syncpt_base_value_f(u32 v)
115e6fff4aaSThierry Reding {
116e6fff4aaSThierry Reding 	return (v & 0xffffff) << 0;
117e6fff4aaSThierry Reding }
118e6fff4aaSThierry Reding #define HOST1X_UCLASS_LOAD_SYNCPT_BASE_VALUE_F(v) \
119e6fff4aaSThierry Reding 	host1x_uclass_load_syncpt_base_value_f(v)
host1x_uclass_incr_syncpt_base_base_indx_f(u32 v)120e6fff4aaSThierry Reding static inline u32 host1x_uclass_incr_syncpt_base_base_indx_f(u32 v)
121e6fff4aaSThierry Reding {
122e6fff4aaSThierry Reding 	return (v & 0xff) << 24;
123e6fff4aaSThierry Reding }
124e6fff4aaSThierry Reding #define HOST1X_UCLASS_INCR_SYNCPT_BASE_BASE_INDX_F(v) \
125e6fff4aaSThierry Reding 	host1x_uclass_incr_syncpt_base_base_indx_f(v)
host1x_uclass_incr_syncpt_base_offset_f(u32 v)126e6fff4aaSThierry Reding static inline u32 host1x_uclass_incr_syncpt_base_offset_f(u32 v)
127e6fff4aaSThierry Reding {
128e6fff4aaSThierry Reding 	return (v & 0xffffff) << 0;
129e6fff4aaSThierry Reding }
130e6fff4aaSThierry Reding #define HOST1X_UCLASS_INCR_SYNCPT_BASE_OFFSET_F(v) \
131e6fff4aaSThierry Reding 	host1x_uclass_incr_syncpt_base_offset_f(v)
host1x_uclass_indoff_r(void)132e6fff4aaSThierry Reding static inline u32 host1x_uclass_indoff_r(void)
133e6fff4aaSThierry Reding {
134e6fff4aaSThierry Reding 	return 0x2d;
135e6fff4aaSThierry Reding }
136e6fff4aaSThierry Reding #define HOST1X_UCLASS_INDOFF \
137e6fff4aaSThierry Reding 	host1x_uclass_indoff_r()
host1x_uclass_indoff_indbe_f(u32 v)138e6fff4aaSThierry Reding static inline u32 host1x_uclass_indoff_indbe_f(u32 v)
139e6fff4aaSThierry Reding {
140e6fff4aaSThierry Reding 	return (v & 0xf) << 28;
141e6fff4aaSThierry Reding }
142e6fff4aaSThierry Reding #define HOST1X_UCLASS_INDOFF_INDBE_F(v) \
143e6fff4aaSThierry Reding 	host1x_uclass_indoff_indbe_f(v)
host1x_uclass_indoff_autoinc_f(u32 v)144e6fff4aaSThierry Reding static inline u32 host1x_uclass_indoff_autoinc_f(u32 v)
145e6fff4aaSThierry Reding {
146e6fff4aaSThierry Reding 	return (v & 0x1) << 27;
147e6fff4aaSThierry Reding }
148e6fff4aaSThierry Reding #define HOST1X_UCLASS_INDOFF_AUTOINC_F(v) \
149e6fff4aaSThierry Reding 	host1x_uclass_indoff_autoinc_f(v)
host1x_uclass_indoff_indmodid_f(u32 v)150e6fff4aaSThierry Reding static inline u32 host1x_uclass_indoff_indmodid_f(u32 v)
151e6fff4aaSThierry Reding {
152e6fff4aaSThierry Reding 	return (v & 0xff) << 18;
153e6fff4aaSThierry Reding }
154e6fff4aaSThierry Reding #define HOST1X_UCLASS_INDOFF_INDMODID_F(v) \
155e6fff4aaSThierry Reding 	host1x_uclass_indoff_indmodid_f(v)
host1x_uclass_indoff_indroffset_f(u32 v)156e6fff4aaSThierry Reding static inline u32 host1x_uclass_indoff_indroffset_f(u32 v)
157e6fff4aaSThierry Reding {
158e6fff4aaSThierry Reding 	return (v & 0xffff) << 2;
159e6fff4aaSThierry Reding }
160e6fff4aaSThierry Reding #define HOST1X_UCLASS_INDOFF_INDROFFSET_F(v) \
161e6fff4aaSThierry Reding 	host1x_uclass_indoff_indroffset_f(v)
host1x_uclass_indoff_rwn_read_v(void)162e6fff4aaSThierry Reding static inline u32 host1x_uclass_indoff_rwn_read_v(void)
163e6fff4aaSThierry Reding {
164e6fff4aaSThierry Reding 	return 1;
165e6fff4aaSThierry Reding }
166e6fff4aaSThierry Reding #define HOST1X_UCLASS_INDOFF_INDROFFSET_F(v) \
167e6fff4aaSThierry Reding 	host1x_uclass_indoff_indroffset_f(v)
host1x_uclass_load_syncpt_payload_32_r(void)168*e902585fSMikko Perttunen static inline u32 host1x_uclass_load_syncpt_payload_32_r(void)
169*e902585fSMikko Perttunen {
170*e902585fSMikko Perttunen 	return 0x4e;
171*e902585fSMikko Perttunen }
172*e902585fSMikko Perttunen #define HOST1X_UCLASS_LOAD_SYNCPT_PAYLOAD_32 \
173*e902585fSMikko Perttunen 	host1x_uclass_load_syncpt_payload_32_r()
host1x_uclass_wait_syncpt_32_r(void)174*e902585fSMikko Perttunen static inline u32 host1x_uclass_wait_syncpt_32_r(void)
175*e902585fSMikko Perttunen {
176*e902585fSMikko Perttunen 	return 0x50;
177*e902585fSMikko Perttunen }
178*e902585fSMikko Perttunen #define HOST1X_UCLASS_WAIT_SYNCPT_32 \
179*e902585fSMikko Perttunen 	host1x_uclass_wait_syncpt_32_r()
180e6fff4aaSThierry Reding 
181e6fff4aaSThierry Reding #endif
182