1 /* SPDX-License-Identifier: GPL-2.0 */
2 /*
3  * Support for Intel Camera Imaging ISP subsystem.
4  * Copyright (c) 2015, Intel Corporation.
5  */
6 
7 #ifndef __SP_PUBLIC_H_INCLUDED__
8 #define __SP_PUBLIC_H_INCLUDED__
9 
10 #include <type_support.h>
11 #include "system_local.h"
12 
13 /*! Enable or disable the program complete irq signal of SP[ID]
14 
15  \param	ID[in]				SP identifier
16  \param	cnd[in]				predicate
17 
18  \return none, if(cnd) enable(SP[ID].irq) else disable(SP[ID].irq)
19  */
20 void cnd_sp_irq_enable(
21     const sp_ID_t		ID,
22     const bool			cnd);
23 
24 /*! Write to the status and control register of SP[ID]
25 
26  \param	ID[in]				SP identifier
27  \param	reg[in]				register index
28  \param value[in]			The data to be written
29 
30  \return none, SP[ID].sc[reg] = value
31  */
32 STORAGE_CLASS_SP_H void sp_ctrl_store(
33     const sp_ID_t		ID,
34     const hrt_address	reg,
35     const hrt_data		value);
36 
37 /*! Read from the status and control register of SP[ID]
38 
39  \param	ID[in]				SP identifier
40  \param	reg[in]				register index
41  \param value[in]			The data to be written
42 
43  \return SP[ID].sc[reg]
44  */
45 STORAGE_CLASS_SP_H hrt_data sp_ctrl_load(
46     const sp_ID_t		ID,
47     const hrt_address	reg);
48 
49 /*! Get the status of a bitfield in the control register of SP[ID]
50 
51  \param	ID[in]				SP identifier
52  \param	reg[in]				register index
53  \param bit[in]				The bit index to be checked
54 
55  \return  (SP[ID].sc[reg] & (1<<bit)) != 0
56  */
57 STORAGE_CLASS_SP_H bool sp_ctrl_getbit(
58     const sp_ID_t		ID,
59     const hrt_address	reg,
60     const unsigned int	bit);
61 
62 /*! Set a bitfield in the control register of SP[ID]
63 
64  \param	ID[in]				SP identifier
65  \param	reg[in]				register index
66  \param bit[in]				The bit index to be set
67 
68  \return none, SP[ID].sc[reg] |= (1<<bit)
69  */
70 STORAGE_CLASS_SP_H void sp_ctrl_setbit(
71     const sp_ID_t		ID,
72     const hrt_address	reg,
73     const unsigned int	bit);
74 
75 /*! Clear a bitfield in the control register of SP[ID]
76 
77  \param	ID[in]				SP identifier
78  \param	reg[in]				register index
79  \param bit[in]				The bit index to be set
80 
81  \return none, SP[ID].sc[reg] &= ~(1<<bit)
82  */
83 STORAGE_CLASS_SP_H void sp_ctrl_clearbit(
84     const sp_ID_t		ID,
85     const hrt_address	reg,
86     const unsigned int	bit);
87 
88 /*! Write to the DMEM of SP[ID]
89 
90  \param	ID[in]				SP identifier
91  \param	addr[in]			the address in DMEM
92  \param data[in]			The data to be written
93  \param size[in]			The size(in bytes) of the data to be written
94 
95  \return none, SP[ID].dmem[addr...addr+size-1] = data
96  */
97 STORAGE_CLASS_SP_H void sp_dmem_store(
98     const sp_ID_t		ID,
99     hrt_address		addr,
100     const void			*data,
101     const size_t		size);
102 
103 /*! Read from the DMEM of SP[ID]
104 
105  \param	ID[in]				SP identifier
106  \param	addr[in]			the address in DMEM
107  \param data[in]			The data to be read
108  \param size[in]			The size(in bytes) of the data to be read
109 
110  \return none, data = SP[ID].dmem[addr...addr+size-1]
111  */
112 STORAGE_CLASS_SP_H void sp_dmem_load(
113     const sp_ID_t		ID,
114     const hrt_address	addr,
115     void			*data,
116     const size_t		size);
117 
118 /*! Write a 8-bit datum to the DMEM of SP[ID]
119 
120  \param	ID[in]				SP identifier
121  \param	addr[in]			the address in DMEM
122  \param data[in]			The data to be written
123  \param size[in]			The size(in bytes) of the data to be written
124 
125  \return none, SP[ID].dmem[addr...addr+size-1] = data
126  */
127 STORAGE_CLASS_SP_H void sp_dmem_store_uint8(
128     const sp_ID_t		ID,
129     hrt_address		addr,
130     const uint8_t		data);
131 
132 /*! Write a 16-bit datum to the DMEM of SP[ID]
133 
134  \param	ID[in]				SP identifier
135  \param	addr[in]			the address in DMEM
136  \param data[in]			The data to be written
137  \param size[in]			The size(in bytes) of the data to be written
138 
139  \return none, SP[ID].dmem[addr...addr+size-1] = data
140  */
141 STORAGE_CLASS_SP_H void sp_dmem_store_uint16(
142     const sp_ID_t		ID,
143     hrt_address		addr,
144     const uint16_t		data);
145 
146 /*! Write a 32-bit datum to the DMEM of SP[ID]
147 
148  \param	ID[in]				SP identifier
149  \param	addr[in]			the address in DMEM
150  \param data[in]			The data to be written
151  \param size[in]			The size(in bytes) of the data to be written
152 
153  \return none, SP[ID].dmem[addr...addr+size-1] = data
154  */
155 STORAGE_CLASS_SP_H void sp_dmem_store_uint32(
156     const sp_ID_t		ID,
157     hrt_address		addr,
158     const uint32_t		data);
159 
160 /*! Load a 8-bit datum from the DMEM of SP[ID]
161 
162  \param	ID[in]				SP identifier
163  \param	addr[in]			the address in DMEM
164  \param data[in]			The data to be read
165  \param size[in]			The size(in bytes) of the data to be read
166 
167  \return none, data = SP[ID].dmem[addr...addr+size-1]
168  */
169 STORAGE_CLASS_SP_H uint8_t sp_dmem_load_uint8(
170     const sp_ID_t		ID,
171     const hrt_address	addr);
172 
173 /*! Load a 16-bit datum from the DMEM of SP[ID]
174 
175  \param	ID[in]				SP identifier
176  \param	addr[in]			the address in DMEM
177  \param data[in]			The data to be read
178  \param size[in]			The size(in bytes) of the data to be read
179 
180  \return none, data = SP[ID].dmem[addr...addr+size-1]
181  */
182 STORAGE_CLASS_SP_H uint16_t sp_dmem_load_uint16(
183     const sp_ID_t		ID,
184     const hrt_address	addr);
185 
186 /*! Load a 32-bit datum from the DMEM of SP[ID]
187 
188  \param	ID[in]				SP identifier
189  \param	addr[in]			the address in DMEM
190  \param data[in]			The data to be read
191  \param size[in]			The size(in bytes) of the data to be read
192 
193  \return none, data = SP[ID].dmem[addr...addr+size-1]
194  */
195 STORAGE_CLASS_SP_H uint32_t sp_dmem_load_uint32(
196     const sp_ID_t		ID,
197     const hrt_address	addr);
198 
199 #endif /* __SP_PUBLIC_H_INCLUDED__ */
200