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 __ISP_PUBLIC_H_INCLUDED__
17 #define __ISP_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 ISP[ID]
23 
24  \param	ID[in]				SP identifier
25  \param	cnd[in]				predicate
26 
27  \return none, if(cnd) enable(ISP[ID].irq) else disable(ISP[ID].irq)
28  */
29 void cnd_isp_irq_enable(
30     const isp_ID_t		ID,
31     const bool			cnd);
32 
33 /*! Write to the status and control register of ISP[ID]
34 
35  \param	ID[in]				ISP identifier
36  \param	reg[in]				register index
37  \param value[in]			The data to be written
38 
39  \return none, ISP[ID].sc[reg] = value
40  */
41 STORAGE_CLASS_ISP_H void isp_ctrl_store(
42     const isp_ID_t		ID,
43     const unsigned int	reg,
44     const hrt_data		value);
45 
46 /*! Read from the status and control register of ISP[ID]
47 
48  \param	ID[in]				ISP identifier
49  \param	reg[in]				register index
50  \param value[in]			The data to be written
51 
52  \return ISP[ID].sc[reg]
53  */
54 STORAGE_CLASS_ISP_H hrt_data isp_ctrl_load(
55     const isp_ID_t		ID,
56     const unsigned int	reg);
57 
58 /*! Get the status of a bitfield in the control register of ISP[ID]
59 
60  \param	ID[in]				ISP identifier
61  \param	reg[in]				register index
62  \param bit[in]				The bit index to be checked
63 
64  \return  (ISP[ID].sc[reg] & (1<<bit)) != 0
65  */
66 STORAGE_CLASS_ISP_H bool isp_ctrl_getbit(
67     const isp_ID_t		ID,
68     const unsigned int	reg,
69     const unsigned int	bit);
70 
71 /*! Set a bitfield in the control register of ISP[ID]
72 
73  \param	ID[in]				ISP identifier
74  \param	reg[in]				register index
75  \param bit[in]				The bit index to be set
76 
77  \return none, ISP[ID].sc[reg] |= (1<<bit)
78  */
79 STORAGE_CLASS_ISP_H void isp_ctrl_setbit(
80     const isp_ID_t		ID,
81     const unsigned int	reg,
82     const unsigned int	bit);
83 
84 /*! Clear a bitfield in the control register of ISP[ID]
85 
86  \param	ID[in]				ISP identifier
87  \param	reg[in]				register index
88  \param bit[in]				The bit index to be set
89 
90  \return none, ISP[ID].sc[reg] &= ~(1<<bit)
91  */
92 STORAGE_CLASS_ISP_H void isp_ctrl_clearbit(
93     const isp_ID_t		ID,
94     const unsigned int	reg,
95     const unsigned int	bit);
96 
97 /*! Write to the DMEM of ISP[ID]
98 
99  \param	ID[in]				ISP 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, ISP[ID].dmem[addr...addr+size-1] = data
105  */
106 STORAGE_CLASS_ISP_H void isp_dmem_store(
107     const isp_ID_t		ID,
108     unsigned int		addr,
109     const void			*data,
110     const size_t		size);
111 
112 /*! Read from the DMEM of ISP[ID]
113 
114  \param	ID[in]				ISP 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 = ISP[ID].dmem[addr...addr+size-1]
120  */
121 STORAGE_CLASS_ISP_H void isp_dmem_load(
122     const isp_ID_t		ID,
123     const unsigned int	addr,
124     void				*data,
125     const size_t		size);
126 
127 /*! Write a 32-bit datum to the DMEM of ISP[ID]
128 
129  \param	ID[in]				ISP 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, ISP[ID].dmem[addr] = data
135  */
136 STORAGE_CLASS_ISP_H void isp_dmem_store_uint32(
137     const isp_ID_t		ID,
138     unsigned int		addr,
139     const uint32_t		data);
140 
141 /*! Load a 32-bit datum from the DMEM of ISP[ID]
142 
143  \param	ID[in]				ISP identifier
144  \param	addr[in]			the address in DMEM
145  \param data[in]			The data to be read
146  \param size[in]			The size(in bytes) of the data to be read
147 
148  \return none, data = ISP[ID].dmem[addr]
149  */
150 STORAGE_CLASS_ISP_H uint32_t isp_dmem_load_uint32(
151     const isp_ID_t		ID,
152     const unsigned int	addr);
153 
154 /*! Concatenate the LSW and MSW into a double precision word
155 
156  \param	x0[in]				Integer containing the LSW
157  \param	x1[in]				Integer containing the MSW
158 
159  \return x0 | (x1 << bits_per_vector_element)
160  */
161 STORAGE_CLASS_ISP_H uint32_t isp_2w_cat_1w(
162     const u16		x0,
163     const uint16_t		x1);
164 
165 unsigned int isp_is_ready(isp_ID_t ID);
166 
167 unsigned int isp_is_sleeping(isp_ID_t ID);
168 
169 void isp_start(isp_ID_t ID);
170 
171 void isp_wake(isp_ID_t ID);
172 
173 #endif /* __ISP_PUBLIC_H_INCLUDED__ */
174