/*
* 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/sched.h>
#include <linux/slab.h>
#include <linux/smp_lock.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/pci_ids.h>
#include <asm/io.h>
#include <asm/irq.h>
#include <asm/system.h>
#include <asm/byteorder.h>
#include "../core/hcd.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");
DECLARE_WAIT_QUEUE_HEAD(u132_hcd_wait);
/*
* u132_module_lock exists to protect access to global variables
*
*/
static struct semaphore 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 work_struct scheduler;
};
struct u132_ring {
        unsigned in_use:1;
        unsigned length:7;
        u8 number;
        struct u132 *u132;
        struct u132_endp *curr_endp;
        struct work_struct scheduler;
};
#define OHCI_QUIRK_AMD756 0x01
#define OHCI_QUIRK_SUPERIO 0x02
#define OHCI_QUIRK_INITRESET 0x04
#define OHCI_BIG_ENDIAN 0x08
#define OHCI_QUIRK_ZFMICRO 0x10
struct u132 {
        struct kref kref;
        struct list_head u132_list;
        struct semaphore 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 work_struct 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];
};
int usb_ftdi_elan_read_reg(struct platform_device *pdev, u32 *data);
int usb_ftdi_elan_read_pcimem(struct platform_device *pdev, u8 addressofs,
        u8 width, u32 *data);
int usb_ftdi_elan_write_pcimem(struct platform_device *pdev, u8 addressofs,
        u8 width, u32 data);
/*
* these can not be inlines because we need the structure offset!!
* Does anyone have a better way?????
*/
#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);
#define u132_write_pcimem_byte(u132, member, data) \
        usb_ftdi_elan_write_pcimem(u132->platform_dev, offsetof(struct \
        ohci_regs, member), 0x0e, 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;
        down(&u132_module_lock);
        list_del_init(&u132->u132_list);
        u132_instances -= 1;
        up(&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_work(workqueue, &ring->scheduler))
                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 (delta > 0) {
                if (queue_delayed_work(workqueue, &endp->scheduler, delta))
                        kref_get(&endp->kref);
        } else if (queue_work(workqueue, &endp->scheduler))
                kref_get(&endp->kref);
        return;
}

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 (delta > 0) {
                if (queue_delayed_work(workqueue, &u132->monitor, delta)) {
                        kref_get(&u132->kref);
                }
        } else if (queue_work(workqueue, &u132->monitor))
                kref_get(&u132->kref);
        return;
}

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

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(void *data)
{
        struct u132 *u132 = data;
        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;
                down(&u132->sw_lock);
                retval = read_roothub_info(u132);
                if (retval) {
                        struct usb_hcd *hcd = u132_to_hcd(u132);
                        u132_disable(u132);
                        u132->going = 1;
                        up(&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);
                        up(&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;
        urb->status = status;
        urb->hcpriv = NULL;
        spin_lock_irqsave(&endp->queue_lock.slock, irqs);
        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, NULL);
        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;
        urb->status = status;
        urb->hcpriv = NULL;
        spin_lock_irqsave(&endp->queue_lock.slock, irqs);
        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, NULL);
        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 status=%d\n", urb, urb->status);
                up(&u132->scheduler_lock);
                u132_hcd_giveback_urb(u132, endp, urb, -ENODEV);
                return;
        } else if (urb->status == -EINPROGRESS) {
                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 statu"
                        "s=%d\n", urb, urb->status);
                up(&u132->scheduler_lock);
                u132_hcd_giveback_urb(u132, endp, urb, urb->status);
                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 status=%d\n", urb, urb->status);
                up(&u132->scheduler_lock);
                u132_hcd_giveback_urb(u132, endp, urb, -ENODEV);
                return;
        } else if (urb->status == -EINPROGRESS) {
                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 statu"
                        "s=%d\n", urb, urb->status);
                up(&u132->scheduler_lock);
                u132_hcd_giveback_urb(u132, endp, urb, urb->status);
                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 status=%d\n", urb, urb->status);
                up(&u132->scheduler_lock);
                u132_hcd_giveback_urb(u132, endp, urb, -ENODEV);
                return;
        } else if (urb->status == -EINPROGRESS) {
                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 statu"
                        "s=%d\n", urb, urb->status);
                up(&u132->scheduler_lock);
                u132_hcd_giveback_urb(u132, endp, urb, urb->status);
                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 status=%d\n", urb, urb->status);
                up(&u132->scheduler_lock);
                u132_hcd_giveback_urb(u132, endp, urb, -ENODEV);
                return;
        } else if (urb->status == -EINPROGRESS) {
                up(&u132->scheduler_lock);
                u132_hcd_giveback_urb(u132, endp, urb, 0);
                return;
        } else {
                dev_err(&u132->platform_dev->dev, "CALLBACK called urb=%p statu"
                        "s=%d\n", urb, urb->status);
                up(&u132->scheduler_lock);
                u132_hcd_giveback_urb(u132, endp, urb, urb->status);
                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 status=%d\n", urb, urb->status);
                up(&u132->scheduler_lock);
                u132_hcd_giveback_urb(u132, endp, urb, -ENODEV);
                return;
        } else if (urb->status == -EINPROGRESS) {
                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 statu"
                        "s=%d\n", urb, urb->status);
                up(&u132->scheduler_lock);
                u132_hcd_giveback_urb(u132, endp, urb, urb->status);
                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 status=%d\n", urb, urb->status);
                up(&u132->scheduler_lock);
                u132_hcd_giveback_urb(u132, endp, urb, -ENODEV);
                return;
        } else if (urb->status == -EINPROGRESS) {
                up(&u132->scheduler_lock);
                u132_hcd_giveback_urb(u132, endp, urb, 0);
                return;
        } else {
                dev_err(&u132->platform_dev->dev, "CALLBACK called urb=%p statu"
                        "s=%d\n", urb, urb->status);
                up(&u132->scheduler_lock);
                u132_hcd_giveback_urb(u132, endp, urb, urb->status);
                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 status=%d\n", urb, urb->status);
                up(&u132->scheduler_lock);
                u132_hcd_giveback_urb(u132, endp, urb, -ENODEV);
                return;
        } else if (urb->status == -EINPROGRESS) {
                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 statu"
                        "s=%d\n", urb, urb->status);
                up(&u132->scheduler_lock);
                u132_hcd_giveback_urb(u132, endp, urb, urb->status);
                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 status=%d\n", urb, urb->status);
                up(&u132->scheduler_lock);
                u132_hcd_giveback_urb(u132, endp, urb, -ENODEV);
                return;
        } else if (urb->status == -EINPROGRESS) {
                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 statu"
                        "s=%d\n", urb, urb->status);
                up(&u132->scheduler_lock);
                u132_hcd_giveback_urb(u132, endp, urb, urb->status);
                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 status=%d\n", urb, urb->status);
                up(&u132->scheduler_lock);
                u132_hcd_giveback_urb(u132, endp, urb, -ENODEV);
                return;
        } else if (urb->status == -EINPROGRESS) {
                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 statu"
                        "s=%d\n", urb, urb->status);
                up(&u132->scheduler_lock);
                u132_hcd_giveback_urb(u132, endp, urb, urb->status);
                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 status=%d\n", urb, urb->status);
                up(&u132->scheduler_lock);
                u132_hcd_giveback_urb(u132, endp, urb, -ENODEV);
                return;
        } else if (urb->status == -EINPROGRESS) {
                up(&u132->scheduler_lock);
                u132_hcd_giveback_urb(u132, endp, urb, 0);
                return;
        } else {
                dev_err(&u132->platform_dev->dev, "CALLBACK called urb=%p statu"
                        "s=%d\n", urb, urb->status);
                up(&u132->scheduler_lock);
                u132_hcd_giveback_urb(u132, endp, urb, urb->status);
                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 status=%d\n", urb, urb->status);
                up(&u132->scheduler_lock);
                u132_hcd_giveback_urb(u132, endp, urb, -ENODEV);
                return;
        } else if (urb->status == -EINPROGRESS) {
                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 statu"
                        "s=%d\n", urb, urb->status);
                up(&u132->scheduler_lock);
                u132_hcd_giveback_urb(u132, endp, urb, urb->status);
                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 status=%d\n", urb, urb->status);
                up(&u132->scheduler_lock);
                u132_hcd_giveback_urb(u132, endp, urb, -ENODEV);
                return;
        } else if (urb->status == -EINPROGRESS) {
                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 statu"
                        "s=%d\n", urb, urb->status);
                up(&u132->scheduler_lock);
                u132_hcd_giveback_urb(u132, endp, urb, urb->status);
                return;
        }
}

static void u132_hcd_ring_work_scheduler(void *data);
static void u132_hcd_endp_work_scheduler(void *data);
/*
* this work function is only executed from the work queue
*
*/
static void u132_hcd_ring_work_scheduler(void *data)
{
        struct u132_ring *ring = data;
        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(void *data)
{
        struct u132_ring *ring;
        struct u132_endp *endp = data;
        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;
                        }
                }
        }
}

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

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_usb_reset(struct u132 *u132)
{
        int retval;
        retval = u132_read_pcimem(u132, control, &u132->hc_control);
        if (retval)
                return retval;
        u132->hc_control &= OHCI_CTRL_RWC;
        retval = u132_write_pcimem(u132, control, u132->hc_control);
        if (retval)
                return retval;
        return 0;
}

static int u132_init(struct u132 *u132)
{
        int retval;
        u32 control;
        u132_disable(u132);
        u132->next_statechange =
                jiffies; /* SMM owns the HC? not for long! */  {
                u32 control;
                retval = u132_read_pcimem(u132, control, &control);
                if (retval)
                        return retval;
                if (control & OHCI_CTRL_IR) {
                        u32 temp = 50;
                        retval = u132_write_pcimem(u132, intrenable,
                                OHCI_INTR_OC);
                        if (retval)
                                return retval;
                        retval = u132_write_pcimem_byte(u132, cmdstatus,
                                OHCI_OCR);
                        if (retval)
                                return retval;
                      check:{
                                retval = u132_read_pcimem(u132, control,
                                        &control);
                                if (retval)
                                        return retval;
                        }
                        if (control & OHCI_CTRL_IR) {
                                msleep(10);
                                if (--temp == 0) {
                                        dev_err(&u132->platform_dev->dev, "USB "
                                                "HC takeover failed!(BIOS/SMM b"
                                                "ug) control=%08X\n", control);
                                        return -EBUSY;
                                }
                                goto check;
                        }
                        u132_usb_reset(u132);
                }
        }
        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_byte(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_byte(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, "device has been removed %d\n"
                        , u132->going);
        } else if (u132->going > 0) {
                dev_err(&u132->platform_dev->dev, "device hcd=%p is being remov"
                        "ed\n", hcd);
        } else {
                down(&u132->sw_lock);
                msleep(100);
                u132_power(u132, 0);
                up(&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;
                down(&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);
                up(&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;
                down(&u132->sw_lock);
                retval = u132_init(u132);
                if (retval) {
                        u132_disable(u132);
                        u132->going = 1;
                }
                up(&u132->sw_lock);
                return retval;
        }
}

static int create_endpoint_and_queue_int(struct u132 *u132,
        struct u132_udev *udev, struct usb_host_endpoint *hep, 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;
        u8 endp_number = ++u132->num_endpoints;
        struct u132_endp *endp = hep->hcpriv = u132->endp[endp_number - 1] =
                kmalloc(sizeof(struct u132_endp), mem_flags);
        if (!endp) {
                return -ENOMEM;
        }
        INIT_WORK(&endp->scheduler, u132_hcd_endp_work_scheduler, (void *)endp);
        spin_lock_init(&endp->queue_lock.slock);
        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 = hep;
        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;
        spin_lock_irqsave(&endp->queue_lock.slock, irqs);
        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 usb_host_endpoint *hep, 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 usb_host_endpoint *hep, 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;
        u8 endp_number = ++u132->num_endpoints;
        struct u132_endp *endp = hep->hcpriv = u132->endp[endp_number - 1] =
                kmalloc(sizeof(struct u132_endp), mem_flags);
        if (!endp) {
                return -ENOMEM;
        }
        INIT_WORK(&endp->scheduler, u132_hcd_endp_work_scheduler, (void *)endp);
        spin_lock_init(&endp->queue_lock.slock);
        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 = hep;
        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;
        spin_lock_irqsave(&endp->queue_lock.slock, irqs);
        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 usb_host_endpoint *hep, 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 usb_host_endpoint *hep, struct urb *urb,
        struct usb_device *usb_dev, u8 usb_addr, u8 usb_endp,
        gfp_t mem_flags)
{
        struct u132_ring *ring;
        u8 endp_number = ++u132->num_endpoints;
        struct u132_endp *endp = hep->hcpriv = u132->endp[endp_number - 1] =
                kmalloc(sizeof(struct u132_endp), mem_flags);
        if (!endp) {
                return -ENOMEM;
        }
        INIT_WORK(&endp->scheduler, u132_hcd_endp_work_scheduler, (void *)endp);
        spin_lock_init(&endp->queue_lock.slock);
        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 = hep;
        u132_endp_init_kref(u132, endp);
        u132_endp_get_kref(u132, endp);
        if (usb_addr == 0) {
                unsigned long irqs;
                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;
                spin_lock_irqsave(&endp->queue_lock.slock, irqs);
                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) */
                unsigned long irqs;
                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;
                spin_lock_irqsave(&endp->queue_lock.slock, irqs);
                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 usb_host_endpoint *hep, 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 usb_host_endpoint *hep,
        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 status=%d\n", urb, urb->status);
                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 = hep->hcpriv;
                        urb->actual_length = 0;
                        if (endp) {
                                unsigned long irqs;
                                int retval;
                                spin_lock_irqsave(&endp->queue_lock.slock,
                                        irqs);
                                retval = queue_int_on_old_endpoint(u132, udev,
                                        hep, urb, usb_dev, endp, usb_addr,
                                        usb_endp, address);
                                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,
                                         hep, 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 = hep->hcpriv;
                        urb->actual_length = 0;
                        if (endp) {
                                unsigned long irqs;
                                int retval;
                                spin_lock_irqsave(&endp->queue_lock.slock,
                                        irqs);
                                retval = queue_bulk_on_old_endpoint(u132, udev,
                                        hep, urb, usb_dev, endp, usb_addr,
                                        usb_endp, address);
                                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, hep, urb, usb_dev, usb_addr,
                                        usb_endp, address, mem_flags);
                } else {
                        struct u132_endp *endp = hep->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 = queue_control_on_old_endpoint(u132,
                                        hep, urb, usb_dev, endp, usb_addr,
                                        usb_endp);
                                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,
                                        hep, 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;
                        urb->hcpriv = NULL;
                        usb_hcd_giveback_urb(hcd, urb, NULL);
                        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)
{
        unsigned long irqs;
        spin_lock_irqsave(&endp->queue_lock.slock, irqs);
        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);
                        urb->hcpriv = NULL;
                        return 0;
                } else {
                        spin_unlock_irqrestore(&endp->queue_lock.slock, irqs);
                        u132_hcd_abandon_urb(u132, endp, urb, 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);
                        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;
                        urb->hcpriv = NULL;
                        usb_hcd_giveback_urb(hcd, urb, NULL);
                        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 = 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)
{
        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);
                } 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);
                }
        }
}

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, "device has been removed %d\n"
                        , 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);
                dump_stack();
                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;
                down(&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;
                }
                up(&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 ansynchronously 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);
                dump_stack();
                if (u132->going++ > 1) {
                        return -ENODEV;
                } else {
                        int rings = MAX_U132_RINGS;
                        int endps = MAX_U132_ENDPS;
                        msleep(100);
                        down(&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);
                        up(&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;
        init_MUTEX(&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_WORK(&ring->scheduler, u132_hcd_ring_work_scheduler,
                        (void *)ring);
        } down(&u132->sw_lock);
        INIT_WORK(&u132->monitor, u132_hcd_monitor_work, (void *)u132);
        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;
        }
        up(&u132->sw_lock);
        return;
}

static int __devinit u132_probe(struct platform_device *pdev)
{
        struct usb_hcd *hcd;
        msleep(100);
        if (u132_exiting > 0) {
                return -ENODEV;
        }                        /* 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;
                down(&u132_module_lock);
                list_add_tail(&u132->u132_list, &u132_static_list);
                u132->sequence_num = ++u132_instances;
                up(&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 explicitely 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;
        init_MUTEX(&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;
        down(&u132_module_lock);
        u132_exiting += 1;
        up(&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");
