1 /******************************************************************************
3 * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved.
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of version 2 of the GNU General Public License as
7 * published by the Free Software Foundation.
9 * This program is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
14 * You should have received a copy of the GNU General Public License along with
15 * this program; if not, write to the Free Software Foundation, Inc.,
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
19 ******************************************************************************/
25 /*#define DEBUG_VERSION "1.1"*/ /*2015.07.29 YuChen*/
26 /*#define DEBUG_VERSION "1.2"*/ /*2015.08.28 Dino*/
27 #define DEBUG_VERSION "1.3" /*2016.04.28 YuChen*/
28 /* -----------------------------------------------------------------------------
29 * Define the debug levels
31 * 1. DBG_TRACE and DBG_LOUD are used for normal cases.
32 * So that, they can help SW engineer to develope or trace states changed
33 * and also help HW enginner to trace every operation to and from HW,
36 * 2. DBG_WARNNING and DBG_SERIOUS are used for unusual or error cases,
37 * which help us to debug SW or HW.
39 * -----------------------------------------------------------------------------
41 * Never used in a call to ODM_RT_TRACE()!
47 * For example, Tx/Rx/IO locked up, OS hangs, memory access violation,
48 * resource allocation failed, unexpected HW behavior, HW BUG and so on.
50 #define ODM_DBG_SERIOUS 2
53 * Abnormal, rare, or unexpeted cases.
54 * For example, IRP/Packet/OID canceled, device suprisely unremoved and so on.
56 #define ODM_DBG_WARNING 3
59 * Normal case with useful information about current SW or HW state.
60 * For example, Tx/Rx descriptor to fill, Tx/Rx descriptor completed status,
61 * SW protocol state change, dynamic mechanism state change and so on.
63 #define ODM_DBG_LOUD 4
66 * Normal case with detail execution flow or information.
68 #define ODM_DBG_TRACE 5
71 #define RATE_DECISION BIT(0)
72 #define INIT_RA_TABLE BIT(1)
73 #define RATE_UP BIT(2)
74 #define RATE_DOWN BIT(3)
75 #define TRY_DONE BIT(4)
77 #define F_RATE_AP_RPT BIT(7)
79 /* -----------------------------------------------------------------------------
80 * Define the tracing components
82 * -----------------------------------------------------------------------------
84 #define PHYDM_FW_COMP_RA BIT(0)
85 #define PHYDM_FW_COMP_MU BIT(1)
86 #define PHYDM_FW_COMP_PATH_DIV BIT(2)
87 #define PHYDM_FW_COMP_PHY_CONFIG BIT(3)
90 /*BB Driver Functions*/
91 #define ODM_COMP_DIG BIT(0)
92 #define ODM_COMP_RA_MASK BIT(1)
93 #define ODM_COMP_DYNAMIC_TXPWR BIT(2)
94 #define ODM_COMP_FA_CNT BIT(3)
95 #define ODM_COMP_RSSI_MONITOR BIT(4)
96 #define ODM_COMP_SNIFFER BIT(5)
97 #define ODM_COMP_ANT_DIV BIT(6)
98 #define ODM_COMP_DFS BIT(7)
99 #define ODM_COMP_NOISY_DETECT BIT(8)
100 #define ODM_COMP_RATE_ADAPTIVE BIT(9)
101 #define ODM_COMP_PATH_DIV BIT(10)
102 #define ODM_COMP_CCX BIT(11)
104 #define ODM_COMP_DYNAMIC_PRICCA BIT(12)
106 #define ODM_COMP_MP BIT(14)
107 #define ODM_COMP_CFO_TRACKING BIT(15)
108 #define ODM_COMP_ACS BIT(16)
109 #define PHYDM_COMP_ADAPTIVITY BIT(17)
110 #define PHYDM_COMP_RA_DBG BIT(18)
111 #define PHYDM_COMP_TXBF BIT(19)
113 #define ODM_COMP_EDCA_TURBO BIT(20)
114 #define ODM_COMP_DYNAMIC_RX_PATH BIT(21)
115 #define ODM_FW_DEBUG_TRACE BIT(22)
118 #define ODM_COMP_TX_PWR_TRACK BIT(24)
120 #define ODM_COMP_CALIBRATION BIT(26)
121 /* Common Functions */
123 #define ODM_PHY_CONFIG BIT(28)
124 #define ODM_COMP_INIT BIT(29)
125 #define ODM_COMP_COMMON BIT(30)
126 #define ODM_COMP_API BIT(31)
129 /*------------------------Export Marco Definition---------------------------*/
131 #define config_phydm_read_txagc_check(data) (data != INVALID_TXAGC_DATA)
133 #if (DM_ODM_SUPPORT_TYPE == ODM_WIN)
134 #define dbg_print DbgPrint
135 #define dcmd_printf DCMD_Printf
136 #define dcmd_scanf DCMD_Scanf
137 #define RT_PRINTK dbg_print
138 #elif (DM_ODM_SUPPORT_TYPE == ODM_CE)
139 #define dbg_print printk
140 #define RT_PRINTK(fmt, args...) dbg_print("%s(): " fmt, __FUNCTION__, ## args);
141 #define RT_DISP(dbgtype, dbgflag, printstr)
143 #define dbg_print panic_printk
144 /*#define RT_PRINTK(fmt, args...) dbg_print("%s(): " fmt, __FUNCTION__, ## args);*/
145 #define RT_PRINTK(fmt, args...) dbg_print(fmt, ## args);
153 #define ODM_RT_TRACE(p_dm_odm, comp, level, fmt) \
155 if (((comp) & p_dm_odm->debug_components) && (level <= p_dm_odm->debug_level || level == ODM_DBG_SERIOUS)) { \
157 if (p_dm_odm->support_ic_type == ODM_RTL8188E) \
158 dbg_print("[PhyDM-8188E] "); \
159 else if (p_dm_odm->support_ic_type == ODM_RTL8192E) \
160 dbg_print("[PhyDM-8192E] "); \
161 else if (p_dm_odm->support_ic_type == ODM_RTL8812) \
162 dbg_print("[PhyDM-8812A] "); \
163 else if (p_dm_odm->support_ic_type == ODM_RTL8821) \
164 dbg_print("[PhyDM-8821A] "); \
165 else if (p_dm_odm->support_ic_type == ODM_RTL8814A) \
166 dbg_print("[PhyDM-8814A] "); \
167 else if (p_dm_odm->support_ic_type == ODM_RTL8703B) \
168 dbg_print("[PhyDM-8703B] "); \
169 else if (p_dm_odm->support_ic_type == ODM_RTL8822B) \
170 dbg_print("[PhyDM-8822B] "); \
171 else if (p_dm_odm->support_ic_type == ODM_RTL8188F) \
172 dbg_print("[PhyDM-8188F] "); \
177 #define ODM_RT_TRACE_F(p_dm_odm, comp, level, fmt) do {\
178 if (((comp) & p_dm_odm->debug_components) && (level <= p_dm_odm->debug_level)) { \
185 #define ODM_RT_ASSERT(p_dm_odm, expr, fmt) do {\
187 dbg_print("Assertion failed! %s at ......\n", #expr); \
188 dbg_print(" ......%s,%s, line=%d\n", __FILE__, __FUNCTION__, __LINE__); \
194 #define ODM_dbg_enter() { dbg_print(" == > %s\n", __FUNCTION__); }
195 #define ODM_dbg_exit() { dbg_print("< == %s\n", __FUNCTION__); }
196 #define ODM_dbg_trace(str) { dbg_print("%s:%s\n", __FUNCTION__, str); }
198 #define ODM_PRINT_ADDR(p_dm_odm, comp, level, title_str, ptr) do {\
199 if (((comp) & p_dm_odm->debug_components) && (level <= p_dm_odm->debug_level)) { \
202 u8 *__ptr = (u8 *)ptr; \
203 dbg_print("[ODM] "); \
204 dbg_print(title_str); \
206 for (__i = 0; __i < 6; __i++) \
207 dbg_print("%02X%s", __ptr[__i], (__i == 5) ? "" : "-"); \
213 #define ODM_RT_TRACE(p_dm_odm, comp, level, fmt)
214 #define ODM_RT_TRACE_F(p_dm_odm, comp, level, fmt)
215 #define ODM_RT_ASSERT(p_dm_odm, expr, fmt)
216 #define ODM_dbg_enter()
217 #define ODM_dbg_exit()
218 #define ODM_dbg_trace(str)
219 #define ODM_PRINT_ADDR(p_dm_odm, comp, level, title_str, ptr)
222 #define BB_DBGPORT_PRIORITY_3 3 /*Debug function (the highest priority)*/
223 #define BB_DBGPORT_PRIORITY_2 2 /*Check hang function & Strong function*/
224 #define BB_DBGPORT_PRIORITY_1 1 /*Watch dog function*/
225 #define BB_DBGPORT_RELEASE 0 /*Init value (the lowest priority)*/
228 phydm_init_debug_setting(struct PHY_DM_STRUCT *p_dm_odm);
232 phydm_set_bb_dbg_port(
234 u8 curr_dbg_priority,
239 phydm_release_bb_dbg_port(
244 phydm_get_bb_dbg_port_value(
248 void phydm_basic_dbg_message(void *p_dm_void);
250 #if (DM_ODM_SUPPORT_TYPE == ODM_WIN)
251 #define PHYDM_DBGPRINT 0
252 #define PHYDM_SSCANF(x, y, z) dcmd_scanf(x, y, z)
253 #define PHYDM_VAST_INFO_SNPRINTF PHYDM_SNPRINTF
254 #if (PHYDM_DBGPRINT == 1)
255 #define PHYDM_SNPRINTF(msg) \
261 #define PHYDM_SNPRINTF(msg) \
264 dcmd_printf(output);\
268 #if (DM_ODM_SUPPORT_TYPE == ODM_CE) || defined(__OSK__)
269 #define PHYDM_DBGPRINT 0
271 #define PHYDM_DBGPRINT 1
275 #define DCMD_DECIMAL "%d"
276 #define DCMD_CHAR "%c"
277 #define DCMD_HEX "%x"
279 #define PHYDM_SSCANF(x, y, z) sscanf(x, y, z)
281 #define PHYDM_VAST_INFO_SNPRINTF(msg)\
287 #if (PHYDM_DBGPRINT == 1)
288 #define PHYDM_SNPRINTF(msg)\
294 #define PHYDM_SNPRINTF(msg)\
297 used += snprintf msg;\
303 void phydm_basic_profile(
309 #if (DM_ODM_SUPPORT_TYPE & (ODM_CE | ODM_AP))
312 struct PHY_DM_STRUCT *p_dm_odm,
322 struct PHY_DM_STRUCT *p_dm_odm,
332 struct PHY_DM_STRUCT *p_dm_odm,
333 enum odm_rf_path_e tx_path,
334 enum odm_rf_path_e rx_path,
338 #if (DM_ODM_SUPPORT_TYPE == ODM_WIN)
339 void phydm_sbd_check(
340 struct PHY_DM_STRUCT *p_dm_odm
343 void phydm_sbd_callback(
344 struct timer_list *p_timer
347 void phydm_sbd_workitem_callback(
353 phydm_fw_trace_en_h2c(
356 u32 fw_debug_component,
362 phydm_fw_trace_handler(
369 phydm_fw_trace_handler_code(
376 phydm_fw_trace_handler_8051(
382 #endif /* __ODM_DBG_H__ */