xref: /OK3568_Linux_fs/external/rkwifibt/drivers/rtl8852be/phl/hal_g6/mac/pltfm_cfg.h (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1 /** @file */
2 /******************************************************************************
3  *
4  * Copyright(c) 2019 Realtek Corporation. All rights reserved.
5  *
6  * This program is free software; you can redistribute it and/or modify it
7  * under the terms of version 2 of the GNU General Public License as
8  * published by the Free Software Foundation.
9  *
10  * This program is distributed in the hope that it will be useful, but WITHOUT
11  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13  * more details.
14  *
15  ******************************************************************************/
16 
17 #ifndef _MAC_AX_PLTFM_H_
18 #define _MAC_AX_PLTFM_H_
19 
20 #ifndef __cplusplus /* for win/linux driver */
21 
22 /* Include header file which contain the following definitions, */
23 /* or modify this file to meet your platform */
24 /*[Driver] use their own header files*/
25 #include "../hal_headers_le.h"
26 
27 /*[Driver] provide the define of NULL, u8, u16, u32*/
28 #ifndef NULL
29 #define NULL		((void *)0)
30 #endif
31 
32 /*[Driver] provide the type mutex*/
33 /* Mutex type */
34 #define mac_ax_mutex _os_mutex
35 
36 #ifndef ARRAY_SIZE
37 #define ARRAY_SIZE(arr)		(sizeof(arr) / sizeof((arr)[0]))
38 #endif
39 
40 #define _ASSERT_ BUG_ON
41 
42 /* 1: enable MAC debug messages */
43 /* 0: disable MAC debug messages */
44 #define MAC_AX_DBG_MSG_EN	1
45 
46 /* Set debug message level */
47 #define MAC_AX_MSG_LEVEL_TRACE		3
48 #define MAC_AX_MSG_LEVEL_WARNING	2
49 #define MAC_AX_MSG_LEVEL_ERR		1
50 #define MAC_AX_MSG_LEVEL_ALWAYS		0
51 #define MAC_AX_MSG_LEVEL		MAC_AX_MSG_LEVEL_TRACE
52 
53 #define SET_CLR_WORD(_w, _v, _f)                                               \
54 				(((_w) & ~((_f##_MSK) << (_f##_SH))) |         \
55 				(((_v) & (_f##_MSK)) << (_f##_SH)))
56 #define SET_WORD(_v, _f)	(((_v) & (_f##_MSK)) << (_f##_SH))
57 #define GET_FIELD(_w, _f)         (((_w) >> (_f##_SH)) & (_f##_MSK))
58 
59 #define SET_CLR_WOR2(_w, _v, _sh, _msk) (((_w) & ~(_msk << _sh)) |             \
60 					(((_v) & _msk) << _sh))
61 #define SET_WOR2(_v, _sh, _msk)         (((_v) & _msk) << _sh)
62 #define GET_FIEL2(_w, _sh, _msk)        (((_w) >> _sh) & _msk)
63 
64 #define GET_MSK(_f)         ((_f##_MSK) << (_f##_SH))
65 
66 #else /* for WD1 test program */
67 
68 /* Include header file which contain the following definitions, */
69 /* or modify this file to meet your platform */
70 #include <Windows.h> // critical_section
71 #include <stdint.h>
72 
73 #define BIT(x)	(1 << (x))
74 
75 #ifndef NULL
76 #define NULL	((void *)0)
77 #endif
78 
79 typedef unsigned char	u8;
80 typedef uint16_t	u16;
81 typedef uint32_t	u32;
82 typedef char		s8;
83 typedef int16_t		s16;
84 typedef int32_t		s32;
85 
86 #include "../hal_headers_le.h"
87 
88 typedef u16 __le16;
89 typedef u32 __le32;
90 typedef u16 __be16;
91 typedef u32 __be32;
92 
93 typedef	CRITICAL_SECTION	mac_ax_mutex;
94 
95 #define ARRAY_SIZE(arr)		(sizeof(arr) / sizeof((arr)[0]))
96 
97 /* 1: the platform is Little Endian. */
98 /* 0: the platform is Big Endian. */
99 #define MAC_AX_IS_LITTLE_ENDIAN	1
100 
101 /* 1: enable MAC debug messages */
102 /* 0: disable MAC debug messages */
103 #define MAC_AX_DBG_MSG_EN	1
104 
105 /* Set debug message level */
106 #define MAC_AX_MSG_LEVEL_TRACE		3
107 #define MAC_AX_MSG_LEVEL_WARNING	2
108 #define MAC_AX_MSG_LEVEL_ERR		1
109 #define MAC_AX_MSG_LEVEL_ALWAYS		0
110 #define MAC_AX_MSG_LEVEL		MAC_AX_MSG_LEVEL_TRACE
111 
112 #define SET_CLR_WORD(_w, _v, _f)                                               \
113 				(((_w) & ~((_f##_MSK) << (_f##_SH))) |         \
114 				(((_v) & (_f##_MSK)) << (_f##_SH)))
115 #define SET_WORD(_v, _f)	(((_v) & (_f##_MSK)) << (_f##_SH))
116 #define GET_FIELD(_w, _f)         (((_w) >> (_f##_SH)) & (_f##_MSK))
117 
118 #define SET_CLR_WOR2(_w, _v, _sh, _msk) (((_w) & ~(_msk << _sh)) |             \
119 					(((_v) & _msk) << _sh))
120 #define SET_WOR2(_v, _sh, _msk)         (((_v) & _msk) << _sh)
121 #define GET_FIEL2(_w, _sh, _msk)        (((_w) >> _sh) & _msk)
122 
123 #define GET_MSK(_f)         ((_f##_MSK) << (_f##_SH))
124 
125 #define SWAP32(x)                                                              \
126 	((u32)((((u32)(x) & (u32)0x000000ff) << 24) |                          \
127 	       (((u32)(x) & (u32)0x0000ff00) << 8) |                           \
128 	       (((u32)(x) & (u32)0x00ff0000) >> 8) |                           \
129 	       (((u32)(x) & (u32)0xff000000) >> 24)))
130 
131 #define SWAP16(x)                                                              \
132 	((u16)((((u16)(x) & (u16)0x00ff) << 8) |                               \
133 	       (((u16)(x) & (u16)0xff00) >> 8)))
134 
135 #if MAC_AX_IS_LITTLE_ENDIAN
136 #define cpu_to_le32(x)              ((u32)(x))
137 #define le32_to_cpu(x)              ((u32)(x))
138 #define cpu_to_le16(x)              ((u16)(x))
139 #define le16_to_cpu(x)              ((u16)(x))
140 #define cpu_to_be32(x)              SWAP32((x))
141 #define be32_to_cpu(x)              SWAP32((x))
142 #define cpu_to_be16(x)              SWAP16((x))
143 #define be16_to_cpu(x)              SWAP16((x))
144 #else
145 #define cpu_to_le32(x)              SWAP32((x))
146 #define le32_to_cpu(x)              SWAP32((x))
147 #define cpu_to_le16(x)              SWAP16((x))
148 #define le16_to_cpu(x)              SWAP16((x))
149 #define cpu_to_be32(x)              ((u32)(x))
150 #define be32_to_cpu(x)              ((u32)(x))
151 #define cpu_to_be16(x)              ((u16)(x))
152 #define be16_to_cpu(x)              ((u16)(x))
153 #endif
154 
155 #ifndef __func__
156 #define __func__ __FUNCTION__
157 #endif
158 
159 #endif // end of #else /* for WD1 test program */
160 
161 #endif
162