038cf3cf7c607b6fcaf35bd8f08a4d1234ad4aeb
[linux.git] /
1 #ifndef ISP2401
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 #else
16 /**
17 Support for Intel Camera Imaging ISP subsystem.
18 Copyright (c) 2010 - 2015, Intel Corporation.
19
20 This program is free software; you can redistribute it and/or modify it
21 under the terms and conditions of the GNU General Public License,
22 version 2, as published by the Free Software Foundation.
23
24 This program is distributed in the hope it will be useful, but WITHOUT
25 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
26 FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
27 more details.
28 */
29 #endif
30
31 #ifndef __DEVICE_ACCESS_H_INCLUDED__
32 #define __DEVICE_ACCESS_H_INCLUDED__
33
34 /*!
35  * \brief
36  * Define the public interface for physical system
37  * access functions to SRAM and registers. Access
38  * types are limited to those defined in <stdint.h>
39  * All accesses are aligned
40  *
41  * The address representation is private to the system
42  * and represented as/stored in "hrt_address".
43  *
44  * The system global address can differ by an offset;
45  * The device base address. This offset must be added
46  * by the implementation of the access function
47  *
48  * "store" is a transfer to the device
49  * "load" is a transfer from the device
50  */
51
52 #include <type_support.h>
53
54 /*
55  * User provided file that defines the system address types:
56  *      - hrt_address   a type that can hold the (sub)system address range
57  */
58 #include "system_types.h"
59 /*
60  * We cannot assume that the global system address size is the size of
61  * a pointer because a (say) 64-bit host can be simulated in a 32-bit
62  * environment. Only if the host environment is modelled as on the target
63  * we could use a pointer. Even then, prototyping may need to be done
64  * before the target environment is available. AS we cannot wait for that
65  * we are stuck with integer addresses
66  */
67
68 /*typedef       char *sys_address;*/
69 typedef hrt_address             sys_address;
70
71 /*! Set the (sub)system base address
72
73  \param base_addr[in]           The offset on which the (sub)system is located
74                                                         in the global address map
75
76  \return none,
77  */
78 void device_set_base_address(
79         const sys_address               base_addr);
80
81 /*! Get the (sub)system base address
82
83  \return base_address,
84  */
85 sys_address device_get_base_address(void);
86
87 /*! Read an 8-bit value from a device register or memory in the device
88
89  \param addr[in]                        Local address
90
91  \return device[addr]
92  */
93 uint8_t ia_css_device_load_uint8(
94         const hrt_address               addr);
95
96 /*! Read a 16-bit value from a device register or memory in the device
97
98  \param addr[in]                        Local address
99
100  \return device[addr]
101  */
102 uint16_t ia_css_device_load_uint16(
103         const hrt_address               addr);
104
105 /*! Read a 32-bit value from a device register or memory in the device
106
107  \param addr[in]                        Local address
108
109  \return device[addr]
110  */
111 uint32_t ia_css_device_load_uint32(
112         const hrt_address               addr);
113
114 /*! Read a 64-bit value from a device register or memory in the device
115
116  \param addr[in]                        Local address
117
118  \return device[addr]
119  */
120 uint64_t ia_css_device_load_uint64(
121         const hrt_address               addr);
122
123 /*! Write an 8-bit value to a device register or memory in the device
124
125  \param addr[in]                        Local address
126  \param data[in]                        value
127
128  \return none, device[addr] = value
129  */
130 void ia_css_device_store_uint8(
131         const hrt_address               addr,
132         const uint8_t                   data);
133
134 /*! Write a 16-bit value to a device register or memory in the device
135
136  \param addr[in]                        Local address
137  \param data[in]                        value
138
139  \return none, device[addr] = value
140  */
141 void ia_css_device_store_uint16(
142         const hrt_address               addr,
143         const uint16_t                  data);
144
145 /*! Write a 32-bit value to a device register or memory in the device
146
147  \param addr[in]                        Local address
148  \param data[in]                        value
149
150  \return none, device[addr] = value
151  */
152 void ia_css_device_store_uint32(
153         const hrt_address               addr,
154         const uint32_t                  data);
155
156 /*! Write a 64-bit value to a device register or memory in the device
157
158  \param addr[in]                        Local address
159  \param data[in]                        value
160
161  \return none, device[addr] = value
162  */
163 void ia_css_device_store_uint64(
164         const hrt_address               addr,
165         const uint64_t                  data);
166
167 /*! Read an array of bytes from device registers or memory in the device
168
169  \param addr[in]                        Local address
170  \param data[out]                       pointer to the destination array
171  \param size[in]                        number of bytes to read
172
173  \return none
174  */
175 void ia_css_device_load(
176         const hrt_address               addr,
177         void                                    *data,
178         const size_t                    size);
179
180 /*! Write an array of bytes to device registers or memory in the device
181
182  \param addr[in]                        Local address
183  \param data[in]                        pointer to the source array
184  \param size[in]                        number of bytes to write
185
186  \return none
187  */
188 void ia_css_device_store(
189         const hrt_address               addr,
190         const void                              *data,
191         const size_t                    size);
192
193 #endif /* __DEVICE_ACCESS_H_INCLUDED__ */