1*2b27bdccSThomas Gleixner /* SPDX-License-Identifier: GPL-2.0-only */ 27b3115f2SLuciano Coelho /* 37b3115f2SLuciano Coelho * This file is part of wl12xx 47b3115f2SLuciano Coelho * 57b3115f2SLuciano Coelho * Copyright (C) 2011 Texas Instruments. All rights reserved. 67b3115f2SLuciano Coelho * Copyright (C) 2008-2009 Nokia Corporation 77b3115f2SLuciano Coelho * 87b3115f2SLuciano Coelho * Contact: Luciano Coelho <coelho@ti.com> 97b3115f2SLuciano Coelho */ 107b3115f2SLuciano Coelho 117b3115f2SLuciano Coelho #ifndef __DEBUG_H__ 127b3115f2SLuciano Coelho #define __DEBUG_H__ 137b3115f2SLuciano Coelho 147b3115f2SLuciano Coelho #include <linux/bitops.h> 157b3115f2SLuciano Coelho #include <linux/printk.h> 167b3115f2SLuciano Coelho 17fc3d1db5SArik Nemtsov #define DRIVER_NAME "wlcore" 187b3115f2SLuciano Coelho #define DRIVER_PREFIX DRIVER_NAME ": " 197b3115f2SLuciano Coelho 207b3115f2SLuciano Coelho enum { 217b3115f2SLuciano Coelho DEBUG_NONE = 0, 227b3115f2SLuciano Coelho DEBUG_IRQ = BIT(0), 237b3115f2SLuciano Coelho DEBUG_SPI = BIT(1), 247b3115f2SLuciano Coelho DEBUG_BOOT = BIT(2), 257b3115f2SLuciano Coelho DEBUG_MAILBOX = BIT(3), 267b3115f2SLuciano Coelho DEBUG_TESTMODE = BIT(4), 277b3115f2SLuciano Coelho DEBUG_EVENT = BIT(5), 287b3115f2SLuciano Coelho DEBUG_TX = BIT(6), 297b3115f2SLuciano Coelho DEBUG_RX = BIT(7), 307b3115f2SLuciano Coelho DEBUG_SCAN = BIT(8), 317b3115f2SLuciano Coelho DEBUG_CRYPT = BIT(9), 327b3115f2SLuciano Coelho DEBUG_PSM = BIT(10), 337b3115f2SLuciano Coelho DEBUG_MAC80211 = BIT(11), 347b3115f2SLuciano Coelho DEBUG_CMD = BIT(12), 357b3115f2SLuciano Coelho DEBUG_ACX = BIT(13), 367b3115f2SLuciano Coelho DEBUG_SDIO = BIT(14), 377b3115f2SLuciano Coelho DEBUG_FILTERS = BIT(15), 387b3115f2SLuciano Coelho DEBUG_ADHOC = BIT(16), 397b3115f2SLuciano Coelho DEBUG_AP = BIT(17), 407b3115f2SLuciano Coelho DEBUG_PROBE = BIT(18), 4125a43d78SLuciano Coelho DEBUG_IO = BIT(19), 427b3115f2SLuciano Coelho DEBUG_MASTER = (DEBUG_ADHOC | DEBUG_AP), 437b3115f2SLuciano Coelho DEBUG_ALL = ~0, 447b3115f2SLuciano Coelho }; 457b3115f2SLuciano Coelho 467b3115f2SLuciano Coelho extern u32 wl12xx_debug_level; 477b3115f2SLuciano Coelho 487b3115f2SLuciano Coelho #define DEBUG_DUMP_LIMIT 1024 497b3115f2SLuciano Coelho 507b3115f2SLuciano Coelho #define wl1271_error(fmt, arg...) \ 517b3115f2SLuciano Coelho pr_err(DRIVER_PREFIX "ERROR " fmt "\n", ##arg) 527b3115f2SLuciano Coelho 537b3115f2SLuciano Coelho #define wl1271_warning(fmt, arg...) \ 54fe3881cfSJoe Perches pr_warn(DRIVER_PREFIX "WARNING " fmt "\n", ##arg) 557b3115f2SLuciano Coelho 567b3115f2SLuciano Coelho #define wl1271_notice(fmt, arg...) \ 577b3115f2SLuciano Coelho pr_info(DRIVER_PREFIX fmt "\n", ##arg) 587b3115f2SLuciano Coelho 597b3115f2SLuciano Coelho #define wl1271_info(fmt, arg...) \ 607b3115f2SLuciano Coelho pr_info(DRIVER_PREFIX fmt "\n", ##arg) 617b3115f2SLuciano Coelho 62fc3d1db5SArik Nemtsov /* define the debug macro differently if dynamic debug is supported */ 63fc3d1db5SArik Nemtsov #if defined(CONFIG_DYNAMIC_DEBUG) 647b3115f2SLuciano Coelho #define wl1271_debug(level, fmt, arg...) \ 657b3115f2SLuciano Coelho do { \ 66fc3d1db5SArik Nemtsov if (unlikely(level & wl12xx_debug_level)) \ 67fc3d1db5SArik Nemtsov dynamic_pr_debug(DRIVER_PREFIX fmt "\n", ##arg); \ 687b3115f2SLuciano Coelho } while (0) 69fc3d1db5SArik Nemtsov #else 70fc3d1db5SArik Nemtsov #define wl1271_debug(level, fmt, arg...) \ 71fc3d1db5SArik Nemtsov do { \ 72fc3d1db5SArik Nemtsov if (unlikely(level & wl12xx_debug_level)) \ 73fc3d1db5SArik Nemtsov printk(KERN_DEBUG pr_fmt(DRIVER_PREFIX fmt "\n"), \ 74fc3d1db5SArik Nemtsov ##arg); \ 75fc3d1db5SArik Nemtsov } while (0) 76fc3d1db5SArik Nemtsov #endif 777b3115f2SLuciano Coelho 787b3115f2SLuciano Coelho #define wl1271_dump(level, prefix, buf, len) \ 797b3115f2SLuciano Coelho do { \ 807b3115f2SLuciano Coelho if (level & wl12xx_debug_level) \ 81da7aa280SLuciano Coelho print_hex_dump_debug(DRIVER_PREFIX prefix, \ 827b3115f2SLuciano Coelho DUMP_PREFIX_OFFSET, 16, 1, \ 837b3115f2SLuciano Coelho buf, \ 847b3115f2SLuciano Coelho min_t(size_t, len, DEBUG_DUMP_LIMIT), \ 857b3115f2SLuciano Coelho 0); \ 867b3115f2SLuciano Coelho } while (0) 877b3115f2SLuciano Coelho 887b3115f2SLuciano Coelho #define wl1271_dump_ascii(level, prefix, buf, len) \ 897b3115f2SLuciano Coelho do { \ 907b3115f2SLuciano Coelho if (level & wl12xx_debug_level) \ 91da7aa280SLuciano Coelho print_hex_dump_debug(DRIVER_PREFIX prefix, \ 927b3115f2SLuciano Coelho DUMP_PREFIX_OFFSET, 16, 1, \ 937b3115f2SLuciano Coelho buf, \ 947b3115f2SLuciano Coelho min_t(size_t, len, DEBUG_DUMP_LIMIT), \ 957b3115f2SLuciano Coelho true); \ 967b3115f2SLuciano Coelho } while (0) 977b3115f2SLuciano Coelho 987b3115f2SLuciano Coelho #endif /* __DEBUG_H__ */ 99