/*
* 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 = 0;
static int u132_instances = 0;
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 semaphore 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);
        } down(&u132->scheduler_lock);
        ring = endp->ring;
        ring->in_use = 0;
        u132_ring_cancel_work(u132, ring);
        u132_ring_queue_work(u132, ring, 0);
        up(&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];
        down(&u132->scheduler_lock);
        if (u132->going > 1) {
                dev_err(&u132->platform_dev->dev, "device has been removed %d\n"
                        , u132->going);
                up(&u132->scheduler_lock);
                u132_hcd_forget_urb(u132, endp, urb, -ENODEV);
                return;
        } else if (endp->dequeueing) {
                endp->dequeueing = 0;
                up(&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);
                up(&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;
                                up(&u132->scheduler_lock);
                                retval = edset_single(u132, ring, endp, urb,
                                        address, endp->toggle_bits,
                                        u132_hcd_interrupt_recv);
                                if (retval == 0) {
                                } else
                                        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);
                                up(&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);
                        up(&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]);
                        }
                        up(&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);
                up(&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;
        down(&u132->scheduler_lock);
        if (u132->going > 1) {
                dev_err(&u132->platform_dev->dev, "device has been removed %d\n"
                        , u132->going);
                up(&u132->scheduler_lock);
                u132_hcd_forget_urb(u132, endp, urb, -ENODEV);
                return;
        } else if (endp->dequeueing) {
                endp->dequeueing = 0;
                up(&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);
                up(&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;
                        up(&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;
                } else {
                        up(&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);
                up(&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];
        down(&u132->scheduler_lock);
        if (u132->going > 1) {
                dev_err(&u132->platform_dev->dev, "device has been removed %d\n"
                        , u132->going);
                up(&u132->scheduler_lock);
                u132_hcd_forget_urb(u132, endp, urb, -ENODEV);
                return;
        } else if (endp->dequeueing) {
                endp->dequeueing = 0;
                up(&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);
                up(&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);
                        up(&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) {
                        } else
                                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);
                        up(&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);
                        up(&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]);
                        up(&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);
                        up(&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]);
                        up(&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);
                up(&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;
        down(&u132->scheduler_lock);
        if (u132->going > 1) {
                dev_err(&u132->platform_dev->dev, "device has been removed %d\n"
                        , u132->going);
                up(&u132->scheduler_lock);
                u132_hcd_forget_urb(u132, endp, urb, -ENODEV);
                return;
        } else if (endp->dequeueing) {
                endp->dequeueing = 0;
                up(&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);
                up(&u132->scheduler_lock);
                u132_hcd_giveback_urb(u132, endp, urb, -ENODEV);
                return;
	} else if (!urb->unlinked) {
                up(&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);
                up(&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;
        down(&u132->scheduler_lock);
        if (u132->going > 1) {
                dev_err(&u132->platform_dev->dev, "device has been removed %d\n"
                        , u132->going);
                up(&u132->scheduler_lock);
                u132_hcd_forget_urb(u132, endp, urb, -ENODEV);
                return;
        } else if (endp->dequeueing) {
                endp->dequeueing = 0;
                up(&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);
                up(&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;
                        up(&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) {
                        } else
                                u132_hcd_giveback_urb(u132, endp, urb, retval);
                        return;
                } else if (condition_code == TD_CC_STALL) {
                        up(&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 {
                        up(&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);
                up(&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;
        down(&u132->scheduler_lock);
        if (u132->going > 1) {
                dev_err(&u132->platform_dev->dev, "device has been removed %d\n"
                        , u132->going);
                up(&u132->scheduler_lock);
                u132_hcd_forget_urb(u132, endp, urb, -ENODEV);
                return;
        } else if (endp->dequeueing) {
                endp->dequeueing = 0;
                up(&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);
                up(&u132->scheduler_lock);
                u132_hcd_giveback_urb(u132, endp, urb, -ENODEV);
                return;
	} else if (!urb->unlinked) {
                up(&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);
                up(&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;
        down(&u132->scheduler_lock);
        if (u132->going > 1) {
                dev_err(&u132->platform_dev->dev, "device has been removed %d\n"
                        , u132->going);
                up(&u132->scheduler_lock);
                u132_hcd_forget_urb(u132, endp, urb, -ENODEV);
                return;
        } else if (endp->dequeueing) {
                endp->dequeueing = 0;
                up(&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);
                up(&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;
                        up(&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) {
                        } else
                                u132_hcd_giveback_urb(u132, endp, urb, retval);
                        return;
                } else {
                        int retval;
                        struct u132_ring *ring = endp->ring;
                        up(&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) {
                        } else
                                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);
                up(&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];
        down(&u132->scheduler_lock);
        if (u132->going > 1) {
                dev_err(&u132->platform_dev->dev, "device has been removed %d\n"
                        , u132->going);
                up(&u132->scheduler_lock);
                u132_hcd_forget_urb(u132, endp, urb, -ENODEV);
                return;
        } else if (endp->dequeueing) {
                endp->dequeueing = 0;
                up(&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);
                up(&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;
                up(&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);
                up(&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;
        down(&u132->scheduler_lock);
        if (u132->going > 1) {
                dev_err(&u132->platform_dev->dev, "device has been removed %d\n"
                        , u132->going);
                up(&u132->scheduler_lock);
                u132_hcd_forget_urb(u132, endp, urb, -ENODEV);
                return;
        } else if (endp->dequeueing) {
                endp->dequeueing = 0;
                up(&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);
                up(&u132->scheduler_lock);
                u132_hcd_giveback_urb(u132, endp, urb, -ENODEV);
                return;
	} else if (!urb->unlinked) {
                int retval;
                struct u132_ring *ring = endp->ring;
                up(&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) {
                } else
                        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);
                up(&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;
        down(&u132->scheduler_lock);
        if (u132->going > 1) {
                dev_err(&u132->platform_dev->dev, "device has been removed %d\n"
                        , u132->going);
                up(&u132->scheduler_lock);
                u132_hcd_forget_urb(u132, endp, urb, -ENODEV);
                return;
        } else if (endp->dequeueing) {
                endp->dequeueing = 0;
                up(&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);
                up(&u132->scheduler_lock);
                u132_hcd_giveback_urb(u132, endp, urb, -ENODEV);
                return;
	} else if (!urb->unlinked) {
                up(&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);
                up(&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;
        down(&u132->scheduler_lock);
        if (u132->going > 1) {
                dev_err(&u132->platform_dev->dev, "device has been removed %d\n"
                        , u132->going);
                up(&u132->scheduler_lock);
                u132_hcd_forget_urb(u132, endp, urb, -ENODEV);
                return;
        } else if (endp->dequeueing) {
                endp->dequeueing = 0;
                up(&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);
                up(&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;
                up(&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) {
                } else
                        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);
                up(&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;
        down(&u132->scheduler_lock);
        if (u132->going > 1) {
                dev_err(&u132->platform_dev->dev, "device has been removed %d\n"
                        , u132->going);
                up(&u132->scheduler_lock);
                u132_hcd_forget_urb(u132, endp, urb, -ENODEV);
                return;
        } else if (endp->dequeueing) {
                endp->dequeueing = 0;
                up(&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);
                up(&u132->scheduler_lock);
                u132_hcd_giveback_urb(u132, endp, urb, -ENODEV);
                return;
	} else if (!urb->unlinked) {
                int retval;
                struct u132_ring *ring = endp->ring;
                up(&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) {
                } else
                        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);
                up(&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;
        down(&u132->scheduler_lock);
        if (ring->in_use) {
                up(&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);
                                up(&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);
                        up(&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);
                        up(&u132->scheduler_lock);
                        return;
                } else {
                        up(&u132->scheduler_lock);
                        u132_ring_put_kref(u132, ring);
                        return;
                }
        } else {
                up(&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;
        down(&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);
                up(&u132->scheduler_lock);
                u132_endp_put_kref(u132, endp);
                return;
        } else if (endp->active) {
                up(&u132->scheduler_lock);
                u132_endp_put_kref(u132, endp);
                return;
        } else if (ring->in_use) {
                up(&u132->scheduler_lock);
                u132_endp_put_kref(u132, endp);
                return;
        } else if (endp->queue_next == endp->queue_last) {
                up(&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) {
                        up(&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;
                        up(&u132->scheduler_lock);
                        retval = edset_single(u132, ring, endp, urb, address,
                                endp->toggle_bits, u132_hcd_interrupt_recv);
                        if (retval == 0) {
                        } else
                                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) {
                        up(&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;
                        up(&u132->scheduler_lock);
                        retval = edset_setup(u132, ring, endp, urb, address,
                                0x2, u132_hcd_initial_setup_sent);
                        if (retval == 0) {
                        } else
                                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;
                        up(&u132->scheduler_lock);
                        retval = edset_setup(u132, ring, endp, urb, 0, 0x2,
                                u132_hcd_enumeration_address_sent);
                        if (retval == 0) {
                        } else
                                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;
                        up(&u132->scheduler_lock);
                        retval = edset_setup(u132, ring, endp, urb, address,
                                0x2, u132_hcd_configure_setup_sent);
                        if (retval == 0) {
                        } else
                                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) {
                                up(&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;
                                up(&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) {
                                up(&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;
                                up(&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;
                hcd->self.controller->power.power_state = PMSG_ON;
        } else {
                u132->power = 0;
                hcd->state = HC_STATE_HALT;
                hcd->self.controller->power.power_state = PMSG_SUSPEND;
        }
}

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;
                if (u132->hc_fminterval != FI) {
                }
                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) {
                } else
                        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_hcd_suspend(struct usb_hcd *hcd, pm_message_t message)
{
        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_hcd_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;
}

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_hcd_suspend NULL
#define u132_hcd_resume NULL
#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,
        .suspend = u132_hcd_suspend,
        .resume = u132_hcd_resume,
        .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);
        init_MUTEX(&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;
                if (state.event == PM_EVENT_FREEZE) {
                        retval = u132_bus_suspend(hcd);
                } else if (state.event == PM_EVENT_SUSPEND) {
                        int ports = MAX_U132_PORTS;
                        while (ports-- > 0) {
                                port_power(u132, ports, 0);
                        }
                }
                if (retval == 0)
                        pdev->dev.power.power_state = state;
                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 (pdev->dev.power.power_state.event == PM_EVENT_SUSPEND) {
                        int ports = MAX_U132_PORTS;
                        while (ports-- > 0) {
                                port_power(u132, ports, 1);
                        }
                        retval = 0;
                } else {
                        pdev->dev.power.power_state = PMSG_ON;
                        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");
