1 /* SPDX-License-Identifier: GPL-2.0-only */
5 * Copyright (c) 2022 NVIDIA Corporation.
8 #ifndef __HOST1X_OPCODES_H
9 #define __HOST1X_OPCODES_H
11 #include <linux/types.h>
13 static inline u32 host1x_class_host_wait_syncpt(
14 unsigned indx, unsigned threshold)
16 return host1x_uclass_wait_syncpt_indx_f(indx)
17 | host1x_uclass_wait_syncpt_thresh_f(threshold);
20 static inline u32 host1x_class_host_load_syncpt_base(
21 unsigned indx, unsigned threshold)
23 return host1x_uclass_load_syncpt_base_base_indx_f(indx)
24 | host1x_uclass_load_syncpt_base_value_f(threshold);
27 static inline u32 host1x_class_host_wait_syncpt_base(
28 unsigned indx, unsigned base_indx, unsigned offset)
30 return host1x_uclass_wait_syncpt_base_indx_f(indx)
31 | host1x_uclass_wait_syncpt_base_base_indx_f(base_indx)
32 | host1x_uclass_wait_syncpt_base_offset_f(offset);
35 static inline u32 host1x_class_host_incr_syncpt_base(
36 unsigned base_indx, unsigned offset)
38 return host1x_uclass_incr_syncpt_base_base_indx_f(base_indx)
39 | host1x_uclass_incr_syncpt_base_offset_f(offset);
42 static inline u32 host1x_class_host_incr_syncpt(
43 unsigned cond, unsigned indx)
45 return host1x_uclass_incr_syncpt_cond_f(cond)
46 | host1x_uclass_incr_syncpt_indx_f(indx);
49 static inline u32 host1x_class_host_indoff_reg_write(
50 unsigned mod_id, unsigned offset, bool auto_inc)
52 u32 v = host1x_uclass_indoff_indbe_f(0xf)
53 | host1x_uclass_indoff_indmodid_f(mod_id)
54 | host1x_uclass_indoff_indroffset_f(offset);
56 v |= host1x_uclass_indoff_autoinc_f(1);
60 static inline u32 host1x_class_host_indoff_reg_read(
61 unsigned mod_id, unsigned offset, bool auto_inc)
63 u32 v = host1x_uclass_indoff_indmodid_f(mod_id)
64 | host1x_uclass_indoff_indroffset_f(offset)
65 | host1x_uclass_indoff_rwn_read_v();
67 v |= host1x_uclass_indoff_autoinc_f(1);
71 static inline u32 host1x_opcode_setclass(
72 unsigned class_id, unsigned offset, unsigned mask)
74 return (0 << 28) | (offset << 16) | (class_id << 6) | mask;
77 static inline u32 host1x_opcode_incr(unsigned offset, unsigned count)
79 return (1 << 28) | (offset << 16) | count;
82 static inline u32 host1x_opcode_nonincr(unsigned offset, unsigned count)
84 return (2 << 28) | (offset << 16) | count;
87 static inline u32 host1x_opcode_mask(unsigned offset, unsigned mask)
89 return (3 << 28) | (offset << 16) | mask;
92 static inline u32 host1x_opcode_imm(unsigned offset, unsigned value)
94 return (4 << 28) | (offset << 16) | value;
97 static inline u32 host1x_opcode_imm_incr_syncpt(unsigned cond, unsigned indx)
99 return host1x_opcode_imm(host1x_uclass_incr_syncpt_r(),
100 host1x_class_host_incr_syncpt(cond, indx));
103 static inline u32 host1x_opcode_restart(unsigned address)
105 return (5 << 28) | (address >> 4);
108 static inline u32 host1x_opcode_gather(unsigned count)
110 return (6 << 28) | count;
113 static inline u32 host1x_opcode_gather_nonincr(unsigned offset, unsigned count)
115 return (6 << 28) | (offset << 16) | BIT(15) | count;
118 static inline u32 host1x_opcode_gather_incr(unsigned offset, unsigned count)
120 return (6 << 28) | (offset << 16) | BIT(15) | BIT(14) | count;
123 static inline u32 host1x_opcode_setstreamid(unsigned streamid)
125 return (7 << 28) | streamid;
128 static inline u32 host1x_opcode_setpayload(unsigned payload)
130 return (9 << 28) | payload;
133 static inline u32 host1x_opcode_gather_wide(unsigned count)
135 return (12 << 28) | count;
138 static inline u32 host1x_opcode_acquire_mlock(unsigned mlock)
140 return (14 << 28) | (0 << 24) | mlock;
143 static inline u32 host1x_opcode_release_mlock(unsigned mlock)
145 return (14 << 28) | (1 << 24) | mlock;
148 #define HOST1X_OPCODE_NOP host1x_opcode_nonincr(0, 0)