aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Buesch <mb@bu3sch.de>2008-05-17 16:44:35 -0400
committerJohn W. Linville <linville@tuxdriver.com>2008-05-21 21:48:15 -0400
commite48b0eeb0ab508021b654a45f332b30cac2163b9 (patch)
tree57e90c75b42416e58080c055f30d48135d946c0d
parente2530083609148a7835b54c431f6b8956407c1f6 (diff)
b43: Add hooks for firmware debugging
This patch adds some hooks for firmware debugging. Signed-off-by: Michael Buesch <mb@bu3sch.de> Signed-off-by: John W. Linville <linville@tuxdriver.com>
-rw-r--r--drivers/net/wireless/b43/b43.h9
-rw-r--r--drivers/net/wireless/b43/main.c79
2 files changed, 81 insertions, 7 deletions
diff --git a/drivers/net/wireless/b43/b43.h b/drivers/net/wireless/b43/b43.h
index aa493830a82d..00468594b456 100644
--- a/drivers/net/wireless/b43/b43.h
+++ b/drivers/net/wireless/b43/b43.h
@@ -422,6 +422,12 @@ enum {
422 B43_IRQ_RFKILL | \ 422 B43_IRQ_RFKILL | \
423 B43_IRQ_TX_OK) 423 B43_IRQ_TX_OK)
424 424
425/* Debug-IRQ reasons. */
426#define B43_DEBUGIRQ_PANIC 0 /* The firmware panic'ed */
427#define B43_DEBUGIRQ_DUMP_SHM 1 /* Dump shared SHM */
428#define B43_DEBUGIRQ_DUMP_REGS 2 /* Dump the microcode registers */
429#define B43_DEBUGIRQ_ACK 0xFFFF /* The host writes that to ACK the IRQ */
430
425/* Device specific rate values. 431/* Device specific rate values.
426 * The actual values defined here are (rate_in_mbps * 2). 432 * The actual values defined here are (rate_in_mbps * 2).
427 * Some code depends on this. Don't change it. */ 433 * Some code depends on this. Don't change it. */
@@ -765,6 +771,9 @@ struct b43_firmware {
765 u16 rev; 771 u16 rev;
766 /* Firmware patchlevel */ 772 /* Firmware patchlevel */
767 u16 patch; 773 u16 patch;
774
775 /* Set to true, if we are using an opensource firmware. */
776 bool opensource;
768}; 777};
769 778
770/* Device (802.11 core) initialization status. */ 779/* Device (802.11 core) initialization status. */
diff --git a/drivers/net/wireless/b43/main.c b/drivers/net/wireless/b43/main.c
index ff5dce67faa1..656a1f04ad6e 100644
--- a/drivers/net/wireless/b43/main.c
+++ b/drivers/net/wireless/b43/main.c
@@ -1664,7 +1664,64 @@ static void b43_set_beacon_int(struct b43_wldev *dev, u16 beacon_int)
1664 1664
1665static void handle_irq_ucode_debug(struct b43_wldev *dev) 1665static void handle_irq_ucode_debug(struct b43_wldev *dev)
1666{ 1666{
1667 //TODO 1667 unsigned int i, cnt;
1668 u16 reason;
1669 __le16 *buf;
1670
1671 /* The proprietary firmware doesn't have this IRQ. */
1672 if (!dev->fw.opensource)
1673 return;
1674
1675 /* Microcode register 63 contains the debug-IRQ reason. */
1676 reason = b43_shm_read16(dev, B43_SHM_SCRATCH, 63);
1677 switch (reason) {
1678 case B43_DEBUGIRQ_PANIC:
1679 /* The reason for the panic is in register 3. */
1680 reason = b43_shm_read16(dev, B43_SHM_SCRATCH, 3);
1681 b43err(dev->wl, "Whoopsy, the microcode panic'ed! Reason: %u\n",
1682 reason);
1683 b43_controller_restart(dev, "Microcode panic");
1684 break;
1685 case B43_DEBUGIRQ_DUMP_SHM:
1686 if (!B43_DEBUG)
1687 break; /* Only with driver debugging enabled. */
1688 buf = kmalloc(4096, GFP_ATOMIC);
1689 if (!buf) {
1690 b43dbg(dev->wl, "SHM-dump: Failed to allocate memory\n");
1691 goto out;
1692 }
1693 for (i = 0; i < 4096; i += 2) {
1694 u16 tmp = b43_shm_read16(dev, B43_SHM_SHARED, i);
1695 buf[i / 2] = cpu_to_le16(tmp);
1696 }
1697 b43info(dev->wl, "Shared memory dump:\n");
1698 print_hex_dump(KERN_INFO, "", DUMP_PREFIX_OFFSET,
1699 16, 2, buf, 4096, 1);
1700 kfree(buf);
1701 break;
1702 case B43_DEBUGIRQ_DUMP_REGS:
1703 if (!B43_DEBUG)
1704 break; /* Only with driver debugging enabled. */
1705 b43info(dev->wl, "Microcode register dump:\n");
1706 for (i = 0, cnt = 0; i < 64; i++) {
1707 u16 tmp = b43_shm_read16(dev, B43_SHM_SCRATCH, i);
1708 if (cnt == 0)
1709 printk(KERN_INFO);
1710 printk("r%02u: 0x%04X ", i, tmp);
1711 cnt++;
1712 if (cnt == 6) {
1713 printk("\n");
1714 cnt = 0;
1715 }
1716 }
1717 printk("\n");
1718 break;
1719 default:
1720 b43dbg(dev->wl, "Debug-IRQ triggered for unknown reason: %u\n",
1721 reason);
1722 }
1723out:
1724 b43_shm_write16(dev, B43_SHM_SCRATCH, 63, B43_DEBUGIRQ_ACK);
1668} 1725}
1669 1726
1670/* Interrupt handler bottom-half */ 1727/* Interrupt handler bottom-half */
@@ -2122,14 +2179,22 @@ static int b43_upload_microcode(struct b43_wldev *dev)
2122 err = -EOPNOTSUPP; 2179 err = -EOPNOTSUPP;
2123 goto error; 2180 goto error;
2124 } 2181 }
2125 b43info(dev->wl, "Loading firmware version %u.%u "
2126 "(20%.2i-%.2i-%.2i %.2i:%.2i:%.2i)\n",
2127 fwrev, fwpatch,
2128 (fwdate >> 12) & 0xF, (fwdate >> 8) & 0xF, fwdate & 0xFF,
2129 (fwtime >> 11) & 0x1F, (fwtime >> 5) & 0x3F, fwtime & 0x1F);
2130
2131 dev->fw.rev = fwrev; 2182 dev->fw.rev = fwrev;
2132 dev->fw.patch = fwpatch; 2183 dev->fw.patch = fwpatch;
2184 dev->fw.opensource = (fwdate == 0xFFFF);
2185
2186 if (dev->fw.opensource) {
2187 /* Patchlevel info is encoded in the "time" field. */
2188 dev->fw.patch = fwtime;
2189 b43info(dev->wl, "Loading OpenSource firmware version %u.%u\n",
2190 dev->fw.rev, dev->fw.patch);
2191 } else {
2192 b43info(dev->wl, "Loading firmware version %u.%u "
2193 "(20%.2i-%.2i-%.2i %.2i:%.2i:%.2i)\n",
2194 fwrev, fwpatch,
2195 (fwdate >> 12) & 0xF, (fwdate >> 8) & 0xF, fwdate & 0xFF,
2196 (fwtime >> 11) & 0x1F, (fwtime >> 5) & 0x3F, fwtime & 0x1F);
2197 }
2133 2198
2134 if (b43_is_old_txhdr_format(dev)) { 2199 if (b43_is_old_txhdr_format(dev)) {
2135 b43warn(dev->wl, "You are using an old firmware image. " 2200 b43warn(dev->wl, "You are using an old firmware image. "