/*
 * ISP1362 HCD (Host Controller Driver) for USB.
 *
 * Copyright (C) 2005 Lothar Wassmann <LW@KARO-electronics.de>
 *
 * Derived from the SL811 HCD, rewritten for ISP116x.
 * Copyright (C) 2005 Olav Kongas <ok@artecdesign.ee>
 *
 * Portions:
 * Copyright (C) 2004 Psion Teklogix (for NetBook PRO)
 * Copyright (C) 2004 David Brownell
 */

/*
 * The ISP1362 chip requires a large delay (300ns and 462ns) between
 * accesses to the address and data register.
 * The following timing options exist:
 *
 * 1. Configure your memory controller to add such delays if it can (the best)
 * 2. Implement platform-specific delay function possibly
 *    combined with configuring the memory controller; see
 *    include/linux/usb_isp1362.h for more info.
 * 3. Use ndelay (easiest, poorest).
 *
 * Use the corresponding macros USE_PLATFORM_DELAY and USE_NDELAY in the
 * platform specific section of isp1362.h to select the appropriate variant.
 *
 * Also note that according to the Philips "ISP1362 Errata" document
 * Rev 1.00 from 27 May data corruption may occur when the #WR signal
 * is reasserted (even with #CS deasserted) within 132ns after a
 * write cycle to any controller register. If the hardware doesn't
 * implement the recommended fix (gating the #WR with #CS) software
 * must ensure that no further write cycle (not necessarily to the chip!)
 * is issued by the CPU within this interval.

 * For PXA25x this can be ensured by using VLIO with the maximum
 * recovery time (MSCx = 0x7f8c) with a memory clock of 99.53 MHz.
 */

#ifdef CONFIG_USB_DEBUG
# define ISP1362_DEBUG
#else
# undef ISP1362_DEBUG
#endif

/*
 * The PXA255 UDC apparently doesn't handle GET_STATUS, GET_CONFIG and
 * GET_INTERFACE requests correctly when the SETUP and DATA stages of the
 * requests are carried out in separate frames. This will delay any SETUP
 * packets until the start of the next frame so that this situation is
 * unlikely to occur (and makes usbtest happy running with a PXA255 target
 * device).
 */
#undef BUGGY_PXA2XX_UDC_USBTEST

#undef PTD_TRACE
#undef URB_TRACE
#undef VERBOSE
#undef REGISTERS

/* This enables a memory test on the ISP1362 chip memory to make sure the
 * chip access timing is correct.
 */
#undef CHIP_BUFFER_TEST

#include <linux/module.h>
#include <linux/moduleparam.h>
#include <linux/kernel.h>
#include <linux/delay.h>
#include <linux/ioport.h>
#include <linux/sched.h>
#include <linux/slab.h>
#include <linux/smp_lock.h>
#include <linux/errno.h>
#include <linux/init.h>
#include <linux/list.h>
#include <linux/interrupt.h>
#include <linux/usb.h>
#include <linux/usb/isp1362.h>
#include <linux/usb/hcd.h>
#include <linux/platform_device.h>
#include <linux/pm.h>
#include <linux/io.h>
#include <linux/bitmap.h>

#include <asm/irq.h>
#include <asm/system.h>
#include <asm/byteorder.h>
#include <asm/unaligned.h>

static int dbg_level;
#ifdef ISP1362_DEBUG
module_param(dbg_level, int, 0644);
#else
module_param(dbg_level, int, 0);
#define	STUB_DEBUG_FILE
#endif

#include "../core/usb.h"
#include "isp1362.h"


#define DRIVER_VERSION	"2005-04-04"
#define DRIVER_DESC	"ISP1362 USB Host Controller Driver"

MODULE_DESCRIPTION(DRIVER_DESC);
MODULE_LICENSE("GPL");

static const char hcd_name[] = "isp1362-hcd";

static void isp1362_hc_stop(struct usb_hcd *hcd);
static int isp1362_hc_start(struct usb_hcd *hcd);

/*-------------------------------------------------------------------------*/

/*
 * When called from the interrupthandler only isp1362_hcd->irqenb is modified,
 * since the interrupt handler will write isp1362_hcd->irqenb to HCuPINT upon
 * completion.
 * We don't need a 'disable' counterpart, since interrupts will be disabled
 * only by the interrupt handler.
 */
static inline void isp1362_enable_int(struct isp1362_hcd *isp1362_hcd, u16 mask)
{
	if ((isp1362_hcd->irqenb | mask) == isp1362_hcd->irqenb)
		return;
	if (mask & ~isp1362_hcd->irqenb)
		isp1362_write_reg16(isp1362_hcd, HCuPINT, mask & ~isp1362_hcd->irqenb);
	isp1362_hcd->irqenb |= mask;
	if (isp1362_hcd->irq_active)
		return;
	isp1362_write_reg16(isp1362_hcd, HCuPINTENB, isp1362_hcd->irqenb);
}

/*-------------------------------------------------------------------------*/

static inline struct isp1362_ep_queue *get_ptd_queue(struct isp1362_hcd *isp1362_hcd,
						     u16 offset)
{
	struct isp1362_ep_queue *epq = NULL;

	if (offset < isp1362_hcd->istl_queue[1].buf_start)
		epq = &isp1362_hcd->istl_queue[0];
	else if (offset < isp1362_hcd->intl_queue.buf_start)
		epq = &isp1362_hcd->istl_queue[1];
	else if (offset < isp1362_hcd->atl_queue.buf_start)
		epq = &isp1362_hcd->intl_queue;
	else if (offset < isp1362_hcd->atl_queue.buf_start +
		   isp1362_hcd->atl_queue.buf_size)
		epq = &isp1362_hcd->atl_queue;

	if (epq)
		DBG(1, "%s: PTD $%04x is on %s queue\n", __func__, offset, epq->name);
	else
		pr_warning("%s: invalid PTD $%04x\n", __func__, offset);

	return epq;
}

static inline int get_ptd_offset(struct isp1362_ep_queue *epq, u8 index)
{
	int offset;

	if (index * epq->blk_size > epq->buf_size) {
		pr_warning("%s: Bad %s index %d(%d)\n", __func__, epq->name, index,
		     epq->buf_size / epq->blk_size);
		return -EINVAL;
	}
	offset = epq->buf_start + index * epq->blk_size;
	DBG(3, "%s: %s PTD[%02x] # %04x\n", __func__, epq->name, index, offset);

	return offset;
}

/*-------------------------------------------------------------------------*/

static inline u16 max_transfer_size(struct isp1362_ep_queue *epq, size_t size,
				    int mps)
{
	u16 xfer_size = min_t(size_t, MAX_XFER_SIZE, size);

	xfer_size = min_t(size_t, xfer_size, epq->buf_avail * epq->blk_size - PTD_HEADER_SIZE);
	if (xfer_size < size && xfer_size % mps)
		xfer_size -= xfer_size % mps;

	return xfer_size;
}

static int claim_ptd_buffers(struct isp1362_ep_queue *epq,
			     struct isp1362_ep *ep, u16 len)
{
	int ptd_offset = -EINVAL;
	int num_ptds = ((len + PTD_HEADER_SIZE - 1) / epq->blk_size) + 1;
	int found;

	BUG_ON(len > epq->buf_size);

	if (!epq->buf_avail)
		return -ENOMEM;

	if (ep->num_ptds)
		pr_err("%s: %s len %d/%d num_ptds %d buf_map %08lx skip_map %08lx\n", __func__,
		    epq->name, len, epq->blk_size, num_ptds, epq->buf_map, epq->skip_map);
	BUG_ON(ep->num_ptds != 0);

	found = bitmap_find_next_zero_area(&epq->buf_map, epq->buf_count, 0,
						num_ptds, 0);
	if (found >= epq->buf_count)
		return -EOVERFLOW;

	DBG(1, "%s: Found %d PTDs[%d] for %d/%d byte\n", __func__,
	    num_ptds, found, len, (int)(epq->blk_size - PTD_HEADER_SIZE));
	ptd_offset = get_ptd_offset(epq, found);
	WARN_ON(ptd_offset < 0);
	ep->ptd_offset = ptd_offset;
	ep->num_ptds += num_ptds;
	epq->buf_avail -= num_ptds;
	BUG_ON(epq->buf_avail > epq->buf_count);
	ep->ptd_index = found;
	bitmap_set(&epq->buf_map, found, num_ptds);
	DBG(1, "%s: Done %s PTD[%d] $%04x, avail %d count %d claimed %d %08lx:%08lx\n",
	    __func__, epq->name, ep->ptd_index, ep->ptd_offset,
	    epq->buf_avail, epq->buf_count, num_ptds, epq->buf_map, epq->skip_map);

	return found;
}

static inline void release_ptd_buffers(struct isp1362_ep_queue *epq, struct isp1362_ep *ep)
{
	int index = ep->ptd_index;
	int last = ep->ptd_index + ep->num_ptds;

	if (last > epq->buf_count)
		pr_err("%s: ep %p req %d len %d %s PTD[%d] $%04x num_ptds %d buf_count %d buf_avail %d buf_map %08lx skip_map %08lx\n",
		    __func__, ep, ep->num_req, ep->length, epq->name, ep->ptd_index,
		    ep->ptd_offset, ep->num_ptds, epq->buf_count, epq->buf_avail,
		    epq->buf_map, epq->skip_map);
	BUG_ON(last > epq->buf_count);

	for (; index < last; index++) {
		__clear_bit(index, &epq->buf_map);
		__set_bit(index, &epq->skip_map);
	}
	epq->buf_avail += ep->num_ptds;
	epq->ptd_count--;

	BUG_ON(epq->buf_avail > epq->buf_count);
	BUG_ON(epq->ptd_count > epq->buf_count);

	DBG(1, "%s: Done %s PTDs $%04x released %d avail %d count %d\n",
	    __func__, epq->name,
	    ep->ptd_offset, ep->num_ptds, epq->buf_avail, epq->buf_count);
	DBG(1, "%s: buf_map %08lx skip_map %08lx\n", __func__,
	    epq->buf_map, epq->skip_map);

	ep->num_ptds = 0;
	ep->ptd_offset = -EINVAL;
	ep->ptd_index = -EINVAL;
}

/*-------------------------------------------------------------------------*/

/*
  Set up PTD's.
*/
static void prepare_ptd(struct isp1362_hcd *isp1362_hcd, struct urb *urb,
			struct isp1362_ep *ep, struct isp1362_ep_queue *epq,
			u16 fno)
{
	struct ptd *ptd;
	int toggle;
	int dir;
	u16 len;
	size_t buf_len = urb->transfer_buffer_length - urb->actual_length;

	DBG(3, "%s: %s ep %p\n", __func__, epq->name, ep);

	ptd = &ep->ptd;

	ep->data = (unsigned char *)urb->transfer_buffer + urb->actual_length;

	switch (ep->nextpid) {
	case USB_PID_IN:
		toggle = usb_gettoggle(urb->dev, ep->epnum, 0);
		dir = PTD_DIR_IN;
		if (usb_pipecontrol(urb->pipe)) {
			len = min_t(size_t, ep->maxpacket, buf_len);
		} else if (usb_pipeisoc(urb->pipe)) {
			len = min_t(size_t, urb->iso_frame_desc[fno].length, MAX_XFER_SIZE);
			ep->data = urb->transfer_buffer + urb->iso_frame_desc[fno].offset;
		} else
			len = max_transfer_size(epq, buf_len, ep->maxpacket);
		DBG(1, "%s: IN    len %d/%d/%d from URB\n", __func__, len, ep->maxpacket,
		    (int)buf_len);
		break;
	case USB_PID_OUT:
		toggle = usb_gettoggle(urb->dev, ep->epnum, 1);
		dir = PTD_DIR_OUT;
		if (usb_pipecontrol(urb->pipe))
			len = min_t(size_t, ep->maxpacket, buf_len);
		else if (usb_pipeisoc(urb->pipe))
			len = min_t(size_t, urb->iso_frame_desc[0].length, MAX_XFER_SIZE);
		else
			len = max_transfer_size(epq, buf_len, ep->maxpacket);
		if (len == 0)
			pr_info("%s: Sending ZERO packet: %d\n", __func__,
			     urb->transfer_flags & URB_ZERO_PACKET);
		DBG(1, "%s: OUT   len %d/%d/%d from URB\n", __func__, len, ep->maxpacket,
		    (int)buf_len);
		break;
	case USB_PID_SETUP:
		toggle = 0;
		dir = PTD_DIR_SETUP;
		len = sizeof(struct usb_ctrlrequest);
		DBG(1, "%s: SETUP len %d\n", __func__, len);
		ep->data = urb->setup_packet;
		break;
	case USB_PID_ACK:
		toggle = 1;
		len = 0;
		dir = (urb->transfer_buffer_length && usb_pipein(urb->pipe)) ?
			PTD_DIR_OUT : PTD_DIR_IN;
		DBG(1, "%s: ACK   len %d\n", __func__, len);
		break;
	default:
		toggle = dir = len = 0;
		pr_err("%s@%d: ep->nextpid %02x\n", __func__, __LINE__, ep->nextpid);
		BUG_ON(1);
	}

	ep->length = len;
	if (!len)
		ep->data = NULL;

	ptd->count = PTD_CC_MSK | PTD_ACTIVE_MSK | PTD_TOGGLE(toggle);
	ptd->mps = PTD_MPS(ep->maxpacket) | PTD_SPD(urb->dev->speed == USB_SPEED_LOW) |
		PTD_EP(ep->epnum);
	ptd->len = PTD_LEN(len) | PTD_DIR(dir);
	ptd->faddr = PTD_FA(usb_pipedevice(urb->pipe));

	if (usb_pipeint(urb->pipe)) {
		ptd->faddr |= PTD_SF_INT(ep->branch);
		ptd->faddr |= PTD_PR(ep->interval ? __ffs(ep->interval) : 0);
	}
	if (usb_pipeisoc(urb->pipe))
		ptd->faddr |= PTD_SF_ISO(fno);

	DBG(1, "%s: Finished\n", __func__);
}

static void isp1362_write_ptd(struct isp1362_hcd *isp1362_hcd, struct isp1362_ep *ep,
			      struct isp1362_ep_queue *epq)
{
	struct ptd *ptd = &ep->ptd;
	int len = PTD_GET_DIR(ptd) == PTD_DIR_IN ? 0 : ep->length;

	_BUG_ON(ep->ptd_offset < 0);

	prefetch(ptd);
	isp1362_write_buffer(isp1362_hcd, ptd, ep->ptd_offset, PTD_HEADER_SIZE);
	if (len)
		isp1362_write_buffer(isp1362_hcd, ep->data,
				     ep->ptd_offset + PTD_HEADER_SIZE, len);

	dump_ptd(ptd);
	dump_ptd_out_data(ptd, ep->data);
}

static void isp1362_read_ptd(struct isp1362_hcd *isp1362_hcd, struct isp1362_ep *ep,
			     struct isp1362_ep_queue *epq)
{
	struct ptd *ptd = &ep->ptd;
	int act_len;

	WARN_ON(list_empty(&ep->active));
	BUG_ON(ep->ptd_offset < 0);

	list_del_init(&ep->active);
	DBG(1, "%s: ep %p removed from active list %p\n", __func__, ep, &epq->active);

	prefetchw(ptd);
	isp1362_read_buffer(isp1362_hcd, ptd, ep->ptd_offset, PTD_HEADER_SIZE);
	dump_ptd(ptd);
	act_len = PTD_GET_COUNT(ptd);
	if (PTD_GET_DIR(ptd) != PTD_DIR_IN || act_len == 0)
		return;
	if (act_len > ep->length)
		pr_err("%s: ep %p PTD $%04x act_len %d ep->length %d\n", __func__, ep,
			 ep->ptd_offset, act_len, ep->length);
	BUG_ON(act_len > ep->length);
	/* Only transfer the amount of data that has actually been overwritten
	 * in the chip buffer. We don't want any data that doesn't belong to the
	 * transfer to leak out of the chip to the callers transfer buffer!
	 */
	prefetchw(ep->data);
	isp1362_read_buffer(isp1362_hcd, ep->data,
			    ep->ptd_offset + PTD_HEADER_SIZE, act_len);
	dump_ptd_in_data(ptd, ep->data);
}

/*
 * INT PTDs will stay in the chip until data is available.
 * This function will remove a PTD from the chip when the URB is dequeued.
 * Must be called with the spinlock held and IRQs disabled
 */
static void remove_ptd(struct isp1362_hcd *isp1362_hcd, struct isp1362_ep *ep)

{
	int index;
	struct isp1362_ep_queue *epq;

	DBG(1, "%s: ep %p PTD[%d] $%04x\n", __func__, ep, ep->ptd_index, ep->ptd_offset);
	BUG_ON(ep->ptd_offset < 0);

	epq = get_ptd_queue(isp1362_hcd, ep->ptd_offset);
	BUG_ON(!epq);

	/* put ep in remove_list for cleanup */
	WARN_ON(!list_empty(&ep->remove_list));
	list_add_tail(&ep->remove_list, &isp1362_hcd->remove_list);
	/* let SOF interrupt handle the cleanup */
	isp1362_enable_int(isp1362_hcd, HCuPINT_SOF);

	index = ep->ptd_index;
	if (index < 0)
		/* ISO queues don't have SKIP registers */
		return;

	DBG(1, "%s: Disabling PTD[%02x] $%04x %08lx|%08x\n", __func__,
	    index, ep->ptd_offset, epq->skip_map, 1 << index);

	/* prevent further processing of PTD (will be effective after next SOF) */
	epq->skip_map |= 1 << index;
	if (epq == &isp1362_hcd->atl_queue) {
		DBG(2, "%s: ATLSKIP = %08x -> %08lx\n", __func__,
		    isp1362_read_reg32(isp1362_hcd, HCATLSKIP), epq->skip_map);
		isp1362_write_reg32(isp1362_hcd, HCATLSKIP, epq->skip_map);
		if (~epq->skip_map == 0)
			isp1362_clr_mask16(isp1362_hcd, HCBUFSTAT, HCBUFSTAT_ATL_ACTIVE);
	} else if (epq == &isp1362_hcd->intl_queue) {
		DBG(2, "%s: INTLSKIP = %08x -> %08lx\n", __func__,
		    isp1362_read_reg32(isp1362_hcd, HCINTLSKIP), epq->skip_map);
		isp1362_write_reg32(isp1362_hcd, HCINTLSKIP, epq->skip_map);
		if (~epq->skip_map == 0)
			isp1362_clr_mask16(isp1362_hcd, HCBUFSTAT, HCBUFSTAT_INTL_ACTIVE);
	}
}

/*
  Take done or failed requests out of schedule. Give back
  processed urbs.
*/
static void finish_request(struct isp1362_hcd *isp1362_hcd, struct isp1362_ep *ep,
			   struct urb *urb, int status)
     __releases(isp1362_hcd->lock)
     __acquires(isp1362_hcd->lock)
{
	urb->hcpriv = NULL;
	ep->error_count = 0;

	if (usb_pipecontrol(urb->pipe))
		ep->nextpid = USB_PID_SETUP;

	URB_DBG("%s: req %d FA %d ep%d%s %s: len %d/%d %s stat %d\n", __func__,
		ep->num_req, usb_pipedevice(urb->pipe),
		usb_pipeendpoint(urb->pipe),
		!usb_pipein(urb->pipe) ? "out" : "in",
		usb_pipecontrol(urb->pipe) ? "ctrl" :
			usb_pipeint(urb->pipe) ? "int" :
			usb_pipebulk(urb->pipe) ? "bulk" :
			"iso",
		urb->actual_length, urb->transfer_buffer_length,
		!(urb->transfer_flags & URB_SHORT_NOT_OK) ?
		"short_ok" : "", urb->status);


	usb_hcd_unlink_urb_from_ep(isp1362_hcd_to_hcd(isp1362_hcd), urb);
	spin_unlock(&isp1362_hcd->lock);
	usb_hcd_giveback_urb(isp1362_hcd_to_hcd(isp1362_hcd), urb, status);
	spin_lock(&isp1362_hcd->lock);

	/* take idle endpoints out of the schedule right away */
	if (!list_empty(&ep->hep->urb_list))
		return;

	/* async deschedule */
	if (!list_empty(&ep->schedule)) {
		list_del_init(&ep->schedule);
		return;
	}


	if (ep->interval) {
		/* periodic deschedule */
		DBG(1, "deschedule qh%d/%p branch %d load %d bandwidth %d -> %d\n", ep->interval,
		    ep, ep->branch, ep->load,
		    isp1362_hcd->load[ep->branch],
		    isp1362_hcd->load[ep->branch] - ep->load);
		isp1362_hcd->load[ep->branch] -= ep->load;
		ep->branch = PERIODIC_SIZE;
	}
}

/*
 * Analyze transfer results, handle partial transfers and errors
*/
static void postproc_ep(struct isp1362_hcd *isp1362_hcd, struct isp1362_ep *ep)
{
	struct urb *urb = get_urb(ep);
	struct usb_device *udev;
	struct ptd *ptd;
	int short_ok;
	u16 len;
	int urbstat = -EINPROGRESS;
	u8 cc;

	DBG(2, "%s: ep %p req %d\n", __func__, ep, ep->num_req);

	udev = urb->dev;
	ptd = &ep->ptd;
	cc = PTD_GET_CC(ptd);
	if (cc == PTD_NOTACCESSED) {
		pr_err("%s: req %d PTD %p Untouched by ISP1362\n", __func__,
		    ep->num_req, ptd);
		cc = PTD_DEVNOTRESP;
	}

	short_ok = !(urb->transfer_flags & URB_SHORT_NOT_OK);
	len = urb->transfer_buffer_length - urb->actual_length;

	/* Data underrun is special. For allowed underrun
	   we clear the error and continue as normal. For
	   forbidden underrun we finish the DATA stage
	   immediately while for control transfer,
	   we do a STATUS stage.
	*/
	if (cc == PTD_DATAUNDERRUN) {
		if (short_ok) {
			DBG(1, "%s: req %d Allowed data underrun short_%sok %d/%d/%d byte\n",
			    __func__, ep->num_req, short_ok ? "" : "not_",
			    PTD_GET_COUNT(ptd), ep->maxpacket, len);
			cc = PTD_CC_NOERROR;
			urbstat = 0;
		} else {
			DBG(1, "%s: req %d Data Underrun %s nextpid %02x short_%sok %d/%d/%d byte\n",
			    __func__, ep->num_req,
			    usb_pipein(urb->pipe) ? "IN" : "OUT", ep->nextpid,
			    short_ok ? "" : "not_",
			    PTD_GET_COUNT(ptd), ep->maxpacket, len);
			if (usb_pipecontrol(urb->pipe)) {
				ep->nextpid = USB_PID_ACK;
				/* save the data underrun error code for later and
				 * procede with the status stage
				 */
				urb->actual_length += PTD_GET_COUNT(ptd);
				BUG_ON(urb->actual_length > urb->transfer_buffer_length);

				if (urb->status == -EINPROGRESS)
					urb->status = cc_to_error[PTD_DATAUNDERRUN];
			} else {
				usb_settoggle(udev, ep->epnum, ep->nextpid == USB_PID_OUT,
					      PTD_GET_TOGGLE(ptd));
				urbstat = cc_to_error[PTD_DATAUNDERRUN];
			}
			goto out;
		}
	}

	if (cc != PTD_CC_NOERROR) {
		if (++ep->error_count >= 3 || cc == PTD_CC_STALL || cc == PTD_DATAOVERRUN) {
			urbstat = cc_to_error[cc];
			DBG(1, "%s: req %d nextpid %02x, status %d, error %d, error_count %d\n",
			    __func__, ep->num_req, ep->nextpid, urbstat, cc,
			    ep->error_count);
		}
		goto out;
	}

	switch (ep->nextpid) {
	case USB_PID_OUT:
		if (PTD_GET_COUNT(ptd) != ep->length)
			pr_err("%s: count=%d len=%d\n", __func__,
			   PTD_GET_COUNT(ptd), ep->length);
		BUG_ON(PTD_GET_COUNT(ptd) != ep->length);
		urb->actual_length += ep->length;
		BUG_ON(urb->actual_length > urb->transfer_buffer_length);
		usb_settoggle(udev, ep->epnum, 1, PTD_GET_TOGGLE(ptd));
		if (urb->actual_length == urb->transfer_buffer_length) {
			DBG(3, "%s: req %d xfer complete %d/%d status %d -> 0\n", __func__,
			    ep->num_req, len, ep->maxpacket, urbstat);
			if (usb_pipecontrol(urb->pipe)) {
				DBG(3, "%s: req %d %s Wait for ACK\n", __func__,
				    ep->num_req,
				    usb_pipein(urb->pipe) ? "IN" : "OUT");
				ep->nextpid = USB_PID_ACK;
			} else {
				if (len % ep->maxpacket ||
				    !(urb->transfer_flags & URB_ZERO_PACKET)) {
					urbstat = 0;
					DBG(3, "%s: req %d URB %s status %d count %d/%d/%d\n",
					    __func__, ep->num_req, usb_pipein(urb->pipe) ? "IN" : "OUT",
					    urbstat, len, ep->maxpacket, urb->actual_length);
				}
			}
		}
		break;
	case USB_PID_IN:
		len = PTD_GET_COUNT(ptd);
		BUG_ON(len > ep->length);
		urb->actual_length += len;
		BUG_ON(urb->actual_length > urb->transfer_buffer_length);
		usb_settoggle(udev, ep->epnum, 0, PTD_GET_TOGGLE(ptd));
		/* if transfer completed or (allowed) data underrun */
		if ((urb->transfer_buffer_length == urb->actual_length) ||
		    len % ep->maxpacket) {
			DBG(3, "%s: req %d xfer complete %d/%d status %d -> 0\n", __func__,
			    ep->num_req, len, ep->maxpacket, urbstat);
			if (usb_pipecontrol(urb->pipe)) {
				DBG(3, "%s: req %d %s Wait for ACK\n", __func__,
				    ep->num_req,
				    usb_pipein(urb->pipe) ? "IN" : "OUT");
				ep->nextpid = USB_PID_ACK;
			} else {
				urbstat = 0;
				DBG(3, "%s: req %d URB %s status %d count %d/%d/%d\n",
				    __func__, ep->num_req, usb_pipein(urb->pipe) ? "IN" : "OUT",
				    urbstat, len, ep->maxpacket, urb->actual_length);
			}
		}
		break;
	case USB_PID_SETUP:
		if (urb->transfer_buffer_length == urb->actual_length) {
			ep->nextpid = USB_PID_ACK;
		} else if (usb_pipeout(urb->pipe)) {
			usb_settoggle(udev, 0, 1, 1);
			ep->nextpid = USB_PID_OUT;
		} else {
			usb_settoggle(udev, 0, 0, 1);
			ep->nextpid = USB_PID_IN;
		}
		break;
	case USB_PID_ACK:
		DBG(3, "%s: req %d got ACK %d -> 0\n", __func__, ep->num_req,
		    urbstat);
		WARN_ON(urbstat != -EINPROGRESS);
		urbstat = 0;
		ep->nextpid = 0;
		break;
	default:
		BUG_ON(1);
	}

 out:
	if (urbstat != -EINPROGRESS) {
		DBG(2, "%s: Finishing ep %p req %d urb %p status %d\n", __func__,
		    ep, ep->num_req, urb, urbstat);
		finish_request(isp1362_hcd, ep, urb, urbstat);
	}
}

static void finish_unlinks(struct isp1362_hcd *isp1362_hcd)
{
	struct isp1362_ep *ep;
	struct isp1362_ep *tmp;

	list_for_each_entry_safe(ep, tmp, &isp1362_hcd->remove_list, remove_list) {
		struct isp1362_ep_queue *epq =
			get_ptd_queue(isp1362_hcd, ep->ptd_offset);
		int index = ep->ptd_index;

		BUG_ON(epq == NULL);
		if (index >= 0) {
			DBG(1, "%s: remove PTD[%d] $%04x\n", __func__, index, ep->ptd_offset);
			BUG_ON(ep->num_ptds == 0);
			release_ptd_buffers(epq, ep);
		}
		if (!list_empty(&ep->hep->urb_list)) {
			struct urb *urb = get_urb(ep);

			DBG(1, "%s: Finishing req %d ep %p from remove_list\n", __func__,
			    ep->num_req, ep);
			finish_request(isp1362_hcd, ep, urb, -ESHUTDOWN);
		}
		WARN_ON(list_empty(&ep->active));
		if (!list_empty(&ep->active)) {
			list_del_init(&ep->active);
			DBG(1, "%s: ep %p removed from active list\n", __func__, ep);
		}
		list_del_init(&ep->remove_list);
		DBG(1, "%s: ep %p removed from remove_list\n", __func__, ep);
	}
	DBG(1, "%s: Done\n", __func__);
}

static inline void enable_atl_transfers(struct isp1362_hcd *isp1362_hcd, int count)
{
	if (count > 0) {
		if (count < isp1362_hcd->atl_queue.ptd_count)
			isp1362_write_reg16(isp1362_hcd, HCATLDTC, count);
		isp1362_enable_int(isp1362_hcd, HCuPINT_ATL);
		isp1362_write_reg32(isp1362_hcd, HCATLSKIP, isp1362_hcd->atl_queue.skip_map);
		isp1362_set_mask16(isp1362_hcd, HCBUFSTAT, HCBUFSTAT_ATL_ACTIVE);
	} else
		isp1362_enable_int(isp1362_hcd, HCuPINT_SOF);
}

static inline void enable_intl_transfers(struct isp1362_hcd *isp1362_hcd)
{
	isp1362_enable_int(isp1362_hcd, HCuPINT_INTL);
	isp1362_set_mask16(isp1362_hcd, HCBUFSTAT, HCBUFSTAT_INTL_ACTIVE);
	isp1362_write_reg32(isp1362_hcd, HCINTLSKIP, isp1362_hcd->intl_queue.skip_map);
}

static inline void enable_istl_transfers(struct isp1362_hcd *isp1362_hcd, int flip)
{
	isp1362_enable_int(isp1362_hcd, flip ? HCuPINT_ISTL1 : HCuPINT_ISTL0);
	isp1362_set_mask16(isp1362_hcd, HCBUFSTAT, flip ?
			   HCBUFSTAT_ISTL1_FULL : HCBUFSTAT_ISTL0_FULL);
}

static int submit_req(struct isp1362_hcd *isp1362_hcd, struct urb *urb,
		      struct isp1362_ep *ep, struct isp1362_ep_queue *epq)
{
	int index = epq->free_ptd;

	prepare_ptd(isp1362_hcd, urb, ep, epq, 0);
	index = claim_ptd_buffers(epq, ep, ep->length);
	if (index == -ENOMEM) {
		DBG(1, "%s: req %d No free %s PTD available: %d, %08lx:%08lx\n", __func__,
		    ep->num_req, epq->name, ep->num_ptds, epq->buf_map, epq->skip_map);
		return index;
	} else if (index == -EOVERFLOW) {
		DBG(1, "%s: req %d Not enough space for %d byte %s PTD %d %08lx:%08lx\n",
		    __func__, ep->num_req, ep->length, epq->name, ep->num_ptds,
		    epq->buf_map, epq->skip_map);
		return index;
	} else
		BUG_ON(index < 0);
	list_add_tail(&ep->active, &epq->active);
	DBG(1, "%s: ep %p req %d len %d added to active list %p\n", __func__,
	    ep, ep->num_req, ep->length, &epq->active);
	DBG(1, "%s: Submitting %s PTD $%04x for ep %p req %d\n", __func__, epq->name,
	    ep->ptd_offset, ep, ep->num_req);
	isp1362_write_ptd(isp1362_hcd, ep, epq);
	__clear_bit(ep->ptd_index, &epq->skip_map);

	return 0;
}

static void start_atl_transfers(struct isp1362_hcd *isp1362_hcd)
{
	int ptd_count = 0;
	struct isp1362_ep_queue *epq = &isp1362_hcd->atl_queue;
	struct isp1362_ep *ep;
	int defer = 0;

	if (atomic_read(&epq->finishing)) {
		DBG(1, "%s: finish_transfers is active for %s\n", __func__, epq->name);
		return;
	}

	list_for_each_entry(ep, &isp1362_hcd->async, schedule) {
		struct urb *urb = get_urb(ep);
		int ret;

		if (!list_empty(&ep->active)) {
			DBG(2, "%s: Skipping active %s ep %p\n", __func__, epq->name, ep);
			continue;
		}

		DBG(1, "%s: Processing %s ep %p req %d\n", __func__, epq->name,
		    ep, ep->num_req);

		ret = submit_req(isp1362_hcd, urb, ep, epq);
		if (ret == -ENOMEM) {
			defer = 1;
			break;
		} else if (ret == -EOVERFLOW) {
			defer = 1;
			continue;
		}
#ifdef BUGGY_PXA2XX_UDC_USBTEST
		defer = ep->nextpid == USB_PID_SETUP;
#endif
		ptd_count++;
	}

	/* Avoid starving of endpoints */
	if (isp1362_hcd->async.next != isp1362_hcd->async.prev) {
		DBG(2, "%s: Cycling ASYNC schedule %d\n", __func__, ptd_count);
		list_move(&isp1362_hcd->async, isp1362_hcd->async.next);
	}
	if (ptd_count || defer)
		enable_atl_transfers(isp1362_hcd, defer ? 0 : ptd_count);

	epq->ptd_count += ptd_count;
	if (epq->ptd_count > epq->stat_maxptds) {
		epq->stat_maxptds = epq->ptd_count;
		DBG(0, "%s: max_ptds: %d\n", __func__, epq->stat_maxptds);
	}
}

static void start_intl_transfers(struct isp1362_hcd *isp1362_hcd)
{
	int ptd_count = 0;
	struct isp1362_ep_queue *epq = &isp1362_hcd->intl_queue;
	struct isp1362_ep *ep;

	if (atomic_read(&epq->finishing)) {
		DBG(1, "%s: finish_transfers is active for %s\n", __func__, epq->name);
		return;
	}

	list_for_each_entry(ep, &isp1362_hcd->periodic, schedule) {
		struct urb *urb = get_urb(ep);
		int ret;

		if (!list_empty(&ep->active)) {
			DBG(1, "%s: Skipping active %s ep %p\n", __func__,
			    epq->name, ep);
			continue;
		}

		DBG(1, "%s: Processing %s ep %p req %d\n", __func__,
		    epq->name, ep, ep->num_req);
		ret = submit_req(isp1362_hcd, urb, ep, epq);
		if (ret == -ENOMEM)
			break;
		else if (ret == -EOVERFLOW)
			continue;
		ptd_count++;
	}

	if (ptd_count) {
		static int last_count;

		if (ptd_count != last_count) {
			DBG(0, "%s: ptd_count: %d\n", __func__, ptd_count);
			last_count = ptd_count;
		}
		enable_intl_transfers(isp1362_hcd);
	}

	epq->ptd_count += ptd_count;
	if (epq->ptd_count > epq->stat_maxptds)
		epq->stat_maxptds = epq->ptd_count;
}

static inline int next_ptd(struct isp1362_ep_queue *epq, struct isp1362_ep *ep)
{
	u16 ptd_offset = ep->ptd_offset;
	int num_ptds = (ep->length + PTD_HEADER_SIZE + (epq->blk_size - 1)) / epq->blk_size;

	DBG(2, "%s: PTD offset $%04x + %04x => %d * %04x -> $%04x\n", __func__, ptd_offset,
	    ep->length, num_ptds, epq->blk_size, ptd_offset + num_ptds * epq->blk_size);

	ptd_offset += num_ptds * epq->blk_size;
	if (ptd_offset < epq->buf_start + epq->buf_size)
		return ptd_offset;
	else
		return -ENOMEM;
}

static void start_iso_transfers(struct isp1362_hcd *isp1362_hcd)
{
	int ptd_count = 0;
	int flip = isp1362_hcd->istl_flip;
	struct isp1362_ep_queue *epq;
	int ptd_offset;
	struct isp1362_ep *ep;
	struct isp1362_ep *tmp;
	u16 fno = isp1362_read_reg32(isp1362_hcd, HCFMNUM);

 fill2:
	epq = &isp1362_hcd->istl_queue[flip];
	if (atomic_read(&epq->finishing)) {
		DBG(1, "%s: finish_transfers is active for %s\n", __func__, epq->name);
		return;
	}

	if (!list_empty(&epq->active))
		return;

	ptd_offset = epq->buf_start;
	list_for_each_entry_safe(ep, tmp, &isp1362_hcd->isoc, schedule) {
		struct urb *urb = get_urb(ep);
		s16 diff = fno - (u16)urb->start_frame;

		DBG(1, "%s: Processing %s ep %p\n", __func__, epq->name, ep);

		if (diff > urb->number_of_packets) {
			/* time frame for this URB has elapsed */
			finish_request(isp1362_hcd, ep, urb, -EOVERFLOW);
			continue;
		} else if (diff < -1) {
			/* URB is not due in this frame or the next one.
			 * Comparing with '-1' instead of '0' accounts for double
			 * buffering in the ISP1362 which enables us to queue the PTD
			 * one frame ahead of time
			 */
		} else if (diff == -1) {
			/* submit PTD's that are due in the next frame */
			prepare_ptd(isp1362_hcd, urb, ep, epq, fno);
			if (ptd_offset + PTD_HEADER_SIZE + ep->length >
			    epq->buf_start + epq->buf_size) {
				pr_err("%s: Not enough ISO buffer space for %d byte PTD\n",
				    __func__, ep->length);
				continue;
			}
			ep->ptd_offset = ptd_offset;
			list_add_tail(&ep->active, &epq->active);

			ptd_offset = next_ptd(epq, ep);
			if (ptd_offset < 0) {
				pr_warning("%s: req %d No more %s PTD buffers available\n", __func__,
				     ep->num_req, epq->name);
				break;
			}
		}
	}
	list_for_each_entry(ep, &epq->active, active) {
		if (epq->active.next == &ep->active)
			ep->ptd.mps |= PTD_LAST_MSK;
		isp1362_write_ptd(isp1362_hcd, ep, epq);
		ptd_count++;
	}

	if (ptd_count)
		enable_istl_transfers(isp1362_hcd, flip);

	epq->ptd_count += ptd_count;
	if (epq->ptd_count > epq->stat_maxptds)
		epq->stat_maxptds = epq->ptd_count;

	/* check, whether the second ISTL buffer may also be filled */
	if (!(isp1362_read_reg16(isp1362_hcd, HCBUFSTAT) &
	      (flip ? HCBUFSTAT_ISTL0_FULL : HCBUFSTAT_ISTL1_FULL))) {
		fno++;
		ptd_count = 0;
		flip = 1 - flip;
		goto fill2;
	}
}

static void finish_transfers(struct isp1362_hcd *isp1362_hcd, unsigned long done_map,
			     struct isp1362_ep_queue *epq)
{
	struct isp1362_ep *ep;
	struct isp1362_ep *tmp;

	if (list_empty(&epq->active)) {
		DBG(1, "%s: Nothing to do for %s queue\n", __func__, epq->name);
		return;
	}

	DBG(1, "%s: Finishing %s transfers %08lx\n", __func__, epq->name, done_map);

	atomic_inc(&epq->finishing);
	list_for_each_entry_safe(ep, tmp, &epq->active, active) {
		int index = ep->ptd_index;

		DBG(1, "%s: Checking %s PTD[%02x] $%04x\n", __func__, epq->name,
		    index, ep->ptd_offset);

		BUG_ON(index < 0);
		if (__test_and_clear_bit(index, &done_map)) {
			isp1362_read_ptd(isp1362_hcd, ep, epq);
			epq->free_ptd = index;
			BUG_ON(ep->num_ptds == 0);
			release_ptd_buffers(epq, ep);

			DBG(1, "%s: ep %p req %d removed from active list\n", __func__,
			    ep, ep->num_req);
			if (!list_empty(&ep->remove_list)) {
				list_del_init(&ep->remove_list);
				DBG(1, "%s: ep %p removed from remove list\n", __func__, ep);
			}
			DBG(1, "%s: Postprocessing %s ep %p req %d\n", __func__, epq->name,
			    ep, ep->num_req);
			postproc_ep(isp1362_hcd, ep);
		}
		if (!done_map)
			break;
	}
	if (done_map)
		pr_warning("%s: done_map not clear: %08lx:%08lx\n", __func__, done_map,
		     epq->skip_map);
	atomic_dec(&epq->finishing);
}

static void finish_iso_transfers(struct isp1362_hcd *isp1362_hcd, struct isp1362_ep_queue *epq)
{
	struct isp1362_ep *ep;
	struct isp1362_ep *tmp;

	if (list_empty(&epq->active)) {
		DBG(1, "%s: Nothing to do for %s queue\n", __func__, epq->name);
		return;
	}

	DBG(1, "%s: Finishing %s transfers\n", __func__, epq->name);

	atomic_inc(&epq->finishing);
	list_for_each_entry_safe(ep, tmp, &epq->active, active) {
		DBG(1, "%s: Checking PTD $%04x\n", __func__, ep->ptd_offset);

		isp1362_read_ptd(isp1362_hcd, ep, epq);
		DBG(1, "%s: Postprocessing %s ep %p\n", __func__, epq->name, ep);
		postproc_ep(isp1362_hcd, ep);
	}
	WARN_ON(epq->blk_size != 0);
	atomic_dec(&epq->finishing);
}

static irqreturn_t isp1362_irq(struct usb_hcd *hcd)
{
	int handled = 0;
	struct isp1362_hcd *isp1362_hcd = hcd_to_isp1362_hcd(hcd);
	u16 irqstat;
	u16 svc_mask;

	spin_lock(&isp1362_hcd->lock);

	BUG_ON(isp1362_hcd->irq_active++);

	isp1362_write_reg16(isp1362_hcd, HCuPINTENB, 0);

	irqstat = isp1362_read_reg16(isp1362_hcd, HCuPINT);
	DBG(3, "%s: got IRQ %04x:%04x\n", __func__, irqstat, isp1362_hcd->irqenb);

	/* only handle interrupts that are currently enabled */
	irqstat &= isp1362_hcd->irqenb;
	isp1362_write_reg16(isp1362_hcd, HCuPINT, irqstat);
	svc_mask = irqstat;

	if (irqstat & HCuPINT_SOF) {
		isp1362_hcd->irqenb &= ~HCuPINT_SOF;
		isp1362_hcd->irq_stat[ISP1362_INT_SOF]++;
		handled = 1;
		svc_mask &= ~HCuPINT_SOF;
		DBG(3, "%s: SOF\n", __func__);
		isp1362_hcd->fmindex = isp1362_read_reg32(isp1362_hcd, HCFMNUM);
		if (!list_empty(&isp1362_hcd->remove_list))
			finish_unlinks(isp1362_hcd);
		if (!list_empty(&isp1362_hcd->async) && !(irqstat & HCuPINT_ATL)) {
			if (list_empty(&isp1362_hcd->atl_queue.active)) {
				start_atl_transfers(isp1362_hcd);
			} else {
				isp1362_enable_int(isp1362_hcd, HCuPINT_ATL);
				isp1362_write_reg32(isp1362_hcd, HCATLSKIP,
						    isp1362_hcd->atl_queue.skip_map);
				isp1362_set_mask16(isp1362_hcd, HCBUFSTAT, HCBUFSTAT_ATL_ACTIVE);
			}
		}
	}

	if (irqstat & HCuPINT_ISTL0) {
		isp1362_hcd->irq_stat[ISP1362_INT_ISTL0]++;
		handled = 1;
		svc_mask &= ~HCuPINT_ISTL0;
		isp1362_clr_mask16(isp1362_hcd, HCBUFSTAT, HCBUFSTAT_ISTL0_FULL);
		DBG(1, "%s: ISTL0\n", __func__);
		WARN_ON((int)!!isp1362_hcd->istl_flip);
		WARN_ON(isp1362_read_reg16(isp1362_hcd, HCBUFSTAT) &
			HCBUFSTAT_ISTL0_ACTIVE);
		WARN_ON(!(isp1362_read_reg16(isp1362_hcd, HCBUFSTAT) &
			HCBUFSTAT_ISTL0_DONE));
		isp1362_hcd->irqenb &= ~HCuPINT_ISTL0;
	}

	if (irqstat & HCuPINT_ISTL1) {
		isp1362_hcd->irq_stat[ISP1362_INT_ISTL1]++;
		handled = 1;
		svc_mask &= ~HCuPINT_ISTL1;
		isp1362_clr_mask16(isp1362_hcd, HCBUFSTAT, HCBUFSTAT_ISTL1_FULL);
		DBG(1, "%s: ISTL1\n", __func__);
		WARN_ON(!(int)isp1362_hcd->istl_flip);
		WARN_ON(isp1362_read_reg16(isp1362_hcd, HCBUFSTAT) &
			HCBUFSTAT_ISTL1_ACTIVE);
		WARN_ON(!(isp1362_read_reg16(isp1362_hcd, HCBUFSTAT) &
			HCBUFSTAT_ISTL1_DONE));
		isp1362_hcd->irqenb &= ~HCuPINT_ISTL1;
	}

	if (irqstat & (HCuPINT_ISTL0 | HCuPINT_ISTL1)) {
		WARN_ON((irqstat & (HCuPINT_ISTL0 | HCuPINT_ISTL1)) ==
			(HCuPINT_ISTL0 | HCuPINT_ISTL1));
		finish_iso_transfers(isp1362_hcd,
				     &isp1362_hcd->istl_queue[isp1362_hcd->istl_flip]);
		start_iso_transfers(isp1362_hcd);
		isp1362_hcd->istl_flip = 1 - isp1362_hcd->istl_flip;
	}

	if (irqstat & HCuPINT_INTL) {
		u32 done_map = isp1362_read_reg32(isp1362_hcd, HCINTLDONE);
		u32 skip_map = isp1362_read_reg32(isp1362_hcd, HCINTLSKIP);
		isp1362_hcd->irq_stat[ISP1362_INT_INTL]++;

		DBG(2, "%s: INTL\n", __func__);

		svc_mask &= ~HCuPINT_INTL;

		isp1362_write_reg32(isp1362_hcd, HCINTLSKIP, skip_map | done_map);
		if (~(done_map | skip_map) == 0)
			/* All PTDs are finished, disable INTL processing entirely */
			isp1362_clr_mask16(isp1362_hcd, HCBUFSTAT, HCBUFSTAT_INTL_ACTIVE);

		handled = 1;
		WARN_ON(!done_map);
		if (done_map) {
			DBG(3, "%s: INTL done_map %08x\n", __func__, done_map);
			finish_transfers(isp1362_hcd, done_map, &isp1362_hcd->intl_queue);
			start_intl_transfers(isp1362_hcd);
		}
	}

	if (irqstat & HCuPINT_ATL) {
		u32 done_map = isp1362_read_reg32(isp1362_hcd, HCATLDONE);
		u32 skip_map = isp1362_read_reg32(isp1362_hcd, HCATLSKIP);
		isp1362_hcd->irq_stat[ISP1362_INT_ATL]++;

		DBG(2, "%s: ATL\n", __func__);

		svc_mask &= ~HCuPINT_ATL;

		isp1362_write_reg32(isp1362_hcd, HCATLSKIP, skip_map | done_map);
		if (~(done_map | skip_map) == 0)
			isp1362_clr_mask16(isp1362_hcd, HCBUFSTAT, HCBUFSTAT_ATL_ACTIVE);
		if (done_map) {
			DBG(3, "%s: ATL done_map %08x\n", __func__, done_map);
			finish_transfers(isp1362_hcd, done_map, &isp1362_hcd->atl_queue);
			start_atl_transfers(isp1362_hcd);
		}
		handled = 1;
	}

	if (irqstat & HCuPINT_OPR) {
		u32 intstat = isp1362_read_reg32(isp1362_hcd, HCINTSTAT);
		isp1362_hcd->irq_stat[ISP1362_INT_OPR]++;

		svc_mask &= ~HCuPINT_OPR;
		DBG(2, "%s: OPR %08x:%08x\n", __func__, intstat, isp1362_hcd->intenb);
		intstat &= isp1362_hcd->intenb;
		if (intstat & OHCI_INTR_UE) {
			pr_err("Unrecoverable error\n");
			/* FIXME: do here reset or cleanup or whatever */
		}
		if (intstat & OHCI_INTR_RHSC) {
			isp1362_hcd->rhstatus = isp1362_read_reg32(isp1362_hcd, HCRHSTATUS);
			isp1362_hcd->rhport[0] = isp1362_read_reg32(isp1362_hcd, HCRHPORT1);
			isp1362_hcd->rhport[1] = isp1362_read_reg32(isp1362_hcd, HCRHPORT2);
		}
		if (intstat & OHCI_INTR_RD) {
			pr_info("%s: RESUME DETECTED\n", __func__);
			isp1362_show_reg(isp1362_hcd, HCCONTROL);
			usb_hcd_resume_root_hub(hcd);
		}
		isp1362_write_reg32(isp1362_hcd, HCINTSTAT, intstat);
		irqstat &= ~HCuPINT_OPR;
		handled = 1;
	}

	if (irqstat & HCuPINT_SUSP) {
		isp1362_hcd->irq_stat[ISP1362_INT_SUSP]++;
		handled = 1;
		svc_mask &= ~HCuPINT_SUSP;

		pr_info("%s: SUSPEND IRQ\n", __func__);
	}

	if (irqstat & HCuPINT_CLKRDY) {
		isp1362_hcd->irq_stat[ISP1362_INT_CLKRDY]++;
		handled = 1;
		isp1362_hcd->irqenb &= ~HCuPINT_CLKRDY;
		svc_mask &= ~HCuPINT_CLKRDY;
		pr_info("%s: CLKRDY IRQ\n", __func__);
	}

	if (svc_mask)
		pr_err("%s: Unserviced interrupt(s) %04x\n", __func__, svc_mask);

	isp1362_write_reg16(isp1362_hcd, HCuPINTENB, isp1362_hcd->irqenb);
	isp1362_hcd->irq_active--;
	spin_unlock(&isp1362_hcd->lock);

	return IRQ_RETVAL(handled);
}

/*-------------------------------------------------------------------------*/

#define	MAX_PERIODIC_LOAD	900	/* out of 1000 usec */
static int balance(struct isp1362_hcd *isp1362_hcd, u16 interval, u16 load)
{
	int i, branch = -ENOSPC;

	/* search for the least loaded schedule branch of that interval
	 * which has enough bandwidth left unreserved.
	 */
	for (i = 0; i < interval; i++) {
		if (branch < 0 || isp1362_hcd->load[branch] > isp1362_hcd->load[i]) {
			int j;

			for (j = i; j < PERIODIC_SIZE; j += interval) {
				if ((isp1362_hcd->load[j] + load) > MAX_PERIODIC_LOAD) {
					pr_err("%s: new load %d load[%02x] %d max %d\n", __func__,
					    load, j, isp1362_hcd->load[j], MAX_PERIODIC_LOAD);
					break;
				}
			}
			if (j < PERIODIC_SIZE)
				continue;
			branch = i;
		}
	}
	return branch;
}

/* NB! ALL the code above this point runs with isp1362_hcd->lock
   held, irqs off
*/

/*-------------------------------------------------------------------------*/

static int isp1362_urb_enqueue(struct usb_hcd *hcd,
			       struct urb *urb,
			       gfp_t mem_flags)
{
	struct isp1362_hcd *isp1362_hcd = hcd_to_isp1362_hcd(hcd);
	struct usb_device *udev = urb->dev;
	unsigned int pipe = urb->pipe;
	int is_out = !usb_pipein(pipe);
	int type = usb_pipetype(pipe);
	int epnum = usb_pipeendpoint(pipe);
	struct usb_host_endpoint *hep = urb->ep;
	struct isp1362_ep *ep = NULL;
	unsigned long flags;
	int retval = 0;

	DBG(3, "%s: urb %p\n", __func__, urb);

	if (type == PIPE_ISOCHRONOUS) {
		pr_err("Isochronous transfers not supported\n");
		return -ENOSPC;
	}

	URB_DBG("%s: FA %d ep%d%s %s: len %d %s%s\n", __func__,
		usb_pipedevice(pipe), epnum,
		is_out ? "out" : "in",
		usb_pipecontrol(pipe) ? "ctrl" :
			usb_pipeint(pipe) ? "int" :
			usb_pipebulk(pipe) ? "bulk" :
			"iso",
		urb->transfer_buffer_length,
		(urb->transfer_flags & URB_ZERO_PACKET) ? "ZERO_PACKET " : "",
		!(urb->transfer_flags & URB_SHORT_NOT_OK) ?
		"short_ok" : "");

	/* avoid all allocations within spinlocks: request or endpoint */
	if (!hep->hcpriv) {
		ep = kzalloc(sizeof *ep, mem_flags);
		if (!ep)
			return -ENOMEM;
	}
	spin_lock_irqsave(&isp1362_hcd->lock, flags);

	/* don't submit to a dead or disabled port */
	if (!((isp1362_hcd->rhport[0] | isp1362_hcd->rhport[1]) &
	      USB_PORT_STAT_ENABLE) ||
	    !HC_IS_RUNNING(hcd->state)) {
		kfree(ep);
		retval = -ENODEV;
		goto fail_not_linked;
	}

	retval = usb_hcd_link_urb_to_ep(hcd, urb);
	if (retval) {
		kfree(ep);
		goto fail_not_linked;
	}

	if (hep->hcpriv) {
		ep = hep->hcpriv;
	} else {
		INIT_LIST_HEAD(&ep->schedule);
		INIT_LIST_HEAD(&ep->active);
		INIT_LIST_HEAD(&ep->remove_list);
		ep->udev = usb_get_dev(udev);
		ep->hep = hep;
		ep->epnum = epnum;
		ep->maxpacket = usb_maxpacket(udev, urb->pipe, is_out);
		ep->ptd_offset = -EINVAL;
		ep->ptd_index = -EINVAL;
		usb_settoggle(udev, epnum, is_out, 0);

		if (type == PIPE_CONTROL)
			ep->nextpid = USB_PID_SETUP;
		else if (is_out)
			ep->nextpid = USB_PID_OUT;
		else
			ep->nextpid = USB_PID_IN;

		switch (type) {
		case PIPE_ISOCHRONOUS:
		case PIPE_INTERRUPT:
			if (urb->interval > PERIODIC_SIZE)
				urb->interval = PERIODIC_SIZE;
			ep->interval = urb->interval;
			ep->branch = PERIODIC_SIZE;
			ep->load = usb_calc_bus_time(udev->speed, !is_out,
						     (type == PIPE_ISOCHRONOUS),
						     usb_maxpacket(udev, pipe, is_out)) / 1000;
			break;
		}
		hep->hcpriv = ep;
	}
	ep->num_req = isp1362_hcd->req_serial++;

	/* maybe put endpoint into schedule */
	switch (type) {
	case PIPE_CONTROL:
	case PIPE_BULK:
		if (list_empty(&ep->schedule)) {
			DBG(1, "%s: Adding ep %p req %d to async schedule\n",
				__func__, ep, ep->num_req);
			list_add_tail(&ep->schedule, &isp1362_hcd->async);
		}
		break;
	case PIPE_ISOCHRONOUS:
	case PIPE_INTERRUPT:
		urb->interval = ep->interval;

		/* urb submitted for already existing EP */
		if (ep->branch < PERIODIC_SIZE)
			break;

		retval = balance(isp1362_hcd, ep->interval, ep->load);
		if (retval < 0) {
			pr_err("%s: balance returned %d\n", __func__, retval);
			goto fail;
		}
		ep->branch = retval;
		retval = 0;
		isp1362_hcd->fmindex = isp1362_read_reg32(isp1362_hcd, HCFMNUM);
		DBG(1, "%s: Current frame %04x branch %02x start_frame %04x(%04x)\n",
		    __func__, isp1362_hcd->fmindex, ep->branch,
		    ((isp1362_hcd->fmindex + PERIODIC_SIZE - 1) &
		     ~(PERIODIC_SIZE - 1)) + ep->branch,
		    (isp1362_hcd->fmindex & (PERIODIC_SIZE - 1)) + ep->branch);

		if (list_empty(&ep->schedule)) {
			if (type == PIPE_ISOCHRONOUS) {
				u16 frame = isp1362_hcd->fmindex;

				frame += max_t(u16, 8, ep->interval);
				frame &= ~(ep->interval - 1);
				frame |= ep->branch;
				if (frame_before(frame, isp1362_hcd->fmindex))
					frame += ep->interval;
				urb->start_frame = frame;

				DBG(1, "%s: Adding ep %p to isoc schedule\n", __func__, ep);
				list_add_tail(&ep->schedule, &isp1362_hcd->isoc);
			} else {
				DBG(1, "%s: Adding ep %p to periodic schedule\n", __func__, ep);
				list_add_tail(&ep->schedule, &isp1362_hcd->periodic);
			}
		} else
			DBG(1, "%s: ep %p already scheduled\n", __func__, ep);

		DBG(2, "%s: load %d bandwidth %d -> %d\n", __func__,
		    ep->load / ep->interval, isp1362_hcd->load[ep->branch],
		    isp1362_hcd->load[ep->branch] + ep->load);
		isp1362_hcd->load[ep->branch] += ep->load;
	}

	urb->hcpriv = hep;
	ALIGNSTAT(isp1362_hcd, urb->transfer_buffer);

	switch (type) {
	case PIPE_CONTROL:
	case PIPE_BULK:
		start_atl_transfers(isp1362_hcd);
		break;
	case PIPE_INTERRUPT:
		start_intl_transfers(isp1362_hcd);
		break;
	case PIPE_ISOCHRONOUS:
		start_iso_transfers(isp1362_hcd);
		break;
	default:
		BUG();
	}
 fail:
	if (retval)
		usb_hcd_unlink_urb_from_ep(hcd, urb);


 fail_not_linked:
	spin_unlock_irqrestore(&isp1362_hcd->lock, flags);
	if (retval)
		DBG(0, "%s: urb %p failed with %d\n", __func__, urb, retval);
	return retval;
}

static int isp1362_urb_dequeue(struct usb_hcd *hcd, struct urb *urb, int status)
{
	struct isp1362_hcd *isp1362_hcd = hcd_to_isp1362_hcd(hcd);
	struct usb_host_endpoint *hep;
	unsigned long flags;
	struct isp1362_ep *ep;
	int retval = 0;

	DBG(3, "%s: urb %p\n", __func__, urb);

	spin_lock_irqsave(&isp1362_hcd->lock, flags);
	retval = usb_hcd_check_unlink_urb(hcd, urb, status);
	if (retval)
		goto done;

	hep = urb->hcpriv;

	if (!hep) {
		spin_unlock_irqrestore(&isp1362_hcd->lock, flags);
		return -EIDRM;
	}

	ep = hep->hcpriv;
	if (ep) {
		/* In front of queue? */
		if (ep->hep->urb_list.next == &urb->urb_list) {
			if (!list_empty(&ep->active)) {
				DBG(1, "%s: urb %p ep %p req %d active PTD[%d] $%04x\n", __func__,
				    urb, ep, ep->num_req, ep->ptd_index, ep->ptd_offset);
				/* disable processing and queue PTD for removal */
				remove_ptd(isp1362_hcd, ep);
				urb = NULL;
			}
		}
		if (urb) {
			DBG(1, "%s: Finishing ep %p req %d\n", __func__, ep,
			    ep->num_req);
			finish_request(isp1362_hcd, ep, urb, status);
		} else
			DBG(1, "%s: urb %p active; wait4irq\n", __func__, urb);
	} else {
		pr_warning("%s: No EP in URB %p\n", __func__, urb);
		retval = -EINVAL;
	}
done:
	spin_unlock_irqrestore(&isp1362_hcd->lock, flags);

	DBG(3, "%s: exit\n", __func__);

	return retval;
}

static void isp1362_endpoint_disable(struct usb_hcd *hcd, struct usb_host_endpoint *hep)
{
	struct isp1362_ep *ep = hep->hcpriv;
	struct isp1362_hcd *isp1362_hcd = hcd_to_isp1362_hcd(hcd);
	unsigned long flags;

	DBG(1, "%s: ep %p\n", __func__, ep);
	if (!ep)
		return;
	spin_lock_irqsave(&isp1362_hcd->lock, flags);
	if (!list_empty(&hep->urb_list)) {
		if (!list_empty(&ep->active) && list_empty(&ep->remove_list)) {
			DBG(1, "%s: Removing ep %p req %d PTD[%d] $%04x\n", __func__,
			    ep, ep->num_req, ep->ptd_index, ep->ptd_offset);
			remove_ptd(isp1362_hcd, ep);
			pr_info("%s: Waiting for Interrupt to clean up\n", __func__);
		}
	}
	spin_unlock_irqrestore(&isp1362_hcd->lock, flags);
	/* Wait for interrupt to clear out active list */
	while (!list_empty(&ep->active))
		msleep(1);

	DBG(1, "%s: Freeing EP %p\n", __func__, ep);

	usb_put_dev(ep->udev);
	kfree(ep);
	hep->hcpriv = NULL;
}

static int isp1362_get_frame(struct usb_hcd *hcd)
{
	struct isp1362_hcd *isp1362_hcd = hcd_to_isp1362_hcd(hcd);
	u32 fmnum;
	unsigned long flags;

	spin_lock_irqsave(&isp1362_hcd->lock, flags);
	fmnum = isp1362_read_reg32(isp1362_hcd, HCFMNUM);
	spin_unlock_irqrestore(&isp1362_hcd->lock, flags);

	return (int)fmnum;
}

/*-------------------------------------------------------------------------*/

/* Adapted from ohci-hub.c */
static int isp1362_hub_status_data(struct usb_hcd *hcd, char *buf)
{
	struct isp1362_hcd *isp1362_hcd = hcd_to_isp1362_hcd(hcd);
	int ports, i, changed = 0;
	unsigned long flags;

	if (!HC_IS_RUNNING(hcd->state))
		return -ESHUTDOWN;

	/* Report no status change now, if we are scheduled to be
	   called later */
	if (timer_pending(&hcd->rh_timer))
		return 0;

	ports = isp1362_hcd->rhdesca & RH_A_NDP;
	BUG_ON(ports > 2);

	spin_lock_irqsave(&isp1362_hcd->lock, flags);
	/* init status */
	if (isp1362_hcd->rhstatus & (RH_HS_LPSC | RH_HS_OCIC))
		buf[0] = changed = 1;
	else
		buf[0] = 0;

	for (i = 0; i < ports; i++) {
		u32 status = isp1362_hcd->rhport[i];

		if (status & (RH_PS_CSC | RH_PS_PESC | RH_PS_PSSC |
			      RH_PS_OCIC | RH_PS_PRSC)) {
			changed = 1;
			buf[0] |= 1 << (i + 1);
			continue;
		}

		if (!(status & RH_PS_CCS))
			continue;
	}
	spin_unlock_irqrestore(&isp1362_hcd->lock, flags);
	return changed;
}

static void isp1362_hub_descriptor(struct isp1362_hcd *isp1362_hcd,
				   struct usb_hub_descriptor *desc)
{
	u32 reg = isp1362_hcd->rhdesca;

	DBG(3, "%s: enter\n", __func__);

	desc->bDescriptorType = 0x29;
	desc->bDescLength = 9;
	desc->bHubContrCurrent = 0;
	desc->bNbrPorts = reg & 0x3;
	/* Power switching, device type, overcurrent. */
	desc->wHubCharacteristics = cpu_to_le16((reg >> 8) & 0x1f);
	DBG(0, "%s: hubcharacteristics = %02x\n", __func__, cpu_to_le16((reg >> 8) & 0x1f));
	desc->bPwrOn2PwrGood = (reg >> 24) & 0xff;
	/* two bitmaps:  ports removable, and legacy PortPwrCtrlMask */
	desc->bitmap[0] = desc->bNbrPorts == 1 ? 1 << 1 : 3 << 1;
	desc->bitmap[1] = ~0;

	DBG(3, "%s: exit\n", __func__);
}

/* Adapted from ohci-hub.c */
static int isp1362_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
			       u16 wIndex, char *buf, u16 wLength)
{
	struct isp1362_hcd *isp1362_hcd = hcd_to_isp1362_hcd(hcd);
	int retval = 0;
	unsigned long flags;
	unsigned long t1;
	int ports = isp1362_hcd->rhdesca & RH_A_NDP;
	u32 tmp = 0;

	switch (typeReq) {
	case ClearHubFeature:
		DBG(0, "ClearHubFeature: ");
		switch (wValue) {
		case C_HUB_OVER_CURRENT:
			_DBG(0, "C_HUB_OVER_CURRENT\n");
			spin_lock_irqsave(&isp1362_hcd->lock, flags);
			isp1362_write_reg32(isp1362_hcd, HCRHSTATUS, RH_HS_OCIC);
			spin_unlock_irqrestore(&isp1362_hcd->lock, flags);
		case C_HUB_LOCAL_POWER:
			_DBG(0, "C_HUB_LOCAL_POWER\n");
			break;
		default:
			goto error;
		}
		break;
	case SetHubFeature:
		DBG(0, "SetHubFeature: ");
		switch (wValue) {
		case C_HUB_OVER_CURRENT:
		case C_HUB_LOCAL_POWER:
			_DBG(0, "C_HUB_OVER_CURRENT or C_HUB_LOCAL_POWER\n");
			break;
		default:
			goto error;
		}
		break;
	case GetHubDescriptor:
		DBG(0, "GetHubDescriptor\n");
		isp1362_hub_descriptor(isp1362_hcd, (struct usb_hub_descriptor *)buf);
		break;
	case GetHubStatus:
		DBG(0, "GetHubStatus\n");
		put_unaligned(cpu_to_le32(0), (__le32 *) buf);
		break;
	case GetPortStatus:
#ifndef VERBOSE
		DBG(0, "GetPortStatus\n");
#endif
		if (!wIndex || wIndex > ports)
			goto error;
		tmp = isp1362_hcd->rhport[--wIndex];
		put_unaligned(cpu_to_le32(tmp), (__le32 *) buf);
		break;
	case ClearPortFeature:
		DBG(0, "ClearPortFeature: ");
		if (!wIndex || wIndex > ports)
			goto error;
		wIndex--;

		switch (wValue) {
		case USB_PORT_FEAT_ENABLE:
			_DBG(0, "USB_PORT_FEAT_ENABLE\n");
			tmp = RH_PS_CCS;
			break;
		case USB_PORT_FEAT_C_ENABLE:
			_DBG(0, "USB_PORT_FEAT_C_ENABLE\n");
			tmp = RH_PS_PESC;
			break;
		case USB_PORT_FEAT_SUSPEND:
			_DBG(0, "USB_PORT_FEAT_SUSPEND\n");
			tmp = RH_PS_POCI;
			break;
		case USB_PORT_FEAT_C_SUSPEND:
			_DBG(0, "USB_PORT_FEAT_C_SUSPEND\n");
			tmp = RH_PS_PSSC;
			break;
		case USB_PORT_FEAT_POWER:
			_DBG(0, "USB_PORT_FEAT_POWER\n");
			tmp = RH_PS_LSDA;

			break;
		case USB_PORT_FEAT_C_CONNECTION:
			_DBG(0, "USB_PORT_FEAT_C_CONNECTION\n");
			tmp = RH_PS_CSC;
			break;
		case USB_PORT_FEAT_C_OVER_CURRENT:
			_DBG(0, "USB_PORT_FEAT_C_OVER_CURRENT\n");
			tmp = RH_PS_OCIC;
			break;
		case USB_PORT_FEAT_C_RESET:
			_DBG(0, "USB_PORT_FEAT_C_RESET\n");
			tmp = RH_PS_PRSC;
			break;
		default:
			goto error;
		}

		spin_lock_irqsave(&isp1362_hcd->lock, flags);
		isp1362_write_reg32(isp1362_hcd, HCRHPORT1 + wIndex, tmp);
		isp1362_hcd->rhport[wIndex] =
			isp1362_read_reg32(isp1362_hcd, HCRHPORT1 + wIndex);
		spin_unlock_irqrestore(&isp1362_hcd->lock, flags);
		break;
	case SetPortFeature:
		DBG(0, "SetPortFeature: ");
		if (!wIndex || wIndex > ports)
			goto error;
		wIndex--;
		switch (wValue) {
		case USB_PORT_FEAT_SUSPEND:
			_DBG(0, "USB_PORT_FEAT_SUSPEND\n");
			spin_lock_irqsave(&isp1362_hcd->lock, flags);
			isp1362_write_reg32(isp1362_hcd, HCRHPORT1 + wIndex, RH_PS_PSS);
			isp1362_hcd->rhport[wIndex] =
				isp1362_read_reg32(isp1362_hcd, HCRHPORT1 + wIndex);
			spin_unlock_irqrestore(&isp1362_hcd->lock, flags);
			break;
		case USB_PORT_FEAT_POWER:
			_DBG(0, "USB_PORT_FEAT_POWER\n");
			spin_lock_irqsave(&isp1362_hcd->lock, flags);
			isp1362_write_reg32(isp1362_hcd, HCRHPORT1 + wIndex, RH_PS_PPS);
			isp1362_hcd->rhport[wIndex] =
				isp1362_read_reg32(isp1362_hcd, HCRHPORT1 + wIndex);
			spin_unlock_irqrestore(&isp1362_hcd->lock, flags);
			break;
		case USB_PORT_FEAT_RESET:
			_DBG(0, "USB_PORT_FEAT_RESET\n");
			spin_lock_irqsave(&isp1362_hcd->lock, flags);

			t1 = jiffies + msecs_to_jiffies(USB_RESET_WIDTH);
			while (time_before(jiffies, t1)) {
				/* spin until any current reset finishes */
				for (;;) {
					tmp = isp1362_read_reg32(isp1362_hcd, HCRHPORT1 + wIndex);
					if (!(tmp & RH_PS_PRS))
						break;
					udelay(500);
				}
				if (!(tmp & RH_PS_CCS))
					break;
				/* Reset lasts 10ms (claims datasheet) */
				isp1362_write_reg32(isp1362_hcd, HCRHPORT1 + wIndex, (RH_PS_PRS));

				spin_unlock_irqrestore(&isp1362_hcd->lock, flags);
				msleep(10);
				spin_lock_irqsave(&isp1362_hcd->lock, flags);
			}

			isp1362_hcd->rhport[wIndex] = isp1362_read_reg32(isp1362_hcd,
									 HCRHPORT1 + wIndex);
			spin_unlock_irqrestore(&isp1362_hcd->lock, flags);
			break;
		default:
			goto error;
		}
		break;

	default:
 error:
		/* "protocol stall" on error */
		_DBG(0, "PROTOCOL STALL\n");
		retval = -EPIPE;
	}

	return retval;
}

#ifdef	CONFIG_PM
static int isp1362_bus_suspend(struct usb_hcd *hcd)
{
	int status = 0;
	struct isp1362_hcd *isp1362_hcd = hcd_to_isp1362_hcd(hcd);
	unsigned long flags;

	if (time_before(jiffies, isp1362_hcd->next_statechange))
		msleep(5);

	spin_lock_irqsave(&isp1362_hcd->lock, flags);

	isp1362_hcd->hc_control = isp1362_read_reg32(isp1362_hcd, HCCONTROL);
	switch (isp1362_hcd->hc_control & OHCI_CTRL_HCFS) {
	case OHCI_USB_RESUME:
		DBG(0, "%s: resume/suspend?\n", __func__);
		isp1362_hcd->hc_control &= ~OHCI_CTRL_HCFS;
		isp1362_hcd->hc_control |= OHCI_USB_RESET;
		isp1362_write_reg32(isp1362_hcd, HCCONTROL, isp1362_hcd->hc_control);
		/* FALL THROUGH */
	case OHCI_USB_RESET:
		status = -EBUSY;
		pr_warning("%s: needs reinit!\n", __func__);
		goto done;
	case OHCI_USB_SUSPEND:
		pr_warning("%s: already suspended?\n", __func__);
		goto done;
	}
	DBG(0, "%s: suspend root hub\n", __func__);

	/* First stop any processing */
	hcd->state = HC_STATE_QUIESCING;
	if (!list_empty(&isp1362_hcd->atl_queue.active) ||
	    !list_empty(&isp1362_hcd->intl_queue.active) ||
	    !list_empty(&isp1362_hcd->istl_queue[0] .active) ||
	    !list_empty(&isp1362_hcd->istl_queue[1] .active)) {
		int limit;

		isp1362_write_reg32(isp1362_hcd, HCATLSKIP, ~0);
		isp1362_write_reg32(isp1362_hcd, HCINTLSKIP, ~0);
		isp1362_write_reg16(isp1362_hcd, HCBUFSTAT, 0);
		isp1362_write_reg16(isp1362_hcd, HCuPINTENB, 0);
		isp1362_write_reg32(isp1362_hcd, HCINTSTAT, OHCI_INTR_SF);

		DBG(0, "%s: stopping schedules ...\n", __func__);
		limit = 2000;
		while (limit > 0) {
			udelay(250);
			limit -= 250;
			if (isp1362_read_reg32(isp1362_hcd, HCINTSTAT) & OHCI_INTR_SF)
				break;
		}
		mdelay(7);
		if (isp1362_read_reg16(isp1362_hcd, HCuPINT) & HCuPINT_ATL) {
			u32 done_map = isp1362_read_reg32(isp1362_hcd, HCATLDONE);
			finish_transfers(isp1362_hcd, done_map, &isp1362_hcd->atl_queue);
		}
		if (isp1362_read_reg16(isp1362_hcd, HCuPINT) & HCuPINT_INTL) {
			u32 done_map = isp1362_read_reg32(isp1362_hcd, HCINTLDONE);
			finish_transfers(isp1362_hcd, done_map, &isp1362_hcd->intl_queue);
		}
		if (isp1362_read_reg16(isp1362_hcd, HCuPINT) & HCuPINT_ISTL0)
			finish_iso_transfers(isp1362_hcd, &isp1362_hcd->istl_queue[0]);
		if (isp1362_read_reg16(isp1362_hcd, HCuPINT) & HCuPINT_ISTL1)
			finish_iso_transfers(isp1362_hcd, &isp1362_hcd->istl_queue[1]);
	}
	DBG(0, "%s: HCINTSTAT: %08x\n", __func__,
		    isp1362_read_reg32(isp1362_hcd, HCINTSTAT));
	isp1362_write_reg32(isp1362_hcd, HCINTSTAT,
			    isp1362_read_reg32(isp1362_hcd, HCINTSTAT));

	/* Suspend hub */
	isp1362_hcd->hc_control = OHCI_USB_SUSPEND;
	isp1362_show_reg(isp1362_hcd, HCCONTROL);
	isp1362_write_reg32(isp1362_hcd, HCCONTROL, isp1362_hcd->hc_control);
	isp1362_show_reg(isp1362_hcd, HCCONTROL);

#if 1
	isp1362_hcd->hc_control = isp1362_read_reg32(isp1362_hcd, HCCONTROL);
	if ((isp1362_hcd->hc_control & OHCI_CTRL_HCFS) != OHCI_USB_SUSPEND) {
		pr_err("%s: controller won't suspend %08x\n", __func__,
		    isp1362_hcd->hc_control);
		status = -EBUSY;
	} else
#endif
	{
		/* no resumes until devices finish suspending */
		isp1362_hcd->next_statechange = jiffies + msecs_to_jiffies(5);
	}
done:
	if (status == 0) {
		hcd->state = HC_STATE_SUSPENDED;
		DBG(0, "%s: HCD suspended: %08x\n", __func__,
		    isp1362_read_reg32(isp1362_hcd, HCCONTROL));
	}
	spin_unlock_irqrestore(&isp1362_hcd->lock, flags);
	return status;
}

static int isp1362_bus_resume(struct usb_hcd *hcd)
{
	struct isp1362_hcd *isp1362_hcd = hcd_to_isp1362_hcd(hcd);
	u32 port;
	unsigned long flags;
	int status = -EINPROGRESS;

	if (time_before(jiffies, isp1362_hcd->next_statechange))
		msleep(5);

	spin_lock_irqsave(&isp1362_hcd->lock, flags);
	isp1362_hcd->hc_control = isp1362_read_reg32(isp1362_hcd, HCCONTROL);
	pr_info("%s: HCCONTROL: %08x\n", __func__, isp1362_hcd->hc_control);
	if (hcd->state == HC_STATE_RESUMING) {
		pr_warning("%s: duplicate resume\n", __func__);
		status = 0;
	} else
		switch (isp1362_hcd->hc_control & OHCI_CTRL_HCFS) {
		case OHCI_USB_SUSPEND:
			DBG(0, "%s: resume root hub\n", __func__);
			isp1362_hcd->hc_control &= ~OHCI_CTRL_HCFS;
			isp1362_hcd->hc_control |= OHCI_USB_RESUME;
			isp1362_write_reg32(isp1362_hcd, HCCONTROL, isp1362_hcd->hc_control);
			break;
		case OHCI_USB_RESUME:
			/* HCFS changes sometime after INTR_RD */
			DBG(0, "%s: remote wakeup\n", __func__);
			break;
		case OHCI_USB_OPER:
			DBG(0, "%s: odd resume\n", __func__);
			status = 0;
			hcd->self.root_hub->dev.power.power_state = PMSG_ON;
			break;
		default:		/* RESET, we lost power */
			DBG(0, "%s: root hub hardware reset\n", __func__);
			status = -EBUSY;
		}
	spin_unlock_irqrestore(&isp1362_hcd->lock, flags);
	if (status == -EBUSY) {
		DBG(0, "%s: Restarting HC\n", __func__);
		isp1362_hc_stop(hcd);
		return isp1362_hc_start(hcd);
	}
	if (status != -EINPROGRESS)
		return status;
	spin_lock_irqsave(&isp1362_hcd->lock, flags);
	port = isp1362_read_reg32(isp1362_hcd, HCRHDESCA) & RH_A_NDP;
	while (port--) {
		u32 stat = isp1362_read_reg32(isp1362_hcd, HCRHPORT1 + port);

		/* force global, not selective, resume */
		if (!(stat & RH_PS_PSS)) {
			DBG(0, "%s: Not Resuming RH port %d\n", __func__, port);
			continue;
		}
		DBG(0, "%s: Resuming RH port %d\n", __func__, port);
		isp1362_write_reg32(isp1362_hcd, HCRHPORT1 + port, RH_PS_POCI);
	}
	spin_unlock_irqrestore(&isp1362_hcd->lock, flags);

	/* Some controllers (lucent) need extra-long delays */
	hcd->state = HC_STATE_RESUMING;
	mdelay(20 /* usb 11.5.1.10 */ + 15);

	isp1362_hcd->hc_control = OHCI_USB_OPER;
	spin_lock_irqsave(&isp1362_hcd->lock, flags);
	isp1362_show_reg(isp1362_hcd, HCCONTROL);
	isp1362_write_reg32(isp1362_hcd, HCCONTROL, isp1362_hcd->hc_control);
	spin_unlock_irqrestore(&isp1362_hcd->lock, flags);
	/* TRSMRCY */
	msleep(10);

	/* keep it alive for ~5x suspend + resume costs */
	isp1362_hcd->next_statechange = jiffies + msecs_to_jiffies(250);

	hcd->self.root_hub->dev.power.power_state = PMSG_ON;
	hcd->state = HC_STATE_RUNNING;
	return 0;
}
#else
#define	isp1362_bus_suspend	NULL
#define	isp1362_bus_resume	NULL
#endif

/*-------------------------------------------------------------------------*/

#ifdef STUB_DEBUG_FILE

static inline void create_debug_file(struct isp1362_hcd *isp1362_hcd)
{
}
static inline void remove_debug_file(struct isp1362_hcd *isp1362_hcd)
{
}

#else

#include <linux/proc_fs.h>
#include <linux/seq_file.h>

static void dump_irq(struct seq_file *s, char *label, u16 mask)
{
	seq_printf(s, "%-15s %04x%s%s%s%s%s%s\n", label, mask,
		   mask & HCuPINT_CLKRDY ? " clkrdy" : "",
		   mask & HCuPINT_SUSP ? " susp" : "",
		   mask & HCuPINT_OPR ? " opr" : "",
		   mask & HCuPINT_EOT ? " eot" : "",
		   mask & HCuPINT_ATL ? " atl" : "",
		   mask & HCuPINT_SOF ? " sof" : "");
}

static void dump_int(struct seq_file *s, char *label, u32 mask)
{
	seq_printf(s, "%-15s %08x%s%s%s%s%s%s%s\n", label, mask,
		   mask & OHCI_INTR_MIE ? " MIE" : "",
		   mask & OHCI_INTR_RHSC ? " rhsc" : "",
		   mask & OHCI_INTR_FNO ? " fno" : "",
		   mask & OHCI_INTR_UE ? " ue" : "",
		   mask & OHCI_INTR_RD ? " rd" : "",
		   mask & OHCI_INTR_SF ? " sof" : "",
		   mask & OHCI_INTR_SO ? " so" : "");
}

static void dump_ctrl(struct seq_file *s, char *label, u32 mask)
{
	seq_printf(s, "%-15s %08x%s%s%s\n", label, mask,
		   mask & OHCI_CTRL_RWC ? " rwc" : "",
		   mask & OHCI_CTRL_RWE ? " rwe" : "",
		   ({
			   char *hcfs;
			   switch (mask & OHCI_CTRL_HCFS) {
			   case OHCI_USB_OPER:
				   hcfs = " oper";
				   break;
			   case OHCI_USB_RESET:
				   hcfs = " reset";
				   break;
			   case OHCI_USB_RESUME:
				   hcfs = " resume";
				   break;
			   case OHCI_USB_SUSPEND:
				   hcfs = " suspend";
				   break;
			   default:
				   hcfs = " ?";
			   }
			   hcfs;
		   }));
}

static void dump_regs(struct seq_file *s, struct isp1362_hcd *isp1362_hcd)
{
	seq_printf(s, "HCREVISION [%02x] %08x\n", ISP1362_REG_NO(ISP1362_REG_HCREVISION),
		   isp1362_read_reg32(isp1362_hcd, HCREVISION));
	seq_printf(s, "HCCONTROL  [%02x] %08x\n", ISP1362_REG_NO(ISP1362_REG_HCCONTROL),
		   isp1362_read_reg32(isp1362_hcd, HCCONTROL));
	seq_printf(s, "HCCMDSTAT  [%02x] %08x\n", ISP1362_REG_NO(ISP1362_REG_HCCMDSTAT),
		   isp1362_read_reg32(isp1362_hcd, HCCMDSTAT));
	seq_printf(s, "HCINTSTAT  [%02x] %08x\n", ISP1362_REG_NO(ISP1362_REG_HCINTSTAT),
		   isp1362_read_reg32(isp1362_hcd, HCINTSTAT));
	seq_printf(s, "HCINTENB   [%02x] %08x\n", ISP1362_REG_NO(ISP1362_REG_HCINTENB),
		   isp1362_read_reg32(isp1362_hcd, HCINTENB));
	seq_printf(s, "HCFMINTVL  [%02x] %08x\n", ISP1362_REG_NO(ISP1362_REG_HCFMINTVL),
		   isp1362_read_reg32(isp1362_hcd, HCFMINTVL));
	seq_printf(s, "HCFMREM    [%02x] %08x\n", ISP1362_REG_NO(ISP1362_REG_HCFMREM),
		   isp1362_read_reg32(isp1362_hcd, HCFMREM));
	seq_printf(s, "HCFMNUM    [%02x] %08x\n", ISP1362_REG_NO(ISP1362_REG_HCFMNUM),
		   isp1362_read_reg32(isp1362_hcd, HCFMNUM));
	seq_printf(s, "HCLSTHRESH [%02x] %08x\n", ISP1362_REG_NO(ISP1362_REG_HCLSTHRESH),
		   isp1362_read_reg32(isp1362_hcd, HCLSTHRESH));
	seq_printf(s, "HCRHDESCA  [%02x] %08x\n", ISP1362_REG_NO(ISP1362_REG_HCRHDESCA),
		   isp1362_read_reg32(isp1362_hcd, HCRHDESCA));
	seq_printf(s, "HCRHDESCB  [%02x] %08x\n", ISP1362_REG_NO(ISP1362_REG_HCRHDESCB),
		   isp1362_read_reg32(isp1362_hcd, HCRHDESCB));
	seq_printf(s, "HCRHSTATUS [%02x] %08x\n", ISP1362_REG_NO(ISP1362_REG_HCRHSTATUS),
		   isp1362_read_reg32(isp1362_hcd, HCRHSTATUS));
	seq_printf(s, "HCRHPORT1  [%02x] %08x\n", ISP1362_REG_NO(ISP1362_REG_HCRHPORT1),
		   isp1362_read_reg32(isp1362_hcd, HCRHPORT1));
	seq_printf(s, "HCRHPORT2  [%02x] %08x\n", ISP1362_REG_NO(ISP1362_REG_HCRHPORT2),
		   isp1362_read_reg32(isp1362_hcd, HCRHPORT2));
	seq_printf(s, "\n");
	seq_printf(s, "HCHWCFG    [%02x]     %04x\n", ISP1362_REG_NO(ISP1362_REG_HCHWCFG),
		   isp1362_read_reg16(isp1362_hcd, HCHWCFG));
	seq_printf(s, "HCDMACFG   [%02x]     %04x\n", ISP1362_REG_NO(ISP1362_REG_HCDMACFG),
		   isp1362_read_reg16(isp1362_hcd, HCDMACFG));
	seq_printf(s, "HCXFERCTR  [%02x]     %04x\n", ISP1362_REG_NO(ISP1362_REG_HCXFERCTR),
		   isp1362_read_reg16(isp1362_hcd, HCXFERCTR));
	seq_printf(s, "HCuPINT    [%02x]     %04x\n", ISP1362_REG_NO(ISP1362_REG_HCuPINT),
		   isp1362_read_reg16(isp1362_hcd, HCuPINT));
	seq_printf(s, "HCuPINTENB [%02x]     %04x\n", ISP1362_REG_NO(ISP1362_REG_HCuPINTENB),
		   isp1362_read_reg16(isp1362_hcd, HCuPINTENB));
	seq_printf(s, "HCCHIPID   [%02x]     %04x\n", ISP1362_REG_NO(ISP1362_REG_HCCHIPID),
		   isp1362_read_reg16(isp1362_hcd, HCCHIPID));
	seq_printf(s, "HCSCRATCH  [%02x]     %04x\n", ISP1362_REG_NO(ISP1362_REG_HCSCRATCH),
		   isp1362_read_reg16(isp1362_hcd, HCSCRATCH));
	seq_printf(s, "HCBUFSTAT  [%02x]     %04x\n", ISP1362_REG_NO(ISP1362_REG_HCBUFSTAT),
		   isp1362_read_reg16(isp1362_hcd, HCBUFSTAT));
	seq_printf(s, "HCDIRADDR  [%02x] %08x\n", ISP1362_REG_NO(ISP1362_REG_HCDIRADDR),
		   isp1362_read_reg32(isp1362_hcd, HCDIRADDR));
#if 0
	seq_printf(s, "HCDIRDATA  [%02x]     %04x\n", ISP1362_REG_NO(HCDIRDATA),
		   isp1362_read_reg16(isp1362_hcd, HCDIRDATA));
#endif
	seq_printf(s, "HCISTLBUFSZ[%02x]     %04x\n", ISP1362_REG_NO(ISP1362_REG_HCISTLBUFSZ),
		   isp1362_read_reg16(isp1362_hcd, HCISTLBUFSZ));
	seq_printf(s, "HCISTLRATE [%02x]     %04x\n", ISP1362_REG_NO(ISP1362_REG_HCISTLRATE),
		   isp1362_read_reg16(isp1362_hcd, HCISTLRATE));
	seq_printf(s, "\n");
	seq_printf(s, "HCINTLBUFSZ[%02x]     %04x\n", ISP1362_REG_NO(ISP1362_REG_HCINTLBUFSZ),
		   isp1362_read_reg16(isp1362_hcd, HCINTLBUFSZ));
	seq_printf(s, "HCINTLBLKSZ[%02x]     %04x\n", ISP1362_REG_NO(ISP1362_REG_HCINTLBLKSZ),
		   isp1362_read_reg16(isp1362_hcd, HCINTLBLKSZ));
	seq_printf(s, "HCINTLDONE [%02x] %08x\n", ISP1362_REG_NO(ISP1362_REG_HCINTLDONE),
		   isp1362_read_reg32(isp1362_hcd, HCINTLDONE));
	seq_printf(s, "HCINTLSKIP [%02x] %08x\n", ISP1362_REG_NO(ISP1362_REG_HCINTLSKIP),
		   isp1362_read_reg32(isp1362_hcd, HCINTLSKIP));
	seq_printf(s, "HCINTLLAST [%02x] %08x\n", ISP1362_REG_NO(ISP1362_REG_HCINTLLAST),
		   isp1362_read_reg32(isp1362_hcd, HCINTLLAST));
	seq_printf(s, "HCINTLCURR [%02x]     %04x\n", ISP1362_REG_NO(ISP1362_REG_HCINTLCURR),
		   isp1362_read_reg16(isp1362_hcd, HCINTLCURR));
	seq_printf(s, "\n");
	seq_printf(s, "HCATLBUFSZ [%02x]     %04x\n", ISP1362_REG_NO(ISP1362_REG_HCATLBUFSZ),
		   isp1362_read_reg16(isp1362_hcd, HCATLBUFSZ));
	seq_printf(s, "HCATLBLKSZ [%02x]     %04x\n", ISP1362_REG_NO(ISP1362_REG_HCATLBLKSZ),
		   isp1362_read_reg16(isp1362_hcd, HCATLBLKSZ));
#if 0
	seq_printf(s, "HCATLDONE  [%02x] %08x\n", ISP1362_REG_NO(ISP1362_REG_HCATLDONE),
		   isp1362_read_reg32(isp1362_hcd, HCATLDONE));
#endif
	seq_printf(s, "HCATLSKIP  [%02x] %08x\n", ISP1362_REG_NO(ISP1362_REG_HCATLSKIP),
		   isp1362_read_reg32(isp1362_hcd, HCATLSKIP));
	seq_printf(s, "HCATLLAST  [%02x] %08x\n", ISP1362_REG_NO(ISP1362_REG_HCATLLAST),
		   isp1362_read_reg32(isp1362_hcd, HCATLLAST));
	seq_printf(s, "HCATLCURR  [%02x]     %04x\n", ISP1362_REG_NO(ISP1362_REG_HCATLCURR),
		   isp1362_read_reg16(isp1362_hcd, HCATLCURR));
	seq_printf(s, "\n");
	seq_printf(s, "HCATLDTC   [%02x]     %04x\n", ISP1362_REG_NO(ISP1362_REG_HCATLDTC),
		   isp1362_read_reg16(isp1362_hcd, HCATLDTC));
	seq_printf(s, "HCATLDTCTO [%02x]     %04x\n", ISP1362_REG_NO(ISP1362_REG_HCATLDTCTO),
		   isp1362_read_reg16(isp1362_hcd, HCATLDTCTO));
}

static int proc_isp1362_show(struct seq_file *s, void *unused)
{
	struct isp1362_hcd *isp1362_hcd = s->private;
	struct isp1362_ep *ep;
	int i;

	seq_printf(s, "%s\n%s version %s\n",
		   isp1362_hcd_to_hcd(isp1362_hcd)->product_desc, hcd_name, DRIVER_VERSION);

	/* collect statistics to help estimate potential win for
	 * DMA engines that care about alignment (PXA)
	 */
	seq_printf(s, "alignment:  16b/%ld 8b/%ld 4b/%ld 2b/%ld 1b/%ld\n",
		   isp1362_hcd->stat16, isp1362_hcd->stat8, isp1362_hcd->stat4,
		   isp1362_hcd->stat2, isp1362_hcd->stat1);
	seq_printf(s, "max # ptds in ATL  fifo: %d\n", isp1362_hcd->atl_queue.stat_maxptds);
	seq_printf(s, "max # ptds in INTL fifo: %d\n", isp1362_hcd->intl_queue.stat_maxptds);
	seq_printf(s, "max # ptds in ISTL fifo: %d\n",
		   max(isp1362_hcd->istl_queue[0] .stat_maxptds,
		       isp1362_hcd->istl_queue[1] .stat_maxptds));

	/* FIXME: don't show the following in suspended state */
	spin_lock_irq(&isp1362_hcd->lock);

	dump_irq(s, "hc_irq_enable", isp1362_read_reg16(isp1362_hcd, HCuPINTENB));
	dump_irq(s, "hc_irq_status", isp1362_read_reg16(isp1362_hcd, HCuPINT));
	dump_int(s, "ohci_int_enable", isp1362_read_reg32(isp1362_hcd, HCINTENB));
	dump_int(s, "ohci_int_status", isp1362_read_reg32(isp1362_hcd, HCINTSTAT));
	dump_ctrl(s, "ohci_control", isp1362_read_reg32(isp1362_hcd, HCCONTROL));

	for (i = 0; i < NUM_ISP1362_IRQS; i++)
		if (isp1362_hcd->irq_stat[i])
			seq_printf(s, "%-15s: %d\n",
				   ISP1362_INT_NAME(i), isp1362_hcd->irq_stat[i]);

	dump_regs(s, isp1362_hcd);
	list_for_each_entry(ep, &isp1362_hcd->async, schedule) {
		struct urb *urb;

		seq_printf(s, "%p, ep%d%s, maxpacket %d:\n", ep, ep->epnum,
			   ({
				   char *s;
				   switch (ep->nextpid) {
				   case USB_PID_IN:
					   s = "in";
					   break;
				   case USB_PID_OUT:
					   s = "out";
					   break;
				   case USB_PID_SETUP:
					   s = "setup";
					   break;
				   case USB_PID_ACK:
					   s = "status";
					   break;
				   default:
					   s = "?";
					   break;
				   };
				   s;}), ep->maxpacket) ;
		list_for_each_entry(urb, &ep->hep->urb_list, urb_list) {
			seq_printf(s, "  urb%p, %d/%d\n", urb,
				   urb->actual_length,
				   urb->transfer_buffer_length);
		}
	}
	if (!list_empty(&isp1362_hcd->async))
		seq_printf(s, "\n");
	dump_ptd_queue(&isp1362_hcd->atl_queue);

	seq_printf(s, "periodic size= %d\n", PERIODIC_SIZE);

	list_for_each_entry(ep, &isp1362_hcd->periodic, schedule) {
		seq_printf(s, "branch:%2d load:%3d PTD[%d] $%04x:\n", ep->branch,
			   isp1362_hcd->load[ep->branch], ep->ptd_index, ep->ptd_offset);

		seq_printf(s, "   %d/%p (%sdev%d ep%d%s max %d)\n",
			   ep->interval, ep,
			   (ep->udev->speed == USB_SPEED_FULL) ? "" : "ls ",
			   ep->udev->devnum, ep->epnum,
			   (ep->epnum == 0) ? "" :
			   ((ep->nextpid == USB_PID_IN) ?
			    "in" : "out"), ep->maxpacket);
	}
	dump_ptd_queue(&isp1362_hcd->intl_queue);

	seq_printf(s, "ISO:\n");

	list_for_each_entry(ep, &isp1362_hcd->isoc, schedule) {
		seq_printf(s, "   %d/%p (%sdev%d ep%d%s max %d)\n",
			   ep->interval, ep,
			   (ep->udev->speed == USB_SPEED_FULL) ? "" : "ls ",
			   ep->udev->devnum, ep->epnum,
			   (ep->epnum == 0) ? "" :
			   ((ep->nextpid == USB_PID_IN) ?
			    "in" : "out"), ep->maxpacket);
	}

	spin_unlock_irq(&isp1362_hcd->lock);
	seq_printf(s, "\n");

	return 0;
}

static int proc_isp1362_open(struct inode *inode, struct file *file)
{
	return single_open(file, proc_isp1362_show, PDE(inode)->data);
}

static const struct file_operations proc_ops = {
	.open = proc_isp1362_open,
	.read = seq_read,
	.llseek = seq_lseek,
	.release = single_release,
};

/* expect just one isp1362_hcd per system */
static const char proc_filename[] = "driver/isp1362";

static void create_debug_file(struct isp1362_hcd *isp1362_hcd)
{
	struct proc_dir_entry *pde;

	pde = create_proc_entry(proc_filename, 0, NULL);
	if (pde == NULL) {
		pr_warning("%s: Failed to create debug file '%s'\n", __func__, proc_filename);
		return;
	}

	pde->proc_fops = &proc_ops;
	pde->data = isp1362_hcd;
	isp1362_hcd->pde = pde;
}

static void remove_debug_file(struct isp1362_hcd *isp1362_hcd)
{
	if (isp1362_hcd->pde)
		remove_proc_entry(proc_filename, NULL);
}

#endif

/*-------------------------------------------------------------------------*/

static void __isp1362_sw_reset(struct isp1362_hcd *isp1362_hcd)
{
	int tmp = 20;

	isp1362_write_reg16(isp1362_hcd, HCSWRES, HCSWRES_MAGIC);
	isp1362_write_reg32(isp1362_hcd, HCCMDSTAT, OHCI_HCR);
	while (--tmp) {
		mdelay(1);
		if (!(isp1362_read_reg32(isp1362_hcd, HCCMDSTAT) & OHCI_HCR))
			break;
	}
	if (!tmp)
		pr_err("Software reset timeout\n");
}

static void isp1362_sw_reset(struct isp1362_hcd *isp1362_hcd)
{
	unsigned long flags;

	spin_lock_irqsave(&isp1362_hcd->lock, flags);
	__isp1362_sw_reset(isp1362_hcd);
	spin_unlock_irqrestore(&isp1362_hcd->lock, flags);
}

static int isp1362_mem_config(struct usb_hcd *hcd)
{
	struct isp1362_hcd *isp1362_hcd = hcd_to_isp1362_hcd(hcd);
	unsigned long flags;
	u32 total;
	u16 istl_size = ISP1362_ISTL_BUFSIZE;
	u16 intl_blksize = ISP1362_INTL_BLKSIZE + PTD_HEADER_SIZE;
	u16 intl_size = ISP1362_INTL_BUFFERS * intl_blksize;
	u16 atl_blksize = ISP1362_ATL_BLKSIZE + PTD_HEADER_SIZE;
	u16 atl_buffers = (ISP1362_BUF_SIZE - (istl_size + intl_size)) / atl_blksize;
	u16 atl_size;
	int i;

	WARN_ON(istl_size & 3);
	WARN_ON(atl_blksize & 3);
	WARN_ON(intl_blksize & 3);
	WARN_ON(atl_blksize < PTD_HEADER_SIZE);
	WARN_ON(intl_blksize < PTD_HEADER_SIZE);

	BUG_ON((unsigned)ISP1362_INTL_BUFFERS > 32);
	if (atl_buffers > 32)
		atl_buffers = 32;
	atl_size = atl_buffers * atl_blksize;
	total = atl_size + intl_size + istl_size;
	dev_info(hcd->self.controller, "ISP1362 Memory usage:\n");
	dev_info(hcd->self.controller, "  ISTL:    2 * %4d:     %4d @ $%04x:$%04x\n",
		 istl_size / 2, istl_size, 0, istl_size / 2);
	dev_info(hcd->self.controller, "  INTL: %4d * (%3zu+8):  %4d @ $%04x\n",
		 ISP1362_INTL_BUFFERS, intl_blksize - PTD_HEADER_SIZE,
		 intl_size, istl_size);
	dev_info(hcd->self.controller, "  ATL : %4d * (%3zu+8):  %4d @ $%04x\n",
		 atl_buffers, atl_blksize - PTD_HEADER_SIZE,
		 atl_size, istl_size + intl_size);
	dev_info(hcd->self.controller, "  USED/FREE:   %4d      %4d\n", total,
		 ISP1362_BUF_SIZE - total);

	if (total > ISP1362_BUF_SIZE) {
		dev_err(hcd->self.controller, "%s: Memory requested: %d, available %d\n",
			__func__, total, ISP1362_BUF_SIZE);
		return -ENOMEM;
	}

	total = istl_size + intl_size + atl_size;
	spin_lock_irqsave(&isp1362_hcd->lock, flags);

	for (i = 0; i < 2; i++) {
		isp1362_hcd->istl_queue[i].buf_start = i * istl_size / 2,
		isp1362_hcd->istl_queue[i].buf_size = istl_size / 2;
		isp1362_hcd->istl_queue[i].blk_size = 4;
		INIT_LIST_HEAD(&isp1362_hcd->istl_queue[i].active);
		snprintf(isp1362_hcd->istl_queue[i].name,
			 sizeof(isp1362_hcd->istl_queue[i].name), "ISTL%d", i);
		DBG(3, "%s: %5s buf $%04x %d\n", __func__,
		     isp1362_hcd->istl_queue[i].name,
		     isp1362_hcd->istl_queue[i].buf_start,
		     isp1362_hcd->istl_queue[i].buf_size);
	}
	isp1362_write_reg16(isp1362_hcd, HCISTLBUFSZ, istl_size / 2);

	isp1362_hcd->intl_queue.buf_start = istl_size;
	isp1362_hcd->intl_queue.buf_size = intl_size;
	isp1362_hcd->intl_queue.buf_count = ISP1362_INTL_BUFFERS;
	isp1362_hcd->intl_queue.blk_size = intl_blksize;
	isp1362_hcd->intl_queue.buf_avail = isp1362_hcd->intl_queue.buf_count;
	isp1362_hcd->intl_queue.skip_map = ~0;
	INIT_LIST_HEAD(&isp1362_hcd->intl_queue.active);

	isp1362_write_reg16(isp1362_hcd, HCINTLBUFSZ,
			    isp1362_hcd->intl_queue.buf_size);
	isp1362_write_reg16(isp1362_hcd, HCINTLBLKSZ,
			    isp1362_hcd->intl_queue.blk_size - PTD_HEADER_SIZE);
	isp1362_write_reg32(isp1362_hcd, HCINTLSKIP, ~0);
	isp1362_write_reg32(isp1362_hcd, HCINTLLAST,
			    1 << (ISP1362_INTL_BUFFERS - 1));

	isp1362_hcd->atl_queue.buf_start = istl_size + intl_size;
	isp1362_hcd->atl_queue.buf_size = atl_size;
	isp1362_hcd->atl_queue.buf_count = atl_buffers;
	isp1362_hcd->atl_queue.blk_size = atl_blksize;
	isp1362_hcd->atl_queue.buf_avail = isp1362_hcd->atl_queue.buf_count;
	isp1362_hcd->atl_queue.skip_map = ~0;
	INIT_LIST_HEAD(&isp1362_hcd->atl_queue.active);

	isp1362_write_reg16(isp1362_hcd, HCATLBUFSZ,
			    isp1362_hcd->atl_queue.buf_size);
	isp1362_write_reg16(isp1362_hcd, HCATLBLKSZ,
			    isp1362_hcd->atl_queue.blk_size - PTD_HEADER_SIZE);
	isp1362_write_reg32(isp1362_hcd, HCATLSKIP, ~0);
	isp1362_write_reg32(isp1362_hcd, HCATLLAST,
			    1 << (atl_buffers - 1));

	snprintf(isp1362_hcd->atl_queue.name,
		 sizeof(isp1362_hcd->atl_queue.name), "ATL");
	snprintf(isp1362_hcd->intl_queue.name,
		 sizeof(isp1362_hcd->intl_queue.name), "INTL");
	DBG(3, "%s: %5s buf $%04x %2d * %4d = %4d\n", __func__,
	     isp1362_hcd->intl_queue.name,
	     isp1362_hcd->intl_queue.buf_start,
	     ISP1362_INTL_BUFFERS, isp1362_hcd->intl_queue.blk_size,
	     isp1362_hcd->intl_queue.buf_size);
	DBG(3, "%s: %5s buf $%04x %2d * %4d = %4d\n", __func__,
	     isp1362_hcd->atl_queue.name,
	     isp1362_hcd->atl_queue.buf_start,
	     atl_buffers, isp1362_hcd->atl_queue.blk_size,
	     isp1362_hcd->atl_queue.buf_size);

	spin_unlock_irqrestore(&isp1362_hcd->lock, flags);

	return 0;
}

static int isp1362_hc_reset(struct usb_hcd *hcd)
{
	int ret = 0;
	struct isp1362_hcd *isp1362_hcd = hcd_to_isp1362_hcd(hcd);
	unsigned long t;
	unsigned long timeout = 100;
	unsigned long flags;
	int clkrdy = 0;

	pr_info("%s:\n", __func__);

	if (isp1362_hcd->board && isp1362_hcd->board->reset) {
		isp1362_hcd->board->reset(hcd->self.controller, 1);
		msleep(20);
		if (isp1362_hcd->board->clock)
			isp1362_hcd->board->clock(hcd->self.controller, 1);
		isp1362_hcd->board->reset(hcd->self.controller, 0);
	} else
		isp1362_sw_reset(isp1362_hcd);

	/* chip has been reset. First we need to see a clock */
	t = jiffies + msecs_to_jiffies(timeout);
	while (!clkrdy && time_before_eq(jiffies, t)) {
		spin_lock_irqsave(&isp1362_hcd->lock, flags);
		clkrdy = isp1362_read_reg16(isp1362_hcd, HCuPINT) & HCuPINT_CLKRDY;
		spin_unlock_irqrestore(&isp1362_hcd->lock, flags);
		if (!clkrdy)
			msleep(4);
	}

	spin_lock_irqsave(&isp1362_hcd->lock, flags);
	isp1362_write_reg16(isp1362_hcd, HCuPINT, HCuPINT_CLKRDY);
	spin_unlock_irqrestore(&isp1362_hcd->lock, flags);
	if (!clkrdy) {
		pr_err("Clock not ready after %lums\n", timeout);
		ret = -ENODEV;
	}
	return ret;
}

static void isp1362_hc_stop(struct usb_hcd *hcd)
{
	struct isp1362_hcd *isp1362_hcd = hcd_to_isp1362_hcd(hcd);
	unsigned long flags;
	u32 tmp;

	pr_info("%s:\n", __func__);

	del_timer_sync(&hcd->rh_timer);

	spin_lock_irqsave(&isp1362_hcd->lock, flags);

	isp1362_write_reg16(isp1362_hcd, HCuPINTENB, 0);

	/* Switch off power for all ports */
	tmp = isp1362_read_reg32(isp1362_hcd, HCRHDESCA);
	tmp &= ~(RH_A_NPS | RH_A_PSM);
	isp1362_write_reg32(isp1362_hcd, HCRHDESCA, tmp);
	isp1362_write_reg32(isp1362_hcd, HCRHSTATUS, RH_HS_LPS);

	/* Reset the chip */
	if (isp1362_hcd->board && isp1362_hcd->board->reset)
		isp1362_hcd->board->reset(hcd->self.controller, 1);
	else
		__isp1362_sw_reset(isp1362_hcd);

	if (isp1362_hcd->board && isp1362_hcd->board->clock)
		isp1362_hcd->board->clock(hcd->self.controller, 0);

	spin_unlock_irqrestore(&isp1362_hcd->lock, flags);
}

#ifdef CHIP_BUFFER_TEST
static int isp1362_chip_test(struct isp1362_hcd *isp1362_hcd)
{
	int ret = 0;
	u16 *ref;
	unsigned long flags;

	ref = kmalloc(2 * ISP1362_BUF_SIZE, GFP_KERNEL);
	if (ref) {
		int offset;
		u16 *tst = &ref[ISP1362_BUF_SIZE / 2];

		for (offset = 0; offset < ISP1362_BUF_SIZE / 2; offset++) {
			ref[offset] = ~offset;
			tst[offset] = offset;
		}

		for (offset = 0; offset < 4; offset++) {
			int j;

			for (j = 0; j < 8; j++) {
				spin_lock_irqsave(&isp1362_hcd->lock, flags);
				isp1362_write_buffer(isp1362_hcd, (u8 *)ref + offset, 0, j);
				isp1362_read_buffer(isp1362_hcd, (u8 *)tst + offset, 0, j);
				spin_unlock_irqrestore(&isp1362_hcd->lock, flags);

				if (memcmp(ref, tst, j)) {
					ret = -ENODEV;
					pr_err("%s: memory check with %d byte offset %d failed\n",
					    __func__, j, offset);
					dump_data((u8 *)ref + offset, j);
					dump_data((u8 *)tst + offset, j);
				}
			}
		}

		spin_lock_irqsave(&isp1362_hcd->lock, flags);
		isp1362_write_buffer(isp1362_hcd, ref, 0, ISP1362_BUF_SIZE);
		isp1362_read_buffer(isp1362_hcd, tst, 0, ISP1362_BUF_SIZE);
		spin_unlock_irqrestore(&isp1362_hcd->lock, flags);

		if (memcmp(ref, tst, ISP1362_BUF_SIZE)) {
			ret = -ENODEV;
			pr_err("%s: memory check failed\n", __func__);
			dump_data((u8 *)tst, ISP1362_BUF_SIZE / 2);
		}

		for (offset = 0; offset < 256; offset++) {
			int test_size = 0;

			yield();

			memset(tst, 0, ISP1362_BUF_SIZE);
			spin_lock_irqsave(&isp1362_hcd->lock, flags);
			isp1362_write_buffer(isp1362_hcd, tst, 0, ISP1362_BUF_SIZE);
			isp1362_read_buffer(isp1362_hcd, tst, 0, ISP1362_BUF_SIZE);
			spin_unlock_irqrestore(&isp1362_hcd->lock, flags);
			if (memcmp(tst, tst + (ISP1362_BUF_SIZE / (2 * sizeof(*tst))),
				   ISP1362_BUF_SIZE / 2)) {
				pr_err("%s: Failed to clear buffer\n", __func__);
				dump_data((u8 *)tst, ISP1362_BUF_SIZE);
				break;
			}
			spin_lock_irqsave(&isp1362_hcd->lock, flags);
			isp1362_write_buffer(isp1362_hcd, ref, offset * 2, PTD_HEADER_SIZE);
			isp1362_write_buffer(isp1362_hcd, ref + PTD_HEADER_SIZE / sizeof(*ref),
					     offset * 2 + PTD_HEADER_SIZE, test_size);
			isp1362_read_buffer(isp1362_hcd, tst, offset * 2,
					    PTD_HEADER_SIZE + test_size);
			spin_unlock_irqrestore(&isp1362_hcd->lock, flags);
			if (memcmp(ref, tst, PTD_HEADER_SIZE + test_size)) {
				dump_data(((u8 *)ref) + offset, PTD_HEADER_SIZE + test_size);
				dump_data((u8 *)tst, PTD_HEADER_SIZE + test_size);
				spin_lock_irqsave(&isp1362_hcd->lock, flags);
				isp1362_read_buffer(isp1362_hcd, tst, offset * 2,
						    PTD_HEADER_SIZE + test_size);
				spin_unlock_irqrestore(&isp1362_hcd->lock, flags);
				if (memcmp(ref, tst, PTD_HEADER_SIZE + test_size)) {
					ret = -ENODEV;
					pr_err("%s: memory check with offset %02x failed\n",
					    __func__, offset);
					break;
				}
				pr_warning("%s: memory check with offset %02x ok after second read\n",
				     __func__, offset);
			}
		}
		kfree(ref);
	}
	return ret;
}
#endif

static int isp1362_hc_start(struct usb_hcd *hcd)
{
	int ret;
	struct isp1362_hcd *isp1362_hcd = hcd_to_isp1362_hcd(hcd);
	struct isp1362_platform_data *board = isp1362_hcd->board;
	u16 hwcfg;
	u16 chipid;
	unsigned long flags;

	pr_info("%s:\n", __func__);

	spin_lock_irqsave(&isp1362_hcd->lock, flags);
	chipid = isp1362_read_reg16(isp1362_hcd, HCCHIPID);
	spin_unlock_irqrestore(&isp1362_hcd->lock, flags);

	if ((chipid & HCCHIPID_MASK) != HCCHIPID_MAGIC) {
		pr_err("%s: Invalid chip ID %04x\n", __func__, chipid);
		return -ENODEV;
	}

#ifdef CHIP_BUFFER_TEST
	ret = isp1362_chip_test(isp1362_hcd);
	if (ret)
		return -ENODEV;
#endif
	spin_lock_irqsave(&isp1362_hcd->lock, flags);
	/* clear interrupt status and disable all interrupt sources */
	isp1362_write_reg16(isp1362_hcd, HCuPINT, 0xff);
	isp1362_write_reg16(isp1362_hcd, HCuPINTENB, 0);

	/* HW conf */
	hwcfg = HCHWCFG_INT_ENABLE | HCHWCFG_DBWIDTH(1);
	if (board->sel15Kres)
		hwcfg |= HCHWCFG_PULLDOWN_DS2 |
			((MAX_ROOT_PORTS > 1) ? HCHWCFG_PULLDOWN_DS1 : 0);
	if (board->clknotstop)
		hwcfg |= HCHWCFG_CLKNOTSTOP;
	if (board->oc_enable)
		hwcfg |= HCHWCFG_ANALOG_OC;
	if (board->int_act_high)
		hwcfg |= HCHWCFG_INT_POL;
	if (board->int_edge_triggered)
		hwcfg |= HCHWCFG_INT_TRIGGER;
	if (board->dreq_act_high)
		hwcfg |= HCHWCFG_DREQ_POL;
	if (board->dack_act_high)
		hwcfg |= HCHWCFG_DACK_POL;
	isp1362_write_reg16(isp1362_hcd, HCHWCFG, hwcfg);
	isp1362_show_reg(isp1362_hcd, HCHWCFG);
	isp1362_write_reg16(isp1362_hcd, HCDMACFG, 0);
	spin_unlock_irqrestore(&isp1362_hcd->lock, flags);

	ret = isp1362_mem_config(hcd);
	if (ret)
		return ret;

	spin_lock_irqsave(&isp1362_hcd->lock, flags);

	/* Root hub conf */
	isp1362_hcd->rhdesca = 0;
	if (board->no_power_switching)
		isp1362_hcd->rhdesca |= RH_A_NPS;
	if (board->power_switching_mode)
		isp1362_hcd->rhdesca |= RH_A_PSM;
	if (board->potpg)
		isp1362_hcd->rhdesca |= (board->potpg << 24) & RH_A_POTPGT;
	else
		isp1362_hcd->rhdesca |= (25 << 24) & RH_A_POTPGT;

	isp1362_write_reg32(isp1362_hcd, HCRHDESCA, isp1362_hcd->rhdesca & ~RH_A_OCPM);
	isp1362_write_reg32(isp1362_hcd, HCRHDESCA, isp1362_hcd->rhdesca | RH_A_OCPM);
	isp1362_hcd->rhdesca = isp1362_read_reg32(isp1362_hcd, HCRHDESCA);

	isp1362_hcd->rhdescb = RH_B_PPCM;
	isp1362_write_reg32(isp1362_hcd, HCRHDESCB, isp1362_hcd->rhdescb);
	isp1362_hcd->rhdescb = isp1362_read_reg32(isp1362_hcd, HCRHDESCB);

	isp1362_read_reg32(isp1362_hcd, HCFMINTVL);
	isp1362_write_reg32(isp1362_hcd, HCFMINTVL, (FSMP(FI) << 16) | FI);
	isp1362_write_reg32(isp1362_hcd, HCLSTHRESH, LSTHRESH);

	spin_unlock_irqrestore(&isp1362_hcd->lock, flags);

	isp1362_hcd->hc_control = OHCI_USB_OPER;
	hcd->state = HC_STATE_RUNNING;

	spin_lock_irqsave(&isp1362_hcd->lock, flags);
	/* Set up interrupts */
	isp1362_hcd->intenb = OHCI_INTR_MIE | OHCI_INTR_RHSC | OHCI_INTR_UE;
	isp1362_hcd->intenb |= OHCI_INTR_RD;
	isp1362_hcd->irqenb = HCuPINT_OPR | HCuPINT_SUSP;
	isp1362_write_reg32(isp1362_hcd, HCINTENB, isp1362_hcd->intenb);
	isp1362_write_reg16(isp1362_hcd, HCuPINTENB, isp1362_hcd->irqenb);

	/* Go operational */
	isp1362_write_reg32(isp1362_hcd, HCCONTROL, isp1362_hcd->hc_control);
	/* enable global power */
	isp1362_write_reg32(isp1362_hcd, HCRHSTATUS, RH_HS_LPSC | RH_HS_DRWE);

	spin_unlock_irqrestore(&isp1362_hcd->lock, flags);

	return 0;
}

/*-------------------------------------------------------------------------*/

static struct hc_driver isp1362_hc_driver = {
	.description =		hcd_name,
	.product_desc =		"ISP1362 Host Controller",
	.hcd_priv_size =	sizeof(struct isp1362_hcd),

	.irq =			isp1362_irq,
	.flags =		HCD_USB11 | HCD_MEMORY,

	.reset =		isp1362_hc_reset,
	.start =		isp1362_hc_start,
	.stop =			isp1362_hc_stop,

	.urb_enqueue =		isp1362_urb_enqueue,
	.urb_dequeue =		isp1362_urb_dequeue,
	.endpoint_disable =	isp1362_endpoint_disable,

	.get_frame_number =	isp1362_get_frame,

	.hub_status_data =	isp1362_hub_status_data,
	.hub_control =		isp1362_hub_control,
	.bus_suspend =		isp1362_bus_suspend,
	.bus_resume =		isp1362_bus_resume,
};

/*-------------------------------------------------------------------------*/

static int __devexit isp1362_remove(struct platform_device *pdev)
{
	struct usb_hcd *hcd = platform_get_drvdata(pdev);
	struct isp1362_hcd *isp1362_hcd = hcd_to_isp1362_hcd(hcd);
	struct resource *res;

	remove_debug_file(isp1362_hcd);
	DBG(0, "%s: Removing HCD\n", __func__);
	usb_remove_hcd(hcd);

	DBG(0, "%s: Unmapping data_reg @ %p\n", __func__,
	    isp1362_hcd->data_reg);
	iounmap(isp1362_hcd->data_reg);

	DBG(0, "%s: Unmapping addr_reg @ %p\n", __func__,
	    isp1362_hcd->addr_reg);
	iounmap(isp1362_hcd->addr_reg);

	res = platform_get_resource(pdev, IORESOURCE_MEM, 1);
	DBG(0, "%s: release mem_region: %08lx\n", __func__, (long unsigned int)res->start);
	if (res)
		release_mem_region(res->start, resource_size(res));

	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
	DBG(0, "%s: release mem_region: %08lx\n", __func__, (long unsigned int)res->start);
	if (res)
		release_mem_region(res->start, resource_size(res));

	DBG(0, "%s: put_hcd\n", __func__);
	usb_put_hcd(hcd);
	DBG(0, "%s: Done\n", __func__);

	return 0;
}

static int __init isp1362_probe(struct platform_device *pdev)
{
	struct usb_hcd *hcd;
	struct isp1362_hcd *isp1362_hcd;
	struct resource *addr, *data;
	void __iomem *addr_reg;
	void __iomem *data_reg;
	int irq;
	int retval = 0;
	struct resource *irq_res;
	unsigned int irq_flags = 0;

	/* basic sanity checks first.  board-specific init logic should
	 * have initialized this the three resources and probably board
	 * specific platform_data.  we don't probe for IRQs, and do only
	 * minimal sanity checking.
	 */
	if (pdev->num_resources < 3) {
		retval = -ENODEV;
		goto err1;
	}

	data = platform_get_resource(pdev, IORESOURCE_MEM, 0);
	addr = platform_get_resource(pdev, IORESOURCE_MEM, 1);
	irq_res = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
	if (!addr || !data || !irq_res) {
		retval = -ENODEV;
		goto err1;
	}
	irq = irq_res->start;

	if (pdev->dev.dma_mask) {
		DBG(1, "won't do DMA");
		retval = -ENODEV;
		goto err1;
	}

	if (!request_mem_region(addr->start, resource_size(addr), hcd_name)) {
		retval = -EBUSY;
		goto err1;
	}
	addr_reg = ioremap(addr->start, resource_size(addr));
	if (addr_reg == NULL) {
		retval = -ENOMEM;
		goto err2;
	}

	if (!request_mem_region(data->start, resource_size(data), hcd_name)) {
		retval = -EBUSY;
		goto err3;
	}
	data_reg = ioremap(data->start, resource_size(data));
	if (data_reg == NULL) {
		retval = -ENOMEM;
		goto err4;
	}

	/* allocate and initialize hcd */
	hcd = usb_create_hcd(&isp1362_hc_driver, &pdev->dev, dev_name(&pdev->dev));
	if (!hcd) {
		retval = -ENOMEM;
		goto err5;
	}
	hcd->rsrc_start = data->start;
	isp1362_hcd = hcd_to_isp1362_hcd(hcd);
	isp1362_hcd->data_reg = data_reg;
	isp1362_hcd->addr_reg = addr_reg;

	isp1362_hcd->next_statechange = jiffies;
	spin_lock_init(&isp1362_hcd->lock);
	INIT_LIST_HEAD(&isp1362_hcd->async);
	INIT_LIST_HEAD(&isp1362_hcd->periodic);
	INIT_LIST_HEAD(&isp1362_hcd->isoc);
	INIT_LIST_HEAD(&isp1362_hcd->remove_list);
	isp1362_hcd->board = pdev->dev.platform_data;
#if USE_PLATFORM_DELAY
	if (!isp1362_hcd->board->delay) {
		dev_err(hcd->self.controller, "No platform delay function given\n");
		retval = -ENODEV;
		goto err6;
	}
#endif

	if (irq_res->flags & IORESOURCE_IRQ_HIGHEDGE)
		irq_flags |= IRQF_TRIGGER_RISING;
	if (irq_res->flags & IORESOURCE_IRQ_LOWEDGE)
		irq_flags |= IRQF_TRIGGER_FALLING;
	if (irq_res->flags & IORESOURCE_IRQ_HIGHLEVEL)
		irq_flags |= IRQF_TRIGGER_HIGH;
	if (irq_res->flags & IORESOURCE_IRQ_LOWLEVEL)
		irq_flags |= IRQF_TRIGGER_LOW;

	retval = usb_add_hcd(hcd, irq, irq_flags | IRQF_DISABLED | IRQF_SHARED);
	if (retval != 0)
		goto err6;
	pr_info("%s, irq %d\n", hcd->product_desc, irq);

	create_debug_file(isp1362_hcd);

	return 0;

 err6:
	DBG(0, "%s: Freeing dev %p\n", __func__, isp1362_hcd);
	usb_put_hcd(hcd);
 err5:
	DBG(0, "%s: Unmapping data_reg @ %p\n", __func__, data_reg);
	iounmap(data_reg);
 err4:
	DBG(0, "%s: Releasing mem region %08lx\n", __func__, (long unsigned int)data->start);
	release_mem_region(data->start, resource_size(data));
 err3:
	DBG(0, "%s: Unmapping addr_reg @ %p\n", __func__, addr_reg);
	iounmap(addr_reg);
 err2:
	DBG(0, "%s: Releasing mem region %08lx\n", __func__, (long unsigned int)addr->start);
	release_mem_region(addr->start, resource_size(addr));
 err1:
	pr_err("%s: init error, %d\n", __func__, retval);

	return retval;
}

#ifdef	CONFIG_PM
static int isp1362_suspend(struct platform_device *pdev, pm_message_t state)
{
	struct usb_hcd *hcd = platform_get_drvdata(pdev);
	struct isp1362_hcd *isp1362_hcd = hcd_to_isp1362_hcd(hcd);
	unsigned long flags;
	int retval = 0;

	DBG(0, "%s: Suspending device\n", __func__);

	if (state.event == PM_EVENT_FREEZE) {
		DBG(0, "%s: Suspending root hub\n", __func__);
		retval = isp1362_bus_suspend(hcd);
	} else {
		DBG(0, "%s: Suspending RH ports\n", __func__);
		spin_lock_irqsave(&isp1362_hcd->lock, flags);
		isp1362_write_reg32(isp1362_hcd, HCRHSTATUS, RH_HS_LPS);
		spin_unlock_irqrestore(&isp1362_hcd->lock, flags);
	}
	if (retval == 0)
		pdev->dev.power.power_state = state;
	return retval;
}

static int isp1362_resume(struct platform_device *pdev)
{
	struct usb_hcd *hcd = platform_get_drvdata(pdev);
	struct isp1362_hcd *isp1362_hcd = hcd_to_isp1362_hcd(hcd);
	unsigned long flags;

	DBG(0, "%s: Resuming\n", __func__);

	if (pdev->dev.power.power_state.event == PM_EVENT_SUSPEND) {
		DBG(0, "%s: Resume RH ports\n", __func__);
		spin_lock_irqsave(&isp1362_hcd->lock, flags);
		isp1362_write_reg32(isp1362_hcd, HCRHSTATUS, RH_HS_LPSC);
		spin_unlock_irqrestore(&isp1362_hcd->lock, flags);
		return 0;
	}

	pdev->dev.power.power_state = PMSG_ON;

	return isp1362_bus_resume(isp1362_hcd_to_hcd(isp1362_hcd));
}
#else
#define	isp1362_suspend	NULL
#define	isp1362_resume	NULL
#endif

static struct platform_driver isp1362_driver = {
	.probe = isp1362_probe,
	.remove = __devexit_p(isp1362_remove),

	.suspend = isp1362_suspend,
	.resume = isp1362_resume,
	.driver = {
		.name = (char *)hcd_name,
		.owner = THIS_MODULE,
	},
};

/*-------------------------------------------------------------------------*/

static int __init isp1362_init(void)
{
	if (usb_disabled())
		return -ENODEV;
	pr_info("driver %s, %s\n", hcd_name, DRIVER_VERSION);
	return platform_driver_register(&isp1362_driver);
}
module_init(isp1362_init);

static void __exit isp1362_cleanup(void)
{
	platform_driver_unregister(&isp1362_driver);
}
module_exit(isp1362_cleanup);
