/*
* Host Controller Driver for the Elan Digital Systems U132 adapter
*
* Copyright(C) 2006 Elan Digital Systems Limited
* http://www.elandigitalsystems.com
*
* Author and Maintainer - Tony Olech - Elan Digital Systems
* tony.olech@elandigitalsystems.com
*
* This program is free software;you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation, version 2.
*
*
* This driver was written by Tony Olech(tony.olech@elandigitalsystems.com)
* based on various USB host drivers in the 2.6.15 linux kernel
* with constant reference to the 3rd Edition of Linux Device Drivers
* published by O'Reilly
*
* The U132 adapter is a USB to CardBus adapter specifically designed
* for PC cards that contain an OHCI host controller. Typical PC cards
* are the Orange Mobile 3G Option GlobeTrotter Fusion card.
*
* The U132 adapter will *NOT *work with PC cards that do not contain
* an OHCI controller. A simple way to test whether a PC card has an
* OHCI controller as an interface is to insert the PC card directly
* into a laptop(or desktop) with a CardBus slot and if "lspci" shows
* a new USB controller and "lsusb -v" shows a new OHCI Host Controller
* then there is a good chance that the U132 adapter will support the
* PC card.(you also need the specific client driver for the PC card)
*
* Please inform the Author and Maintainer about any PC cards that
* contain OHCI Host Controller and work when directly connected to
* an embedded CardBus slot but do not work when they are connected
* via an ELAN U132 adapter.
*
*/
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/moduleparam.h>
#include <linux/delay.h>
#include <linux/ioport.h>
#include <linux/pci_ids.h>
#include <linux/sched.h>
#include <linux/slab.h>
#include <linux/errno.h>
#include <linux/init.h>
#include <linux/timer.h>
#include <linux/list.h>
#include <linux/interrupt.h>
#include <linux/usb.h>
#include <linux/workqueue.h>
#include <linux/platform_device.h>
#include <linux/mutex.h>
#include <asm/io.h>
#include <asm/irq.h>
#include <asm/system.h>
#include <asm/byteorder.h>
#include "../core/hcd.h"

	/* FIXME ohci.h is ONLY for internal use by the OHCI driver.
	 * If you're going to try stuff like this, you need to split
	 * out shareable stuff (register declarations?) into its own
	 * file, maybe name <linux/usb/ohci.h>
	 */

#include "ohci.h"
#define OHCI_CONTROL_INIT OHCI_CTRL_CBSR
#define OHCI_INTR_INIT (OHCI_INTR_MIE | OHCI_INTR_UE | OHCI_INTR_RD | \
	OHCI_INTR_WDH)
MODULE_AUTHOR("Tony Olech - Elan Digital Systems Limited");
MODULE_DESCRIPTION("U132 USB Host Controller Driver");
MODULE_LICENSE("GPL");
#define INT_MODULE_PARM(n, v) static int n = v;module_param(n, int, 0444)
INT_MODULE_PARM(testing, 0);
/* Some boards misreport power switching/overcurrent*/
static int distrust_firmware = 1;
module_param(distrust_firmware, bool, 0);
MODULE_PARM_DESC(distrust_firmware, "true to distrust firmware power/overcurren"
	"t setup");
static DECLARE_WAIT_QUEUE_HEAD(u132_hcd_wait);
/*
* u132_module_lock exists to protect access to global variables
*
*/
static struct mutex u132_module_lock;
static int u132_exiting;
static int u132_instances;
static struct list_head u132_static_list;
/*
* end of the global variables protected by u132_module_lock
*/
static struct workqueue_struct *workqueue;
#define MAX_U132_PORTS 7
#define MAX_U132_ADDRS 128
#define MAX_U132_UDEVS 4
#define MAX_U132_ENDPS 100
#define MAX_U132_RINGS 4
static const char *cc_to_text[16] = {
	"No Error ",
	"CRC Error ",
	"Bit Stuff ",
	"Data Togg ",
	"Stall ",
	"DevNotResp ",
	"PIDCheck ",
	"UnExpPID ",
	"DataOver ",
	"DataUnder ",
	"(for hw) ",
	"(for hw) ",
	"BufferOver ",
	"BuffUnder ",
	"(for HCD) ",
	"(for HCD) "
};
struct u132_port {
	struct u132 *u132;
	int reset;
	int enable;
	int power;
	int Status;
};
struct u132_addr {
	u8 address;
};
struct u132_udev {
	struct kref kref;
	struct usb_device *usb_device;
	u8 enumeration;
	u8 udev_number;
	u8 usb_addr;
	u8 portnumber;
	u8 endp_number_in[16];
	u8 endp_number_out[16];
};
#define ENDP_QUEUE_SHIFT 3
#define ENDP_QUEUE_SIZE (1<<ENDP_QUEUE_SHIFT)
#define ENDP_QUEUE_MASK (ENDP_QUEUE_SIZE-1)
struct u132_urbq {
	struct list_head urb_more;
	struct urb *urb;
};
struct u132_spin {
	spinlock_t slock;
};
struct u132_endp {
	struct kref kref;
	u8 udev_number;
	u8 endp_number;
	u8 usb_addr;
	u8 usb_endp;
	struct u132 *u132;
	struct list_head endp_ring;
	struct u132_ring *ring;
	unsigned toggle_bits:2;
	unsigned active:1;
	unsigned delayed:1;
	unsigned input:1;
	unsigned output:1;
	unsigned pipetype:2;
	unsigned dequeueing:1;
	unsigned edset_flush:1;
	unsigned spare_bits:14;
	unsigned long jiffies;
	struct usb_host_endpoint *hep;
	struct u132_spin queue_lock;
	u16 queue_size;
	u16 queue_last;
	u16 queue_next;
	struct urb *urb_list[ENDP_QUEUE_SIZE];
	struct list_head urb_more;
	struct delayed_work scheduler;
};
struct u132_ring {
	unsigned in_use:1;
	unsigned length:7;
	u8 number;
	struct u132 *u132;
	struct u132_endp *curr_endp;
	struct delayed_work scheduler;
};
struct u132 {
	struct kref kref;
	struct list_head u132_list;
	struct mutex sw_lock;
	struct mutex scheduler_lock;
	struct u132_platform_data *board;
	struct platform_device *platform_dev;
	struct u132_ring ring[MAX_U132_RINGS];
	int sequence_num;
	int going;
	int power;
	int reset;
	int num_ports;
	u32 hc_control;
	u32 hc_fminterval;
	u32 hc_roothub_status;
	u32 hc_roothub_a;
	u32 hc_roothub_portstatus[MAX_ROOT_PORTS];
	int flags;
	unsigned long next_statechange;
	struct delayed_work monitor;
	int num_endpoints;
	struct u132_addr addr[MAX_U132_ADDRS];
	struct u132_udev udev[MAX_U132_UDEVS];
	struct u132_port port[MAX_U132_PORTS];
	struct u132_endp *endp[MAX_U132_ENDPS];
};

/*
* these cannot be inlines because we need the structure offset!!
* Does anyone have a better way?????
*/
#define ftdi_read_pcimem(pdev, member, data) usb_ftdi_elan_read_pcimem(pdev, \
	offsetof(struct ohci_regs, member), 0, data);
#define ftdi_write_pcimem(pdev, member, data) usb_ftdi_elan_write_pcimem(pdev, \
	offsetof(struct ohci_regs, member), 0, data);
#define u132_read_pcimem(u132, member, data) \
	usb_ftdi_elan_read_pcimem(u132->platform_dev, offsetof(struct \
	ohci_regs, member), 0, data);
#define u132_write_pcimem(u132, member, data) \
	usb_ftdi_elan_write_pcimem(u132->platform_dev, offsetof(struct \
	ohci_regs, member), 0, data);
static inline struct u132 *udev_to_u132(struct u132_udev *udev)
{
	u8 udev_number = udev->udev_number;
	return container_of(udev, struct u132, udev[udev_number]);
}

static inline struct u132 *hcd_to_u132(struct usb_hcd *hcd)
{
	return (struct u132 *)(hcd->hcd_priv);
}

static inline struct usb_hcd *u132_to_hcd(struct u132 *u132)
{
	return container_of((void *)u132, struct usb_hcd, hcd_priv);
}

static inline void u132_disable(struct u132 *u132)
{
	u132_to_hcd(u132)->state = HC_STATE_HALT;
}


#define kref_to_u132(d) container_of(d, struct u132, kref)
#define kref_to_u132_endp(d) container_of(d, struct u132_endp, kref)
#define kref_to_u132_udev(d) container_of(d, struct u132_udev, kref)
#include "../misc/usb_u132.h"
static const char hcd_name[] = "u132_hcd";
#define PORT_C_MASK ((USB_PORT_STAT_C_CONNECTION | USB_PORT_STAT_C_ENABLE | \
	USB_PORT_STAT_C_SUSPEND | USB_PORT_STAT_C_OVERCURRENT | \
	USB_PORT_STAT_C_RESET) << 16)
static void u132_hcd_delete(struct kref *kref)
{
	struct u132 *u132 = kref_to_u132(kref);
	struct platform_device *pdev = u132->platform_dev;
	struct usb_hcd *hcd = u132_to_hcd(u132);
	u132->going += 1;
	mutex_lock(&u132_module_lock);
	list_del_init(&u132->u132_list);
	u132_instances -= 1;
	mutex_unlock(&u132_module_lock);
	dev_warn(&u132->platform_dev->dev, "FREEING the hcd=%p and thus the u13"
		"2=%p going=%d pdev=%p\n", hcd, u132, u132->going, pdev);
	usb_put_hcd(hcd);
}

static inline void u132_u132_put_kref(struct u132 *u132)
{
	kref_put(&u132->kref, u132_hcd_delete);
}

static inline void u132_u132_init_kref(struct u132 *u132)
{
	kref_init(&u132->kref);
}

static void u132_udev_delete(struct kref *kref)
{
	struct u132_udev *udev = kref_to_u132_udev(kref);
	udev->udev_number = 0;
	udev->usb_device = NULL;
	udev->usb_addr = 0;
	udev->enumeration = 0;
}

static inline void u132_udev_put_kref(struct u132 *u132, struct u132_udev *udev)
{
	kref_put(&udev->kref, u132_udev_delete);
}

static inline void u132_udev_get_kref(struct u132 *u132, struct u132_udev *udev)
{
	kref_get(&udev->kref);
}

static inline void u132_udev_init_kref(struct u132 *u132,
	struct u132_udev *udev)
{
	kref_init(&udev->kref);
}

static inline void u132_ring_put_kref(struct u132 *u132, struct u132_ring *ring)
{
	kref_put(&u132->kref, u132_hcd_delete);
}

static void u132_ring_requeue_work(struct u132 *u132, struct u132_ring *ring,
	unsigned int delta)
{
	if (delta > 0) {
		if (queue_delayed_work(workqueue, &ring->scheduler, delta))
			return;
	} else if (queue_delayed_work(workqueue, &ring->scheduler, 0))
		return;
	kref_put(&u132->kref, u132_hcd_delete);
	return;
}

static void u132_ring_queue_work(struct u132 *u132, struct u132_ring *ring,
	unsigned int delta)
{
	kref_get(&u132->kref);
	u132_ring_requeue_work(u132, ring, delta);
	return;
}

static void u132_ring_cancel_work(struct u132 *u132, struct u132_ring *ring)
{
	if (cancel_delayed_work(&ring->scheduler))
		kref_put(&u132->kref, u132_hcd_delete);
}

static void u132_endp_delete(struct kref *kref)
{
	struct u132_endp *endp = kref_to_u132_endp(kref);
	struct u132 *u132 = endp->u132;
	u8 usb_addr = endp->usb_addr;
	u8 usb_endp = endp->usb_endp;
	u8 address = u132->addr[usb_addr].address;
	struct u132_udev *udev = &u132->udev[address];
	u8 endp_number = endp->endp_number;
	struct usb_host_endpoint *hep = endp->hep;
	struct u132_ring *ring = endp->ring;
	struct list_head *head = &endp->endp_ring;
	ring->length -= 1;
	if (endp == ring->curr_endp) {
		if (list_empty(head)) {
			ring->curr_endp = NULL;
			list_del(head);
		} else {
			struct u132_endp *next_endp = list_entry(head->next,
				struct u132_endp, endp_ring);
			ring->curr_endp = next_endp;
			list_del(head);
		}
	} else
		list_del(head);
	if (endp->input) {
		udev->endp_number_in[usb_endp] = 0;
		u132_udev_put_kref(u132, udev);
	}
	if (endp->output) {
		udev->endp_number_out[usb_endp] = 0;
		u132_udev_put_kref(u132, udev);
	}
	u132->endp[endp_number - 1] = NULL;
	hep->hcpriv = NULL;
	kfree(endp);
	u132_u132_put_kref(u132);
}

static inline void u132_endp_put_kref(struct u132 *u132, struct u132_endp *endp)
{
	kref_put(&endp->kref, u132_endp_delete);
}

static inline void u132_endp_get_kref(struct u132 *u132, struct u132_endp *endp)
{
	kref_get(&endp->kref);
}

static inline void u132_endp_init_kref(struct u132 *u132,
	struct u132_endp *endp)
{
	kref_init(&endp->kref);
	kref_get(&u132->kref);
}

static void u132_endp_queue_work(struct u132 *u132, struct u132_endp *endp,
	unsigned int delta)
{
	if (queue_delayed_work(workqueue, &endp->scheduler, delta))
		kref_get(&endp->kref);
}

static void u132_endp_cancel_work(struct u132 *u132, struct u132_endp *endp)
{
	if (cancel_delayed_work(&endp->scheduler))
		kref_put(&endp->kref, u132_endp_delete);
}

static inline void u132_monitor_put_kref(struct u132 *u132)
{
	kref_put(&u132->kref, u132_hcd_delete);
}

static void u132_monitor_queue_work(struct u132 *u132, unsigned int delta)
{
	if (queue_delayed_work(workqueue, &u132->monitor, delta))
		kref_get(&u132->kref);
}

static void u132_monitor_requeue_work(struct u132 *u132, unsigned int delta)
{
	if (!queue_delayed_work(workqueue, &u132->monitor, delta))
		kref_put(&u132->kref, u132_hcd_delete);
}

static void u132_monitor_cancel_work(struct u132 *u132)
{
	if (cancel_delayed_work(&u132->monitor))
		kref_put(&u132->kref, u132_hcd_delete);
}

static int read_roothub_info(struct u132 *u132)
{
	u32 revision;
	int retval;
	retval = u132_read_pcimem(u132, revision, &revision);
	if (retval) {
		dev_err(&u132->platform_dev->dev, "error %d accessing device co"
			"ntrol\n", retval);
		return retval;
	} else if ((revision & 0xFF) == 0x10) {
	} else if ((revision & 0xFF) == 0x11) {
	} else {
		dev_err(&u132->platform_dev->dev, "device revision is not valid"
			" %08X\n", revision);
		return -ENODEV;
	}
	retval = u132_read_pcimem(u132, control, &u132->hc_control);
	if (retval) {
		dev_err(&u132->platform_dev->dev, "error %d accessing device co"
			"ntrol\n", retval);
		return retval;
	}
	retval = u132_read_pcimem(u132, roothub.status,
		&u132->hc_roothub_status);
	if (retval) {
		dev_err(&u132->platform_dev->dev, "error %d accessing device re"
			"g roothub.status\n", retval);
		return retval;
	}
	retval = u132_read_pcimem(u132, roothub.a, &u132->hc_roothub_a);
	if (retval) {
		dev_err(&u132->platform_dev->dev, "error %d accessing device re"
			"g roothub.a\n", retval);
		return retval;
	}
	{
		int I = u132->num_ports;
		int i = 0;
		while (I-- > 0) {
			retval = u132_read_pcimem(u132, roothub.portstatus[i],
				&u132->hc_roothub_portstatus[i]);
			if (retval) {
				dev_err(&u132->platform_dev->dev, "error %d acc"
					"essing device roothub.portstatus[%d]\n"
					, retval, i);
				return retval;
			} else
				i += 1;
		}
	}
	return 0;
}

static void u132_hcd_monitor_work(struct work_struct *work)
{
	struct u132 *u132 = container_of(work, struct u132, monitor.work);
	if (u132->going > 1) {
		dev_err(&u132->platform_dev->dev, "device has been removed %d\n"
			, u132->going);
		u132_monitor_put_kref(u132);
		return;
	} else if (u132->going > 0) {
		dev_err(&u132->platform_dev->dev, "device is being removed\n");
		u132_monitor_put_kref(u132);
		return;
	} else {
		int retval;
		mutex_lock(&u132->sw_lock);
		retval = read_roothub_info(u132);
		if (retval) {
			struct usb_hcd *hcd = u132_to_hcd(u132);
			u132_disable(u132);
			u132->going = 1;
			mutex_unlock(&u132->sw_lock);
			usb_hc_died(hcd);
			ftdi_elan_gone_away(u132->platform_dev);
			u132_monitor_put_kref(u132);
			return;
		} else {
			u132_monitor_requeue_work(u132, 500);
			mutex_unlock(&u132->sw_lock);
			return;
		}
	}
}

static void u132_hcd_giveback_urb(struct u132 *u132, struct u132_endp *endp,
	struct urb *urb, int status)
{
	struct u132_ring *ring;
	unsigned long irqs;
	struct usb_hcd *hcd = u132_to_hcd(u132);
	urb->error_count = 0;
	spin_lock_irqsave(&endp->queue_lock.slock, irqs);
	usb_hcd_unlink_urb_from_ep(hcd, urb);
	endp->queue_next += 1;
	if (ENDP_QUEUE_SIZE > --endp->queue_size) {
		endp->active = 0;
		spin_unlock_irqrestore(&endp->queue_lock.slock, irqs);
	} else {
		struct list_head *next = endp->urb_more.next;
		struct u132_urbq *urbq = list_entry(next, struct u132_urbq,
			urb_more);
		list_del(next);
		endp->urb_list[ENDP_QUEUE_MASK & endp->queue_last++] =
			urbq->urb;
		endp->active = 0;
		spin_unlock_irqrestore(&endp->queue_lock.slock, irqs);
		kfree(urbq);
	}
	mutex_lock(&u132->scheduler_lock);
	ring = endp->ring;
	ring->in_use = 0;
	u132_ring_cancel_work(u132, ring);
	u132_ring_queue_work(u132, ring, 0);
	mutex_unlock(&u132->scheduler_lock);
	u132_endp_put_kref(u132, endp);
	usb_hcd_giveback_urb(hcd, urb, status);
	return;
}

static void u132_hcd_forget_urb(struct u132 *u132, struct u132_endp *endp,
	struct urb *urb, int status)
{
	u132_endp_put_kref(u132, endp);
}

static void u132_hcd_abandon_urb(struct u132 *u132, struct u132_endp *endp,
	struct urb *urb, int status)
{
	unsigned long irqs;
	struct usb_hcd *hcd = u132_to_hcd(u132);
	urb->error_count = 0;
	spin_lock_irqsave(&endp->queue_lock.slock, irqs);
	usb_hcd_unlink_urb_from_ep(hcd, urb);
	endp->queue_next += 1;
	if (ENDP_QUEUE_SIZE > --endp->queue_size) {
		endp->active = 0;
		spin_unlock_irqrestore(&endp->queue_lock.slock, irqs);
	} else {
		struct list_head *next = endp->urb_more.next;
		struct u132_urbq *urbq = list_entry(next, struct u132_urbq,
			urb_more);
		list_del(next);
		endp->urb_list[ENDP_QUEUE_MASK & endp->queue_last++] =
			urbq->urb;
		endp->active = 0;
		spin_unlock_irqrestore(&endp->queue_lock.slock, irqs);
		kfree(urbq);
	} usb_hcd_giveback_urb(hcd, urb, status);
	return;
}

static inline int edset_input(struct u132 *u132, struct u132_ring *ring,
	struct u132_endp *endp, struct urb *urb, u8 address, u8 toggle_bits,
	void (*callback) (void *endp, struct urb *urb, u8 *buf, int len,
	int toggle_bits, int error_count, int condition_code, int repeat_number,
	 int halted, int skipped, int actual, int non_null))
{
	return usb_ftdi_elan_edset_input(u132->platform_dev, ring->number, endp,
		 urb, address, endp->usb_endp, toggle_bits, callback);
}

static inline int edset_setup(struct u132 *u132, struct u132_ring *ring,
	struct u132_endp *endp, struct urb *urb, u8 address, u8 toggle_bits,
	void (*callback) (void *endp, struct urb *urb, u8 *buf, int len,
	int toggle_bits, int error_count, int condition_code, int repeat_number,
	 int halted, int skipped, int actual, int non_null))
{
	return usb_ftdi_elan_edset_setup(u132->platform_dev, ring->number, endp,
		 urb, address, endp->usb_endp, toggle_bits, callback);
}

static inline int edset_single(struct u132 *u132, struct u132_ring *ring,
	struct u132_endp *endp, struct urb *urb, u8 address, u8 toggle_bits,
	void (*callback) (void *endp, struct urb *urb, u8 *buf, int len,
	int toggle_bits, int error_count, int condition_code, int repeat_number,
	 int halted, int skipped, int actual, int non_null))
{
	return usb_ftdi_elan_edset_single(u132->platform_dev, ring->number,
		endp, urb, address, endp->usb_endp, toggle_bits, callback);
}

static inline int edset_output(struct u132 *u132, struct u132_ring *ring,
	struct u132_endp *endp, struct urb *urb, u8 address, u8 toggle_bits,
	void (*callback) (void *endp, struct urb *urb, u8 *buf, int len,
	int toggle_bits, int error_count, int condition_code, int repeat_number,
	 int halted, int skipped, int actual, int non_null))
{
	return usb_ftdi_elan_edset_output(u132->platform_dev, ring->number,
		endp, urb, address, endp->usb_endp, toggle_bits, callback);
}


/*
* must not LOCK sw_lock
*
*/
static void u132_hcd_interrupt_recv(void *data, struct urb *urb, u8 *buf,
	int len, int toggle_bits, int error_count, int condition_code,
	int repeat_number, int halted, int skipped, int actual, int non_null)
{
	struct u132_endp *endp = data;
	struct u132 *u132 = endp->u132;
	u8 address = u132->addr[endp->usb_addr].address;
	struct u132_udev *udev = &u132->udev[address];
	mutex_lock(&u132->scheduler_lock);
	if (u132->going > 1) {
		dev_err(&u132->platform_dev->dev, "device has been removed %d\n"
			, u132->going);
		mutex_unlock(&u132->scheduler_lock);
		u132_hcd_forget_urb(u132, endp, urb, -ENODEV);
		return;
	} else if (endp->dequeueing) {
		endp->dequeueing = 0;
		mutex_unlock(&u132->scheduler_lock);
		u132_hcd_giveback_urb(u132, endp, urb, -EINTR);
		return;
	} else if (u132->going > 0) {
		dev_err(&u132->platform_dev->dev, "device is being removed "
				"urb=%p\n", urb);
		mutex_unlock(&u132->scheduler_lock);
		u132_hcd_giveback_urb(u132, endp, urb, -ENODEV);
		return;
	} else if (!urb->unlinked) {
		struct u132_ring *ring = endp->ring;
		u8 *u = urb->transfer_buffer + urb->actual_length;
		u8 *b = buf;
		int L = len;

		while (L-- > 0)
			*u++ = *b++;

		urb->actual_length += len;
		if ((condition_code == TD_CC_NOERROR) &&
			(urb->transfer_buffer_length > urb->actual_length)) {
			endp->toggle_bits = toggle_bits;
			usb_settoggle(udev->usb_device, endp->usb_endp, 0,
				1 & toggle_bits);
			if (urb->actual_length > 0) {
				int retval;
				mutex_unlock(&u132->scheduler_lock);
				retval = edset_single(u132, ring, endp, urb,
					address, endp->toggle_bits,
					u132_hcd_interrupt_recv);
				if (retval != 0)
					u132_hcd_giveback_urb(u132, endp, urb,
						retval);
			} else {
				ring->in_use = 0;
				endp->active = 0;
				endp->jiffies = jiffies +
					msecs_to_jiffies(urb->interval);
				u132_ring_cancel_work(u132, ring);
				u132_ring_queue_work(u132, ring, 0);
				mutex_unlock(&u132->scheduler_lock);
				u132_endp_put_kref(u132, endp);
			}
			return;
		} else if ((condition_code == TD_DATAUNDERRUN) &&
			((urb->transfer_flags & URB_SHORT_NOT_OK) == 0)) {
			endp->toggle_bits = toggle_bits;
			usb_settoggle(udev->usb_device, endp->usb_endp, 0,
				1 & toggle_bits);
			mutex_unlock(&u132->scheduler_lock);
			u132_hcd_giveback_urb(u132, endp, urb, 0);
			return;
		} else {
			if (condition_code == TD_CC_NOERROR) {
				endp->toggle_bits = toggle_bits;
				usb_settoggle(udev->usb_device, endp->usb_endp,
					0, 1 & toggle_bits);
			} else if (condition_code == TD_CC_STALL) {
				endp->toggle_bits = 0x2;
				usb_settoggle(udev->usb_device, endp->usb_endp,
					0, 0);
			} else {
				endp->toggle_bits = 0x2;
				usb_settoggle(udev->usb_device, endp->usb_endp,
					0, 0);
				dev_err(&u132->platform_dev->dev, "urb=%p givin"
					"g back INTERRUPT %s\n", urb,
					cc_to_text[condition_code]);
			}
			mutex_unlock(&u132->scheduler_lock);
			u132_hcd_giveback_urb(u132, endp, urb,
				cc_to_error[condition_code]);
			return;
		}
	} else {
		dev_err(&u132->platform_dev->dev, "CALLBACK called urb=%p "
				"unlinked=%d\n", urb, urb->unlinked);
		mutex_unlock(&u132->scheduler_lock);
		u132_hcd_giveback_urb(u132, endp, urb, 0);
		return;
	}
}

static void u132_hcd_bulk_output_sent(void *data, struct urb *urb, u8 *buf,
	int len, int toggle_bits, int error_count, int condition_code,
	int repeat_number, int halted, int skipped, int actual, int non_null)
{
	struct u132_endp *endp = data;
	struct u132 *u132 = endp->u132;
	u8 address = u132->addr[endp->usb_addr].address;
	mutex_lock(&u132->scheduler_lock);
	if (u132->going > 1) {
		dev_err(&u132->platform_dev->dev, "device has been removed %d\n"
			, u132->going);
		mutex_unlock(&u132->scheduler_lock);
		u132_hcd_forget_urb(u132, endp, urb, -ENODEV);
		return;
	} else if (endp->dequeueing) {
		endp->dequeueing = 0;
		mutex_unlock(&u132->scheduler_lock);
		u132_hcd_giveback_urb(u132, endp, urb, -EINTR);
		return;
	} else if (u132->going > 0) {
		dev_err(&u132->platform_dev->dev, "device is being removed "
				"urb=%p\n", urb);
		mutex_unlock(&u132->scheduler_lock);
		u132_hcd_giveback_urb(u132, endp, urb, -ENODEV);
		return;
	} else if (!urb->unlinked) {
		struct u132_ring *ring = endp->ring;
		urb->actual_length += len;
		endp->toggle_bits = toggle_bits;
		if (urb->transfer_buffer_length > urb->actual_length) {
			int retval;
			mutex_unlock(&u132->scheduler_lock);
			retval = edset_output(u132, ring, endp, urb, address,
				endp->toggle_bits, u132_hcd_bulk_output_sent);
			if (retval != 0)
				u132_hcd_giveback_urb(u132, endp, urb, retval);
			return;
		} else {
			mutex_unlock(&u132->scheduler_lock);
			u132_hcd_giveback_urb(u132, endp, urb, 0);
			return;
		}
	} else {
		dev_err(&u132->platform_dev->dev, "CALLBACK called urb=%p "
				"unlinked=%d\n", urb, urb->unlinked);
		mutex_unlock(&u132->scheduler_lock);
		u132_hcd_giveback_urb(u132, endp, urb, 0);
		return;
	}
}

static void u132_hcd_bulk_input_recv(void *data, struct urb *urb, u8 *buf,
	int len, int toggle_bits, int error_count, int condition_code,
	int repeat_number, int halted, int skipped, int actual, int non_null)
{
	struct u132_endp *endp = data;
	struct u132 *u132 = endp->u132;
	u8 address = u132->addr[endp->usb_addr].address;
	struct u132_udev *udev = &u132->udev[address];
	mutex_lock(&u132->scheduler_lock);
	if (u132->going > 1) {
		dev_err(&u132->platform_dev->dev, "device has been removed %d\n"
			, u132->going);
		mutex_unlock(&u132->scheduler_lock);
		u132_hcd_forget_urb(u132, endp, urb, -ENODEV);
		return;
	} else if (endp->dequeueing) {
		endp->dequeueing = 0;
		mutex_unlock(&u132->scheduler_lock);
		u132_hcd_giveback_urb(u132, endp, urb, -EINTR);
		return;
	} else if (u132->going > 0) {
		dev_err(&u132->platform_dev->dev, "device is being removed "
				"urb=%p\n", urb);
		mutex_unlock(&u132->scheduler_lock);
		u132_hcd_giveback_urb(u132, endp, urb, -ENODEV);
		return;
	} else if (!urb->unlinked) {
		struct u132_ring *ring = endp->ring;
		u8 *u = urb->transfer_buffer + urb->actual_length;
		u8 *b = buf;
		int L = len;

		while (L-- > 0)
			*u++ = *b++;

		urb->actual_length += len;
		if ((condition_code == TD_CC_NOERROR) &&
			(urb->transfer_buffer_length > urb->actual_length)) {
			int retval;
			endp->toggle_bits = toggle_bits;
			usb_settoggle(udev->usb_device, endp->usb_endp, 0,
				1 & toggle_bits);
			mutex_unlock(&u132->scheduler_lock);
			retval = usb_ftdi_elan_edset_input(u132->platform_dev,
				ring->number, endp, urb, address,
				endp->usb_endp, endp->toggle_bits,
				u132_hcd_bulk_input_recv);
			if (retval != 0)
				u132_hcd_giveback_urb(u132, endp, urb, retval);
			return;
		} else if (condition_code == TD_CC_NOERROR) {
			endp->toggle_bits = toggle_bits;
			usb_settoggle(udev->usb_device, endp->usb_endp, 0,
				1 & toggle_bits);
			mutex_unlock(&u132->scheduler_lock);
			u132_hcd_giveback_urb(u132, endp, urb,
				cc_to_error[condition_code]);
			return;
		} else if ((condition_code == TD_DATAUNDERRUN) &&
			((urb->transfer_flags & URB_SHORT_NOT_OK) == 0)) {
			endp->toggle_bits = toggle_bits;
			usb_settoggle(udev->usb_device, endp->usb_endp, 0,
				1 & toggle_bits);
			mutex_unlock(&u132->scheduler_lock);
			u132_hcd_giveback_urb(u132, endp, urb, 0);
			return;
		} else if (condition_code == TD_DATAUNDERRUN) {
			endp->toggle_bits = toggle_bits;
			usb_settoggle(udev->usb_device, endp->usb_endp, 0,
				1 & toggle_bits);
			dev_warn(&u132->platform_dev->dev, "urb=%p(SHORT NOT OK"
				") giving back BULK IN %s\n", urb,
				cc_to_text[condition_code]);
			mutex_unlock(&u132->scheduler_lock);
			u132_hcd_giveback_urb(u132, endp, urb, 0);
			return;
		} else if (condition_code == TD_CC_STALL) {
			endp->toggle_bits = 0x2;
			usb_settoggle(udev->usb_device, endp->usb_endp, 0, 0);
			mutex_unlock(&u132->scheduler_lock);
			u132_hcd_giveback_urb(u132, endp, urb,
				cc_to_error[condition_code]);
			return;
		} else {
			endp->toggle_bits = 0x2;
			usb_settoggle(udev->usb_device, endp->usb_endp, 0, 0);
			dev_err(&u132->platform_dev->dev, "urb=%p giving back B"
				"ULK IN code=%d %s\n", urb, condition_code,
				cc_to_text[condition_code]);
			mutex_unlock(&u132->scheduler_lock);
			u132_hcd_giveback_urb(u132, endp, urb,
				cc_to_error[condition_code]);
			return;
		}
	} else {
		dev_err(&u132->platform_dev->dev, "CALLBACK called urb=%p "
				"unlinked=%d\n", urb, urb->unlinked);
		mutex_unlock(&u132->scheduler_lock);
		u132_hcd_giveback_urb(u132, endp, urb, 0);
		return;
	}
}

static void u132_hcd_configure_empty_sent(void *data, struct urb *urb, u8 *buf,
	int len, int toggle_bits, int error_count, int condition_code,
	int repeat_number, int halted, int skipped, int actual, int non_null)
{
	struct u132_endp *endp = data;
	struct u132 *u132 = endp->u132;
	mutex_lock(&u132->scheduler_lock);
	if (u132->going > 1) {
		dev_err(&u132->platform_dev->dev, "device has been removed %d\n"
			, u132->going);
		mutex_unlock(&u132->scheduler_lock);
		u132_hcd_forget_urb(u132, endp, urb, -ENODEV);
		return;
	} else if (endp->dequeueing) {
		endp->dequeueing = 0;
		mutex_unlock(&u132->scheduler_lock);
		u132_hcd_giveback_urb(u132, endp, urb, -EINTR);
		return;
	} else if (u132->going > 0) {
		dev_err(&u132->platform_dev->dev, "device is being removed "
				"urb=%p\n", urb);
		mutex_unlock(&u132->scheduler_lock);
		u132_hcd_giveback_urb(u132, endp, urb, -ENODEV);
		return;
	} else if (!urb->unlinked) {
		mutex_unlock(&u132->scheduler_lock);
		u132_hcd_giveback_urb(u132, endp, urb, 0);
		return;
	} else {
		dev_err(&u132->platform_dev->dev, "CALLBACK called urb=%p "
				"unlinked=%d\n", urb, urb->unlinked);
		mutex_unlock(&u132->scheduler_lock);
		u132_hcd_giveback_urb(u132, endp, urb, 0);
		return;
	}
}

static void u132_hcd_configure_input_recv(void *data, struct urb *urb, u8 *buf,
	int len, int toggle_bits, int error_count, int condition_code,
	int repeat_number, int halted, int skipped, int actual, int non_null)
{
	struct u132_endp *endp = data;
	struct u132 *u132 = endp->u132;
	u8 address = u132->addr[endp->usb_addr].address;
	mutex_lock(&u132->scheduler_lock);
	if (u132->going > 1) {
		dev_err(&u132->platform_dev->dev, "device has been removed %d\n"
			, u132->going);
		mutex_unlock(&u132->scheduler_lock);
		u132_hcd_forget_urb(u132, endp, urb, -ENODEV);
		return;
	} else if (endp->dequeueing) {
		endp->dequeueing = 0;
		mutex_unlock(&u132->scheduler_lock);
		u132_hcd_giveback_urb(u132, endp, urb, -EINTR);
		return;
	} else if (u132->going > 0) {
		dev_err(&u132->platform_dev->dev, "device is being removed "
				"urb=%p\n", urb);
		mutex_unlock(&u132->scheduler_lock);
		u132_hcd_giveback_urb(u132, endp, urb, -ENODEV);
		return;
	} else if (!urb->unlinked) {
		struct u132_ring *ring = endp->ring;
		u8 *u = urb->transfer_buffer;
		u8 *b = buf;
		int L = len;

		while (L-- > 0)
			*u++ = *b++;

		urb->actual_length = len;
		if ((condition_code == TD_CC_NOERROR) || ((condition_code ==
			TD_DATAUNDERRUN) && ((urb->transfer_flags &
			URB_SHORT_NOT_OK) == 0))) {
			int retval;
			mutex_unlock(&u132->scheduler_lock);
			retval = usb_ftdi_elan_edset_empty(u132->platform_dev,
				ring->number, endp, urb, address,
				endp->usb_endp, 0x3,
				u132_hcd_configure_empty_sent);
			if (retval != 0)
				u132_hcd_giveback_urb(u132, endp, urb, retval);
			return;
		} else if (condition_code == TD_CC_STALL) {
			mutex_unlock(&u132->scheduler_lock);
			dev_warn(&u132->platform_dev->dev, "giving back SETUP I"
				"NPUT STALL urb %p\n", urb);
			u132_hcd_giveback_urb(u132, endp, urb,
				cc_to_error[condition_code]);
			return;
		} else {
			mutex_unlock(&u132->scheduler_lock);
			dev_err(&u132->platform_dev->dev, "giving back SETUP IN"
				"PUT %s urb %p\n", cc_to_text[condition_code],
				urb);
			u132_hcd_giveback_urb(u132, endp, urb,
				cc_to_error[condition_code]);
			return;
		}
	} else {
		dev_err(&u132->platform_dev->dev, "CALLBACK called urb=%p "
				"unlinked=%d\n", urb, urb->unlinked);
		mutex_unlock(&u132->scheduler_lock);
		u132_hcd_giveback_urb(u132, endp, urb, 0);
		return;
	}
}

static void u132_hcd_configure_empty_recv(void *data, struct urb *urb, u8 *buf,
	int len, int toggle_bits, int error_count, int condition_code,
	int repeat_number, int halted, int skipped, int actual, int non_null)
{
	struct u132_endp *endp = data;
	struct u132 *u132 = endp->u132;
	mutex_lock(&u132->scheduler_lock);
	if (u132->going > 1) {
		dev_err(&u132->platform_dev->dev, "device has been removed %d\n"
			, u132->going);
		mutex_unlock(&u132->scheduler_lock);
		u132_hcd_forget_urb(u132, endp, urb, -ENODEV);
		return;
	} else if (endp->dequeueing) {
		endp->dequeueing = 0;
		mutex_unlock(&u132->scheduler_lock);
		u132_hcd_giveback_urb(u132, endp, urb, -EINTR);
		return;
	} else if (u132->going > 0) {
		dev_err(&u132->platform_dev->dev, "device is being removed "
				"urb=%p\n", urb);
		mutex_unlock(&u132->scheduler_lock);
		u132_hcd_giveback_urb(u132, endp, urb, -ENODEV);
		return;
	} else if (!urb->unlinked) {
		mutex_unlock(&u132->scheduler_lock);
		u132_hcd_giveback_urb(u132, endp, urb, 0);
		return;
	} else {
		dev_err(&u132->platform_dev->dev, "CALLBACK called urb=%p "
				"unlinked=%d\n", urb, urb->unlinked);
		mutex_unlock(&u132->scheduler_lock);
		u132_hcd_giveback_urb(u132, endp, urb, 0);
		return;
	}
}

static void u132_hcd_configure_setup_sent(void *data, struct urb *urb, u8 *buf,
	int len, int toggle_bits, int error_count, int condition_code,
	int repeat_number, int halted, int skipped, int actual, int non_null)
{
	struct u132_endp *endp = data;
	struct u132 *u132 = endp->u132;
	u8 address = u132->addr[endp->usb_addr].address;
	mutex_lock(&u132->scheduler_lock);
	if (u132->going > 1) {
		dev_err(&u132->platform_dev->dev, "device has been removed %d\n"
			, u132->going);
		mutex_unlock(&u132->scheduler_lock);
		u132_hcd_forget_urb(u132, endp, urb, -ENODEV);
		return;
	} else if (endp->dequeueing) {
		endp->dequeueing = 0;
		mutex_unlock(&u132->scheduler_lock);
		u132_hcd_giveback_urb(u132, endp, urb, -EINTR);
		return;
	} else if (u132->going > 0) {
		dev_err(&u132->platform_dev->dev, "device is being removed "
				"urb=%p\n", urb);
		mutex_unlock(&u132->scheduler_lock);
		u132_hcd_giveback_urb(u132, endp, urb, -ENODEV);
		return;
	} else if (!urb->unlinked) {
		if (usb_pipein(urb->pipe)) {
			int retval;
			struct u132_ring *ring = endp->ring;
			mutex_unlock(&u132->scheduler_lock);
			retval = usb_ftdi_elan_edset_input(u132->platform_dev,
				ring->number, endp, urb, address,
				endp->usb_endp, 0,
				u132_hcd_configure_input_recv);
			if (retval != 0)
				u132_hcd_giveback_urb(u132, endp, urb, retval);
			return;
		} else {
			int retval;
			struct u132_ring *ring = endp->ring;
			mutex_unlock(&u132->scheduler_lock);
			retval = usb_ftdi_elan_edset_input(u132->platform_dev,
				ring->number, endp, urb, address,
				endp->usb_endp, 0,
				u132_hcd_configure_empty_recv);
			if (retval != 0)
				u132_hcd_giveback_urb(u132, endp, urb, retval);
			return;
		}
	} else {
		dev_err(&u132->platform_dev->dev, "CALLBACK called urb=%p "
				"unlinked=%d\n", urb, urb->unlinked);
		mutex_unlock(&u132->scheduler_lock);
		u132_hcd_giveback_urb(u132, endp, urb, 0);
		return;
	}
}

static void u132_hcd_enumeration_empty_recv(void *data, struct urb *urb,
	u8 *buf, int len, int toggle_bits, int error_count, int condition_code,
	int repeat_number, int halted, int skipped, int actual, int non_null)
{
	struct u132_endp *endp = data;
	struct u132 *u132 = endp->u132;
	u8 address = u132->addr[endp->usb_addr].address;
	struct u132_udev *udev = &u132->udev[address];
	mutex_lock(&u132->scheduler_lock);
	if (u132->going > 1) {
		dev_err(&u132->platform_dev->dev, "device has been removed %d\n"
			, u132->going);
		mutex_unlock(&u132->scheduler_lock);
		u132_hcd_forget_urb(u132, endp, urb, -ENODEV);
		return;
	} else if (endp->dequeueing) {
		endp->dequeueing = 0;
		mutex_unlock(&u132->scheduler_lock);
		u132_hcd_giveback_urb(u132, endp, urb, -EINTR);
		return;
	} else if (u132->going > 0) {
		dev_err(&u132->platform_dev->dev, "device is being removed "
				"urb=%p\n", urb);
		mutex_unlock(&u132->scheduler_lock);
		u132_hcd_giveback_urb(u132, endp, urb, -ENODEV);
		return;
	} else if (!urb->unlinked) {
		u132->addr[0].address = 0;
		endp->usb_addr = udev->usb_addr;
		mutex_unlock(&u132->scheduler_lock);
		u132_hcd_giveback_urb(u132, endp, urb, 0);
		return;
	} else {
		dev_err(&u132->platform_dev->dev, "CALLBACK called urb=%p "
				"unlinked=%d\n", urb, urb->unlinked);
		mutex_unlock(&u132->scheduler_lock);
		u132_hcd_giveback_urb(u132, endp, urb, 0);
		return;
	}
}

static void u132_hcd_enumeration_address_sent(void *data, struct urb *urb,
	u8 *buf, int len, int toggle_bits, int error_count, int condition_code,
	int repeat_number, int halted, int skipped, int actual, int non_null)
{
	struct u132_endp *endp = data;
	struct u132 *u132 = endp->u132;
	mutex_lock(&u132->scheduler_lock);
	if (u132->going > 1) {
		dev_err(&u132->platform_dev->dev, "device has been removed %d\n"
			, u132->going);
		mutex_unlock(&u132->scheduler_lock);
		u132_hcd_forget_urb(u132, endp, urb, -ENODEV);
		return;
	} else if (endp->dequeueing) {
		endp->dequeueing = 0;
		mutex_unlock(&u132->scheduler_lock);
		u132_hcd_giveback_urb(u132, endp, urb, -EINTR);
		return;
	} else if (u132->going > 0) {
		dev_err(&u132->platform_dev->dev, "device is being removed "
				"urb=%p\n", urb);
		mutex_unlock(&u132->scheduler_lock);
		u132_hcd_giveback_urb(u132, endp, urb, -ENODEV);
		return;
	} else if (!urb->unlinked) {
		int retval;
		struct u132_ring *ring = endp->ring;
		mutex_unlock(&u132->scheduler_lock);
		retval = usb_ftdi_elan_edset_input(u132->platform_dev,
			ring->number, endp, urb, 0, endp->usb_endp, 0,
			u132_hcd_enumeration_empty_recv);
		if (retval != 0)
			u132_hcd_giveback_urb(u132, endp, urb, retval);
		return;
	} else {
		dev_err(&u132->platform_dev->dev, "CALLBACK called urb=%p "
				"unlinked=%d\n", urb, urb->unlinked);
		mutex_unlock(&u132->scheduler_lock);
		u132_hcd_giveback_urb(u132, endp, urb, 0);
		return;
	}
}

static void u132_hcd_initial_empty_sent(void *data, struct urb *urb, u8 *buf,
	int len, int toggle_bits, int error_count, int condition_code,
	int repeat_number, int halted, int skipped, int actual, int non_null)
{
	struct u132_endp *endp = data;
	struct u132 *u132 = endp->u132;
	mutex_lock(&u132->scheduler_lock);
	if (u132->going > 1) {
		dev_err(&u132->platform_dev->dev, "device has been removed %d\n"
			, u132->going);
		mutex_unlock(&u132->scheduler_lock);
		u132_hcd_forget_urb(u132, endp, urb, -ENODEV);
		return;
	} else if (endp->dequeueing) {
		endp->dequeueing = 0;
		mutex_unlock(&u132->scheduler_lock);
		u132_hcd_giveback_urb(u132, endp, urb, -EINTR);
		return;
	} else if (u132->going > 0) {
		dev_err(&u132->platform_dev->dev, "device is being removed "
				"urb=%p\n", urb);
		mutex_unlock(&u132->scheduler_lock);
		u132_hcd_giveback_urb(u132, endp, urb, -ENODEV);
		return;
	} else if (!urb->unlinked) {
		mutex_unlock(&u132->scheduler_lock);
		u132_hcd_giveback_urb(u132, endp, urb, 0);
		return;
	} else {
		dev_err(&u132->platform_dev->dev, "CALLBACK called urb=%p "
				"unlinked=%d\n", urb, urb->unlinked);
		mutex_unlock(&u132->scheduler_lock);
		u132_hcd_giveback_urb(u132, endp, urb, 0);
		return;
	}
}

static void u132_hcd_initial_input_recv(void *data, struct urb *urb, u8 *buf,
	int len, int toggle_bits, int error_count, int condition_code,
	int repeat_number, int halted, int skipped, int actual, int non_null)
{
	struct u132_endp *endp = data;
	struct u132 *u132 = endp->u132;
	u8 address = u132->addr[endp->usb_addr].address;
	mutex_lock(&u132->scheduler_lock);
	if (u132->going > 1) {
		dev_err(&u132->platform_dev->dev, "device has been removed %d\n"
			, u132->going);
		mutex_unlock(&u132->scheduler_lock);
		u132_hcd_forget_urb(u132, endp, urb, -ENODEV);
		return;
	} else if (endp->dequeueing) {
		endp->dequeueing = 0;
		mutex_unlock(&u132->scheduler_lock);
		u132_hcd_giveback_urb(u132, endp, urb, -EINTR);
		return;
	} else if (u132->going > 0) {
		dev_err(&u132->platform_dev->dev, "device is being removed "
				"urb=%p\n", urb);
		mutex_unlock(&u132->scheduler_lock);
		u132_hcd_giveback_urb(u132, endp, urb, -ENODEV);
		return;
	} else if (!urb->unlinked) {
		int retval;
		struct u132_ring *ring = endp->ring;
		u8 *u = urb->transfer_buffer;
		u8 *b = buf;
		int L = len;

		while (L-- > 0)
			*u++ = *b++;

		urb->actual_length = len;
		mutex_unlock(&u132->scheduler_lock);
		retval = usb_ftdi_elan_edset_empty(u132->platform_dev,
			ring->number, endp, urb, address, endp->usb_endp, 0x3,
			u132_hcd_initial_empty_sent);
		if (retval != 0)
			u132_hcd_giveback_urb(u132, endp, urb, retval);
		return;
	} else {
		dev_err(&u132->platform_dev->dev, "CALLBACK called urb=%p "
				"unlinked=%d\n", urb, urb->unlinked);
		mutex_unlock(&u132->scheduler_lock);
		u132_hcd_giveback_urb(u132, endp, urb, 0);
		return;
	}
}

static void u132_hcd_initial_setup_sent(void *data, struct urb *urb, u8 *buf,
	int len, int toggle_bits, int error_count, int condition_code,
	int repeat_number, int halted, int skipped, int actual, int non_null)
{
	struct u132_endp *endp = data;
	struct u132 *u132 = endp->u132;
	u8 address = u132->addr[endp->usb_addr].address;
	mutex_lock(&u132->scheduler_lock);
	if (u132->going > 1) {
		dev_err(&u132->platform_dev->dev, "device has been removed %d\n"
			, u132->going);
		mutex_unlock(&u132->scheduler_lock);
		u132_hcd_forget_urb(u132, endp, urb, -ENODEV);
		return;
	} else if (endp->dequeueing) {
		endp->dequeueing = 0;
		mutex_unlock(&u132->scheduler_lock);
		u132_hcd_giveback_urb(u132, endp, urb, -EINTR);
		return;
	} else if (u132->going > 0) {
		dev_err(&u132->platform_dev->dev, "device is being removed "
				"urb=%p\n", urb);
		mutex_unlock(&u132->scheduler_lock);
		u132_hcd_giveback_urb(u132, endp, urb, -ENODEV);
		return;
	} else if (!urb->unlinked) {
		int retval;
		struct u132_ring *ring = endp->ring;
		mutex_unlock(&u132->scheduler_lock);
		retval = usb_ftdi_elan_edset_input(u132->platform_dev,
			ring->number, endp, urb, address, endp->usb_endp, 0,
			u132_hcd_initial_input_recv);
		if (retval != 0)
			u132_hcd_giveback_urb(u132, endp, urb, retval);
		return;
	} else {
		dev_err(&u132->platform_dev->dev, "CALLBACK called urb=%p "
				"unlinked=%d\n", urb, urb->unlinked);
		mutex_unlock(&u132->scheduler_lock);
		u132_hcd_giveback_urb(u132, endp, urb, 0);
		return;
	}
}

/*
* this work function is only executed from the work queue
*
*/
static void u132_hcd_ring_work_scheduler(struct work_struct *work)
{
	struct u132_ring *ring =
		container_of(work, struct u132_ring, scheduler.work);
	struct u132 *u132 = ring->u132;
	mutex_lock(&u132->scheduler_lock);
	if (ring->in_use) {
		mutex_unlock(&u132->scheduler_lock);
		u132_ring_put_kref(u132, ring);
		return;
	} else if (ring->curr_endp) {
		struct u132_endp *last_endp = ring->curr_endp;
		struct list_head *scan;
		struct list_head *head = &last_endp->endp_ring;
		unsigned long wakeup = 0;
		list_for_each(scan, head) {
			struct u132_endp *endp = list_entry(scan,
				struct u132_endp, endp_ring);
			if (endp->queue_next == endp->queue_last) {
			} else if ((endp->delayed == 0)
				|| time_after_eq(jiffies, endp->jiffies)) {
				ring->curr_endp = endp;
				u132_endp_cancel_work(u132, last_endp);
				u132_endp_queue_work(u132, last_endp, 0);
				mutex_unlock(&u132->scheduler_lock);
				u132_ring_put_kref(u132, ring);
				return;
			} else {
				unsigned long delta = endp->jiffies - jiffies;
				if (delta > wakeup)
					wakeup = delta;
			}
		}
		if (last_endp->queue_next == last_endp->queue_last) {
		} else if ((last_endp->delayed == 0) || time_after_eq(jiffies,
			last_endp->jiffies)) {
			u132_endp_cancel_work(u132, last_endp);
			u132_endp_queue_work(u132, last_endp, 0);
			mutex_unlock(&u132->scheduler_lock);
			u132_ring_put_kref(u132, ring);
			return;
		} else {
			unsigned long delta = last_endp->jiffies - jiffies;
			if (delta > wakeup)
				wakeup = delta;
		}
		if (wakeup > 0) {
			u132_ring_requeue_work(u132, ring, wakeup);
			mutex_unlock(&u132->scheduler_lock);
			return;
		} else {
			mutex_unlock(&u132->scheduler_lock);
			u132_ring_put_kref(u132, ring);
			return;
		}
	} else {
		mutex_unlock(&u132->scheduler_lock);
		u132_ring_put_kref(u132, ring);
		return;
	}
}

static void u132_hcd_endp_work_scheduler(struct work_struct *work)
{
	struct u132_ring *ring;
	struct u132_endp *endp =
		container_of(work, struct u132_endp, scheduler.work);
	struct u132 *u132 = endp->u132;
	mutex_lock(&u132->scheduler_lock);
	ring = endp->ring;
	if (endp->edset_flush) {
		endp->edset_flush = 0;
		if (endp->dequeueing)
			usb_ftdi_elan_edset_flush(u132->platform_dev,
				ring->number, endp);
		mutex_unlock(&u132->scheduler_lock);
		u132_endp_put_kref(u132, endp);
		return;
	} else if (endp->active) {
		mutex_unlock(&u132->scheduler_lock);
		u132_endp_put_kref(u132, endp);
		return;
	} else if (ring->in_use) {
		mutex_unlock(&u132->scheduler_lock);
		u132_endp_put_kref(u132, endp);
		return;
	} else if (endp->queue_next == endp->queue_last) {
		mutex_unlock(&u132->scheduler_lock);
		u132_endp_put_kref(u132, endp);
		return;
	} else if (endp->pipetype == PIPE_INTERRUPT) {
		u8 address = u132->addr[endp->usb_addr].address;
		if (ring->in_use) {
			mutex_unlock(&u132->scheduler_lock);
			u132_endp_put_kref(u132, endp);
			return;
		} else {
			int retval;
			struct urb *urb = endp->urb_list[ENDP_QUEUE_MASK &
				endp->queue_next];
			endp->active = 1;
			ring->curr_endp = endp;
			ring->in_use = 1;
			mutex_unlock(&u132->scheduler_lock);
			retval = edset_single(u132, ring, endp, urb, address,
				endp->toggle_bits, u132_hcd_interrupt_recv);
			if (retval != 0)
				u132_hcd_giveback_urb(u132, endp, urb, retval);
			return;
		}
	} else if (endp->pipetype == PIPE_CONTROL) {
		u8 address = u132->addr[endp->usb_addr].address;
		if (ring->in_use) {
			mutex_unlock(&u132->scheduler_lock);
			u132_endp_put_kref(u132, endp);
			return;
		} else if (address == 0) {
			int retval;
			struct urb *urb = endp->urb_list[ENDP_QUEUE_MASK &
				endp->queue_next];
			endp->active = 1;
			ring->curr_endp = endp;
			ring->in_use = 1;
			mutex_unlock(&u132->scheduler_lock);
			retval = edset_setup(u132, ring, endp, urb, address,
				0x2, u132_hcd_initial_setup_sent);
			if (retval != 0)
				u132_hcd_giveback_urb(u132, endp, urb, retval);
			return;
		} else if (endp->usb_addr == 0) {
			int retval;
			struct urb *urb = endp->urb_list[ENDP_QUEUE_MASK &
				endp->queue_next];
			endp->active = 1;
			ring->curr_endp = endp;
			ring->in_use = 1;
			mutex_unlock(&u132->scheduler_lock);
			retval = edset_setup(u132, ring, endp, urb, 0, 0x2,
				u132_hcd_enumeration_address_sent);
			if (retval != 0)
				u132_hcd_giveback_urb(u132, endp, urb, retval);
			return;
		} else {
			int retval;
			u8 address = u132->addr[endp->usb_addr].address;
			struct urb *urb = endp->urb_list[ENDP_QUEUE_MASK &
				endp->queue_next];
			endp->active = 1;
			ring->curr_endp = endp;
			ring->in_use = 1;
			mutex_unlock(&u132->scheduler_lock);
			retval = edset_setup(u132, ring, endp, urb, address,
				0x2, u132_hcd_configure_setup_sent);
			if (retval != 0)
				u132_hcd_giveback_urb(u132, endp, urb, retval);
			return;
		}
	} else {
		if (endp->input) {
			u8 address = u132->addr[endp->usb_addr].address;
			if (ring->in_use) {
				mutex_unlock(&u132->scheduler_lock);
				u132_endp_put_kref(u132, endp);
				return;
			} else {
				int retval;
				struct urb *urb = endp->urb_list[
					ENDP_QUEUE_MASK & endp->queue_next];
				endp->active = 1;
				ring->curr_endp = endp;
				ring->in_use = 1;
				mutex_unlock(&u132->scheduler_lock);
				retval = edset_input(u132, ring, endp, urb,
					address, endp->toggle_bits,
					u132_hcd_bulk_input_recv);
				if (retval == 0) {
				} else
					u132_hcd_giveback_urb(u132, endp, urb,
						retval);
				return;
			}
		} else {	/* output pipe */
			u8 address = u132->addr[endp->usb_addr].address;
			if (ring->in_use) {
				mutex_unlock(&u132->scheduler_lock);
				u132_endp_put_kref(u132, endp);
				return;
			} else {
				int retval;
				struct urb *urb = endp->urb_list[
					ENDP_QUEUE_MASK & endp->queue_next];
				endp->active = 1;
				ring->curr_endp = endp;
				ring->in_use = 1;
				mutex_unlock(&u132->scheduler_lock);
				retval = edset_output(u132, ring, endp, urb,
					address, endp->toggle_bits,
					u132_hcd_bulk_output_sent);
				if (retval == 0) {
				} else
					u132_hcd_giveback_urb(u132, endp, urb,
						retval);
				return;
			}
		}
	}
}
#ifdef CONFIG_PM

static void port_power(struct u132 *u132, int pn, int is_on)
{
	u132->port[pn].power = is_on;
}

#endif

static void u132_power(struct u132 *u132, int is_on)
{
	struct usb_hcd *hcd = u132_to_hcd(u132)
		;	/* hub is inactive unless the port is powered */
	if (is_on) {
		if (u132->power)
			return;
		u132->power = 1;
	} else {
		u132->power = 0;
		hcd->state = HC_STATE_HALT;
	}
}

static int u132_periodic_reinit(struct u132 *u132)
{
	int retval;
	u32 fi = u132->hc_fminterval & 0x03fff;
	u32 fit;
	u32 fminterval;
	retval = u132_read_pcimem(u132, fminterval, &fminterval);
	if (retval)
		return retval;
	fit = fminterval & FIT;
	retval = u132_write_pcimem(u132, fminterval,
		(fit ^ FIT) | u132->hc_fminterval);
	if (retval)
		return retval;
	retval = u132_write_pcimem(u132, periodicstart,
		((9 * fi) / 10) & 0x3fff);
	if (retval)
		return retval;
	return 0;
}

static char *hcfs2string(int state)
{
	switch (state) {
	case OHCI_USB_RESET:
		return "reset";
	case OHCI_USB_RESUME:
		return "resume";
	case OHCI_USB_OPER:
		return "operational";
	case OHCI_USB_SUSPEND:
		return "suspend";
	}
	return "?";
}

static int u132_init(struct u132 *u132)
{
	int retval;
	u32 control;
	u132_disable(u132);
	u132->next_statechange = jiffies;
	retval = u132_write_pcimem(u132, intrdisable, OHCI_INTR_MIE);
	if (retval)
		return retval;
	retval = u132_read_pcimem(u132, control, &control);
	if (retval)
		return retval;
	if (u132->num_ports == 0) {
		u32 rh_a = -1;
		retval = u132_read_pcimem(u132, roothub.a, &rh_a);
		if (retval)
			return retval;
		u132->num_ports = rh_a & RH_A_NDP;
		retval = read_roothub_info(u132);
		if (retval)
			return retval;
	}
	if (u132->num_ports > MAX_U132_PORTS)
		return -EINVAL;

	return 0;
}


/* Start an OHCI controller, set the BUS operational
* resets USB and controller
* enable interrupts
*/
static int u132_run(struct u132 *u132)
{
	int retval;
	u32 control;
	u32 status;
	u32 fminterval;
	u32 periodicstart;
	u32 cmdstatus;
	u32 roothub_a;
	int mask = OHCI_INTR_INIT;
	int first = u132->hc_fminterval == 0;
	int sleep_time = 0;
	int reset_timeout = 30;	/* ... allow extra time */
	u132_disable(u132);
	if (first) {
		u32 temp;
		retval = u132_read_pcimem(u132, fminterval, &temp);
		if (retval)
			return retval;
		u132->hc_fminterval = temp & 0x3fff;
		u132->hc_fminterval |= FSMP(u132->hc_fminterval) << 16;
	}
	retval = u132_read_pcimem(u132, control, &u132->hc_control);
	if (retval)
		return retval;
	dev_info(&u132->platform_dev->dev, "resetting from state '%s', control "
		"= %08X\n", hcfs2string(u132->hc_control & OHCI_CTRL_HCFS),
		u132->hc_control);
	switch (u132->hc_control & OHCI_CTRL_HCFS) {
	case OHCI_USB_OPER:
		sleep_time = 0;
		break;
	case OHCI_USB_SUSPEND:
	case OHCI_USB_RESUME:
		u132->hc_control &= OHCI_CTRL_RWC;
		u132->hc_control |= OHCI_USB_RESUME;
		sleep_time = 10;
		break;
	default:
		u132->hc_control &= OHCI_CTRL_RWC;
		u132->hc_control |= OHCI_USB_RESET;
		sleep_time = 50;
		break;
	}
	retval = u132_write_pcimem(u132, control, u132->hc_control);
	if (retval)
		return retval;
	retval = u132_read_pcimem(u132, control, &control);
	if (retval)
		return retval;
	msleep(sleep_time);
	retval = u132_read_pcimem(u132, roothub.a, &roothub_a);
	if (retval)
		return retval;
	if (!(roothub_a & RH_A_NPS)) {
		int temp;	/* power down each port */
		for (temp = 0; temp < u132->num_ports; temp++) {
			retval = u132_write_pcimem(u132,
				roothub.portstatus[temp], RH_PS_LSDA);
			if (retval)
				return retval;
		}
	}
	retval = u132_read_pcimem(u132, control, &control);
	if (retval)
		return retval;
retry:
	retval = u132_read_pcimem(u132, cmdstatus, &status);
	if (retval)
		return retval;
	retval = u132_write_pcimem(u132, cmdstatus, OHCI_HCR);
	if (retval)
		return retval;
extra:	{
		retval = u132_read_pcimem(u132, cmdstatus, &status);
		if (retval)
			return retval;
		if (0 != (status & OHCI_HCR)) {
			if (--reset_timeout == 0) {
				dev_err(&u132->platform_dev->dev, "USB HC reset"
					" timed out!\n");
				return -ENODEV;
			} else {
				msleep(5);
				goto extra;
			}
		}
	}
	if (u132->flags & OHCI_QUIRK_INITRESET) {
		retval = u132_write_pcimem(u132, control, u132->hc_control);
		if (retval)
			return retval;
		retval = u132_read_pcimem(u132, control, &control);
		if (retval)
			return retval;
	}
	retval = u132_write_pcimem(u132, ed_controlhead, 0x00000000);
	if (retval)
		return retval;
	retval = u132_write_pcimem(u132, ed_bulkhead, 0x11000000);
	if (retval)
		return retval;
	retval = u132_write_pcimem(u132, hcca, 0x00000000);
	if (retval)
		return retval;
	retval = u132_periodic_reinit(u132);
	if (retval)
		return retval;
	retval = u132_read_pcimem(u132, fminterval, &fminterval);
	if (retval)
		return retval;
	retval = u132_read_pcimem(u132, periodicstart, &periodicstart);
	if (retval)
		return retval;
	if (0 == (fminterval & 0x3fff0000) || 0 == periodicstart) {
		if (!(u132->flags & OHCI_QUIRK_INITRESET)) {
			u132->flags |= OHCI_QUIRK_INITRESET;
			goto retry;
		} else
			dev_err(&u132->platform_dev->dev, "init err(%08x %04x)"
				"\n", fminterval, periodicstart);
	}			/* start controller operations */
	u132->hc_control &= OHCI_CTRL_RWC;
	u132->hc_control |= OHCI_CONTROL_INIT | OHCI_CTRL_BLE | OHCI_USB_OPER;
	retval = u132_write_pcimem(u132, control, u132->hc_control);
	if (retval)
		return retval;
	retval = u132_write_pcimem(u132, cmdstatus, OHCI_BLF);
	if (retval)
		return retval;
	retval = u132_read_pcimem(u132, cmdstatus, &cmdstatus);
	if (retval)
		return retval;
	retval = u132_read_pcimem(u132, control, &control);
	if (retval)
		return retval;
	u132_to_hcd(u132)->state = HC_STATE_RUNNING;
	retval = u132_write_pcimem(u132, roothub.status, RH_HS_DRWE);
	if (retval)
		return retval;
	retval = u132_write_pcimem(u132, intrstatus, mask);
	if (retval)
		return retval;
	retval = u132_write_pcimem(u132, intrdisable,
		OHCI_INTR_MIE | OHCI_INTR_OC | OHCI_INTR_RHSC | OHCI_INTR_FNO |
		OHCI_INTR_UE | OHCI_INTR_RD | OHCI_INTR_SF | OHCI_INTR_WDH |
		OHCI_INTR_SO);
	if (retval)
		return retval;	/* handle root hub init quirks ... */
	retval = u132_read_pcimem(u132, roothub.a, &roothub_a);
	if (retval)
		return retval;
	roothub_a &= ~(RH_A_PSM | RH_A_OCPM);
	if (u132->flags & OHCI_QUIRK_SUPERIO) {
		roothub_a |= RH_A_NOCP;
		roothub_a &= ~(RH_A_POTPGT | RH_A_NPS);
		retval = u132_write_pcimem(u132, roothub.a, roothub_a);
		if (retval)
			return retval;
	} else if ((u132->flags & OHCI_QUIRK_AMD756) || distrust_firmware) {
		roothub_a |= RH_A_NPS;
		retval = u132_write_pcimem(u132, roothub.a, roothub_a);
		if (retval)
			return retval;
	}
	retval = u132_write_pcimem(u132, roothub.status, RH_HS_LPSC);
	if (retval)
		return retval;
	retval = u132_write_pcimem(u132, roothub.b,
		(roothub_a & RH_A_NPS) ? 0 : RH_B_PPCM);
	if (retval)
		return retval;
	retval = u132_read_pcimem(u132, control, &control);
	if (retval)
		return retval;
	mdelay((roothub_a >> 23) & 0x1fe);
	u132_to_hcd(u132)->state = HC_STATE_RUNNING;
	return 0;
}

static void u132_hcd_stop(struct usb_hcd *hcd)
{
	struct u132 *u132 = hcd_to_u132(hcd);
	if (u132->going > 1) {
		dev_err(&u132->platform_dev->dev, "u132 device %p(hcd=%p) has b"
			"een removed %d\n", u132, hcd, u132->going);
	} else if (u132->going > 0) {
		dev_err(&u132->platform_dev->dev, "device hcd=%p is being remov"
			"ed\n", hcd);
	} else {
		mutex_lock(&u132->sw_lock);
		msleep(100);
		u132_power(u132, 0);
		mutex_unlock(&u132->sw_lock);
	}
}

static int u132_hcd_start(struct usb_hcd *hcd)
{
	struct u132 *u132 = hcd_to_u132(hcd);
	if (u132->going > 1) {
		dev_err(&u132->platform_dev->dev, "device has been removed %d\n"
			, u132->going);
		return -ENODEV;
	} else if (u132->going > 0) {
		dev_err(&u132->platform_dev->dev, "device is being removed\n");
		return -ESHUTDOWN;
	} else if (hcd->self.controller) {
		int retval;
		struct platform_device *pdev =
			to_platform_device(hcd->self.controller);
		u16 vendor = ((struct u132_platform_data *)
			(pdev->dev.platform_data))->vendor;
		u16 device = ((struct u132_platform_data *)
			(pdev->dev.platform_data))->device;
		mutex_lock(&u132->sw_lock);
		msleep(10);
		if (vendor == PCI_VENDOR_ID_AMD && device == 0x740c) {
			u132->flags = OHCI_QUIRK_AMD756;
		} else if (vendor == PCI_VENDOR_ID_OPTI && device == 0xc861) {
			dev_err(&u132->platform_dev->dev, "WARNING: OPTi workar"
				"ounds unavailable\n");
		} else if (vendor == PCI_VENDOR_ID_COMPAQ && device == 0xa0f8)
			u132->flags |= OHCI_QUIRK_ZFMICRO;
		retval = u132_run(u132);
		if (retval) {
			u132_disable(u132);
			u132->going = 1;
		}
		msleep(100);
		mutex_unlock(&u132->sw_lock);
		return retval;
	} else {
		dev_err(&u132->platform_dev->dev, "platform_device missing\n");
		return -ENODEV;
	}
}

static int u132_hcd_reset(struct usb_hcd *hcd)
{
	struct u132 *u132 = hcd_to_u132(hcd);
	if (u132->going > 1) {
		dev_err(&u132->platform_dev->dev, "device has been removed %d\n"
			, u132->going);
		return -ENODEV;
	} else if (u132->going > 0) {
		dev_err(&u132->platform_dev->dev, "device is being removed\n");
		return -ESHUTDOWN;
	} else {
		int retval;
		mutex_lock(&u132->sw_lock);
		retval = u132_init(u132);
		if (retval) {
			u132_disable(u132);
			u132->going = 1;
		}
		mutex_unlock(&u132->sw_lock);
		return retval;
	}
}

static int create_endpoint_and_queue_int(struct u132 *u132,
	struct u132_udev *udev, struct urb *urb,
	struct usb_device *usb_dev, u8 usb_addr, u8 usb_endp, u8 address,
	gfp_t mem_flags)
{
	struct u132_ring *ring;
	unsigned long irqs;
	int rc;
	u8 endp_number;
	struct u132_endp *endp = kmalloc(sizeof(struct u132_endp), mem_flags);

	if (!endp)
		return -ENOMEM;

	spin_lock_init(&endp->queue_lock.slock);
	spin_lock_irqsave(&endp->queue_lock.slock, irqs);
	rc = usb_hcd_link_urb_to_ep(u132_to_hcd(u132), urb);
	if (rc) {
		spin_unlock_irqrestore(&endp->queue_lock.slock, irqs);
		kfree(endp);
		return rc;
	}

	endp_number = ++u132->num_endpoints;
	urb->ep->hcpriv = u132->endp[endp_number - 1] = endp;
	INIT_DELAYED_WORK(&endp->scheduler, u132_hcd_endp_work_scheduler);
	INIT_LIST_HEAD(&endp->urb_more);
	ring = endp->ring = &u132->ring[0];
	if (ring->curr_endp) {
		list_add_tail(&endp->endp_ring, &ring->curr_endp->endp_ring);
	} else {
		INIT_LIST_HEAD(&endp->endp_ring);
		ring->curr_endp = endp;
	}
	ring->length += 1;
	endp->dequeueing = 0;
	endp->edset_flush = 0;
	endp->active = 0;
	endp->delayed = 0;
	endp->endp_number = endp_number;
	endp->u132 = u132;
	endp->hep = urb->ep;
	endp->pipetype = usb_pipetype(urb->pipe);
	u132_endp_init_kref(u132, endp);
	if (usb_pipein(urb->pipe)) {
		endp->toggle_bits = 0x2;
		usb_settoggle(udev->usb_device, usb_endp, 0, 0);
		endp->input = 1;
		endp->output = 0;
		udev->endp_number_in[usb_endp] = endp_number;
		u132_udev_get_kref(u132, udev);
	} else {
		endp->toggle_bits = 0x2;
		usb_settoggle(udev->usb_device, usb_endp, 1, 0);
		endp->input = 0;
		endp->output = 1;
		udev->endp_number_out[usb_endp] = endp_number;
		u132_udev_get_kref(u132, udev);
	}
	urb->hcpriv = u132;
	endp->delayed = 1;
	endp->jiffies = jiffies + msecs_to_jiffies(urb->interval);
	endp->udev_number = address;
	endp->usb_addr = usb_addr;
	endp->usb_endp = usb_endp;
	endp->queue_size = 1;
	endp->queue_last = 0;
	endp->queue_next = 0;
	endp->urb_list[ENDP_QUEUE_MASK & endp->queue_last++] = urb;
	spin_unlock_irqrestore(&endp->queue_lock.slock, irqs);
	u132_endp_queue_work(u132, endp, msecs_to_jiffies(urb->interval));
	return 0;
}

static int queue_int_on_old_endpoint(struct u132 *u132,
	struct u132_udev *udev, struct urb *urb,
	struct usb_device *usb_dev, struct u132_endp *endp, u8 usb_addr,
	u8 usb_endp, u8 address)
{
	urb->hcpriv = u132;
	endp->delayed = 1;
	endp->jiffies = jiffies + msecs_to_jiffies(urb->interval);
	if (endp->queue_size++ < ENDP_QUEUE_SIZE) {
		endp->urb_list[ENDP_QUEUE_MASK & endp->queue_last++] = urb;
	} else {
		struct u132_urbq *urbq = kmalloc(sizeof(struct u132_urbq),
			GFP_ATOMIC);
		if (urbq == NULL) {
			endp->queue_size -= 1;
			return -ENOMEM;
		} else {
			list_add_tail(&urbq->urb_more, &endp->urb_more);
			urbq->urb = urb;
		}
	}
	return 0;
}

static int create_endpoint_and_queue_bulk(struct u132 *u132,
	struct u132_udev *udev, struct urb *urb,
	struct usb_device *usb_dev, u8 usb_addr, u8 usb_endp, u8 address,
	gfp_t mem_flags)
{
	int ring_number;
	struct u132_ring *ring;
	unsigned long irqs;
	int rc;
	u8 endp_number;
	struct u132_endp *endp = kmalloc(sizeof(struct u132_endp), mem_flags);

	if (!endp)
		return -ENOMEM;

	spin_lock_init(&endp->queue_lock.slock);
	spin_lock_irqsave(&endp->queue_lock.slock, irqs);
	rc = usb_hcd_link_urb_to_ep(u132_to_hcd(u132), urb);
	if (rc) {
		spin_unlock_irqrestore(&endp->queue_lock.slock, irqs);
		kfree(endp);
		return rc;
	}

	endp_number = ++u132->num_endpoints;
	urb->ep->hcpriv = u132->endp[endp_number - 1] = endp;
	INIT_DELAYED_WORK(&endp->scheduler, u132_hcd_endp_work_scheduler);
	INIT_LIST_HEAD(&endp->urb_more);
	endp->dequeueing = 0;
	endp->edset_flush = 0;
	endp->active = 0;
	endp->delayed = 0;
	endp->endp_number = endp_number;
	endp->u132 = u132;
	endp->hep = urb->ep;
	endp->pipetype = usb_pipetype(urb->pipe);
	u132_endp_init_kref(u132, endp);
	if (usb_pipein(urb->pipe)) {
		endp->toggle_bits = 0x2;
		usb_settoggle(udev->usb_device, usb_endp, 0, 0);
		ring_number = 3;
		endp->input = 1;
		endp->output = 0;
		udev->endp_number_in[usb_endp] = endp_number;
		u132_udev_get_kref(u132, udev);
	} else {
		endp->toggle_bits = 0x2;
		usb_settoggle(udev->usb_device, usb_endp, 1, 0);
		ring_number = 2;
		endp->input = 0;
		endp->output = 1;
		udev->endp_number_out[usb_endp] = endp_number;
		u132_udev_get_kref(u132, udev);
	}
	ring = endp->ring = &u132->ring[ring_number - 1];
	if (ring->curr_endp) {
		list_add_tail(&endp->endp_ring, &ring->curr_endp->endp_ring);
	} else {
		INIT_LIST_HEAD(&endp->endp_ring);
		ring->curr_endp = endp;
	}
	ring->length += 1;
	urb->hcpriv = u132;
	endp->udev_number = address;
	endp->usb_addr = usb_addr;
	endp->usb_endp = usb_endp;
	endp->queue_size = 1;
	endp->queue_last = 0;
	endp->queue_next = 0;
	endp->urb_list[ENDP_QUEUE_MASK & endp->queue_last++] = urb;
	spin_unlock_irqrestore(&endp->queue_lock.slock, irqs);
	u132_endp_queue_work(u132, endp, 0);
	return 0;
}

static int queue_bulk_on_old_endpoint(struct u132 *u132, struct u132_udev *udev,
	struct urb *urb,
	struct usb_device *usb_dev, struct u132_endp *endp, u8 usb_addr,
	u8 usb_endp, u8 address)
{
	urb->hcpriv = u132;
	if (endp->queue_size++ < ENDP_QUEUE_SIZE) {
		endp->urb_list[ENDP_QUEUE_MASK & endp->queue_last++] = urb;
	} else {
		struct u132_urbq *urbq = kmalloc(sizeof(struct u132_urbq),
			GFP_ATOMIC);
		if (urbq == NULL) {
			endp->queue_size -= 1;
			return -ENOMEM;
		} else {
			list_add_tail(&urbq->urb_more, &endp->urb_more);
			urbq->urb = urb;
		}
	}
	return 0;
}

static int create_endpoint_and_queue_control(struct u132 *u132,
	struct urb *urb,
	struct usb_device *usb_dev, u8 usb_addr, u8 usb_endp,
	gfp_t mem_flags)
{
	struct u132_ring *ring;
	unsigned long irqs;
	int rc;
	u8 endp_number;
	struct u132_endp *endp = kmalloc(sizeof(struct u132_endp), mem_flags);

	if (!endp)
		return -ENOMEM;

	spin_lock_init(&endp->queue_lock.slock);
	spin_lock_irqsave(&endp->queue_lock.slock, irqs);
	rc = usb_hcd_link_urb_to_ep(u132_to_hcd(u132), urb);
	if (rc) {
		spin_unlock_irqrestore(&endp->queue_lock.slock, irqs);
		kfree(endp);
		return rc;
	}

	endp_number = ++u132->num_endpoints;
	urb->ep->hcpriv = u132->endp[endp_number - 1] = endp;
	INIT_DELAYED_WORK(&endp->scheduler, u132_hcd_endp_work_scheduler);
	INIT_LIST_HEAD(&endp->urb_more);
	ring = endp->ring = &u132->ring[0];
	if (ring->curr_endp) {
		list_add_tail(&endp->endp_ring, &ring->curr_endp->endp_ring);
	} else {
		INIT_LIST_HEAD(&endp->endp_ring);
		ring->curr_endp = endp;
	}
	ring->length += 1;
	endp->dequeueing = 0;
	endp->edset_flush = 0;
	endp->active = 0;
	endp->delayed = 0;
	endp->endp_number = endp_number;
	endp->u132 = u132;
	endp->hep = urb->ep;
	u132_endp_init_kref(u132, endp);
	u132_endp_get_kref(u132, endp);
	if (usb_addr == 0) {
		u8 address = u132->addr[usb_addr].address;
		struct u132_udev *udev = &u132->udev[address];
		endp->udev_number = address;
		endp->usb_addr = usb_addr;
		endp->usb_endp = usb_endp;
		endp->input = 1;
		endp->output = 1;
		endp->pipetype = usb_pipetype(urb->pipe);
		u132_udev_init_kref(u132, udev);
		u132_udev_get_kref(u132, udev);
		udev->endp_number_in[usb_endp] = endp_number;
		udev->endp_number_out[usb_endp] = endp_number;
		urb->hcpriv = u132;
		endp->queue_size = 1;
		endp->queue_last = 0;
		endp->queue_next = 0;
		endp->urb_list[ENDP_QUEUE_MASK & endp->queue_last++] = urb;
		spin_unlock_irqrestore(&endp->queue_lock.slock, irqs);
		u132_endp_queue_work(u132, endp, 0);
		return 0;
	} else {		/*(usb_addr > 0) */
		u8 address = u132->addr[usb_addr].address;
		struct u132_udev *udev = &u132->udev[address];
		endp->udev_number = address;
		endp->usb_addr = usb_addr;
		endp->usb_endp = usb_endp;
		endp->input = 1;
		endp->output = 1;
		endp->pipetype = usb_pipetype(urb->pipe);
		u132_udev_get_kref(u132, udev);
		udev->enumeration = 2;
		udev->endp_number_in[usb_endp] = endp_number;
		udev->endp_number_out[usb_endp] = endp_number;
		urb->hcpriv = u132;
		endp->queue_size = 1;
		endp->queue_last = 0;
		endp->queue_next = 0;
		endp->urb_list[ENDP_QUEUE_MASK & endp->queue_last++] = urb;
		spin_unlock_irqrestore(&endp->queue_lock.slock, irqs);
		u132_endp_queue_work(u132, endp, 0);
		return 0;
	}
}

static int queue_control_on_old_endpoint(struct u132 *u132,
	struct urb *urb,
	struct usb_device *usb_dev, struct u132_endp *endp, u8 usb_addr,
	u8 usb_endp)
{
	if (usb_addr == 0) {
		if (usb_pipein(urb->pipe)) {
			urb->hcpriv = u132;
			if (endp->queue_size++ < ENDP_QUEUE_SIZE) {
				endp->urb_list[ENDP_QUEUE_MASK &
					endp->queue_last++] = urb;
			} else {
				struct u132_urbq *urbq =
					kmalloc(sizeof(struct u132_urbq),
					GFP_ATOMIC);
				if (urbq == NULL) {
					endp->queue_size -= 1;
					return -ENOMEM;
				} else {
					list_add_tail(&urbq->urb_more,
						&endp->urb_more);
					urbq->urb = urb;
				}
			}
			return 0;
		} else {	/* usb_pipeout(urb->pipe) */
			struct u132_addr *addr = &u132->addr[usb_dev->devnum];
			int I = MAX_U132_UDEVS;
			int i = 0;
			while (--I > 0) {
				struct u132_udev *udev = &u132->udev[++i];
				if (udev->usb_device) {
					continue;
				} else {
					udev->enumeration = 1;
					u132->addr[0].address = i;
					endp->udev_number = i;
					udev->udev_number = i;
					udev->usb_addr = usb_dev->devnum;
					u132_udev_init_kref(u132, udev);
					udev->endp_number_in[usb_endp] =
						endp->endp_number;
					u132_udev_get_kref(u132, udev);
					udev->endp_number_out[usb_endp] =
						endp->endp_number;
					udev->usb_device = usb_dev;
					((u8 *) (urb->setup_packet))[2] =
						addr->address = i;
					u132_udev_get_kref(u132, udev);
					break;
				}
			}
			if (I == 0) {
				dev_err(&u132->platform_dev->dev, "run out of d"
					"evice space\n");
				return -EINVAL;
			}
			urb->hcpriv = u132;
			if (endp->queue_size++ < ENDP_QUEUE_SIZE) {
				endp->urb_list[ENDP_QUEUE_MASK &
					endp->queue_last++] = urb;
			} else {
				struct u132_urbq *urbq =
					kmalloc(sizeof(struct u132_urbq),
					GFP_ATOMIC);
				if (urbq == NULL) {
					endp->queue_size -= 1;
					return -ENOMEM;
				} else {
					list_add_tail(&urbq->urb_more,
						&endp->urb_more);
					urbq->urb = urb;
				}
			}
			return 0;
		}
	} else {		/*(usb_addr > 0) */
		u8 address = u132->addr[usb_addr].address;
		struct u132_udev *udev = &u132->udev[address];
		urb->hcpriv = u132;
		if (udev->enumeration != 2)
			udev->enumeration = 2;
		if (endp->queue_size++ < ENDP_QUEUE_SIZE) {
			endp->urb_list[ENDP_QUEUE_MASK & endp->queue_last++] =
				urb;
		} else {
			struct u132_urbq *urbq =
				kmalloc(sizeof(struct u132_urbq), GFP_ATOMIC);
			if (urbq == NULL) {
				endp->queue_size -= 1;
				return -ENOMEM;
			} else {
				list_add_tail(&urbq->urb_more, &endp->urb_more);
				urbq->urb = urb;
			}
		}
		return 0;
	}
}

static int u132_urb_enqueue(struct usb_hcd *hcd, struct urb *urb,
		gfp_t mem_flags)
{
	struct u132 *u132 = hcd_to_u132(hcd);
	if (irqs_disabled()) {
		if (__GFP_WAIT & mem_flags) {
			printk(KERN_ERR "invalid context for function that migh"
				"t sleep\n");
			return -EINVAL;
		}
	}
	if (u132->going > 1) {
		dev_err(&u132->platform_dev->dev, "device has been removed %d\n"
			, u132->going);
		return -ENODEV;
	} else if (u132->going > 0) {
		dev_err(&u132->platform_dev->dev, "device is being removed "
				"urb=%p\n", urb);
		return -ESHUTDOWN;
	} else {
		u8 usb_addr = usb_pipedevice(urb->pipe);
		u8 usb_endp = usb_pipeendpoint(urb->pipe);
		struct usb_device *usb_dev = urb->dev;
		if (usb_pipetype(urb->pipe) == PIPE_INTERRUPT) {
			u8 address = u132->addr[usb_addr].address;
			struct u132_udev *udev = &u132->udev[address];
			struct u132_endp *endp = urb->ep->hcpriv;
			urb->actual_length = 0;
			if (endp) {
				unsigned long irqs;
				int retval;
				spin_lock_irqsave(&endp->queue_lock.slock,
					irqs);
				retval = usb_hcd_link_urb_to_ep(hcd, urb);
				if (retval == 0) {
					retval = queue_int_on_old_endpoint(
							u132, udev, urb,
							usb_dev, endp,
							usb_addr, usb_endp,
							address);
					if (retval)
						usb_hcd_unlink_urb_from_ep(
	hcd, urb);
				}
				spin_unlock_irqrestore(&endp->queue_lock.slock,
					irqs);
				if (retval) {
					return retval;
				} else {
					u132_endp_queue_work(u132, endp,
						msecs_to_jiffies(urb->interval))
						;
					return 0;
				}
			} else if (u132->num_endpoints == MAX_U132_ENDPS) {
				return -EINVAL;
			} else {	/*(endp == NULL) */
				return create_endpoint_and_queue_int(u132, udev,
						urb, usb_dev, usb_addr,
						usb_endp, address, mem_flags);
			}
		} else if (usb_pipetype(urb->pipe) == PIPE_ISOCHRONOUS) {
			dev_err(&u132->platform_dev->dev, "the hardware does no"
				"t support PIPE_ISOCHRONOUS\n");
			return -EINVAL;
		} else if (usb_pipetype(urb->pipe) == PIPE_BULK) {
			u8 address = u132->addr[usb_addr].address;
			struct u132_udev *udev = &u132->udev[address];
			struct u132_endp *endp = urb->ep->hcpriv;
			urb->actual_length = 0;
			if (endp) {
				unsigned long irqs;
				int retval;
				spin_lock_irqsave(&endp->queue_lock.slock,
					irqs);
				retval = usb_hcd_link_urb_to_ep(hcd, urb);
				if (retval == 0) {
					retval = queue_bulk_on_old_endpoint(
							u132, udev, urb,
							usb_dev, endp,
							usb_addr, usb_endp,
							address);
					if (retval)
						usb_hcd_unlink_urb_from_ep(
	hcd, urb);
				}
				spin_unlock_irqrestore(&endp->queue_lock.slock,
					irqs);
				if (retval) {
					return retval;
				} else {
					u132_endp_queue_work(u132, endp, 0);
					return 0;
				}
			} else if (u132->num_endpoints == MAX_U132_ENDPS) {
				return -EINVAL;
			} else
				return create_endpoint_and_queue_bulk(u132,
					udev, urb, usb_dev, usb_addr,
					usb_endp, address, mem_flags);
		} else {
			struct u132_endp *endp = urb->ep->hcpriv;
			u16 urb_size = 8;
			u8 *b = urb->setup_packet;
			int i = 0;
			char data[30 * 3 + 4];
			char *d = data;
			int m = (sizeof(data) - 1) / 3;
			int l = 0;
			data[0] = 0;
			while (urb_size-- > 0) {
				if (i > m) {
				} else if (i++ < m) {
					int w = sprintf(d, " %02X", *b++);
					d += w;
					l += w;
				} else
					d += sprintf(d, " ..");
			}
			if (endp) {
				unsigned long irqs;
				int retval;
				spin_lock_irqsave(&endp->queue_lock.slock,
					irqs);
				retval = usb_hcd_link_urb_to_ep(hcd, urb);
				if (retval == 0) {
					retval = queue_control_on_old_endpoint(
							u132, urb, usb_dev,
							endp, usb_addr,
							usb_endp);
					if (retval)
						usb_hcd_unlink_urb_from_ep(
								hcd, urb);
				}
				spin_unlock_irqrestore(&endp->queue_lock.slock,
					irqs);
				if (retval) {
					return retval;
				} else {
					u132_endp_queue_work(u132, endp, 0);
					return 0;
				}
			} else if (u132->num_endpoints == MAX_U132_ENDPS) {
				return -EINVAL;
			} else
				return create_endpoint_and_queue_control(u132,
					urb, usb_dev, usb_addr, usb_endp,
					mem_flags);
		}
	}
}

static int dequeue_from_overflow_chain(struct u132 *u132,
	struct u132_endp *endp, struct urb *urb)
{
	struct list_head *scan;
	struct list_head *head = &endp->urb_more;
	list_for_each(scan, head) {
		struct u132_urbq *urbq = list_entry(scan, struct u132_urbq,
			urb_more);
		if (urbq->urb == urb) {
			struct usb_hcd *hcd = u132_to_hcd(u132);
			list_del(scan);
			endp->queue_size -= 1;
			urb->error_count = 0;
			usb_hcd_giveback_urb(hcd, urb, 0);
			return 0;
		} else
			continue;
	}
	dev_err(&u132->platform_dev->dev, "urb=%p not found in endp[%d]=%p ring"
		"[%d] %c%c usb_endp=%d usb_addr=%d size=%d next=%04X last=%04X"
		"\n", urb, endp->endp_number, endp, endp->ring->number,
		endp->input ? 'I' : ' ', endp->output ? 'O' : ' ',
		endp->usb_endp, endp->usb_addr, endp->queue_size,
		endp->queue_next, endp->queue_last);
	return -EINVAL;
}

static int u132_endp_urb_dequeue(struct u132 *u132, struct u132_endp *endp,
		struct urb *urb, int status)
{
	unsigned long irqs;
	int rc;

	spin_lock_irqsave(&endp->queue_lock.slock, irqs);
	rc = usb_hcd_check_unlink_urb(u132_to_hcd(u132), urb, status);
	if (rc) {
		spin_unlock_irqrestore(&endp->queue_lock.slock, irqs);
		return rc;
	}
	if (endp->queue_size == 0) {
		dev_err(&u132->platform_dev->dev, "urb=%p not found in endp[%d]"
			"=%p ring[%d] %c%c usb_endp=%d usb_addr=%d\n", urb,
			endp->endp_number, endp, endp->ring->number,
			endp->input ? 'I' : ' ', endp->output ? 'O' : ' ',
			endp->usb_endp, endp->usb_addr);
		spin_unlock_irqrestore(&endp->queue_lock.slock, irqs);
		return -EINVAL;
	}
	if (urb == endp->urb_list[ENDP_QUEUE_MASK & endp->queue_next]) {
		if (endp->active) {
			endp->dequeueing = 1;
			endp->edset_flush = 1;
			u132_endp_queue_work(u132, endp, 0);
			spin_unlock_irqrestore(&endp->queue_lock.slock, irqs);
			return 0;
		} else {
			spin_unlock_irqrestore(&endp->queue_lock.slock, irqs);
			u132_hcd_abandon_urb(u132, endp, urb, status);
			return 0;
		}
	} else {
		u16 queue_list = 0;
		u16 queue_size = endp->queue_size;
		u16 queue_scan = endp->queue_next;
		struct urb **urb_slot = NULL;
		while (++queue_list < ENDP_QUEUE_SIZE && --queue_size > 0) {
			if (urb == endp->urb_list[ENDP_QUEUE_MASK &
				++queue_scan]) {
				urb_slot = &endp->urb_list[ENDP_QUEUE_MASK &
					queue_scan];
				break;
			} else
				continue;
		}
		while (++queue_list < ENDP_QUEUE_SIZE && --queue_size > 0) {
			*urb_slot = endp->urb_list[ENDP_QUEUE_MASK &
				++queue_scan];
			urb_slot = &endp->urb_list[ENDP_QUEUE_MASK &
				queue_scan];
		}
		if (urb_slot) {
			struct usb_hcd *hcd = u132_to_hcd(u132);

			usb_hcd_unlink_urb_from_ep(hcd, urb);
			endp->queue_size -= 1;
			if (list_empty(&endp->urb_more)) {
				spin_unlock_irqrestore(&endp->queue_lock.slock,
					irqs);
			} else {
				struct list_head *next = endp->urb_more.next;
				struct u132_urbq *urbq = list_entry(next,
					struct u132_urbq, urb_more);
				list_del(next);
				*urb_slot = urbq->urb;
				spin_unlock_irqrestore(&endp->queue_lock.slock,
					irqs);
				kfree(urbq);
			} urb->error_count = 0;
			usb_hcd_giveback_urb(hcd, urb, status);
			return 0;
		} else if (list_empty(&endp->urb_more)) {
			dev_err(&u132->platform_dev->dev, "urb=%p not found in "
				"endp[%d]=%p ring[%d] %c%c usb_endp=%d usb_addr"
				"=%d size=%d next=%04X last=%04X\n", urb,
				endp->endp_number, endp, endp->ring->number,
				endp->input ? 'I' : ' ',
				endp->output ? 'O' : ' ', endp->usb_endp,
				endp->usb_addr, endp->queue_size,
				endp->queue_next, endp->queue_last);
			spin_unlock_irqrestore(&endp->queue_lock.slock, irqs);
			return -EINVAL;
		} else {
			int retval;

			usb_hcd_unlink_urb_from_ep(u132_to_hcd(u132), urb);
			retval = dequeue_from_overflow_chain(u132, endp,
				urb);
			spin_unlock_irqrestore(&endp->queue_lock.slock, irqs);
			return retval;
		}
	}
}

static int u132_urb_dequeue(struct usb_hcd *hcd, struct urb *urb, int status)
{
	struct u132 *u132 = hcd_to_u132(hcd);
	if (u132->going > 2) {
		dev_err(&u132->platform_dev->dev, "device has been removed %d\n"
			, u132->going);
		return -ENODEV;
	} else {
		u8 usb_addr = usb_pipedevice(urb->pipe);
		u8 usb_endp = usb_pipeendpoint(urb->pipe);
		u8 address = u132->addr[usb_addr].address;
		struct u132_udev *udev = &u132->udev[address];
		if (usb_pipein(urb->pipe)) {
			u8 endp_number = udev->endp_number_in[usb_endp];
			struct u132_endp *endp = u132->endp[endp_number - 1];
			return u132_endp_urb_dequeue(u132, endp, urb, status);
		} else {
			u8 endp_number = udev->endp_number_out[usb_endp];
			struct u132_endp *endp = u132->endp[endp_number - 1];
			return u132_endp_urb_dequeue(u132, endp, urb, status);
		}
	}
}

static void u132_endpoint_disable(struct usb_hcd *hcd,
	struct usb_host_endpoint *hep)
{
	struct u132 *u132 = hcd_to_u132(hcd);
	if (u132->going > 2) {
		dev_err(&u132->platform_dev->dev, "u132 device %p(hcd=%p hep=%p"
			") has been removed %d\n", u132, hcd, hep,
			u132->going);
	} else {
		struct u132_endp *endp = hep->hcpriv;
		if (endp)
			u132_endp_put_kref(u132, endp);
	}
}

static int u132_get_frame(struct usb_hcd *hcd)
{
	struct u132 *u132 = hcd_to_u132(hcd);
	if (u132->going > 1) {
		dev_err(&u132->platform_dev->dev, "device has been removed %d\n"
			, u132->going);
		return -ENODEV;
	} else if (u132->going > 0) {
		dev_err(&u132->platform_dev->dev, "device is being removed\n");
		return -ESHUTDOWN;
	} else {
		int frame = 0;
		dev_err(&u132->platform_dev->dev, "TODO: u132_get_frame\n");
		msleep(100);
		return frame;
	}
}

static int u132_roothub_descriptor(struct u132 *u132,
	struct usb_hub_descriptor *desc)
{
	int retval;
	u16 temp;
	u32 rh_a = -1;
	u32 rh_b = -1;
	retval = u132_read_pcimem(u132, roothub.a, &rh_a);
	if (retval)
		return retval;
	desc->bDescriptorType = 0x29;
	desc->bPwrOn2PwrGood = (rh_a & RH_A_POTPGT) >> 24;
	desc->bHubContrCurrent = 0;
	desc->bNbrPorts = u132->num_ports;
	temp = 1 + (u132->num_ports / 8);
	desc->bDescLength = 7 + 2 * temp;
	temp = 0;
	if (rh_a & RH_A_NPS)
		temp |= 0x0002;
	if (rh_a & RH_A_PSM)
		temp |= 0x0001;
	if (rh_a & RH_A_NOCP)
		temp |= 0x0010;
	else if (rh_a & RH_A_OCPM)
		temp |= 0x0008;
	desc->wHubCharacteristics = cpu_to_le16(temp);
	retval = u132_read_pcimem(u132, roothub.b, &rh_b);
	if (retval)
		return retval;
	memset(desc->bitmap, 0xff, sizeof(desc->bitmap));
	desc->bitmap[0] = rh_b & RH_B_DR;
	if (u132->num_ports > 7) {
		desc->bitmap[1] = (rh_b & RH_B_DR) >> 8;
		desc->bitmap[2] = 0xff;
	} else
		desc->bitmap[1] = 0xff;
	return 0;
}

static int u132_roothub_status(struct u132 *u132, __le32 *desc)
{
	u32 rh_status = -1;
	int ret_status = u132_read_pcimem(u132, roothub.status, &rh_status);
	*desc = cpu_to_le32(rh_status);
	return ret_status;
}

static int u132_roothub_portstatus(struct u132 *u132, __le32 *desc, u16 wIndex)
{
	if (wIndex == 0 || wIndex > u132->num_ports) {
		return -EINVAL;
	} else {
		int port = wIndex - 1;
		u32 rh_portstatus = -1;
		int ret_portstatus = u132_read_pcimem(u132,
			roothub.portstatus[port], &rh_portstatus);
		*desc = cpu_to_le32(rh_portstatus);
		if (*(u16 *) (desc + 2)) {
			dev_info(&u132->platform_dev->dev, "Port %d Status Chan"
				"ge = %08X\n", port, *desc);
		}
		return ret_portstatus;
	}
}


/* this timer value might be vendor-specific ... */
#define PORT_RESET_HW_MSEC 10
#define PORT_RESET_MSEC 10
/* wrap-aware logic morphed from <linux/jiffies.h> */
#define tick_before(t1, t2) ((s16)(((s16)(t1))-((s16)(t2))) < 0)
static int u132_roothub_portreset(struct u132 *u132, int port_index)
{
	int retval;
	u32 fmnumber;
	u16 now;
	u16 reset_done;
	retval = u132_read_pcimem(u132, fmnumber, &fmnumber);
	if (retval)
		return retval;
	now = fmnumber;
	reset_done = now + PORT_RESET_MSEC;
	do {
		u32 portstat;
		do {
			retval = u132_read_pcimem(u132,
				roothub.portstatus[port_index], &portstat);
			if (retval)
				return retval;
			if (RH_PS_PRS & portstat)
				continue;
			else
				break;
		} while (tick_before(now, reset_done));
		if (RH_PS_PRS & portstat)
			return -ENODEV;
		if (RH_PS_CCS & portstat) {
			if (RH_PS_PRSC & portstat) {
				retval = u132_write_pcimem(u132,
					roothub.portstatus[port_index],
					RH_PS_PRSC);
				if (retval)
					return retval;
			}
		} else
			break;	/* start the next reset,
				sleep till it's probably done */
		retval = u132_write_pcimem(u132, roothub.portstatus[port_index],
			 RH_PS_PRS);
		if (retval)
			return retval;
		msleep(PORT_RESET_HW_MSEC);
		retval = u132_read_pcimem(u132, fmnumber, &fmnumber);
		if (retval)
			return retval;
		now = fmnumber;
	} while (tick_before(now, reset_done));
	return 0;
}

static int u132_roothub_setportfeature(struct u132 *u132, u16 wValue,
	u16 wIndex)
{
	if (wIndex == 0 || wIndex > u132->num_ports) {
		return -EINVAL;
	} else {
		int retval;
		int port_index = wIndex - 1;
		struct u132_port *port = &u132->port[port_index];
		port->Status &= ~(1 << wValue);
		switch (wValue) {
		case USB_PORT_FEAT_SUSPEND:
			retval = u132_write_pcimem(u132,
				roothub.portstatus[port_index], RH_PS_PSS);
			if (retval)
				return retval;
			return 0;
		case USB_PORT_FEAT_POWER:
			retval = u132_write_pcimem(u132,
				roothub.portstatus[port_index], RH_PS_PPS);
			if (retval)
				return retval;
			return 0;
		case USB_PORT_FEAT_RESET:
			retval = u132_roothub_portreset(u132, port_index);
			if (retval)
				return retval;
			return 0;
		default:
			return -EPIPE;
		}
	}
}

static int u132_roothub_clearportfeature(struct u132 *u132, u16 wValue,
	u16 wIndex)
{
	if (wIndex == 0 || wIndex > u132->num_ports) {
		return -EINVAL;
	} else {
		int port_index = wIndex - 1;
		u32 temp;
		int retval;
		struct u132_port *port = &u132->port[port_index];
		port->Status &= ~(1 << wValue);
		switch (wValue) {
		case USB_PORT_FEAT_ENABLE:
			temp = RH_PS_CCS;
			break;
		case USB_PORT_FEAT_C_ENABLE:
			temp = RH_PS_PESC;
			break;
		case USB_PORT_FEAT_SUSPEND:
			temp = RH_PS_POCI;
			if ((u132->hc_control & OHCI_CTRL_HCFS)
				!= OHCI_USB_OPER) {
				dev_err(&u132->platform_dev->dev, "TODO resume_"
					"root_hub\n");
			}
			break;
		case USB_PORT_FEAT_C_SUSPEND:
			temp = RH_PS_PSSC;
			break;
		case USB_PORT_FEAT_POWER:
			temp = RH_PS_LSDA;
			break;
		case USB_PORT_FEAT_C_CONNECTION:
			temp = RH_PS_CSC;
			break;
		case USB_PORT_FEAT_C_OVER_CURRENT:
			temp = RH_PS_OCIC;
			break;
		case USB_PORT_FEAT_C_RESET:
			temp = RH_PS_PRSC;
			break;
		default:
			return -EPIPE;
		}
		retval = u132_write_pcimem(u132, roothub.portstatus[port_index],
			 temp);
		if (retval)
			return retval;
		return 0;
	}
}


/* the virtual root hub timer IRQ checks for hub status*/
static int u132_hub_status_data(struct usb_hcd *hcd, char *buf)
{
	struct u132 *u132 = hcd_to_u132(hcd);
	if (u132->going > 1) {
		dev_err(&u132->platform_dev->dev, "device hcd=%p has been remov"
			"ed %d\n", hcd, u132->going);
		return -ENODEV;
	} else if (u132->going > 0) {
		dev_err(&u132->platform_dev->dev, "device hcd=%p is being remov"
			"ed\n", hcd);
		return -ESHUTDOWN;
	} else {
		int i, changed = 0, length = 1;
		if (u132->flags & OHCI_QUIRK_AMD756) {
			if ((u132->hc_roothub_a & RH_A_NDP) > MAX_ROOT_PORTS) {
				dev_err(&u132->platform_dev->dev, "bogus NDP, r"
					"ereads as NDP=%d\n",
					u132->hc_roothub_a & RH_A_NDP);
				goto done;
			}
		}
		if (u132->hc_roothub_status & (RH_HS_LPSC | RH_HS_OCIC))
			buf[0] = changed = 1;
		else
			buf[0] = 0;
		if (u132->num_ports > 7) {
			buf[1] = 0;
			length++;
		}
		for (i = 0; i < u132->num_ports; i++) {
			if (u132->hc_roothub_portstatus[i] & (RH_PS_CSC |
				RH_PS_PESC | RH_PS_PSSC | RH_PS_OCIC |
				RH_PS_PRSC)) {
				changed = 1;
				if (i < 7)
					buf[0] |= 1 << (i + 1);
				else
					buf[1] |= 1 << (i - 7);
				continue;
			}
			if (!(u132->hc_roothub_portstatus[i] & RH_PS_CCS))
				continue;

			if ((u132->hc_roothub_portstatus[i] & RH_PS_PSS))
				continue;
		}
done:
		return changed ? length : 0;
	}
}

static int u132_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
	u16 wIndex, char *buf, u16 wLength)
{
	struct u132 *u132 = hcd_to_u132(hcd);
	if (u132->going > 1) {
		dev_err(&u132->platform_dev->dev, "device has been removed %d\n"
			, u132->going);
		return -ENODEV;
	} else if (u132->going > 0) {
		dev_err(&u132->platform_dev->dev, "device is being removed\n");
		return -ESHUTDOWN;
	} else {
		int retval = 0;
		mutex_lock(&u132->sw_lock);
		switch (typeReq) {
		case ClearHubFeature:
			switch (wValue) {
			case C_HUB_OVER_CURRENT:
			case C_HUB_LOCAL_POWER:
				break;
			default:
				goto stall;
			}
			break;
		case SetHubFeature:
			switch (wValue) {
			case C_HUB_OVER_CURRENT:
			case C_HUB_LOCAL_POWER:
				break;
			default:
				goto stall;
			}
			break;
		case ClearPortFeature:{
				retval = u132_roothub_clearportfeature(u132,
					wValue, wIndex);
				if (retval)
					goto error;
				break;
			}
		case GetHubDescriptor:{
				retval = u132_roothub_descriptor(u132,
					(struct usb_hub_descriptor *)buf);
				if (retval)
					goto error;
				break;
			}
		case GetHubStatus:{
				retval = u132_roothub_status(u132,
					(__le32 *) buf);
				if (retval)
					goto error;
				break;
			}
		case GetPortStatus:{
				retval = u132_roothub_portstatus(u132,
					(__le32 *) buf, wIndex);
				if (retval)
					goto error;
				break;
			}
		case SetPortFeature:{
				retval = u132_roothub_setportfeature(u132,
					wValue, wIndex);
				if (retval)
					goto error;
				break;
			}
		default:
			goto stall;
		error:
			u132_disable(u132);
			u132->going = 1;
			break;
		stall:
			retval = -EPIPE;
			break;
		}
		mutex_unlock(&u132->sw_lock);
		return retval;
	}
}

static int u132_start_port_reset(struct usb_hcd *hcd, unsigned port_num)
{
	struct u132 *u132 = hcd_to_u132(hcd);
	if (u132->going > 1) {
		dev_err(&u132->platform_dev->dev, "device has been removed %d\n"
			, u132->going);
		return -ENODEV;
	} else if (u132->going > 0) {
		dev_err(&u132->platform_dev->dev, "device is being removed\n");
		return -ESHUTDOWN;
	} else
		return 0;
}

static void u132_hub_irq_enable(struct usb_hcd *hcd)
{
	struct u132 *u132 = hcd_to_u132(hcd);
	if (u132->going > 1) {
		dev_err(&u132->platform_dev->dev, "device has been removed %d\n"
			, u132->going);
	} else if (u132->going > 0)
		dev_err(&u132->platform_dev->dev, "device is being removed\n");
}


#ifdef CONFIG_PM
static int u132_bus_suspend(struct usb_hcd *hcd)
{
	struct u132 *u132 = hcd_to_u132(hcd);
	if (u132->going > 1) {
		dev_err(&u132->platform_dev->dev, "device has been removed %d\n"
			, u132->going);
		return -ENODEV;
	} else if (u132->going > 0) {
		dev_err(&u132->platform_dev->dev, "device is being removed\n");
		return -ESHUTDOWN;
	} else
		return 0;
}

static int u132_bus_resume(struct usb_hcd *hcd)
{
	struct u132 *u132 = hcd_to_u132(hcd);
	if (u132->going > 1) {
		dev_err(&u132->platform_dev->dev, "device has been removed %d\n"
			, u132->going);
		return -ENODEV;
	} else if (u132->going > 0) {
		dev_err(&u132->platform_dev->dev, "device is being removed\n");
		return -ESHUTDOWN;
	} else
		return 0;
}

#else
#define u132_bus_suspend NULL
#define u132_bus_resume NULL
#endif
static struct hc_driver u132_hc_driver = {
	.description = hcd_name,
	.hcd_priv_size = sizeof(struct u132),
	.irq = NULL,
	.flags = HCD_USB11 | HCD_MEMORY,
	.reset = u132_hcd_reset,
	.start = u132_hcd_start,
	.stop = u132_hcd_stop,
	.urb_enqueue = u132_urb_enqueue,
	.urb_dequeue = u132_urb_dequeue,
	.endpoint_disable = u132_endpoint_disable,
	.get_frame_number = u132_get_frame,
	.hub_status_data = u132_hub_status_data,
	.hub_control = u132_hub_control,
	.bus_suspend = u132_bus_suspend,
	.bus_resume = u132_bus_resume,
	.start_port_reset = u132_start_port_reset,
	.hub_irq_enable = u132_hub_irq_enable,
};

/*
* This function may be called by the USB core whilst the "usb_all_devices_rwsem"
* is held for writing, thus this module must not call usb_remove_hcd()
* synchronously - but instead should immediately stop activity to the
* device and asynchronously call usb_remove_hcd()
*/
static int __devexit u132_remove(struct platform_device *pdev)
{
	struct usb_hcd *hcd = platform_get_drvdata(pdev);
	if (hcd) {
		struct u132 *u132 = hcd_to_u132(hcd);
		if (u132->going++ > 1) {
			dev_err(&u132->platform_dev->dev, "already being remove"
				"d\n");
			return -ENODEV;
		} else {
			int rings = MAX_U132_RINGS;
			int endps = MAX_U132_ENDPS;
			dev_err(&u132->platform_dev->dev, "removing device u132"
				".%d\n", u132->sequence_num);
			msleep(100);
			mutex_lock(&u132->sw_lock);
			u132_monitor_cancel_work(u132);
			while (rings-- > 0) {
				struct u132_ring *ring = &u132->ring[rings];
				u132_ring_cancel_work(u132, ring);
			} while (endps-- > 0) {
				struct u132_endp *endp = u132->endp[endps];
				if (endp)
					u132_endp_cancel_work(u132, endp);
			}
			u132->going += 1;
			printk(KERN_INFO "removing device u132.%d\n",
				u132->sequence_num);
			mutex_unlock(&u132->sw_lock);
			usb_remove_hcd(hcd);
			u132_u132_put_kref(u132);
			return 0;
		}
	} else
		return 0;
}

static void u132_initialise(struct u132 *u132, struct platform_device *pdev)
{
	int rings = MAX_U132_RINGS;
	int ports = MAX_U132_PORTS;
	int addrs = MAX_U132_ADDRS;
	int udevs = MAX_U132_UDEVS;
	int endps = MAX_U132_ENDPS;
	u132->board = pdev->dev.platform_data;
	u132->platform_dev = pdev;
	u132->power = 0;
	u132->reset = 0;
	mutex_init(&u132->sw_lock);
	mutex_init(&u132->scheduler_lock);
	while (rings-- > 0) {
		struct u132_ring *ring = &u132->ring[rings];
		ring->u132 = u132;
		ring->number = rings + 1;
		ring->length = 0;
		ring->curr_endp = NULL;
		INIT_DELAYED_WORK(&ring->scheduler,
				  u132_hcd_ring_work_scheduler);
	}
	mutex_lock(&u132->sw_lock);
	INIT_DELAYED_WORK(&u132->monitor, u132_hcd_monitor_work);
	while (ports-- > 0) {
		struct u132_port *port = &u132->port[ports];
		port->u132 = u132;
		port->reset = 0;
		port->enable = 0;
		port->power = 0;
		port->Status = 0;
	}
	while (addrs-- > 0) {
		struct u132_addr *addr = &u132->addr[addrs];
		addr->address = 0;
	}
	while (udevs-- > 0) {
		struct u132_udev *udev = &u132->udev[udevs];
		int i = ARRAY_SIZE(udev->endp_number_in);
		int o = ARRAY_SIZE(udev->endp_number_out);
		udev->usb_device = NULL;
		udev->udev_number = 0;
		udev->usb_addr = 0;
		udev->portnumber = 0;
		while (i-- > 0)
			udev->endp_number_in[i] = 0;

		while (o-- > 0)
			udev->endp_number_out[o] = 0;

	}
	while (endps-- > 0)
		u132->endp[endps] = NULL;

	mutex_unlock(&u132->sw_lock);
	return;
}

static int __devinit u132_probe(struct platform_device *pdev)
{
	struct usb_hcd *hcd;
	int retval;
	u32 control;
	u32 rh_a = -1;
	u32 num_ports;

	msleep(100);
	if (u132_exiting > 0)
		return -ENODEV;

	retval = ftdi_write_pcimem(pdev, intrdisable, OHCI_INTR_MIE);
	if (retval)
		return retval;
	retval = ftdi_read_pcimem(pdev, control, &control);
	if (retval)
		return retval;
	retval = ftdi_read_pcimem(pdev, roothub.a, &rh_a);
	if (retval)
		return retval;
	num_ports = rh_a & RH_A_NDP;	/* refuse to confuse usbcore */
	if (pdev->dev.dma_mask)
		return -EINVAL;

	hcd = usb_create_hcd(&u132_hc_driver, &pdev->dev, pdev->dev.bus_id);
	if (!hcd) {
		printk(KERN_ERR "failed to create the usb hcd struct for U132\n"
			);
		ftdi_elan_gone_away(pdev);
		return -ENOMEM;
	} else {
		int retval = 0;
		struct u132 *u132 = hcd_to_u132(hcd);
		hcd->rsrc_start = 0;
		mutex_lock(&u132_module_lock);
		list_add_tail(&u132->u132_list, &u132_static_list);
		u132->sequence_num = ++u132_instances;
		mutex_unlock(&u132_module_lock);
		u132_u132_init_kref(u132);
		u132_initialise(u132, pdev);
		hcd->product_desc = "ELAN U132 Host Controller";
		retval = usb_add_hcd(hcd, 0, 0);
		if (retval != 0) {
			dev_err(&u132->platform_dev->dev, "init error %d\n",
				retval);
			u132_u132_put_kref(u132);
			return retval;
		} else {
			u132_monitor_queue_work(u132, 100);
			return 0;
		}
	}
}


#ifdef CONFIG_PM
/* for this device there's no useful distinction between the controller
* and its root hub, except that the root hub only gets direct PM calls
* when CONFIG_USB_SUSPEND is enabled.
*/
static int u132_suspend(struct platform_device *pdev, pm_message_t state)
{
	struct usb_hcd *hcd = platform_get_drvdata(pdev);
	struct u132 *u132 = hcd_to_u132(hcd);
	if (u132->going > 1) {
		dev_err(&u132->platform_dev->dev, "device has been removed %d\n"
			, u132->going);
		return -ENODEV;
	} else if (u132->going > 0) {
		dev_err(&u132->platform_dev->dev, "device is being removed\n");
		return -ESHUTDOWN;
	} else {
		int retval = 0, ports;

		switch (state.event) {
		case PM_EVENT_FREEZE:
			retval = u132_bus_suspend(hcd);
			break;
		case PM_EVENT_SUSPEND:
		case PM_EVENT_HIBERNATE:
			ports = MAX_U132_PORTS;
			while (ports-- > 0) {
				port_power(u132, ports, 0);
			}
			break;
		}
		return retval;
	}
}

static int u132_resume(struct platform_device *pdev)
{
	struct usb_hcd *hcd = platform_get_drvdata(pdev);
	struct u132 *u132 = hcd_to_u132(hcd);
	if (u132->going > 1) {
		dev_err(&u132->platform_dev->dev, "device has been removed %d\n"
			, u132->going);
		return -ENODEV;
	} else if (u132->going > 0) {
		dev_err(&u132->platform_dev->dev, "device is being removed\n");
		return -ESHUTDOWN;
	} else {
		int retval = 0;
		if (!u132->port[0].power) {
			int ports = MAX_U132_PORTS;
			while (ports-- > 0) {
				port_power(u132, ports, 1);
			}
			retval = 0;
		} else {
			retval = u132_bus_resume(hcd);
		}
		return retval;
	}
}

#else
#define u132_suspend NULL
#define u132_resume NULL
#endif
/*
* this driver is loaded explicitly by ftdi_u132
*
* the platform_driver struct is static because it is per type of module
*/
static struct platform_driver u132_platform_driver = {
	.probe = u132_probe,
	.remove = __devexit_p(u132_remove),
	.suspend = u132_suspend,
	.resume = u132_resume,
	.driver = {
		   .name = (char *)hcd_name,
		   .owner = THIS_MODULE,
		   },
};
static int __init u132_hcd_init(void)
{
	int retval;
	INIT_LIST_HEAD(&u132_static_list);
	u132_instances = 0;
	u132_exiting = 0;
	mutex_init(&u132_module_lock);
	if (usb_disabled())
		return -ENODEV;
	printk(KERN_INFO "driver %s built at %s on %s\n", hcd_name, __TIME__,
		__DATE__);
	workqueue = create_singlethread_workqueue("u132");
	retval = platform_driver_register(&u132_platform_driver);
	return retval;
}


module_init(u132_hcd_init);
static void __exit u132_hcd_exit(void)
{
	struct u132 *u132;
	struct u132 *temp;
	mutex_lock(&u132_module_lock);
	u132_exiting += 1;
	mutex_unlock(&u132_module_lock);
	list_for_each_entry_safe(u132, temp, &u132_static_list, u132_list) {
		platform_device_unregister(u132->platform_dev);
	}
	platform_driver_unregister(&u132_platform_driver);
	printk(KERN_INFO "u132-hcd driver deregistered\n");
	wait_event(u132_hcd_wait, u132_instances == 0);
	flush_workqueue(workqueue);
	destroy_workqueue(workqueue);
}


module_exit(u132_hcd_exit);
MODULE_LICENSE("GPL");
MODULE_ALIAS("platform:u132_hcd");
