]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - sys/dev/wpi/if_wpi_debug.h
Add ELF Tool Chain's ar(1) and elfdump(1) to contrib
[FreeBSD/FreeBSD.git] / sys / dev / wpi / if_wpi_debug.h
1 /*-
2  * Copyright (c) 2006,2007
3  *      Damien Bergamini <damien.bergamini@free.fr>
4  *      Benjamin Close <Benjamin.Close@clearchain.com>
5  *
6  * Permission to use, copy, modify, and distribute this software for any
7  * purpose with or without fee is hereby granted, provided that the above
8  * copyright notice and this permission notice appear in all copies.
9  *
10  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17  *
18  * $FreeBSD$
19  */
20
21 #ifndef __IF_WPI_DEBUG_H__
22 #define __IF_WPI_DEBUG_H__
23
24 #ifdef WPI_DEBUG
25 enum {
26         WPI_DEBUG_XMIT          = 0x00000001,   /* basic xmit operation */
27         WPI_DEBUG_RECV          = 0x00000002,   /* basic recv operation */
28         WPI_DEBUG_STATE         = 0x00000004,   /* 802.11 state transitions */
29         WPI_DEBUG_HW            = 0x00000008,   /* Stage 1 (eeprom) debugging */
30         WPI_DEBUG_RESET         = 0x00000010,   /* reset processing */
31         WPI_DEBUG_FIRMWARE      = 0x00000020,   /* firmware(9) loading debug */
32         WPI_DEBUG_BEACON        = 0x00000040,   /* beacon handling */
33         WPI_DEBUG_WATCHDOG      = 0x00000080,   /* watchdog timeout */
34         WPI_DEBUG_INTR          = 0x00000100,   /* ISR */
35         WPI_DEBUG_SCAN          = 0x00000200,   /* Scan related operations */
36         WPI_DEBUG_NOTIFY        = 0x00000400,   /* State 2 Notif intr debug */
37         WPI_DEBUG_TEMP          = 0x00000800,   /* TXPower/Temp Calibration */
38         WPI_DEBUG_CMD           = 0x00001000,   /* cmd submission */
39         WPI_DEBUG_TRACE         = 0x00002000,   /* Print begin and start driver function */
40         WPI_DEBUG_PWRSAVE       = 0x00004000,   /* Power save operations */
41         WPI_DEBUG_EEPROM        = 0x00008000,   /* EEPROM info */
42         WPI_DEBUG_NODE          = 0x00010000,   /* node addition/removal */
43         WPI_DEBUG_KEY           = 0x00020000,   /* node key management */
44         WPI_DEBUG_EDCA          = 0x00040000,   /* WME info */
45         WPI_DEBUG_REGISTER      = 0x00080000,   /* print chipset register */
46         WPI_DEBUG_BMISS         = 0x00100000,   /* print number of missed beacons */
47         WPI_DEBUG_ANY           = 0xffffffff
48 };
49
50 #define DPRINTF(sc, m, ...) do {                \
51         if (sc->sc_debug & (m))                 \
52                 printf(__VA_ARGS__);            \
53 } while (0)
54
55 #define TRACE_STR_BEGIN         "->%s: begin\n"
56 #define TRACE_STR_DOING         "->Doing %s\n"
57 #define TRACE_STR_END           "->%s: end\n"
58 #define TRACE_STR_END_ERR       "->%s: end in error\n"
59
60 #define WPI_DESC(x) case x:     return #x
61
62 static const char *wpi_cmd_str(int cmd)
63 {
64         switch (cmd) {
65                 /* Notifications. */
66                 WPI_DESC(WPI_UC_READY);
67                 WPI_DESC(WPI_RX_DONE);
68                 WPI_DESC(WPI_START_SCAN);
69                 WPI_DESC(WPI_SCAN_RESULTS);
70                 WPI_DESC(WPI_STOP_SCAN);
71                 WPI_DESC(WPI_BEACON_SENT);
72                 WPI_DESC(WPI_RX_STATISTICS);
73                 WPI_DESC(WPI_BEACON_STATISTICS);
74                 WPI_DESC(WPI_STATE_CHANGED);
75                 WPI_DESC(WPI_BEACON_MISSED);
76
77                 /* Command notifications. */
78                 WPI_DESC(WPI_CMD_RXON);
79                 WPI_DESC(WPI_CMD_RXON_ASSOC);
80                 WPI_DESC(WPI_CMD_EDCA_PARAMS);
81                 WPI_DESC(WPI_CMD_TIMING);
82                 WPI_DESC(WPI_CMD_ADD_NODE);
83                 WPI_DESC(WPI_CMD_DEL_NODE);
84                 WPI_DESC(WPI_CMD_TX_DATA);
85                 WPI_DESC(WPI_CMD_MRR_SETUP);
86                 WPI_DESC(WPI_CMD_SET_LED);
87                 WPI_DESC(WPI_CMD_SET_POWER_MODE);
88                 WPI_DESC(WPI_CMD_SCAN);
89                 WPI_DESC(WPI_CMD_SCAN_ABORT);
90                 WPI_DESC(WPI_CMD_SET_BEACON);
91                 WPI_DESC(WPI_CMD_TXPOWER);
92                 WPI_DESC(WPI_CMD_BT_COEX);
93
94         default:
95                 return "UNKNOWN CMD";
96         }
97 }
98
99 /*
100  * Translate CSR code to string
101  */
102 static const char *wpi_get_csr_string(size_t csr)
103 {
104         switch (csr) {
105                 WPI_DESC(WPI_HW_IF_CONFIG);
106                 WPI_DESC(WPI_INT);
107                 WPI_DESC(WPI_INT_MASK);
108                 WPI_DESC(WPI_FH_INT);
109                 WPI_DESC(WPI_GPIO_IN);
110                 WPI_DESC(WPI_RESET);
111                 WPI_DESC(WPI_GP_CNTRL);
112                 WPI_DESC(WPI_EEPROM);
113                 WPI_DESC(WPI_EEPROM_GP);
114                 WPI_DESC(WPI_GIO);
115                 WPI_DESC(WPI_UCODE_GP1);
116                 WPI_DESC(WPI_UCODE_GP2);
117                 WPI_DESC(WPI_GIO_CHICKEN);
118                 WPI_DESC(WPI_ANA_PLL);
119                 WPI_DESC(WPI_DBG_HPET_MEM);
120         default:
121                 KASSERT(0, ("Unknown CSR: %d\n", csr));
122                 return "UNKNOWN CSR";
123         }
124 }
125
126 static const char *wpi_get_prph_string(size_t prph)
127 {
128         switch (prph) {
129                 WPI_DESC(WPI_APMG_CLK_CTRL);
130                 WPI_DESC(WPI_APMG_PS);
131                 WPI_DESC(WPI_APMG_PCI_STT);
132                 WPI_DESC(WPI_APMG_RFKILL);
133         default:
134                 KASSERT(0, ("Unknown register: %d\n", prph));
135                 return "UNKNOWN PRPH";
136         }
137 }
138
139 #else
140 #define DPRINTF(sc, m, ...)     do { (void) sc; } while (0)
141 #endif
142
143 #endif  /* __IF_WPI_DEBUG_H__ */