blob: ca47f7f1080708d941f6b7e1f176a0d362cca8a3 [file] [log] [blame]
Wolfgang Denk4646d2a2006-05-30 15:56:48 +02001/**
2 * @file IxNpeMhConfig_p.h
3 *
4 * @author Intel Corporation
5 * @date 18 Jan 2002
6 *
7 * @brief This file contains the private API for the Configuration module.
8 *
9 *
10 * @par
11 * IXP400 SW Release version 2.0
12 *
13 * -- Copyright Notice --
14 *
15 * @par
16 * Copyright 2001-2005, Intel Corporation.
17 * All rights reserved.
18 *
19 * @par
Wolfgang Denkc57eadc2013-07-28 22:12:47 +020020 * SPDX-License-Identifier: BSD-3-Clause
Wolfgang Denk4646d2a2006-05-30 15:56:48 +020021 * @par
22 * -- End of Copyright Notice --
23*/
24
25/**
26 * @defgroup IxNpeMhConfig_p IxNpeMhConfig_p
27 *
28 * @brief The private API for the Configuration module.
29 *
30 * @{
31 */
32
33#ifndef IXNPEMHCONFIG_P_H
34#define IXNPEMHCONFIG_P_H
35
36#include "IxOsal.h"
37
38#include "IxNpeMh.h"
39#include "IxNpeMhMacros_p.h"
40
41/*
42 * inline definition
43 */
44/* enable function inlining for performances */
45#ifdef IXNPEMHSOLICITEDCBMGR_C
46/* Non-inline functions will be defined in this translation unit.
47 Reason is that in GNU Compiler, if the Optimization is turn off, all extern inline
48 functions will not be compiled.
49*/
50# ifndef __wince
51# ifndef IXNPEMHCONFIG_INLINE
52# define IXNPEMHCONFIG_INLINE
53# endif
54# else
55# ifndef IXNPEMHCONFIG_INLINE
56# define IXNPEMHCONFIG_INLINE IX_OSAL_INLINE_EXTERN
57# endif
58# endif /* __wince*/
59
60#else
61
62# ifndef IXNPEMHCONFIG_INLINE
63# define IXNPEMHCONFIG_INLINE IX_OSAL_INLINE_EXTERN
64# endif /* IXNPEMHCONFIG_INLINE */
65#endif /* IXNPEMHSOLICITEDCBMGR_C */
66/*
67 * Typedefs and #defines, etc.
68 */
69
70typedef void (*IxNpeMhConfigIsr) (int); /**< ISR function pointer */
71
72/**
73 * @struct IxNpeMhConfigNpeInfo
74 *
75 * @brief This structure is used to maintain the configuration information
76 * associated with an NPE.
77 */
78
79typedef struct
80{
81 IxOsalMutex mutex; /**< mutex */
82 UINT32 interruptId; /**< interrupt ID */
83 UINT32 virtualRegisterBase; /**< register virtual base address */
84 UINT32 statusRegister; /**< status register virtual address */
85 UINT32 controlRegister; /**< control register virtual address */
86 UINT32 inFifoRegister; /**< inFIFO register virutal address */
87 UINT32 outFifoRegister; /**< outFIFO register virtual address */
88 IxNpeMhConfigIsr isr; /**< isr routine for handling interrupt */
York Sun4a598092013-04-01 11:29:11 -070089 BOOL oldInterruptState; /**< old interrupt state (true => enabled) */
Wolfgang Denk4646d2a2006-05-30 15:56:48 +020090} IxNpeMhConfigNpeInfo;
91
92
93/*
94 * #defines for function return types, etc.
95 */
96
97/**< NPE register base address */
98#define IX_NPEMH_NPE_BASE (IX_OSAL_IXP400_PERIPHERAL_PHYS_BASE)
99
100#define IX_NPEMH_NPEA_OFFSET (0x6000) /**< NPE-A register base offset */
101#define IX_NPEMH_NPEB_OFFSET (0x7000) /**< NPE-B register base offset */
102#define IX_NPEMH_NPEC_OFFSET (0x8000) /**< NPE-C register base offset */
103
104#define IX_NPEMH_NPESTAT_OFFSET (0x002C) /**< NPE status register offset */
105#define IX_NPEMH_NPECTL_OFFSET (0x0030) /**< NPE control register offset */
106#define IX_NPEMH_NPEFIFO_OFFSET (0x0038) /**< NPE FIFO register offset */
107
108/** NPE-A register base address */
109#define IX_NPEMH_NPEA_BASE (IX_NPEMH_NPE_BASE + IX_NPEMH_NPEA_OFFSET)
110/** NPE-B register base address */
111#define IX_NPEMH_NPEB_BASE (IX_NPEMH_NPE_BASE + IX_NPEMH_NPEB_OFFSET)
112/** NPE-C register base address */
113#define IX_NPEMH_NPEC_BASE (IX_NPEMH_NPE_BASE + IX_NPEMH_NPEC_OFFSET)
114
115/* NPE-A configuration */
116
117/** NPE-A interrupt */
118#define IX_NPEMH_NPEA_INT (IX_OSAL_IXP400_NPEA_IRQ_LVL)
119/** NPE-A FIFO register */
120#define IX_NPEMH_NPEA_FIFO (IX_NPEMH_NPEA_BASE + IX_NPEMH_NPEFIFO_OFFSET)
121/** NPE-A control register */
122#define IX_NPEMH_NPEA_CTL (IX_NPEMH_NPEA_BASE + IX_NPEMH_NPECTL_OFFSET)
123/** NPE-A status register */
124#define IX_NPEMH_NPEA_STAT (IX_NPEMH_NPEA_BASE + IX_NPEMH_NPESTAT_OFFSET)
125
126/* NPE-B configuration */
127
128/** NPE-B interrupt */
129#define IX_NPEMH_NPEB_INT (IX_OSAL_IXP400_NPEB_IRQ_LVL)
130/** NPE-B FIFO register */
131#define IX_NPEMH_NPEB_FIFO (IX_NPEMH_NPEB_BASE + IX_NPEMH_NPEFIFO_OFFSET)
132/** NPE-B control register */
133#define IX_NPEMH_NPEB_CTL (IX_NPEMH_NPEB_BASE + IX_NPEMH_NPECTL_OFFSET)
134/** NPE-B status register */
135#define IX_NPEMH_NPEB_STAT (IX_NPEMH_NPEB_BASE + IX_NPEMH_NPESTAT_OFFSET)
136
137/* NPE-C configuration */
138
139/** NPE-C interrupt */
140#define IX_NPEMH_NPEC_INT (IX_OSAL_IXP400_NPEC_IRQ_LVL)
141/** NPE-C FIFO register */
142#define IX_NPEMH_NPEC_FIFO (IX_NPEMH_NPEC_BASE + IX_NPEMH_NPEFIFO_OFFSET)
143/** NPE-C control register */
144#define IX_NPEMH_NPEC_CTL (IX_NPEMH_NPEC_BASE + IX_NPEMH_NPECTL_OFFSET)
145/** NPE-C status register */
146#define IX_NPEMH_NPEC_STAT (IX_NPEMH_NPEC_BASE + IX_NPEMH_NPESTAT_OFFSET)
147
148/* NPE control register bit definitions */
149#define IX_NPEMH_NPE_CTL_OFE (1 << 16) /**< OutFifoEnable */
150#define IX_NPEMH_NPE_CTL_IFE (1 << 17) /**< InFifoEnable */
151#define IX_NPEMH_NPE_CTL_OFEWE (1 << 24) /**< OutFifoEnableWriteEnable */
152#define IX_NPEMH_NPE_CTL_IFEWE (1 << 25) /**< InFifoEnableWriteEnable */
153
154/* NPE status register bit definitions */
155#define IX_NPEMH_NPE_STAT_OFNE (1 << 16) /**< OutFifoNotEmpty */
156#define IX_NPEMH_NPE_STAT_IFNF (1 << 17) /**< InFifoNotFull */
157#define IX_NPEMH_NPE_STAT_OFNF (1 << 18) /**< OutFifoNotFull */
158#define IX_NPEMH_NPE_STAT_IFNE (1 << 19) /**< InFifoNotEmpty */
159#define IX_NPEMH_NPE_STAT_MBINT (1 << 20) /**< Mailbox interrupt */
160#define IX_NPEMH_NPE_STAT_IFINT (1 << 21) /**< InFifo interrupt */
161#define IX_NPEMH_NPE_STAT_OFINT (1 << 22) /**< OutFifo interrupt */
162#define IX_NPEMH_NPE_STAT_WFINT (1 << 23) /**< WatchFifo interrupt */
163
164
165/**
166 * Variable declarations. Externs are followed by static variables.
167 */
168extern IxNpeMhConfigNpeInfo ixNpeMhConfigNpeInfo[IX_NPEMH_NUM_NPES];
169
170
171/*
172 * Prototypes for interface functions.
173 */
174
175/**
176 * @fn void ixNpeMhConfigInitialize (
177 IxNpeMhNpeInterrupts npeInterrupts)
178 *
179 * @brief This function initialises the Configuration module.
180 *
181 * @param IxNpeMhNpeInterrupts npeInterrupts (in) - whether or not to
182 * service the NPE "outFIFO not empty" interrupts.
183 *
184 * @return No return value.
185 */
186
187void ixNpeMhConfigInitialize (
188 IxNpeMhNpeInterrupts npeInterrupts);
189
190/**
191 * @fn void ixNpeMhConfigUninit (void)
192 *
193 * @brief This function uninitialises the Configuration module.
194 *
195 * @return No return value.
196 */
197
198void ixNpeMhConfigUninit (void);
199
200/**
201 * @fn void ixNpeMhConfigIsrRegister (
202 IxNpeMhNpeId npeId,
203 IxNpeMhConfigIsr isr)
204 *
205 * @brief This function registers an ISR to handle NPE "outFIFO not
206 * empty" interrupts.
207 *
208 * @param IxNpeMhNpeId npeId (in) - the ID of the NPE whose interrupt will
209 * be handled.
210 * @param IxNpeMhConfigIsr isr (in) - the ISR function pointer that the
211 * interrupt will trigger.
212 *
213 * @return No return value.
214 */
215
216void ixNpeMhConfigIsrRegister (
217 IxNpeMhNpeId npeId,
218 IxNpeMhConfigIsr isr);
219
220/**
221 * @fn BOOL ixNpeMhConfigNpeInterruptEnable (
222 IxNpeMhNpeId npeId)
223 *
224 * @brief This function enables a NPE's "outFIFO not empty" interrupt.
225 *
226 * @param IxNpeMhNpeId npeId (in) - the ID of the NPE whose interrupt will
227 * be enabled.
228 *
York Sun4a598092013-04-01 11:29:11 -0700229 * @return Returns the previous state of the interrupt (true => enabled).
Wolfgang Denk4646d2a2006-05-30 15:56:48 +0200230 */
231
232BOOL ixNpeMhConfigNpeInterruptEnable (
233 IxNpeMhNpeId npeId);
234
235/**
236 * @fn BOOL ixNpeMhConfigNpeInterruptDisable (
237 IxNpeMhNpeId npeId)
238 *
239 * @brief This function disables a NPE's "outFIFO not empty" interrupt
240 *
241 * @param IxNpeMhNpeId npeId (in) - the ID of the NPE whose interrupt will
242 * be disabled.
243 *
York Sun4a598092013-04-01 11:29:11 -0700244 * @return Returns the previous state of the interrupt (true => enabled).
Wolfgang Denk4646d2a2006-05-30 15:56:48 +0200245 */
246
247BOOL ixNpeMhConfigNpeInterruptDisable (
248 IxNpeMhNpeId npeId);
249
250/**
251 * @fn IxNpeMhMessageId ixNpeMhConfigMessageIdGet (
252 IxNpeMhMessage message)
253 *
254 * @brief This function gets the ID of a message.
255 *
256 * @param IxNpeMhMessage message (in) - the message to get the ID of.
257 *
258 * @return the ID of the message
259 */
260
261IxNpeMhMessageId ixNpeMhConfigMessageIdGet (
262 IxNpeMhMessage message);
263
264/**
265 * @fn BOOL ixNpeMhConfigNpeIdIsValid (
266 IxNpeMhNpeId npeId)
267 *
268 * @brief This function checks to see if a NPE ID is valid.
269 *
270 * @param IxNpeMhNpeId npeId (in) - the NPE ID to validate.
271 *
York Sun4a598092013-04-01 11:29:11 -0700272 * @return true if the NPE ID is valid, otherwise false.
Wolfgang Denk4646d2a2006-05-30 15:56:48 +0200273 */
274
275BOOL ixNpeMhConfigNpeIdIsValid (
276 IxNpeMhNpeId npeId);
277
278/**
279 * @fn void ixNpeMhConfigLockGet (
280 IxNpeMhNpeId npeId)
281 *
282 * @brief This function gets a lock for exclusive NPE interaction, and
283 * disables the NPE's "outFIFO not empty" interrupt.
284 *
285 * @param IxNpeMhNpeId npeId (in) - The ID of the NPE for which to get the
286 * lock and disable its interrupt.
287 *
288 * @return No return value.
289 */
290
291void ixNpeMhConfigLockGet (
292 IxNpeMhNpeId npeId);
293
294/**
295 * @fn void ixNpeMhConfigLockRelease (
296 IxNpeMhNpeId npeId)
297 *
298 * @brief This function releases a lock for exclusive NPE interaction, and
299 * enables the NPE's "outFIFO not empty" interrupt.
300 *
301 * @param IxNpeMhNpeId npeId (in) - The ID of the NPE for which to release
302 * the lock and enable its interrupt.
303 *
304 * @return No return value.
305 */
306
307void ixNpeMhConfigLockRelease (
308 IxNpeMhNpeId npeId);
309
310/**
311 * @fn BOOL ixNpeMhConfigInFifoIsEmpty (
312 IxNpeMhNpeId npeId)
313 *
314 * @brief This inline function checks if a NPE's inFIFO is empty.
315 *
316 * @param IxNpeMhNpeId npeId (in) - The ID of the NPE for which the inFIFO
317 * will be checked.
318 *
York Sun4a598092013-04-01 11:29:11 -0700319 * @return true if the inFIFO is empty, otherwise false.
Wolfgang Denk4646d2a2006-05-30 15:56:48 +0200320 */
321
322IXNPEMHCONFIG_INLINE BOOL ixNpeMhConfigInFifoIsEmpty (
323 IxNpeMhNpeId npeId);
324
325/**
326 * @fn BOOL ixNpeMhConfigInFifoIsFull (
327 IxNpeMhNpeId npeId)
328 *
329 * @brief This inline function checks if a NPE's inFIFO is full.
330 *
331 * @param IxNpeMhNpeId npeId (in) - The ID of the NPE for which the inFIFO
332 * will be checked.
333 *
York Sun4a598092013-04-01 11:29:11 -0700334 * @return true if the inFIFO is full, otherwise false.
Wolfgang Denk4646d2a2006-05-30 15:56:48 +0200335 */
336
337IXNPEMHCONFIG_INLINE BOOL ixNpeMhConfigInFifoIsFull (
338 IxNpeMhNpeId npeId);
339
340/**
341 * @fn BOOL ixNpeMhConfigOutFifoIsEmpty (
342 IxNpeMhNpeId npeId)
343 *
344 * @brief This inline function checks if a NPE's outFIFO is empty.
345 *
346 * @param IxNpeMhNpeId npeId (in) - The ID of the NPE for which the outFIFO
347 * will be checked.
348 *
York Sun4a598092013-04-01 11:29:11 -0700349 * @return true if the outFIFO is empty, otherwise false.
Wolfgang Denk4646d2a2006-05-30 15:56:48 +0200350 */
351
352IXNPEMHCONFIG_INLINE BOOL ixNpeMhConfigOutFifoIsEmpty (
353 IxNpeMhNpeId npeId);
354
355/**
356 * @fn BOOL ixNpeMhConfigOutFifoIsFull (
357 IxNpeMhNpeId npeId)
358 *
359 * @brief This inline function checks if a NPE's outFIFO is full.
360 *
361 * @param IxNpeMhNpeId npeId (in) - The ID of the NPE for which the outFIFO
362 * will be checked.
363 *
York Sun4a598092013-04-01 11:29:11 -0700364 * @return true if the outFIFO is full, otherwise false.
Wolfgang Denk4646d2a2006-05-30 15:56:48 +0200365 */
366
367IXNPEMHCONFIG_INLINE BOOL ixNpeMhConfigOutFifoIsFull (
368 IxNpeMhNpeId npeId);
369
370/**
371 * @fn IX_STATUS ixNpeMhConfigInFifoWrite (
372 IxNpeMhNpeId npeId,
373 IxNpeMhMessage message)
374 *
375 * @brief This function writes a message to a NPE's inFIFO. The caller
376 * must first check that the NPE's inFifo is not full. After writing the first
377 * word of the message, this function will keep polling NPE's inFIFO is not
378 * full to write the second word. If inFIFO is not available after maximum
379 * retries (IX_NPE_MH_MAX_NUM_OF_RETRIES), this function will return TIMEOUT
380 * status to indicate NPE hang / halt.
381 *
382 * @param IxNpeMhNpeId npeId (in) - The ID of the NPE for which the inFIFO
383 * will be written to.
384 * @param IxNpeMhMessage message (in) - The message to write.
385 *
386 * @return The function returns a status indicating success, failure or timeout.
387 */
388
389IX_STATUS ixNpeMhConfigInFifoWrite (
390 IxNpeMhNpeId npeId,
391 IxNpeMhMessage message);
392
393/**
394 * @fn IX_STATUS ixNpeMhConfigOutFifoRead (
395 IxNpeMhNpeId npeId,
396 IxNpeMhMessage *message)
397 *
398 * @brief This function reads a message from a NPE's outFIFO. The caller
399 * must first check that the NPE's outFifo is not empty. After reading the first
400 * word of the message, this function will keep polling NPE's outFIFO is not
401 * empty to read the second word. If outFIFO is empty after maximum
402 * retries (IX_NPE_MH_MAX_NUM_OF_RETRIES), this function will return TIMEOUT
403 * status to indicate NPE hang / halt.
404 *
405 * @param IxNpeMhNpeId npeId (in) - The ID of the NPE for which the outFIFO
406 * will be read from.
407 * @param IxNpeMhMessage message (out) - The message read.
408 *
409 * @return The function returns a status indicating success, failure or timeout.
410 */
411
412IX_STATUS ixNpeMhConfigOutFifoRead (
413 IxNpeMhNpeId npeId,
414 IxNpeMhMessage *message);
415
416/**
417 * @fn void ixNpeMhConfigShow (
418 IxNpeMhNpeId npeId)
419 *
420 * @brief This function will display the current state of the Configuration
421 * module.
422 *
423 * @param IxNpeMhNpeId npeId (in) - The ID of the NPE to display state
424 * information for.
425 *
426 * @return No return value.
427 */
428
429void ixNpeMhConfigShow (
430 IxNpeMhNpeId npeId);
431
432/**
433 * @fn void ixNpeMhConfigShowReset (
434 IxNpeMhNpeId npeId)
435 *
436 * @brief This function will reset the current state of the Configuration
437 * module.
438 *
439 * @param IxNpeMhNpeId npeId (in) - The ID of the NPE to reset state
440 * information for.
441 *
442 * @return No return value.
443 */
444
445void ixNpeMhConfigShowReset (
446 IxNpeMhNpeId npeId);
447
448/*
449 * Inline functions
450 */
451
452/*
453 * This inline function checks if a NPE's inFIFO is empty.
454 */
455
456IXNPEMHCONFIG_INLINE
457BOOL ixNpeMhConfigInFifoIsEmpty (
458 IxNpeMhNpeId npeId)
459{
460 UINT32 ifne;
461 volatile UINT32 *statusReg =
462 (UINT32 *)ixNpeMhConfigNpeInfo[npeId].statusRegister;
463
464 /* get the IFNE (InFifoNotEmpty) bit of the status register */
465 IX_NPEMH_REGISTER_READ_BITS (statusReg, &ifne, IX_NPEMH_NPE_STAT_IFNE);
466
467 /* if the IFNE status bit is unset then the inFIFO is empty */
468 return (ifne == 0);
469}
470
471
472/*
473 * This inline function checks if a NPE's inFIFO is full.
474 */
475IXNPEMHCONFIG_INLINE
476BOOL ixNpeMhConfigInFifoIsFull (
477 IxNpeMhNpeId npeId)
478{
479 UINT32 ifnf;
480 volatile UINT32 *statusReg =
481 (UINT32 *)ixNpeMhConfigNpeInfo[npeId].statusRegister;
482
483 /* get the IFNF (InFifoNotFull) bit of the status register */
484 IX_NPEMH_REGISTER_READ_BITS (statusReg, &ifnf, IX_NPEMH_NPE_STAT_IFNF);
485
486 /* if the IFNF status bit is unset then the inFIFO is full */
487 return (ifnf == 0);
488}
489
490
491/*
492 * This inline function checks if a NPE's outFIFO is empty.
493 */
494IXNPEMHCONFIG_INLINE
495BOOL ixNpeMhConfigOutFifoIsEmpty (
496 IxNpeMhNpeId npeId)
497{
498 UINT32 ofne;
499 volatile UINT32 *statusReg =
500 (UINT32 *)ixNpeMhConfigNpeInfo[npeId].statusRegister;
501
502 /* get the OFNE (OutFifoNotEmpty) bit of the status register */
503 IX_NPEMH_REGISTER_READ_BITS (statusReg, &ofne, IX_NPEMH_NPE_STAT_OFNE);
504
505 /* if the OFNE status bit is unset then the outFIFO is empty */
506 return (ofne == 0);
507}
508
509/*
510 * This inline function checks if a NPE's outFIFO is full.
511 */
512IXNPEMHCONFIG_INLINE
513BOOL ixNpeMhConfigOutFifoIsFull (
514 IxNpeMhNpeId npeId)
515{
516 UINT32 ofnf;
517 volatile UINT32 *statusReg =
518 (UINT32 *)ixNpeMhConfigNpeInfo[npeId].statusRegister;
519
520 /* get the OFNF (OutFifoNotFull) bit of the status register */
521 IX_NPEMH_REGISTER_READ_BITS (statusReg, &ofnf, IX_NPEMH_NPE_STAT_OFNF);
522
523 /* if the OFNF status bit is unset then the outFIFO is full */
524 return (ofnf == 0);
525}
526
527#endif /* IXNPEMHCONFIG_P_H */
528
529/**
530 * @} defgroup IxNpeMhConfig_p
531 */