xref: /wlan-driver/fw-api/hw/qca5332/HALcomdef.h (revision 5113495b16420b49004c444715d2daae2066e7dc)
1 
2 /* Copyright (c) 2022, Qualcomm Innovation Center, Inc. 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  * Assembly wrapper
22  */
23 #ifndef _ARM_ASM_
24 
25 /*
26  * C++ wrapper
27  */
28 #ifdef __cplusplus
29 extern "C" {
30 #endif
31 
32 #include "com_dtypes.h"
33 
34 /* -----------------------------------------------------------------------
35 ** Types
36 ** ----------------------------------------------------------------------- */
37 
38 /*
39  * Standard integer types.
40  *
41  * bool32  - boolean, 32 bit (TRUE or FALSE)
42  */
43 #ifndef _BOOL32_DEFINED
44 typedef  unsigned long int  bool32;
45 #define _BOOL32_DEFINED
46 #endif
47 
48 /*
49  * Macro to allow forcing an enum to 32 bits.  The argument should be
50  * an identifier in the namespace of the enumeration in question, i.e.
51  * for the clk HAL we might use HAL_ENUM_32BITS(CLK_xxx).
52  */
53 #define HAL_ENUM_32BITS(x) HAL_##x##_FORCE32BITS = 0x7FFFFFFF
54 
55 /*===========================================================================
56 
57 FUNCTION inp, outp, inpw, outpw, inpdw, outpdw
58 
59 DESCRIPTION
60   IN/OUT port macros for byte and word ports, typically inlined by compilers
61   which support these routines
62 
63 PARAMETERS
64   inp(   xx_addr )
65   inpw(  xx_addr )
66   inpdw( xx_addr )
67   outp(   xx_addr, xx_byte_val  )
68   outpw(  xx_addr, xx_word_val  )
69   outpdw( xx_addr, xx_dword_val )
70       xx_addr      - Address of port to read or write (may be memory mapped)
71       xx_byte_val  - 8 bit value to write
72       xx_word_val  - 16 bit value to write
73       xx_dword_val - 32 bit value to write
74 
75 DEPENDENCIES
76   None
77 
78 RETURN VALUE
79   inp/inpw/inpdw: the byte, word or dword read from the given address
80   outp/outpw/outpdw: the byte, word or dword written to the given address
81 
82 SIDE EFFECTS
83   None.
84 
85 ===========================================================================*/
86 
87   /* ARM based targets use memory mapped i/o, so the inp/outp calls are
88   ** macroized to access memory directly
89   */
90 
91   #define inp(port)         (*((volatile byte *) (port)))
92   #define inpw(port)        (*((volatile word *) (port)))
93   #define inpdw(port)       (*((volatile dword *)(port)))
94 
95   #define outp(port, val)   (*((volatile byte *) (port)) = ((byte) (val)))
96   #define outpw(port, val)  (*((volatile word *) (port)) = ((word) (val)))
97   #define outpdw(port, val) (*((volatile dword *) (port)) = ((dword) (val)))
98 
99 #ifdef __cplusplus
100 }
101 #endif
102 
103 #endif /* !_ARM_ASM_ */
104 
105 #endif /* HAL_COMDEF_H */
106 
107