GNU Linux-libre 4.14.266-gnu1
[releases.git] / drivers / staging / media / atomisp / pci / atomisp2 / css2400 / hive_isp_css_include / device_access / device_access.h
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 extern void device_set_base_address(
79         const sys_address               base_addr);
80
81
82 /*! Get the (sub)system base address
83
84  \return base_address,
85  */
86 extern sys_address device_get_base_address(void);
87
88 /*! Read an 8-bit value from a device register or memory in the device
89
90  \param addr[in]                        Local address
91
92  \return device[addr]
93  */
94 extern uint8_t ia_css_device_load_uint8(
95         const hrt_address               addr);
96
97 /*! Read a 16-bit value from a device register or memory in the device
98
99  \param addr[in]                        Local address
100
101  \return device[addr]
102  */
103 extern uint16_t ia_css_device_load_uint16(
104         const hrt_address               addr);
105
106 /*! Read a 32-bit value from a device register or memory in the device
107
108  \param addr[in]                        Local address
109
110  \return device[addr]
111  */
112 extern uint32_t ia_css_device_load_uint32(
113         const hrt_address               addr);
114
115 /*! Read a 64-bit value from a device register or memory in the device
116
117  \param addr[in]                        Local address
118
119  \return device[addr]
120  */
121 extern uint64_t ia_css_device_load_uint64(
122         const hrt_address               addr);
123
124 /*! Write an 8-bit value to a device register or memory in the device
125
126  \param addr[in]                        Local address
127  \param data[in]                        value
128
129  \return none, device[addr] = value
130  */
131 extern void ia_css_device_store_uint8(
132         const hrt_address               addr,
133         const uint8_t                   data);
134
135 /*! Write a 16-bit value to a device register or memory in the device
136
137  \param addr[in]                        Local address
138  \param data[in]                        value
139
140  \return none, device[addr] = value
141  */
142 extern void ia_css_device_store_uint16(
143         const hrt_address               addr,
144         const uint16_t                  data);
145
146 /*! Write a 32-bit value to a device register or memory in the device
147
148  \param addr[in]                        Local address
149  \param data[in]                        value
150
151  \return none, device[addr] = value
152  */
153 extern void ia_css_device_store_uint32(
154         const hrt_address               addr,
155         const uint32_t                  data);
156
157 /*! Write a 64-bit value to a device register or memory in the device
158
159  \param addr[in]                        Local address
160  \param data[in]                        value
161
162  \return none, device[addr] = value
163  */
164 extern void ia_css_device_store_uint64(
165         const hrt_address               addr,
166         const uint64_t                  data);
167
168 /*! Read an array of bytes from device registers or memory in the device
169
170  \param addr[in]                        Local address
171  \param data[out]                       pointer to the destination array
172  \param size[in]                        number of bytes to read
173
174  \return none
175  */
176 extern void ia_css_device_load(
177         const hrt_address               addr,
178         void                                    *data,
179         const size_t                    size);
180
181 /*! Write an array of bytes to device registers or memory in the device
182
183  \param addr[in]                        Local address
184  \param data[in]                        pointer to the source array
185  \param size[in]                        number of bytes to write
186
187  \return none
188  */
189 extern void ia_css_device_store(
190         const hrt_address               addr,
191         const void                              *data,
192         const size_t                    size);
193
194 #endif /* __DEVICE_ACCESS_H_INCLUDED__ */