2007-03-19 19:34:37 +02:00
|
|
|
/*
|
2007-12-05 11:32:04 +02:00
|
|
|
* ADM5120 HCD (Host Controller Driver) for USB
|
2007-03-19 19:34:37 +02:00
|
|
|
*
|
2007-12-05 11:32:04 +02:00
|
|
|
* Copyright (C) 2007 Gabor Juhos <juhosg at openwrt.org>
|
2007-03-19 19:34:37 +02:00
|
|
|
*
|
2007-12-05 11:32:04 +02:00
|
|
|
* This file was derived from: drivers/usb/host/ohci-hcd.c
|
|
|
|
* (C) Copyright 1999 Roman Weissgaerber <weissg@vienna.at>
|
|
|
|
* (C) Copyright 2000-2004 David Brownell <dbrownell@users.sourceforge.net>
|
2007-09-21 10:32:19 +03:00
|
|
|
*
|
2007-12-05 11:32:04 +02:00
|
|
|
* [ Initialisation is based on Linus' ]
|
|
|
|
* [ uhci code and gregs ahcd fragments ]
|
|
|
|
* [ (C) Copyright 1999 Linus Torvalds ]
|
|
|
|
* [ (C) Copyright 1999 Gregory P. Smith]
|
2007-09-21 10:32:19 +03:00
|
|
|
*
|
|
|
|
* This file is licenced under the GPL.
|
2007-03-19 19:34:37 +02:00
|
|
|
*/
|
|
|
|
|
2007-04-08 13:15:17 +03:00
|
|
|
#include <linux/module.h>
|
2007-09-21 10:32:19 +03:00
|
|
|
#include <linux/moduleparam.h>
|
|
|
|
#include <linux/pci.h>
|
|
|
|
#include <linux/kernel.h>
|
2007-04-08 13:15:17 +03:00
|
|
|
#include <linux/delay.h>
|
2007-09-21 10:32:19 +03:00
|
|
|
#include <linux/ioport.h>
|
|
|
|
#include <linux/sched.h>
|
|
|
|
#include <linux/slab.h>
|
2007-03-19 19:34:37 +02:00
|
|
|
#include <linux/errno.h>
|
2007-04-08 13:15:17 +03:00
|
|
|
#include <linux/init.h>
|
2007-09-21 10:32:19 +03:00
|
|
|
#include <linux/timer.h>
|
2007-04-08 13:15:17 +03:00
|
|
|
#include <linux/list.h>
|
2007-03-19 19:34:37 +02:00
|
|
|
#include <linux/usb.h>
|
2007-09-21 10:32:19 +03:00
|
|
|
#include <linux/usb/otg.h>
|
|
|
|
#include <linux/dma-mapping.h>
|
|
|
|
#include <linux/dmapool.h>
|
|
|
|
#include <linux/reboot.h>
|
2007-03-19 19:34:37 +02:00
|
|
|
|
2007-04-08 13:15:17 +03:00
|
|
|
#include <asm/io.h>
|
|
|
|
#include <asm/irq.h>
|
|
|
|
#include <asm/system.h>
|
2007-09-21 10:32:19 +03:00
|
|
|
#include <asm/unaligned.h>
|
2007-04-08 13:15:17 +03:00
|
|
|
#include <asm/byteorder.h>
|
|
|
|
|
2007-03-19 19:34:37 +02:00
|
|
|
#include "../core/hcd.h"
|
2007-09-21 10:32:19 +03:00
|
|
|
#include "../core/hub.h"
|
2007-03-19 19:34:37 +02:00
|
|
|
|
2007-12-05 11:32:04 +02:00
|
|
|
#define DRIVER_VERSION "0.14.1"
|
2007-09-21 10:32:19 +03:00
|
|
|
#define DRIVER_AUTHOR "Gabor Juhos <juhosg at openwrt.org>"
|
|
|
|
#define DRIVER_DESC "ADMtek USB 1.1 Host Controller Driver"
|
2007-03-19 19:34:37 +02:00
|
|
|
|
2007-09-21 10:32:19 +03:00
|
|
|
/*-------------------------------------------------------------------------*/
|
2007-04-08 13:15:17 +03:00
|
|
|
|
2007-11-15 11:16:47 +02:00
|
|
|
#undef ADMHC_VERBOSE_DEBUG /* not always helpful */
|
2007-03-19 19:34:37 +02:00
|
|
|
|
2007-09-21 10:32:19 +03:00
|
|
|
/* For initializing controller (mask in an HCFS mode too) */
|
|
|
|
#define OHCI_CONTROL_INIT OHCI_CTRL_CBSR
|
2007-03-19 19:34:37 +02:00
|
|
|
|
2007-09-21 10:32:19 +03:00
|
|
|
#define ADMHC_INTR_INIT \
|
|
|
|
( ADMHC_INTR_MIE | ADMHC_INTR_INSM | ADMHC_INTR_FATI \
|
2007-11-23 17:53:35 +02:00
|
|
|
| ADMHC_INTR_RESI | ADMHC_INTR_TDC | ADMHC_INTR_BABI )
|
2007-03-19 19:34:37 +02:00
|
|
|
|
2007-09-21 10:32:19 +03:00
|
|
|
/*-------------------------------------------------------------------------*/
|
2007-03-19 19:34:37 +02:00
|
|
|
|
2007-09-21 10:32:19 +03:00
|
|
|
static const char hcd_name [] = "admhc-hcd";
|
2007-03-19 19:34:37 +02:00
|
|
|
|
2007-09-21 10:32:19 +03:00
|
|
|
#define STATECHANGE_DELAY msecs_to_jiffies(300)
|
2007-03-19 19:34:37 +02:00
|
|
|
|
2007-09-21 10:32:19 +03:00
|
|
|
#include "adm5120.h"
|
2007-03-19 19:34:37 +02:00
|
|
|
|
2007-09-21 10:32:19 +03:00
|
|
|
static void admhc_dump(struct admhcd *ahcd, int verbose);
|
|
|
|
static int admhc_init(struct admhcd *ahcd);
|
|
|
|
static void admhc_stop(struct usb_hcd *hcd);
|
2007-03-19 19:34:37 +02:00
|
|
|
|
2007-09-21 10:32:19 +03:00
|
|
|
#include "adm5120-dbg.c"
|
|
|
|
#include "adm5120-mem.c"
|
2007-11-08 14:28:27 +02:00
|
|
|
#include "adm5120-pm.c"
|
|
|
|
#include "adm5120-hub.c"
|
2007-09-21 10:32:19 +03:00
|
|
|
#include "adm5120-q.c"
|
2007-03-19 19:34:37 +02:00
|
|
|
|
2007-09-21 10:32:19 +03:00
|
|
|
/*-------------------------------------------------------------------------*/
|
2007-03-19 19:34:37 +02:00
|
|
|
|
2007-09-21 10:32:19 +03:00
|
|
|
/*
|
|
|
|
* queue up an urb for anything except the root hub
|
|
|
|
*/
|
|
|
|
static int admhc_urb_enqueue(struct usb_hcd *hcd, struct usb_host_endpoint *ep,
|
|
|
|
struct urb *urb, gfp_t mem_flags)
|
2007-03-19 19:34:37 +02:00
|
|
|
{
|
2007-09-21 10:32:19 +03:00
|
|
|
struct admhcd *ahcd = hcd_to_admhcd(hcd);
|
|
|
|
struct ed *ed;
|
|
|
|
struct urb_priv *urb_priv;
|
|
|
|
unsigned int pipe = urb->pipe;
|
2007-11-01 21:25:05 +02:00
|
|
|
int td_cnt = 0;
|
2007-09-21 10:32:19 +03:00
|
|
|
unsigned long flags;
|
2007-11-08 14:28:27 +02:00
|
|
|
int ret = 0;
|
2007-03-19 19:34:37 +02:00
|
|
|
|
2007-09-21 10:32:19 +03:00
|
|
|
#ifdef ADMHC_VERBOSE_DEBUG
|
2007-11-01 21:25:05 +02:00
|
|
|
spin_lock_irqsave(&ahcd->lock, flags);
|
|
|
|
urb_print(ahcd, urb, "ENQEUE", usb_pipein(pipe));
|
|
|
|
spin_unlock_irqrestore(&ahcd->lock, flags);
|
2007-09-21 10:32:19 +03:00
|
|
|
#endif
|
2007-03-19 19:34:37 +02:00
|
|
|
|
2007-09-21 10:32:19 +03:00
|
|
|
/* every endpoint has an ed, locate and maybe (re)initialize it */
|
|
|
|
ed = ed_get(ahcd, ep, urb->dev, pipe, urb->interval);
|
2007-03-19 19:34:37 +02:00
|
|
|
if (!ed)
|
|
|
|
return -ENOMEM;
|
|
|
|
|
2007-09-21 10:32:19 +03:00
|
|
|
/* for the private part of the URB we need the number of TDs */
|
|
|
|
switch (ed->type) {
|
2007-08-10 11:56:41 +03:00
|
|
|
case PIPE_CONTROL:
|
2007-09-21 10:32:19 +03:00
|
|
|
if (urb->transfer_buffer_length > TD_DATALEN_MAX)
|
|
|
|
/* td_submit_urb() doesn't yet handle these */
|
|
|
|
return -EMSGSIZE;
|
|
|
|
|
|
|
|
/* 1 TD for setup, 1 for ACK, plus ... */
|
|
|
|
td_cnt = 2;
|
2007-11-23 17:53:35 +02:00
|
|
|
/* FALLTHROUGH */
|
2007-08-10 11:56:41 +03:00
|
|
|
case PIPE_BULK:
|
2007-09-21 10:32:19 +03:00
|
|
|
/* one TD for every 4096 Bytes (can be upto 8K) */
|
2007-11-23 17:53:35 +02:00
|
|
|
td_cnt += urb->transfer_buffer_length / TD_DATALEN_MAX;
|
2007-09-21 10:32:19 +03:00
|
|
|
/* ... and for any remaining bytes ... */
|
|
|
|
if ((urb->transfer_buffer_length % TD_DATALEN_MAX) != 0)
|
|
|
|
td_cnt++;
|
|
|
|
/* ... and maybe a zero length packet to wrap it up */
|
|
|
|
if (td_cnt == 0)
|
|
|
|
td_cnt++;
|
|
|
|
else if ((urb->transfer_flags & URB_ZERO_PACKET) != 0
|
|
|
|
&& (urb->transfer_buffer_length
|
|
|
|
% usb_maxpacket(urb->dev, pipe,
|
|
|
|
usb_pipeout (pipe))) == 0)
|
|
|
|
td_cnt++;
|
|
|
|
break;
|
|
|
|
case PIPE_INTERRUPT:
|
|
|
|
/*
|
|
|
|
* for Interrupt IN/OUT transactions, each ED contains
|
|
|
|
* only 1 TD.
|
|
|
|
* TODO: check transfer_buffer_length?
|
|
|
|
*/
|
|
|
|
td_cnt = 1;
|
2007-08-10 11:56:41 +03:00
|
|
|
break;
|
|
|
|
case PIPE_ISOCHRONOUS:
|
2007-09-21 10:32:19 +03:00
|
|
|
/* number of packets from URB */
|
|
|
|
td_cnt = urb->number_of_packets;
|
2007-08-10 11:56:41 +03:00
|
|
|
break;
|
2007-03-19 19:34:37 +02:00
|
|
|
}
|
|
|
|
|
2007-09-21 10:32:19 +03:00
|
|
|
urb_priv = urb_priv_alloc(ahcd, td_cnt, mem_flags);
|
|
|
|
if (!urb_priv)
|
|
|
|
return -ENOMEM;
|
|
|
|
|
|
|
|
urb_priv->ed = ed;
|
|
|
|
|
|
|
|
spin_lock_irqsave(&ahcd->lock, flags);
|
|
|
|
/* don't submit to a dead HC */
|
|
|
|
if (!test_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags)) {
|
2007-11-08 14:28:27 +02:00
|
|
|
ret = -ENODEV;
|
2007-09-21 10:32:19 +03:00
|
|
|
goto fail;
|
2007-03-19 19:34:37 +02:00
|
|
|
}
|
2007-09-21 10:32:19 +03:00
|
|
|
if (!HC_IS_RUNNING(hcd->state)) {
|
2007-11-08 14:28:27 +02:00
|
|
|
ret = -ENODEV;
|
2007-09-21 10:32:19 +03:00
|
|
|
goto fail;
|
2007-03-19 19:34:37 +02:00
|
|
|
}
|
|
|
|
|
2007-09-21 10:32:19 +03:00
|
|
|
/* in case of unlink-during-submit */
|
|
|
|
spin_lock(&urb->lock);
|
|
|
|
if (urb->status != -EINPROGRESS) {
|
|
|
|
spin_unlock(&urb->lock);
|
|
|
|
urb->hcpriv = urb_priv;
|
|
|
|
finish_urb(ahcd, urb);
|
2007-11-08 14:28:27 +02:00
|
|
|
ret = 0;
|
2007-09-21 10:32:19 +03:00
|
|
|
goto fail;
|
2007-03-19 19:34:37 +02:00
|
|
|
}
|
|
|
|
|
2007-11-23 17:53:35 +02:00
|
|
|
/* schedule the ed if needed */
|
|
|
|
if (ed->state == ED_IDLE) {
|
|
|
|
ret = ed_schedule(ahcd, ed);
|
|
|
|
if (ret < 0)
|
|
|
|
goto fail0;
|
|
|
|
|
|
|
|
if (ed->type == PIPE_ISOCHRONOUS) {
|
2007-09-21 10:32:19 +03:00
|
|
|
u16 frame = admhc_frame_no(ahcd);
|
|
|
|
|
|
|
|
/* delay a few frames before the first TD */
|
|
|
|
frame += max_t (u16, 8, ed->interval);
|
|
|
|
frame &= ~(ed->interval - 1);
|
|
|
|
frame |= ed->branch;
|
|
|
|
urb->start_frame = frame;
|
|
|
|
|
|
|
|
/* yes, only URB_ISO_ASAP is supported, and
|
|
|
|
* urb->start_frame is never used as input.
|
|
|
|
*/
|
2007-11-23 17:53:35 +02:00
|
|
|
}
|
|
|
|
} else if (ed->type == PIPE_ISOCHRONOUS)
|
|
|
|
urb->start_frame = ed->last_iso + ed->interval;
|
2007-09-21 10:32:19 +03:00
|
|
|
|
2007-11-23 17:53:35 +02:00
|
|
|
/* fill the TDs and link them to the ed; and
|
|
|
|
* enable that part of the schedule, if needed
|
|
|
|
* and update count of queued periodic urbs
|
|
|
|
*/
|
2007-09-21 10:32:19 +03:00
|
|
|
urb->hcpriv = urb_priv;
|
2007-11-23 17:53:35 +02:00
|
|
|
td_submit_urb(ahcd, urb);
|
2007-09-21 10:32:19 +03:00
|
|
|
|
2007-11-23 17:53:35 +02:00
|
|
|
#ifdef ADMHC_VERBOSE_DEBUG
|
|
|
|
admhc_dump_ed(ahcd, "admhc_urb_enqueue", urb_priv->ed, 1);
|
|
|
|
#endif
|
2007-11-26 10:49:58 +02:00
|
|
|
|
2007-11-23 17:53:35 +02:00
|
|
|
fail0:
|
2007-09-21 10:32:19 +03:00
|
|
|
spin_unlock(&urb->lock);
|
|
|
|
fail:
|
2007-11-23 17:53:35 +02:00
|
|
|
if (ret)
|
2007-09-21 10:32:19 +03:00
|
|
|
urb_priv_free(ahcd, urb_priv);
|
|
|
|
|
|
|
|
spin_unlock_irqrestore(&ahcd->lock, flags);
|
2007-11-08 14:28:27 +02:00
|
|
|
return ret;
|
2007-03-19 19:34:37 +02:00
|
|
|
}
|
|
|
|
|
2007-09-21 10:32:19 +03:00
|
|
|
/*
|
|
|
|
* decouple the URB from the HC queues (TDs, urb_priv); it's
|
|
|
|
* already marked using urb->status. reporting is always done
|
|
|
|
* asynchronously, and we might be dealing with an urb that's
|
|
|
|
* partially transferred, or an ED with other urbs being unlinked.
|
|
|
|
*/
|
|
|
|
static int admhc_urb_dequeue(struct usb_hcd *hcd, struct urb *urb)
|
2007-03-19 19:34:37 +02:00
|
|
|
{
|
2007-11-01 21:25:05 +02:00
|
|
|
struct admhcd *ahcd = hcd_to_admhcd(hcd);
|
|
|
|
unsigned long flags;
|
|
|
|
|
2007-11-23 20:11:49 +02:00
|
|
|
spin_lock_irqsave(&ahcd->lock, flags);
|
|
|
|
|
2007-09-21 10:32:19 +03:00
|
|
|
#ifdef ADMHC_VERBOSE_DEBUG
|
2007-11-23 17:53:35 +02:00
|
|
|
urb_print(ahcd, urb, "DEQUEUE", 1);
|
2007-09-21 10:32:19 +03:00
|
|
|
#endif
|
2007-03-19 19:34:37 +02:00
|
|
|
|
2007-09-21 10:32:19 +03:00
|
|
|
if (HC_IS_RUNNING(hcd->state)) {
|
2007-11-23 17:53:35 +02:00
|
|
|
struct urb_priv *urb_priv;
|
|
|
|
|
2007-09-21 10:32:19 +03:00
|
|
|
/* Unless an IRQ completed the unlink while it was being
|
|
|
|
* handed to us, flag it for unlink and giveback, and force
|
|
|
|
* some upcoming INTR_SF to call finish_unlinks()
|
|
|
|
*/
|
2007-11-23 17:53:35 +02:00
|
|
|
urb_priv = urb->hcpriv;
|
|
|
|
if (urb_priv) {
|
|
|
|
if (urb_priv->ed->state == ED_OPER)
|
|
|
|
start_ed_unlink(ahcd, urb_priv->ed);
|
2007-09-21 10:32:19 +03:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
/*
|
|
|
|
* with HC dead, we won't respect hc queue pointers
|
|
|
|
* any more ... just clean up every urb's memory.
|
|
|
|
*/
|
2007-11-23 17:53:35 +02:00
|
|
|
if (urb->hcpriv)
|
2007-09-21 10:32:19 +03:00
|
|
|
finish_urb(ahcd, urb);
|
|
|
|
}
|
|
|
|
spin_unlock_irqrestore(&ahcd->lock, flags);
|
2007-03-19 19:34:37 +02:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2007-09-21 10:32:19 +03:00
|
|
|
/*-------------------------------------------------------------------------*/
|
|
|
|
|
|
|
|
/* frees config/altsetting state for endpoints,
|
|
|
|
* including ED memory, dummy TD, and bulk/intr data toggle
|
|
|
|
*/
|
2007-11-23 17:53:35 +02:00
|
|
|
|
2007-11-01 21:25:05 +02:00
|
|
|
static void admhc_endpoint_disable(struct usb_hcd *hcd,
|
|
|
|
struct usb_host_endpoint *ep)
|
2007-03-19 19:34:37 +02:00
|
|
|
{
|
2007-09-21 10:32:19 +03:00
|
|
|
struct admhcd *ahcd = hcd_to_admhcd(hcd);
|
|
|
|
unsigned long flags;
|
|
|
|
struct ed *ed = ep->hcpriv;
|
|
|
|
unsigned limit = 1000;
|
|
|
|
|
|
|
|
/* ASSERT: any requests/urbs are being unlinked */
|
|
|
|
/* ASSERT: nobody can be submitting urbs for this any more */
|
|
|
|
|
|
|
|
if (!ed)
|
|
|
|
return;
|
|
|
|
|
|
|
|
#ifdef ADMHC_VERBOSE_DEBUG
|
|
|
|
spin_lock_irqsave(&ahcd->lock, flags);
|
2007-11-01 21:25:05 +02:00
|
|
|
admhc_dump_ed(ahcd, "EP-DISABLE", ed, 1);
|
2007-09-21 10:32:19 +03:00
|
|
|
spin_unlock_irqrestore(&ahcd->lock, flags);
|
|
|
|
#endif
|
2007-03-19 19:34:37 +02:00
|
|
|
|
2007-09-21 10:32:19 +03:00
|
|
|
rescan:
|
|
|
|
spin_lock_irqsave(&ahcd->lock, flags);
|
|
|
|
|
|
|
|
if (!HC_IS_RUNNING(hcd->state)) {
|
|
|
|
sanitize:
|
2007-11-23 17:53:35 +02:00
|
|
|
ed->state = ED_IDLE;
|
|
|
|
finish_unlinks(ahcd, 0);
|
2007-09-21 10:32:19 +03:00
|
|
|
}
|
2007-03-19 19:34:37 +02:00
|
|
|
|
2007-09-21 10:32:19 +03:00
|
|
|
switch (ed->state) {
|
|
|
|
case ED_UNLINK: /* wait for hw to finish? */
|
|
|
|
/* major IRQ delivery trouble loses INTR_SOFI too... */
|
|
|
|
if (limit-- == 0) {
|
|
|
|
admhc_warn(ahcd, "IRQ INTR_SOFI lossage\n");
|
|
|
|
goto sanitize;
|
|
|
|
}
|
|
|
|
spin_unlock_irqrestore(&ahcd->lock, flags);
|
|
|
|
schedule_timeout_uninterruptible(1);
|
|
|
|
goto rescan;
|
2007-11-23 17:53:35 +02:00
|
|
|
case ED_IDLE: /* fully unlinked */
|
|
|
|
if (list_empty(&ed->td_list)) {
|
|
|
|
td_free (ahcd, ed->dummy);
|
|
|
|
ed_free (ahcd, ed);
|
2007-03-19 19:34:37 +02:00
|
|
|
break;
|
|
|
|
}
|
2007-09-21 10:32:19 +03:00
|
|
|
/* else FALL THROUGH */
|
|
|
|
default:
|
|
|
|
/* caller was supposed to have unlinked any requests;
|
|
|
|
* that's not our job. can't recover; must leak ed.
|
|
|
|
*/
|
2007-11-23 17:53:35 +02:00
|
|
|
admhc_err(ahcd, "leak ed %p (#%02x) state %d%s\n",
|
|
|
|
ed, ep->desc.bEndpointAddress, ed->state,
|
|
|
|
list_empty(&ed->td_list) ? "" : " (has tds)");
|
|
|
|
td_free(ahcd, ed->dummy);
|
2007-09-21 10:32:19 +03:00
|
|
|
break;
|
2007-03-19 19:34:37 +02:00
|
|
|
}
|
2007-11-01 21:25:05 +02:00
|
|
|
|
2007-09-21 10:32:19 +03:00
|
|
|
ep->hcpriv = NULL;
|
2007-11-01 21:25:05 +02:00
|
|
|
|
2007-09-21 10:32:19 +03:00
|
|
|
spin_unlock_irqrestore(&ahcd->lock, flags);
|
|
|
|
return;
|
2007-03-19 19:34:37 +02:00
|
|
|
}
|
|
|
|
|
2007-11-08 14:28:27 +02:00
|
|
|
static int admhc_get_frame_number(struct usb_hcd *hcd)
|
2007-03-19 19:34:37 +02:00
|
|
|
{
|
|
|
|
struct admhcd *ahcd = hcd_to_admhcd(hcd);
|
|
|
|
|
2007-09-21 10:32:19 +03:00
|
|
|
return admhc_frame_no(ahcd);
|
2007-03-19 19:34:37 +02:00
|
|
|
}
|
|
|
|
|
2007-09-21 10:32:19 +03:00
|
|
|
static void admhc_usb_reset(struct admhcd *ahcd)
|
2007-03-19 19:34:37 +02:00
|
|
|
{
|
2007-11-23 17:53:35 +02:00
|
|
|
#if 0
|
|
|
|
ahcd->hc_control = admhc_readl(ahcd, &ahcd->regs->control);
|
|
|
|
ahcd->hc_control &= OHCI_CTRL_RWC;
|
|
|
|
admhc_writel(ahcd, ahcd->hc_control, &ahcd->regs->control);
|
|
|
|
#else
|
|
|
|
/* FIXME */
|
2007-09-21 10:32:19 +03:00
|
|
|
ahcd->host_control = ADMHC_BUSS_RESET;
|
2007-11-23 17:53:35 +02:00
|
|
|
admhc_writel(ahcd, ahcd->host_control ,&ahcd->regs->host_control);
|
|
|
|
#endif
|
2007-03-19 19:34:37 +02:00
|
|
|
}
|
|
|
|
|
2007-09-21 10:32:19 +03:00
|
|
|
/* admhc_shutdown forcibly disables IRQs and DMA, helping kexec and
|
|
|
|
* other cases where the next software may expect clean state from the
|
|
|
|
* "firmware". this is bus-neutral, unlike shutdown() methods.
|
|
|
|
*/
|
|
|
|
static void
|
|
|
|
admhc_shutdown(struct usb_hcd *hcd)
|
2007-03-19 19:34:37 +02:00
|
|
|
{
|
2007-09-21 10:32:19 +03:00
|
|
|
struct admhcd *ahcd;
|
2007-03-19 19:34:37 +02:00
|
|
|
|
2007-09-21 10:32:19 +03:00
|
|
|
ahcd = hcd_to_admhcd(hcd);
|
|
|
|
admhc_intr_disable(ahcd, ADMHC_INTR_MIE);
|
|
|
|
admhc_dma_disable(ahcd);
|
|
|
|
admhc_usb_reset(ahcd);
|
2007-11-23 17:53:35 +02:00
|
|
|
/* flush the writes */
|
|
|
|
admhc_writel_flush(ahcd);
|
2007-09-21 10:32:19 +03:00
|
|
|
}
|
2007-03-19 19:34:37 +02:00
|
|
|
|
2007-09-21 10:32:19 +03:00
|
|
|
/*-------------------------------------------------------------------------*
|
|
|
|
* HC functions
|
|
|
|
*-------------------------------------------------------------------------*/
|
|
|
|
|
|
|
|
static void admhc_eds_cleanup(struct admhcd *ahcd)
|
|
|
|
{
|
|
|
|
if (ahcd->ed_tails[PIPE_INTERRUPT]) {
|
|
|
|
ed_free(ahcd, ahcd->ed_tails[PIPE_INTERRUPT]);
|
|
|
|
ahcd->ed_tails[PIPE_INTERRUPT] = NULL;
|
2007-03-19 19:34:37 +02:00
|
|
|
}
|
|
|
|
|
2007-09-21 10:32:19 +03:00
|
|
|
if (ahcd->ed_tails[PIPE_ISOCHRONOUS]) {
|
|
|
|
ed_free(ahcd, ahcd->ed_tails[PIPE_ISOCHRONOUS]);
|
|
|
|
ahcd->ed_tails[PIPE_ISOCHRONOUS] = NULL;
|
|
|
|
}
|
2007-03-19 19:34:37 +02:00
|
|
|
|
2007-09-21 10:32:19 +03:00
|
|
|
if (ahcd->ed_tails[PIPE_CONTROL]) {
|
|
|
|
ed_free(ahcd, ahcd->ed_tails[PIPE_CONTROL]);
|
|
|
|
ahcd->ed_tails[PIPE_CONTROL] = NULL;
|
|
|
|
}
|
2007-07-20 19:26:39 +03:00
|
|
|
|
2007-09-21 10:32:19 +03:00
|
|
|
if (ahcd->ed_tails[PIPE_BULK]) {
|
|
|
|
ed_free(ahcd, ahcd->ed_tails[PIPE_BULK]);
|
|
|
|
ahcd->ed_tails[PIPE_BULK] = NULL;
|
|
|
|
}
|
2007-07-20 19:26:39 +03:00
|
|
|
|
2007-09-21 10:32:19 +03:00
|
|
|
ahcd->ed_head = NULL;
|
|
|
|
}
|
2007-07-20 19:26:39 +03:00
|
|
|
|
2007-11-23 17:53:35 +02:00
|
|
|
#define ED_DUMMY_INFO (ED_SPEED_FULL | ED_SKIP)
|
2007-07-20 19:26:39 +03:00
|
|
|
|
2007-09-21 10:32:19 +03:00
|
|
|
static int admhc_eds_init(struct admhcd *ahcd)
|
|
|
|
{
|
|
|
|
struct ed *ed;
|
2007-08-03 18:59:23 +03:00
|
|
|
|
2007-09-21 10:32:19 +03:00
|
|
|
ed = ed_create(ahcd, PIPE_INTERRUPT, ED_DUMMY_INFO);
|
|
|
|
if (!ed)
|
|
|
|
goto err;
|
2007-07-20 19:26:39 +03:00
|
|
|
|
2007-09-21 10:32:19 +03:00
|
|
|
ahcd->ed_tails[PIPE_INTERRUPT] = ed;
|
2007-07-20 19:26:39 +03:00
|
|
|
|
2007-09-21 10:32:19 +03:00
|
|
|
ed = ed_create(ahcd, PIPE_ISOCHRONOUS, ED_DUMMY_INFO);
|
|
|
|
if (!ed)
|
|
|
|
goto err;
|
2007-07-20 19:26:39 +03:00
|
|
|
|
2007-09-21 10:32:19 +03:00
|
|
|
ahcd->ed_tails[PIPE_ISOCHRONOUS] = ed;
|
|
|
|
ed->ed_prev = ahcd->ed_tails[PIPE_INTERRUPT];
|
|
|
|
ahcd->ed_tails[PIPE_INTERRUPT]->ed_next = ed;
|
|
|
|
ahcd->ed_tails[PIPE_INTERRUPT]->hwNextED = cpu_to_hc32(ahcd, ed->dma);
|
2007-07-20 19:26:39 +03:00
|
|
|
|
2007-09-21 10:32:19 +03:00
|
|
|
ed = ed_create(ahcd, PIPE_CONTROL, ED_DUMMY_INFO);
|
|
|
|
if (!ed)
|
|
|
|
goto err;
|
2007-07-20 19:26:39 +03:00
|
|
|
|
2007-09-21 10:32:19 +03:00
|
|
|
ahcd->ed_tails[PIPE_CONTROL] = ed;
|
|
|
|
ed->ed_prev = ahcd->ed_tails[PIPE_ISOCHRONOUS];
|
|
|
|
ahcd->ed_tails[PIPE_ISOCHRONOUS]->ed_next = ed;
|
|
|
|
ahcd->ed_tails[PIPE_ISOCHRONOUS]->hwNextED = cpu_to_hc32(ahcd, ed->dma);
|
2007-07-20 19:26:39 +03:00
|
|
|
|
2007-09-21 10:32:19 +03:00
|
|
|
ed = ed_create(ahcd, PIPE_BULK, ED_DUMMY_INFO);
|
|
|
|
if (!ed)
|
|
|
|
goto err;
|
2007-07-20 19:26:39 +03:00
|
|
|
|
2007-09-21 10:32:19 +03:00
|
|
|
ahcd->ed_tails[PIPE_BULK] = ed;
|
|
|
|
ed->ed_prev = ahcd->ed_tails[PIPE_CONTROL];
|
|
|
|
ahcd->ed_tails[PIPE_CONTROL]->ed_next = ed;
|
|
|
|
ahcd->ed_tails[PIPE_CONTROL]->hwNextED = cpu_to_hc32(ahcd, ed->dma);
|
|
|
|
|
|
|
|
ahcd->ed_head = ahcd->ed_tails[PIPE_INTERRUPT];
|
|
|
|
|
|
|
|
#ifdef ADMHC_VERBOSE_DEBUG
|
|
|
|
admhc_dump_ed(ahcd, "ed intr", ahcd->ed_tails[PIPE_INTERRUPT], 1);
|
|
|
|
admhc_dump_ed(ahcd, "ed isoc", ahcd->ed_tails[PIPE_ISOCHRONOUS], 1);
|
|
|
|
admhc_dump_ed(ahcd, "ed ctrl", ahcd->ed_tails[PIPE_CONTROL], 1);
|
|
|
|
admhc_dump_ed(ahcd, "ed bulk", ahcd->ed_tails[PIPE_BULK], 1);
|
|
|
|
#endif
|
2007-08-03 00:06:00 +03:00
|
|
|
|
2007-08-10 11:56:41 +03:00
|
|
|
return 0;
|
2007-09-21 10:32:19 +03:00
|
|
|
|
|
|
|
err:
|
|
|
|
admhc_eds_cleanup(ahcd);
|
|
|
|
return -ENOMEM;
|
2007-07-20 19:26:39 +03:00
|
|
|
}
|
|
|
|
|
2007-09-21 10:32:19 +03:00
|
|
|
/* init memory, and kick BIOS/SMM off */
|
|
|
|
|
|
|
|
static int admhc_init(struct admhcd *ahcd)
|
2007-07-20 19:26:39 +03:00
|
|
|
{
|
2007-09-21 10:32:19 +03:00
|
|
|
struct usb_hcd *hcd = admhcd_to_hcd(ahcd);
|
|
|
|
int ret;
|
2007-07-20 19:26:39 +03:00
|
|
|
|
2007-09-21 10:32:19 +03:00
|
|
|
admhc_disable(ahcd);
|
|
|
|
ahcd->regs = hcd->regs;
|
2007-07-20 19:26:39 +03:00
|
|
|
|
2007-09-21 10:32:19 +03:00
|
|
|
/* Disable HC interrupts */
|
|
|
|
admhc_intr_disable(ahcd, ADMHC_INTR_MIE);
|
2007-07-20 19:26:39 +03:00
|
|
|
|
2007-09-21 10:32:19 +03:00
|
|
|
/* Read the number of ports unless overridden */
|
|
|
|
if (ahcd->num_ports == 0)
|
2007-11-10 21:20:47 +02:00
|
|
|
ahcd->num_ports = admhc_read_rhdesc(ahcd) & ADMHC_RH_NUMP;
|
2007-07-20 19:26:39 +03:00
|
|
|
|
2007-09-21 10:32:19 +03:00
|
|
|
ret = admhc_mem_init(ahcd);
|
|
|
|
if (ret)
|
|
|
|
goto err;
|
|
|
|
|
|
|
|
/* init dummy endpoints */
|
|
|
|
ret = admhc_eds_init(ahcd);
|
|
|
|
if (ret)
|
|
|
|
goto err;
|
|
|
|
|
|
|
|
create_debug_files(ahcd);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
err:
|
|
|
|
admhc_stop(hcd);
|
2007-07-20 19:26:39 +03:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2007-09-21 10:32:19 +03:00
|
|
|
/*-------------------------------------------------------------------------*/
|
|
|
|
|
|
|
|
/* Start an OHCI controller, set the BUS operational
|
|
|
|
* resets USB and controller
|
|
|
|
* enable interrupts
|
|
|
|
*/
|
|
|
|
static int admhc_run(struct admhcd *ahcd)
|
2007-07-20 19:26:39 +03:00
|
|
|
{
|
2007-09-21 10:32:19 +03:00
|
|
|
u32 temp;
|
|
|
|
int first = ahcd->fminterval == 0;
|
|
|
|
struct usb_hcd *hcd = admhcd_to_hcd(ahcd);
|
|
|
|
|
|
|
|
admhc_disable(ahcd);
|
|
|
|
|
|
|
|
/* boot firmware should have set this up (5.1.1.3.1) */
|
|
|
|
if (first) {
|
|
|
|
temp = admhc_readl(ahcd, &ahcd->regs->fminterval);
|
|
|
|
ahcd->fminterval = temp & ADMHC_SFI_FI_MASK;
|
|
|
|
if (ahcd->fminterval != FI)
|
|
|
|
admhc_dbg(ahcd, "fminterval delta %d\n",
|
|
|
|
ahcd->fminterval - FI);
|
|
|
|
ahcd->fminterval |=
|
2007-11-08 14:28:27 +02:00
|
|
|
(FSLDP(ahcd->fminterval) << ADMHC_SFI_FSLDP_SHIFT);
|
2007-09-21 10:32:19 +03:00
|
|
|
/* also: power/overcurrent flags in rhdesc */
|
|
|
|
}
|
2007-07-20 19:26:39 +03:00
|
|
|
|
2007-11-23 17:53:35 +02:00
|
|
|
#if 0 /* TODO: not applicable */
|
|
|
|
/* Reset USB nearly "by the book". RemoteWakeupConnected was
|
|
|
|
* saved if boot firmware (BIOS/SMM/...) told us it's connected,
|
|
|
|
* or if bus glue did the same (e.g. for PCI add-in cards with
|
|
|
|
* PCI PM support).
|
|
|
|
*/
|
|
|
|
if ((ahcd->hc_control & OHCI_CTRL_RWC) != 0
|
|
|
|
&& !device_may_wakeup(hcd->self.controller))
|
|
|
|
device_init_wakeup(hcd->self.controller, 1);
|
|
|
|
#endif
|
|
|
|
|
2007-09-21 10:32:19 +03:00
|
|
|
switch (ahcd->host_control & ADMHC_HC_BUSS) {
|
|
|
|
case ADMHC_BUSS_OPER:
|
|
|
|
temp = 0;
|
|
|
|
break;
|
|
|
|
case ADMHC_BUSS_SUSPEND:
|
|
|
|
/* FALLTHROUGH ? */
|
|
|
|
case ADMHC_BUSS_RESUME:
|
|
|
|
ahcd->host_control = ADMHC_BUSS_RESUME;
|
|
|
|
temp = 10 /* msec wait */;
|
|
|
|
break;
|
|
|
|
/* case ADMHC_BUSS_RESET: */
|
|
|
|
default:
|
|
|
|
ahcd->host_control = ADMHC_BUSS_RESET;
|
|
|
|
temp = 50 /* msec wait */;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
admhc_writel(ahcd, ahcd->host_control, &ahcd->regs->host_control);
|
2007-11-15 11:16:47 +02:00
|
|
|
|
2007-11-23 17:53:35 +02:00
|
|
|
/* flush the writes */
|
|
|
|
admhc_writel_flush(ahcd);
|
|
|
|
|
|
|
|
msleep(temp);
|
2007-11-10 21:20:47 +02:00
|
|
|
temp = admhc_read_rhdesc(ahcd);
|
2007-09-21 10:32:19 +03:00
|
|
|
if (!(temp & ADMHC_RH_NPS)) {
|
|
|
|
/* power down each port */
|
|
|
|
for (temp = 0; temp < ahcd->num_ports; temp++)
|
2007-11-10 21:20:47 +02:00
|
|
|
admhc_write_portstatus(ahcd, temp, ADMHC_PS_CPP);
|
2007-09-21 10:32:19 +03:00
|
|
|
}
|
2007-11-23 17:53:35 +02:00
|
|
|
/* flush those writes */
|
|
|
|
admhc_writel_flush(ahcd);
|
2007-09-21 10:32:19 +03:00
|
|
|
|
|
|
|
/* 2msec timelimit here means no irqs/preempt */
|
|
|
|
spin_lock_irq(&ahcd->lock);
|
|
|
|
|
|
|
|
admhc_writel(ahcd, ADMHC_CTRL_SR, &ahcd->regs->gencontrol);
|
|
|
|
temp = 30; /* ... allow extra time */
|
|
|
|
while ((admhc_readl(ahcd, &ahcd->regs->gencontrol) & ADMHC_CTRL_SR) != 0) {
|
|
|
|
if (--temp == 0) {
|
|
|
|
spin_unlock_irq(&ahcd->lock);
|
|
|
|
admhc_err(ahcd, "USB HC reset timed out!\n");
|
|
|
|
return -1;
|
|
|
|
}
|
2007-11-15 11:16:47 +02:00
|
|
|
udelay(1);
|
2007-08-10 11:56:41 +03:00
|
|
|
}
|
2007-08-03 20:31:52 +03:00
|
|
|
|
2007-09-21 10:32:19 +03:00
|
|
|
/* enable HOST mode, before access any host specific register */
|
|
|
|
admhc_writel(ahcd, ADMHC_CTRL_UHFE, &ahcd->regs->gencontrol);
|
2007-07-20 19:26:39 +03:00
|
|
|
|
2007-09-21 10:32:19 +03:00
|
|
|
/* Tell the controller where the descriptor list is */
|
|
|
|
admhc_writel(ahcd, (u32)ahcd->ed_head->dma, &ahcd->regs->hosthead);
|
2007-07-20 19:26:39 +03:00
|
|
|
|
2007-09-21 10:32:19 +03:00
|
|
|
periodic_reinit(ahcd);
|
2007-08-03 18:59:23 +03:00
|
|
|
|
2007-09-21 10:32:19 +03:00
|
|
|
/* use rhsc irqs after khubd is fully initialized */
|
|
|
|
hcd->poll_rh = 1;
|
|
|
|
hcd->uses_new_polling = 1;
|
2007-07-20 19:26:39 +03:00
|
|
|
|
2007-11-23 17:53:35 +02:00
|
|
|
#if 0
|
|
|
|
/* wake on ConnectStatusChange, matching external hubs */
|
|
|
|
admhc_writel(ahcd, RH_HS_DRWE, &ahcd->regs->roothub.status);
|
|
|
|
#else
|
|
|
|
/* FIXME roothub_write_status (ahcd, ADMHC_RH_DRWE); */
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* Choose the interrupts we care about now, others later on demand */
|
|
|
|
admhc_intr_ack(ahcd, ~0);
|
|
|
|
admhc_intr_enable(ahcd, ADMHC_INTR_INIT);
|
|
|
|
|
|
|
|
admhc_writel(ahcd, ADMHC_RH_NPS | ADMHC_RH_LPSC, &ahcd->regs->rhdesc);
|
|
|
|
|
|
|
|
/* flush those writes */
|
|
|
|
admhc_writel_flush(ahcd);
|
|
|
|
|
2007-09-21 10:32:19 +03:00
|
|
|
/* start controller operations */
|
|
|
|
ahcd->host_control = ADMHC_BUSS_OPER;
|
|
|
|
admhc_writel(ahcd, ahcd->host_control, &ahcd->regs->host_control);
|
2007-03-19 19:34:37 +02:00
|
|
|
|
2007-09-21 10:32:19 +03:00
|
|
|
temp = 20;
|
|
|
|
while ((admhc_readl(ahcd, &ahcd->regs->host_control)
|
|
|
|
& ADMHC_HC_BUSS) != ADMHC_BUSS_OPER) {
|
|
|
|
if (--temp == 0) {
|
|
|
|
spin_unlock_irq(&ahcd->lock);
|
|
|
|
admhc_err(ahcd, "unable to setup operational mode!\n");
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
mdelay(1);
|
2007-08-10 11:56:41 +03:00
|
|
|
}
|
2007-03-19 19:34:37 +02:00
|
|
|
|
2007-11-23 17:53:35 +02:00
|
|
|
hcd->state = HC_STATE_RUNNING;
|
|
|
|
|
|
|
|
ahcd->next_statechange = jiffies + STATECHANGE_DELAY;
|
|
|
|
|
2007-11-15 11:16:47 +02:00
|
|
|
#if 0
|
2007-11-23 17:53:35 +02:00
|
|
|
/* FIXME: enabling DMA is always failed here for an unknown reason */
|
|
|
|
admhc_dma_enable(ahcd);
|
2007-11-15 11:16:47 +02:00
|
|
|
|
2007-11-23 17:53:35 +02:00
|
|
|
temp = 200;
|
|
|
|
while ((admhc_readl(ahcd, &ahcd->regs->host_control)
|
|
|
|
& ADMHC_HC_DMAE) != ADMHC_HC_DMAE) {
|
|
|
|
if (--temp == 0) {
|
|
|
|
spin_unlock_irq(&ahcd->lock);
|
|
|
|
admhc_err(ahcd, "unable to enable DMA!\n");
|
|
|
|
admhc_dump(ahcd, 1);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
mdelay(1);
|
|
|
|
}
|
2007-09-21 10:32:19 +03:00
|
|
|
|
2007-11-23 17:53:35 +02:00
|
|
|
#endif
|
2007-11-15 11:16:47 +02:00
|
|
|
|
2007-09-21 10:32:19 +03:00
|
|
|
spin_unlock_irq(&ahcd->lock);
|
|
|
|
|
|
|
|
mdelay(ADMHC_POTPGT);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*-------------------------------------------------------------------------*/
|
|
|
|
|
|
|
|
/* an interrupt happens */
|
|
|
|
|
|
|
|
static irqreturn_t admhc_irq(struct usb_hcd *hcd)
|
|
|
|
{
|
|
|
|
struct admhcd *ahcd = hcd_to_admhcd(hcd);
|
|
|
|
struct admhcd_regs __iomem *regs = ahcd->regs;
|
|
|
|
u32 ints;
|
|
|
|
|
|
|
|
ints = admhc_readl(ahcd, ®s->int_status);
|
2007-11-23 17:53:35 +02:00
|
|
|
if ((ints & ADMHC_INTR_INTA) == 0) {
|
2007-09-21 10:32:19 +03:00
|
|
|
/* no unmasked interrupt status is set */
|
|
|
|
return IRQ_NONE;
|
2007-11-15 11:16:47 +02:00
|
|
|
}
|
2007-04-08 13:15:17 +03:00
|
|
|
|
2007-09-21 10:32:19 +03:00
|
|
|
ints &= admhc_readl(ahcd, ®s->int_enable);
|
|
|
|
|
|
|
|
if (ints & ADMHC_INTR_FATI) {
|
2007-11-23 17:53:35 +02:00
|
|
|
/* e.g. due to PCI Master/Target Abort */
|
2007-09-21 10:32:19 +03:00
|
|
|
admhc_disable(ahcd);
|
|
|
|
admhc_err(ahcd, "Fatal Error, controller disabled\n");
|
2007-11-23 17:53:35 +02:00
|
|
|
admhc_dump(ahcd, 1);
|
2007-09-21 10:32:19 +03:00
|
|
|
admhc_usb_reset(ahcd);
|
2007-08-10 11:56:41 +03:00
|
|
|
}
|
2007-06-05 17:03:42 +03:00
|
|
|
|
2007-11-01 21:25:05 +02:00
|
|
|
if (ints & ADMHC_INTR_BABI) {
|
2007-11-23 17:53:35 +02:00
|
|
|
admhc_intr_disable(ahcd, ADMHC_INTR_BABI);
|
|
|
|
admhc_intr_ack(ahcd, ADMHC_INTR_BABI);
|
2007-11-10 21:20:47 +02:00
|
|
|
admhc_err(ahcd, "Babble Detected\n");
|
2007-11-01 21:25:05 +02:00
|
|
|
}
|
|
|
|
|
2007-09-21 10:32:19 +03:00
|
|
|
if (ints & ADMHC_INTR_INSM) {
|
|
|
|
admhc_vdbg(ahcd, "Root Hub Status Change\n");
|
|
|
|
ahcd->next_statechange = jiffies + STATECHANGE_DELAY;
|
|
|
|
admhc_intr_ack(ahcd, ADMHC_INTR_RESI | ADMHC_INTR_INSM);
|
|
|
|
|
|
|
|
/* NOTE: Vendors didn't always make the same implementation
|
|
|
|
* choices for RHSC. Many followed the spec; RHSC triggers
|
|
|
|
* on an edge, like setting and maybe clearing a port status
|
|
|
|
* change bit. With others it's level-triggered, active
|
|
|
|
* until khubd clears all the port status change bits. We'll
|
|
|
|
* always disable it here and rely on polling until khubd
|
|
|
|
* re-enables it.
|
|
|
|
*/
|
|
|
|
admhc_intr_disable(ahcd, ADMHC_INTR_INSM);
|
|
|
|
usb_hcd_poll_rh_status(hcd);
|
|
|
|
} else if (ints & ADMHC_INTR_RESI) {
|
|
|
|
/* For connect and disconnect events, we expect the controller
|
|
|
|
* to turn on RHSC along with RD. But for remote wakeup events
|
|
|
|
* this might not happen.
|
|
|
|
*/
|
|
|
|
admhc_vdbg(ahcd, "Resume Detect\n");
|
|
|
|
admhc_intr_ack(ahcd, ADMHC_INTR_RESI);
|
|
|
|
hcd->poll_rh = 1;
|
|
|
|
if (ahcd->autostop) {
|
2007-11-15 11:16:47 +02:00
|
|
|
spin_lock(&ahcd->lock);
|
2007-09-21 10:32:19 +03:00
|
|
|
admhc_rh_resume(ahcd);
|
2007-11-15 11:16:47 +02:00
|
|
|
spin_unlock(&ahcd->lock);
|
2007-09-21 10:32:19 +03:00
|
|
|
} else
|
|
|
|
usb_hcd_resume_root_hub(hcd);
|
2007-08-03 00:06:00 +03:00
|
|
|
}
|
2007-03-19 19:34:37 +02:00
|
|
|
|
2007-09-21 10:32:19 +03:00
|
|
|
if (ints & ADMHC_INTR_TDC) {
|
2007-11-15 11:16:47 +02:00
|
|
|
admhc_vdbg(ahcd, "Transfer Descriptor Complete\n");
|
2007-11-23 17:53:35 +02:00
|
|
|
admhc_intr_ack(ahcd, ADMHC_INTR_TDC);
|
2007-09-21 10:32:19 +03:00
|
|
|
if (HC_IS_RUNNING(hcd->state))
|
|
|
|
admhc_intr_disable(ahcd, ADMHC_INTR_TDC);
|
2007-11-08 14:28:27 +02:00
|
|
|
spin_lock(&ahcd->lock);
|
2007-09-21 10:32:19 +03:00
|
|
|
admhc_td_complete(ahcd);
|
2007-11-08 14:28:27 +02:00
|
|
|
spin_unlock(&ahcd->lock);
|
2007-09-21 10:32:19 +03:00
|
|
|
if (HC_IS_RUNNING(hcd->state))
|
|
|
|
admhc_intr_enable(ahcd, ADMHC_INTR_TDC);
|
|
|
|
}
|
2007-08-03 18:59:23 +03:00
|
|
|
|
2007-09-21 10:32:19 +03:00
|
|
|
if (ints & ADMHC_INTR_SO) {
|
|
|
|
/* could track INTR_SO to reduce available PCI/... bandwidth */
|
2007-11-23 17:53:35 +02:00
|
|
|
admhc_vdbg(ahcd, "Schedule Overrun\n");
|
2007-09-21 10:32:19 +03:00
|
|
|
}
|
2007-06-05 17:03:42 +03:00
|
|
|
|
2007-11-23 17:53:35 +02:00
|
|
|
#if 1
|
|
|
|
spin_lock(&ahcd->lock);
|
|
|
|
if (ahcd->ed_rm_list)
|
|
|
|
finish_unlinks(ahcd, admhc_frame_no(ahcd));
|
|
|
|
|
|
|
|
if ((ints & ADMHC_INTR_SOFI) != 0 && !ahcd->ed_rm_list
|
|
|
|
&& HC_IS_RUNNING(hcd->state))
|
|
|
|
admhc_intr_disable(ahcd, ADMHC_INTR_SOFI);
|
|
|
|
spin_unlock(&ahcd->lock);
|
|
|
|
#else
|
2007-09-21 10:32:19 +03:00
|
|
|
if (ints & ADMHC_INTR_SOFI) {
|
2007-11-23 17:53:35 +02:00
|
|
|
admhc_vdbg(ahcd, "Start Of Frame\n");
|
2007-11-11 19:56:32 +02:00
|
|
|
spin_lock(&ahcd->lock);
|
2007-11-23 17:53:35 +02:00
|
|
|
|
2007-09-21 10:32:19 +03:00
|
|
|
/* handle any pending ED removes */
|
2007-11-23 17:53:35 +02:00
|
|
|
finish_unlinks(ahcd, admhc_frameno(ahcd));
|
|
|
|
|
|
|
|
/* leaving INTR_SOFI enabled when there's still unlinking
|
|
|
|
* to be done in the (next frame).
|
|
|
|
*/
|
|
|
|
if ((ahcd->ed_rm_list == NULL) ||
|
|
|
|
HC_IS_RUNNING(hcd->state) == 0)
|
|
|
|
/*
|
|
|
|
* disable INTR_SOFI if there are no unlinking to be
|
|
|
|
* done (in the next frame)
|
|
|
|
*/
|
|
|
|
admhc_intr_disable(ahcd, ADMHC_INTR_SOFI);
|
|
|
|
|
2007-11-08 14:28:27 +02:00
|
|
|
spin_unlock(&ahcd->lock);
|
2007-08-03 00:06:00 +03:00
|
|
|
}
|
2007-11-23 17:53:35 +02:00
|
|
|
#endif
|
2007-03-19 19:34:37 +02:00
|
|
|
|
2007-09-21 10:32:19 +03:00
|
|
|
if (HC_IS_RUNNING(hcd->state)) {
|
|
|
|
admhc_intr_ack(ahcd, ints);
|
|
|
|
admhc_intr_enable(ahcd, ADMHC_INTR_MIE);
|
2007-11-23 17:53:35 +02:00
|
|
|
admhc_writel_flush(ahcd);
|
2007-09-21 10:32:19 +03:00
|
|
|
}
|
2007-03-19 19:34:37 +02:00
|
|
|
|
2007-09-21 10:32:19 +03:00
|
|
|
return IRQ_HANDLED;
|
2007-03-19 19:34:37 +02:00
|
|
|
}
|
|
|
|
|
2007-09-21 10:32:19 +03:00
|
|
|
/*-------------------------------------------------------------------------*/
|
|
|
|
|
|
|
|
static void admhc_stop(struct usb_hcd *hcd)
|
2007-08-03 00:06:00 +03:00
|
|
|
{
|
2007-09-21 10:32:19 +03:00
|
|
|
struct admhcd *ahcd = hcd_to_admhcd(hcd);
|
|
|
|
|
|
|
|
admhc_dump(ahcd, 1);
|
|
|
|
|
|
|
|
flush_scheduled_work();
|
|
|
|
|
|
|
|
admhc_usb_reset(ahcd);
|
2007-11-23 17:53:35 +02:00
|
|
|
admhc_intr_disable(ahcd, ADMHC_INTR_MIE);
|
2007-09-21 10:32:19 +03:00
|
|
|
|
|
|
|
free_irq(hcd->irq, hcd);
|
|
|
|
hcd->irq = -1;
|
|
|
|
|
|
|
|
remove_debug_files(ahcd);
|
|
|
|
admhc_eds_cleanup(ahcd);
|
|
|
|
admhc_mem_cleanup(ahcd);
|
2007-08-03 00:06:00 +03:00
|
|
|
}
|
|
|
|
|
2007-09-21 10:32:19 +03:00
|
|
|
/*-------------------------------------------------------------------------*/
|
|
|
|
|
|
|
|
#ifdef CONFIG_MIPS_ADM5120
|
|
|
|
#include "adm5120-drv.c"
|
|
|
|
#define PLATFORM_DRIVER usb_hcd_adm5120_driver
|
|
|
|
#endif
|
2007-04-08 13:15:17 +03:00
|
|
|
|
2007-09-21 10:32:19 +03:00
|
|
|
#if !defined(PLATFORM_DRIVER)
|
|
|
|
#error "missing bus glue for admhc-hcd"
|
|
|
|
#endif
|
|
|
|
|
2007-12-05 11:32:04 +02:00
|
|
|
#define DRIVER_INFO DRIVER_DESC " version " DRIVER_VERSION
|
2007-03-19 19:34:37 +02:00
|
|
|
|
2007-09-21 10:32:19 +03:00
|
|
|
static int __init admhc_hcd_mod_init(void)
|
2007-03-19 19:34:37 +02:00
|
|
|
{
|
2007-11-08 14:28:27 +02:00
|
|
|
int ret = 0;
|
2007-07-11 16:00:27 +03:00
|
|
|
|
2007-09-21 10:32:19 +03:00
|
|
|
if (usb_disabled())
|
2007-03-19 19:34:37 +02:00
|
|
|
return -ENODEV;
|
2007-07-11 16:00:27 +03:00
|
|
|
|
2007-09-21 10:32:19 +03:00
|
|
|
pr_info("%s: " DRIVER_INFO "\n", hcd_name);
|
|
|
|
pr_info("%s: block sizes: ed %Zd td %Zd\n", hcd_name,
|
|
|
|
sizeof (struct ed), sizeof (struct td));
|
2007-03-19 19:34:37 +02:00
|
|
|
|
2007-09-21 10:32:19 +03:00
|
|
|
#ifdef PLATFORM_DRIVER
|
2007-11-08 14:28:27 +02:00
|
|
|
ret = platform_driver_register(&PLATFORM_DRIVER);
|
|
|
|
if (ret < 0)
|
2007-09-21 10:32:19 +03:00
|
|
|
goto error_platform;
|
|
|
|
#endif
|
2007-07-11 16:00:27 +03:00
|
|
|
|
2007-11-08 14:28:27 +02:00
|
|
|
return ret;
|
2007-09-21 10:32:19 +03:00
|
|
|
|
|
|
|
#ifdef PLATFORM_DRIVER
|
|
|
|
platform_driver_unregister(&PLATFORM_DRIVER);
|
|
|
|
error_platform:
|
|
|
|
#endif
|
2007-11-08 14:28:27 +02:00
|
|
|
return ret;
|
2007-03-19 19:34:37 +02:00
|
|
|
}
|
2007-09-21 10:32:19 +03:00
|
|
|
module_init(admhc_hcd_mod_init);
|
2007-03-19 19:34:37 +02:00
|
|
|
|
2007-09-21 10:32:19 +03:00
|
|
|
static void __exit admhc_hcd_mod_exit(void)
|
2007-08-03 18:59:23 +03:00
|
|
|
{
|
2007-09-21 10:32:19 +03:00
|
|
|
platform_driver_unregister(&PLATFORM_DRIVER);
|
2007-03-19 19:34:37 +02:00
|
|
|
}
|
2007-09-21 10:32:19 +03:00
|
|
|
module_exit(admhc_hcd_mod_exit);
|
2007-03-19 19:34:37 +02:00
|
|
|
|
2007-09-21 10:32:19 +03:00
|
|
|
MODULE_AUTHOR(DRIVER_AUTHOR);
|
|
|
|
MODULE_DESCRIPTION(DRIVER_INFO);
|
2007-12-05 11:32:04 +02:00
|
|
|
MODULE_VERSION(DRIVER_VERSION);
|
2007-09-21 10:32:19 +03:00
|
|
|
MODULE_LICENSE("GPL");
|