Commit 5f81f4b0 authored by JiebingLi's avatar JiebingLi Committed by Greg Kroah-Hartman

USB: langwell: USB Client driver code cleanup

Code cleanup by using standard debugging API's and USB inline functions
Signed-off-by: default avatarJiebingLi <jiebing.li@intel.com>
Signed-off-by: default avatarAlan Cox <alan@linux.intel.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent f0ae849d
...@@ -19,7 +19,7 @@ ...@@ -19,7 +19,7 @@
/* #undef DEBUG */ /* #undef DEBUG */
/* #undef VERBOSE */ /* #undef VERBOSE_DEBUG */
#if defined(CONFIG_USB_LANGWELL_OTG) #if defined(CONFIG_USB_LANGWELL_OTG)
#define OTG_TRANSCEIVER #define OTG_TRANSCEIVER
...@@ -77,141 +77,110 @@ langwell_ep0_desc = { ...@@ -77,141 +77,110 @@ langwell_ep0_desc = {
/*-------------------------------------------------------------------------*/ /*-------------------------------------------------------------------------*/
/* debugging */ /* debugging */
#ifdef DEBUG #ifdef VERBOSE_DEBUG
#define DBG(dev, fmt, args...) \
pr_debug("%s %s: " fmt , driver_name, \
pci_name(dev->pdev), ## args)
#else
#define DBG(dev, fmt, args...) \
do { } while (0)
#endif /* DEBUG */
#ifdef VERBOSE
#define VDBG DBG
#else
#define VDBG(dev, fmt, args...) \
do { } while (0)
#endif /* VERBOSE */
#define ERROR(dev, fmt, args...) \
pr_err("%s %s: " fmt , driver_name, \
pci_name(dev->pdev), ## args)
#define WARNING(dev, fmt, args...) \
pr_warning("%s %s: " fmt , driver_name, \
pci_name(dev->pdev), ## args)
#define INFO(dev, fmt, args...) \
pr_info("%s %s: " fmt , driver_name, \
pci_name(dev->pdev), ## args)
#ifdef VERBOSE
static inline void print_all_registers(struct langwell_udc *dev) static inline void print_all_registers(struct langwell_udc *dev)
{ {
int i; int i;
/* Capability Registers */ /* Capability Registers */
printk(KERN_DEBUG "Capability Registers (offset: " dev_dbg(&dev->pdev->dev,
"0x%04x, length: 0x%08x)\n", "Capability Registers (offset: 0x%04x, length: 0x%08x)\n",
CAP_REG_OFFSET, CAP_REG_OFFSET, (u32)sizeof(struct langwell_cap_regs));
(u32)sizeof(struct langwell_cap_regs)); dev_dbg(&dev->pdev->dev, "caplength=0x%02x\n",
printk(KERN_DEBUG "caplength=0x%02x\n",
readb(&dev->cap_regs->caplength)); readb(&dev->cap_regs->caplength));
printk(KERN_DEBUG "hciversion=0x%04x\n", dev_dbg(&dev->pdev->dev, "hciversion=0x%04x\n",
readw(&dev->cap_regs->hciversion)); readw(&dev->cap_regs->hciversion));
printk(KERN_DEBUG "hcsparams=0x%08x\n", dev_dbg(&dev->pdev->dev, "hcsparams=0x%08x\n",
readl(&dev->cap_regs->hcsparams)); readl(&dev->cap_regs->hcsparams));
printk(KERN_DEBUG "hccparams=0x%08x\n", dev_dbg(&dev->pdev->dev, "hccparams=0x%08x\n",
readl(&dev->cap_regs->hccparams)); readl(&dev->cap_regs->hccparams));
printk(KERN_DEBUG "dciversion=0x%04x\n", dev_dbg(&dev->pdev->dev, "dciversion=0x%04x\n",
readw(&dev->cap_regs->dciversion)); readw(&dev->cap_regs->dciversion));
printk(KERN_DEBUG "dccparams=0x%08x\n", dev_dbg(&dev->pdev->dev, "dccparams=0x%08x\n",
readl(&dev->cap_regs->dccparams)); readl(&dev->cap_regs->dccparams));
/* Operational Registers */ /* Operational Registers */
printk(KERN_DEBUG "Operational Registers (offset: " dev_dbg(&dev->pdev->dev,
"0x%04x, length: 0x%08x)\n", "Operational Registers (offset: 0x%04x, length: 0x%08x)\n",
OP_REG_OFFSET, OP_REG_OFFSET, (u32)sizeof(struct langwell_op_regs));
(u32)sizeof(struct langwell_op_regs)); dev_dbg(&dev->pdev->dev, "extsts=0x%08x\n",
printk(KERN_DEBUG "extsts=0x%08x\n",
readl(&dev->op_regs->extsts)); readl(&dev->op_regs->extsts));
printk(KERN_DEBUG "extintr=0x%08x\n", dev_dbg(&dev->pdev->dev, "extintr=0x%08x\n",
readl(&dev->op_regs->extintr)); readl(&dev->op_regs->extintr));
printk(KERN_DEBUG "usbcmd=0x%08x\n", dev_dbg(&dev->pdev->dev, "usbcmd=0x%08x\n",
readl(&dev->op_regs->usbcmd)); readl(&dev->op_regs->usbcmd));
printk(KERN_DEBUG "usbsts=0x%08x\n", dev_dbg(&dev->pdev->dev, "usbsts=0x%08x\n",
readl(&dev->op_regs->usbsts)); readl(&dev->op_regs->usbsts));
printk(KERN_DEBUG "usbintr=0x%08x\n", dev_dbg(&dev->pdev->dev, "usbintr=0x%08x\n",
readl(&dev->op_regs->usbintr)); readl(&dev->op_regs->usbintr));
printk(KERN_DEBUG "frindex=0x%08x\n", dev_dbg(&dev->pdev->dev, "frindex=0x%08x\n",
readl(&dev->op_regs->frindex)); readl(&dev->op_regs->frindex));
printk(KERN_DEBUG "ctrldssegment=0x%08x\n", dev_dbg(&dev->pdev->dev, "ctrldssegment=0x%08x\n",
readl(&dev->op_regs->ctrldssegment)); readl(&dev->op_regs->ctrldssegment));
printk(KERN_DEBUG "deviceaddr=0x%08x\n", dev_dbg(&dev->pdev->dev, "deviceaddr=0x%08x\n",
readl(&dev->op_regs->deviceaddr)); readl(&dev->op_regs->deviceaddr));
printk(KERN_DEBUG "endpointlistaddr=0x%08x\n", dev_dbg(&dev->pdev->dev, "endpointlistaddr=0x%08x\n",
readl(&dev->op_regs->endpointlistaddr)); readl(&dev->op_regs->endpointlistaddr));
printk(KERN_DEBUG "ttctrl=0x%08x\n", dev_dbg(&dev->pdev->dev, "ttctrl=0x%08x\n",
readl(&dev->op_regs->ttctrl)); readl(&dev->op_regs->ttctrl));
printk(KERN_DEBUG "burstsize=0x%08x\n", dev_dbg(&dev->pdev->dev, "burstsize=0x%08x\n",
readl(&dev->op_regs->burstsize)); readl(&dev->op_regs->burstsize));
printk(KERN_DEBUG "txfilltuning=0x%08x\n", dev_dbg(&dev->pdev->dev, "txfilltuning=0x%08x\n",
readl(&dev->op_regs->txfilltuning)); readl(&dev->op_regs->txfilltuning));
printk(KERN_DEBUG "txttfilltuning=0x%08x\n", dev_dbg(&dev->pdev->dev, "txttfilltuning=0x%08x\n",
readl(&dev->op_regs->txttfilltuning)); readl(&dev->op_regs->txttfilltuning));
printk(KERN_DEBUG "ic_usb=0x%08x\n", dev_dbg(&dev->pdev->dev, "ic_usb=0x%08x\n",
readl(&dev->op_regs->ic_usb)); readl(&dev->op_regs->ic_usb));
printk(KERN_DEBUG "ulpi_viewport=0x%08x\n", dev_dbg(&dev->pdev->dev, "ulpi_viewport=0x%08x\n",
readl(&dev->op_regs->ulpi_viewport)); readl(&dev->op_regs->ulpi_viewport));
printk(KERN_DEBUG "configflag=0x%08x\n", dev_dbg(&dev->pdev->dev, "configflag=0x%08x\n",
readl(&dev->op_regs->configflag)); readl(&dev->op_regs->configflag));
printk(KERN_DEBUG "portsc1=0x%08x\n", dev_dbg(&dev->pdev->dev, "portsc1=0x%08x\n",
readl(&dev->op_regs->portsc1)); readl(&dev->op_regs->portsc1));
printk(KERN_DEBUG "devlc=0x%08x\n", dev_dbg(&dev->pdev->dev, "devlc=0x%08x\n",
readl(&dev->op_regs->devlc)); readl(&dev->op_regs->devlc));
printk(KERN_DEBUG "otgsc=0x%08x\n", dev_dbg(&dev->pdev->dev, "otgsc=0x%08x\n",
readl(&dev->op_regs->otgsc)); readl(&dev->op_regs->otgsc));
printk(KERN_DEBUG "usbmode=0x%08x\n", dev_dbg(&dev->pdev->dev, "usbmode=0x%08x\n",
readl(&dev->op_regs->usbmode)); readl(&dev->op_regs->usbmode));
printk(KERN_DEBUG "endptnak=0x%08x\n", dev_dbg(&dev->pdev->dev, "endptnak=0x%08x\n",
readl(&dev->op_regs->endptnak)); readl(&dev->op_regs->endptnak));
printk(KERN_DEBUG "endptnaken=0x%08x\n", dev_dbg(&dev->pdev->dev, "endptnaken=0x%08x\n",
readl(&dev->op_regs->endptnaken)); readl(&dev->op_regs->endptnaken));
printk(KERN_DEBUG "endptsetupstat=0x%08x\n", dev_dbg(&dev->pdev->dev, "endptsetupstat=0x%08x\n",
readl(&dev->op_regs->endptsetupstat)); readl(&dev->op_regs->endptsetupstat));
printk(KERN_DEBUG "endptprime=0x%08x\n", dev_dbg(&dev->pdev->dev, "endptprime=0x%08x\n",
readl(&dev->op_regs->endptprime)); readl(&dev->op_regs->endptprime));
printk(KERN_DEBUG "endptflush=0x%08x\n", dev_dbg(&dev->pdev->dev, "endptflush=0x%08x\n",
readl(&dev->op_regs->endptflush)); readl(&dev->op_regs->endptflush));
printk(KERN_DEBUG "endptstat=0x%08x\n", dev_dbg(&dev->pdev->dev, "endptstat=0x%08x\n",
readl(&dev->op_regs->endptstat)); readl(&dev->op_regs->endptstat));
printk(KERN_DEBUG "endptcomplete=0x%08x\n", dev_dbg(&dev->pdev->dev, "endptcomplete=0x%08x\n",
readl(&dev->op_regs->endptcomplete)); readl(&dev->op_regs->endptcomplete));
for (i = 0; i < dev->ep_max / 2; i++) { for (i = 0; i < dev->ep_max / 2; i++) {
printk(KERN_DEBUG "endptctrl[%d]=0x%08x\n", dev_dbg(&dev->pdev->dev, "endptctrl[%d]=0x%08x\n",
i, readl(&dev->op_regs->endptctrl[i])); i, readl(&dev->op_regs->endptctrl[i]));
} }
} }
#endif /* VERBOSE */ #else
#define print_all_registers(dev) do { } while (0)
#endif /* VERBOSE_DEBUG */
/*-------------------------------------------------------------------------*/
#define DIR_STRING(bAddress) (((bAddress) & USB_DIR_IN) ? "in" : "out") /*-------------------------------------------------------------------------*/
#define is_in(ep) (((ep)->ep_num == 0) ? ((ep)->dev->ep0_dir == \ #define is_in(ep) (((ep)->ep_num == 0) ? ((ep)->dev->ep0_dir == \
USB_DIR_IN) : ((ep)->desc->bEndpointAddress \ USB_DIR_IN) : (usb_endpoint_dir_in((ep)->desc)))
& USB_DIR_IN) == USB_DIR_IN)
#define DIR_STRING(ep) (is_in(ep) ? "in" : "out")
#ifdef DEBUG
static char *type_string(u8 bmAttributes) static char *type_string(const struct usb_endpoint_descriptor *desc)
{ {
switch ((bmAttributes) & USB_ENDPOINT_XFERTYPE_MASK) { switch (usb_endpoint_type(desc)) {
case USB_ENDPOINT_XFER_BULK: case USB_ENDPOINT_XFER_BULK:
return "bulk"; return "bulk";
case USB_ENDPOINT_XFER_ISOC: case USB_ENDPOINT_XFER_ISOC:
...@@ -222,7 +191,6 @@ static char *type_string(u8 bmAttributes) ...@@ -222,7 +191,6 @@ static char *type_string(u8 bmAttributes)
return "control"; return "control";
} }
#endif
/* configure endpoint control registers */ /* configure endpoint control registers */
...@@ -233,7 +201,7 @@ static void ep_reset(struct langwell_ep *ep, unsigned char ep_num, ...@@ -233,7 +201,7 @@ static void ep_reset(struct langwell_ep *ep, unsigned char ep_num,
u32 endptctrl; u32 endptctrl;
dev = ep->dev; dev = ep->dev;
VDBG(dev, "---> %s()\n", __func__); dev_vdbg(&dev->pdev->dev, "---> %s()\n", __func__);
endptctrl = readl(&dev->op_regs->endptctrl[ep_num]); endptctrl = readl(&dev->op_regs->endptctrl[ep_num]);
if (is_in) { /* TX */ if (is_in) { /* TX */
...@@ -250,7 +218,7 @@ static void ep_reset(struct langwell_ep *ep, unsigned char ep_num, ...@@ -250,7 +218,7 @@ static void ep_reset(struct langwell_ep *ep, unsigned char ep_num,
writel(endptctrl, &dev->op_regs->endptctrl[ep_num]); writel(endptctrl, &dev->op_regs->endptctrl[ep_num]);
VDBG(dev, "<--- %s()\n", __func__); dev_vdbg(&dev->pdev->dev, "<--- %s()\n", __func__);
} }
...@@ -260,7 +228,7 @@ static void ep0_reset(struct langwell_udc *dev) ...@@ -260,7 +228,7 @@ static void ep0_reset(struct langwell_udc *dev)
struct langwell_ep *ep; struct langwell_ep *ep;
int i; int i;
VDBG(dev, "---> %s()\n", __func__); dev_vdbg(&dev->pdev->dev, "---> %s()\n", __func__);
/* ep0 in and out */ /* ep0 in and out */
for (i = 0; i < 2; i++) { for (i = 0; i < 2; i++) {
...@@ -283,7 +251,7 @@ static void ep0_reset(struct langwell_udc *dev) ...@@ -283,7 +251,7 @@ static void ep0_reset(struct langwell_udc *dev)
ep_reset(&dev->ep[0], 0, i, USB_ENDPOINT_XFER_CONTROL); ep_reset(&dev->ep[0], 0, i, USB_ENDPOINT_XFER_CONTROL);
} }
VDBG(dev, "<--- %s()\n", __func__); dev_vdbg(&dev->pdev->dev, "<--- %s()\n", __func__);
return; return;
} }
...@@ -305,7 +273,7 @@ static int langwell_ep_enable(struct usb_ep *_ep, ...@@ -305,7 +273,7 @@ static int langwell_ep_enable(struct usb_ep *_ep,
ep = container_of(_ep, struct langwell_ep, ep); ep = container_of(_ep, struct langwell_ep, ep);
dev = ep->dev; dev = ep->dev;
VDBG(dev, "---> %s()\n", __func__); dev_vdbg(&dev->pdev->dev, "---> %s()\n", __func__);
if (!_ep || !desc || ep->desc if (!_ep || !desc || ep->desc
|| desc->bDescriptorType != USB_DT_ENDPOINT) || desc->bDescriptorType != USB_DT_ENDPOINT)
...@@ -326,7 +294,7 @@ static int langwell_ep_enable(struct usb_ep *_ep, ...@@ -326,7 +294,7 @@ static int langwell_ep_enable(struct usb_ep *_ep,
* sanity check type, direction, address, and then * sanity check type, direction, address, and then
* initialize the endpoint capabilities fields in dQH * initialize the endpoint capabilities fields in dQH
*/ */
switch (desc->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) { switch (usb_endpoint_type(desc)) {
case USB_ENDPOINT_XFER_CONTROL: case USB_ENDPOINT_XFER_CONTROL:
ios = 1; ios = 1;
break; break;
...@@ -395,24 +363,24 @@ static int langwell_ep_enable(struct usb_ep *_ep, ...@@ -395,24 +363,24 @@ static int langwell_ep_enable(struct usb_ep *_ep,
ep->ep.maxpacket = max; ep->ep.maxpacket = max;
ep->desc = desc; ep->desc = desc;
ep->stopped = 0; ep->stopped = 0;
ep->ep_num = desc->bEndpointAddress & USB_ENDPOINT_NUMBER_MASK; ep->ep_num = usb_endpoint_num(desc);
/* ep_type */ /* ep_type */
ep->ep_type = desc->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK; ep->ep_type = usb_endpoint_type(desc);
/* configure endpoint control registers */ /* configure endpoint control registers */
ep_reset(ep, ep->ep_num, is_in(ep), ep->ep_type); ep_reset(ep, ep->ep_num, is_in(ep), ep->ep_type);
DBG(dev, "enabled %s (ep%d%s-%s), max %04x\n", dev_dbg(&dev->pdev->dev, "enabled %s (ep%d%s-%s), max %04x\n",
_ep->name, _ep->name,
ep->ep_num, ep->ep_num,
DIR_STRING(desc->bEndpointAddress), DIR_STRING(ep),
type_string(desc->bmAttributes), type_string(desc),
max); max);
spin_unlock_irqrestore(&dev->lock, flags); spin_unlock_irqrestore(&dev->lock, flags);
done: done:
VDBG(dev, "<--- %s()\n", __func__); dev_vdbg(&dev->pdev->dev, "<--- %s()\n", __func__);
return retval; return retval;
} }
...@@ -428,7 +396,7 @@ static void done(struct langwell_ep *ep, struct langwell_request *req, ...@@ -428,7 +396,7 @@ static void done(struct langwell_ep *ep, struct langwell_request *req,
struct langwell_dtd *curr_dtd, *next_dtd; struct langwell_dtd *curr_dtd, *next_dtd;
int i; int i;
VDBG(dev, "---> %s()\n", __func__); dev_vdbg(&dev->pdev->dev, "---> %s()\n", __func__);
/* remove the req from ep->queue */ /* remove the req from ep->queue */
list_del_init(&req->queue); list_del_init(&req->queue);
...@@ -448,7 +416,8 @@ static void done(struct langwell_ep *ep, struct langwell_request *req, ...@@ -448,7 +416,8 @@ static void done(struct langwell_ep *ep, struct langwell_request *req,
} }
if (req->mapped) { if (req->mapped) {
dma_unmap_single(&dev->pdev->dev, req->req.dma, req->req.length, dma_unmap_single(&dev->pdev->dev,
req->req.dma, req->req.length,
is_in(ep) ? PCI_DMA_TODEVICE : PCI_DMA_FROMDEVICE); is_in(ep) ? PCI_DMA_TODEVICE : PCI_DMA_FROMDEVICE);
req->req.dma = DMA_ADDR_INVALID; req->req.dma = DMA_ADDR_INVALID;
req->mapped = 0; req->mapped = 0;
...@@ -458,7 +427,8 @@ static void done(struct langwell_ep *ep, struct langwell_request *req, ...@@ -458,7 +427,8 @@ static void done(struct langwell_ep *ep, struct langwell_request *req,
is_in(ep) ? DMA_TO_DEVICE : DMA_FROM_DEVICE); is_in(ep) ? DMA_TO_DEVICE : DMA_FROM_DEVICE);
if (status != -ESHUTDOWN) if (status != -ESHUTDOWN)
DBG(dev, "complete %s, req %p, stat %d, len %u/%u\n", dev_dbg(&dev->pdev->dev,
"complete %s, req %p, stat %d, len %u/%u\n",
ep->ep.name, &req->req, status, ep->ep.name, &req->req, status,
req->req.actual, req->req.length); req->req.actual, req->req.length);
...@@ -473,7 +443,7 @@ static void done(struct langwell_ep *ep, struct langwell_request *req, ...@@ -473,7 +443,7 @@ static void done(struct langwell_ep *ep, struct langwell_request *req,
spin_lock(&dev->lock); spin_lock(&dev->lock);
ep->stopped = stopped; ep->stopped = stopped;
VDBG(dev, "<--- %s()\n", __func__); dev_vdbg(&dev->pdev->dev, "<--- %s()\n", __func__);
} }
...@@ -511,7 +481,7 @@ static int langwell_ep_disable(struct usb_ep *_ep) ...@@ -511,7 +481,7 @@ static int langwell_ep_disable(struct usb_ep *_ep)
ep = container_of(_ep, struct langwell_ep, ep); ep = container_of(_ep, struct langwell_ep, ep);
dev = ep->dev; dev = ep->dev;
VDBG(dev, "---> %s()\n", __func__); dev_vdbg(&dev->pdev->dev, "---> %s()\n", __func__);
if (!_ep || !ep->desc) if (!_ep || !ep->desc)
return -EINVAL; return -EINVAL;
...@@ -535,8 +505,8 @@ static int langwell_ep_disable(struct usb_ep *_ep) ...@@ -535,8 +505,8 @@ static int langwell_ep_disable(struct usb_ep *_ep)
spin_unlock_irqrestore(&dev->lock, flags); spin_unlock_irqrestore(&dev->lock, flags);
DBG(dev, "disabled %s\n", _ep->name); dev_dbg(&dev->pdev->dev, "disabled %s\n", _ep->name);
VDBG(dev, "<--- %s()\n", __func__); dev_vdbg(&dev->pdev->dev, "<--- %s()\n", __func__);
return 0; return 0;
} }
...@@ -555,7 +525,7 @@ static struct usb_request *langwell_alloc_request(struct usb_ep *_ep, ...@@ -555,7 +525,7 @@ static struct usb_request *langwell_alloc_request(struct usb_ep *_ep,
ep = container_of(_ep, struct langwell_ep, ep); ep = container_of(_ep, struct langwell_ep, ep);
dev = ep->dev; dev = ep->dev;
VDBG(dev, "---> %s()\n", __func__); dev_vdbg(&dev->pdev->dev, "---> %s()\n", __func__);
req = kzalloc(sizeof(*req), gfp_flags); req = kzalloc(sizeof(*req), gfp_flags);
if (!req) if (!req)
...@@ -564,8 +534,8 @@ static struct usb_request *langwell_alloc_request(struct usb_ep *_ep, ...@@ -564,8 +534,8 @@ static struct usb_request *langwell_alloc_request(struct usb_ep *_ep,
req->req.dma = DMA_ADDR_INVALID; req->req.dma = DMA_ADDR_INVALID;
INIT_LIST_HEAD(&req->queue); INIT_LIST_HEAD(&req->queue);
VDBG(dev, "alloc request for %s\n", _ep->name); dev_vdbg(&dev->pdev->dev, "alloc request for %s\n", _ep->name);
VDBG(dev, "<--- %s()\n", __func__); dev_vdbg(&dev->pdev->dev, "<--- %s()\n", __func__);
return &req->req; return &req->req;
} }
...@@ -580,7 +550,7 @@ static void langwell_free_request(struct usb_ep *_ep, ...@@ -580,7 +550,7 @@ static void langwell_free_request(struct usb_ep *_ep,
ep = container_of(_ep, struct langwell_ep, ep); ep = container_of(_ep, struct langwell_ep, ep);
dev = ep->dev; dev = ep->dev;
VDBG(dev, "---> %s()\n", __func__); dev_vdbg(&dev->pdev->dev, "---> %s()\n", __func__);
if (!_ep || !_req) if (!_ep || !_req)
return; return;
...@@ -591,8 +561,8 @@ static void langwell_free_request(struct usb_ep *_ep, ...@@ -591,8 +561,8 @@ static void langwell_free_request(struct usb_ep *_ep,
if (_req) if (_req)
kfree(req); kfree(req);
VDBG(dev, "free request for %s\n", _ep->name); dev_vdbg(&dev->pdev->dev, "free request for %s\n", _ep->name);
VDBG(dev, "<--- %s()\n", __func__); dev_vdbg(&dev->pdev->dev, "<--- %s()\n", __func__);
} }
...@@ -608,23 +578,24 @@ static int queue_dtd(struct langwell_ep *ep, struct langwell_request *req) ...@@ -608,23 +578,24 @@ static int queue_dtd(struct langwell_ep *ep, struct langwell_request *req)
struct langwell_udc *dev; struct langwell_udc *dev;
dev = ep->dev; dev = ep->dev;
VDBG(dev, "---> %s()\n", __func__); dev_vdbg(&dev->pdev->dev, "---> %s()\n", __func__);
i = ep->ep_num * 2 + is_in(ep); i = ep->ep_num * 2 + is_in(ep);
dqh = &dev->ep_dqh[i]; dqh = &dev->ep_dqh[i];
if (ep->ep_num) if (ep->ep_num)
VDBG(dev, "%s\n", ep->name); dev_vdbg(&dev->pdev->dev, "%s\n", ep->name);
else else
/* ep0 */ /* ep0 */
VDBG(dev, "%s-%s\n", ep->name, is_in(ep) ? "in" : "out"); dev_vdbg(&dev->pdev->dev, "%s-%s\n", ep->name, DIR_STRING(ep));
VDBG(dev, "ep_dqh[%d] addr: 0x%08x\n", i, (u32)&(dev->ep_dqh[i])); dev_vdbg(&dev->pdev->dev, "ep_dqh[%d] addr: 0x%08x\n",
i, (u32)&(dev->ep_dqh[i]));
bit_mask = is_in(ep) ? bit_mask = is_in(ep) ?
(1 << (ep->ep_num + 16)) : (1 << (ep->ep_num)); (1 << (ep->ep_num + 16)) : (1 << (ep->ep_num));
VDBG(dev, "bit_mask = 0x%08x\n", bit_mask); dev_vdbg(&dev->pdev->dev, "bit_mask = 0x%08x\n", bit_mask);
/* check if the pipe is empty */ /* check if the pipe is empty */
if (!(list_empty(&ep->queue))) { if (!(list_empty(&ep->queue))) {
...@@ -665,14 +636,17 @@ static int queue_dtd(struct langwell_ep *ep, struct langwell_request *req) ...@@ -665,14 +636,17 @@ static int queue_dtd(struct langwell_ep *ep, struct langwell_request *req)
/* clear active and halt bit */ /* clear active and halt bit */
dtd_status = (u8) ~(DTD_STS_ACTIVE | DTD_STS_HALTED); dtd_status = (u8) ~(DTD_STS_ACTIVE | DTD_STS_HALTED);
dqh->dtd_status &= dtd_status; dqh->dtd_status &= dtd_status;
VDBG(dev, "dqh->dtd_status = 0x%x\n", dqh->dtd_status); dev_vdbg(&dev->pdev->dev, "dqh->dtd_status = 0x%x\n", dqh->dtd_status);
/* ensure that updates to the dQH will occure before priming */
wmb();
/* write 1 to endptprime register to PRIME endpoint */ /* write 1 to endptprime register to PRIME endpoint */
bit_mask = is_in(ep) ? (1 << (ep->ep_num + 16)) : (1 << ep->ep_num); bit_mask = is_in(ep) ? (1 << (ep->ep_num + 16)) : (1 << ep->ep_num);
VDBG(dev, "endprime bit_mask = 0x%08x\n", bit_mask); dev_vdbg(&dev->pdev->dev, "endprime bit_mask = 0x%08x\n", bit_mask);
writel(bit_mask, &dev->op_regs->endptprime); writel(bit_mask, &dev->op_regs->endptprime);
out: out:
VDBG(dev, "<--- %s()\n", __func__); dev_vdbg(&dev->pdev->dev, "<--- %s()\n", __func__);
return 0; return 0;
} }
...@@ -687,7 +661,7 @@ static struct langwell_dtd *build_dtd(struct langwell_request *req, ...@@ -687,7 +661,7 @@ static struct langwell_dtd *build_dtd(struct langwell_request *req,
int i; int i;
dev = req->ep->dev; dev = req->ep->dev;
VDBG(dev, "---> %s()\n", __func__); dev_vdbg(&dev->pdev->dev, "---> %s()\n", __func__);
/* the maximum transfer length, up to 16k bytes */ /* the maximum transfer length, up to 16k bytes */
*length = min(req->req.length - req->req.actual, *length = min(req->req.length - req->req.actual,
...@@ -708,7 +682,7 @@ static struct langwell_dtd *build_dtd(struct langwell_request *req, ...@@ -708,7 +682,7 @@ static struct langwell_dtd *build_dtd(struct langwell_request *req,
/* fill in total bytes with transfer size */ /* fill in total bytes with transfer size */
dtd->dtd_total = cpu_to_le16(*length); dtd->dtd_total = cpu_to_le16(*length);
VDBG(dev, "dtd->dtd_total = %d\n", dtd->dtd_total); dev_vdbg(&dev->pdev->dev, "dtd->dtd_total = %d\n", dtd->dtd_total);
/* set is_last flag if req->req.zero is set or not */ /* set is_last flag if req->req.zero is set or not */
if (req->req.zero) { if (req->req.zero) {
...@@ -722,7 +696,7 @@ static struct langwell_dtd *build_dtd(struct langwell_request *req, ...@@ -722,7 +696,7 @@ static struct langwell_dtd *build_dtd(struct langwell_request *req,
*is_last = 0; *is_last = 0;
if (*is_last == 0) if (*is_last == 0)
VDBG(dev, "multi-dtd request!\n"); dev_vdbg(&dev->pdev->dev, "multi-dtd request!\n");
/* set interrupt on complete bit for the last dTD */ /* set interrupt on complete bit for the last dTD */
if (*is_last && !req->req.no_interrupt) if (*is_last && !req->req.no_interrupt)
...@@ -733,10 +707,12 @@ static struct langwell_dtd *build_dtd(struct langwell_request *req, ...@@ -733,10 +707,12 @@ static struct langwell_dtd *build_dtd(struct langwell_request *req,
/* set the active bit of status field to 1 */ /* set the active bit of status field to 1 */
dtd->dtd_status = DTD_STS_ACTIVE; dtd->dtd_status = DTD_STS_ACTIVE;
VDBG(dev, "dtd->dtd_status = 0x%02x\n", dtd->dtd_status); dev_vdbg(&dev->pdev->dev, "dtd->dtd_status = 0x%02x\n",
dtd->dtd_status);
VDBG(dev, "length = %d, dma addr= 0x%08x\n", *length, (int)*dma); dev_vdbg(&dev->pdev->dev, "length = %d, dma addr= 0x%08x\n",
VDBG(dev, "<--- %s()\n", __func__); *length, (int)*dma);
dev_vdbg(&dev->pdev->dev, "<--- %s()\n", __func__);
return dtd; return dtd;
} }
...@@ -751,7 +727,7 @@ static int req_to_dtd(struct langwell_request *req) ...@@ -751,7 +727,7 @@ static int req_to_dtd(struct langwell_request *req)
dma_addr_t dma; dma_addr_t dma;
dev = req->ep->dev; dev = req->ep->dev;
VDBG(dev, "---> %s()\n", __func__); dev_vdbg(&dev->pdev->dev, "---> %s()\n", __func__);
do { do {
dtd = build_dtd(req, &count, &dma, &is_last); dtd = build_dtd(req, &count, &dma, &is_last);
if (dtd == NULL) if (dtd == NULL)
...@@ -773,7 +749,7 @@ static int req_to_dtd(struct langwell_request *req) ...@@ -773,7 +749,7 @@ static int req_to_dtd(struct langwell_request *req)
req->tail = dtd; req->tail = dtd;
VDBG(dev, "<--- %s()\n", __func__); dev_vdbg(&dev->pdev->dev, "<--- %s()\n", __func__);
return 0; return 0;
} }
...@@ -803,9 +779,9 @@ static int langwell_ep_queue(struct usb_ep *_ep, struct usb_request *_req, ...@@ -803,9 +779,9 @@ static int langwell_ep_queue(struct usb_ep *_ep, struct usb_request *_req,
dev = ep->dev; dev = ep->dev;
req->ep = ep; req->ep = ep;
VDBG(dev, "---> %s()\n", __func__); dev_vdbg(&dev->pdev->dev, "---> %s()\n", __func__);
if (ep->desc->bmAttributes == USB_ENDPOINT_XFER_ISOC) { if (usb_endpoint_xfer_isoc(ep->desc)) {
if (req->req.length > ep->ep.maxpacket) if (req->req.length > ep->ep.maxpacket)
return -EMSGSIZE; return -EMSGSIZE;
is_iso = 1; is_iso = 1;
...@@ -818,7 +794,7 @@ static int langwell_ep_queue(struct usb_ep *_ep, struct usb_request *_req, ...@@ -818,7 +794,7 @@ static int langwell_ep_queue(struct usb_ep *_ep, struct usb_request *_req,
if (_req->dma == DMA_ADDR_INVALID) { if (_req->dma == DMA_ADDR_INVALID) {
/* WORKAROUND: WARN_ON(size == 0) */ /* WORKAROUND: WARN_ON(size == 0) */
if (_req->length == 0) { if (_req->length == 0) {
VDBG(dev, "req->length: 0->1\n"); dev_vdbg(&dev->pdev->dev, "req->length: 0->1\n");
zlflag = 1; zlflag = 1;
_req->length++; _req->length++;
} }
...@@ -827,24 +803,25 @@ static int langwell_ep_queue(struct usb_ep *_ep, struct usb_request *_req, ...@@ -827,24 +803,25 @@ static int langwell_ep_queue(struct usb_ep *_ep, struct usb_request *_req,
_req->buf, _req->length, _req->buf, _req->length,
is_in(ep) ? DMA_TO_DEVICE : DMA_FROM_DEVICE); is_in(ep) ? DMA_TO_DEVICE : DMA_FROM_DEVICE);
if (zlflag && (_req->length == 1)) { if (zlflag && (_req->length == 1)) {
VDBG(dev, "req->length: 1->0\n"); dev_vdbg(&dev->pdev->dev, "req->length: 1->0\n");
zlflag = 0; zlflag = 0;
_req->length = 0; _req->length = 0;
} }
req->mapped = 1; req->mapped = 1;
VDBG(dev, "req->mapped = 1\n"); dev_vdbg(&dev->pdev->dev, "req->mapped = 1\n");
} else { } else {
dma_sync_single_for_device(&dev->pdev->dev, dma_sync_single_for_device(&dev->pdev->dev,
_req->dma, _req->length, _req->dma, _req->length,
is_in(ep) ? DMA_TO_DEVICE : DMA_FROM_DEVICE); is_in(ep) ? DMA_TO_DEVICE : DMA_FROM_DEVICE);
req->mapped = 0; req->mapped = 0;
VDBG(dev, "req->mapped = 0\n"); dev_vdbg(&dev->pdev->dev, "req->mapped = 0\n");
} }
DBG(dev, "%s queue req %p, len %u, buf %p, dma 0x%08llx\n", dev_dbg(&dev->pdev->dev,
"%s queue req %p, len %u, buf %p, dma 0x%08x\n",
_ep->name, _ep->name,
_req, _req->length, _req->buf, (unsigned long long)_req->dma); _req, _req->length, _req->buf, (int)_req->dma);
_req->status = -EINPROGRESS; _req->status = -EINPROGRESS;
_req->actual = 0; _req->actual = 0;
...@@ -866,12 +843,12 @@ static int langwell_ep_queue(struct usb_ep *_ep, struct usb_request *_req, ...@@ -866,12 +843,12 @@ static int langwell_ep_queue(struct usb_ep *_ep, struct usb_request *_req,
if (likely(req != NULL)) { if (likely(req != NULL)) {
list_add_tail(&req->queue, &ep->queue); list_add_tail(&req->queue, &ep->queue);
VDBG(dev, "list_add_tail() \n"); dev_vdbg(&dev->pdev->dev, "list_add_tail()\n");
} }
spin_unlock_irqrestore(&dev->lock, flags); spin_unlock_irqrestore(&dev->lock, flags);
VDBG(dev, "<--- %s()\n", __func__); dev_vdbg(&dev->pdev->dev, "<--- %s()\n", __func__);
return 0; return 0;
} }
...@@ -888,7 +865,7 @@ static int langwell_ep_dequeue(struct usb_ep *_ep, struct usb_request *_req) ...@@ -888,7 +865,7 @@ static int langwell_ep_dequeue(struct usb_ep *_ep, struct usb_request *_req)
ep = container_of(_ep, struct langwell_ep, ep); ep = container_of(_ep, struct langwell_ep, ep);
dev = ep->dev; dev = ep->dev;
VDBG(dev, "---> %s()\n", __func__); dev_vdbg(&dev->pdev->dev, "---> %s()\n", __func__);
if (!_ep || !ep->desc || !_req) if (!_ep || !ep->desc || !_req)
return -EINVAL; return -EINVAL;
...@@ -924,7 +901,7 @@ static int langwell_ep_dequeue(struct usb_ep *_ep, struct usb_request *_req) ...@@ -924,7 +901,7 @@ static int langwell_ep_dequeue(struct usb_ep *_ep, struct usb_request *_req)
/* queue head may be partially complete. */ /* queue head may be partially complete. */
if (ep->queue.next == &req->queue) { if (ep->queue.next == &req->queue) {
DBG(dev, "unlink (%s) dma\n", _ep->name); dev_dbg(&dev->pdev->dev, "unlink (%s) dma\n", _ep->name);
_req->status = -ECONNRESET; _req->status = -ECONNRESET;
langwell_ep_fifo_flush(&ep->ep); langwell_ep_fifo_flush(&ep->ep);
...@@ -963,7 +940,7 @@ static int langwell_ep_dequeue(struct usb_ep *_ep, struct usb_request *_req) ...@@ -963,7 +940,7 @@ static int langwell_ep_dequeue(struct usb_ep *_ep, struct usb_request *_req)
ep->stopped = stopped; ep->stopped = stopped;
spin_unlock_irqrestore(&dev->lock, flags); spin_unlock_irqrestore(&dev->lock, flags);
VDBG(dev, "<--- %s()\n", __func__); dev_vdbg(&dev->pdev->dev, "<--- %s()\n", __func__);
return retval; return retval;
} }
...@@ -976,7 +953,7 @@ static void ep_set_halt(struct langwell_ep *ep, int value) ...@@ -976,7 +953,7 @@ static void ep_set_halt(struct langwell_ep *ep, int value)
u32 endptctrl = 0; u32 endptctrl = 0;
int ep_num; int ep_num;
struct langwell_udc *dev = ep->dev; struct langwell_udc *dev = ep->dev;
VDBG(dev, "---> %s()\n", __func__); dev_vdbg(&dev->pdev->dev, "---> %s()\n", __func__);
ep_num = ep->ep_num; ep_num = ep->ep_num;
endptctrl = readl(&dev->op_regs->endptctrl[ep_num]); endptctrl = readl(&dev->op_regs->endptctrl[ep_num]);
...@@ -1001,7 +978,7 @@ static void ep_set_halt(struct langwell_ep *ep, int value) ...@@ -1001,7 +978,7 @@ static void ep_set_halt(struct langwell_ep *ep, int value)
writel(endptctrl, &dev->op_regs->endptctrl[ep_num]); writel(endptctrl, &dev->op_regs->endptctrl[ep_num]);
VDBG(dev, "<--- %s()\n", __func__); dev_vdbg(&dev->pdev->dev, "<--- %s()\n", __func__);
} }
...@@ -1016,7 +993,7 @@ static int langwell_ep_set_halt(struct usb_ep *_ep, int value) ...@@ -1016,7 +993,7 @@ static int langwell_ep_set_halt(struct usb_ep *_ep, int value)
ep = container_of(_ep, struct langwell_ep, ep); ep = container_of(_ep, struct langwell_ep, ep);
dev = ep->dev; dev = ep->dev;
VDBG(dev, "---> %s()\n", __func__); dev_vdbg(&dev->pdev->dev, "---> %s()\n", __func__);
if (!_ep || !ep->desc) if (!_ep || !ep->desc)
return -EINVAL; return -EINVAL;
...@@ -1024,8 +1001,7 @@ static int langwell_ep_set_halt(struct usb_ep *_ep, int value) ...@@ -1024,8 +1001,7 @@ static int langwell_ep_set_halt(struct usb_ep *_ep, int value)
if (!dev->driver || dev->gadget.speed == USB_SPEED_UNKNOWN) if (!dev->driver || dev->gadget.speed == USB_SPEED_UNKNOWN)
return -ESHUTDOWN; return -ESHUTDOWN;
if (ep->desc && (ep->desc->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) if (usb_endpoint_xfer_isoc(ep->desc))
== USB_ENDPOINT_XFER_ISOC)
return -EOPNOTSUPP; return -EOPNOTSUPP;
spin_lock_irqsave(&dev->lock, flags); spin_lock_irqsave(&dev->lock, flags);
...@@ -1036,7 +1012,7 @@ static int langwell_ep_set_halt(struct usb_ep *_ep, int value) ...@@ -1036,7 +1012,7 @@ static int langwell_ep_set_halt(struct usb_ep *_ep, int value)
*/ */
if (!list_empty(&ep->queue) && is_in(ep) && value) { if (!list_empty(&ep->queue) && is_in(ep) && value) {
/* IN endpoint FIFO holds bytes */ /* IN endpoint FIFO holds bytes */
DBG(dev, "%s FIFO holds bytes\n", _ep->name); dev_dbg(&dev->pdev->dev, "%s FIFO holds bytes\n", _ep->name);
retval = -EAGAIN; retval = -EAGAIN;
goto done; goto done;
} }
...@@ -1050,8 +1026,9 @@ static int langwell_ep_set_halt(struct usb_ep *_ep, int value) ...@@ -1050,8 +1026,9 @@ static int langwell_ep_set_halt(struct usb_ep *_ep, int value)
} }
done: done:
spin_unlock_irqrestore(&dev->lock, flags); spin_unlock_irqrestore(&dev->lock, flags);
DBG(dev, "%s %s halt\n", _ep->name, value ? "set" : "clear"); dev_dbg(&dev->pdev->dev, "%s %s halt\n",
VDBG(dev, "<--- %s()\n", __func__); _ep->name, value ? "set" : "clear");
dev_vdbg(&dev->pdev->dev, "<--- %s()\n", __func__);
return retval; return retval;
} }
...@@ -1065,12 +1042,12 @@ static int langwell_ep_set_wedge(struct usb_ep *_ep) ...@@ -1065,12 +1042,12 @@ static int langwell_ep_set_wedge(struct usb_ep *_ep)
ep = container_of(_ep, struct langwell_ep, ep); ep = container_of(_ep, struct langwell_ep, ep);
dev = ep->dev; dev = ep->dev;
VDBG(dev, "---> %s()\n", __func__); dev_vdbg(&dev->pdev->dev, "---> %s()\n", __func__);
if (!_ep || !ep->desc) if (!_ep || !ep->desc)
return -EINVAL; return -EINVAL;
VDBG(dev, "<--- %s()\n", __func__); dev_vdbg(&dev->pdev->dev, "<--- %s()\n", __func__);
return usb_ep_set_halt(_ep); return usb_ep_set_halt(_ep);
} }
...@@ -1086,15 +1063,16 @@ static void langwell_ep_fifo_flush(struct usb_ep *_ep) ...@@ -1086,15 +1063,16 @@ static void langwell_ep_fifo_flush(struct usb_ep *_ep)
ep = container_of(_ep, struct langwell_ep, ep); ep = container_of(_ep, struct langwell_ep, ep);
dev = ep->dev; dev = ep->dev;
VDBG(dev, "---> %s()\n", __func__); dev_vdbg(&dev->pdev->dev, "---> %s()\n", __func__);
if (!_ep || !ep->desc) { if (!_ep || !ep->desc) {
VDBG(dev, "ep or ep->desc is NULL\n"); dev_vdbg(&dev->pdev->dev, "ep or ep->desc is NULL\n");
VDBG(dev, "<--- %s()\n", __func__); dev_vdbg(&dev->pdev->dev, "<--- %s()\n", __func__);
return; return;
} }
VDBG(dev, "%s-%s fifo flush\n", _ep->name, is_in(ep) ? "in" : "out"); dev_vdbg(&dev->pdev->dev, "%s-%s fifo flush\n",
_ep->name, DIR_STRING(ep));
/* flush endpoint buffer */ /* flush endpoint buffer */
if (ep->ep_num == 0) if (ep->ep_num == 0)
...@@ -1110,14 +1088,14 @@ static void langwell_ep_fifo_flush(struct usb_ep *_ep) ...@@ -1110,14 +1088,14 @@ static void langwell_ep_fifo_flush(struct usb_ep *_ep)
writel(flush_bit, &dev->op_regs->endptflush); writel(flush_bit, &dev->op_regs->endptflush);
while (readl(&dev->op_regs->endptflush)) { while (readl(&dev->op_regs->endptflush)) {
if (time_after(jiffies, timeout)) { if (time_after(jiffies, timeout)) {
ERROR(dev, "ep flush timeout\n"); dev_err(&dev->pdev->dev, "ep flush timeout\n");
goto done; goto done;
} }
cpu_relax(); cpu_relax();
} }
} while (readl(&dev->op_regs->endptstat) & flush_bit); } while (readl(&dev->op_regs->endptstat) & flush_bit);
done: done:
VDBG(dev, "<--- %s()\n", __func__); dev_vdbg(&dev->pdev->dev, "<--- %s()\n", __func__);
} }
...@@ -1167,11 +1145,11 @@ static int langwell_get_frame(struct usb_gadget *_gadget) ...@@ -1167,11 +1145,11 @@ static int langwell_get_frame(struct usb_gadget *_gadget)
return -ENODEV; return -ENODEV;
dev = container_of(_gadget, struct langwell_udc, gadget); dev = container_of(_gadget, struct langwell_udc, gadget);
VDBG(dev, "---> %s()\n", __func__); dev_vdbg(&dev->pdev->dev, "---> %s()\n", __func__);
retval = readl(&dev->op_regs->frindex) & FRINDEX_MASK; retval = readl(&dev->op_regs->frindex) & FRINDEX_MASK;
VDBG(dev, "<--- %s()\n", __func__); dev_vdbg(&dev->pdev->dev, "<--- %s()\n", __func__);
return retval; return retval;
} }
...@@ -1187,11 +1165,13 @@ static int langwell_wakeup(struct usb_gadget *_gadget) ...@@ -1187,11 +1165,13 @@ static int langwell_wakeup(struct usb_gadget *_gadget)
return 0; return 0;
dev = container_of(_gadget, struct langwell_udc, gadget); dev = container_of(_gadget, struct langwell_udc, gadget);
VDBG(dev, "---> %s()\n", __func__); dev_vdbg(&dev->pdev->dev, "---> %s()\n", __func__);
/* Remote Wakeup feature not enabled by host */ /* remote wakeup feature not enabled by host */
if (!dev->remote_wakeup) if (!dev->remote_wakeup) {
dev_info(&dev->pdev->dev, "remote wakeup is disabled\n");
return -ENOTSUPP; return -ENOTSUPP;
}
spin_lock_irqsave(&dev->lock, flags); spin_lock_irqsave(&dev->lock, flags);
...@@ -1215,13 +1195,12 @@ static int langwell_wakeup(struct usb_gadget *_gadget) ...@@ -1215,13 +1195,12 @@ static int langwell_wakeup(struct usb_gadget *_gadget)
/* exit PHY low power suspend */ /* exit PHY low power suspend */
devlc = readl(&dev->op_regs->devlc); devlc = readl(&dev->op_regs->devlc);
VDBG(dev, "devlc = 0x%08x\n", devlc);
devlc &= ~LPM_PHCD; devlc &= ~LPM_PHCD;
writel(devlc, &dev->op_regs->devlc); writel(devlc, &dev->op_regs->devlc);
spin_unlock_irqrestore(&dev->lock, flags); spin_unlock_irqrestore(&dev->lock, flags);
VDBG(dev, "<--- %s()\n", __func__); dev_vdbg(&dev->pdev->dev, "<--- %s()\n", __func__);
return 0; return 0;
} }
...@@ -1237,10 +1216,11 @@ static int langwell_vbus_session(struct usb_gadget *_gadget, int is_active) ...@@ -1237,10 +1216,11 @@ static int langwell_vbus_session(struct usb_gadget *_gadget, int is_active)
return -ENODEV; return -ENODEV;
dev = container_of(_gadget, struct langwell_udc, gadget); dev = container_of(_gadget, struct langwell_udc, gadget);
VDBG(dev, "---> %s()\n", __func__); dev_vdbg(&dev->pdev->dev, "---> %s()\n", __func__);
spin_lock_irqsave(&dev->lock, flags); spin_lock_irqsave(&dev->lock, flags);
VDBG(dev, "VBUS status: %s\n", is_active ? "on" : "off"); dev_vdbg(&dev->pdev->dev, "VBUS status: %s\n",
is_active ? "on" : "off");
dev->vbus_active = (is_active != 0); dev->vbus_active = (is_active != 0);
if (dev->driver && dev->softconnected && dev->vbus_active) { if (dev->driver && dev->softconnected && dev->vbus_active) {
...@@ -1255,7 +1235,7 @@ static int langwell_vbus_session(struct usb_gadget *_gadget, int is_active) ...@@ -1255,7 +1235,7 @@ static int langwell_vbus_session(struct usb_gadget *_gadget, int is_active)
spin_unlock_irqrestore(&dev->lock, flags); spin_unlock_irqrestore(&dev->lock, flags);
VDBG(dev, "<--- %s()\n", __func__); dev_vdbg(&dev->pdev->dev, "<--- %s()\n", __func__);
return 0; return 0;
} }
...@@ -1269,15 +1249,15 @@ static int langwell_vbus_draw(struct usb_gadget *_gadget, unsigned mA) ...@@ -1269,15 +1249,15 @@ static int langwell_vbus_draw(struct usb_gadget *_gadget, unsigned mA)
return -ENODEV; return -ENODEV;
dev = container_of(_gadget, struct langwell_udc, gadget); dev = container_of(_gadget, struct langwell_udc, gadget);
VDBG(dev, "---> %s()\n", __func__); dev_vdbg(&dev->pdev->dev, "---> %s()\n", __func__);
if (dev->transceiver) { if (dev->transceiver) {
VDBG(dev, "otg_set_power\n"); dev_vdbg(&dev->pdev->dev, "otg_set_power\n");
VDBG(dev, "<--- %s()\n", __func__); dev_vdbg(&dev->pdev->dev, "<--- %s()\n", __func__);
return otg_set_power(dev->transceiver, mA); return otg_set_power(dev->transceiver, mA);
} }
VDBG(dev, "<--- %s()\n", __func__); dev_vdbg(&dev->pdev->dev, "<--- %s()\n", __func__);
return -ENOTSUPP; return -ENOTSUPP;
} }
...@@ -1294,7 +1274,7 @@ static int langwell_pullup(struct usb_gadget *_gadget, int is_on) ...@@ -1294,7 +1274,7 @@ static int langwell_pullup(struct usb_gadget *_gadget, int is_on)
dev = container_of(_gadget, struct langwell_udc, gadget); dev = container_of(_gadget, struct langwell_udc, gadget);
VDBG(dev, "---> %s()\n", __func__); dev_vdbg(&dev->pdev->dev, "---> %s()\n", __func__);
spin_lock_irqsave(&dev->lock, flags); spin_lock_irqsave(&dev->lock, flags);
dev->softconnected = (is_on != 0); dev->softconnected = (is_on != 0);
...@@ -1310,7 +1290,7 @@ static int langwell_pullup(struct usb_gadget *_gadget, int is_on) ...@@ -1310,7 +1290,7 @@ static int langwell_pullup(struct usb_gadget *_gadget, int is_on)
} }
spin_unlock_irqrestore(&dev->lock, flags); spin_unlock_irqrestore(&dev->lock, flags);
VDBG(dev, "<--- %s()\n", __func__); dev_vdbg(&dev->pdev->dev, "<--- %s()\n", __func__);
return 0; return 0;
} }
...@@ -1351,7 +1331,7 @@ static int langwell_udc_reset(struct langwell_udc *dev) ...@@ -1351,7 +1331,7 @@ static int langwell_udc_reset(struct langwell_udc *dev)
if (!dev) if (!dev)
return -EINVAL; return -EINVAL;
DBG(dev, "---> %s()\n", __func__); dev_dbg(&dev->pdev->dev, "---> %s()\n", __func__);
/* set controller to stop state */ /* set controller to stop state */
usbcmd = readl(&dev->op_regs->usbcmd); usbcmd = readl(&dev->op_regs->usbcmd);
...@@ -1367,7 +1347,7 @@ static int langwell_udc_reset(struct langwell_udc *dev) ...@@ -1367,7 +1347,7 @@ static int langwell_udc_reset(struct langwell_udc *dev)
timeout = jiffies + RESET_TIMEOUT; timeout = jiffies + RESET_TIMEOUT;
while (readl(&dev->op_regs->usbcmd) & CMD_RST) { while (readl(&dev->op_regs->usbcmd) & CMD_RST) {
if (time_after(jiffies, timeout)) { if (time_after(jiffies, timeout)) {
ERROR(dev, "device reset timeout\n"); dev_err(&dev->pdev->dev, "device reset timeout\n");
return -ETIMEDOUT; return -ETIMEDOUT;
} }
cpu_relax(); cpu_relax();
...@@ -1382,7 +1362,7 @@ static int langwell_udc_reset(struct langwell_udc *dev) ...@@ -1382,7 +1362,7 @@ static int langwell_udc_reset(struct langwell_udc *dev)
writel(usbmode, &dev->op_regs->usbmode); writel(usbmode, &dev->op_regs->usbmode);
usbmode = readl(&dev->op_regs->usbmode); usbmode = readl(&dev->op_regs->usbmode);
VDBG(dev, "usbmode=0x%08x\n", usbmode); dev_vdbg(&dev->pdev->dev, "usbmode=0x%08x\n", usbmode);
/* Write-Clear setup status */ /* Write-Clear setup status */
writel(0, &dev->op_regs->usbsts); writel(0, &dev->op_regs->usbsts);
...@@ -1400,10 +1380,11 @@ static int langwell_udc_reset(struct langwell_udc *dev) ...@@ -1400,10 +1380,11 @@ static int langwell_udc_reset(struct langwell_udc *dev)
endpointlistaddr &= ENDPOINTLISTADDR_MASK; endpointlistaddr &= ENDPOINTLISTADDR_MASK;
writel(endpointlistaddr, &dev->op_regs->endpointlistaddr); writel(endpointlistaddr, &dev->op_regs->endpointlistaddr);
VDBG(dev, "dQH base (vir: %p, phy: 0x%08x), endpointlistaddr=0x%08x\n", dev_vdbg(&dev->pdev->dev,
"dQH base (vir: %p, phy: 0x%08x), endpointlistaddr=0x%08x\n",
dev->ep_dqh, endpointlistaddr, dev->ep_dqh, endpointlistaddr,
readl(&dev->op_regs->endpointlistaddr)); readl(&dev->op_regs->endpointlistaddr));
DBG(dev, "<--- %s()\n", __func__); dev_dbg(&dev->pdev->dev, "<--- %s()\n", __func__);
return 0; return 0;
} }
...@@ -1415,7 +1396,7 @@ static int eps_reinit(struct langwell_udc *dev) ...@@ -1415,7 +1396,7 @@ static int eps_reinit(struct langwell_udc *dev)
char name[14]; char name[14];
int i; int i;
VDBG(dev, "---> %s()\n", __func__); dev_vdbg(&dev->pdev->dev, "---> %s()\n", __func__);
/* initialize ep0 */ /* initialize ep0 */
ep = &dev->ep[0]; ep = &dev->ep[0];
...@@ -1453,7 +1434,7 @@ static int eps_reinit(struct langwell_udc *dev) ...@@ -1453,7 +1434,7 @@ static int eps_reinit(struct langwell_udc *dev)
ep->dqh = &dev->ep_dqh[i]; ep->dqh = &dev->ep_dqh[i];
} }
VDBG(dev, "<--- %s()\n", __func__); dev_vdbg(&dev->pdev->dev, "<--- %s()\n", __func__);
return 0; return 0;
} }
...@@ -1462,7 +1443,7 @@ static int eps_reinit(struct langwell_udc *dev) ...@@ -1462,7 +1443,7 @@ static int eps_reinit(struct langwell_udc *dev)
static void langwell_udc_start(struct langwell_udc *dev) static void langwell_udc_start(struct langwell_udc *dev)
{ {
u32 usbintr, usbcmd; u32 usbintr, usbcmd;
DBG(dev, "---> %s()\n", __func__); dev_dbg(&dev->pdev->dev, "---> %s()\n", __func__);
/* enable interrupts */ /* enable interrupts */
usbintr = INTR_ULPIE /* ULPI */ usbintr = INTR_ULPIE /* ULPI */
...@@ -1485,7 +1466,7 @@ static void langwell_udc_start(struct langwell_udc *dev) ...@@ -1485,7 +1466,7 @@ static void langwell_udc_start(struct langwell_udc *dev)
usbcmd |= CMD_RUNSTOP; usbcmd |= CMD_RUNSTOP;
writel(usbcmd, &dev->op_regs->usbcmd); writel(usbcmd, &dev->op_regs->usbcmd);
DBG(dev, "<--- %s()\n", __func__); dev_dbg(&dev->pdev->dev, "<--- %s()\n", __func__);
return; return;
} }
...@@ -1495,7 +1476,7 @@ static void langwell_udc_stop(struct langwell_udc *dev) ...@@ -1495,7 +1476,7 @@ static void langwell_udc_stop(struct langwell_udc *dev)
{ {
u32 usbcmd; u32 usbcmd;
DBG(dev, "---> %s()\n", __func__); dev_dbg(&dev->pdev->dev, "---> %s()\n", __func__);
/* disable all interrupts */ /* disable all interrupts */
writel(0, &dev->op_regs->usbintr); writel(0, &dev->op_regs->usbintr);
...@@ -1508,7 +1489,7 @@ static void langwell_udc_stop(struct langwell_udc *dev) ...@@ -1508,7 +1489,7 @@ static void langwell_udc_stop(struct langwell_udc *dev)
usbcmd &= ~CMD_RUNSTOP; usbcmd &= ~CMD_RUNSTOP;
writel(usbcmd, &dev->op_regs->usbcmd); writel(usbcmd, &dev->op_regs->usbcmd);
DBG(dev, "<--- %s()\n", __func__); dev_dbg(&dev->pdev->dev, "<--- %s()\n", __func__);
return; return;
} }
...@@ -1518,7 +1499,7 @@ static void stop_activity(struct langwell_udc *dev, ...@@ -1518,7 +1499,7 @@ static void stop_activity(struct langwell_udc *dev,
struct usb_gadget_driver *driver) struct usb_gadget_driver *driver)
{ {
struct langwell_ep *ep; struct langwell_ep *ep;
DBG(dev, "---> %s()\n", __func__); dev_dbg(&dev->pdev->dev, "---> %s()\n", __func__);
nuke(&dev->ep[0], -ESHUTDOWN); nuke(&dev->ep[0], -ESHUTDOWN);
...@@ -1533,7 +1514,7 @@ static void stop_activity(struct langwell_udc *dev, ...@@ -1533,7 +1514,7 @@ static void stop_activity(struct langwell_udc *dev,
spin_lock(&dev->lock); spin_lock(&dev->lock);
} }
DBG(dev, "<--- %s()\n", __func__); dev_dbg(&dev->pdev->dev, "<--- %s()\n", __func__);
} }
...@@ -1659,13 +1640,15 @@ static ssize_t show_langwell_udc(struct device *_dev, ...@@ -1659,13 +1640,15 @@ static ssize_t show_langwell_udc(struct device *_dev,
"Over-current Change: %s\n" "Over-current Change: %s\n"
"Port Enable/Disable Change: %s\n" "Port Enable/Disable Change: %s\n"
"Port Enabled/Disabled: %s\n" "Port Enabled/Disabled: %s\n"
"Current Connect Status: %s\n\n", "Current Connect Status: %s\n"
"LPM Suspend Status: %s\n\n",
(tmp_reg & PORTS_PR) ? "Reset" : "Not Reset", (tmp_reg & PORTS_PR) ? "Reset" : "Not Reset",
(tmp_reg & PORTS_SUSP) ? "Suspend " : "Not Suspend", (tmp_reg & PORTS_SUSP) ? "Suspend " : "Not Suspend",
(tmp_reg & PORTS_OCC) ? "Detected" : "No", (tmp_reg & PORTS_OCC) ? "Detected" : "No",
(tmp_reg & PORTS_PEC) ? "Changed" : "Not Changed", (tmp_reg & PORTS_PEC) ? "Changed" : "Not Changed",
(tmp_reg & PORTS_PE) ? "Enable" : "Not Correct", (tmp_reg & PORTS_PE) ? "Enable" : "Not Correct",
(tmp_reg & PORTS_CCS) ? "Attached" : "Not Attached"); (tmp_reg & PORTS_CCS) ? "Attached" : "Not Attached",
(tmp_reg & PORTS_SLP) ? "LPM L1" : "LPM L0");
size -= t; size -= t;
next += t; next += t;
...@@ -1676,7 +1659,7 @@ static ssize_t show_langwell_udc(struct device *_dev, ...@@ -1676,7 +1659,7 @@ static ssize_t show_langwell_udc(struct device *_dev,
"Serial Transceiver : %d\n" "Serial Transceiver : %d\n"
"Port Speed: %s\n" "Port Speed: %s\n"
"Port Force Full Speed Connenct: %s\n" "Port Force Full Speed Connenct: %s\n"
"PHY Low Power Suspend Clock Disable: %s\n" "PHY Low Power Suspend Clock: %s\n"
"BmAttributes: %d\n\n", "BmAttributes: %d\n\n",
LPM_PTS(tmp_reg), LPM_PTS(tmp_reg),
(tmp_reg & LPM_STS) ? 1 : 0, (tmp_reg & LPM_STS) ? 1 : 0,
...@@ -1816,7 +1799,7 @@ int usb_gadget_register_driver(struct usb_gadget_driver *driver) ...@@ -1816,7 +1799,7 @@ int usb_gadget_register_driver(struct usb_gadget_driver *driver)
if (!dev) if (!dev)
return -ENODEV; return -ENODEV;
DBG(dev, "---> %s()\n", __func__); dev_dbg(&dev->pdev->dev, "---> %s()\n", __func__);
if (dev->driver) if (dev->driver)
return -EBUSY; return -EBUSY;
...@@ -1832,7 +1815,7 @@ int usb_gadget_register_driver(struct usb_gadget_driver *driver) ...@@ -1832,7 +1815,7 @@ int usb_gadget_register_driver(struct usb_gadget_driver *driver)
retval = driver->bind(&dev->gadget); retval = driver->bind(&dev->gadget);
if (retval) { if (retval) {
DBG(dev, "bind to driver %s --> %d\n", dev_dbg(&dev->pdev->dev, "bind to driver %s --> %d\n",
driver->driver.name, retval); driver->driver.name, retval);
dev->driver = NULL; dev->driver = NULL;
dev->gadget.dev.driver = NULL; dev->gadget.dev.driver = NULL;
...@@ -1851,13 +1834,13 @@ int usb_gadget_register_driver(struct usb_gadget_driver *driver) ...@@ -1851,13 +1834,13 @@ int usb_gadget_register_driver(struct usb_gadget_driver *driver)
if (dev->got_irq) if (dev->got_irq)
langwell_udc_start(dev); langwell_udc_start(dev);
VDBG(dev, "After langwell_udc_start(), print all registers:\n"); dev_vdbg(&dev->pdev->dev,
#ifdef VERBOSE "After langwell_udc_start(), print all registers:\n");
print_all_registers(dev); print_all_registers(dev);
#endif
INFO(dev, "register driver: %s\n", driver->driver.name); dev_info(&dev->pdev->dev, "register driver: %s\n",
VDBG(dev, "<--- %s()\n", __func__); driver->driver.name);
dev_dbg(&dev->pdev->dev, "<--- %s()\n", __func__);
return 0; return 0;
err_unbind: err_unbind:
...@@ -1865,7 +1848,7 @@ int usb_gadget_register_driver(struct usb_gadget_driver *driver) ...@@ -1865,7 +1848,7 @@ int usb_gadget_register_driver(struct usb_gadget_driver *driver)
dev->gadget.dev.driver = NULL; dev->gadget.dev.driver = NULL;
dev->driver = NULL; dev->driver = NULL;
DBG(dev, "<--- %s()\n", __func__); dev_dbg(&dev->pdev->dev, "<--- %s()\n", __func__);
return retval; return retval;
} }
EXPORT_SYMBOL(usb_gadget_register_driver); EXPORT_SYMBOL(usb_gadget_register_driver);
...@@ -1880,7 +1863,7 @@ int usb_gadget_unregister_driver(struct usb_gadget_driver *driver) ...@@ -1880,7 +1863,7 @@ int usb_gadget_unregister_driver(struct usb_gadget_driver *driver)
if (!dev) if (!dev)
return -ENODEV; return -ENODEV;
DBG(dev, "---> %s()\n", __func__); dev_dbg(&dev->pdev->dev, "---> %s()\n", __func__);
if (unlikely(!driver || !driver->bind || !driver->unbind)) if (unlikely(!driver || !driver->bind || !driver->unbind))
return -EINVAL; return -EINVAL;
...@@ -1910,8 +1893,9 @@ int usb_gadget_unregister_driver(struct usb_gadget_driver *driver) ...@@ -1910,8 +1893,9 @@ int usb_gadget_unregister_driver(struct usb_gadget_driver *driver)
device_remove_file(&dev->pdev->dev, &dev_attr_function); device_remove_file(&dev->pdev->dev, &dev_attr_function);
INFO(dev, "unregistered driver '%s'\n", driver->driver.name); dev_info(&dev->pdev->dev, "unregistered driver '%s'\n",
DBG(dev, "<--- %s()\n", __func__); driver->driver.name);
dev_dbg(&dev->pdev->dev, "<--- %s()\n", __func__);
return 0; return 0;
} }
EXPORT_SYMBOL(usb_gadget_unregister_driver); EXPORT_SYMBOL(usb_gadget_unregister_driver);
...@@ -1930,7 +1914,7 @@ static void setup_tripwire(struct langwell_udc *dev) ...@@ -1930,7 +1914,7 @@ static void setup_tripwire(struct langwell_udc *dev)
unsigned long timeout; unsigned long timeout;
struct langwell_dqh *dqh; struct langwell_dqh *dqh;
VDBG(dev, "---> %s()\n", __func__); dev_vdbg(&dev->pdev->dev, "---> %s()\n", __func__);
/* ep0 OUT dQH */ /* ep0 OUT dQH */
dqh = &dev->ep_dqh[EP_DIR_OUT]; dqh = &dev->ep_dqh[EP_DIR_OUT];
...@@ -1943,7 +1927,7 @@ static void setup_tripwire(struct langwell_udc *dev) ...@@ -1943,7 +1927,7 @@ static void setup_tripwire(struct langwell_udc *dev)
timeout = jiffies + SETUPSTAT_TIMEOUT; timeout = jiffies + SETUPSTAT_TIMEOUT;
while (readl(&dev->op_regs->endptsetupstat)) { while (readl(&dev->op_regs->endptsetupstat)) {
if (time_after(jiffies, timeout)) { if (time_after(jiffies, timeout)) {
ERROR(dev, "setup_tripwire timeout\n"); dev_err(&dev->pdev->dev, "setup_tripwire timeout\n");
break; break;
} }
cpu_relax(); cpu_relax();
...@@ -1963,7 +1947,7 @@ static void setup_tripwire(struct langwell_udc *dev) ...@@ -1963,7 +1947,7 @@ static void setup_tripwire(struct langwell_udc *dev)
usbcmd = readl(&dev->op_regs->usbcmd); usbcmd = readl(&dev->op_regs->usbcmd);
writel(usbcmd & ~CMD_SUTW, &dev->op_regs->usbcmd); writel(usbcmd & ~CMD_SUTW, &dev->op_regs->usbcmd);
VDBG(dev, "<--- %s()\n", __func__); dev_vdbg(&dev->pdev->dev, "<--- %s()\n", __func__);
} }
...@@ -1972,7 +1956,7 @@ static void ep0_stall(struct langwell_udc *dev) ...@@ -1972,7 +1956,7 @@ static void ep0_stall(struct langwell_udc *dev)
{ {
u32 endptctrl; u32 endptctrl;
VDBG(dev, "---> %s()\n", __func__); dev_vdbg(&dev->pdev->dev, "---> %s()\n", __func__);
/* set TX and RX to stall */ /* set TX and RX to stall */
endptctrl = readl(&dev->op_regs->endptctrl[0]); endptctrl = readl(&dev->op_regs->endptctrl[0]);
...@@ -1983,7 +1967,7 @@ static void ep0_stall(struct langwell_udc *dev) ...@@ -1983,7 +1967,7 @@ static void ep0_stall(struct langwell_udc *dev)
dev->ep0_state = WAIT_FOR_SETUP; dev->ep0_state = WAIT_FOR_SETUP;
dev->ep0_dir = USB_DIR_OUT; dev->ep0_dir = USB_DIR_OUT;
VDBG(dev, "<--- %s()\n", __func__); dev_vdbg(&dev->pdev->dev, "<--- %s()\n", __func__);
} }
...@@ -1994,7 +1978,7 @@ static int prime_status_phase(struct langwell_udc *dev, int dir) ...@@ -1994,7 +1978,7 @@ static int prime_status_phase(struct langwell_udc *dev, int dir)
struct langwell_ep *ep; struct langwell_ep *ep;
int status = 0; int status = 0;
VDBG(dev, "---> %s()\n", __func__); dev_vdbg(&dev->pdev->dev, "---> %s()\n", __func__);
if (dir == EP_DIR_IN) if (dir == EP_DIR_IN)
dev->ep0_dir = USB_DIR_IN; dev->ep0_dir = USB_DIR_IN;
...@@ -2019,11 +2003,11 @@ static int prime_status_phase(struct langwell_udc *dev, int dir) ...@@ -2019,11 +2003,11 @@ static int prime_status_phase(struct langwell_udc *dev, int dir)
return -ENOMEM; return -ENOMEM;
if (status) if (status)
ERROR(dev, "can't queue ep0 status request\n"); dev_err(&dev->pdev->dev, "can't queue ep0 status request\n");
list_add_tail(&req->queue, &ep->queue); list_add_tail(&req->queue, &ep->queue);
VDBG(dev, "<--- %s()\n", __func__); dev_vdbg(&dev->pdev->dev, "<--- %s()\n", __func__);
return status; return status;
} }
...@@ -2032,11 +2016,11 @@ static int prime_status_phase(struct langwell_udc *dev, int dir) ...@@ -2032,11 +2016,11 @@ static int prime_status_phase(struct langwell_udc *dev, int dir)
static void set_address(struct langwell_udc *dev, u16 value, static void set_address(struct langwell_udc *dev, u16 value,
u16 index, u16 length) u16 index, u16 length)
{ {
VDBG(dev, "---> %s()\n", __func__); dev_vdbg(&dev->pdev->dev, "---> %s()\n", __func__);
/* save the new address to device struct */ /* save the new address to device struct */
dev->dev_addr = (u8) value; dev->dev_addr = (u8) value;
VDBG(dev, "dev->dev_addr = %d\n", dev->dev_addr); dev_vdbg(&dev->pdev->dev, "dev->dev_addr = %d\n", dev->dev_addr);
/* update usb state */ /* update usb state */
dev->usb_state = USB_STATE_ADDRESS; dev->usb_state = USB_STATE_ADDRESS;
...@@ -2045,7 +2029,7 @@ static void set_address(struct langwell_udc *dev, u16 value, ...@@ -2045,7 +2029,7 @@ static void set_address(struct langwell_udc *dev, u16 value,
if (prime_status_phase(dev, EP_DIR_IN)) if (prime_status_phase(dev, EP_DIR_IN))
ep0_stall(dev); ep0_stall(dev);
VDBG(dev, "<--- %s()\n", __func__); dev_vdbg(&dev->pdev->dev, "<--- %s()\n", __func__);
} }
...@@ -2054,7 +2038,7 @@ static struct langwell_ep *get_ep_by_windex(struct langwell_udc *dev, ...@@ -2054,7 +2038,7 @@ static struct langwell_ep *get_ep_by_windex(struct langwell_udc *dev,
u16 wIndex) u16 wIndex)
{ {
struct langwell_ep *ep; struct langwell_ep *ep;
VDBG(dev, "---> %s()\n", __func__); dev_vdbg(&dev->pdev->dev, "---> %s()\n", __func__);
if ((wIndex & USB_ENDPOINT_NUMBER_MASK) == 0) if ((wIndex & USB_ENDPOINT_NUMBER_MASK) == 0)
return &dev->ep[0]; return &dev->ep[0];
...@@ -2073,7 +2057,7 @@ static struct langwell_ep *get_ep_by_windex(struct langwell_udc *dev, ...@@ -2073,7 +2057,7 @@ static struct langwell_ep *get_ep_by_windex(struct langwell_udc *dev,
return ep; return ep;
} }
VDBG(dev, "<--- %s()\n", __func__); dev_vdbg(&dev->pdev->dev, "<--- %s()\n", __func__);
return NULL; return NULL;
} }
...@@ -2085,7 +2069,7 @@ static int ep_is_stall(struct langwell_ep *ep) ...@@ -2085,7 +2069,7 @@ static int ep_is_stall(struct langwell_ep *ep)
u32 endptctrl; u32 endptctrl;
int retval; int retval;
VDBG(dev, "---> %s()\n", __func__); dev_vdbg(&dev->pdev->dev, "---> %s()\n", __func__);
endptctrl = readl(&dev->op_regs->endptctrl[ep->ep_num]); endptctrl = readl(&dev->op_regs->endptctrl[ep->ep_num]);
if (is_in(ep)) if (is_in(ep))
...@@ -2093,7 +2077,7 @@ static int ep_is_stall(struct langwell_ep *ep) ...@@ -2093,7 +2077,7 @@ static int ep_is_stall(struct langwell_ep *ep)
else else
retval = endptctrl & EPCTRL_RXS ? 1 : 0; retval = endptctrl & EPCTRL_RXS ? 1 : 0;
VDBG(dev, "<--- %s()\n", __func__); dev_vdbg(&dev->pdev->dev, "<--- %s()\n", __func__);
return retval; return retval;
} }
...@@ -2107,7 +2091,7 @@ static void get_status(struct langwell_udc *dev, u8 request_type, u16 value, ...@@ -2107,7 +2091,7 @@ static void get_status(struct langwell_udc *dev, u8 request_type, u16 value,
u16 status_data = 0; /* 16 bits cpu view status data */ u16 status_data = 0; /* 16 bits cpu view status data */
int status = 0; int status = 0;
VDBG(dev, "---> %s()\n", __func__); dev_vdbg(&dev->pdev->dev, "---> %s()\n", __func__);
ep = &dev->ep[0]; ep = &dev->ep[0];
...@@ -2129,6 +2113,8 @@ static void get_status(struct langwell_udc *dev, u8 request_type, u16 value, ...@@ -2129,6 +2113,8 @@ static void get_status(struct langwell_udc *dev, u8 request_type, u16 value,
status_data = ep_is_stall(epn) << USB_ENDPOINT_HALT; status_data = ep_is_stall(epn) << USB_ENDPOINT_HALT;
} }
dev_dbg(&dev->pdev->dev, "get status data: 0x%04x\n", status_data);
dev->ep0_dir = USB_DIR_IN; dev->ep0_dir = USB_DIR_IN;
/* borrow the per device status_req */ /* borrow the per device status_req */
...@@ -2150,18 +2136,19 @@ static void get_status(struct langwell_udc *dev, u8 request_type, u16 value, ...@@ -2150,18 +2136,19 @@ static void get_status(struct langwell_udc *dev, u8 request_type, u16 value,
goto stall; goto stall;
if (status) { if (status) {
ERROR(dev, "response error on GET_STATUS request\n"); dev_err(&dev->pdev->dev,
"response error on GET_STATUS request\n");
goto stall; goto stall;
} }
list_add_tail(&req->queue, &ep->queue); list_add_tail(&req->queue, &ep->queue);
dev->ep0_state = DATA_STATE_XMIT; dev->ep0_state = DATA_STATE_XMIT;
VDBG(dev, "<--- %s()\n", __func__); dev_vdbg(&dev->pdev->dev, "<--- %s()\n", __func__);
return; return;
stall: stall:
ep0_stall(dev); ep0_stall(dev);
VDBG(dev, "<--- %s()\n", __func__); dev_vdbg(&dev->pdev->dev, "<--- %s()\n", __func__);
} }
...@@ -2173,12 +2160,12 @@ static void handle_setup_packet(struct langwell_udc *dev, ...@@ -2173,12 +2160,12 @@ static void handle_setup_packet(struct langwell_udc *dev,
u16 wIndex = le16_to_cpu(setup->wIndex); u16 wIndex = le16_to_cpu(setup->wIndex);
u16 wLength = le16_to_cpu(setup->wLength); u16 wLength = le16_to_cpu(setup->wLength);
VDBG(dev, "---> %s()\n", __func__); dev_vdbg(&dev->pdev->dev, "---> %s()\n", __func__);
/* ep0 fifo flush */ /* ep0 fifo flush */
nuke(&dev->ep[0], -ESHUTDOWN); nuke(&dev->ep[0], -ESHUTDOWN);
DBG(dev, "SETUP %02x.%02x v%04x i%04x l%04x\n", dev_dbg(&dev->pdev->dev, "SETUP %02x.%02x v%04x i%04x l%04x\n",
setup->bRequestType, setup->bRequest, setup->bRequestType, setup->bRequest,
wValue, wIndex, wLength); wValue, wIndex, wLength);
...@@ -2197,7 +2184,7 @@ static void handle_setup_packet(struct langwell_udc *dev, ...@@ -2197,7 +2184,7 @@ static void handle_setup_packet(struct langwell_udc *dev,
/* We process some stardard setup requests here */ /* We process some stardard setup requests here */
switch (setup->bRequest) { switch (setup->bRequest) {
case USB_REQ_GET_STATUS: case USB_REQ_GET_STATUS:
DBG(dev, "SETUP: USB_REQ_GET_STATUS\n"); dev_dbg(&dev->pdev->dev, "SETUP: USB_REQ_GET_STATUS\n");
/* get status, DATA and STATUS phase */ /* get status, DATA and STATUS phase */
if ((setup->bRequestType & (USB_DIR_IN | USB_TYPE_MASK)) if ((setup->bRequestType & (USB_DIR_IN | USB_TYPE_MASK))
!= (USB_DIR_IN | USB_TYPE_STANDARD)) != (USB_DIR_IN | USB_TYPE_STANDARD))
...@@ -2206,7 +2193,7 @@ static void handle_setup_packet(struct langwell_udc *dev, ...@@ -2206,7 +2193,7 @@ static void handle_setup_packet(struct langwell_udc *dev,
goto end; goto end;
case USB_REQ_SET_ADDRESS: case USB_REQ_SET_ADDRESS:
DBG(dev, "SETUP: USB_REQ_SET_ADDRESS\n"); dev_dbg(&dev->pdev->dev, "SETUP: USB_REQ_SET_ADDRESS\n");
/* STATUS phase */ /* STATUS phase */
if (setup->bRequestType != (USB_DIR_OUT | USB_TYPE_STANDARD if (setup->bRequestType != (USB_DIR_OUT | USB_TYPE_STANDARD
| USB_RECIP_DEVICE)) | USB_RECIP_DEVICE))
...@@ -2220,9 +2207,11 @@ static void handle_setup_packet(struct langwell_udc *dev, ...@@ -2220,9 +2207,11 @@ static void handle_setup_packet(struct langwell_udc *dev,
{ {
int rc = -EOPNOTSUPP; int rc = -EOPNOTSUPP;
if (setup->bRequest == USB_REQ_SET_FEATURE) if (setup->bRequest == USB_REQ_SET_FEATURE)
DBG(dev, "SETUP: USB_REQ_SET_FEATURE\n"); dev_dbg(&dev->pdev->dev,
"SETUP: USB_REQ_SET_FEATURE\n");
else if (setup->bRequest == USB_REQ_CLEAR_FEATURE) else if (setup->bRequest == USB_REQ_CLEAR_FEATURE)
DBG(dev, "SETUP: USB_REQ_CLEAR_FEATURE\n"); dev_dbg(&dev->pdev->dev,
"SETUP: USB_REQ_CLEAR_FEATURE\n");
if ((setup->bRequestType & (USB_RECIP_MASK | USB_TYPE_MASK)) if ((setup->bRequestType & (USB_RECIP_MASK | USB_TYPE_MASK))
== (USB_RECIP_ENDPOINT | USB_TYPE_STANDARD)) { == (USB_RECIP_ENDPOINT | USB_TYPE_STANDARD)) {
...@@ -2274,31 +2263,38 @@ static void handle_setup_packet(struct langwell_udc *dev, ...@@ -2274,31 +2263,38 @@ static void handle_setup_packet(struct langwell_udc *dev,
} }
case USB_REQ_GET_DESCRIPTOR: case USB_REQ_GET_DESCRIPTOR:
DBG(dev, "SETUP: USB_REQ_GET_DESCRIPTOR\n"); dev_dbg(&dev->pdev->dev,
"SETUP: USB_REQ_GET_DESCRIPTOR\n");
goto delegate; goto delegate;
case USB_REQ_SET_DESCRIPTOR: case USB_REQ_SET_DESCRIPTOR:
DBG(dev, "SETUP: USB_REQ_SET_DESCRIPTOR unsupported\n"); dev_dbg(&dev->pdev->dev,
"SETUP: USB_REQ_SET_DESCRIPTOR unsupported\n");
goto delegate; goto delegate;
case USB_REQ_GET_CONFIGURATION: case USB_REQ_GET_CONFIGURATION:
DBG(dev, "SETUP: USB_REQ_GET_CONFIGURATION\n"); dev_dbg(&dev->pdev->dev,
"SETUP: USB_REQ_GET_CONFIGURATION\n");
goto delegate; goto delegate;
case USB_REQ_SET_CONFIGURATION: case USB_REQ_SET_CONFIGURATION:
DBG(dev, "SETUP: USB_REQ_SET_CONFIGURATION\n"); dev_dbg(&dev->pdev->dev,
"SETUP: USB_REQ_SET_CONFIGURATION\n");
goto delegate; goto delegate;
case USB_REQ_GET_INTERFACE: case USB_REQ_GET_INTERFACE:
DBG(dev, "SETUP: USB_REQ_GET_INTERFACE\n"); dev_dbg(&dev->pdev->dev,
"SETUP: USB_REQ_GET_INTERFACE\n");
goto delegate; goto delegate;
case USB_REQ_SET_INTERFACE: case USB_REQ_SET_INTERFACE:
DBG(dev, "SETUP: USB_REQ_SET_INTERFACE\n"); dev_dbg(&dev->pdev->dev,
"SETUP: USB_REQ_SET_INTERFACE\n");
goto delegate; goto delegate;
case USB_REQ_SYNCH_FRAME: case USB_REQ_SYNCH_FRAME:
DBG(dev, "SETUP: USB_REQ_SYNCH_FRAME unsupported\n"); dev_dbg(&dev->pdev->dev,
"SETUP: USB_REQ_SYNCH_FRAME unsupported\n");
goto delegate; goto delegate;
default: default:
...@@ -2310,7 +2306,8 @@ static void handle_setup_packet(struct langwell_udc *dev, ...@@ -2310,7 +2306,8 @@ static void handle_setup_packet(struct langwell_udc *dev,
/* DATA phase from gadget, STATUS phase from udc */ /* DATA phase from gadget, STATUS phase from udc */
dev->ep0_dir = (setup->bRequestType & USB_DIR_IN) dev->ep0_dir = (setup->bRequestType & USB_DIR_IN)
? USB_DIR_IN : USB_DIR_OUT; ? USB_DIR_IN : USB_DIR_OUT;
VDBG(dev, "dev->ep0_dir = 0x%x, wLength = %d\n", dev_vdbg(&dev->pdev->dev,
"dev->ep0_dir = 0x%x, wLength = %d\n",
dev->ep0_dir, wLength); dev->ep0_dir, wLength);
spin_unlock(&dev->lock); spin_unlock(&dev->lock);
if (dev->driver->setup(&dev->gadget, if (dev->driver->setup(&dev->gadget,
...@@ -2322,7 +2319,8 @@ static void handle_setup_packet(struct langwell_udc *dev, ...@@ -2322,7 +2319,8 @@ static void handle_setup_packet(struct langwell_udc *dev,
} else { } else {
/* no DATA phase, IN STATUS phase from gadget */ /* no DATA phase, IN STATUS phase from gadget */
dev->ep0_dir = USB_DIR_IN; dev->ep0_dir = USB_DIR_IN;
VDBG(dev, "dev->ep0_dir = 0x%x, wLength = %d\n", dev_vdbg(&dev->pdev->dev,
"dev->ep0_dir = 0x%x, wLength = %d\n",
dev->ep0_dir, wLength); dev->ep0_dir, wLength);
spin_unlock(&dev->lock); spin_unlock(&dev->lock);
if (dev->driver->setup(&dev->gadget, if (dev->driver->setup(&dev->gadget,
...@@ -2334,7 +2332,7 @@ static void handle_setup_packet(struct langwell_udc *dev, ...@@ -2334,7 +2332,7 @@ static void handle_setup_packet(struct langwell_udc *dev,
break; break;
} }
end: end:
VDBG(dev, "<--- %s()\n", __func__); dev_vdbg(&dev->pdev->dev, "<--- %s()\n", __func__);
return; return;
} }
...@@ -2359,7 +2357,7 @@ static int process_ep_req(struct langwell_udc *dev, int index, ...@@ -2359,7 +2357,7 @@ static int process_ep_req(struct langwell_udc *dev, int index,
td_complete = 0; td_complete = 0;
actual = curr_req->req.length; actual = curr_req->req.length;
VDBG(dev, "---> %s()\n", __func__); dev_vdbg(&dev->pdev->dev, "---> %s()\n", __func__);
for (i = 0; i < curr_req->dtd_count; i++) { for (i = 0; i < curr_req->dtd_count; i++) {
remaining_length = le16_to_cpu(curr_dtd->dtd_total); remaining_length = le16_to_cpu(curr_dtd->dtd_total);
...@@ -2372,10 +2370,12 @@ static int process_ep_req(struct langwell_udc *dev, int index, ...@@ -2372,10 +2370,12 @@ static int process_ep_req(struct langwell_udc *dev, int index,
/* transfers completed successfully */ /* transfers completed successfully */
if (!remaining_length) { if (!remaining_length) {
td_complete++; td_complete++;
VDBG(dev, "dTD transmitted successfully\n"); dev_vdbg(&dev->pdev->dev,
"dTD transmitted successfully\n");
} else { } else {
if (dir) { if (dir) {
VDBG(dev, "TX dTD remains data\n"); dev_vdbg(&dev->pdev->dev,
"TX dTD remains data\n");
retval = -EPROTO; retval = -EPROTO;
break; break;
...@@ -2387,26 +2387,31 @@ static int process_ep_req(struct langwell_udc *dev, int index, ...@@ -2387,26 +2387,31 @@ static int process_ep_req(struct langwell_udc *dev, int index,
} else { } else {
/* transfers completed with errors */ /* transfers completed with errors */
if (dtd_status & DTD_STS_ACTIVE) { if (dtd_status & DTD_STS_ACTIVE) {
DBG(dev, "request not completed\n"); dev_dbg(&dev->pdev->dev,
"dTD status ACTIVE dQH[%d]\n", index);
retval = 1; retval = 1;
return retval; return retval;
} else if (dtd_status & DTD_STS_HALTED) { } else if (dtd_status & DTD_STS_HALTED) {
ERROR(dev, "dTD error %08x dQH[%d]\n", dev_err(&dev->pdev->dev,
"dTD error %08x dQH[%d]\n",
dtd_status, index); dtd_status, index);
/* clear the errors and halt condition */ /* clear the errors and halt condition */
curr_dqh->dtd_status = 0; curr_dqh->dtd_status = 0;
retval = -EPIPE; retval = -EPIPE;
break; break;
} else if (dtd_status & DTD_STS_DBE) { } else if (dtd_status & DTD_STS_DBE) {
DBG(dev, "data buffer (overflow) error\n"); dev_dbg(&dev->pdev->dev,
"data buffer (overflow) error\n");
retval = -EPROTO; retval = -EPROTO;
break; break;
} else if (dtd_status & DTD_STS_TRE) { } else if (dtd_status & DTD_STS_TRE) {
DBG(dev, "transaction(ISO) error\n"); dev_dbg(&dev->pdev->dev,
"transaction(ISO) error\n");
retval = -EILSEQ; retval = -EILSEQ;
break; break;
} else } else
ERROR(dev, "unknown error (0x%x)!\n", dev_err(&dev->pdev->dev,
"unknown error (0x%x)!\n",
dtd_status); dtd_status);
} }
...@@ -2420,7 +2425,7 @@ static int process_ep_req(struct langwell_udc *dev, int index, ...@@ -2420,7 +2425,7 @@ static int process_ep_req(struct langwell_udc *dev, int index,
curr_req->req.actual = actual; curr_req->req.actual = actual;
VDBG(dev, "<--- %s()\n", __func__); dev_vdbg(&dev->pdev->dev, "<--- %s()\n", __func__);
return 0; return 0;
} }
...@@ -2430,7 +2435,7 @@ static void ep0_req_complete(struct langwell_udc *dev, ...@@ -2430,7 +2435,7 @@ static void ep0_req_complete(struct langwell_udc *dev,
struct langwell_ep *ep0, struct langwell_request *req) struct langwell_ep *ep0, struct langwell_request *req)
{ {
u32 new_addr; u32 new_addr;
VDBG(dev, "---> %s()\n", __func__); dev_vdbg(&dev->pdev->dev, "---> %s()\n", __func__);
if (dev->usb_state == USB_STATE_ADDRESS) { if (dev->usb_state == USB_STATE_ADDRESS) {
/* set the new address */ /* set the new address */
...@@ -2438,7 +2443,7 @@ static void ep0_req_complete(struct langwell_udc *dev, ...@@ -2438,7 +2443,7 @@ static void ep0_req_complete(struct langwell_udc *dev,
writel(new_addr << USBADR_SHIFT, &dev->op_regs->deviceaddr); writel(new_addr << USBADR_SHIFT, &dev->op_regs->deviceaddr);
new_addr = USBADR(readl(&dev->op_regs->deviceaddr)); new_addr = USBADR(readl(&dev->op_regs->deviceaddr));
VDBG(dev, "new_addr = %d\n", new_addr); dev_vdbg(&dev->pdev->dev, "new_addr = %d\n", new_addr);
} }
done(ep0, req, 0); done(ep0, req, 0);
...@@ -2458,14 +2463,14 @@ static void ep0_req_complete(struct langwell_udc *dev, ...@@ -2458,14 +2463,14 @@ static void ep0_req_complete(struct langwell_udc *dev,
dev->ep0_state = WAIT_FOR_SETUP; dev->ep0_state = WAIT_FOR_SETUP;
break; break;
case WAIT_FOR_SETUP: case WAIT_FOR_SETUP:
ERROR(dev, "unexpect ep0 packets\n"); dev_err(&dev->pdev->dev, "unexpect ep0 packets\n");
break; break;
default: default:
ep0_stall(dev); ep0_stall(dev);
break; break;
} }
VDBG(dev, "<--- %s()\n", __func__); dev_vdbg(&dev->pdev->dev, "<--- %s()\n", __func__);
} }
...@@ -2477,16 +2482,17 @@ static void handle_trans_complete(struct langwell_udc *dev) ...@@ -2477,16 +2482,17 @@ static void handle_trans_complete(struct langwell_udc *dev)
struct langwell_ep *epn; struct langwell_ep *epn;
struct langwell_request *curr_req, *temp_req; struct langwell_request *curr_req, *temp_req;
VDBG(dev, "---> %s()\n", __func__); dev_vdbg(&dev->pdev->dev, "---> %s()\n", __func__);
complete_bits = readl(&dev->op_regs->endptcomplete); complete_bits = readl(&dev->op_regs->endptcomplete);
VDBG(dev, "endptcomplete register: 0x%08x\n", complete_bits); dev_vdbg(&dev->pdev->dev, "endptcomplete register: 0x%08x\n",
complete_bits);
/* Write-Clear the bits in endptcomplete register */ /* Write-Clear the bits in endptcomplete register */
writel(complete_bits, &dev->op_regs->endptcomplete); writel(complete_bits, &dev->op_regs->endptcomplete);
if (!complete_bits) { if (!complete_bits) {
DBG(dev, "complete_bits = 0\n"); dev_dbg(&dev->pdev->dev, "complete_bits = 0\n");
goto done; goto done;
} }
...@@ -2506,23 +2512,25 @@ static void handle_trans_complete(struct langwell_udc *dev) ...@@ -2506,23 +2512,25 @@ static void handle_trans_complete(struct langwell_udc *dev)
epn = &dev->ep[i]; epn = &dev->ep[i];
if (epn->name == NULL) { if (epn->name == NULL) {
WARNING(dev, "invalid endpoint\n"); dev_warn(&dev->pdev->dev, "invalid endpoint\n");
continue; continue;
} }
if (i < 2) if (i < 2)
/* ep0 in and out */ /* ep0 in and out */
DBG(dev, "%s-%s transfer completed\n", dev_dbg(&dev->pdev->dev, "%s-%s transfer completed\n",
epn->name, epn->name,
is_in(epn) ? "in" : "out"); is_in(epn) ? "in" : "out");
else else
DBG(dev, "%s transfer completed\n", epn->name); dev_dbg(&dev->pdev->dev, "%s transfer completed\n",
epn->name);
/* process the req queue until an uncomplete request */ /* process the req queue until an uncomplete request */
list_for_each_entry_safe(curr_req, temp_req, list_for_each_entry_safe(curr_req, temp_req,
&epn->queue, queue) { &epn->queue, queue) {
status = process_ep_req(dev, i, curr_req); status = process_ep_req(dev, i, curr_req);
VDBG(dev, "%s req status: %d\n", epn->name, status); dev_vdbg(&dev->pdev->dev, "%s req status: %d\n",
epn->name, status);
if (status) if (status)
break; break;
...@@ -2540,7 +2548,7 @@ static void handle_trans_complete(struct langwell_udc *dev) ...@@ -2540,7 +2548,7 @@ static void handle_trans_complete(struct langwell_udc *dev)
} }
} }
done: done:
VDBG(dev, "<--- %s()\n", __func__); dev_vdbg(&dev->pdev->dev, "<--- %s()\n", __func__);
return; return;
} }
...@@ -2551,14 +2559,14 @@ static void handle_port_change(struct langwell_udc *dev) ...@@ -2551,14 +2559,14 @@ static void handle_port_change(struct langwell_udc *dev)
u32 portsc1, devlc; u32 portsc1, devlc;
u32 speed; u32 speed;
VDBG(dev, "---> %s()\n", __func__); dev_vdbg(&dev->pdev->dev, "---> %s()\n", __func__);
if (dev->bus_reset) if (dev->bus_reset)
dev->bus_reset = 0; dev->bus_reset = 0;
portsc1 = readl(&dev->op_regs->portsc1); portsc1 = readl(&dev->op_regs->portsc1);
devlc = readl(&dev->op_regs->devlc); devlc = readl(&dev->op_regs->devlc);
VDBG(dev, "portsc1 = 0x%08x, devlc = 0x%08x\n", dev_vdbg(&dev->pdev->dev, "portsc1 = 0x%08x, devlc = 0x%08x\n",
portsc1, devlc); portsc1, devlc);
/* bus reset is finished */ /* bus reset is finished */
...@@ -2579,25 +2587,22 @@ static void handle_port_change(struct langwell_udc *dev) ...@@ -2579,25 +2587,22 @@ static void handle_port_change(struct langwell_udc *dev)
dev->gadget.speed = USB_SPEED_UNKNOWN; dev->gadget.speed = USB_SPEED_UNKNOWN;
break; break;
} }
VDBG(dev, "speed = %d, dev->gadget.speed = %d\n", dev_vdbg(&dev->pdev->dev,
"speed = %d, dev->gadget.speed = %d\n",
speed, dev->gadget.speed); speed, dev->gadget.speed);
} }
/* LPM L0 to L1 */ /* LPM L0 to L1 */
if (dev->lpm && dev->lpm_state == LPM_L0) if (dev->lpm && dev->lpm_state == LPM_L0)
if (portsc1 & PORTS_SUSP && portsc1 & PORTS_SLP) { if (portsc1 & PORTS_SUSP && portsc1 & PORTS_SLP) {
INFO(dev, "LPM L0 to L1\n"); dev_info(&dev->pdev->dev, "LPM L0 to L1\n");
dev->lpm_state = LPM_L1; dev->lpm_state = LPM_L1;
} }
/* LPM L1 to L0, force resume or remote wakeup finished */ /* LPM L1 to L0, force resume or remote wakeup finished */
if (dev->lpm && dev->lpm_state == LPM_L1) if (dev->lpm && dev->lpm_state == LPM_L1)
if (!(portsc1 & PORTS_SUSP)) { if (!(portsc1 & PORTS_SUSP)) {
if (portsc1 & PORTS_SLP) dev_info(&dev->pdev->dev, "LPM L1 to L0\n");
INFO(dev, "LPM L1 to L0, force resume\n");
else
INFO(dev, "LPM L1 to L0, remote wakeup\n");
dev->lpm_state = LPM_L0; dev->lpm_state = LPM_L0;
} }
...@@ -2605,7 +2610,7 @@ static void handle_port_change(struct langwell_udc *dev) ...@@ -2605,7 +2610,7 @@ static void handle_port_change(struct langwell_udc *dev)
if (!dev->resume_state) if (!dev->resume_state)
dev->usb_state = USB_STATE_DEFAULT; dev->usb_state = USB_STATE_DEFAULT;
VDBG(dev, "<--- %s()\n", __func__); dev_vdbg(&dev->pdev->dev, "<--- %s()\n", __func__);
} }
...@@ -2617,7 +2622,7 @@ static void handle_usb_reset(struct langwell_udc *dev) ...@@ -2617,7 +2622,7 @@ static void handle_usb_reset(struct langwell_udc *dev)
endptcomplete; endptcomplete;
unsigned long timeout; unsigned long timeout;
VDBG(dev, "---> %s()\n", __func__); dev_vdbg(&dev->pdev->dev, "---> %s()\n", __func__);
/* Write-Clear the device address */ /* Write-Clear the device address */
deviceaddr = readl(&dev->op_regs->deviceaddr); deviceaddr = readl(&dev->op_regs->deviceaddr);
...@@ -2651,7 +2656,7 @@ static void handle_usb_reset(struct langwell_udc *dev) ...@@ -2651,7 +2656,7 @@ static void handle_usb_reset(struct langwell_udc *dev)
timeout = jiffies + PRIME_TIMEOUT; timeout = jiffies + PRIME_TIMEOUT;
while (readl(&dev->op_regs->endptprime)) { while (readl(&dev->op_regs->endptprime)) {
if (time_after(jiffies, timeout)) { if (time_after(jiffies, timeout)) {
ERROR(dev, "USB reset timeout\n"); dev_err(&dev->pdev->dev, "USB reset timeout\n");
break; break;
} }
cpu_relax(); cpu_relax();
...@@ -2661,7 +2666,7 @@ static void handle_usb_reset(struct langwell_udc *dev) ...@@ -2661,7 +2666,7 @@ static void handle_usb_reset(struct langwell_udc *dev)
writel((u32) ~0, &dev->op_regs->endptflush); writel((u32) ~0, &dev->op_regs->endptflush);
if (readl(&dev->op_regs->portsc1) & PORTS_PR) { if (readl(&dev->op_regs->portsc1) & PORTS_PR) {
VDBG(dev, "USB bus reset\n"); dev_vdbg(&dev->pdev->dev, "USB bus reset\n");
/* bus is reseting */ /* bus is reseting */
dev->bus_reset = 1; dev->bus_reset = 1;
...@@ -2669,7 +2674,7 @@ static void handle_usb_reset(struct langwell_udc *dev) ...@@ -2669,7 +2674,7 @@ static void handle_usb_reset(struct langwell_udc *dev)
stop_activity(dev, dev->driver); stop_activity(dev, dev->driver);
dev->usb_state = USB_STATE_DEFAULT; dev->usb_state = USB_STATE_DEFAULT;
} else { } else {
VDBG(dev, "device controller reset\n"); dev_vdbg(&dev->pdev->dev, "device controller reset\n");
/* controller reset */ /* controller reset */
langwell_udc_reset(dev); langwell_udc_reset(dev);
...@@ -2691,7 +2696,7 @@ static void handle_usb_reset(struct langwell_udc *dev) ...@@ -2691,7 +2696,7 @@ static void handle_usb_reset(struct langwell_udc *dev)
dev->lotg->hsm.b_hnp_enable = 0; dev->lotg->hsm.b_hnp_enable = 0;
#endif #endif
VDBG(dev, "<--- %s()\n", __func__); dev_vdbg(&dev->pdev->dev, "<--- %s()\n", __func__);
} }
...@@ -2699,7 +2704,7 @@ static void handle_usb_reset(struct langwell_udc *dev) ...@@ -2699,7 +2704,7 @@ static void handle_usb_reset(struct langwell_udc *dev)
static void handle_bus_suspend(struct langwell_udc *dev) static void handle_bus_suspend(struct langwell_udc *dev)
{ {
u32 devlc; u32 devlc;
DBG(dev, "---> %s()\n", __func__); dev_dbg(&dev->pdev->dev, "---> %s()\n", __func__);
dev->resume_state = dev->usb_state; dev->resume_state = dev->usb_state;
dev->usb_state = USB_STATE_SUSPENDED; dev->usb_state = USB_STATE_SUSPENDED;
...@@ -2733,31 +2738,30 @@ static void handle_bus_suspend(struct langwell_udc *dev) ...@@ -2733,31 +2738,30 @@ static void handle_bus_suspend(struct langwell_udc *dev)
spin_unlock(&dev->lock); spin_unlock(&dev->lock);
dev->driver->suspend(&dev->gadget); dev->driver->suspend(&dev->gadget);
spin_lock(&dev->lock); spin_lock(&dev->lock);
DBG(dev, "suspend %s\n", dev->driver->driver.name); dev_dbg(&dev->pdev->dev, "suspend %s\n",
dev->driver->driver.name);
} }
} }
/* enter PHY low power suspend */ /* enter PHY low power suspend */
devlc = readl(&dev->op_regs->devlc); devlc = readl(&dev->op_regs->devlc);
VDBG(dev, "devlc = 0x%08x\n", devlc);
devlc |= LPM_PHCD; devlc |= LPM_PHCD;
writel(devlc, &dev->op_regs->devlc); writel(devlc, &dev->op_regs->devlc);
DBG(dev, "<--- %s()\n", __func__); dev_dbg(&dev->pdev->dev, "<--- %s()\n", __func__);
} }
static void handle_bus_resume(struct langwell_udc *dev) static void handle_bus_resume(struct langwell_udc *dev)
{ {
u32 devlc; u32 devlc;
DBG(dev, "---> %s()\n", __func__); dev_dbg(&dev->pdev->dev, "---> %s()\n", __func__);
dev->usb_state = dev->resume_state; dev->usb_state = dev->resume_state;
dev->resume_state = 0; dev->resume_state = 0;
/* exit PHY low power suspend */ /* exit PHY low power suspend */
devlc = readl(&dev->op_regs->devlc); devlc = readl(&dev->op_regs->devlc);
VDBG(dev, "devlc = 0x%08x\n", devlc);
devlc &= ~LPM_PHCD; devlc &= ~LPM_PHCD;
writel(devlc, &dev->op_regs->devlc); writel(devlc, &dev->op_regs->devlc);
...@@ -2772,11 +2776,12 @@ static void handle_bus_resume(struct langwell_udc *dev) ...@@ -2772,11 +2776,12 @@ static void handle_bus_resume(struct langwell_udc *dev)
spin_unlock(&dev->lock); spin_unlock(&dev->lock);
dev->driver->resume(&dev->gadget); dev->driver->resume(&dev->gadget);
spin_lock(&dev->lock); spin_lock(&dev->lock);
DBG(dev, "resume %s\n", dev->driver->driver.name); dev_dbg(&dev->pdev->dev, "resume %s\n",
dev->driver->driver.name);
} }
} }
DBG(dev, "<--- %s()\n", __func__); dev_dbg(&dev->pdev->dev, "<--- %s()\n", __func__);
} }
...@@ -2789,11 +2794,11 @@ static irqreturn_t langwell_irq(int irq, void *_dev) ...@@ -2789,11 +2794,11 @@ static irqreturn_t langwell_irq(int irq, void *_dev)
irq_sts, irq_sts,
portsc1; portsc1;
VDBG(dev, "---> %s()\n", __func__); dev_vdbg(&dev->pdev->dev, "---> %s()\n", __func__);
if (dev->stopped) { if (dev->stopped) {
VDBG(dev, "handle IRQ_NONE\n"); dev_vdbg(&dev->pdev->dev, "handle IRQ_NONE\n");
VDBG(dev, "<--- %s()\n", __func__); dev_vdbg(&dev->pdev->dev, "<--- %s()\n", __func__);
return IRQ_NONE; return IRQ_NONE;
} }
...@@ -2806,12 +2811,13 @@ static irqreturn_t langwell_irq(int irq, void *_dev) ...@@ -2806,12 +2811,13 @@ static irqreturn_t langwell_irq(int irq, void *_dev)
usbintr = readl(&dev->op_regs->usbintr); usbintr = readl(&dev->op_regs->usbintr);
irq_sts = usbsts & usbintr; irq_sts = usbsts & usbintr;
VDBG(dev, "usbsts = 0x%08x, usbintr = 0x%08x, irq_sts = 0x%08x\n", dev_vdbg(&dev->pdev->dev,
"usbsts = 0x%08x, usbintr = 0x%08x, irq_sts = 0x%08x\n",
usbsts, usbintr, irq_sts); usbsts, usbintr, irq_sts);
if (!irq_sts) { if (!irq_sts) {
VDBG(dev, "handle IRQ_NONE\n"); dev_vdbg(&dev->pdev->dev, "handle IRQ_NONE\n");
VDBG(dev, "<--- %s()\n", __func__); dev_vdbg(&dev->pdev->dev, "<--- %s()\n", __func__);
spin_unlock(&dev->lock); spin_unlock(&dev->lock);
return IRQ_NONE; return IRQ_NONE;
} }
...@@ -2827,12 +2833,13 @@ static irqreturn_t langwell_irq(int irq, void *_dev) ...@@ -2827,12 +2833,13 @@ static irqreturn_t langwell_irq(int irq, void *_dev)
/* USB interrupt */ /* USB interrupt */
if (irq_sts & STS_UI) { if (irq_sts & STS_UI) {
VDBG(dev, "USB interrupt\n"); dev_vdbg(&dev->pdev->dev, "USB interrupt\n");
/* setup packet received from ep0 */ /* setup packet received from ep0 */
if (readl(&dev->op_regs->endptsetupstat) if (readl(&dev->op_regs->endptsetupstat)
& EP0SETUPSTAT_MASK) { & EP0SETUPSTAT_MASK) {
VDBG(dev, "USB SETUP packet received interrupt\n"); dev_vdbg(&dev->pdev->dev,
"USB SETUP packet received interrupt\n");
/* setup tripwire semaphone */ /* setup tripwire semaphone */
setup_tripwire(dev); setup_tripwire(dev);
handle_setup_packet(dev, &dev->local_setup_buff); handle_setup_packet(dev, &dev->local_setup_buff);
...@@ -2840,7 +2847,8 @@ static irqreturn_t langwell_irq(int irq, void *_dev) ...@@ -2840,7 +2847,8 @@ static irqreturn_t langwell_irq(int irq, void *_dev)
/* USB transfer completion */ /* USB transfer completion */
if (readl(&dev->op_regs->endptcomplete)) { if (readl(&dev->op_regs->endptcomplete)) {
VDBG(dev, "USB transfer completion interrupt\n"); dev_vdbg(&dev->pdev->dev,
"USB transfer completion interrupt\n");
handle_trans_complete(dev); handle_trans_complete(dev);
} }
} }
...@@ -2848,36 +2856,36 @@ static irqreturn_t langwell_irq(int irq, void *_dev) ...@@ -2848,36 +2856,36 @@ static irqreturn_t langwell_irq(int irq, void *_dev)
/* SOF received interrupt (for ISO transfer) */ /* SOF received interrupt (for ISO transfer) */
if (irq_sts & STS_SRI) { if (irq_sts & STS_SRI) {
/* FIXME */ /* FIXME */
/* VDBG(dev, "SOF received interrupt\n"); */ /* dev_vdbg(&dev->pdev->dev, "SOF received interrupt\n"); */
} }
/* port change detect interrupt */ /* port change detect interrupt */
if (irq_sts & STS_PCI) { if (irq_sts & STS_PCI) {
VDBG(dev, "port change detect interrupt\n"); dev_vdbg(&dev->pdev->dev, "port change detect interrupt\n");
handle_port_change(dev); handle_port_change(dev);
} }
/* suspend interrrupt */ /* suspend interrrupt */
if (irq_sts & STS_SLI) { if (irq_sts & STS_SLI) {
VDBG(dev, "suspend interrupt\n"); dev_vdbg(&dev->pdev->dev, "suspend interrupt\n");
handle_bus_suspend(dev); handle_bus_suspend(dev);
} }
/* USB reset interrupt */ /* USB reset interrupt */
if (irq_sts & STS_URI) { if (irq_sts & STS_URI) {
VDBG(dev, "USB reset interrupt\n"); dev_vdbg(&dev->pdev->dev, "USB reset interrupt\n");
handle_usb_reset(dev); handle_usb_reset(dev);
} }
/* USB error or system error interrupt */ /* USB error or system error interrupt */
if (irq_sts & (STS_UEI | STS_SEI)) { if (irq_sts & (STS_UEI | STS_SEI)) {
/* FIXME */ /* FIXME */
WARNING(dev, "error IRQ, irq_sts: %x\n", irq_sts); dev_warn(&dev->pdev->dev, "error IRQ, irq_sts: %x\n", irq_sts);
} }
spin_unlock(&dev->lock); spin_unlock(&dev->lock);
VDBG(dev, "<--- %s()\n", __func__); dev_vdbg(&dev->pdev->dev, "<--- %s()\n", __func__);
return IRQ_HANDLED; return IRQ_HANDLED;
} }
...@@ -2889,11 +2897,11 @@ static void gadget_release(struct device *_dev) ...@@ -2889,11 +2897,11 @@ static void gadget_release(struct device *_dev)
{ {
struct langwell_udc *dev = the_controller; struct langwell_udc *dev = the_controller;
DBG(dev, "---> %s()\n", __func__); dev_dbg(&dev->pdev->dev, "---> %s()\n", __func__);
complete(dev->done); complete(dev->done);
DBG(dev, "<--- %s()\n", __func__); dev_dbg(&dev->pdev->dev, "<--- %s()\n", __func__);
kfree(dev); kfree(dev);
} }
...@@ -2906,7 +2914,7 @@ static void langwell_udc_remove(struct pci_dev *pdev) ...@@ -2906,7 +2914,7 @@ static void langwell_udc_remove(struct pci_dev *pdev)
DECLARE_COMPLETION(done); DECLARE_COMPLETION(done);
BUG_ON(dev->driver); BUG_ON(dev->driver);
DBG(dev, "---> %s()\n", __func__); dev_dbg(&dev->pdev->dev, "---> %s()\n", __func__);
dev->done = &done; dev->done = &done;
...@@ -2949,8 +2957,8 @@ static void langwell_udc_remove(struct pci_dev *pdev) ...@@ -2949,8 +2957,8 @@ static void langwell_udc_remove(struct pci_dev *pdev)
dev->cap_regs = NULL; dev->cap_regs = NULL;
INFO(dev, "unbind\n"); dev_info(&dev->pdev->dev, "unbind\n");
DBG(dev, "<--- %s()\n", __func__); dev_dbg(&dev->pdev->dev, "<--- %s()\n", __func__);
device_unregister(&dev->gadget.dev); device_unregister(&dev->gadget.dev);
device_remove_file(&pdev->dev, &dev_attr_langwell_udc); device_remove_file(&pdev->dev, &dev_attr_langwell_udc);
...@@ -2997,7 +3005,7 @@ static int langwell_udc_probe(struct pci_dev *pdev, ...@@ -2997,7 +3005,7 @@ static int langwell_udc_probe(struct pci_dev *pdev,
spin_lock_init(&dev->lock); spin_lock_init(&dev->lock);
dev->pdev = pdev; dev->pdev = pdev;
DBG(dev, "---> %s()\n", __func__); dev_dbg(&dev->pdev->dev, "---> %s()\n", __func__);
#ifdef OTG_TRANSCEIVER #ifdef OTG_TRANSCEIVER
/* PCI device is already enabled by otg_transceiver driver */ /* PCI device is already enabled by otg_transceiver driver */
...@@ -3022,7 +3030,7 @@ static int langwell_udc_probe(struct pci_dev *pdev, ...@@ -3022,7 +3030,7 @@ static int langwell_udc_probe(struct pci_dev *pdev,
resource = pci_resource_start(pdev, 0); resource = pci_resource_start(pdev, 0);
len = pci_resource_len(pdev, 0); len = pci_resource_len(pdev, 0);
if (!request_mem_region(resource, len, driver_name)) { if (!request_mem_region(resource, len, driver_name)) {
ERROR(dev, "controller already in use\n"); dev_err(&dev->pdev->dev, "controller already in use\n");
retval = -EBUSY; retval = -EBUSY;
goto error; goto error;
} }
...@@ -3031,33 +3039,35 @@ static int langwell_udc_probe(struct pci_dev *pdev, ...@@ -3031,33 +3039,35 @@ static int langwell_udc_probe(struct pci_dev *pdev,
base = ioremap_nocache(resource, len); base = ioremap_nocache(resource, len);
#endif #endif
if (base == NULL) { if (base == NULL) {
ERROR(dev, "can't map memory\n"); dev_err(&dev->pdev->dev, "can't map memory\n");
retval = -EFAULT; retval = -EFAULT;
goto error; goto error;
} }
dev->cap_regs = (struct langwell_cap_regs __iomem *) base; dev->cap_regs = (struct langwell_cap_regs __iomem *) base;
VDBG(dev, "dev->cap_regs: %p\n", dev->cap_regs); dev_vdbg(&dev->pdev->dev, "dev->cap_regs: %p\n", dev->cap_regs);
dev->op_regs = (struct langwell_op_regs __iomem *) dev->op_regs = (struct langwell_op_regs __iomem *)
(base + OP_REG_OFFSET); (base + OP_REG_OFFSET);
VDBG(dev, "dev->op_regs: %p\n", dev->op_regs); dev_vdbg(&dev->pdev->dev, "dev->op_regs: %p\n", dev->op_regs);
/* irq setup after old hardware is cleaned up */ /* irq setup after old hardware is cleaned up */
if (!pdev->irq) { if (!pdev->irq) {
ERROR(dev, "No IRQ. Check PCI setup!\n"); dev_err(&dev->pdev->dev, "No IRQ. Check PCI setup!\n");
retval = -ENODEV; retval = -ENODEV;
goto error; goto error;
} }
#ifndef OTG_TRANSCEIVER #ifndef OTG_TRANSCEIVER
INFO(dev, "irq %d, io mem: 0x%08lx, len: 0x%08lx, pci mem 0x%p\n", dev_info(&dev->pdev->dev,
"irq %d, io mem: 0x%08lx, len: 0x%08lx, pci mem 0x%p\n",
pdev->irq, resource, len, base); pdev->irq, resource, len, base);
/* enables bus-mastering for device dev */ /* enables bus-mastering for device dev */
pci_set_master(pdev); pci_set_master(pdev);
if (request_irq(pdev->irq, langwell_irq, IRQF_SHARED, if (request_irq(pdev->irq, langwell_irq, IRQF_SHARED,
driver_name, dev) != 0) { driver_name, dev) != 0) {
ERROR(dev, "request interrupt %d failed\n", pdev->irq); dev_err(&dev->pdev->dev,
"request interrupt %d failed\n", pdev->irq);
retval = -EBUSY; retval = -EBUSY;
goto error; goto error;
} }
...@@ -3071,32 +3081,34 @@ static int langwell_udc_probe(struct pci_dev *pdev, ...@@ -3071,32 +3081,34 @@ static int langwell_udc_probe(struct pci_dev *pdev,
dev->lpm = (readl(&dev->cap_regs->hccparams) & HCC_LEN) ? 1 : 0; dev->lpm = (readl(&dev->cap_regs->hccparams) & HCC_LEN) ? 1 : 0;
dev->dciversion = readw(&dev->cap_regs->dciversion); dev->dciversion = readw(&dev->cap_regs->dciversion);
dev->devcap = (readl(&dev->cap_regs->dccparams) & DEVCAP) ? 1 : 0; dev->devcap = (readl(&dev->cap_regs->dccparams) & DEVCAP) ? 1 : 0;
VDBG(dev, "dev->lpm: %d\n", dev->lpm); dev_vdbg(&dev->pdev->dev, "dev->lpm: %d\n", dev->lpm);
VDBG(dev, "dev->dciversion: 0x%04x\n", dev->dciversion); dev_vdbg(&dev->pdev->dev, "dev->dciversion: 0x%04x\n",
VDBG(dev, "dccparams: 0x%08x\n", readl(&dev->cap_regs->dccparams)); dev->dciversion);
VDBG(dev, "dev->devcap: %d\n", dev->devcap); dev_vdbg(&dev->pdev->dev, "dccparams: 0x%08x\n",
readl(&dev->cap_regs->dccparams));
dev_vdbg(&dev->pdev->dev, "dev->devcap: %d\n", dev->devcap);
if (!dev->devcap) { if (!dev->devcap) {
ERROR(dev, "can't support device mode\n"); dev_err(&dev->pdev->dev, "can't support device mode\n");
retval = -ENODEV; retval = -ENODEV;
goto error; goto error;
} }
/* a pair of endpoints (out/in) for each address */ /* a pair of endpoints (out/in) for each address */
dev->ep_max = DEN(readl(&dev->cap_regs->dccparams)) * 2; dev->ep_max = DEN(readl(&dev->cap_regs->dccparams)) * 2;
VDBG(dev, "dev->ep_max: %d\n", dev->ep_max); dev_vdbg(&dev->pdev->dev, "dev->ep_max: %d\n", dev->ep_max);
/* allocate endpoints memory */ /* allocate endpoints memory */
dev->ep = kzalloc(sizeof(struct langwell_ep) * dev->ep_max, dev->ep = kzalloc(sizeof(struct langwell_ep) * dev->ep_max,
GFP_KERNEL); GFP_KERNEL);
if (!dev->ep) { if (!dev->ep) {
ERROR(dev, "allocate endpoints memory failed\n"); dev_err(&dev->pdev->dev, "allocate endpoints memory failed\n");
retval = -ENOMEM; retval = -ENOMEM;
goto error; goto error;
} }
/* allocate device dQH memory */ /* allocate device dQH memory */
size = dev->ep_max * sizeof(struct langwell_dqh); size = dev->ep_max * sizeof(struct langwell_dqh);
VDBG(dev, "orig size = %d\n", size); dev_vdbg(&dev->pdev->dev, "orig size = %d\n", size);
if (size < DQH_ALIGNMENT) if (size < DQH_ALIGNMENT)
size = DQH_ALIGNMENT; size = DQH_ALIGNMENT;
else if ((size % DQH_ALIGNMENT) != 0) { else if ((size % DQH_ALIGNMENT) != 0) {
...@@ -3106,17 +3118,18 @@ static int langwell_udc_probe(struct pci_dev *pdev, ...@@ -3106,17 +3118,18 @@ static int langwell_udc_probe(struct pci_dev *pdev,
dev->ep_dqh = dma_alloc_coherent(&pdev->dev, size, dev->ep_dqh = dma_alloc_coherent(&pdev->dev, size,
&dev->ep_dqh_dma, GFP_KERNEL); &dev->ep_dqh_dma, GFP_KERNEL);
if (!dev->ep_dqh) { if (!dev->ep_dqh) {
ERROR(dev, "allocate dQH memory failed\n"); dev_err(&dev->pdev->dev, "allocate dQH memory failed\n");
retval = -ENOMEM; retval = -ENOMEM;
goto error; goto error;
} }
dev->ep_dqh_size = size; dev->ep_dqh_size = size;
VDBG(dev, "ep_dqh_size = %d\n", dev->ep_dqh_size); dev_vdbg(&dev->pdev->dev, "ep_dqh_size = %d\n", dev->ep_dqh_size);
/* initialize ep0 status request structure */ /* initialize ep0 status request structure */
dev->status_req = kzalloc(sizeof(struct langwell_request), GFP_KERNEL); dev->status_req = kzalloc(sizeof(struct langwell_request), GFP_KERNEL);
if (!dev->status_req) { if (!dev->status_req) {
ERROR(dev, "allocate status_req memory failed\n"); dev_err(&dev->pdev->dev,
"allocate status_req memory failed\n");
retval = -ENOMEM; retval = -ENOMEM;
goto error; goto error;
} }
...@@ -3174,18 +3187,20 @@ static int langwell_udc_probe(struct pci_dev *pdev, ...@@ -3174,18 +3187,20 @@ static int langwell_udc_probe(struct pci_dev *pdev,
} }
/* done */ /* done */
INFO(dev, "%s\n", driver_desc); dev_info(&dev->pdev->dev, "%s\n", driver_desc);
INFO(dev, "irq %d, pci mem %p\n", pdev->irq, base); dev_info(&dev->pdev->dev, "irq %d, pci mem %p\n", pdev->irq, base);
INFO(dev, "Driver version: " DRIVER_VERSION "\n"); dev_info(&dev->pdev->dev, "Driver version: " DRIVER_VERSION "\n");
INFO(dev, "Support (max) %d endpoints\n", dev->ep_max); dev_info(&dev->pdev->dev, "Support (max) %d endpoints\n", dev->ep_max);
INFO(dev, "Device interface version: 0x%04x\n", dev->dciversion); dev_info(&dev->pdev->dev, "Device interface version: 0x%04x\n",
INFO(dev, "Controller mode: %s\n", dev->devcap ? "Device" : "Host"); dev->dciversion);
INFO(dev, "Support USB LPM: %s\n", dev->lpm ? "Yes" : "No"); dev_info(&dev->pdev->dev, "Controller mode: %s\n",
dev->devcap ? "Device" : "Host");
VDBG(dev, "After langwell_udc_probe(), print all registers:\n"); dev_info(&dev->pdev->dev, "Support USB LPM: %s\n",
#ifdef VERBOSE dev->lpm ? "Yes" : "No");
dev_vdbg(&dev->pdev->dev,
"After langwell_udc_probe(), print all registers:\n");
print_all_registers(dev); print_all_registers(dev);
#endif
the_controller = dev; the_controller = dev;
...@@ -3197,12 +3212,12 @@ static int langwell_udc_probe(struct pci_dev *pdev, ...@@ -3197,12 +3212,12 @@ static int langwell_udc_probe(struct pci_dev *pdev,
if (retval) if (retval)
goto error; goto error;
VDBG(dev, "<--- %s()\n", __func__); dev_vdbg(&dev->pdev->dev, "<--- %s()\n", __func__);
return 0; return 0;
error: error:
if (dev) { if (dev) {
DBG(dev, "<--- %s()\n", __func__); dev_dbg(&dev->pdev->dev, "<--- %s()\n", __func__);
langwell_udc_remove(pdev); langwell_udc_remove(pdev);
} }
...@@ -3216,7 +3231,7 @@ static int langwell_udc_suspend(struct pci_dev *pdev, pm_message_t state) ...@@ -3216,7 +3231,7 @@ static int langwell_udc_suspend(struct pci_dev *pdev, pm_message_t state)
struct langwell_udc *dev = the_controller; struct langwell_udc *dev = the_controller;
u32 devlc; u32 devlc;
DBG(dev, "---> %s()\n", __func__); dev_dbg(&dev->pdev->dev, "---> %s()\n", __func__);
/* disable interrupt and set controller to stop state */ /* disable interrupt and set controller to stop state */
langwell_udc_stop(dev); langwell_udc_stop(dev);
...@@ -3226,7 +3241,6 @@ static int langwell_udc_suspend(struct pci_dev *pdev, pm_message_t state) ...@@ -3226,7 +3241,6 @@ static int langwell_udc_suspend(struct pci_dev *pdev, pm_message_t state)
free_irq(pdev->irq, dev); free_irq(pdev->irq, dev);
dev->got_irq = 0; dev->got_irq = 0;
/* save PCI state */ /* save PCI state */
pci_save_state(pdev); pci_save_state(pdev);
...@@ -3235,11 +3249,10 @@ static int langwell_udc_suspend(struct pci_dev *pdev, pm_message_t state) ...@@ -3235,11 +3249,10 @@ static int langwell_udc_suspend(struct pci_dev *pdev, pm_message_t state)
/* enter PHY low power suspend */ /* enter PHY low power suspend */
devlc = readl(&dev->op_regs->devlc); devlc = readl(&dev->op_regs->devlc);
VDBG(dev, "devlc = 0x%08x\n", devlc);
devlc |= LPM_PHCD; devlc |= LPM_PHCD;
writel(devlc, &dev->op_regs->devlc); writel(devlc, &dev->op_regs->devlc);
DBG(dev, "<--- %s()\n", __func__); dev_dbg(&dev->pdev->dev, "<--- %s()\n", __func__);
return 0; return 0;
} }
...@@ -3250,11 +3263,10 @@ static int langwell_udc_resume(struct pci_dev *pdev) ...@@ -3250,11 +3263,10 @@ static int langwell_udc_resume(struct pci_dev *pdev)
struct langwell_udc *dev = the_controller; struct langwell_udc *dev = the_controller;
u32 devlc; u32 devlc;
DBG(dev, "---> %s()\n", __func__); dev_dbg(&dev->pdev->dev, "---> %s()\n", __func__);
/* exit PHY low power suspend */ /* exit PHY low power suspend */
devlc = readl(&dev->op_regs->devlc); devlc = readl(&dev->op_regs->devlc);
VDBG(dev, "devlc = 0x%08x\n", devlc);
devlc &= ~LPM_PHCD; devlc &= ~LPM_PHCD;
writel(devlc, &dev->op_regs->devlc); writel(devlc, &dev->op_regs->devlc);
...@@ -3265,10 +3277,11 @@ static int langwell_udc_resume(struct pci_dev *pdev) ...@@ -3265,10 +3277,11 @@ static int langwell_udc_resume(struct pci_dev *pdev)
pci_restore_state(pdev); pci_restore_state(pdev);
/* enable IRQ handler */ /* enable IRQ handler */
if (request_irq(pdev->irq, langwell_irq, IRQF_SHARED, driver_name, dev) if (request_irq(pdev->irq, langwell_irq, IRQF_SHARED,
!= 0) { driver_name, dev) != 0) {
ERROR(dev, "request interrupt %d failed\n", pdev->irq); dev_err(&dev->pdev->dev, "request interrupt %d failed\n",
return -1; pdev->irq);
return -EBUSY;
} }
dev->got_irq = 1; dev->got_irq = 1;
...@@ -3290,7 +3303,7 @@ static int langwell_udc_resume(struct pci_dev *pdev) ...@@ -3290,7 +3303,7 @@ static int langwell_udc_resume(struct pci_dev *pdev)
dev->ep0_state = WAIT_FOR_SETUP; dev->ep0_state = WAIT_FOR_SETUP;
dev->ep0_dir = USB_DIR_OUT; dev->ep0_dir = USB_DIR_OUT;
DBG(dev, "<--- %s()\n", __func__); dev_dbg(&dev->pdev->dev, "<--- %s()\n", __func__);
return 0; return 0;
} }
...@@ -3301,15 +3314,15 @@ static void langwell_udc_shutdown(struct pci_dev *pdev) ...@@ -3301,15 +3314,15 @@ static void langwell_udc_shutdown(struct pci_dev *pdev)
struct langwell_udc *dev = the_controller; struct langwell_udc *dev = the_controller;
u32 usbmode; u32 usbmode;
DBG(dev, "---> %s()\n", __func__); dev_dbg(&dev->pdev->dev, "---> %s()\n", __func__);
/* reset controller mode to IDLE */ /* reset controller mode to IDLE */
usbmode = readl(&dev->op_regs->usbmode); usbmode = readl(&dev->op_regs->usbmode);
DBG(dev, "usbmode = 0x%08x\n", usbmode); dev_dbg(&dev->pdev->dev, "usbmode = 0x%08x\n", usbmode);
usbmode &= (~3 | MODE_IDLE); usbmode &= (~3 | MODE_IDLE);
writel(usbmode, &dev->op_regs->usbmode); writel(usbmode, &dev->op_regs->usbmode);
DBG(dev, "<--- %s()\n", __func__); dev_dbg(&dev->pdev->dev, "<--- %s()\n", __func__);
} }
/*-------------------------------------------------------------------------*/ /*-------------------------------------------------------------------------*/
...@@ -3324,7 +3337,6 @@ static const struct pci_device_id pci_ids[] = { { ...@@ -3324,7 +3337,6 @@ static const struct pci_device_id pci_ids[] = { {
}, { /* end: all zeroes */ } }, { /* end: all zeroes */ }
}; };
MODULE_DEVICE_TABLE(pci, pci_ids); MODULE_DEVICE_TABLE(pci, pci_ids);
...@@ -3343,12 +3355,6 @@ static struct pci_driver langwell_pci_driver = { ...@@ -3343,12 +3355,6 @@ static struct pci_driver langwell_pci_driver = {
}; };
MODULE_DESCRIPTION(DRIVER_DESC);
MODULE_AUTHOR("Xiaochen Shen <xiaochen.shen@intel.com>");
MODULE_VERSION(DRIVER_VERSION);
MODULE_LICENSE("GPL");
static int __init init(void) static int __init init(void)
{ {
#ifdef OTG_TRANSCEIVER #ifdef OTG_TRANSCEIVER
...@@ -3370,3 +3376,9 @@ static void __exit cleanup(void) ...@@ -3370,3 +3376,9 @@ static void __exit cleanup(void)
} }
module_exit(cleanup); module_exit(cleanup);
MODULE_DESCRIPTION(DRIVER_DESC);
MODULE_AUTHOR("Xiaochen Shen <xiaochen.shen@intel.com>");
MODULE_VERSION(DRIVER_VERSION);
MODULE_LICENSE("GPL");
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment