GNU Linux-libre 4.14.290-gnu1
[releases.git] / drivers / staging / media / atomisp / pci / atomisp2 / css2400 / hive_isp_css_common / system_global.h
1 /*
2  * Support for Intel Camera Imaging ISP subsystem.
3  * Copyright (c) 2015, Intel Corporation.
4  *
5  * This program is free software; you can redistribute it and/or modify it
6  * under the terms and conditions of the GNU General Public License,
7  * version 2, as published by the Free Software Foundation.
8  *
9  * This program is distributed in the hope it will be useful, but WITHOUT
10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
12  * more details.
13  */
14
15 #ifndef __SYSTEM_GLOBAL_H_INCLUDED__
16 #define __SYSTEM_GLOBAL_H_INCLUDED__
17
18 #include <hive_isp_css_defs.h>
19 #include <type_support.h>
20
21 /*
22  * The longest allowed (uninteruptible) bus transfer, does not
23  * take stalling into account
24  */
25 #define HIVE_ISP_MAX_BURST_LENGTH       1024
26
27 /*
28  * Maximum allowed burst length in words for the ISP DMA
29  */
30 #define ISP_DMA_MAX_BURST_LENGTH        128
31
32 /*
33  * Create a list of HAS and IS properties that defines the system
34  *
35  * The configuration assumes the following
36  * - The system is hetereogeneous; Multiple cells and devices classes
37  * - The cell and device instances are homogeneous, each device type
38  *   belongs to the same class
39  * - Device instances supporting a subset of the class capabilities are
40  *   allowed
41  *
42  * We could manage different device classes through the enumerated
43  * lists (C) or the use of classes (C++), but that is presently not
44  * fully supported
45  *
46  * N.B. the 3 input formatters are of 2 different classess
47  */
48
49 #define IS_ISP_2400_SYSTEM
50 /*
51  * Since this file is visible everywhere and the system definition
52  * macros are not, detect the separate definitions for {host, SP, ISP}
53  *
54  * The 2401 system has the nice property that it uses a vanilla 2400 SP
55  * so the SP will believe it is a 2400 system rather than 2401...
56  */
57 //#if defined(SYSTEM_hive_isp_css_2401_system) || defined(__isp2401_mamoiada) || defined(__scalar_processor_2401)
58 #if defined(SYSTEM_hive_isp_css_2401_system) || defined(__isp2401_mamoiada)
59 #define IS_ISP_2401_MAMOIADA_SYSTEM
60 #define HAS_ISP_2401_MAMOIADA
61 #define HAS_SP_2400
62 //#elif defined(SYSTEM_hive_isp_css_2400_system) || defined(__isp2400_mamoiada) || defined(__scalar_processor_2400)
63 #elif defined(SYSTEM_hive_isp_css_2400_system) || defined(__isp2400_mamoiada)
64 #define IS_ISP_2400_MAMOIADA_SYSTEM
65 #define HAS_ISP_2400_MAMOIADA
66 #define HAS_SP_2400
67 #else
68 #error "system_global.h: 2400_SYSTEM must be one of {2400, 2401 }"
69 #endif
70
71 #define USE_INPUT_SYSTEM_VERSION_2
72
73 #define HAS_MMU_VERSION_2
74 #define HAS_DMA_VERSION_2
75 #define HAS_GDC_VERSION_2
76 #define HAS_VAMEM_VERSION_2
77 #define HAS_HMEM_VERSION_1
78 #define HAS_BAMEM_VERSION_2
79 #define HAS_IRQ_VERSION_2
80 #define HAS_IRQ_MAP_VERSION_2
81 #define HAS_INPUT_FORMATTER_VERSION_2
82 /* 2401: HAS_INPUT_SYSTEM_VERSION_2401 */
83 #define HAS_INPUT_SYSTEM_VERSION_2
84 #define HAS_BUFFERED_SENSOR
85 #define HAS_FIFO_MONITORS_VERSION_2
86 /* #define HAS_GP_REGS_VERSION_2 */
87 #define HAS_GP_DEVICE_VERSION_2
88 #define HAS_GPIO_VERSION_1
89 #define HAS_TIMED_CTRL_VERSION_1
90 #define HAS_RX_VERSION_2
91
92 #define DMA_DDR_TO_VAMEM_WORKAROUND
93 #define DMA_DDR_TO_HMEM_WORKAROUND
94
95 /*
96  * Semi global. "HRT" is accessible from SP, but the HRT types do not fully apply
97  */
98 #define HRT_VADDRESS_WIDTH      32
99 //#define HRT_ADDRESS_WIDTH     64              /* Surprise, this is a local property*/
100 #define HRT_DATA_WIDTH          32
101
102 #define SIZEOF_HRT_REG          (HRT_DATA_WIDTH>>3)
103 #define HIVE_ISP_CTRL_DATA_BYTES (HIVE_ISP_CTRL_DATA_WIDTH/8)
104
105 /* The main bus connecting all devices */
106 #define HRT_BUS_WIDTH           HIVE_ISP_CTRL_DATA_WIDTH
107 #define HRT_BUS_BYTES           HIVE_ISP_CTRL_DATA_BYTES
108
109 /* per-frame parameter handling support */
110 #define SH_CSS_ENABLE_PER_FRAME_PARAMS
111
112 typedef uint32_t                        hrt_bus_align_t;
113
114 /*
115  * Enumerate the devices, device access through the API is by ID, through the DLI by address
116  * The enumerator terminators are used to size the wiring arrays and as an exception value.
117  */
118 typedef enum {
119         DDR0_ID = 0,
120         N_DDR_ID
121 } ddr_ID_t;
122
123 typedef enum {
124         ISP0_ID = 0,
125         N_ISP_ID
126 } isp_ID_t;
127
128 typedef enum {
129         SP0_ID = 0,
130         N_SP_ID
131 } sp_ID_t;
132
133 #if defined (IS_ISP_2401_MAMOIADA_SYSTEM)
134 typedef enum {
135         MMU0_ID = 0,
136         MMU1_ID,
137         N_MMU_ID
138 } mmu_ID_t;
139 #elif defined (IS_ISP_2400_MAMOIADA_SYSTEM)
140 typedef enum {
141         MMU0_ID = 0,
142         MMU1_ID,
143         N_MMU_ID
144 } mmu_ID_t;
145 #else
146 #error "system_global.h: SYSTEM must be one of {2400, 2401}"
147 #endif
148
149 typedef enum {
150         DMA0_ID = 0,
151         N_DMA_ID
152 } dma_ID_t;
153
154 typedef enum {
155         GDC0_ID = 0,
156         GDC1_ID,
157         N_GDC_ID
158 } gdc_ID_t;
159
160 #define N_GDC_ID_CPP 2 // this extra define is needed because we want to use it also in the preprocessor, and that doesn't work with enums.
161
162 typedef enum {
163         VAMEM0_ID = 0,
164         VAMEM1_ID,
165         VAMEM2_ID,
166         N_VAMEM_ID
167 } vamem_ID_t;
168
169 typedef enum {
170         BAMEM0_ID = 0,
171         N_BAMEM_ID
172 } bamem_ID_t;
173
174 typedef enum {
175         HMEM0_ID = 0,
176         N_HMEM_ID
177 } hmem_ID_t;
178
179 /*
180 typedef enum {
181         IRQ0_ID = 0,
182         N_IRQ_ID
183 } irq_ID_t;
184 */
185
186 typedef enum {
187         IRQ0_ID = 0,    // GP IRQ block
188         IRQ1_ID,                // Input formatter
189         IRQ2_ID,                // input system
190         IRQ3_ID,                // input selector
191         N_IRQ_ID
192 } irq_ID_t;
193
194 typedef enum {
195         FIFO_MONITOR0_ID = 0,
196         N_FIFO_MONITOR_ID
197 } fifo_monitor_ID_t;
198
199 /*
200  * Deprecated: Since all gp_reg instances are different
201  * and put in the address maps of other devices we cannot
202  * enumerate them as that assumes the instrances are the
203  * same.
204  *
205  * We define a single GP_DEVICE containing all gp_regs
206  * w.r.t. a single base address
207  *
208 typedef enum {
209         GP_REGS0_ID = 0,
210         N_GP_REGS_ID
211 } gp_regs_ID_t;
212  */
213 typedef enum {
214         GP_DEVICE0_ID = 0,
215         N_GP_DEVICE_ID
216 } gp_device_ID_t;
217
218 typedef enum {
219         GP_TIMER0_ID = 0,
220         GP_TIMER1_ID,
221         GP_TIMER2_ID,
222         GP_TIMER3_ID,
223         GP_TIMER4_ID,
224         GP_TIMER5_ID,
225         GP_TIMER6_ID,
226         GP_TIMER7_ID,
227         N_GP_TIMER_ID
228 } gp_timer_ID_t;
229
230 typedef enum {
231         GPIO0_ID = 0,
232         N_GPIO_ID
233 } gpio_ID_t;
234
235 typedef enum {
236         TIMED_CTRL0_ID = 0,
237         N_TIMED_CTRL_ID
238 } timed_ctrl_ID_t;
239
240 typedef enum {
241         INPUT_FORMATTER0_ID = 0,
242         INPUT_FORMATTER1_ID,
243         INPUT_FORMATTER2_ID,
244         INPUT_FORMATTER3_ID,
245         N_INPUT_FORMATTER_ID
246 } input_formatter_ID_t;
247
248 /* The IF RST is outside the IF */
249 #define INPUT_FORMATTER0_SRST_OFFSET    0x0824
250 #define INPUT_FORMATTER1_SRST_OFFSET    0x0624
251 #define INPUT_FORMATTER2_SRST_OFFSET    0x0424
252 #define INPUT_FORMATTER3_SRST_OFFSET    0x0224
253
254 #define INPUT_FORMATTER0_SRST_MASK              0x0001
255 #define INPUT_FORMATTER1_SRST_MASK              0x0002
256 #define INPUT_FORMATTER2_SRST_MASK              0x0004
257 #define INPUT_FORMATTER3_SRST_MASK              0x0008
258
259 typedef enum {
260         INPUT_SYSTEM0_ID = 0,
261         N_INPUT_SYSTEM_ID
262 } input_system_ID_t;
263
264 typedef enum {
265         RX0_ID = 0,
266         N_RX_ID
267 } rx_ID_t;
268
269 typedef enum {
270         MIPI_PORT0_ID = 0,
271         MIPI_PORT1_ID,
272         MIPI_PORT2_ID,
273         N_MIPI_PORT_ID
274 } mipi_port_ID_t;
275
276 #define N_RX_CHANNEL_ID         4
277
278 /* Generic port enumeration with an internal port type ID */
279 typedef enum {
280         CSI_PORT0_ID = 0,
281         CSI_PORT1_ID,
282         CSI_PORT2_ID,
283         TPG_PORT0_ID,
284         PRBS_PORT0_ID,
285         FIFO_PORT0_ID,
286         MEMORY_PORT0_ID,
287         N_INPUT_PORT_ID
288 } input_port_ID_t;
289
290 typedef enum {
291         CAPTURE_UNIT0_ID = 0,
292         CAPTURE_UNIT1_ID,
293         CAPTURE_UNIT2_ID,
294         ACQUISITION_UNIT0_ID,
295         DMA_UNIT0_ID,
296         CTRL_UNIT0_ID,
297         GPREGS_UNIT0_ID,
298         FIFO_UNIT0_ID,
299         IRQ_UNIT0_ID,
300         N_SUB_SYSTEM_ID
301 } sub_system_ID_t;
302
303 #define N_CAPTURE_UNIT_ID               3
304 #define N_ACQUISITION_UNIT_ID   1
305 #define N_CTRL_UNIT_ID                  1
306
307 enum ia_css_isp_memories {
308         IA_CSS_ISP_PMEM0 = 0,
309         IA_CSS_ISP_DMEM0,
310         IA_CSS_ISP_VMEM0,
311         IA_CSS_ISP_VAMEM0,
312         IA_CSS_ISP_VAMEM1,
313         IA_CSS_ISP_VAMEM2,
314         IA_CSS_ISP_HMEM0,
315         IA_CSS_SP_DMEM0,
316         IA_CSS_DDR,
317         N_IA_CSS_MEMORIES
318 };
319 #define IA_CSS_NUM_MEMORIES 9
320 /* For driver compatability */
321 #define N_IA_CSS_ISP_MEMORIES   IA_CSS_NUM_MEMORIES
322 #define IA_CSS_NUM_ISP_MEMORIES IA_CSS_NUM_MEMORIES
323
324 #if 0
325 typedef enum {
326         dev_chn, /* device channels, external resource */
327         ext_mem, /* external memories */
328         int_mem, /* internal memories */
329         int_chn  /* internal channels, user defined */
330 } resource_type_t;
331
332 /* if this enum is extended with other memory resources, pls also extend the function resource_to_memptr() */
333 typedef enum {
334         vied_nci_dev_chn_dma_ext0,
335         int_mem_vmem0,
336         int_mem_dmem0
337 } resource_id_t;
338
339 /* enum listing the different memories within a program group.
340    This enum is used in the mem_ptr_t type */
341 typedef enum {
342         buf_mem_invalid = 0,
343         buf_mem_vmem_prog0,
344         buf_mem_dmem_prog0
345 } buf_mem_t;
346
347 #endif
348 #endif /* __SYSTEM_GLOBAL_H_INCLUDED__ */