xref: /freebsd/sys/dev/wpi/if_wpi_debug.h (revision 95ee2897e98f5d444f26ed2334cc7c439f9c16c6)
1692ad7caSAdrian Chadd /*-
2692ad7caSAdrian Chadd  * Copyright (c) 2006,2007
3692ad7caSAdrian Chadd  *	Damien Bergamini <damien.bergamini@free.fr>
4692ad7caSAdrian Chadd  *	Benjamin Close <Benjamin.Close@clearchain.com>
5*ce036b51SAndriy Voskoboinyk  * Copyright (c) 2015 Andriy Voskoboinyk <avos@FreeBSD.org>
6692ad7caSAdrian Chadd  *
7692ad7caSAdrian Chadd  * Permission to use, copy, modify, and distribute this software for any
8692ad7caSAdrian Chadd  * purpose with or without fee is hereby granted, provided that the above
9692ad7caSAdrian Chadd  * copyright notice and this permission notice appear in all copies.
10692ad7caSAdrian Chadd  *
11692ad7caSAdrian Chadd  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
12692ad7caSAdrian Chadd  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
13692ad7caSAdrian Chadd  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
14692ad7caSAdrian Chadd  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
15692ad7caSAdrian Chadd  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
16692ad7caSAdrian Chadd  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
17692ad7caSAdrian Chadd  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
18692ad7caSAdrian Chadd  */
19692ad7caSAdrian Chadd 
20692ad7caSAdrian Chadd #ifndef __IF_WPI_DEBUG_H__
21692ad7caSAdrian Chadd #define __IF_WPI_DEBUG_H__
22692ad7caSAdrian Chadd 
23692ad7caSAdrian Chadd #ifdef WPI_DEBUG
24692ad7caSAdrian Chadd enum {
25692ad7caSAdrian Chadd 	WPI_DEBUG_XMIT		= 0x00000001,	/* basic xmit operation */
26692ad7caSAdrian Chadd 	WPI_DEBUG_RECV		= 0x00000002,	/* basic recv operation */
27692ad7caSAdrian Chadd 	WPI_DEBUG_STATE		= 0x00000004,	/* 802.11 state transitions */
28692ad7caSAdrian Chadd 	WPI_DEBUG_HW		= 0x00000008,	/* Stage 1 (eeprom) debugging */
29692ad7caSAdrian Chadd 	WPI_DEBUG_RESET		= 0x00000010,	/* reset processing */
30692ad7caSAdrian Chadd 	WPI_DEBUG_FIRMWARE	= 0x00000020,	/* firmware(9) loading debug */
31692ad7caSAdrian Chadd 	WPI_DEBUG_BEACON	= 0x00000040,	/* beacon handling */
32692ad7caSAdrian Chadd 	WPI_DEBUG_WATCHDOG	= 0x00000080,	/* watchdog timeout */
33692ad7caSAdrian Chadd 	WPI_DEBUG_INTR		= 0x00000100,	/* ISR */
34692ad7caSAdrian Chadd 	WPI_DEBUG_SCAN		= 0x00000200,	/* Scan related operations */
35692ad7caSAdrian Chadd 	WPI_DEBUG_NOTIFY	= 0x00000400,	/* State 2 Notif intr debug */
36692ad7caSAdrian Chadd 	WPI_DEBUG_TEMP		= 0x00000800,	/* TXPower/Temp Calibration */
37692ad7caSAdrian Chadd 	WPI_DEBUG_CMD		= 0x00001000,	/* cmd submission */
38692ad7caSAdrian Chadd 	WPI_DEBUG_TRACE		= 0x00002000,	/* Print begin and start driver function */
39692ad7caSAdrian Chadd 	WPI_DEBUG_PWRSAVE	= 0x00004000,	/* Power save operations */
40692ad7caSAdrian Chadd 	WPI_DEBUG_EEPROM	= 0x00008000,	/* EEPROM info */
410528191aSAdrian Chadd 	WPI_DEBUG_NODE		= 0x00010000,	/* node addition/removal */
420528191aSAdrian Chadd 	WPI_DEBUG_KEY		= 0x00020000,	/* node key management */
430528191aSAdrian Chadd 	WPI_DEBUG_EDCA		= 0x00040000,	/* WME info */
44a6df6cfeSAdrian Chadd 	WPI_DEBUG_REGISTER	= 0x00080000,	/* print chipset register */
453e54d9fdSAdrian Chadd 	WPI_DEBUG_BMISS		= 0x00100000,	/* print number of missed beacons */
46692ad7caSAdrian Chadd 	WPI_DEBUG_ANY		= 0xffffffff
47692ad7caSAdrian Chadd };
48692ad7caSAdrian Chadd 
49692ad7caSAdrian Chadd #define DPRINTF(sc, m, ...) do {		\
50692ad7caSAdrian Chadd 	if (sc->sc_debug & (m))			\
51692ad7caSAdrian Chadd 		printf(__VA_ARGS__);		\
52692ad7caSAdrian Chadd } while (0)
53692ad7caSAdrian Chadd 
54692ad7caSAdrian Chadd #define TRACE_STR_BEGIN		"->%s: begin\n"
55692ad7caSAdrian Chadd #define TRACE_STR_DOING		"->Doing %s\n"
56692ad7caSAdrian Chadd #define TRACE_STR_END		"->%s: end\n"
57692ad7caSAdrian Chadd #define TRACE_STR_END_ERR	"->%s: end in error\n"
58692ad7caSAdrian Chadd 
59a6df6cfeSAdrian Chadd #define WPI_DESC(x) case x:	return #x
60a6df6cfeSAdrian Chadd 
wpi_cmd_str(int cmd)61692ad7caSAdrian Chadd static const char *wpi_cmd_str(int cmd)
62692ad7caSAdrian Chadd {
63692ad7caSAdrian Chadd 	switch (cmd) {
64a6df6cfeSAdrian Chadd 		/* Notifications. */
65a6df6cfeSAdrian Chadd 		WPI_DESC(WPI_UC_READY);
66a6df6cfeSAdrian Chadd 		WPI_DESC(WPI_RX_DONE);
67a6df6cfeSAdrian Chadd 		WPI_DESC(WPI_START_SCAN);
68a6df6cfeSAdrian Chadd 		WPI_DESC(WPI_SCAN_RESULTS);
69a6df6cfeSAdrian Chadd 		WPI_DESC(WPI_STOP_SCAN);
70a6df6cfeSAdrian Chadd 		WPI_DESC(WPI_BEACON_SENT);
71a6df6cfeSAdrian Chadd 		WPI_DESC(WPI_RX_STATISTICS);
72a6df6cfeSAdrian Chadd 		WPI_DESC(WPI_BEACON_STATISTICS);
73a6df6cfeSAdrian Chadd 		WPI_DESC(WPI_STATE_CHANGED);
74a6df6cfeSAdrian Chadd 		WPI_DESC(WPI_BEACON_MISSED);
75692ad7caSAdrian Chadd 
76a6df6cfeSAdrian Chadd 		/* Command notifications. */
77a6df6cfeSAdrian Chadd 		WPI_DESC(WPI_CMD_RXON);
78a6df6cfeSAdrian Chadd 		WPI_DESC(WPI_CMD_RXON_ASSOC);
79a6df6cfeSAdrian Chadd 		WPI_DESC(WPI_CMD_EDCA_PARAMS);
80a6df6cfeSAdrian Chadd 		WPI_DESC(WPI_CMD_TIMING);
81a6df6cfeSAdrian Chadd 		WPI_DESC(WPI_CMD_ADD_NODE);
82a6df6cfeSAdrian Chadd 		WPI_DESC(WPI_CMD_DEL_NODE);
83a6df6cfeSAdrian Chadd 		WPI_DESC(WPI_CMD_TX_DATA);
84a6df6cfeSAdrian Chadd 		WPI_DESC(WPI_CMD_MRR_SETUP);
85a6df6cfeSAdrian Chadd 		WPI_DESC(WPI_CMD_SET_LED);
86a6df6cfeSAdrian Chadd 		WPI_DESC(WPI_CMD_SET_POWER_MODE);
87a6df6cfeSAdrian Chadd 		WPI_DESC(WPI_CMD_SCAN);
886f506674SAdrian Chadd 		WPI_DESC(WPI_CMD_SCAN_ABORT);
89a6df6cfeSAdrian Chadd 		WPI_DESC(WPI_CMD_SET_BEACON);
90a6df6cfeSAdrian Chadd 		WPI_DESC(WPI_CMD_TXPOWER);
91a6df6cfeSAdrian Chadd 		WPI_DESC(WPI_CMD_BT_COEX);
92692ad7caSAdrian Chadd 
93692ad7caSAdrian Chadd 	default:
94692ad7caSAdrian Chadd 		return "UNKNOWN CMD";
95692ad7caSAdrian Chadd 	}
96692ad7caSAdrian Chadd }
97692ad7caSAdrian Chadd 
98a6df6cfeSAdrian Chadd /*
99a6df6cfeSAdrian Chadd  * Translate CSR code to string
100a6df6cfeSAdrian Chadd  */
wpi_get_csr_string(size_t csr)101e43b274aSAdrian Chadd static const char *wpi_get_csr_string(size_t csr)
102a6df6cfeSAdrian Chadd {
103a6df6cfeSAdrian Chadd 	switch (csr) {
104a6df6cfeSAdrian Chadd 		WPI_DESC(WPI_HW_IF_CONFIG);
105a6df6cfeSAdrian Chadd 		WPI_DESC(WPI_INT);
106a6df6cfeSAdrian Chadd 		WPI_DESC(WPI_INT_MASK);
107a6df6cfeSAdrian Chadd 		WPI_DESC(WPI_FH_INT);
108a6df6cfeSAdrian Chadd 		WPI_DESC(WPI_GPIO_IN);
109a6df6cfeSAdrian Chadd 		WPI_DESC(WPI_RESET);
110a6df6cfeSAdrian Chadd 		WPI_DESC(WPI_GP_CNTRL);
111a6df6cfeSAdrian Chadd 		WPI_DESC(WPI_EEPROM);
112a6df6cfeSAdrian Chadd 		WPI_DESC(WPI_EEPROM_GP);
113a6df6cfeSAdrian Chadd 		WPI_DESC(WPI_GIO);
114a6df6cfeSAdrian Chadd 		WPI_DESC(WPI_UCODE_GP1);
115a6df6cfeSAdrian Chadd 		WPI_DESC(WPI_UCODE_GP2);
116a6df6cfeSAdrian Chadd 		WPI_DESC(WPI_GIO_CHICKEN);
117a6df6cfeSAdrian Chadd 		WPI_DESC(WPI_ANA_PLL);
118a6df6cfeSAdrian Chadd 		WPI_DESC(WPI_DBG_HPET_MEM);
119a6df6cfeSAdrian Chadd 	default:
120205cb272SAdrian Chadd 		KASSERT(0, ("Unknown CSR: %d\n", csr));
121a6df6cfeSAdrian Chadd 		return "UNKNOWN CSR";
122a6df6cfeSAdrian Chadd 	}
123a6df6cfeSAdrian Chadd }
124a6df6cfeSAdrian Chadd 
wpi_get_prph_string(size_t prph)125e43b274aSAdrian Chadd static const char *wpi_get_prph_string(size_t prph)
126a6df6cfeSAdrian Chadd {
127a6df6cfeSAdrian Chadd 	switch (prph) {
128a6df6cfeSAdrian Chadd 		WPI_DESC(WPI_APMG_CLK_CTRL);
129a6df6cfeSAdrian Chadd 		WPI_DESC(WPI_APMG_PS);
130a6df6cfeSAdrian Chadd 		WPI_DESC(WPI_APMG_PCI_STT);
131a6df6cfeSAdrian Chadd 		WPI_DESC(WPI_APMG_RFKILL);
132a6df6cfeSAdrian Chadd 	default:
133205cb272SAdrian Chadd 		KASSERT(0, ("Unknown register: %d\n", prph));
134a6df6cfeSAdrian Chadd 		return "UNKNOWN PRPH";
135a6df6cfeSAdrian Chadd 	}
136a6df6cfeSAdrian Chadd }
137a6df6cfeSAdrian Chadd 
138692ad7caSAdrian Chadd #else
139692ad7caSAdrian Chadd #define DPRINTF(sc, m, ...)	do { (void) sc; } while (0)
140692ad7caSAdrian Chadd #endif
141692ad7caSAdrian Chadd 
142692ad7caSAdrian Chadd #endif	/* __IF_WPI_DEBUG_H__ */
143