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