|
1 /* Cypress West Bridge HAL for beagleboard SPI Symbian header file (cyashalbeagleboard_spi.h) |
|
2 ## =========================== |
|
3 ## |
|
4 ## Copyright Cypress Semiconductor Corporation, 2006-2009, |
|
5 ## All Rights Reserved |
|
6 ## UNPUBLISHED, LICENSED SOFTWARE. |
|
7 ## |
|
8 ## CONFIDENTIAL AND PROPRIETARY INFORMATION |
|
9 ## WHICH IS THE PROPERTY OF CYPRESS. |
|
10 ## |
|
11 ## Use of this file is governed |
|
12 ## by the license agreement included in the file |
|
13 ## |
|
14 ## <install>/license/license.txt |
|
15 ## |
|
16 ## where <install> is the Cypress software |
|
17 ## installation root directory path. |
|
18 ## |
|
19 ## =========================== |
|
20 */ |
|
21 |
|
22 /* |
|
23 * This file contains the defintion of the hardware abstraction layer on beagleboard |
|
24 * talking to the West Bridge device through SPI interface |
|
25 */ |
|
26 |
|
27 |
|
28 #ifndef _INCLUDED_CYASHALBEAGLEBOARD_H_ |
|
29 #define _INCLUDED_CYASHALBEAGLEBOARD_H_ |
|
30 |
|
31 typedef struct CyAsHalSleepChannel_t { |
|
32 /* TODO: |
|
33 wait_queue_head_t wq ;*/ |
|
34 int wq ; |
|
35 } CyAsHalSleepChannel ; |
|
36 typedef CyAsHalSleepChannel CyAnHalSleepChannel; |
|
37 |
|
38 #include "cyastypes.h" |
|
39 #include "cyas_cplus_start.h" |
|
40 |
|
41 typedef enum CyAsHalInterfaceMode |
|
42 { |
|
43 CyAsHalCRAMMode = 0, |
|
44 CyAsHalSRAMMode = 1, |
|
45 CyAsHalADMMode = 2, |
|
46 CyAsHalPNANDLBD8Mode = 3, |
|
47 CyAsHalPNANDLBD16Mode = 4, |
|
48 CyAsHalPNANDSBD8Mode = 5, |
|
49 CyAsHalPNANDSBD16Mode = 6, |
|
50 CyAsHalSPIMode = 7, |
|
51 CyAsHalLNAMode = 8, |
|
52 CyAsHalUnknownMode = 9 |
|
53 } CyAsHalInterfaceMode; |
|
54 |
|
55 /************************************************************************************************* |
|
56 * |
|
57 * Below are the data structures that must be defined by the HAL layer |
|
58 * |
|
59 *************************************************************************************************/ |
|
60 |
|
61 /* |
|
62 * The HAL layer must define a TAG for identifying a specific West Bridge device in the system. |
|
63 * In this case the tag is a void * which is really an OMAP device pointer |
|
64 */ |
|
65 typedef void * CyAsHalDeviceTag ; |
|
66 typedef CyAsHalDeviceTag CyAnHalDeviceTag; |
|
67 |
|
68 /* This must be included after the CyAsHalDeviceTag type is defined */ |
|
69 #include "cyashalcb.h" |
|
70 |
|
71 /************************************************************************************************* |
|
72 * |
|
73 * Below are the functions that communicate with the West Bridge device. These are system dependent |
|
74 * and must be defined by the HAL layer for a given system. |
|
75 * |
|
76 *************************************************************************************************/ |
|
77 |
|
78 /* |
|
79 * This function must be defined to write a register within the West Bridge |
|
80 * device. The addr value is the address of the register to write with |
|
81 * respect to the base address of the West Bridge device. |
|
82 */ |
|
83 extern void |
|
84 CyAsHalWriteRegister(CyAsHalDeviceTag tag, uint16_t addr, uint16_t data) ; |
|
85 #define CyAnHalWriteRegister(tag, addr, data) CyAsHalWriteRegister((CyAsHalDeviceTag)(tag), (addr), (data)) |
|
86 |
|
87 /* |
|
88 * This function must be defined to read a register from the West Bridge |
|
89 * device. The addr value is the address of the register to read with |
|
90 * respect to the base address of the West Bridge device. |
|
91 */ |
|
92 uint16_t |
|
93 CyAsHalReadRegister(CyAsHalDeviceTag tag, uint16_t addr) ; |
|
94 #define CyAnHalReadRegister(tag, addr) CyAsHalReadRegister((CyAsHalDeviceTag)(tag), (addr)) |
|
95 |
|
96 /* |
|
97 * This function must be defined to transfer a block of data to the West Bridge device. This |
|
98 * function can use the burst write (DMA) capabilities of West Bridge to do this, or it can |
|
99 * just copy the data using writes. |
|
100 */ |
|
101 extern void |
|
102 CyAsHalDmaSetupWrite(CyAsHalDeviceTag tag, uint8_t ep, void *buf, uint32_t size, uint16_t maxsize) ; |
|
103 #define CyAnHalDmaSetupWrite(tag, ep, buf, sz, max) \ |
|
104 CyAsHalDmaSetupWrite((CyAsHalDeviceTag)(tag), (ep), (buf), (sz), (max)) |
|
105 |
|
106 /* |
|
107 * This function must be defined to transfer a block of data from the West Bridge device. This |
|
108 * function can use the burst read (DMA) capabilities of West Bridge to do this, or it can just |
|
109 * copy the data using reads. |
|
110 */ |
|
111 extern void |
|
112 CyAsHalDmaSetupRead(CyAsHalDeviceTag tag, uint8_t ep, void *buf, uint32_t size, uint16_t maxsize) ; |
|
113 #define CyAnHalDmaSetupRead(tag, ep, buf, sz, max) \ |
|
114 CyAsHalDmaSetupRead((CyAsHalDeviceTag)(tag), (ep), (buf), (sz), (max)) |
|
115 |
|
116 /* |
|
117 * This function must be defined to cancel any pending DMA request. |
|
118 */ |
|
119 extern void |
|
120 CyAsHalDmaCancelRequest(CyAsHalDeviceTag tag, uint8_t ep) ; |
|
121 #define CyAnHalDmaCancelRequest(tag, ep) CyAsHalDmaCancelRequest((CyAsHalDeviceTag)(tag), (ep)) |
|
122 |
|
123 /* |
|
124 * This function must be defined to allow the West Bridge API to register a callback function that is |
|
125 * called when a DMA transfer is complete. |
|
126 */ |
|
127 extern void |
|
128 CyAsHalDmaRegisterCallback(CyAsHalDeviceTag tag, CyAsHalDmaCompleteCallback cb) ; |
|
129 #define CyAnHalDmaRegisterCallback(tag, cb) \ |
|
130 CyAsHalDmaRegisterCallback((CyAsHalDeviceTag)(tag), (CyAsHalDmaRegisterCallback)(cb)) |
|
131 |
|
132 /* |
|
133 * This function must be defined to return the maximum size of DMA request that can be handled |
|
134 * on the given endpoint. The return value should be the maximum size in bytes that the DMA |
|
135 * module can handle. |
|
136 */ |
|
137 extern uint32_t |
|
138 CyAsHalDmaMaxRequestSize(CyAsHalDeviceTag tag, CyAsEndPointNumber_t ep) ; |
|
139 #define CyAnHalDmaMaxRequestSize(tag, ep) \ |
|
140 CyAsHalDmaMaxRequestSize((CyAsHalDeviceTag)(tag), (CyAsEndPointNumber_t)(ep)) |
|
141 |
|
142 /* |
|
143 * This function must be defined to set the state of the WAKEUP pin on the West Bridge device. Generally |
|
144 * this is done via a GPIO of some type. |
|
145 */ |
|
146 extern CyBool |
|
147 CyAsHalSetWakeupPin(CyAsHalDeviceTag tag, CyBool state) ; |
|
148 #define CyAnHalSetWakeupPin(tag, state) CyAsHalSetWakeupPin((CyAsHalDeviceTag)(tag), (state)) |
|
149 |
|
150 /* |
|
151 * This function is called when the West Bridge PLL loses lock, because |
|
152 * of a problem in the supply voltage or the input clock. |
|
153 */ |
|
154 extern void |
|
155 CyAsHalPllLockLossHandler(CyAsHalDeviceTag tag) ; |
|
156 #define CyAnHalPllLockLossHandler(tag) CyAsHalPllLockLossHandler((CyAsHalDeviceTag)(tag)) |
|
157 |
|
158 /* |
|
159 * Function to re-synchronise connection between Processor and West Bridge. |
|
160 * This is a no-operation for this HAL. |
|
161 */ |
|
162 extern CyBool |
|
163 CyAsHalSyncDeviceClocks(CyAsHalDeviceTag tag) ; |
|
164 #define CyAsHalSyncDeviceClocks(tag) (CyTrue) |
|
165 |
|
166 /* |
|
167 * Function to re-initialize West Bridge register when waking up from standby. |
|
168 * This is a no-operation for this HAL. |
|
169 */ |
|
170 extern void |
|
171 CyAsHalInitDevRegisters(CyAsHalDeviceTag tag, CyBool is_standby_wakeup ) ; |
|
172 |
|
173 |
|
174 /* |
|
175 * Function to read and save register values before Astoria is put into standby mode. |
|
176 */ |
|
177 extern void |
|
178 CyAsHalReadRegsBeforeStandby ( |
|
179 CyAsHalDeviceTag tag) ; |
|
180 |
|
181 /* |
|
182 * Function to restore original values to registers after Astoria wakes up from standby mode. |
|
183 */ |
|
184 extern void |
|
185 CyAsHalRestoreRegsAfterStandby ( |
|
186 CyAsHalDeviceTag tag) ; |
|
187 |
|
188 /************************************************************************************************* |
|
189 * |
|
190 * Below are the functions that must be defined to provide the basic operating system services |
|
191 * required by the API. |
|
192 * |
|
193 *************************************************************************************************/ |
|
194 |
|
195 /* |
|
196 * This function is required by the API to allocate memory. This function is expected to work |
|
197 * exactly like malloc(). |
|
198 */ |
|
199 void * |
|
200 CyAsHalAlloc(uint32_t cnt) ; |
|
201 #define CyAnHalAlloc(cnt) CyAsHalAlloc(cnt) |
|
202 |
|
203 /* |
|
204 * This function is required by the API to free memory allocated with CyAsHalAlloc(). This function is |
|
205 * expected to work exacly like free(). |
|
206 */ |
|
207 void |
|
208 CyAsHalFree(void *mem_p) ; |
|
209 #define CyAnHalFree(ptr) CyAsHalFree(ptr) |
|
210 |
|
211 /* |
|
212 * This function is required by the API to allocate memory during a callback. This function must be able to |
|
213 * provide storage at inturupt time. |
|
214 */ |
|
215 void * |
|
216 CyAsHalCBAlloc(uint32_t cnt) ; |
|
217 #define CyAnHalCBAlloc(cnt) CyAsHalCBAlloc(cnt) |
|
218 |
|
219 /* |
|
220 * This function is required by the API to free memory allocated with CyAsHalCBAlloc. |
|
221 */ |
|
222 void |
|
223 CyAsHalCBFree(void *mem_p) ; |
|
224 #define CyAsHalCBFree(ptr) CyAsHalFree(ptr) |
|
225 #define CyAnHalCBFree(ptr) CyAsHalFree(ptr) |
|
226 |
|
227 /* |
|
228 * This function is required to set a block of memory to a specific value. This function is |
|
229 * expected to work exactly like memset() |
|
230 */ |
|
231 void |
|
232 CyAsHalMemSet(void *ptr, uint8_t value, uint32_t cnt) ; |
|
233 #define CyAnHalMemSet(ptr, value, cnt) CyAsHalMemSet((ptr), (value), (cnt)) |
|
234 |
|
235 /* |
|
236 * This function is expected to create a sleep channel. The data structure that represents the |
|
237 * sleep channel is given by the pointer in the argument. |
|
238 */ |
|
239 CyBool |
|
240 CyAsHalCreateSleepChannel(CyAsHalSleepChannel *channel) ; |
|
241 #define CyAnHalCreateSleepChannel(ch) CyAsHalCreateSleepChannel((CyAsHalSleepChannel *)(ch)) |
|
242 |
|
243 /* |
|
244 * This function is expected to destroy a sleep channel. The data structure that represents the |
|
245 * sleep channel is given by the pointer in the argument. |
|
246 */ |
|
247 CyBool |
|
248 CyAsHalDestroySleepChannel(CyAsHalSleepChannel *channel) ; |
|
249 #define CyAnHalDestroySleepChannel(ch) CyAsHalDestroySleepChannel((CyAsHalSleepChannel *)(ch)) |
|
250 |
|
251 CyBool |
|
252 CyAsHalSleepOn(CyAsHalSleepChannel *channel, uint32_t ms) ; |
|
253 #define CyAnHalSleepOn(ch, ms) CyAsHalSleepOn((CyAsHalSleepChannel *)(ch), (ms)) |
|
254 |
|
255 CyBool |
|
256 CyAsHalWake(CyAsHalSleepChannel *channel) ; |
|
257 #define CyAnHalWake(ch) CyAsHalWake((CyAsHalSleepChannel *)(ch)) |
|
258 |
|
259 uint32_t |
|
260 CyAsHalDisableInterrupts(void) ; |
|
261 #define CyAnHalDisableInterrupts() CyAsHalDisableInterrupts() |
|
262 |
|
263 void |
|
264 CyAsHalEnableInterrupts(uint32_t); |
|
265 #define CyAnHalEnableInterrupts(msk) CyAsHalEnableInterrupts(msk) |
|
266 |
|
267 void |
|
268 CyAsHalSleep150(void) ; |
|
269 #define CyAnHalSleep150() CyAsHalSleep150() |
|
270 |
|
271 void |
|
272 CyAsHalSleep(uint32_t ms) ; |
|
273 #define CyAnHalSleep(ms) CyAsHalSleep(ms) |
|
274 |
|
275 #define CyAsHalIsPolling() (CyFalse) |
|
276 #define CyAsHalDisablePolling() |
|
277 #define CyAsHalEnablePolling() |
|
278 |
|
279 #define CyAnHalIsPolling() (CyFalse) |
|
280 #define CyAnHalDisablePolling() |
|
281 #define CyAnHalEnablePolling() |
|
282 |
|
283 #define CyAsHalPrintMessage |
|
284 //#define CyAsHalPrintMessage Kern::Printf |
|
285 #define CyAnHalPrintMessage CyAsHalPrintMessage |
|
286 |
|
287 void |
|
288 CyAsHalPrintMessage2(const char* msg); |
|
289 |
|
290 /*#define CyAsHalAssert(cond) if (!(cond)) { CyAsHalPrintMessage ("Assertion failed at %s:%d\n", __FILE__, __LINE__); }*/ |
|
291 #define CyAsHalAssert(cond) |
|
292 #define CyAnHalAssert(cond) CyAsHalAssert(cond) |
|
293 |
|
294 /* |
|
295 As this is a completely interrupt driven HAL, there is no |
|
296 need to implement the following functions. |
|
297 */ |
|
298 |
|
299 /* |
|
300 * These are the functions that are not part of the HAL layer, but are required to be called |
|
301 * for this HAL. |
|
302 */ |
|
303 int StartBeagleboardHal(const char *pgm, CyAsHalDeviceTag *tag, CyBool debug) ; |
|
304 int StopBeagleboardHal(const char *pgm, CyAsHalDeviceTag tag) ; |
|
305 |
|
306 /* |
|
307 * Constants |
|
308 */ |
|
309 #define CY_AS_OMAP_KERNEL_HAL_SIG (0x1441) |
|
310 |
|
311 #define CYAS_DEV_MAX_ADDR (0xFF) |
|
312 #define CYAS_DEV_ADDR_RANGE (CYAS_DEV_MAX_ADDR << 16) |
|
313 |
|
314 /* The base address is added in the kernel module code. */ |
|
315 #define CYAS_DEV_CALC_ADDR(addr) (addr << 16) |
|
316 |
|
317 /* |
|
318 * Data structures |
|
319 */ |
|
320 typedef struct CyAsOmapDevKernel |
|
321 { |
|
322 /* This is the signature for this data structure */ |
|
323 unsigned int m_sig ; |
|
324 |
|
325 /* Address base of West Bridge Device */ |
|
326 void *m_addr_base ; |
|
327 |
|
328 /* This is a pointer to the next West Bridge device in the system */ |
|
329 struct CyAsOmapDevKernel *m_next_p ; |
|
330 |
|
331 /* This is for thread sync */ |
|
332 /* TODO: struct completion thread_complete ;*/ |
|
333 |
|
334 /* This is for thread to wait for interrupts */ |
|
335 CyAsHalSleepChannel thread_sc ; |
|
336 |
|
337 /* This is for thread to exit upon StopOmapKernel */ |
|
338 int thread_flag ; /* set 1 to exit */ |
|
339 |
|
340 } CyAsOmapDevKernel ; |
|
341 |
|
342 extern int |
|
343 CyAsHalAstoriaInit(void); |
|
344 |
|
345 #include "cyas_cplus_end.h" |
|
346 |
|
347 #endif |