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