xref: /wlan-driver/fw-api/hw/qca6490/v1/HALcomdef.h (revision 5113495b16420b49004c444715d2daae2066e7dc)
1 /*
2  * Copyright (c) 2019 The Linux Foundation. All rights reserved.
3  *
4  * Permission to use, copy, modify, and/or distribute this software for
5  * any purpose with or without fee is hereby granted, provided that the
6  * above copyright notice and this permission notice appear in all
7  * copies.
8  *
9  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
10  * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
11  * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
12  * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
13  * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
14  * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
15  * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
16  * PERFORMANCE OF THIS SOFTWARE.
17  */
18 
19 #ifndef HAL_COMDEF_H
20 #define HAL_COMDEF_H
21 /*
22 ==============================================================================
23 
24 FILE:         HALcomdef.h
25 
26 DESCRIPTION:
27 
28 ==============================================================================
29 
30 				Edit History
31 
32 $Header: //depot/prj/qca/chips/hastings/cores/wcss/verif/native/register/include/HALcomdef.h#1 $
33 
34 when       who     what, where, why
35 --------   ---     -----------------------------------------------------------
36 06/17/10   sc      Included com_dtypes.h and cleaned up typedefs
37 05/15/08   gfr     Added HAL_ENUM_32BITS macro.
38 02/14/08   gfr     Added bool32 type.
39 11/13/07   gfr     Removed dependency on comdef.h
40 01/08/07   hxw     Created
41 
42 */
43 
44 
45 /*
46  * Assembly wrapper
47  */
48 #ifndef _ARM_ASM_
49 
50 /*
51  * C++ wrapper
52  */
53 #ifdef __cplusplus
54 extern "C" {
55 #endif
56 
57 #include "com_dtypes.h"
58 
59 /* -----------------------------------------------------------------------
60 ** Types
61 ** ----------------------------------------------------------------------- */
62 
63 /*
64  * Standard integer types.
65  *
66  * bool32  - boolean, 32 bit (TRUE or FALSE)
67  */
68 #ifndef _BOOL32_DEFINED
69 typedef  unsigned long int  bool32;
70 #define _BOOL32_DEFINED
71 #endif
72 
73 /*
74  * Macro to allow forcing an enum to 32 bits.  The argument should be
75  * an identifier in the namespace of the enumeration in question, i.e.
76  * for the clk HAL we might use HAL_ENUM_32BITS(CLK_xxx).
77  */
78 #define HAL_ENUM_32BITS(x) HAL_##x##_FORCE32BITS = 0x7FFFFFFF
79 
80 /*===========================================================================
81 
82 FUNCTION inp, outp, inpw, outpw, inpdw, outpdw
83 
84 DESCRIPTION
85   IN/OUT port macros for byte and word ports, typically inlined by compilers
86   which support these routines
87 
88 PARAMETERS
89   inp(   xx_addr )
90   inpw(  xx_addr )
91   inpdw( xx_addr )
92   outp(   xx_addr, xx_byte_val  )
93   outpw(  xx_addr, xx_word_val  )
94   outpdw( xx_addr, xx_dword_val )
95       xx_addr      - Address of port to read or write (may be memory mapped)
96       xx_byte_val  - 8 bit value to write
97       xx_word_val  - 16 bit value to write
98       xx_dword_val - 32 bit value to write
99 
100 DEPENDENCIES
101   None
102 
103 RETURN VALUE
104   inp/inpw/inpdw: the byte, word or dword read from the given address
105   outp/outpw/outpdw: the byte, word or dword written to the given address
106 
107 SIDE EFFECTS
108   None.
109 
110 ===========================================================================*/
111 
112   /* ARM based targets use memory mapped i/o, so the inp/outp calls are
113   ** macroized to access memory directly
114   */
115 
116   #define inp(port)         (*((volatile byte *) (port)))
117 
118   #define inpw(port)        (*((volatile word *) (port)))
119   #define inpdw(port)       (*((volatile dword *)(port)))
120 
121   #define outp(port, val)   (*((volatile byte *) (port)) = ((byte) (val)))
122   #define outpw(port, val)  (*((volatile word *) (port)) = ((word) (val)))
123   #define outpdw(port, val) (*((volatile dword *) (port)) = ((dword) (val)))
124 
125 #ifdef __cplusplus
126 }
127 #endif
128 
129 #endif /* !_ARM_ASM_ */
130 
131 #endif /* HAL_COMDEF_H */
132 
133