18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-only */
28c2ecf20Sopenharmony_ci/*
38c2ecf20Sopenharmony_ci * Copyright (c) 2012-2013, NVIDIA Corporation.
48c2ecf20Sopenharmony_ci */
58c2ecf20Sopenharmony_ci
68c2ecf20Sopenharmony_ci /*
78c2ecf20Sopenharmony_ci  * Function naming determines intended use:
88c2ecf20Sopenharmony_ci  *
98c2ecf20Sopenharmony_ci  *     <x>_r(void) : Returns the offset for register <x>.
108c2ecf20Sopenharmony_ci  *
118c2ecf20Sopenharmony_ci  *     <x>_w(void) : Returns the word offset for word (4 byte) element <x>.
128c2ecf20Sopenharmony_ci  *
138c2ecf20Sopenharmony_ci  *     <x>_<y>_s(void) : Returns size of field <y> of register <x> in bits.
148c2ecf20Sopenharmony_ci  *
158c2ecf20Sopenharmony_ci  *     <x>_<y>_f(u32 v) : Returns a value based on 'v' which has been shifted
168c2ecf20Sopenharmony_ci  *         and masked to place it at field <y> of register <x>.  This value
178c2ecf20Sopenharmony_ci  *         can be |'d with others to produce a full register value for
188c2ecf20Sopenharmony_ci  *         register <x>.
198c2ecf20Sopenharmony_ci  *
208c2ecf20Sopenharmony_ci  *     <x>_<y>_m(void) : Returns a mask for field <y> of register <x>.  This
218c2ecf20Sopenharmony_ci  *         value can be ~'d and then &'d to clear the value of field <y> for
228c2ecf20Sopenharmony_ci  *         register <x>.
238c2ecf20Sopenharmony_ci  *
248c2ecf20Sopenharmony_ci  *     <x>_<y>_<z>_f(void) : Returns the constant value <z> after being shifted
258c2ecf20Sopenharmony_ci  *         to place it at field <y> of register <x>.  This value can be |'d
268c2ecf20Sopenharmony_ci  *         with others to produce a full register value for <x>.
278c2ecf20Sopenharmony_ci  *
288c2ecf20Sopenharmony_ci  *     <x>_<y>_v(u32 r) : Returns the value of field <y> from a full register
298c2ecf20Sopenharmony_ci  *         <x> value 'r' after being shifted to place its LSB at bit 0.
308c2ecf20Sopenharmony_ci  *         This value is suitable for direct comparison with other unshifted
318c2ecf20Sopenharmony_ci  *         values appropriate for use in field <y> of register <x>.
328c2ecf20Sopenharmony_ci  *
338c2ecf20Sopenharmony_ci  *     <x>_<y>_<z>_v(void) : Returns the constant value for <z> defined for
348c2ecf20Sopenharmony_ci  *         field <y> of register <x>.  This value is suitable for direct
358c2ecf20Sopenharmony_ci  *         comparison with unshifted values appropriate for use in field <y>
368c2ecf20Sopenharmony_ci  *         of register <x>.
378c2ecf20Sopenharmony_ci  */
388c2ecf20Sopenharmony_ci
398c2ecf20Sopenharmony_ci#ifndef __hw_host1x01_sync_h__
408c2ecf20Sopenharmony_ci#define __hw_host1x01_sync_h__
418c2ecf20Sopenharmony_ci
428c2ecf20Sopenharmony_ci#define REGISTER_STRIDE	4
438c2ecf20Sopenharmony_ci
448c2ecf20Sopenharmony_cistatic inline u32 host1x_sync_syncpt_r(unsigned int id)
458c2ecf20Sopenharmony_ci{
468c2ecf20Sopenharmony_ci	return 0x400 + id * REGISTER_STRIDE;
478c2ecf20Sopenharmony_ci}
488c2ecf20Sopenharmony_ci#define HOST1X_SYNC_SYNCPT(id) \
498c2ecf20Sopenharmony_ci	host1x_sync_syncpt_r(id)
508c2ecf20Sopenharmony_cistatic inline u32 host1x_sync_syncpt_thresh_cpu0_int_status_r(unsigned int id)
518c2ecf20Sopenharmony_ci{
528c2ecf20Sopenharmony_ci	return 0x40 + id * REGISTER_STRIDE;
538c2ecf20Sopenharmony_ci}
548c2ecf20Sopenharmony_ci#define HOST1X_SYNC_SYNCPT_THRESH_CPU0_INT_STATUS(id) \
558c2ecf20Sopenharmony_ci	host1x_sync_syncpt_thresh_cpu0_int_status_r(id)
568c2ecf20Sopenharmony_cistatic inline u32 host1x_sync_syncpt_thresh_int_disable_r(unsigned int id)
578c2ecf20Sopenharmony_ci{
588c2ecf20Sopenharmony_ci	return 0x60 + id * REGISTER_STRIDE;
598c2ecf20Sopenharmony_ci}
608c2ecf20Sopenharmony_ci#define HOST1X_SYNC_SYNCPT_THRESH_INT_DISABLE(id) \
618c2ecf20Sopenharmony_ci	host1x_sync_syncpt_thresh_int_disable_r(id)
628c2ecf20Sopenharmony_cistatic inline u32 host1x_sync_syncpt_thresh_int_enable_cpu0_r(unsigned int id)
638c2ecf20Sopenharmony_ci{
648c2ecf20Sopenharmony_ci	return 0x68 + id * REGISTER_STRIDE;
658c2ecf20Sopenharmony_ci}
668c2ecf20Sopenharmony_ci#define HOST1X_SYNC_SYNCPT_THRESH_INT_ENABLE_CPU0(id) \
678c2ecf20Sopenharmony_ci	host1x_sync_syncpt_thresh_int_enable_cpu0_r(id)
688c2ecf20Sopenharmony_cistatic inline u32 host1x_sync_cf_setup_r(unsigned int channel)
698c2ecf20Sopenharmony_ci{
708c2ecf20Sopenharmony_ci	return 0x80 + channel * REGISTER_STRIDE;
718c2ecf20Sopenharmony_ci}
728c2ecf20Sopenharmony_ci#define HOST1X_SYNC_CF_SETUP(channel) \
738c2ecf20Sopenharmony_ci	host1x_sync_cf_setup_r(channel)
748c2ecf20Sopenharmony_cistatic inline u32 host1x_sync_cf_setup_base_v(u32 r)
758c2ecf20Sopenharmony_ci{
768c2ecf20Sopenharmony_ci	return (r >> 0) & 0x1ff;
778c2ecf20Sopenharmony_ci}
788c2ecf20Sopenharmony_ci#define HOST1X_SYNC_CF_SETUP_BASE_V(r) \
798c2ecf20Sopenharmony_ci	host1x_sync_cf_setup_base_v(r)
808c2ecf20Sopenharmony_cistatic inline u32 host1x_sync_cf_setup_limit_v(u32 r)
818c2ecf20Sopenharmony_ci{
828c2ecf20Sopenharmony_ci	return (r >> 16) & 0x1ff;
838c2ecf20Sopenharmony_ci}
848c2ecf20Sopenharmony_ci#define HOST1X_SYNC_CF_SETUP_LIMIT_V(r) \
858c2ecf20Sopenharmony_ci	host1x_sync_cf_setup_limit_v(r)
868c2ecf20Sopenharmony_cistatic inline u32 host1x_sync_cmdproc_stop_r(void)
878c2ecf20Sopenharmony_ci{
888c2ecf20Sopenharmony_ci	return 0xac;
898c2ecf20Sopenharmony_ci}
908c2ecf20Sopenharmony_ci#define HOST1X_SYNC_CMDPROC_STOP \
918c2ecf20Sopenharmony_ci	host1x_sync_cmdproc_stop_r()
928c2ecf20Sopenharmony_cistatic inline u32 host1x_sync_ch_teardown_r(void)
938c2ecf20Sopenharmony_ci{
948c2ecf20Sopenharmony_ci	return 0xb0;
958c2ecf20Sopenharmony_ci}
968c2ecf20Sopenharmony_ci#define HOST1X_SYNC_CH_TEARDOWN \
978c2ecf20Sopenharmony_ci	host1x_sync_ch_teardown_r()
988c2ecf20Sopenharmony_cistatic inline u32 host1x_sync_usec_clk_r(void)
998c2ecf20Sopenharmony_ci{
1008c2ecf20Sopenharmony_ci	return 0x1a4;
1018c2ecf20Sopenharmony_ci}
1028c2ecf20Sopenharmony_ci#define HOST1X_SYNC_USEC_CLK \
1038c2ecf20Sopenharmony_ci	host1x_sync_usec_clk_r()
1048c2ecf20Sopenharmony_cistatic inline u32 host1x_sync_ctxsw_timeout_cfg_r(void)
1058c2ecf20Sopenharmony_ci{
1068c2ecf20Sopenharmony_ci	return 0x1a8;
1078c2ecf20Sopenharmony_ci}
1088c2ecf20Sopenharmony_ci#define HOST1X_SYNC_CTXSW_TIMEOUT_CFG \
1098c2ecf20Sopenharmony_ci	host1x_sync_ctxsw_timeout_cfg_r()
1108c2ecf20Sopenharmony_cistatic inline u32 host1x_sync_ip_busy_timeout_r(void)
1118c2ecf20Sopenharmony_ci{
1128c2ecf20Sopenharmony_ci	return 0x1bc;
1138c2ecf20Sopenharmony_ci}
1148c2ecf20Sopenharmony_ci#define HOST1X_SYNC_IP_BUSY_TIMEOUT \
1158c2ecf20Sopenharmony_ci	host1x_sync_ip_busy_timeout_r()
1168c2ecf20Sopenharmony_cistatic inline u32 host1x_sync_mlock_owner_r(unsigned int id)
1178c2ecf20Sopenharmony_ci{
1188c2ecf20Sopenharmony_ci	return 0x340 + id * REGISTER_STRIDE;
1198c2ecf20Sopenharmony_ci}
1208c2ecf20Sopenharmony_ci#define HOST1X_SYNC_MLOCK_OWNER(id) \
1218c2ecf20Sopenharmony_ci	host1x_sync_mlock_owner_r(id)
1228c2ecf20Sopenharmony_cistatic inline u32 host1x_sync_mlock_owner_chid_v(u32 v)
1238c2ecf20Sopenharmony_ci{
1248c2ecf20Sopenharmony_ci	return (v >> 8) & 0xf;
1258c2ecf20Sopenharmony_ci}
1268c2ecf20Sopenharmony_ci#define HOST1X_SYNC_MLOCK_OWNER_CHID_V(v) \
1278c2ecf20Sopenharmony_ci	host1x_sync_mlock_owner_chid_v(v)
1288c2ecf20Sopenharmony_cistatic inline u32 host1x_sync_mlock_owner_cpu_owns_v(u32 r)
1298c2ecf20Sopenharmony_ci{
1308c2ecf20Sopenharmony_ci	return (r >> 1) & 0x1;
1318c2ecf20Sopenharmony_ci}
1328c2ecf20Sopenharmony_ci#define HOST1X_SYNC_MLOCK_OWNER_CPU_OWNS_V(r) \
1338c2ecf20Sopenharmony_ci	host1x_sync_mlock_owner_cpu_owns_v(r)
1348c2ecf20Sopenharmony_cistatic inline u32 host1x_sync_mlock_owner_ch_owns_v(u32 r)
1358c2ecf20Sopenharmony_ci{
1368c2ecf20Sopenharmony_ci	return (r >> 0) & 0x1;
1378c2ecf20Sopenharmony_ci}
1388c2ecf20Sopenharmony_ci#define HOST1X_SYNC_MLOCK_OWNER_CH_OWNS_V(r) \
1398c2ecf20Sopenharmony_ci	host1x_sync_mlock_owner_ch_owns_v(r)
1408c2ecf20Sopenharmony_cistatic inline u32 host1x_sync_syncpt_int_thresh_r(unsigned int id)
1418c2ecf20Sopenharmony_ci{
1428c2ecf20Sopenharmony_ci	return 0x500 + id * REGISTER_STRIDE;
1438c2ecf20Sopenharmony_ci}
1448c2ecf20Sopenharmony_ci#define HOST1X_SYNC_SYNCPT_INT_THRESH(id) \
1458c2ecf20Sopenharmony_ci	host1x_sync_syncpt_int_thresh_r(id)
1468c2ecf20Sopenharmony_cistatic inline u32 host1x_sync_syncpt_base_r(unsigned int id)
1478c2ecf20Sopenharmony_ci{
1488c2ecf20Sopenharmony_ci	return 0x600 + id * REGISTER_STRIDE;
1498c2ecf20Sopenharmony_ci}
1508c2ecf20Sopenharmony_ci#define HOST1X_SYNC_SYNCPT_BASE(id) \
1518c2ecf20Sopenharmony_ci	host1x_sync_syncpt_base_r(id)
1528c2ecf20Sopenharmony_cistatic inline u32 host1x_sync_syncpt_cpu_incr_r(unsigned int id)
1538c2ecf20Sopenharmony_ci{
1548c2ecf20Sopenharmony_ci	return 0x700 + id * REGISTER_STRIDE;
1558c2ecf20Sopenharmony_ci}
1568c2ecf20Sopenharmony_ci#define HOST1X_SYNC_SYNCPT_CPU_INCR(id) \
1578c2ecf20Sopenharmony_ci	host1x_sync_syncpt_cpu_incr_r(id)
1588c2ecf20Sopenharmony_cistatic inline u32 host1x_sync_cbread_r(unsigned int channel)
1598c2ecf20Sopenharmony_ci{
1608c2ecf20Sopenharmony_ci	return 0x720 + channel * REGISTER_STRIDE;
1618c2ecf20Sopenharmony_ci}
1628c2ecf20Sopenharmony_ci#define HOST1X_SYNC_CBREAD(channel) \
1638c2ecf20Sopenharmony_ci	host1x_sync_cbread_r(channel)
1648c2ecf20Sopenharmony_cistatic inline u32 host1x_sync_cfpeek_ctrl_r(void)
1658c2ecf20Sopenharmony_ci{
1668c2ecf20Sopenharmony_ci	return 0x74c;
1678c2ecf20Sopenharmony_ci}
1688c2ecf20Sopenharmony_ci#define HOST1X_SYNC_CFPEEK_CTRL \
1698c2ecf20Sopenharmony_ci	host1x_sync_cfpeek_ctrl_r()
1708c2ecf20Sopenharmony_cistatic inline u32 host1x_sync_cfpeek_ctrl_addr_f(u32 v)
1718c2ecf20Sopenharmony_ci{
1728c2ecf20Sopenharmony_ci	return (v & 0x1ff) << 0;
1738c2ecf20Sopenharmony_ci}
1748c2ecf20Sopenharmony_ci#define HOST1X_SYNC_CFPEEK_CTRL_ADDR_F(v) \
1758c2ecf20Sopenharmony_ci	host1x_sync_cfpeek_ctrl_addr_f(v)
1768c2ecf20Sopenharmony_cistatic inline u32 host1x_sync_cfpeek_ctrl_channr_f(u32 v)
1778c2ecf20Sopenharmony_ci{
1788c2ecf20Sopenharmony_ci	return (v & 0x7) << 16;
1798c2ecf20Sopenharmony_ci}
1808c2ecf20Sopenharmony_ci#define HOST1X_SYNC_CFPEEK_CTRL_CHANNR_F(v) \
1818c2ecf20Sopenharmony_ci	host1x_sync_cfpeek_ctrl_channr_f(v)
1828c2ecf20Sopenharmony_cistatic inline u32 host1x_sync_cfpeek_ctrl_ena_f(u32 v)
1838c2ecf20Sopenharmony_ci{
1848c2ecf20Sopenharmony_ci	return (v & 0x1) << 31;
1858c2ecf20Sopenharmony_ci}
1868c2ecf20Sopenharmony_ci#define HOST1X_SYNC_CFPEEK_CTRL_ENA_F(v) \
1878c2ecf20Sopenharmony_ci	host1x_sync_cfpeek_ctrl_ena_f(v)
1888c2ecf20Sopenharmony_cistatic inline u32 host1x_sync_cfpeek_read_r(void)
1898c2ecf20Sopenharmony_ci{
1908c2ecf20Sopenharmony_ci	return 0x750;
1918c2ecf20Sopenharmony_ci}
1928c2ecf20Sopenharmony_ci#define HOST1X_SYNC_CFPEEK_READ \
1938c2ecf20Sopenharmony_ci	host1x_sync_cfpeek_read_r()
1948c2ecf20Sopenharmony_cistatic inline u32 host1x_sync_cfpeek_ptrs_r(void)
1958c2ecf20Sopenharmony_ci{
1968c2ecf20Sopenharmony_ci	return 0x754;
1978c2ecf20Sopenharmony_ci}
1988c2ecf20Sopenharmony_ci#define HOST1X_SYNC_CFPEEK_PTRS \
1998c2ecf20Sopenharmony_ci	host1x_sync_cfpeek_ptrs_r()
2008c2ecf20Sopenharmony_cistatic inline u32 host1x_sync_cfpeek_ptrs_cf_rd_ptr_v(u32 r)
2018c2ecf20Sopenharmony_ci{
2028c2ecf20Sopenharmony_ci	return (r >> 0) & 0x1ff;
2038c2ecf20Sopenharmony_ci}
2048c2ecf20Sopenharmony_ci#define HOST1X_SYNC_CFPEEK_PTRS_CF_RD_PTR_V(r) \
2058c2ecf20Sopenharmony_ci	host1x_sync_cfpeek_ptrs_cf_rd_ptr_v(r)
2068c2ecf20Sopenharmony_cistatic inline u32 host1x_sync_cfpeek_ptrs_cf_wr_ptr_v(u32 r)
2078c2ecf20Sopenharmony_ci{
2088c2ecf20Sopenharmony_ci	return (r >> 16) & 0x1ff;
2098c2ecf20Sopenharmony_ci}
2108c2ecf20Sopenharmony_ci#define HOST1X_SYNC_CFPEEK_PTRS_CF_WR_PTR_V(r) \
2118c2ecf20Sopenharmony_ci	host1x_sync_cfpeek_ptrs_cf_wr_ptr_v(r)
2128c2ecf20Sopenharmony_cistatic inline u32 host1x_sync_cbstat_r(unsigned int channel)
2138c2ecf20Sopenharmony_ci{
2148c2ecf20Sopenharmony_ci	return 0x758 + channel * REGISTER_STRIDE;
2158c2ecf20Sopenharmony_ci}
2168c2ecf20Sopenharmony_ci#define HOST1X_SYNC_CBSTAT(channel) \
2178c2ecf20Sopenharmony_ci	host1x_sync_cbstat_r(channel)
2188c2ecf20Sopenharmony_cistatic inline u32 host1x_sync_cbstat_cboffset_v(u32 r)
2198c2ecf20Sopenharmony_ci{
2208c2ecf20Sopenharmony_ci	return (r >> 0) & 0xffff;
2218c2ecf20Sopenharmony_ci}
2228c2ecf20Sopenharmony_ci#define HOST1X_SYNC_CBSTAT_CBOFFSET_V(r) \
2238c2ecf20Sopenharmony_ci	host1x_sync_cbstat_cboffset_v(r)
2248c2ecf20Sopenharmony_cistatic inline u32 host1x_sync_cbstat_cbclass_v(u32 r)
2258c2ecf20Sopenharmony_ci{
2268c2ecf20Sopenharmony_ci	return (r >> 16) & 0x3ff;
2278c2ecf20Sopenharmony_ci}
2288c2ecf20Sopenharmony_ci#define HOST1X_SYNC_CBSTAT_CBCLASS_V(r) \
2298c2ecf20Sopenharmony_ci	host1x_sync_cbstat_cbclass_v(r)
2308c2ecf20Sopenharmony_ci
2318c2ecf20Sopenharmony_ci#endif /* __hw_host1x01_sync_h__ */
232