1 /* SPDX-License-Identifier: GPL-2.0 */
2 /*
3  * Support for Intel Camera Imaging ISP subsystem.
4  * Copyright (c) 2010-2015, Intel Corporation.
5  *
6  * This program is free software; you can redistribute it and/or modify it
7  * under the terms and conditions of the GNU General Public License,
8  * version 2, as published by the Free Software Foundation.
9  *
10  * This program is distributed in the hope it will be useful, but WITHOUT
11  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
13  * more details.
14  */
15 
16 #ifndef __SP_LOCAL_H_INCLUDED__
17 #define __SP_LOCAL_H_INCLUDED__
18 
19 #include <type_support.h>
20 #include "sp_global.h"
21 
22 struct sp_state_s {
23 	int		pc;
24 	int		status_register;
25 	bool	is_broken;
26 	bool	is_idle;
27 	bool	is_sleeping;
28 	bool	is_stalling;
29 };
30 
31 struct sp_stall_s {
32 	bool	fifo0;
33 	bool	fifo1;
34 	bool	fifo2;
35 	bool	fifo3;
36 	bool	fifo4;
37 	bool	fifo5;
38 	bool	fifo6;
39 	bool	fifo7;
40 	bool	fifo8;
41 	bool	fifo9;
42 	bool	fifoa;
43 	bool	dmem;
44 	bool	control_master;
45 	bool	icache_master;
46 };
47 
48 #define sp_address_of(var)	(HIVE_ADDR_ ## var)
49 
50 /*
51  * deprecated
52  */
53 #define store_sp_int(var, value) \
54 	sp_dmem_store_uint32(SP0_ID, (unsigned int)sp_address_of(var), \
55 		(uint32_t)(value))
56 
57 #define store_sp_ptr(var, value) \
58 	sp_dmem_store_uint32(SP0_ID, (unsigned int)sp_address_of(var), \
59 		(uint32_t)(value))
60 
61 #define load_sp_uint(var) \
62 	sp_dmem_load_uint32(SP0_ID, (unsigned int)sp_address_of(var))
63 
64 #define load_sp_array_uint8(array_name, index) \
65 	sp_dmem_load_uint8(SP0_ID, (unsigned int)sp_address_of(array_name) + \
66 		(index) * sizeof(uint8_t))
67 
68 #define load_sp_array_uint16(array_name, index) \
69 	sp_dmem_load_uint16(SP0_ID, (unsigned int)sp_address_of(array_name) + \
70 		(index) * sizeof(uint16_t))
71 
72 #define load_sp_array_uint(array_name, index) \
73 	sp_dmem_load_uint32(SP0_ID, (unsigned int)sp_address_of(array_name) + \
74 		(index) * sizeof(uint32_t))
75 
76 #define store_sp_var(var, data, bytes) \
77 	sp_dmem_store(SP0_ID, (unsigned int)sp_address_of(var), data, bytes)
78 
79 #define store_sp_array_uint8(array_name, index, value) \
80 	sp_dmem_store_uint8(SP0_ID, (unsigned int)sp_address_of(array_name) + \
81 		(index) * sizeof(uint8_t), value)
82 
83 #define store_sp_array_uint16(array_name, index, value) \
84 	sp_dmem_store_uint16(SP0_ID, (unsigned int)sp_address_of(array_name) + \
85 		(index) * sizeof(uint16_t), value)
86 
87 #define store_sp_array_uint(array_name, index, value) \
88 	sp_dmem_store_uint32(SP0_ID, (unsigned int)sp_address_of(array_name) + \
89 		(index) * sizeof(uint32_t), value)
90 
91 #define store_sp_var_with_offset(var, offset, data, bytes) \
92 	sp_dmem_store(SP0_ID, (unsigned int)sp_address_of(var) + \
93 		offset, data, bytes)
94 
95 #define load_sp_var(var, data, bytes) \
96 	sp_dmem_load(SP0_ID, (unsigned int)sp_address_of(var), data, bytes)
97 
98 #define load_sp_var_with_offset(var, offset, data, bytes) \
99 	sp_dmem_load(SP0_ID, (unsigned int)sp_address_of(var) + offset, \
100 		data, bytes)
101 
102 #endif /* __SP_LOCAL_H_INCLUDED__ */
103