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