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