Commit | Line | Data |
---|---|---|
81eb669b DC |
1 | /* Cypress Antioch HAL for OMAP KERNEL header file (cyashalomapkernel.h) |
2 | ## =========================== | |
3 | ## Copyright (C) 2010 Cypress Semiconductor | |
4 | ## | |
5 | ## This program is free software; you can redistribute it and/or | |
6 | ## modify it under the terms of the GNU General Public License | |
7 | ## as published by the Free Software Foundation; either version 2 | |
8 | ## of the License, or (at your option) any later version. | |
9 | ## | |
10 | ## This program is distributed in the hope that it will be useful, | |
11 | ## but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 | ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
13 | ## GNU General Public License for more details. | |
14 | ## | |
15 | ## You should have received a copy of the GNU General Public License | |
16 | ## along with this program; if not, write to the Free Software | |
17 | ## Foundation, Inc., 51 Franklin Street, Fifth Floor | |
18 | ## Boston, MA 02110-1301, USA. | |
19 | ## =========================== | |
20 | */ | |
21 | ||
22 | /* | |
25985edc | 23 | * This file contains the definition of the hardware abstraction |
81eb669b DC |
24 | * layer on OMAP3430 talking to the West Bridge Astoria device |
25 | */ | |
26 | ||
27 | ||
28 | #ifndef _INCLUDED_CYASHALOMAP_KERNEL_H_ | |
29 | #define _INCLUDED_CYASHALOMAP_KERNEL_H_ | |
30 | ||
31 | #include <linux/kernel.h> | |
32 | #include <linux/module.h> | |
33 | #include <linux/wait.h> | |
34 | #include <linux/string.h> | |
35 | /* include does not seem to work | |
36 | * moving for patch submission | |
37 | #include <mach/gpmc.h> | |
38 | */ | |
39 | #include <linux/../../arch/arm/plat-omap/include/plat/gpmc.h> | |
40 | typedef struct cy_as_hal_sleep_channel_t { | |
0769c38d DC |
41 | wait_queue_head_t wq; |
42 | } cy_as_hal_sleep_channel; | |
81eb669b DC |
43 | |
44 | /* moved to staging location, eventual location | |
45 | * considered is here | |
46 | #include <mach/westbridge/cyashaldef.h> | |
47 | #include <linux/westbridge/cyastypes.h> | |
48 | #include <linux/westbridge/cyas_cplus_start.h> | |
49 | */ | |
50 | #include "../cyashaldef.h" | |
51 | #include "../../../../../../../include/linux/westbridge/cyastypes.h" | |
52 | #include "../../../../../../../include/linux/westbridge/cyas_cplus_start.h" | |
53 | #include "cyasomapdev_kernel.h" | |
54 | ||
55 | /* | |
56 | * Below are the data structures that must be defined by the HAL layer | |
57 | */ | |
58 | ||
59 | /* | |
60 | * The HAL layer must define a TAG for identifying a specific Astoria | |
61 | * device in the system. In this case the tag is a void * which is | |
62 | * really an OMAP device pointer | |
63 | */ | |
0769c38d | 64 | typedef void *cy_as_hal_device_tag; |
81eb669b DC |
65 | |
66 | ||
67 | /* This must be included after the CyAsHalDeviceTag type is defined */ | |
68 | ||
69 | /* moved to staging location, eventual location | |
70 | * considered is here | |
71 | * #include <linux/westbridge/cyashalcb.h> | |
72 | */ | |
73 | #include "../../../../../../../include/linux/westbridge/cyashalcb.h" | |
74 | /* | |
75 | * Below are the functions that communicate with the West Bridge | |
76 | * device. These are system dependent and must be defined by | |
77 | * the HAL layer for a given system. | |
78 | */ | |
79 | ||
80 | /* | |
81 | * This function must be defined to write a register within the Antioch | |
82 | * device. The addr value is the address of the register to write with | |
83 | * respect to the base address of the Antioch device. | |
84 | */ | |
85 | void | |
86 | cy_as_hal_write_register(cy_as_hal_device_tag tag, | |
0769c38d | 87 | uint16_t addr, uint16_t data); |
81eb669b DC |
88 | |
89 | /* | |
90 | * This function must be defined to read a register from | |
91 | * the west bridge device. The addr value is the address of | |
92 | * the register to read with respect to the base address | |
93 | * of the west bridge device. | |
94 | */ | |
95 | uint16_t | |
0769c38d | 96 | cy_as_hal_read_register(cy_as_hal_device_tag tag, uint16_t addr); |
81eb669b DC |
97 | |
98 | /* | |
99 | * This function must be defined to transfer a block of data | |
100 | * to the west bridge device. This function can use the burst write | |
101 | * (DMA) capabilities of Antioch to do this, or it can just copy | |
102 | * the data using writes. | |
103 | */ | |
104 | void | |
105 | cy_as_hal_dma_setup_write(cy_as_hal_device_tag tag, | |
0769c38d | 106 | uint8_t ep, void *buf, uint32_t size, uint16_t maxsize); |
81eb669b DC |
107 | |
108 | /* | |
109 | * This function must be defined to transfer a block of data | |
110 | * from the Antioch device. This function can use the burst | |
111 | * read (DMA) capabilities of Antioch to do this, or it can | |
112 | * just copy the data using reads. | |
113 | */ | |
114 | void | |
115 | cy_as_hal_dma_setup_read(cy_as_hal_device_tag tag, uint8_t ep, | |
0769c38d | 116 | void *buf, uint32_t size, uint16_t maxsize); |
81eb669b DC |
117 | |
118 | /* | |
119 | * This function must be defined to cancel any pending DMA request. | |
120 | */ | |
121 | void | |
0769c38d | 122 | cy_as_hal_dma_cancel_request(cy_as_hal_device_tag tag, uint8_t ep); |
81eb669b DC |
123 | |
124 | /* | |
125 | * This function must be defined to allow the Antioch API to | |
126 | * register a callback function that is called when a DMA transfer | |
127 | * is complete. | |
128 | */ | |
129 | void | |
130 | cy_as_hal_dma_register_callback(cy_as_hal_device_tag tag, | |
0769c38d | 131 | cy_as_hal_dma_complete_callback cb); |
81eb669b DC |
132 | |
133 | /* | |
134 | * This function must be defined to return the maximum size of DMA | |
135 | * request that can be handled on the given endpoint. The return | |
136 | * value should be the maximum size in bytes that the DMA module can | |
137 | * handle. | |
138 | */ | |
139 | uint32_t | |
140 | cy_as_hal_dma_max_request_size(cy_as_hal_device_tag tag, | |
0769c38d | 141 | cy_as_end_point_number_t ep); |
81eb669b DC |
142 | |
143 | /* | |
144 | * This function must be defined to set the state of the WAKEUP pin | |
145 | * on the Antioch device. Generally this is done via a GPIO of some | |
146 | * type. | |
147 | */ | |
148 | cy_bool | |
0769c38d | 149 | cy_as_hal_set_wakeup_pin(cy_as_hal_device_tag tag, cy_bool state); |
81eb669b DC |
150 | |
151 | /* | |
152 | * This function is called when the Antioch PLL loses lock, because | |
153 | * of a problem in the supply voltage or the input clock. | |
154 | */ | |
155 | void | |
0769c38d | 156 | cy_as_hal_pll_lock_loss_handler(cy_as_hal_device_tag tag); |
81eb669b DC |
157 | |
158 | ||
159 | /********************************************************************** | |
160 | * | |
161 | * Below are the functions that must be defined to provide the basic | |
162 | * operating system services required by the API. | |
163 | * | |
164 | ***********************************************************************/ | |
165 | ||
166 | /* | |
167 | * This function is required by the API to allocate memory. This function | |
168 | * is expected to work exactly like malloc(). | |
169 | */ | |
170 | void * | |
0769c38d | 171 | cy_as_hal_alloc(uint32_t cnt); |
81eb669b DC |
172 | |
173 | /* | |
174 | * This function is required by the API to free memory allocated with | |
175 | * CyAsHalAlloc(). This function is expected to work exacly like free(). | |
176 | */ | |
177 | void | |
0769c38d | 178 | cy_as_hal_free(void *mem_p); |
81eb669b DC |
179 | |
180 | /* | |
181 | * This function is required by the API to allocate memory during a | |
182 | * callback. This function must be able to provide storage at inturupt | |
183 | * time. | |
184 | */ | |
185 | void * | |
0769c38d | 186 | cy_as_hal_c_b_alloc(uint32_t cnt); |
81eb669b DC |
187 | |
188 | /* | |
189 | * This function is required by the API to free memory allocated with | |
190 | * CyAsCBHalAlloc(). | |
191 | */ | |
192 | void | |
0769c38d | 193 | cy_as_hal_c_b_free(void *ptr); |
81eb669b DC |
194 | |
195 | /* | |
196 | * This function is required to set a block of memory to a specific | |
197 | * value. This function is expected to work exactly like memset() | |
198 | */ | |
199 | void | |
0769c38d | 200 | cy_as_hal_mem_set(void *ptr, uint8_t value, uint32_t cnt); |
81eb669b DC |
201 | |
202 | /* | |
203 | * This function is expected to create a sleep channel. The data | |
204 | * structure that represents the sleep channel is given by the | |
205 | * pointer in the argument. | |
206 | */ | |
207 | cy_bool | |
0769c38d | 208 | cy_as_hal_create_sleep_channel(cy_as_hal_sleep_channel *channel); |
81eb669b DC |
209 | |
210 | /* | |
211 | * This function is expected to destroy a sleep channel. The data | |
212 | * structure that represents the sleep channel is given by | |
213 | * the pointer in the argument. | |
214 | */ | |
215 | ||
216 | ||
217 | cy_bool | |
0769c38d | 218 | cy_as_hal_destroy_sleep_channel(cy_as_hal_sleep_channel *channel); |
81eb669b DC |
219 | |
220 | cy_bool | |
0769c38d | 221 | cy_as_hal_sleep_on(cy_as_hal_sleep_channel *channel, uint32_t ms); |
81eb669b DC |
222 | |
223 | cy_bool | |
0769c38d | 224 | cy_as_hal_wake(cy_as_hal_sleep_channel *channel); |
81eb669b DC |
225 | |
226 | uint32_t | |
0769c38d | 227 | cy_as_hal_disable_interrupts(void); |
81eb669b DC |
228 | |
229 | void | |
230 | cy_as_hal_enable_interrupts(uint32_t); | |
231 | ||
232 | void | |
233 | cy_as_hal_sleep150(void); | |
234 | ||
235 | void | |
236 | cy_as_hal_sleep(uint32_t ms); | |
237 | ||
238 | cy_bool | |
239 | cy_as_hal_is_polling(void); | |
240 | ||
241 | void cy_as_hal_init_dev_registers(cy_as_hal_device_tag tag, | |
242 | cy_bool is_standby_wakeup); | |
243 | ||
244 | /* | |
245 | * required only in spi mode | |
246 | */ | |
247 | cy_bool cy_as_hal_sync_device_clocks(cy_as_hal_device_tag tag); | |
248 | ||
249 | void cy_as_hal_read_regs_before_standby(cy_as_hal_device_tag tag); | |
250 | ||
251 | ||
252 | #ifndef NDEBUG | |
253 | #define cy_as_hal_assert(cond) if (!(cond))\ | |
254 | printk(KERN_WARNING"assertion failed at %s:%d\n", __FILE__, __LINE__); | |
255 | #else | |
256 | #define cy_as_hal_assert(cond) | |
257 | #endif | |
258 | ||
259 | #define cy_as_hal_print_message printk | |
260 | ||
261 | /* removable debug printks */ | |
262 | #ifndef WESTBRIDGE_NDEBUG | |
263 | #define DBG_PRINT_ENABLED | |
264 | #endif | |
265 | ||
266 | /*#define MBOX_ACCESS_DBG_PRINT_ENABLED*/ | |
267 | ||
268 | ||
269 | #ifdef DBG_PRINT_ENABLED | |
270 | /* Debug printing enabled */ | |
271 | ||
272 | #define DBGPRN(...) printk(__VA_ARGS__) | |
273 | #define DBGPRN_FUNC_NAME printk("<1> %x:_func: %s\n", \ | |
274 | current->pid, __func__) | |
275 | ||
276 | #else | |
277 | /** NO DEBUG PRINTING **/ | |
278 | #define DBGPRN(...) | |
279 | #define DBGPRN_FUNC_NAME | |
280 | ||
281 | #endif | |
282 | ||
283 | /* | |
284 | CyAsMiscSetLogLevel(uint8_t level) | |
285 | { | |
0769c38d | 286 | debug_level = level; |
81eb669b DC |
287 | } |
288 | ||
289 | #ifdef CY_AS_LOG_SUPPORT | |
290 | ||
291 | void | |
292 | cy_as_log_debug_message(int level, const char *str) | |
293 | { | |
294 | if (level <= debug_level) | |
0769c38d | 295 | cy_as_hal_print_message("log %d: %s\n", level, str); |
81eb669b DC |
296 | } |
297 | */ | |
298 | ||
299 | ||
300 | /* | |
301 | * print buffer helper | |
302 | */ | |
303 | void cyashal_prn_buf(void *buf, uint16_t offset, int len); | |
304 | ||
305 | /* | |
306 | * These are the functions that are not part of the HAL layer, | |
307 | * but are required to be called for this HAL. | |
308 | */ | |
309 | int start_o_m_a_p_kernel(const char *pgm, | |
0769c38d DC |
310 | cy_as_hal_device_tag *tag, cy_bool debug); |
311 | int stop_o_m_a_p_kernel(const char *pgm, cy_as_hal_device_tag tag); | |
312 | int omap_start_intr(cy_as_hal_device_tag tag); | |
81eb669b DC |
313 | void cy_as_hal_set_ep_dma_mode(uint8_t ep, bool sg_xfer_enabled); |
314 | ||
315 | /* moved to staging location | |
316 | #include <linux/westbridge/cyas_cplus_end.h> | |
317 | */ | |
318 | #include "../../../../../../../include/linux/westbridge/cyas_cplus_start.h" | |
319 | #endif |