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_SYNC_H
40e6fff4aaSThierry Reding #define HOST1X_HW_HOST1X04_SYNC_H
41e6fff4aaSThierry Reding 
42e6fff4aaSThierry Reding #define REGISTER_STRIDE	4
43e6fff4aaSThierry Reding 
host1x_sync_syncpt_r(unsigned int id)44e6fff4aaSThierry Reding static inline u32 host1x_sync_syncpt_r(unsigned int id)
45e6fff4aaSThierry Reding {
46e6fff4aaSThierry Reding 	return 0xf80 + id * REGISTER_STRIDE;
47e6fff4aaSThierry Reding }
48e6fff4aaSThierry Reding #define HOST1X_SYNC_SYNCPT(id) \
49e6fff4aaSThierry Reding 	host1x_sync_syncpt_r(id)
host1x_sync_syncpt_thresh_cpu0_int_status_r(unsigned int id)50e6fff4aaSThierry Reding static inline u32 host1x_sync_syncpt_thresh_cpu0_int_status_r(unsigned int id)
51e6fff4aaSThierry Reding {
52e6fff4aaSThierry Reding 	return 0xe80 + id * REGISTER_STRIDE;
53e6fff4aaSThierry Reding }
54e6fff4aaSThierry Reding #define HOST1X_SYNC_SYNCPT_THRESH_CPU0_INT_STATUS(id) \
55e6fff4aaSThierry Reding 	host1x_sync_syncpt_thresh_cpu0_int_status_r(id)
host1x_sync_syncpt_thresh_int_disable_r(unsigned int id)56e6fff4aaSThierry Reding static inline u32 host1x_sync_syncpt_thresh_int_disable_r(unsigned int id)
57e6fff4aaSThierry Reding {
58e6fff4aaSThierry Reding 	return 0xf00 + id * REGISTER_STRIDE;
59e6fff4aaSThierry Reding }
60e6fff4aaSThierry Reding #define HOST1X_SYNC_SYNCPT_THRESH_INT_DISABLE(id) \
61e6fff4aaSThierry Reding 	host1x_sync_syncpt_thresh_int_disable_r(id)
host1x_sync_syncpt_thresh_int_enable_cpu0_r(unsigned int id)62e6fff4aaSThierry Reding static inline u32 host1x_sync_syncpt_thresh_int_enable_cpu0_r(unsigned int id)
63e6fff4aaSThierry Reding {
64e6fff4aaSThierry Reding 	return 0xf20 + id * REGISTER_STRIDE;
65e6fff4aaSThierry Reding }
66e6fff4aaSThierry Reding #define HOST1X_SYNC_SYNCPT_THRESH_INT_ENABLE_CPU0(id) \
67e6fff4aaSThierry Reding 	host1x_sync_syncpt_thresh_int_enable_cpu0_r(id)
host1x_sync_cf_setup_r(unsigned int channel)68e6fff4aaSThierry Reding static inline u32 host1x_sync_cf_setup_r(unsigned int channel)
69e6fff4aaSThierry Reding {
70e6fff4aaSThierry Reding 	return 0xc00 + channel * REGISTER_STRIDE;
71e6fff4aaSThierry Reding }
72e6fff4aaSThierry Reding #define HOST1X_SYNC_CF_SETUP(channel) \
73e6fff4aaSThierry Reding 	host1x_sync_cf_setup_r(channel)
host1x_sync_cf_setup_base_v(u32 r)74e6fff4aaSThierry Reding static inline u32 host1x_sync_cf_setup_base_v(u32 r)
75e6fff4aaSThierry Reding {
76e6fff4aaSThierry Reding 	return (r >> 0) & 0x3ff;
77e6fff4aaSThierry Reding }
78e6fff4aaSThierry Reding #define HOST1X_SYNC_CF_SETUP_BASE_V(r) \
79e6fff4aaSThierry Reding 	host1x_sync_cf_setup_base_v(r)
host1x_sync_cf_setup_limit_v(u32 r)80e6fff4aaSThierry Reding static inline u32 host1x_sync_cf_setup_limit_v(u32 r)
81e6fff4aaSThierry Reding {
82e6fff4aaSThierry Reding 	return (r >> 16) & 0x3ff;
83e6fff4aaSThierry Reding }
84e6fff4aaSThierry Reding #define HOST1X_SYNC_CF_SETUP_LIMIT_V(r) \
85e6fff4aaSThierry Reding 	host1x_sync_cf_setup_limit_v(r)
host1x_sync_cmdproc_stop_r(void)86e6fff4aaSThierry Reding static inline u32 host1x_sync_cmdproc_stop_r(void)
87e6fff4aaSThierry Reding {
88e6fff4aaSThierry Reding 	return 0xac;
89e6fff4aaSThierry Reding }
90e6fff4aaSThierry Reding #define HOST1X_SYNC_CMDPROC_STOP \
91e6fff4aaSThierry Reding 	host1x_sync_cmdproc_stop_r()
host1x_sync_ch_teardown_r(void)92e6fff4aaSThierry Reding static inline u32 host1x_sync_ch_teardown_r(void)
93e6fff4aaSThierry Reding {
94e6fff4aaSThierry Reding 	return 0xb0;
95e6fff4aaSThierry Reding }
96e6fff4aaSThierry Reding #define HOST1X_SYNC_CH_TEARDOWN \
97e6fff4aaSThierry Reding 	host1x_sync_ch_teardown_r()
host1x_sync_usec_clk_r(void)98e6fff4aaSThierry Reding static inline u32 host1x_sync_usec_clk_r(void)
99e6fff4aaSThierry Reding {
100e6fff4aaSThierry Reding 	return 0x1a4;
101e6fff4aaSThierry Reding }
102e6fff4aaSThierry Reding #define HOST1X_SYNC_USEC_CLK \
103e6fff4aaSThierry Reding 	host1x_sync_usec_clk_r()
host1x_sync_ctxsw_timeout_cfg_r(void)104e6fff4aaSThierry Reding static inline u32 host1x_sync_ctxsw_timeout_cfg_r(void)
105e6fff4aaSThierry Reding {
106e6fff4aaSThierry Reding 	return 0x1a8;
107e6fff4aaSThierry Reding }
108e6fff4aaSThierry Reding #define HOST1X_SYNC_CTXSW_TIMEOUT_CFG \
109e6fff4aaSThierry Reding 	host1x_sync_ctxsw_timeout_cfg_r()
host1x_sync_ip_busy_timeout_r(void)110e6fff4aaSThierry Reding static inline u32 host1x_sync_ip_busy_timeout_r(void)
111e6fff4aaSThierry Reding {
112e6fff4aaSThierry Reding 	return 0x1bc;
113e6fff4aaSThierry Reding }
114e6fff4aaSThierry Reding #define HOST1X_SYNC_IP_BUSY_TIMEOUT \
115e6fff4aaSThierry Reding 	host1x_sync_ip_busy_timeout_r()
host1x_sync_mlock_owner_r(unsigned int id)116e6fff4aaSThierry Reding static inline u32 host1x_sync_mlock_owner_r(unsigned int id)
117e6fff4aaSThierry Reding {
118e6fff4aaSThierry Reding 	return 0x340 + id * REGISTER_STRIDE;
119e6fff4aaSThierry Reding }
120e6fff4aaSThierry Reding #define HOST1X_SYNC_MLOCK_OWNER(id) \
121e6fff4aaSThierry Reding 	host1x_sync_mlock_owner_r(id)
host1x_sync_mlock_owner_chid_v(u32 v)1223fe2c7d4SDmitry Osipenko static inline u32 host1x_sync_mlock_owner_chid_v(u32 v)
123e6fff4aaSThierry Reding {
1243fe2c7d4SDmitry Osipenko 	return (v >> 8) & 0xf;
125e6fff4aaSThierry Reding }
1263fe2c7d4SDmitry Osipenko #define HOST1X_SYNC_MLOCK_OWNER_CHID_V(v) \
1273fe2c7d4SDmitry Osipenko 	host1x_sync_mlock_owner_chid_v(v)
host1x_sync_mlock_owner_cpu_owns_v(u32 r)128e6fff4aaSThierry Reding static inline u32 host1x_sync_mlock_owner_cpu_owns_v(u32 r)
129e6fff4aaSThierry Reding {
130e6fff4aaSThierry Reding 	return (r >> 1) & 0x1;
131e6fff4aaSThierry Reding }
132e6fff4aaSThierry Reding #define HOST1X_SYNC_MLOCK_OWNER_CPU_OWNS_V(r) \
133e6fff4aaSThierry Reding 	host1x_sync_mlock_owner_cpu_owns_v(r)
host1x_sync_mlock_owner_ch_owns_v(u32 r)134e6fff4aaSThierry Reding static inline u32 host1x_sync_mlock_owner_ch_owns_v(u32 r)
135e6fff4aaSThierry Reding {
136e6fff4aaSThierry Reding 	return (r >> 0) & 0x1;
137e6fff4aaSThierry Reding }
138e6fff4aaSThierry Reding #define HOST1X_SYNC_MLOCK_OWNER_CH_OWNS_V(r) \
139e6fff4aaSThierry Reding 	host1x_sync_mlock_owner_ch_owns_v(r)
host1x_sync_syncpt_int_thresh_r(unsigned int id)140e6fff4aaSThierry Reding static inline u32 host1x_sync_syncpt_int_thresh_r(unsigned int id)
141e6fff4aaSThierry Reding {
142e6fff4aaSThierry Reding 	return 0x1380 + id * REGISTER_STRIDE;
143e6fff4aaSThierry Reding }
144e6fff4aaSThierry Reding #define HOST1X_SYNC_SYNCPT_INT_THRESH(id) \
145e6fff4aaSThierry Reding 	host1x_sync_syncpt_int_thresh_r(id)
host1x_sync_syncpt_base_r(unsigned int id)146e6fff4aaSThierry Reding static inline u32 host1x_sync_syncpt_base_r(unsigned int id)
147e6fff4aaSThierry Reding {
148e6fff4aaSThierry Reding 	return 0x600 + id * REGISTER_STRIDE;
149e6fff4aaSThierry Reding }
150e6fff4aaSThierry Reding #define HOST1X_SYNC_SYNCPT_BASE(id) \
151e6fff4aaSThierry Reding 	host1x_sync_syncpt_base_r(id)
host1x_sync_syncpt_cpu_incr_r(unsigned int id)152e6fff4aaSThierry Reding static inline u32 host1x_sync_syncpt_cpu_incr_r(unsigned int id)
153e6fff4aaSThierry Reding {
154e6fff4aaSThierry Reding 	return 0xf60 + id * REGISTER_STRIDE;
155e6fff4aaSThierry Reding }
156e6fff4aaSThierry Reding #define HOST1X_SYNC_SYNCPT_CPU_INCR(id) \
157e6fff4aaSThierry Reding 	host1x_sync_syncpt_cpu_incr_r(id)
host1x_sync_cbread_r(unsigned int channel)158e6fff4aaSThierry Reding static inline u32 host1x_sync_cbread_r(unsigned int channel)
159e6fff4aaSThierry Reding {
160e6fff4aaSThierry Reding 	return 0xc80 + channel * REGISTER_STRIDE;
161e6fff4aaSThierry Reding }
162e6fff4aaSThierry Reding #define HOST1X_SYNC_CBREAD(channel) \
163e6fff4aaSThierry Reding 	host1x_sync_cbread_r(channel)
host1x_sync_cfpeek_ctrl_r(void)164e6fff4aaSThierry Reding static inline u32 host1x_sync_cfpeek_ctrl_r(void)
165e6fff4aaSThierry Reding {
166e6fff4aaSThierry Reding 	return 0x74c;
167e6fff4aaSThierry Reding }
168e6fff4aaSThierry Reding #define HOST1X_SYNC_CFPEEK_CTRL \
169e6fff4aaSThierry Reding 	host1x_sync_cfpeek_ctrl_r()
host1x_sync_cfpeek_ctrl_addr_f(u32 v)170e6fff4aaSThierry Reding static inline u32 host1x_sync_cfpeek_ctrl_addr_f(u32 v)
171e6fff4aaSThierry Reding {
172e6fff4aaSThierry Reding 	return (v & 0x3ff) << 0;
173e6fff4aaSThierry Reding }
174e6fff4aaSThierry Reding #define HOST1X_SYNC_CFPEEK_CTRL_ADDR_F(v) \
175e6fff4aaSThierry Reding 	host1x_sync_cfpeek_ctrl_addr_f(v)
host1x_sync_cfpeek_ctrl_channr_f(u32 v)176e6fff4aaSThierry Reding static inline u32 host1x_sync_cfpeek_ctrl_channr_f(u32 v)
177e6fff4aaSThierry Reding {
178e6fff4aaSThierry Reding 	return (v & 0xf) << 16;
179e6fff4aaSThierry Reding }
180e6fff4aaSThierry Reding #define HOST1X_SYNC_CFPEEK_CTRL_CHANNR_F(v) \
181e6fff4aaSThierry Reding 	host1x_sync_cfpeek_ctrl_channr_f(v)
host1x_sync_cfpeek_ctrl_ena_f(u32 v)182e6fff4aaSThierry Reding static inline u32 host1x_sync_cfpeek_ctrl_ena_f(u32 v)
183e6fff4aaSThierry Reding {
184e6fff4aaSThierry Reding 	return (v & 0x1) << 31;
185e6fff4aaSThierry Reding }
186e6fff4aaSThierry Reding #define HOST1X_SYNC_CFPEEK_CTRL_ENA_F(v) \
187e6fff4aaSThierry Reding 	host1x_sync_cfpeek_ctrl_ena_f(v)
host1x_sync_cfpeek_read_r(void)188e6fff4aaSThierry Reding static inline u32 host1x_sync_cfpeek_read_r(void)
189e6fff4aaSThierry Reding {
190e6fff4aaSThierry Reding 	return 0x750;
191e6fff4aaSThierry Reding }
192e6fff4aaSThierry Reding #define HOST1X_SYNC_CFPEEK_READ \
193e6fff4aaSThierry Reding 	host1x_sync_cfpeek_read_r()
host1x_sync_cfpeek_ptrs_r(void)194e6fff4aaSThierry Reding static inline u32 host1x_sync_cfpeek_ptrs_r(void)
195e6fff4aaSThierry Reding {
196e6fff4aaSThierry Reding 	return 0x754;
197e6fff4aaSThierry Reding }
198e6fff4aaSThierry Reding #define HOST1X_SYNC_CFPEEK_PTRS \
199e6fff4aaSThierry Reding 	host1x_sync_cfpeek_ptrs_r()
host1x_sync_cfpeek_ptrs_cf_rd_ptr_v(u32 r)200e6fff4aaSThierry Reding static inline u32 host1x_sync_cfpeek_ptrs_cf_rd_ptr_v(u32 r)
201e6fff4aaSThierry Reding {
202e6fff4aaSThierry Reding 	return (r >> 0) & 0x3ff;
203e6fff4aaSThierry Reding }
204e6fff4aaSThierry Reding #define HOST1X_SYNC_CFPEEK_PTRS_CF_RD_PTR_V(r) \
205e6fff4aaSThierry Reding 	host1x_sync_cfpeek_ptrs_cf_rd_ptr_v(r)
host1x_sync_cfpeek_ptrs_cf_wr_ptr_v(u32 r)206e6fff4aaSThierry Reding static inline u32 host1x_sync_cfpeek_ptrs_cf_wr_ptr_v(u32 r)
207e6fff4aaSThierry Reding {
208e6fff4aaSThierry Reding 	return (r >> 16) & 0x3ff;
209e6fff4aaSThierry Reding }
210e6fff4aaSThierry Reding #define HOST1X_SYNC_CFPEEK_PTRS_CF_WR_PTR_V(r) \
211e6fff4aaSThierry Reding 	host1x_sync_cfpeek_ptrs_cf_wr_ptr_v(r)
host1x_sync_cbstat_r(unsigned int channel)212e6fff4aaSThierry Reding static inline u32 host1x_sync_cbstat_r(unsigned int channel)
213e6fff4aaSThierry Reding {
214e6fff4aaSThierry Reding 	return 0xcc0 + channel * REGISTER_STRIDE;
215e6fff4aaSThierry Reding }
216e6fff4aaSThierry Reding #define HOST1X_SYNC_CBSTAT(channel) \
217e6fff4aaSThierry Reding 	host1x_sync_cbstat_r(channel)
host1x_sync_cbstat_cboffset_v(u32 r)218e6fff4aaSThierry Reding static inline u32 host1x_sync_cbstat_cboffset_v(u32 r)
219e6fff4aaSThierry Reding {
220e6fff4aaSThierry Reding 	return (r >> 0) & 0xffff;
221e6fff4aaSThierry Reding }
222e6fff4aaSThierry Reding #define HOST1X_SYNC_CBSTAT_CBOFFSET_V(r) \
223e6fff4aaSThierry Reding 	host1x_sync_cbstat_cboffset_v(r)
host1x_sync_cbstat_cbclass_v(u32 r)224e6fff4aaSThierry Reding static inline u32 host1x_sync_cbstat_cbclass_v(u32 r)
225e6fff4aaSThierry Reding {
226e6fff4aaSThierry Reding 	return (r >> 16) & 0x3ff;
227e6fff4aaSThierry Reding }
228e6fff4aaSThierry Reding #define HOST1X_SYNC_CBSTAT_CBCLASS_V(r) \
229e6fff4aaSThierry Reding 	host1x_sync_cbstat_cbclass_v(r)
230e6fff4aaSThierry Reding 
231e6fff4aaSThierry Reding #endif
232