Author: mav
Date: Wed Jan 28 22:53:41 2009
New Revision: 187876
URL: http://svn.freebsd.org/changeset/base/187876

Log:
  Add hw.sdhci.debug sysctl to control debug level.

Modified:
  head/sys/dev/sdhci/sdhci.c

Modified: head/sys/dev/sdhci/sdhci.c
==============================================================================
--- head/sys/dev/sdhci/sdhci.c  Wed Jan 28 22:09:00 2009        (r187875)
+++ head/sys/dev/sdhci/sdhci.c  Wed Jan 28 22:53:41 2009        (r187876)
@@ -36,6 +36,7 @@ __FBSDID("$FreeBSD$");
 #include <sys/mutex.h>
 #include <sys/resource.h>
 #include <sys/rman.h>
+#include <sys/sysctl.h>
 #include <sys/taskqueue.h>
 
 #include <dev/pci/pcireg.h>
@@ -151,6 +152,12 @@ struct sdhci_softc {
        struct sdhci_slot slots[6];
 };
 
+SYSCTL_NODE(_hw, OID_AUTO, sdhci, CTLFLAG_RD, 0, "sdhci driver");
+
+int    sdhci_debug;
+TUNABLE_INT("hw.sdhci.debug", &sdhci_debug);
+SYSCTL_INT(_hw_sdhci, OID_AUTO, debug, CTLFLAG_RW, &sdhci_debug, 0, "Debug 
level");
+
 static inline uint8_t
 RD1(struct sdhci_slot *slot, bus_size_t off)
 {
@@ -734,7 +741,7 @@ sdhci_attach(device_t dev)
                if (sc->quirks & SDHCI_QUIRK_FORCE_DMA)
                        slot->opt |= SDHCI_HAVE_DMA;
 
-               if (bootverbose) {
+               if (bootverbose || sdhci_debug) {
                        slot_printf(slot, "%uMHz%s 4bits%s%s%s %s\n",
                            slot->max_clk / 1000000,
                            (caps & SDHCI_CAN_DO_HISPD) ? " HS" : "",
@@ -1146,17 +1153,10 @@ sdhci_start(struct sdhci_slot *slot)
                return;
        }
 */
-       if (req->cmd->error) {
-               if (bootverbose) {
-                       slot_printf(slot,
-                           "Command error %d (opcode %u arg %u flags %u "
-                           "dlen %u dflags %u)\n",
-                           req->cmd->error, req->cmd->opcode, req->cmd->arg,
-                           req->cmd->flags,
-                           (req->cmd->data)?(u_int)req->cmd->data->len:0,
-                           (req->cmd->data)?(u_int)req->cmd->data->flags:0);
-               }
-       } else if (slot->sc->quirks & SDHCI_QUIRK_RESET_AFTER_REQUEST) {
+       if (sdhci_debug > 1)
+               slot_printf(slot, "result: %d\n", req->cmd->error);
+       if (!req->cmd->error &&
+           (slot->sc->quirks & SDHCI_QUIRK_RESET_AFTER_REQUEST)) {
                sdhci_reset(slot, SDHCI_RESET_CMD);
                sdhci_reset(slot, SDHCI_RESET_DATA);
        }
@@ -1177,9 +1177,12 @@ sdhci_request(device_t brdev, device_t r
                SDHCI_UNLOCK(slot);
                return (EBUSY);
        }
-/*     printf("%s cmd op %u arg %u flags %u data %ju\n", __func__,
-           req->cmd->opcode, req->cmd->arg, req->cmd->flags,
-           (req->cmd->data)?req->cmd->data->len:0); */
+       if (sdhci_debug > 1) {
+               slot_printf(slot, "CMD%u arg %#x flags %#x dlen %u dflags 
%#x\n",
+                   req->cmd->opcode, req->cmd->arg, req->cmd->flags,
+                   (req->cmd->data)?(u_int)req->cmd->data->len:0,
+                   (req->cmd->data)?req->cmd->data->flags:0);
+       }
        slot->req = req;
        slot->flags = 0;
        sdhci_start(slot);
@@ -1363,23 +1366,23 @@ sdhci_intr(void *arg)
                        SDHCI_UNLOCK(slot);
                        continue;
                }
-/*
-               slot_printf(slot, "got interrupt %x\n", intmask);
-*/
+               if (sdhci_debug > 2)
+                       slot_printf(slot, "Interrupt %#x\n", intmask);
+
                /* Handle card presence interrupts. */
                if (intmask & (SDHCI_INT_CARD_INSERT | SDHCI_INT_CARD_REMOVE)) {
                        WR4(slot, SDHCI_INT_STATUS, intmask & 
                            (SDHCI_INT_CARD_INSERT | SDHCI_INT_CARD_REMOVE));
 
                        if (intmask & SDHCI_INT_CARD_REMOVE) {
-                               if (bootverbose)
+                               if (bootverbose || sdhci_debug)
                                        slot_printf(slot, "Card removed\n");
                                callout_stop(&slot->card_callout);
                                taskqueue_enqueue(taskqueue_swi_giant,
                                    &slot->card_task);
                        }
                        if (intmask & SDHCI_INT_CARD_INSERT) {
-                               if (bootverbose)
+                               if (bootverbose || sdhci_debug)
                                        slot_printf(slot, "Card inserted\n");
                                callout_reset(&slot->card_callout, hz / 2,
                                    sdhci_card_delay, slot);
_______________________________________________
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"

Reply via email to