summaryrefslogtreecommitdiffstats
path: root/sys/dev/sdhci/sdhci.c
diff options
context:
space:
mode:
authormav <mav@FreeBSD.org>2009-01-28 22:53:41 +0000
committermav <mav@FreeBSD.org>2009-01-28 22:53:41 +0000
commit77bcbda08051ed321f3145e2ff4b3a6fb5af49f2 (patch)
treeb7f77e5b05a8ca21eed8dfa5f913bb12671d3e18 /sys/dev/sdhci/sdhci.c
parent3feadc7bee1564867a0cceb910ae2909ceb6a3ed (diff)
downloadFreeBSD-src-77bcbda08051ed321f3145e2ff4b3a6fb5af49f2.zip
FreeBSD-src-77bcbda08051ed321f3145e2ff4b3a6fb5af49f2.tar.gz
Add hw.sdhci.debug sysctl to control debug level.
Diffstat (limited to 'sys/dev/sdhci/sdhci.c')
-rw-r--r--sys/dev/sdhci/sdhci.c43
1 files changed, 23 insertions, 20 deletions
diff --git a/sys/dev/sdhci/sdhci.c b/sys/dev/sdhci/sdhci.c
index 86b6283..bf5fdac 100644
--- a/sys/dev/sdhci/sdhci.c
+++ b/sys/dev/sdhci/sdhci.c
@@ -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 reqdev, struct mmc_request *req)
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);
OpenPOWER on IntegriCloud