musb: output raw register contents on every debug message
authorPaul Fertser <fercerpav@gmail.com>
Fri, 29 Oct 2010 11:24:28 +0000 (15:24 +0400)
committerPaul Fertser <fercerpav@gmail.com>
Fri, 29 Oct 2010 11:24:28 +0000 (15:24 +0400)
This extends the debug function to read and output to the log the contents
of important registers every time it is called. Allows to better trace
state transitions.

drivers/usb/musb/musb_core.c
drivers/usb/musb/musb_debug.h
drivers/usb/musb/musb_gadget.c
drivers/usb/musb/musb_host.c
drivers/usb/musb/musb_regs.h
drivers/usb/musb/musbhsdma.c
drivers/usb/musb/omap2430.c

index 6cb7d13..e172ca6 100644 (file)
@@ -344,7 +344,7 @@ void musb_write_fifo(struct musb_hw_ep *hw_ep, u16 len, const u8 *src)
 
        prefetch((u8 *)src);
 
-       DBG(4, "%cX ep%d fifo %p count %d buf %p\n",
+       DBG_nonverb(4, "%cX ep%d fifo %p count %d buf %p\n",
                        'T', hw_ep->epnum, fifo, len, src);
 
        /* we can't assume unaligned reads work */
@@ -382,7 +382,7 @@ void musb_read_fifo(struct musb_hw_ep *hw_ep, u16 len, u8 *dst)
 {
        void __iomem *fifo = hw_ep->fifo;
 
-       DBG(4, "%cX ep%d fifo %p count %d buf %p\n",
+       DBG_nonverb(4, "%cX ep%d fifo %p count %d buf %p\n",
                        'R', hw_ep->epnum, fifo, len, dst);
 
        /* we can't assume unaligned writes work */
@@ -570,9 +570,10 @@ static irqreturn_t musb_stage0_irq(struct musb *musb, u8 int_usb,
        irqreturn_t handled = IRQ_NONE;
        void __iomem *mbase = musb->mregs;
        u8 r;
+       u8 testmode = musb_readb(musb->mregs, MUSB_TESTMODE);
 
-       DBG(3, "<== Power=%02x, DevCtl=%02x, int_usb=0x%x\n", power, devctl,
-               int_usb);
+       DBG(3, "<== State=%s Testmode=%02x Power=%02x, DevCtl=%02x, int_usb=0x%x\n",
+               otg_state_string(musb), testmode, power, devctl, int_usb);
 
        /* in host mode, the peripheral may issue remote wakeup.
         * in peripheral mode, the host may resume the link.
index 913815d..040b330 100644 (file)
@@ -46,6 +46,21 @@ extern const char *otg_state_string(struct musb *);
 
 #ifdef CONFIG_USB_MUSB_DEBUG
 
+#define xprintk_verb(level, facility, format, args...) do { \
+       if (_dbg_level(level)) { \
+                       u8 testmode, devctl, power/*, otg_ctrl, func_ctrl, isp_debug*/; \
+                       testmode = musb_readb(musb->mregs, MUSB_TESTMODE); \
+                       devctl = musb_readb(musb->mregs, MUSB_DEVCTL); \
+                       power = musb_readb(musb->mregs, MUSB_POWER); \
+                       /*otg_ctrl = musb_ulpi_readb(musb->mregs, ISP1704_OTG_CTRL); \
+                       func_ctrl = musb_ulpi_readb(musb->mregs, ISP1704_FUNC_CTRL); \
+                       isp_debug = musb_ulpi_readb(musb->mregs, ISP1704_DEBUG); */ \
+                       printk(facility "State=%s Testmode=%02x Power=%02x, DevCtl=%02x\n", \
+                               otg_state_string(musb), testmode, power, devctl/*, otg_ctrl, func_ctrl, isp_debug*/); \
+                       printk(facility "%-20s %4d: " format , \
+                               __func__, __LINE__ , ## args); \
+       } } while (0)
+
 #define xprintk(level, facility, format, args...) do { \
        if (_dbg_level(level)) { \
                printk(facility "%-20s %4d: " format , \
@@ -58,7 +73,8 @@ static inline int _dbg_level(unsigned l)
 {
        return musb_debug >= l;
 }
-#define DBG(level, fmt, args...) xprintk(level, KERN_DEBUG, fmt, ## args)
+#define DBG(level, fmt, args...) xprintk_verb(level, KERN_DEBUG, fmt, ## args)
+#define DBG_nonverb(level, fmt, args...) xprintk(level, KERN_DEBUG, fmt, ## args)
 #else
 #define DBG(level, fmt, args...)       do {} while(0)
 #endif /* CONFIG_USB_MUSB_DEBUG */
index 70d6f91..5f2a1f2 100644 (file)
@@ -816,12 +816,12 @@ static int musb_gadget_enable(struct usb_ep *ep,
        if (!ep || !desc)
                return -EINVAL;
 
+       musb_ep = to_musb_ep(ep);
+       musb = musb_ep->musb;
        DBG(1, "===> enabling %s\n", ep->name);
 
-       musb_ep = to_musb_ep(ep);
        hw_ep = musb_ep->hw_ep;
        regs = hw_ep->regs;
-       musb = musb_ep->musb;
        mbase = musb->mregs;
        epnum = musb_ep->current_epnum;
 
@@ -949,8 +949,8 @@ static int musb_gadget_disable(struct usb_ep *ep)
        int             status = 0;
 
        musb_ep = to_musb_ep(ep);
-       DBG(4, "disabling %s\n", musb_ep->name);
        musb = musb_ep->musb;
+       DBG(4, "disabling %s\n", musb_ep->name);
        epnum = musb_ep->current_epnum;
        epio = musb->endpoints[epnum].regs;
 
index 7958251..5fc4196 100644 (file)
@@ -118,7 +118,7 @@ static void musb_h_tx_flush_fifo(struct musb_hw_ep *ep)
        csr = musb_readw(epio, MUSB_TXCSR);
        while (csr & MUSB_TXCSR_FIFONOTEMPTY) {
                if (csr != lastcsr)
-                       DBG(3, "Host TX FIFONOTEMPTY csr: %02x\n", csr);
+                       DBG_nonverb(3, "Host TX FIFONOTEMPTY csr: %02x\n", csr);
                lastcsr = csr;
                csr |= MUSB_TXCSR_FLUSHFIFO;
                musb_writew(epio, MUSB_TXCSR, csr);
@@ -2036,7 +2036,7 @@ static int musb_cleanup_urb(struct urb *urb, struct musb_qh *qh, int is_in)
                dma = is_in ? ep->rx_channel : ep->tx_channel;
                if (dma) {
                        status = ep->musb->dma_controller->channel_abort(dma);
-                       DBG(status ? 1 : 3,
+                       DBG_nonverb(status ? 1 : 3,
                                "abort %cX%d DMA for urb %p --> %d\n",
                                is_in ? 'R' : 'T', ep->epnum,
                                urb, status);
index e9fbfe5..3a69283 100644 (file)
@@ -330,7 +330,7 @@ static inline u8 musb_ulpi_readb(void __iomem *addr, u8 offset)
        while (!(musb_readb(addr, ULPI_REG_CONTROL) & ULPI_REG_CMPLT)) {
                i++;
                if (i == 10000) {
-                       DBG(3, "ULPI read timed out\n");
+                       DBG_nonverb(3, "ULPI read timed out\n");
                        return 0;
                }
 
@@ -355,7 +355,7 @@ static inline void musb_ulpi_writeb(void __iomem *addr,
        while(!(musb_readb(addr, ULPI_REG_CONTROL) & ULPI_REG_CMPLT)) {
                i++;
                if (i == 10000) {
-                       DBG(3, "ULPI write timed out\n");
+                       DBG_nonverb(3, "ULPI write timed out\n");
                        return;
                }
        }
index 59c20a3..a4faaff 100644 (file)
@@ -131,7 +131,7 @@ static void configure_channel(struct dma_channel *channel,
        u8 bchannel = musb_channel->idx;
        u16 csr = 0;
 
-       DBG(4, "%p, pkt_sz %d, addr 0x%x, len %d, mode %d\n",
+       DBG_nonverb(4, "%p, pkt_sz %d, addr 0x%x, len %d, mode %d\n",
                        channel, packet_sz, dma_addr, len, mode);
 
        if (mode)
@@ -167,7 +167,7 @@ static int dma_channel_program(struct dma_channel *channel,
 {
        struct musb_dma_channel *musb_channel = channel->private_data;
 
-       DBG(2, "ep%d-%s pkt_sz %d, dma_addr 0x%x length %d, mode %d\n",
+       DBG_nonverb(2, "ep%d-%s pkt_sz %d, dma_addr 0x%x length %d, mode %d\n",
                musb_channel->epnum,
                musb_channel->transmit ? "Tx" : "Rx",
                packet_sz, dma_addr, len, mode);
index a712bc9..35aab80 100644 (file)
@@ -73,6 +73,8 @@ static void musb_do_idle(unsigned long _musb)
 
        spin_lock_irqsave(&musb->lock, flags);
 
+       DBG(3, "%s\n", otg_state_string(musb));
+
        devctl = musb_readb(musb->mregs, MUSB_DEVCTL);
 
        switch (musb->xceiv->state) {