WIP FPC-III support
[linux/fpc-iii.git] / drivers / gpu / host1x / hw / host1x01_hardware.h
blobfe59df1d3dc37b70b2b7094aee7d2561f74375b4
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 /*
3 * Tegra host1x Register Offsets for Tegra20 and Tegra30
5 * Copyright (c) 2010-2013 NVIDIA Corporation.
6 */
8 #ifndef __HOST1X_HOST1X01_HARDWARE_H
9 #define __HOST1X_HOST1X01_HARDWARE_H
11 #include <linux/types.h>
12 #include <linux/bitops.h>
14 #include "hw_host1x01_channel.h"
15 #include "hw_host1x01_sync.h"
16 #include "hw_host1x01_uclass.h"
18 static inline u32 host1x_class_host_wait_syncpt(
19 unsigned indx, unsigned threshold)
21 return host1x_uclass_wait_syncpt_indx_f(indx)
22 | host1x_uclass_wait_syncpt_thresh_f(threshold);
25 static inline u32 host1x_class_host_load_syncpt_base(
26 unsigned indx, unsigned threshold)
28 return host1x_uclass_load_syncpt_base_base_indx_f(indx)
29 | host1x_uclass_load_syncpt_base_value_f(threshold);
32 static inline u32 host1x_class_host_wait_syncpt_base(
33 unsigned indx, unsigned base_indx, unsigned offset)
35 return host1x_uclass_wait_syncpt_base_indx_f(indx)
36 | host1x_uclass_wait_syncpt_base_base_indx_f(base_indx)
37 | host1x_uclass_wait_syncpt_base_offset_f(offset);
40 static inline u32 host1x_class_host_incr_syncpt_base(
41 unsigned base_indx, unsigned offset)
43 return host1x_uclass_incr_syncpt_base_base_indx_f(base_indx)
44 | host1x_uclass_incr_syncpt_base_offset_f(offset);
47 static inline u32 host1x_class_host_incr_syncpt(
48 unsigned cond, unsigned indx)
50 return host1x_uclass_incr_syncpt_cond_f(cond)
51 | host1x_uclass_incr_syncpt_indx_f(indx);
54 static inline u32 host1x_class_host_indoff_reg_write(
55 unsigned mod_id, unsigned offset, bool auto_inc)
57 u32 v = host1x_uclass_indoff_indbe_f(0xf)
58 | host1x_uclass_indoff_indmodid_f(mod_id)
59 | host1x_uclass_indoff_indroffset_f(offset);
60 if (auto_inc)
61 v |= host1x_uclass_indoff_autoinc_f(1);
62 return v;
65 static inline u32 host1x_class_host_indoff_reg_read(
66 unsigned mod_id, unsigned offset, bool auto_inc)
68 u32 v = host1x_uclass_indoff_indmodid_f(mod_id)
69 | host1x_uclass_indoff_indroffset_f(offset)
70 | host1x_uclass_indoff_rwn_read_v();
71 if (auto_inc)
72 v |= host1x_uclass_indoff_autoinc_f(1);
73 return v;
77 /* cdma opcodes */
78 static inline u32 host1x_opcode_setclass(
79 unsigned class_id, unsigned offset, unsigned mask)
81 return (0 << 28) | (offset << 16) | (class_id << 6) | mask;
84 static inline u32 host1x_opcode_incr(unsigned offset, unsigned count)
86 return (1 << 28) | (offset << 16) | count;
89 static inline u32 host1x_opcode_nonincr(unsigned offset, unsigned count)
91 return (2 << 28) | (offset << 16) | count;
94 static inline u32 host1x_opcode_mask(unsigned offset, unsigned mask)
96 return (3 << 28) | (offset << 16) | mask;
99 static inline u32 host1x_opcode_imm(unsigned offset, unsigned value)
101 return (4 << 28) | (offset << 16) | value;
104 static inline u32 host1x_opcode_imm_incr_syncpt(unsigned cond, unsigned indx)
106 return host1x_opcode_imm(host1x_uclass_incr_syncpt_r(),
107 host1x_class_host_incr_syncpt(cond, indx));
110 static inline u32 host1x_opcode_restart(unsigned address)
112 return (5 << 28) | (address >> 4);
115 static inline u32 host1x_opcode_gather(unsigned count)
117 return (6 << 28) | count;
120 static inline u32 host1x_opcode_gather_nonincr(unsigned offset, unsigned count)
122 return (6 << 28) | (offset << 16) | BIT(15) | count;
125 static inline u32 host1x_opcode_gather_incr(unsigned offset, unsigned count)
127 return (6 << 28) | (offset << 16) | BIT(15) | BIT(14) | count;
130 #define HOST1X_OPCODE_NOP host1x_opcode_nonincr(0, 0)
132 #endif