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 */ 46*3e54d9fdSAdrian 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); 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 */ 101a6df6cfeSAdrian Chadd static const char *wpi_get_csr_string(int 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 125a6df6cfeSAdrian Chadd static const char *wpi_get_prph_string(int 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