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