Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/nick-nhusb]: src/sys Convert to USBHIST
details: https://anonhg.NetBSD.org/src/rev/9697b71d67e5
branches: nick-nhusb
changeset: 334145:9697b71d67e5
user: skrll <skrll%NetBSD.org@localhost>
date: Mon Mar 09 14:26:31 2015 +0000
description:
Convert to USBHIST
diffstat:
sys/arch/arm/omap/tiotg.c | 31 ++-
sys/dev/usb/motg.c | 318 ++++++++++++++++++++++++++-------------------
2 files changed, 202 insertions(+), 147 deletions(-)
diffs (truncated from 905 to 300 lines):
diff -r c92f2eda0181 -r 9697b71d67e5 sys/arch/arm/omap/tiotg.c
--- a/sys/arch/arm/omap/tiotg.c Mon Mar 09 14:24:17 2015 +0000
+++ b/sys/arch/arm/omap/tiotg.c Mon Mar 09 14:26:31 2015 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: tiotg.c,v 1.2.8.2 2014/12/03 12:52:05 skrll Exp $ */
+/* $NetBSD: tiotg.c,v 1.2.8.3 2015/03/09 14:26:31 skrll Exp $ */
/*
* Copyright (c) 2013 Manuel Bouyer. All rights reserved.
*
@@ -24,7 +24,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: tiotg.c,v 1.2.8.2 2014/12/03 12:52:05 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: tiotg.c,v 1.2.8.3 2015/03/09 14:26:31 skrll Exp $");
#include "opt_omap.h"
#include "locators.h"
@@ -56,14 +56,19 @@
#include <dev/usb/usb_mem.h>
#include <dev/usb/motgreg.h>
#include <dev/usb/motgvar.h>
+#include <dev/usb/usbhist.h>
-#define MOTG_DEBUG
-#ifdef MOTG_DEBUG
+#ifdef USB_DEBUG
+#ifndef MOTG_DEBUG
+#define motgdebug 0
+#else
extern int motgdebug;
-#define DPRINTF(x) if (motgdebug) printf x
-#else
-#define DPRINTF(x)
-#endif
+#endif /* MOTG_DEBUG */
+#endif /* USB_DEBUG */
+
+#define DPRINTF(FMT,A,B,C,D) USBHIST_LOGN(motgdebug,1,FMT,A,B,C,D)
+#define MOTGHIST_FUNC() USBHIST_FUNC()
+#define MOTGHIST_CALLED(name) USBHIST_CALLED(motgdebug)
struct tiotg_softc {
device_t sc_dev;
@@ -283,6 +288,7 @@
const char *mode;
u_int state;
#endif
+ MOTGHIST_FUNC(); MOTGHIST_CALLED();
sc->sc_motg.sc_dev = self;
sc->sc_ctrliot = aa->aa_iot;
@@ -317,14 +323,14 @@
}
/* turn clock on */
sitara_cm_reg_read_4(tiotg_port_control[sc->sc_ctrlport].scm_reg, &val);
- DPRINTF((" power val 0x%x", val));
+ DPRINTF("power val 0x%x", val, 0, 0, 0);
/* Enable power */
val &= ~(OMAP2SCM_USB_CTLx_OTGPHY_PWD | OMAP2SCM_USB_CTLx_CMPHY_PWD);
/* enable vbus detect and session end */
val |= (OMAP2SCM_USB_CTLx_VBUSDET | OMAP2SCM_USB_CTLx_SESSIONEND);
sitara_cm_reg_write_4(tiotg_port_control[sc->sc_ctrlport].scm_reg, val);
sitara_cm_reg_read_4(tiotg_port_control[sc->sc_ctrlport].scm_reg, &val);
- DPRINTF(("now val 0x%x ", val));
+ DPRINTF("now val 0x%x", val, 0, 0, 0);
#endif
/* XXX configure mode */
if (sc->sc_ctrlport == 0)
@@ -380,12 +386,13 @@
int rv = 0;
int i;
+ MOTGHIST_FUNC(); MOTGHIST_CALLED();
+
mutex_spin_enter(&sc->sc_motg.sc_intr_lock);
stat = TIOTG_USBC_READ4(sc, USBCTRL_STAT);
stat0 = TIOTG_USBC_READ4(sc, USBCTRL_IRQ_STAT0);
stat1 = TIOTG_USBC_READ4(sc, USBCTRL_IRQ_STAT1);
- DPRINTF(("USB %d 0x%x 0x%x stat %d\n",
- sc->sc_ctrlport, stat0, stat1, stat));
+ DPRINTF("USB %d 0x%x 0x%x stat %d", sc->sc_ctrlport, stat0, stat1, stat);
/* try to deal with vbus errors */
if (stat1 & MUSB2_MASK_IVBUSERR ) {
stat1 &= ~MUSB2_MASK_IVBUSERR;
diff -r c92f2eda0181 -r 9697b71d67e5 sys/dev/usb/motg.c
--- a/sys/dev/usb/motg.c Mon Mar 09 14:24:17 2015 +0000
+++ b/sys/dev/usb/motg.c Mon Mar 09 14:26:31 2015 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: motg.c,v 1.12.2.15 2015/03/09 14:24:17 skrll Exp $ */
+/* $NetBSD: motg.c,v 1.12.2.16 2015/03/09 14:26:31 skrll Exp $ */
/*
* Copyright (c) 1998, 2004, 2011, 2012, 2014 The NetBSD Foundation, Inc.
@@ -42,7 +42,7 @@
#include "opt_motg.h"
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: motg.c,v 1.12.2.15 2015/03/09 14:24:17 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: motg.c,v 1.12.2.16 2015/03/09 14:26:31 skrll Exp $");
#include <sys/param.h>
@@ -54,6 +54,7 @@
#include <sys/proc.h>
#include <sys/queue.h>
#include <sys/select.h>
+#include <sys/sysctl.h>
#include <sys/systm.h>
#include <machine/endian.h>
@@ -62,6 +63,7 @@
#include <dev/usb/usbdi.h>
#include <dev/usb/usbdivar.h>
#include <dev/usb/usb_mem.h>
+#include <dev/usb/usbhist.h>
#ifdef MOTG_ALLWINNER
#include <arch/arm/allwinner/awin_otgreg.h>
@@ -72,19 +74,51 @@
#include <dev/usb/motgvar.h>
#include <dev/usb/usbroothub.h>
-#define MOTG_DEBUG
-#ifdef MOTG_DEBUG
-#define DPRINTF(x) if (motgdebug) printf x
-#define DPRINTFN(n,x) if (motgdebug & (n)) printf x
+#ifdef USB_DEBUG
+#ifndef MOTG_DEBUG
+#define motgdebug 0
+#else
+int motgdebug = 0;
+
+SYSCTL_SETUP(sysctl_hw_motg_setup, "sysctl hw.motg setup")
+{
+ int err;
+ const struct sysctlnode *rnode;
+ const struct sysctlnode *cnode;
+
+ err = sysctl_createv(clog, 0, NULL, &rnode,
+ CTLFLAG_PERMANENT, CTLTYPE_NODE, "motg",
+ SYSCTL_DESCR("motg global controls"),
+ NULL, 0, NULL, 0, CTL_HW, CTL_CREATE, CTL_EOL);
+
+ if (err)
+ goto fail;
+
+ /* control debugging printfs */
+ err = sysctl_createv(clog, 0, &rnode, &cnode,
+ CTLFLAG_PERMANENT|CTLFLAG_READWRITE, CTLTYPE_INT,
+ "debug", SYSCTL_DESCR("Enable debugging output"),
+ NULL, 0, &motgdebug, sizeof(motgdebug), CTL_CREATE, CTL_EOL);
+ if (err)
+ goto fail;
+
+ return;
+fail:
+ aprint_error("%s: sysctl_createv failed (err = %d)\n", __func__, err);
+}
+
+#endif /* MOTG_DEBUG */
+#endif /* USB_DEBUG */
+
#define MD_ROOT 0x0002
#define MD_CTRL 0x0004
#define MD_BULK 0x0008
-// int motgdebug = MD_ROOT | MD_CTRL | MD_BULK;
-int motgdebug = 0;
-#else
-#define DPRINTF(x)
-#define DPRINTFN(n,x)
-#endif
+
+#define DPRINTF(FMT,A,B,C,D) USBHIST_LOGN(motgdebug,1,FMT,A,B,C,D)
+#define DPRINTFN(N,FMT,A,B,C,D) USBHIST_LOGM(motgdebug,N,FMT,A,B,C,D)
+#define MOTGHIST_FUNC() USBHIST_FUNC()
+#define MOTGHIST_CALLED(name) USBHIST_CALLED(motgdebug)
+
/* various timeouts, for various speeds */
/* control NAK timeouts */
@@ -240,6 +274,8 @@
int dynfifo;
int offset, i;
+ MOTGHIST_FUNC(); MOTGHIST_CALLED();
+
if (sc->sc_mode == MOTG_MODE_DEVICE)
return ENOTSUP; /* not supported */
@@ -274,7 +310,7 @@
UWRITE1(sc, MUSB2_REG_DEVCTL, val);
}
delay(1000);
- DPRINTF(("DEVCTL 0x%x\n", UREAD1(sc, MUSB2_REG_DEVCTL)));
+ DPRINTF("DEVCTL 0x%x", UREAD1(sc, MUSB2_REG_DEVCTL), 0, 0, 0);
/* disable testmode */
@@ -298,7 +334,7 @@
/* these numbers exclude the control endpoint */
- DPRINTF(("RX/TX endpoints: %u/%u\n", nrx, ntx));
+ DPRINTFN(1,"RX/TX endpoints: %u/%u", nrx, ntx, 0, 0);
sc->sc_ep_max = MAX(nrx, ntx);
} else {
@@ -312,7 +348,7 @@
/* read out configuration data */
val = UREAD1(sc, MUSB2_REG_CONFDATA);
- DPRINTF(("Config Data: 0x%02x\n", val));
+ DPRINTF("Config Data: 0x%02x", val, 0, 0, 0);
dynfifo = (val & MUSB2_MASK_CD_DYNFIFOSZ) ? 1 : 0;
@@ -321,7 +357,7 @@
"assuming 16Kbytes of FIFO RAM\n");
}
- DPRINTF(("HW version: 0x%04x\n", UREAD1(sc, MUSB2_REG_HWVERS)));
+ DPRINTF("HW version: 0x%04x\n", UREAD1(sc, MUSB2_REG_HWVERS), 0, 0, 0);
/* initialise endpoint profiles */
sc->sc_in_ep[0].ep_fifo_size = 64;
@@ -344,8 +380,8 @@
fifotx_size = (val & MUSB2_MASK_TX_FSIZE);
}
- DPRINTF(("Endpoint %u FIFO size: IN=%u, OUT=%u, DYN=%d\n",
- i, fifotx_size, fiforx_size, dynfifo));
+ DPRINTF("Endpoint %u FIFO size: IN=%u, OUT=%u, DYN=%d",
+ i, fifotx_size, fiforx_size, dynfifo);
if (dynfifo) {
if (sc->sc_ep_fifosize) {
@@ -412,7 +448,7 @@
}
- DPRINTF(("Dynamic FIFO size = %d bytes\n", offset));
+ DPRINTF("Dynamic FIFO size = %d bytes", offset, 0, 0, 0);
/* turn on default interrupts */
@@ -449,14 +485,17 @@
struct motg_hw_ep *ep;
int i, size;
+ MOTGHIST_FUNC(); MOTGHIST_CALLED();
+
ep = (UE_GET_DIR(ed->bEndpointAddress) == UE_DIR_IN) ?
sc->sc_in_ep : sc->sc_out_ep;
size = UE_GET_SIZE(UGETW(pipe->up_endpoint->ue_edesc->wMaxPacketSize));
for (i = sc->sc_ep_max; i >= 1; i--) {
- DPRINTF(("%s_ep[%d].ep_fifo_size %d size %d ref %d\n",
- (UE_GET_DIR(ed->bEndpointAddress) == UE_DIR_IN) ?
- "in" : "out", i, ep[i].ep_fifo_size, size, ep[i].refcount));
+ DPRINTF(UE_GET_DIR(ed->bEndpointAddress) == UE_DIR_IN ?
+ "in_ep[%d].ep_fifo_size %d size %d ref %d" :
+ "out_ep[%d].ep_fifo_size %d size %d ref %d", i,
+ ep[i].ep_fifo_size, size, ep[i].refcount);
if (ep[i].ep_fifo_size >= size) {
/* found a suitable endpoint */
otgpipe->hw_ep = &ep[i];
@@ -486,9 +525,10 @@
usb_endpoint_descriptor_t *ed = pipe->up_endpoint->ue_edesc;
uint8_t rhaddr = pipe->up_dev->ud_bus->ub_rhaddr;
- DPRINTF(("motg_open: pipe=%p, addr=%d, endpt=%d (%d)\n",
- pipe, pipe->up_dev->ud_addr,
- ed->bEndpointAddress, rhaddr));
+ MOTGHIST_FUNC(); MOTGHIST_CALLED();
+
+ DPRINTF("pipe=%p, addr=%d, endpt=%d (%d)", pipe,
+ pipe->up_dev->ud_addr, ed->bEndpointAddress, rhaddr);
if (sc->sc_dying)
return USBD_IOERROR;
@@ -522,11 +562,10 @@
case UE_BULK:
case UE_INTERRUPT:
DPRINTFN(MD_BULK,
- ("new %s %s pipe wMaxPacketSize %d\n",
- (ed->bmAttributes & UE_XFERTYPE) == UE_BULK ?
- "bulk" : "interrupt",
- (UE_GET_DIR(pipe->up_endpoint->ue_edesc->bEndpointAddress) == UE_DIR_IN) ? "read" : "write",
- UGETW(pipe->up_endpoint->ue_edesc->wMaxPacketSize)));
+ "type %d dir %d pipe wMaxPacketSize %d",
+ UE_GET_XFERTYPE(ed->bmAttributes),
+ UE_GET_DIR(pipe->up_endpoint->ue_edesc->bEndpointAddress),
+ UGETW(pipe->up_endpoint->ue_edesc->wMaxPacketSize), 0);
if (motg_select_ep(sc, pipe) != 0)
goto bad;
KASSERT(otgpipe->hw_ep != NULL);
@@ -558,10 +597,11 @@
uint32_t val;
int i;
Home |
Main Index |
Thread Index |
Old Index