2005-04-16 22:20:36 +00:00
|
|
|
/*
|
|
|
|
* SL811HS HCD (Host Controller Driver) for USB.
|
|
|
|
*
|
|
|
|
* Copyright (C) 2004 Psion Teklogix (for NetBook PRO)
|
2005-05-26 12:55:55 +00:00
|
|
|
* Copyright (C) 2004-2005 David Brownell
|
|
|
|
*
|
2005-04-16 22:20:36 +00:00
|
|
|
* Periodic scheduling is based on Roman's OHCI code
|
|
|
|
* Copyright (C) 1999 Roman Weissgaerber
|
|
|
|
*
|
|
|
|
* The SL811HS controller handles host side USB (like the SL11H, but with
|
|
|
|
* another register set and SOF generation) as well as peripheral side USB
|
|
|
|
* (like the SL811S). This driver version doesn't implement the Gadget API
|
|
|
|
* for the peripheral role; or OTG (that'd need much external circuitry).
|
|
|
|
*
|
|
|
|
* For documentation, see the SL811HS spec and the "SL811HS Embedded Host"
|
|
|
|
* document (providing significant pieces missing from that spec); plus
|
|
|
|
* the SL811S spec if you want peripheral side info.
|
2005-05-26 12:55:55 +00:00
|
|
|
*/
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Status: Passed basic stress testing, works with hubs, mice, keyboards,
|
|
|
|
* and usb-storage.
|
|
|
|
*
|
|
|
|
* TODO:
|
2014-11-29 22:47:05 +00:00
|
|
|
* - usb suspend/resume triggered by sl811
|
2005-04-16 22:20:36 +00:00
|
|
|
* - various issues noted in the code
|
|
|
|
* - performance work; use both register banks; ...
|
|
|
|
* - use urb->iso_frame_desc[] with ISO transfers
|
|
|
|
*/
|
|
|
|
|
|
|
|
#undef VERBOSE
|
|
|
|
#undef PACKET_TRACE
|
|
|
|
|
|
|
|
#include <linux/module.h>
|
|
|
|
#include <linux/moduleparam.h>
|
|
|
|
#include <linux/kernel.h>
|
|
|
|
#include <linux/delay.h>
|
|
|
|
#include <linux/ioport.h>
|
|
|
|
#include <linux/sched.h>
|
|
|
|
#include <linux/slab.h>
|
|
|
|
#include <linux/errno.h>
|
|
|
|
#include <linux/timer.h>
|
|
|
|
#include <linux/list.h>
|
|
|
|
#include <linux/interrupt.h>
|
|
|
|
#include <linux/usb.h>
|
2006-06-13 16:59:32 +00:00
|
|
|
#include <linux/usb/sl811.h>
|
2010-04-24 21:21:52 +00:00
|
|
|
#include <linux/usb/hcd.h>
|
2005-10-29 18:07:23 +00:00
|
|
|
#include <linux/platform_device.h>
|
2011-05-20 19:50:29 +00:00
|
|
|
#include <linux/prefetch.h>
|
2013-07-02 19:22:06 +00:00
|
|
|
#include <linux/debugfs.h>
|
|
|
|
#include <linux/seq_file.h>
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
#include <asm/io.h>
|
|
|
|
#include <asm/irq.h>
|
|
|
|
#include <asm/byteorder.h>
|
2009-12-21 17:53:24 +00:00
|
|
|
#include <asm/unaligned.h>
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
#include "sl811.h"
|
|
|
|
|
|
|
|
|
|
|
|
MODULE_DESCRIPTION("SL811HS USB Host Controller Driver");
|
|
|
|
MODULE_LICENSE("GPL");
|
2008-04-11 04:29:22 +00:00
|
|
|
MODULE_ALIAS("platform:sl811-hcd");
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2005-05-26 12:55:55 +00:00
|
|
|
#define DRIVER_VERSION "19 May 2005"
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
/* for now, use only one transfer register bank */
|
|
|
|
#undef USE_B
|
|
|
|
|
|
|
|
// #define QUIRK2
|
|
|
|
#define QUIRK3
|
|
|
|
|
|
|
|
static const char hcd_name[] = "sl811-hcd";
|
|
|
|
|
|
|
|
/*-------------------------------------------------------------------------*/
|
|
|
|
|
|
|
|
static void port_power(struct sl811 *sl811, int is_on)
|
|
|
|
{
|
|
|
|
struct usb_hcd *hcd = sl811_to_hcd(sl811);
|
|
|
|
|
|
|
|
/* hub is inactive unless the port is powered */
|
|
|
|
if (is_on) {
|
2010-03-04 22:05:08 +00:00
|
|
|
if (sl811->port1 & USB_PORT_STAT_POWER)
|
2005-04-16 22:20:36 +00:00
|
|
|
return;
|
|
|
|
|
2010-03-04 22:05:08 +00:00
|
|
|
sl811->port1 = USB_PORT_STAT_POWER;
|
2005-04-16 22:20:36 +00:00
|
|
|
sl811->irq_enable = SL11H_INTMASK_INSRMV;
|
|
|
|
} else {
|
|
|
|
sl811->port1 = 0;
|
|
|
|
sl811->irq_enable = 0;
|
|
|
|
hcd->state = HC_STATE_HALT;
|
|
|
|
}
|
|
|
|
sl811->ctrl1 = 0;
|
|
|
|
sl811_write(sl811, SL11H_IRQ_ENABLE, 0);
|
|
|
|
sl811_write(sl811, SL11H_IRQ_STATUS, ~0);
|
|
|
|
|
|
|
|
if (sl811->board && sl811->board->port_power) {
|
|
|
|
/* switch VBUS, at 500mA unless hub power budget gets set */
|
2013-06-28 18:33:03 +00:00
|
|
|
dev_dbg(hcd->self.controller, "power %s\n",
|
|
|
|
is_on ? "on" : "off");
|
2005-04-16 22:20:36 +00:00
|
|
|
sl811->board->port_power(hcd->self.controller, is_on);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* reset as thoroughly as we can */
|
|
|
|
if (sl811->board && sl811->board->reset)
|
|
|
|
sl811->board->reset(hcd->self.controller);
|
2005-05-26 12:55:55 +00:00
|
|
|
else {
|
|
|
|
sl811_write(sl811, SL11H_CTLREG1, SL11H_CTL1MASK_SE0);
|
|
|
|
mdelay(20);
|
|
|
|
}
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
sl811_write(sl811, SL11H_IRQ_ENABLE, 0);
|
|
|
|
sl811_write(sl811, SL11H_CTLREG1, sl811->ctrl1);
|
|
|
|
sl811_write(sl811, SL811HS_CTLREG2, SL811HS_CTL2_INIT);
|
|
|
|
sl811_write(sl811, SL11H_IRQ_ENABLE, sl811->irq_enable);
|
|
|
|
|
|
|
|
// if !is_on, put into lowpower mode now
|
|
|
|
}
|
|
|
|
|
|
|
|
/*-------------------------------------------------------------------------*/
|
|
|
|
|
|
|
|
/* This is a PIO-only HCD. Queueing appends URBs to the endpoint's queue,
|
|
|
|
* and may start I/O. Endpoint queues are scanned during completion irq
|
2005-05-04 01:07:24 +00:00
|
|
|
* handlers (one per packet: ACK, NAK, faults, etc) and urb cancellation.
|
2005-04-16 22:20:36 +00:00
|
|
|
*
|
|
|
|
* Using an external DMA engine to copy a packet at a time could work,
|
|
|
|
* though setup/teardown costs may be too big to make it worthwhile.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* SETUP starts a new control request. Devices are not allowed to
|
|
|
|
* STALL or NAK these; they must cancel any pending control requests.
|
|
|
|
*/
|
|
|
|
static void setup_packet(
|
|
|
|
struct sl811 *sl811,
|
|
|
|
struct sl811h_ep *ep,
|
|
|
|
struct urb *urb,
|
|
|
|
u8 bank,
|
|
|
|
u8 control
|
|
|
|
)
|
|
|
|
{
|
|
|
|
u8 addr;
|
|
|
|
u8 len;
|
|
|
|
void __iomem *data_reg;
|
|
|
|
|
|
|
|
addr = SL811HS_PACKET_BUF(bank == 0);
|
|
|
|
len = sizeof(struct usb_ctrlrequest);
|
|
|
|
data_reg = sl811->data_reg;
|
|
|
|
sl811_write_buf(sl811, addr, urb->setup_packet, len);
|
|
|
|
|
|
|
|
/* autoincrementing */
|
|
|
|
sl811_write(sl811, bank + SL11H_BUFADDRREG, addr);
|
|
|
|
writeb(len, data_reg);
|
|
|
|
writeb(SL_SETUP /* | ep->epnum */, data_reg);
|
|
|
|
writeb(usb_pipedevice(urb->pipe), data_reg);
|
|
|
|
|
2012-09-12 17:03:22 +00:00
|
|
|
/* always OUT/data0 */
|
2005-04-16 22:20:36 +00:00
|
|
|
sl811_write(sl811, bank + SL11H_HOSTCTLREG,
|
|
|
|
control | SL11H_HCTLMASK_OUT);
|
|
|
|
ep->length = 0;
|
|
|
|
PACKET("SETUP qh%p\n", ep);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* STATUS finishes control requests, often after IN or OUT data packets */
|
|
|
|
static void status_packet(
|
|
|
|
struct sl811 *sl811,
|
|
|
|
struct sl811h_ep *ep,
|
|
|
|
struct urb *urb,
|
|
|
|
u8 bank,
|
|
|
|
u8 control
|
|
|
|
)
|
|
|
|
{
|
|
|
|
int do_out;
|
|
|
|
void __iomem *data_reg;
|
|
|
|
|
|
|
|
do_out = urb->transfer_buffer_length && usb_pipein(urb->pipe);
|
|
|
|
data_reg = sl811->data_reg;
|
|
|
|
|
|
|
|
/* autoincrementing */
|
|
|
|
sl811_write(sl811, bank + SL11H_BUFADDRREG, 0);
|
|
|
|
writeb(0, data_reg);
|
|
|
|
writeb((do_out ? SL_OUT : SL_IN) /* | ep->epnum */, data_reg);
|
|
|
|
writeb(usb_pipedevice(urb->pipe), data_reg);
|
|
|
|
|
|
|
|
/* always data1; sometimes IN */
|
|
|
|
control |= SL11H_HCTLMASK_TOGGLE;
|
|
|
|
if (do_out)
|
|
|
|
control |= SL11H_HCTLMASK_OUT;
|
|
|
|
sl811_write(sl811, bank + SL11H_HOSTCTLREG, control);
|
|
|
|
ep->length = 0;
|
|
|
|
PACKET("STATUS%s/%s qh%p\n", ep->nak_count ? "/retry" : "",
|
|
|
|
do_out ? "out" : "in", ep);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* IN packets can be used with any type of endpoint. here we just
|
|
|
|
* start the transfer, data from the peripheral may arrive later.
|
|
|
|
* urb->iso_frame_desc is currently ignored here...
|
|
|
|
*/
|
|
|
|
static void in_packet(
|
|
|
|
struct sl811 *sl811,
|
|
|
|
struct sl811h_ep *ep,
|
|
|
|
struct urb *urb,
|
|
|
|
u8 bank,
|
|
|
|
u8 control
|
|
|
|
)
|
|
|
|
{
|
|
|
|
u8 addr;
|
|
|
|
u8 len;
|
|
|
|
void __iomem *data_reg;
|
|
|
|
|
|
|
|
/* avoid losing data on overflow */
|
|
|
|
len = ep->maxpacket;
|
|
|
|
addr = SL811HS_PACKET_BUF(bank == 0);
|
|
|
|
if (!(control & SL11H_HCTLMASK_ISOCH)
|
|
|
|
&& usb_gettoggle(urb->dev, ep->epnum, 0))
|
|
|
|
control |= SL11H_HCTLMASK_TOGGLE;
|
|
|
|
data_reg = sl811->data_reg;
|
|
|
|
|
|
|
|
/* autoincrementing */
|
|
|
|
sl811_write(sl811, bank + SL11H_BUFADDRREG, addr);
|
|
|
|
writeb(len, data_reg);
|
|
|
|
writeb(SL_IN | ep->epnum, data_reg);
|
|
|
|
writeb(usb_pipedevice(urb->pipe), data_reg);
|
|
|
|
|
|
|
|
sl811_write(sl811, bank + SL11H_HOSTCTLREG, control);
|
2009-03-04 00:44:13 +00:00
|
|
|
ep->length = min_t(u32, len,
|
2005-04-16 22:20:36 +00:00
|
|
|
urb->transfer_buffer_length - urb->actual_length);
|
|
|
|
PACKET("IN%s/%d qh%p len%d\n", ep->nak_count ? "/retry" : "",
|
|
|
|
!!usb_gettoggle(urb->dev, ep->epnum, 0), ep, len);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* OUT packets can be used with any type of endpoint.
|
|
|
|
* urb->iso_frame_desc is currently ignored here...
|
|
|
|
*/
|
|
|
|
static void out_packet(
|
|
|
|
struct sl811 *sl811,
|
|
|
|
struct sl811h_ep *ep,
|
|
|
|
struct urb *urb,
|
|
|
|
u8 bank,
|
|
|
|
u8 control
|
|
|
|
)
|
|
|
|
{
|
|
|
|
void *buf;
|
|
|
|
u8 addr;
|
|
|
|
u8 len;
|
|
|
|
void __iomem *data_reg;
|
|
|
|
|
|
|
|
buf = urb->transfer_buffer + urb->actual_length;
|
|
|
|
prefetch(buf);
|
|
|
|
|
2009-03-04 00:44:13 +00:00
|
|
|
len = min_t(u32, ep->maxpacket,
|
2005-04-16 22:20:36 +00:00
|
|
|
urb->transfer_buffer_length - urb->actual_length);
|
|
|
|
|
|
|
|
if (!(control & SL11H_HCTLMASK_ISOCH)
|
|
|
|
&& usb_gettoggle(urb->dev, ep->epnum, 1))
|
|
|
|
control |= SL11H_HCTLMASK_TOGGLE;
|
|
|
|
addr = SL811HS_PACKET_BUF(bank == 0);
|
|
|
|
data_reg = sl811->data_reg;
|
|
|
|
|
|
|
|
sl811_write_buf(sl811, addr, buf, len);
|
|
|
|
|
|
|
|
/* autoincrementing */
|
|
|
|
sl811_write(sl811, bank + SL11H_BUFADDRREG, addr);
|
|
|
|
writeb(len, data_reg);
|
|
|
|
writeb(SL_OUT | ep->epnum, data_reg);
|
|
|
|
writeb(usb_pipedevice(urb->pipe), data_reg);
|
|
|
|
|
|
|
|
sl811_write(sl811, bank + SL11H_HOSTCTLREG,
|
|
|
|
control | SL11H_HCTLMASK_OUT);
|
|
|
|
ep->length = len;
|
|
|
|
PACKET("OUT%s/%d qh%p len%d\n", ep->nak_count ? "/retry" : "",
|
|
|
|
!!usb_gettoggle(urb->dev, ep->epnum, 1), ep, len);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*-------------------------------------------------------------------------*/
|
|
|
|
|
|
|
|
/* caller updates on-chip enables later */
|
|
|
|
|
|
|
|
static inline void sofirq_on(struct sl811 *sl811)
|
|
|
|
{
|
|
|
|
if (sl811->irq_enable & SL11H_INTMASK_SOFINTR)
|
|
|
|
return;
|
2013-06-28 18:33:03 +00:00
|
|
|
dev_dbg(sl811_to_hcd(sl811)->self.controller, "sof irq on\n");
|
2005-04-16 22:20:36 +00:00
|
|
|
sl811->irq_enable |= SL11H_INTMASK_SOFINTR;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void sofirq_off(struct sl811 *sl811)
|
|
|
|
{
|
|
|
|
if (!(sl811->irq_enable & SL11H_INTMASK_SOFINTR))
|
|
|
|
return;
|
2013-06-28 18:33:03 +00:00
|
|
|
dev_dbg(sl811_to_hcd(sl811)->self.controller, "sof irq off\n");
|
2005-04-16 22:20:36 +00:00
|
|
|
sl811->irq_enable &= ~SL11H_INTMASK_SOFINTR;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*-------------------------------------------------------------------------*/
|
|
|
|
|
|
|
|
/* pick the next endpoint for a transaction, and issue it.
|
|
|
|
* frames start with periodic transfers (after whatever is pending
|
|
|
|
* from the previous frame), and the rest of the time is async
|
|
|
|
* transfers, scheduled round-robin.
|
|
|
|
*/
|
|
|
|
static struct sl811h_ep *start(struct sl811 *sl811, u8 bank)
|
|
|
|
{
|
|
|
|
struct sl811h_ep *ep;
|
|
|
|
struct urb *urb;
|
|
|
|
int fclock;
|
|
|
|
u8 control;
|
|
|
|
|
|
|
|
/* use endpoint at schedule head */
|
|
|
|
if (sl811->next_periodic) {
|
|
|
|
ep = sl811->next_periodic;
|
|
|
|
sl811->next_periodic = ep->next;
|
|
|
|
} else {
|
|
|
|
if (sl811->next_async)
|
|
|
|
ep = sl811->next_async;
|
|
|
|
else if (!list_empty(&sl811->async))
|
|
|
|
ep = container_of(sl811->async.next,
|
|
|
|
struct sl811h_ep, schedule);
|
|
|
|
else {
|
|
|
|
/* could set up the first fullspeed periodic
|
|
|
|
* transfer for the next frame ...
|
|
|
|
*/
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef USE_B
|
|
|
|
if ((bank && sl811->active_b == ep) || sl811->active_a == ep)
|
|
|
|
return NULL;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
if (ep->schedule.next == &sl811->async)
|
|
|
|
sl811->next_async = NULL;
|
|
|
|
else
|
|
|
|
sl811->next_async = container_of(ep->schedule.next,
|
|
|
|
struct sl811h_ep, schedule);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (unlikely(list_empty(&ep->hep->urb_list))) {
|
2013-06-28 18:33:03 +00:00
|
|
|
dev_dbg(sl811_to_hcd(sl811)->self.controller,
|
|
|
|
"empty %p queue?\n", ep);
|
2005-04-16 22:20:36 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
urb = container_of(ep->hep->urb_list.next, struct urb, urb_list);
|
|
|
|
control = ep->defctrl;
|
|
|
|
|
|
|
|
/* if this frame doesn't have enough time left to transfer this
|
|
|
|
* packet, wait till the next frame. too-simple algorithm...
|
|
|
|
*/
|
|
|
|
fclock = sl811_read(sl811, SL11H_SOFTMRREG) << 6;
|
|
|
|
fclock -= 100; /* setup takes not much time */
|
|
|
|
if (urb->dev->speed == USB_SPEED_LOW) {
|
|
|
|
if (control & SL11H_HCTLMASK_PREAMBLE) {
|
|
|
|
/* also note erratum 1: some hubs won't work */
|
|
|
|
fclock -= 800;
|
|
|
|
}
|
|
|
|
fclock -= ep->maxpacket << 8;
|
|
|
|
|
|
|
|
/* erratum 2: AFTERSOF only works for fullspeed */
|
|
|
|
if (fclock < 0) {
|
|
|
|
if (ep->period)
|
|
|
|
sl811->stat_overrun++;
|
|
|
|
sofirq_on(sl811);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
fclock -= 12000 / 19; /* 19 64byte packets/msec */
|
|
|
|
if (fclock < 0) {
|
|
|
|
if (ep->period)
|
|
|
|
sl811->stat_overrun++;
|
|
|
|
control |= SL11H_HCTLMASK_AFTERSOF;
|
|
|
|
|
|
|
|
/* throttle bulk/control irq noise */
|
|
|
|
} else if (ep->nak_count)
|
|
|
|
control |= SL11H_HCTLMASK_AFTERSOF;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
switch (ep->nextpid) {
|
|
|
|
case USB_PID_IN:
|
|
|
|
in_packet(sl811, ep, urb, bank, control);
|
|
|
|
break;
|
|
|
|
case USB_PID_OUT:
|
|
|
|
out_packet(sl811, ep, urb, bank, control);
|
|
|
|
break;
|
|
|
|
case USB_PID_SETUP:
|
|
|
|
setup_packet(sl811, ep, urb, bank, control);
|
|
|
|
break;
|
|
|
|
case USB_PID_ACK: /* for control status */
|
|
|
|
status_packet(sl811, ep, urb, bank, control);
|
|
|
|
break;
|
|
|
|
default:
|
2013-06-28 18:33:03 +00:00
|
|
|
dev_dbg(sl811_to_hcd(sl811)->self.controller,
|
|
|
|
"bad ep%p pid %02x\n", ep, ep->nextpid);
|
2005-04-16 22:20:36 +00:00
|
|
|
ep = NULL;
|
|
|
|
}
|
|
|
|
return ep;
|
|
|
|
}
|
|
|
|
|
|
|
|
#define MIN_JIFFIES ((msecs_to_jiffies(2) > 1) ? msecs_to_jiffies(2) : 2)
|
|
|
|
|
|
|
|
static inline void start_transfer(struct sl811 *sl811)
|
|
|
|
{
|
2010-03-04 22:05:08 +00:00
|
|
|
if (sl811->port1 & USB_PORT_STAT_SUSPEND)
|
2005-04-16 22:20:36 +00:00
|
|
|
return;
|
|
|
|
if (sl811->active_a == NULL) {
|
|
|
|
sl811->active_a = start(sl811, SL811_EP_A(SL811_HOST_BUF));
|
|
|
|
if (sl811->active_a != NULL)
|
|
|
|
sl811->jiffies_a = jiffies + MIN_JIFFIES;
|
|
|
|
}
|
|
|
|
#ifdef USE_B
|
|
|
|
if (sl811->active_b == NULL) {
|
|
|
|
sl811->active_b = start(sl811, SL811_EP_B(SL811_HOST_BUF));
|
|
|
|
if (sl811->active_b != NULL)
|
|
|
|
sl811->jiffies_b = jiffies + MIN_JIFFIES;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
static void finish_request(
|
|
|
|
struct sl811 *sl811,
|
|
|
|
struct sl811h_ep *ep,
|
|
|
|
struct urb *urb,
|
|
|
|
int status
|
|
|
|
) __releases(sl811->lock) __acquires(sl811->lock)
|
|
|
|
{
|
|
|
|
unsigned i;
|
|
|
|
|
|
|
|
if (usb_pipecontrol(urb->pipe))
|
|
|
|
ep->nextpid = USB_PID_SETUP;
|
|
|
|
|
2007-08-08 15:48:02 +00:00
|
|
|
usb_hcd_unlink_urb_from_ep(sl811_to_hcd(sl811), urb);
|
2005-04-16 22:20:36 +00:00
|
|
|
spin_unlock(&sl811->lock);
|
2007-08-24 19:42:24 +00:00
|
|
|
usb_hcd_giveback_urb(sl811_to_hcd(sl811), urb, status);
|
2005-04-16 22:20:36 +00:00
|
|
|
spin_lock(&sl811->lock);
|
|
|
|
|
|
|
|
/* leave active endpoints in the schedule */
|
|
|
|
if (!list_empty(&ep->hep->urb_list))
|
|
|
|
return;
|
|
|
|
|
|
|
|
/* async deschedule? */
|
|
|
|
if (!list_empty(&ep->schedule)) {
|
|
|
|
list_del_init(&ep->schedule);
|
|
|
|
if (ep == sl811->next_async)
|
|
|
|
sl811->next_async = NULL;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* periodic deschedule */
|
2013-06-28 18:33:03 +00:00
|
|
|
dev_dbg(sl811_to_hcd(sl811)->self.controller,
|
|
|
|
"deschedule qh%d/%p branch %d\n", ep->period, ep, ep->branch);
|
2005-04-16 22:20:36 +00:00
|
|
|
for (i = ep->branch; i < PERIODIC_SIZE; i += ep->period) {
|
|
|
|
struct sl811h_ep *temp;
|
|
|
|
struct sl811h_ep **prev = &sl811->periodic[i];
|
|
|
|
|
|
|
|
while (*prev && ((temp = *prev) != ep))
|
|
|
|
prev = &temp->next;
|
|
|
|
if (*prev)
|
|
|
|
*prev = ep->next;
|
|
|
|
sl811->load[i] -= ep->load;
|
2005-05-26 12:55:55 +00:00
|
|
|
}
|
2005-04-16 22:20:36 +00:00
|
|
|
ep->branch = PERIODIC_SIZE;
|
|
|
|
sl811->periodic_count--;
|
|
|
|
sl811_to_hcd(sl811)->self.bandwidth_allocated
|
|
|
|
-= ep->load / ep->period;
|
|
|
|
if (ep == sl811->next_periodic)
|
|
|
|
sl811->next_periodic = ep->next;
|
|
|
|
|
|
|
|
/* we might turn SOFs back on again for the async schedule */
|
|
|
|
if (sl811->periodic_count == 0)
|
|
|
|
sofirq_off(sl811);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
IRQ: Maintain regs pointer globally rather than passing to IRQ handlers
Maintain a per-CPU global "struct pt_regs *" variable which can be used instead
of passing regs around manually through all ~1800 interrupt handlers in the
Linux kernel.
The regs pointer is used in few places, but it potentially costs both stack
space and code to pass it around. On the FRV arch, removing the regs parameter
from all the genirq function results in a 20% speed up of the IRQ exit path
(ie: from leaving timer_interrupt() to leaving do_IRQ()).
Where appropriate, an arch may override the generic storage facility and do
something different with the variable. On FRV, for instance, the address is
maintained in GR28 at all times inside the kernel as part of general exception
handling.
Having looked over the code, it appears that the parameter may be handed down
through up to twenty or so layers of functions. Consider a USB character
device attached to a USB hub, attached to a USB controller that posts its
interrupts through a cascaded auxiliary interrupt controller. A character
device driver may want to pass regs to the sysrq handler through the input
layer which adds another few layers of parameter passing.
I've build this code with allyesconfig for x86_64 and i386. I've runtested the
main part of the code on FRV and i386, though I can't test most of the drivers.
I've also done partial conversion for powerpc and MIPS - these at least compile
with minimal configurations.
This will affect all archs. Mostly the changes should be relatively easy.
Take do_IRQ(), store the regs pointer at the beginning, saving the old one:
struct pt_regs *old_regs = set_irq_regs(regs);
And put the old one back at the end:
set_irq_regs(old_regs);
Don't pass regs through to generic_handle_irq() or __do_IRQ().
In timer_interrupt(), this sort of change will be necessary:
- update_process_times(user_mode(regs));
- profile_tick(CPU_PROFILING, regs);
+ update_process_times(user_mode(get_irq_regs()));
+ profile_tick(CPU_PROFILING);
I'd like to move update_process_times()'s use of get_irq_regs() into itself,
except that i386, alone of the archs, uses something other than user_mode().
Some notes on the interrupt handling in the drivers:
(*) input_dev() is now gone entirely. The regs pointer is no longer stored in
the input_dev struct.
(*) finish_unlinks() in drivers/usb/host/ohci-q.c needs checking. It does
something different depending on whether it's been supplied with a regs
pointer or not.
(*) Various IRQ handler function pointers have been moved to type
irq_handler_t.
Signed-Off-By: David Howells <dhowells@redhat.com>
(cherry picked from 1b16e7ac850969f38b375e511e3fa2f474a33867 commit)
2006-10-05 13:55:46 +00:00
|
|
|
done(struct sl811 *sl811, struct sl811h_ep *ep, u8 bank)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
|
|
|
u8 status;
|
|
|
|
struct urb *urb;
|
|
|
|
int urbstat = -EINPROGRESS;
|
|
|
|
|
|
|
|
if (unlikely(!ep))
|
|
|
|
return;
|
|
|
|
|
|
|
|
status = sl811_read(sl811, bank + SL11H_PKTSTATREG);
|
|
|
|
|
|
|
|
urb = container_of(ep->hep->urb_list.next, struct urb, urb_list);
|
|
|
|
|
|
|
|
/* we can safely ignore NAKs */
|
|
|
|
if (status & SL11H_STATMASK_NAK) {
|
|
|
|
// PACKET("...NAK_%02x qh%p\n", bank, ep);
|
|
|
|
if (!ep->period)
|
|
|
|
ep->nak_count++;
|
|
|
|
ep->error_count = 0;
|
|
|
|
|
|
|
|
/* ACK advances transfer, toggle, and maybe queue */
|
|
|
|
} else if (status & SL11H_STATMASK_ACK) {
|
|
|
|
struct usb_device *udev = urb->dev;
|
|
|
|
int len;
|
|
|
|
unsigned char *buf;
|
|
|
|
|
|
|
|
/* urb->iso_frame_desc is currently ignored here... */
|
|
|
|
|
|
|
|
ep->nak_count = ep->error_count = 0;
|
|
|
|
switch (ep->nextpid) {
|
|
|
|
case USB_PID_OUT:
|
|
|
|
// PACKET("...ACK/out_%02x qh%p\n", bank, ep);
|
|
|
|
urb->actual_length += ep->length;
|
|
|
|
usb_dotoggle(udev, ep->epnum, 1);
|
|
|
|
if (urb->actual_length
|
|
|
|
== urb->transfer_buffer_length) {
|
|
|
|
if (usb_pipecontrol(urb->pipe))
|
|
|
|
ep->nextpid = USB_PID_ACK;
|
|
|
|
|
|
|
|
/* some bulk protocols terminate OUT transfers
|
|
|
|
* by a short packet, using ZLPs not padding.
|
|
|
|
*/
|
|
|
|
else if (ep->length < ep->maxpacket
|
|
|
|
|| !(urb->transfer_flags
|
|
|
|
& URB_ZERO_PACKET))
|
|
|
|
urbstat = 0;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case USB_PID_IN:
|
|
|
|
// PACKET("...ACK/in_%02x qh%p\n", bank, ep);
|
|
|
|
buf = urb->transfer_buffer + urb->actual_length;
|
|
|
|
prefetchw(buf);
|
|
|
|
len = ep->maxpacket - sl811_read(sl811,
|
|
|
|
bank + SL11H_XFERCNTREG);
|
|
|
|
if (len > ep->length) {
|
|
|
|
len = ep->length;
|
2007-08-24 19:40:47 +00:00
|
|
|
urbstat = -EOVERFLOW;
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
urb->actual_length += len;
|
|
|
|
sl811_read_buf(sl811, SL811HS_PACKET_BUF(bank == 0),
|
|
|
|
buf, len);
|
|
|
|
usb_dotoggle(udev, ep->epnum, 0);
|
2007-08-24 19:40:47 +00:00
|
|
|
if (urbstat == -EINPROGRESS &&
|
|
|
|
(len < ep->maxpacket ||
|
|
|
|
urb->actual_length ==
|
|
|
|
urb->transfer_buffer_length)) {
|
|
|
|
if (usb_pipecontrol(urb->pipe))
|
|
|
|
ep->nextpid = USB_PID_ACK;
|
|
|
|
else
|
|
|
|
urbstat = 0;
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case USB_PID_SETUP:
|
|
|
|
// PACKET("...ACK/setup_%02x qh%p\n", bank, ep);
|
|
|
|
if (urb->transfer_buffer_length == urb->actual_length)
|
|
|
|
ep->nextpid = USB_PID_ACK;
|
|
|
|
else if (usb_pipeout(urb->pipe)) {
|
|
|
|
usb_settoggle(udev, 0, 1, 1);
|
|
|
|
ep->nextpid = USB_PID_OUT;
|
|
|
|
} else {
|
|
|
|
usb_settoggle(udev, 0, 0, 1);
|
|
|
|
ep->nextpid = USB_PID_IN;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case USB_PID_ACK:
|
|
|
|
// PACKET("...ACK/status_%02x qh%p\n", bank, ep);
|
|
|
|
urbstat = 0;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* STALL stops all transfers */
|
|
|
|
} else if (status & SL11H_STATMASK_STALL) {
|
|
|
|
PACKET("...STALL_%02x qh%p\n", bank, ep);
|
|
|
|
ep->nak_count = ep->error_count = 0;
|
|
|
|
urbstat = -EPIPE;
|
|
|
|
|
|
|
|
/* error? retry, until "3 strikes" */
|
|
|
|
} else if (++ep->error_count >= 3) {
|
|
|
|
if (status & SL11H_STATMASK_TMOUT)
|
2006-09-19 05:49:02 +00:00
|
|
|
urbstat = -ETIME;
|
2005-04-16 22:20:36 +00:00
|
|
|
else if (status & SL11H_STATMASK_OVF)
|
|
|
|
urbstat = -EOVERFLOW;
|
|
|
|
else
|
|
|
|
urbstat = -EPROTO;
|
|
|
|
ep->error_count = 0;
|
|
|
|
PACKET("...3STRIKES_%02x %02x qh%p stat %d\n",
|
|
|
|
bank, status, ep, urbstat);
|
|
|
|
}
|
|
|
|
|
2007-08-24 19:40:47 +00:00
|
|
|
if (urbstat != -EINPROGRESS || urb->unlinked)
|
IRQ: Maintain regs pointer globally rather than passing to IRQ handlers
Maintain a per-CPU global "struct pt_regs *" variable which can be used instead
of passing regs around manually through all ~1800 interrupt handlers in the
Linux kernel.
The regs pointer is used in few places, but it potentially costs both stack
space and code to pass it around. On the FRV arch, removing the regs parameter
from all the genirq function results in a 20% speed up of the IRQ exit path
(ie: from leaving timer_interrupt() to leaving do_IRQ()).
Where appropriate, an arch may override the generic storage facility and do
something different with the variable. On FRV, for instance, the address is
maintained in GR28 at all times inside the kernel as part of general exception
handling.
Having looked over the code, it appears that the parameter may be handed down
through up to twenty or so layers of functions. Consider a USB character
device attached to a USB hub, attached to a USB controller that posts its
interrupts through a cascaded auxiliary interrupt controller. A character
device driver may want to pass regs to the sysrq handler through the input
layer which adds another few layers of parameter passing.
I've build this code with allyesconfig for x86_64 and i386. I've runtested the
main part of the code on FRV and i386, though I can't test most of the drivers.
I've also done partial conversion for powerpc and MIPS - these at least compile
with minimal configurations.
This will affect all archs. Mostly the changes should be relatively easy.
Take do_IRQ(), store the regs pointer at the beginning, saving the old one:
struct pt_regs *old_regs = set_irq_regs(regs);
And put the old one back at the end:
set_irq_regs(old_regs);
Don't pass regs through to generic_handle_irq() or __do_IRQ().
In timer_interrupt(), this sort of change will be necessary:
- update_process_times(user_mode(regs));
- profile_tick(CPU_PROFILING, regs);
+ update_process_times(user_mode(get_irq_regs()));
+ profile_tick(CPU_PROFILING);
I'd like to move update_process_times()'s use of get_irq_regs() into itself,
except that i386, alone of the archs, uses something other than user_mode().
Some notes on the interrupt handling in the drivers:
(*) input_dev() is now gone entirely. The regs pointer is no longer stored in
the input_dev struct.
(*) finish_unlinks() in drivers/usb/host/ohci-q.c needs checking. It does
something different depending on whether it's been supplied with a regs
pointer or not.
(*) Various IRQ handler function pointers have been moved to type
irq_handler_t.
Signed-Off-By: David Howells <dhowells@redhat.com>
(cherry picked from 1b16e7ac850969f38b375e511e3fa2f474a33867 commit)
2006-10-05 13:55:46 +00:00
|
|
|
finish_request(sl811, ep, urb, urbstat);
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static inline u8 checkdone(struct sl811 *sl811)
|
|
|
|
{
|
|
|
|
u8 ctl;
|
|
|
|
u8 irqstat = 0;
|
|
|
|
|
|
|
|
if (sl811->active_a && time_before_eq(sl811->jiffies_a, jiffies)) {
|
|
|
|
ctl = sl811_read(sl811, SL811_EP_A(SL11H_HOSTCTLREG));
|
|
|
|
if (ctl & SL11H_HCTLMASK_ARM)
|
|
|
|
sl811_write(sl811, SL811_EP_A(SL11H_HOSTCTLREG), 0);
|
2013-06-28 18:33:03 +00:00
|
|
|
dev_dbg(sl811_to_hcd(sl811)->self.controller,
|
|
|
|
"%s DONE_A: ctrl %02x sts %02x\n",
|
2005-04-16 22:20:36 +00:00
|
|
|
(ctl & SL11H_HCTLMASK_ARM) ? "timeout" : "lost",
|
|
|
|
ctl,
|
|
|
|
sl811_read(sl811, SL811_EP_A(SL11H_PKTSTATREG)));
|
|
|
|
irqstat |= SL11H_INTMASK_DONE_A;
|
|
|
|
}
|
|
|
|
#ifdef USE_B
|
|
|
|
if (sl811->active_b && time_before_eq(sl811->jiffies_b, jiffies)) {
|
|
|
|
ctl = sl811_read(sl811, SL811_EP_B(SL11H_HOSTCTLREG));
|
|
|
|
if (ctl & SL11H_HCTLMASK_ARM)
|
|
|
|
sl811_write(sl811, SL811_EP_B(SL11H_HOSTCTLREG), 0);
|
2013-06-28 18:33:03 +00:00
|
|
|
dev_dbg(sl811_to_hcd(sl811)->self.controller,
|
|
|
|
"%s DONE_B: ctrl %02x sts %02x\n",
|
2005-04-16 22:20:36 +00:00
|
|
|
(ctl & SL11H_HCTLMASK_ARM) ? "timeout" : "lost",
|
|
|
|
ctl,
|
|
|
|
sl811_read(sl811, SL811_EP_B(SL11H_PKTSTATREG)));
|
|
|
|
irqstat |= SL11H_INTMASK_DONE_A;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
return irqstat;
|
|
|
|
}
|
|
|
|
|
IRQ: Maintain regs pointer globally rather than passing to IRQ handlers
Maintain a per-CPU global "struct pt_regs *" variable which can be used instead
of passing regs around manually through all ~1800 interrupt handlers in the
Linux kernel.
The regs pointer is used in few places, but it potentially costs both stack
space and code to pass it around. On the FRV arch, removing the regs parameter
from all the genirq function results in a 20% speed up of the IRQ exit path
(ie: from leaving timer_interrupt() to leaving do_IRQ()).
Where appropriate, an arch may override the generic storage facility and do
something different with the variable. On FRV, for instance, the address is
maintained in GR28 at all times inside the kernel as part of general exception
handling.
Having looked over the code, it appears that the parameter may be handed down
through up to twenty or so layers of functions. Consider a USB character
device attached to a USB hub, attached to a USB controller that posts its
interrupts through a cascaded auxiliary interrupt controller. A character
device driver may want to pass regs to the sysrq handler through the input
layer which adds another few layers of parameter passing.
I've build this code with allyesconfig for x86_64 and i386. I've runtested the
main part of the code on FRV and i386, though I can't test most of the drivers.
I've also done partial conversion for powerpc and MIPS - these at least compile
with minimal configurations.
This will affect all archs. Mostly the changes should be relatively easy.
Take do_IRQ(), store the regs pointer at the beginning, saving the old one:
struct pt_regs *old_regs = set_irq_regs(regs);
And put the old one back at the end:
set_irq_regs(old_regs);
Don't pass regs through to generic_handle_irq() or __do_IRQ().
In timer_interrupt(), this sort of change will be necessary:
- update_process_times(user_mode(regs));
- profile_tick(CPU_PROFILING, regs);
+ update_process_times(user_mode(get_irq_regs()));
+ profile_tick(CPU_PROFILING);
I'd like to move update_process_times()'s use of get_irq_regs() into itself,
except that i386, alone of the archs, uses something other than user_mode().
Some notes on the interrupt handling in the drivers:
(*) input_dev() is now gone entirely. The regs pointer is no longer stored in
the input_dev struct.
(*) finish_unlinks() in drivers/usb/host/ohci-q.c needs checking. It does
something different depending on whether it's been supplied with a regs
pointer or not.
(*) Various IRQ handler function pointers have been moved to type
irq_handler_t.
Signed-Off-By: David Howells <dhowells@redhat.com>
(cherry picked from 1b16e7ac850969f38b375e511e3fa2f474a33867 commit)
2006-10-05 13:55:46 +00:00
|
|
|
static irqreturn_t sl811h_irq(struct usb_hcd *hcd)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
|
|
|
struct sl811 *sl811 = hcd_to_sl811(hcd);
|
|
|
|
u8 irqstat;
|
|
|
|
irqreturn_t ret = IRQ_NONE;
|
|
|
|
unsigned retries = 5;
|
|
|
|
|
|
|
|
spin_lock(&sl811->lock);
|
|
|
|
|
|
|
|
retry:
|
|
|
|
irqstat = sl811_read(sl811, SL11H_IRQ_STATUS) & ~SL11H_INTMASK_DP;
|
|
|
|
if (irqstat) {
|
|
|
|
sl811_write(sl811, SL11H_IRQ_STATUS, irqstat);
|
|
|
|
irqstat &= sl811->irq_enable;
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef QUIRK2
|
|
|
|
/* this may no longer be necessary ... */
|
2005-05-26 12:55:55 +00:00
|
|
|
if (irqstat == 0) {
|
2005-04-16 22:20:36 +00:00
|
|
|
irqstat = checkdone(sl811);
|
2005-05-26 12:55:55 +00:00
|
|
|
if (irqstat)
|
2005-04-16 22:20:36 +00:00
|
|
|
sl811->stat_lost++;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* USB packets, not necessarily handled in the order they're
|
|
|
|
* issued ... that's fine if they're different endpoints.
|
|
|
|
*/
|
|
|
|
if (irqstat & SL11H_INTMASK_DONE_A) {
|
IRQ: Maintain regs pointer globally rather than passing to IRQ handlers
Maintain a per-CPU global "struct pt_regs *" variable which can be used instead
of passing regs around manually through all ~1800 interrupt handlers in the
Linux kernel.
The regs pointer is used in few places, but it potentially costs both stack
space and code to pass it around. On the FRV arch, removing the regs parameter
from all the genirq function results in a 20% speed up of the IRQ exit path
(ie: from leaving timer_interrupt() to leaving do_IRQ()).
Where appropriate, an arch may override the generic storage facility and do
something different with the variable. On FRV, for instance, the address is
maintained in GR28 at all times inside the kernel as part of general exception
handling.
Having looked over the code, it appears that the parameter may be handed down
through up to twenty or so layers of functions. Consider a USB character
device attached to a USB hub, attached to a USB controller that posts its
interrupts through a cascaded auxiliary interrupt controller. A character
device driver may want to pass regs to the sysrq handler through the input
layer which adds another few layers of parameter passing.
I've build this code with allyesconfig for x86_64 and i386. I've runtested the
main part of the code on FRV and i386, though I can't test most of the drivers.
I've also done partial conversion for powerpc and MIPS - these at least compile
with minimal configurations.
This will affect all archs. Mostly the changes should be relatively easy.
Take do_IRQ(), store the regs pointer at the beginning, saving the old one:
struct pt_regs *old_regs = set_irq_regs(regs);
And put the old one back at the end:
set_irq_regs(old_regs);
Don't pass regs through to generic_handle_irq() or __do_IRQ().
In timer_interrupt(), this sort of change will be necessary:
- update_process_times(user_mode(regs));
- profile_tick(CPU_PROFILING, regs);
+ update_process_times(user_mode(get_irq_regs()));
+ profile_tick(CPU_PROFILING);
I'd like to move update_process_times()'s use of get_irq_regs() into itself,
except that i386, alone of the archs, uses something other than user_mode().
Some notes on the interrupt handling in the drivers:
(*) input_dev() is now gone entirely. The regs pointer is no longer stored in
the input_dev struct.
(*) finish_unlinks() in drivers/usb/host/ohci-q.c needs checking. It does
something different depending on whether it's been supplied with a regs
pointer or not.
(*) Various IRQ handler function pointers have been moved to type
irq_handler_t.
Signed-Off-By: David Howells <dhowells@redhat.com>
(cherry picked from 1b16e7ac850969f38b375e511e3fa2f474a33867 commit)
2006-10-05 13:55:46 +00:00
|
|
|
done(sl811, sl811->active_a, SL811_EP_A(SL811_HOST_BUF));
|
2005-04-16 22:20:36 +00:00
|
|
|
sl811->active_a = NULL;
|
|
|
|
sl811->stat_a++;
|
|
|
|
}
|
|
|
|
#ifdef USE_B
|
|
|
|
if (irqstat & SL11H_INTMASK_DONE_B) {
|
IRQ: Maintain regs pointer globally rather than passing to IRQ handlers
Maintain a per-CPU global "struct pt_regs *" variable which can be used instead
of passing regs around manually through all ~1800 interrupt handlers in the
Linux kernel.
The regs pointer is used in few places, but it potentially costs both stack
space and code to pass it around. On the FRV arch, removing the regs parameter
from all the genirq function results in a 20% speed up of the IRQ exit path
(ie: from leaving timer_interrupt() to leaving do_IRQ()).
Where appropriate, an arch may override the generic storage facility and do
something different with the variable. On FRV, for instance, the address is
maintained in GR28 at all times inside the kernel as part of general exception
handling.
Having looked over the code, it appears that the parameter may be handed down
through up to twenty or so layers of functions. Consider a USB character
device attached to a USB hub, attached to a USB controller that posts its
interrupts through a cascaded auxiliary interrupt controller. A character
device driver may want to pass regs to the sysrq handler through the input
layer which adds another few layers of parameter passing.
I've build this code with allyesconfig for x86_64 and i386. I've runtested the
main part of the code on FRV and i386, though I can't test most of the drivers.
I've also done partial conversion for powerpc and MIPS - these at least compile
with minimal configurations.
This will affect all archs. Mostly the changes should be relatively easy.
Take do_IRQ(), store the regs pointer at the beginning, saving the old one:
struct pt_regs *old_regs = set_irq_regs(regs);
And put the old one back at the end:
set_irq_regs(old_regs);
Don't pass regs through to generic_handle_irq() or __do_IRQ().
In timer_interrupt(), this sort of change will be necessary:
- update_process_times(user_mode(regs));
- profile_tick(CPU_PROFILING, regs);
+ update_process_times(user_mode(get_irq_regs()));
+ profile_tick(CPU_PROFILING);
I'd like to move update_process_times()'s use of get_irq_regs() into itself,
except that i386, alone of the archs, uses something other than user_mode().
Some notes on the interrupt handling in the drivers:
(*) input_dev() is now gone entirely. The regs pointer is no longer stored in
the input_dev struct.
(*) finish_unlinks() in drivers/usb/host/ohci-q.c needs checking. It does
something different depending on whether it's been supplied with a regs
pointer or not.
(*) Various IRQ handler function pointers have been moved to type
irq_handler_t.
Signed-Off-By: David Howells <dhowells@redhat.com>
(cherry picked from 1b16e7ac850969f38b375e511e3fa2f474a33867 commit)
2006-10-05 13:55:46 +00:00
|
|
|
done(sl811, sl811->active_b, SL811_EP_B(SL811_HOST_BUF));
|
2005-04-16 22:20:36 +00:00
|
|
|
sl811->active_b = NULL;
|
|
|
|
sl811->stat_b++;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
if (irqstat & SL11H_INTMASK_SOFINTR) {
|
|
|
|
unsigned index;
|
|
|
|
|
|
|
|
index = sl811->frame++ % (PERIODIC_SIZE - 1);
|
|
|
|
sl811->stat_sof++;
|
|
|
|
|
|
|
|
/* be graceful about almost-inevitable periodic schedule
|
|
|
|
* overruns: continue the previous frame's transfers iff
|
|
|
|
* this one has nothing scheduled.
|
|
|
|
*/
|
|
|
|
if (sl811->next_periodic) {
|
2013-06-28 18:33:03 +00:00
|
|
|
// dev_err(hcd->self.controller, "overrun to slot %d\n", index);
|
2005-04-16 22:20:36 +00:00
|
|
|
sl811->stat_overrun++;
|
|
|
|
}
|
|
|
|
if (sl811->periodic[index])
|
|
|
|
sl811->next_periodic = sl811->periodic[index];
|
|
|
|
}
|
|
|
|
|
2014-09-19 15:32:23 +00:00
|
|
|
/* hub_wq manages debouncing and wakeup */
|
2005-04-16 22:20:36 +00:00
|
|
|
if (irqstat & SL11H_INTMASK_INSRMV) {
|
|
|
|
sl811->stat_insrmv++;
|
|
|
|
|
|
|
|
/* most stats are reset for each VBUS session */
|
|
|
|
sl811->stat_wake = 0;
|
|
|
|
sl811->stat_sof = 0;
|
|
|
|
sl811->stat_a = 0;
|
|
|
|
sl811->stat_b = 0;
|
|
|
|
sl811->stat_lost = 0;
|
|
|
|
|
|
|
|
sl811->ctrl1 = 0;
|
|
|
|
sl811_write(sl811, SL11H_CTLREG1, sl811->ctrl1);
|
|
|
|
|
|
|
|
sl811->irq_enable = SL11H_INTMASK_INSRMV;
|
|
|
|
sl811_write(sl811, SL11H_IRQ_ENABLE, sl811->irq_enable);
|
|
|
|
|
|
|
|
/* usbcore nukes other pending transactions on disconnect */
|
|
|
|
if (sl811->active_a) {
|
|
|
|
sl811_write(sl811, SL811_EP_A(SL11H_HOSTCTLREG), 0);
|
|
|
|
finish_request(sl811, sl811->active_a,
|
2005-05-26 12:55:55 +00:00
|
|
|
container_of(sl811->active_a
|
|
|
|
->hep->urb_list.next,
|
2005-04-16 22:20:36 +00:00
|
|
|
struct urb, urb_list),
|
IRQ: Maintain regs pointer globally rather than passing to IRQ handlers
Maintain a per-CPU global "struct pt_regs *" variable which can be used instead
of passing regs around manually through all ~1800 interrupt handlers in the
Linux kernel.
The regs pointer is used in few places, but it potentially costs both stack
space and code to pass it around. On the FRV arch, removing the regs parameter
from all the genirq function results in a 20% speed up of the IRQ exit path
(ie: from leaving timer_interrupt() to leaving do_IRQ()).
Where appropriate, an arch may override the generic storage facility and do
something different with the variable. On FRV, for instance, the address is
maintained in GR28 at all times inside the kernel as part of general exception
handling.
Having looked over the code, it appears that the parameter may be handed down
through up to twenty or so layers of functions. Consider a USB character
device attached to a USB hub, attached to a USB controller that posts its
interrupts through a cascaded auxiliary interrupt controller. A character
device driver may want to pass regs to the sysrq handler through the input
layer which adds another few layers of parameter passing.
I've build this code with allyesconfig for x86_64 and i386. I've runtested the
main part of the code on FRV and i386, though I can't test most of the drivers.
I've also done partial conversion for powerpc and MIPS - these at least compile
with minimal configurations.
This will affect all archs. Mostly the changes should be relatively easy.
Take do_IRQ(), store the regs pointer at the beginning, saving the old one:
struct pt_regs *old_regs = set_irq_regs(regs);
And put the old one back at the end:
set_irq_regs(old_regs);
Don't pass regs through to generic_handle_irq() or __do_IRQ().
In timer_interrupt(), this sort of change will be necessary:
- update_process_times(user_mode(regs));
- profile_tick(CPU_PROFILING, regs);
+ update_process_times(user_mode(get_irq_regs()));
+ profile_tick(CPU_PROFILING);
I'd like to move update_process_times()'s use of get_irq_regs() into itself,
except that i386, alone of the archs, uses something other than user_mode().
Some notes on the interrupt handling in the drivers:
(*) input_dev() is now gone entirely. The regs pointer is no longer stored in
the input_dev struct.
(*) finish_unlinks() in drivers/usb/host/ohci-q.c needs checking. It does
something different depending on whether it's been supplied with a regs
pointer or not.
(*) Various IRQ handler function pointers have been moved to type
irq_handler_t.
Signed-Off-By: David Howells <dhowells@redhat.com>
(cherry picked from 1b16e7ac850969f38b375e511e3fa2f474a33867 commit)
2006-10-05 13:55:46 +00:00
|
|
|
-ESHUTDOWN);
|
2005-04-16 22:20:36 +00:00
|
|
|
sl811->active_a = NULL;
|
|
|
|
}
|
|
|
|
#ifdef USE_B
|
|
|
|
if (sl811->active_b) {
|
|
|
|
sl811_write(sl811, SL811_EP_B(SL11H_HOSTCTLREG), 0);
|
|
|
|
finish_request(sl811, sl811->active_b,
|
2005-05-26 12:55:55 +00:00
|
|
|
container_of(sl811->active_b
|
|
|
|
->hep->urb_list.next,
|
2005-04-16 22:20:36 +00:00
|
|
|
struct urb, urb_list),
|
|
|
|
NULL, -ESHUTDOWN);
|
|
|
|
sl811->active_b = NULL;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2005-05-04 01:07:24 +00:00
|
|
|
/* port status seems weird until after reset, so
|
2014-09-19 15:32:23 +00:00
|
|
|
* force the reset and make hub_wq clean up later.
|
2005-04-16 22:20:36 +00:00
|
|
|
*/
|
2010-04-28 21:31:36 +00:00
|
|
|
if (irqstat & SL11H_INTMASK_RD)
|
2010-03-04 22:05:08 +00:00
|
|
|
sl811->port1 &= ~USB_PORT_STAT_CONNECTION;
|
2010-04-28 21:31:36 +00:00
|
|
|
else
|
2010-03-04 22:05:08 +00:00
|
|
|
sl811->port1 |= USB_PORT_STAT_CONNECTION;
|
2009-09-02 08:26:21 +00:00
|
|
|
|
2010-03-04 22:05:08 +00:00
|
|
|
sl811->port1 |= USB_PORT_STAT_C_CONNECTION << 16;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
} else if (irqstat & SL11H_INTMASK_RD) {
|
2010-03-04 22:05:08 +00:00
|
|
|
if (sl811->port1 & USB_PORT_STAT_SUSPEND) {
|
2013-06-28 18:33:03 +00:00
|
|
|
dev_dbg(hcd->self.controller, "wakeup\n");
|
2010-03-04 22:05:08 +00:00
|
|
|
sl811->port1 |= USB_PORT_STAT_C_SUSPEND << 16;
|
2005-04-16 22:20:36 +00:00
|
|
|
sl811->stat_wake++;
|
|
|
|
} else
|
|
|
|
irqstat &= ~SL11H_INTMASK_RD;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (irqstat) {
|
2010-03-04 22:05:08 +00:00
|
|
|
if (sl811->port1 & USB_PORT_STAT_ENABLE)
|
2005-04-16 22:20:36 +00:00
|
|
|
start_transfer(sl811);
|
|
|
|
ret = IRQ_HANDLED;
|
|
|
|
if (retries--)
|
|
|
|
goto retry;
|
|
|
|
}
|
|
|
|
|
2005-05-26 12:55:55 +00:00
|
|
|
if (sl811->periodic_count == 0 && list_empty(&sl811->async))
|
2005-04-16 22:20:36 +00:00
|
|
|
sofirq_off(sl811);
|
|
|
|
sl811_write(sl811, SL11H_IRQ_ENABLE, sl811->irq_enable);
|
|
|
|
|
|
|
|
spin_unlock(&sl811->lock);
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*-------------------------------------------------------------------------*/
|
|
|
|
|
|
|
|
/* usb 1.1 says max 90% of a frame is available for periodic transfers.
|
|
|
|
* this driver doesn't promise that much since it's got to handle an
|
|
|
|
* IRQ per packet; irq handling latencies also use up that time.
|
2005-09-22 07:49:07 +00:00
|
|
|
*
|
|
|
|
* NOTE: the periodic schedule is a sparse tree, with the load for
|
|
|
|
* each branch minimized. see fig 3.5 in the OHCI spec for example.
|
2005-04-16 22:20:36 +00:00
|
|
|
*/
|
|
|
|
#define MAX_PERIODIC_LOAD 500 /* out of 1000 usec */
|
|
|
|
|
|
|
|
static int balance(struct sl811 *sl811, u16 period, u16 load)
|
|
|
|
{
|
|
|
|
int i, branch = -ENOSPC;
|
|
|
|
|
|
|
|
/* search for the least loaded schedule branch of that period
|
|
|
|
* which has enough bandwidth left unreserved.
|
|
|
|
*/
|
|
|
|
for (i = 0; i < period ; i++) {
|
|
|
|
if (branch < 0 || sl811->load[branch] > sl811->load[i]) {
|
|
|
|
int j;
|
|
|
|
|
|
|
|
for (j = i; j < PERIODIC_SIZE; j += period) {
|
|
|
|
if ((sl811->load[j] + load)
|
|
|
|
> MAX_PERIODIC_LOAD)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (j < PERIODIC_SIZE)
|
|
|
|
continue;
|
2005-05-26 12:55:55 +00:00
|
|
|
branch = i;
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return branch;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*-------------------------------------------------------------------------*/
|
|
|
|
|
|
|
|
static int sl811h_urb_enqueue(
|
|
|
|
struct usb_hcd *hcd,
|
|
|
|
struct urb *urb,
|
2005-10-21 07:21:58 +00:00
|
|
|
gfp_t mem_flags
|
2005-04-16 22:20:36 +00:00
|
|
|
) {
|
|
|
|
struct sl811 *sl811 = hcd_to_sl811(hcd);
|
|
|
|
struct usb_device *udev = urb->dev;
|
|
|
|
unsigned int pipe = urb->pipe;
|
|
|
|
int is_out = !usb_pipein(pipe);
|
|
|
|
int type = usb_pipetype(pipe);
|
|
|
|
int epnum = usb_pipeendpoint(pipe);
|
|
|
|
struct sl811h_ep *ep = NULL;
|
|
|
|
unsigned long flags;
|
|
|
|
int i;
|
2007-08-08 15:48:02 +00:00
|
|
|
int retval;
|
|
|
|
struct usb_host_endpoint *hep = urb->ep;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2011-03-22 19:35:39 +00:00
|
|
|
#ifndef CONFIG_USB_SL811_HCD_ISO
|
2005-04-16 22:20:36 +00:00
|
|
|
if (type == PIPE_ISOCHRONOUS)
|
|
|
|
return -ENOSPC;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* avoid all allocations within spinlocks */
|
2010-07-16 16:15:06 +00:00
|
|
|
if (!hep->hcpriv) {
|
2005-09-06 22:18:34 +00:00
|
|
|
ep = kzalloc(sizeof *ep, mem_flags);
|
2010-07-16 16:15:06 +00:00
|
|
|
if (ep == NULL)
|
|
|
|
return -ENOMEM;
|
|
|
|
}
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
spin_lock_irqsave(&sl811->lock, flags);
|
|
|
|
|
|
|
|
/* don't submit to a dead or disabled port */
|
2010-03-04 22:05:08 +00:00
|
|
|
if (!(sl811->port1 & USB_PORT_STAT_ENABLE)
|
2005-04-16 22:20:36 +00:00
|
|
|
|| !HC_IS_RUNNING(hcd->state)) {
|
|
|
|
retval = -ENODEV;
|
2005-09-22 07:49:07 +00:00
|
|
|
kfree(ep);
|
2007-08-08 15:48:02 +00:00
|
|
|
goto fail_not_linked;
|
|
|
|
}
|
|
|
|
retval = usb_hcd_link_urb_to_ep(hcd, urb);
|
|
|
|
if (retval) {
|
|
|
|
kfree(ep);
|
|
|
|
goto fail_not_linked;
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (hep->hcpriv) {
|
|
|
|
kfree(ep);
|
|
|
|
ep = hep->hcpriv;
|
|
|
|
} else if (!ep) {
|
|
|
|
retval = -ENOMEM;
|
|
|
|
goto fail;
|
|
|
|
|
|
|
|
} else {
|
|
|
|
INIT_LIST_HEAD(&ep->schedule);
|
2006-01-19 15:46:27 +00:00
|
|
|
ep->udev = udev;
|
2005-04-16 22:20:36 +00:00
|
|
|
ep->epnum = epnum;
|
|
|
|
ep->maxpacket = usb_maxpacket(udev, urb->pipe, is_out);
|
|
|
|
ep->defctrl = SL11H_HCTLMASK_ARM | SL11H_HCTLMASK_ENABLE;
|
|
|
|
usb_settoggle(udev, epnum, is_out, 0);
|
|
|
|
|
|
|
|
if (type == PIPE_CONTROL)
|
|
|
|
ep->nextpid = USB_PID_SETUP;
|
|
|
|
else if (is_out)
|
|
|
|
ep->nextpid = USB_PID_OUT;
|
|
|
|
else
|
|
|
|
ep->nextpid = USB_PID_IN;
|
|
|
|
|
|
|
|
if (ep->maxpacket > H_MAXPACKET) {
|
|
|
|
/* iso packets up to 240 bytes could work... */
|
2013-06-28 18:33:03 +00:00
|
|
|
dev_dbg(hcd->self.controller,
|
|
|
|
"dev %d ep%d maxpacket %d\n", udev->devnum,
|
|
|
|
epnum, ep->maxpacket);
|
2005-04-16 22:20:36 +00:00
|
|
|
retval = -EINVAL;
|
2011-01-23 22:08:31 +00:00
|
|
|
kfree(ep);
|
2005-04-16 22:20:36 +00:00
|
|
|
goto fail;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (udev->speed == USB_SPEED_LOW) {
|
|
|
|
/* send preamble for external hub? */
|
|
|
|
if (!(sl811->ctrl1 & SL11H_CTL1MASK_LSPD))
|
|
|
|
ep->defctrl |= SL11H_HCTLMASK_PREAMBLE;
|
|
|
|
}
|
|
|
|
switch (type) {
|
|
|
|
case PIPE_ISOCHRONOUS:
|
|
|
|
case PIPE_INTERRUPT:
|
|
|
|
if (urb->interval > PERIODIC_SIZE)
|
|
|
|
urb->interval = PERIODIC_SIZE;
|
|
|
|
ep->period = urb->interval;
|
|
|
|
ep->branch = PERIODIC_SIZE;
|
|
|
|
if (type == PIPE_ISOCHRONOUS)
|
|
|
|
ep->defctrl |= SL11H_HCTLMASK_ISOCH;
|
|
|
|
ep->load = usb_calc_bus_time(udev->speed, !is_out,
|
|
|
|
(type == PIPE_ISOCHRONOUS),
|
|
|
|
usb_maxpacket(udev, pipe, is_out))
|
|
|
|
/ 1000;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2005-05-26 12:55:55 +00:00
|
|
|
ep->hep = hep;
|
2005-04-16 22:20:36 +00:00
|
|
|
hep->hcpriv = ep;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* maybe put endpoint into schedule */
|
|
|
|
switch (type) {
|
|
|
|
case PIPE_CONTROL:
|
|
|
|
case PIPE_BULK:
|
|
|
|
if (list_empty(&ep->schedule))
|
|
|
|
list_add_tail(&ep->schedule, &sl811->async);
|
|
|
|
break;
|
|
|
|
case PIPE_ISOCHRONOUS:
|
|
|
|
case PIPE_INTERRUPT:
|
|
|
|
urb->interval = ep->period;
|
2005-09-22 07:49:07 +00:00
|
|
|
if (ep->branch < PERIODIC_SIZE) {
|
|
|
|
/* NOTE: the phase is correct here, but the value
|
|
|
|
* needs offsetting by the transfer queue depth.
|
|
|
|
* All current drivers ignore start_frame, so this
|
|
|
|
* is unlikely to ever matter...
|
|
|
|
*/
|
|
|
|
urb->start_frame = (sl811->frame & (PERIODIC_SIZE - 1))
|
|
|
|
+ ep->branch;
|
2005-04-16 22:20:36 +00:00
|
|
|
break;
|
2005-09-22 07:49:07 +00:00
|
|
|
}
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
retval = balance(sl811, ep->period, ep->load);
|
|
|
|
if (retval < 0)
|
|
|
|
goto fail;
|
|
|
|
ep->branch = retval;
|
|
|
|
retval = 0;
|
|
|
|
urb->start_frame = (sl811->frame & (PERIODIC_SIZE - 1))
|
|
|
|
+ ep->branch;
|
|
|
|
|
|
|
|
/* sort each schedule branch by period (slow before fast)
|
|
|
|
* to share the faster parts of the tree without needing
|
|
|
|
* dummy/placeholder nodes
|
|
|
|
*/
|
2013-06-28 18:33:03 +00:00
|
|
|
dev_dbg(hcd->self.controller, "schedule qh%d/%p branch %d\n",
|
|
|
|
ep->period, ep, ep->branch);
|
2005-04-16 22:20:36 +00:00
|
|
|
for (i = ep->branch; i < PERIODIC_SIZE; i += ep->period) {
|
|
|
|
struct sl811h_ep **prev = &sl811->periodic[i];
|
|
|
|
struct sl811h_ep *here = *prev;
|
|
|
|
|
|
|
|
while (here && ep != here) {
|
|
|
|
if (ep->period > here->period)
|
|
|
|
break;
|
|
|
|
prev = &here->next;
|
|
|
|
here = *prev;
|
|
|
|
}
|
|
|
|
if (ep != here) {
|
|
|
|
ep->next = here;
|
|
|
|
*prev = ep;
|
|
|
|
}
|
|
|
|
sl811->load[i] += ep->load;
|
|
|
|
}
|
|
|
|
sl811->periodic_count++;
|
|
|
|
hcd->self.bandwidth_allocated += ep->load / ep->period;
|
|
|
|
sofirq_on(sl811);
|
|
|
|
}
|
|
|
|
|
|
|
|
urb->hcpriv = hep;
|
|
|
|
start_transfer(sl811);
|
|
|
|
sl811_write(sl811, SL11H_IRQ_ENABLE, sl811->irq_enable);
|
|
|
|
fail:
|
2007-08-08 15:48:02 +00:00
|
|
|
if (retval)
|
|
|
|
usb_hcd_unlink_urb_from_ep(hcd, urb);
|
|
|
|
fail_not_linked:
|
2005-04-16 22:20:36 +00:00
|
|
|
spin_unlock_irqrestore(&sl811->lock, flags);
|
|
|
|
return retval;
|
|
|
|
}
|
|
|
|
|
2007-08-08 15:48:02 +00:00
|
|
|
static int sl811h_urb_dequeue(struct usb_hcd *hcd, struct urb *urb, int status)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
|
|
|
struct sl811 *sl811 = hcd_to_sl811(hcd);
|
2005-05-26 12:55:55 +00:00
|
|
|
struct usb_host_endpoint *hep;
|
2005-04-16 22:20:36 +00:00
|
|
|
unsigned long flags;
|
|
|
|
struct sl811h_ep *ep;
|
2007-08-08 15:48:02 +00:00
|
|
|
int retval;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2005-05-26 12:55:55 +00:00
|
|
|
spin_lock_irqsave(&sl811->lock, flags);
|
2007-08-08 15:48:02 +00:00
|
|
|
retval = usb_hcd_check_unlink_urb(hcd, urb, status);
|
|
|
|
if (retval)
|
2005-05-26 12:55:55 +00:00
|
|
|
goto fail;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2007-08-08 15:48:02 +00:00
|
|
|
hep = urb->hcpriv;
|
2005-04-16 22:20:36 +00:00
|
|
|
ep = hep->hcpriv;
|
|
|
|
if (ep) {
|
|
|
|
/* finish right away if this urb can't be active ...
|
|
|
|
* note that some drivers wrongly expect delays
|
|
|
|
*/
|
|
|
|
if (ep->hep->urb_list.next != &urb->urb_list) {
|
|
|
|
/* not front of queue? never active */
|
|
|
|
|
|
|
|
/* for active transfers, we expect an IRQ */
|
|
|
|
} else if (sl811->active_a == ep) {
|
|
|
|
if (time_before_eq(sl811->jiffies_a, jiffies)) {
|
|
|
|
/* happens a lot with lowspeed?? */
|
2013-06-28 18:33:03 +00:00
|
|
|
dev_dbg(hcd->self.controller,
|
|
|
|
"giveup on DONE_A: ctrl %02x sts %02x\n",
|
2005-04-16 22:20:36 +00:00
|
|
|
sl811_read(sl811,
|
|
|
|
SL811_EP_A(SL11H_HOSTCTLREG)),
|
|
|
|
sl811_read(sl811,
|
|
|
|
SL811_EP_A(SL11H_PKTSTATREG)));
|
|
|
|
sl811_write(sl811, SL811_EP_A(SL11H_HOSTCTLREG),
|
|
|
|
0);
|
|
|
|
sl811->active_a = NULL;
|
|
|
|
} else
|
|
|
|
urb = NULL;
|
|
|
|
#ifdef USE_B
|
|
|
|
} else if (sl811->active_b == ep) {
|
|
|
|
if (time_before_eq(sl811->jiffies_a, jiffies)) {
|
|
|
|
/* happens a lot with lowspeed?? */
|
2013-06-28 18:33:03 +00:00
|
|
|
dev_dbg(hcd->self.controller,
|
|
|
|
"giveup on DONE_B: ctrl %02x sts %02x\n",
|
2005-04-16 22:20:36 +00:00
|
|
|
sl811_read(sl811,
|
|
|
|
SL811_EP_B(SL11H_HOSTCTLREG)),
|
|
|
|
sl811_read(sl811,
|
|
|
|
SL811_EP_B(SL11H_PKTSTATREG)));
|
|
|
|
sl811_write(sl811, SL811_EP_B(SL11H_HOSTCTLREG),
|
|
|
|
0);
|
|
|
|
sl811->active_b = NULL;
|
|
|
|
} else
|
|
|
|
urb = NULL;
|
|
|
|
#endif
|
|
|
|
} else {
|
|
|
|
/* front of queue for inactive endpoint */
|
|
|
|
}
|
|
|
|
|
|
|
|
if (urb)
|
IRQ: Maintain regs pointer globally rather than passing to IRQ handlers
Maintain a per-CPU global "struct pt_regs *" variable which can be used instead
of passing regs around manually through all ~1800 interrupt handlers in the
Linux kernel.
The regs pointer is used in few places, but it potentially costs both stack
space and code to pass it around. On the FRV arch, removing the regs parameter
from all the genirq function results in a 20% speed up of the IRQ exit path
(ie: from leaving timer_interrupt() to leaving do_IRQ()).
Where appropriate, an arch may override the generic storage facility and do
something different with the variable. On FRV, for instance, the address is
maintained in GR28 at all times inside the kernel as part of general exception
handling.
Having looked over the code, it appears that the parameter may be handed down
through up to twenty or so layers of functions. Consider a USB character
device attached to a USB hub, attached to a USB controller that posts its
interrupts through a cascaded auxiliary interrupt controller. A character
device driver may want to pass regs to the sysrq handler through the input
layer which adds another few layers of parameter passing.
I've build this code with allyesconfig for x86_64 and i386. I've runtested the
main part of the code on FRV and i386, though I can't test most of the drivers.
I've also done partial conversion for powerpc and MIPS - these at least compile
with minimal configurations.
This will affect all archs. Mostly the changes should be relatively easy.
Take do_IRQ(), store the regs pointer at the beginning, saving the old one:
struct pt_regs *old_regs = set_irq_regs(regs);
And put the old one back at the end:
set_irq_regs(old_regs);
Don't pass regs through to generic_handle_irq() or __do_IRQ().
In timer_interrupt(), this sort of change will be necessary:
- update_process_times(user_mode(regs));
- profile_tick(CPU_PROFILING, regs);
+ update_process_times(user_mode(get_irq_regs()));
+ profile_tick(CPU_PROFILING);
I'd like to move update_process_times()'s use of get_irq_regs() into itself,
except that i386, alone of the archs, uses something other than user_mode().
Some notes on the interrupt handling in the drivers:
(*) input_dev() is now gone entirely. The regs pointer is no longer stored in
the input_dev struct.
(*) finish_unlinks() in drivers/usb/host/ohci-q.c needs checking. It does
something different depending on whether it's been supplied with a regs
pointer or not.
(*) Various IRQ handler function pointers have been moved to type
irq_handler_t.
Signed-Off-By: David Howells <dhowells@redhat.com>
(cherry picked from 1b16e7ac850969f38b375e511e3fa2f474a33867 commit)
2006-10-05 13:55:46 +00:00
|
|
|
finish_request(sl811, ep, urb, 0);
|
2005-04-16 22:20:36 +00:00
|
|
|
else
|
2013-06-28 18:33:03 +00:00
|
|
|
dev_dbg(sl811_to_hcd(sl811)->self.controller,
|
|
|
|
"dequeue, urb %p active %s; wait4irq\n", urb,
|
2005-04-16 22:20:36 +00:00
|
|
|
(sl811->active_a == ep) ? "A" : "B");
|
|
|
|
} else
|
|
|
|
retval = -EINVAL;
|
2007-08-08 15:48:02 +00:00
|
|
|
fail:
|
2005-04-16 22:20:36 +00:00
|
|
|
spin_unlock_irqrestore(&sl811->lock, flags);
|
|
|
|
return retval;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
sl811h_endpoint_disable(struct usb_hcd *hcd, struct usb_host_endpoint *hep)
|
|
|
|
{
|
|
|
|
struct sl811h_ep *ep = hep->hcpriv;
|
|
|
|
|
|
|
|
if (!ep)
|
|
|
|
return;
|
|
|
|
|
|
|
|
/* assume we'd just wait for the irq */
|
|
|
|
if (!list_empty(&hep->urb_list))
|
|
|
|
msleep(3);
|
|
|
|
if (!list_empty(&hep->urb_list))
|
2013-06-28 18:33:03 +00:00
|
|
|
dev_warn(hcd->self.controller, "ep %p not empty?\n", ep);
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
kfree(ep);
|
|
|
|
hep->hcpriv = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
sl811h_get_frame(struct usb_hcd *hcd)
|
|
|
|
{
|
|
|
|
struct sl811 *sl811 = hcd_to_sl811(hcd);
|
|
|
|
|
|
|
|
/* wrong except while periodic transfers are scheduled;
|
|
|
|
* never matches the on-the-wire frame;
|
|
|
|
* subject to overruns.
|
|
|
|
*/
|
|
|
|
return sl811->frame;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*-------------------------------------------------------------------------*/
|
|
|
|
|
|
|
|
/* the virtual root hub timer IRQ checks for hub status */
|
|
|
|
static int
|
|
|
|
sl811h_hub_status_data(struct usb_hcd *hcd, char *buf)
|
|
|
|
{
|
|
|
|
struct sl811 *sl811 = hcd_to_sl811(hcd);
|
|
|
|
#ifdef QUIRK3
|
|
|
|
unsigned long flags;
|
|
|
|
|
|
|
|
/* non-SMP HACK: use root hub timer as i/o watchdog
|
|
|
|
* this seems essential when SOF IRQs aren't in use...
|
|
|
|
*/
|
|
|
|
local_irq_save(flags);
|
|
|
|
if (!timer_pending(&sl811->timer)) {
|
IRQ: Maintain regs pointer globally rather than passing to IRQ handlers
Maintain a per-CPU global "struct pt_regs *" variable which can be used instead
of passing regs around manually through all ~1800 interrupt handlers in the
Linux kernel.
The regs pointer is used in few places, but it potentially costs both stack
space and code to pass it around. On the FRV arch, removing the regs parameter
from all the genirq function results in a 20% speed up of the IRQ exit path
(ie: from leaving timer_interrupt() to leaving do_IRQ()).
Where appropriate, an arch may override the generic storage facility and do
something different with the variable. On FRV, for instance, the address is
maintained in GR28 at all times inside the kernel as part of general exception
handling.
Having looked over the code, it appears that the parameter may be handed down
through up to twenty or so layers of functions. Consider a USB character
device attached to a USB hub, attached to a USB controller that posts its
interrupts through a cascaded auxiliary interrupt controller. A character
device driver may want to pass regs to the sysrq handler through the input
layer which adds another few layers of parameter passing.
I've build this code with allyesconfig for x86_64 and i386. I've runtested the
main part of the code on FRV and i386, though I can't test most of the drivers.
I've also done partial conversion for powerpc and MIPS - these at least compile
with minimal configurations.
This will affect all archs. Mostly the changes should be relatively easy.
Take do_IRQ(), store the regs pointer at the beginning, saving the old one:
struct pt_regs *old_regs = set_irq_regs(regs);
And put the old one back at the end:
set_irq_regs(old_regs);
Don't pass regs through to generic_handle_irq() or __do_IRQ().
In timer_interrupt(), this sort of change will be necessary:
- update_process_times(user_mode(regs));
- profile_tick(CPU_PROFILING, regs);
+ update_process_times(user_mode(get_irq_regs()));
+ profile_tick(CPU_PROFILING);
I'd like to move update_process_times()'s use of get_irq_regs() into itself,
except that i386, alone of the archs, uses something other than user_mode().
Some notes on the interrupt handling in the drivers:
(*) input_dev() is now gone entirely. The regs pointer is no longer stored in
the input_dev struct.
(*) finish_unlinks() in drivers/usb/host/ohci-q.c needs checking. It does
something different depending on whether it's been supplied with a regs
pointer or not.
(*) Various IRQ handler function pointers have been moved to type
irq_handler_t.
Signed-Off-By: David Howells <dhowells@redhat.com>
(cherry picked from 1b16e7ac850969f38b375e511e3fa2f474a33867 commit)
2006-10-05 13:55:46 +00:00
|
|
|
if (sl811h_irq( /* ~0, */ hcd) != IRQ_NONE)
|
2005-04-16 22:20:36 +00:00
|
|
|
sl811->stat_lost++;
|
|
|
|
}
|
|
|
|
local_irq_restore(flags);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
if (!(sl811->port1 & (0xffff << 16)))
|
|
|
|
return 0;
|
|
|
|
|
2014-09-19 15:32:23 +00:00
|
|
|
/* tell hub_wq port 1 changed */
|
2005-04-16 22:20:36 +00:00
|
|
|
*buf = (1 << 1);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
sl811h_hub_descriptor (
|
|
|
|
struct sl811 *sl811,
|
|
|
|
struct usb_hub_descriptor *desc
|
|
|
|
) {
|
|
|
|
u16 temp = 0;
|
|
|
|
|
|
|
|
desc->bDescriptorType = 0x29;
|
|
|
|
desc->bHubContrCurrent = 0;
|
|
|
|
|
|
|
|
desc->bNbrPorts = 1;
|
|
|
|
desc->bDescLength = 9;
|
|
|
|
|
|
|
|
/* per-port power switching (gang of one!), or none */
|
|
|
|
desc->bPwrOn2PwrGood = 0;
|
|
|
|
if (sl811->board && sl811->board->port_power) {
|
|
|
|
desc->bPwrOn2PwrGood = sl811->board->potpg;
|
|
|
|
if (!desc->bPwrOn2PwrGood)
|
|
|
|
desc->bPwrOn2PwrGood = 10;
|
|
|
|
temp = 0x0001;
|
|
|
|
} else
|
|
|
|
temp = 0x0002;
|
|
|
|
|
|
|
|
/* no overcurrent errors detection/handling */
|
|
|
|
temp |= 0x0010;
|
|
|
|
|
2008-04-28 06:00:16 +00:00
|
|
|
desc->wHubCharacteristics = cpu_to_le16(temp);
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2010-11-30 23:55:51 +00:00
|
|
|
/* ports removable, and legacy PortPwrCtrlMask */
|
2001-09-17 07:00:00 +00:00
|
|
|
desc->u.hs.DeviceRemovable[0] = 0 << 1;
|
|
|
|
desc->u.hs.DeviceRemovable[1] = ~0;
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
sl811h_timer(unsigned long _sl811)
|
|
|
|
{
|
|
|
|
struct sl811 *sl811 = (void *) _sl811;
|
|
|
|
unsigned long flags;
|
|
|
|
u8 irqstat;
|
|
|
|
u8 signaling = sl811->ctrl1 & SL11H_CTL1MASK_FORCE;
|
2010-03-04 22:05:08 +00:00
|
|
|
const u32 mask = USB_PORT_STAT_CONNECTION
|
|
|
|
| USB_PORT_STAT_ENABLE
|
2010-03-04 16:32:30 +00:00
|
|
|
| USB_PORT_STAT_LOW_SPEED;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
spin_lock_irqsave(&sl811->lock, flags);
|
|
|
|
|
|
|
|
/* stop special signaling */
|
|
|
|
sl811->ctrl1 &= ~SL11H_CTL1MASK_FORCE;
|
|
|
|
sl811_write(sl811, SL11H_CTLREG1, sl811->ctrl1);
|
|
|
|
udelay(3);
|
|
|
|
|
|
|
|
irqstat = sl811_read(sl811, SL11H_IRQ_STATUS);
|
|
|
|
|
|
|
|
switch (signaling) {
|
|
|
|
case SL11H_CTL1MASK_SE0:
|
2013-06-28 18:33:03 +00:00
|
|
|
dev_dbg(sl811_to_hcd(sl811)->self.controller, "end reset\n");
|
2010-03-04 22:05:08 +00:00
|
|
|
sl811->port1 = (USB_PORT_STAT_C_RESET << 16)
|
|
|
|
| USB_PORT_STAT_POWER;
|
2005-04-16 22:20:36 +00:00
|
|
|
sl811->ctrl1 = 0;
|
|
|
|
/* don't wrongly ack RD */
|
|
|
|
if (irqstat & SL11H_INTMASK_INSRMV)
|
|
|
|
irqstat &= ~SL11H_INTMASK_RD;
|
|
|
|
break;
|
|
|
|
case SL11H_CTL1MASK_K:
|
2013-06-28 18:33:03 +00:00
|
|
|
dev_dbg(sl811_to_hcd(sl811)->self.controller, "end resume\n");
|
2010-03-04 22:05:08 +00:00
|
|
|
sl811->port1 &= ~USB_PORT_STAT_SUSPEND;
|
2005-04-16 22:20:36 +00:00
|
|
|
break;
|
|
|
|
default:
|
2013-06-28 18:33:03 +00:00
|
|
|
dev_dbg(sl811_to_hcd(sl811)->self.controller,
|
|
|
|
"odd timer signaling: %02x\n", signaling);
|
2005-04-16 22:20:36 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
sl811_write(sl811, SL11H_IRQ_STATUS, irqstat);
|
|
|
|
|
|
|
|
if (irqstat & SL11H_INTMASK_RD) {
|
|
|
|
/* usbcore nukes all pending transactions on disconnect */
|
2010-03-04 22:05:08 +00:00
|
|
|
if (sl811->port1 & USB_PORT_STAT_CONNECTION)
|
|
|
|
sl811->port1 |= (USB_PORT_STAT_C_CONNECTION << 16)
|
|
|
|
| (USB_PORT_STAT_C_ENABLE << 16);
|
2005-04-16 22:20:36 +00:00
|
|
|
sl811->port1 &= ~mask;
|
|
|
|
sl811->irq_enable = SL11H_INTMASK_INSRMV;
|
|
|
|
} else {
|
|
|
|
sl811->port1 |= mask;
|
|
|
|
if (irqstat & SL11H_INTMASK_DP)
|
2010-03-04 16:32:30 +00:00
|
|
|
sl811->port1 &= ~USB_PORT_STAT_LOW_SPEED;
|
2005-04-16 22:20:36 +00:00
|
|
|
sl811->irq_enable = SL11H_INTMASK_INSRMV | SL11H_INTMASK_RD;
|
|
|
|
}
|
|
|
|
|
2010-03-04 22:05:08 +00:00
|
|
|
if (sl811->port1 & USB_PORT_STAT_CONNECTION) {
|
2005-04-16 22:20:36 +00:00
|
|
|
u8 ctrl2 = SL811HS_CTL2_INIT;
|
|
|
|
|
|
|
|
sl811->irq_enable |= SL11H_INTMASK_DONE_A;
|
|
|
|
#ifdef USE_B
|
|
|
|
sl811->irq_enable |= SL11H_INTMASK_DONE_B;
|
|
|
|
#endif
|
2010-03-04 16:32:30 +00:00
|
|
|
if (sl811->port1 & USB_PORT_STAT_LOW_SPEED) {
|
2005-04-16 22:20:36 +00:00
|
|
|
sl811->ctrl1 |= SL11H_CTL1MASK_LSPD;
|
|
|
|
ctrl2 |= SL811HS_CTL2MASK_DSWAP;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* start SOFs flowing, kickstarting with A registers */
|
|
|
|
sl811->ctrl1 |= SL11H_CTL1MASK_SOF_ENA;
|
|
|
|
sl811_write(sl811, SL11H_SOFLOWREG, 0xe0);
|
|
|
|
sl811_write(sl811, SL811HS_CTLREG2, ctrl2);
|
|
|
|
|
|
|
|
/* autoincrementing */
|
|
|
|
sl811_write(sl811, SL811_EP_A(SL11H_BUFLNTHREG), 0);
|
|
|
|
writeb(SL_SOF, sl811->data_reg);
|
|
|
|
writeb(0, sl811->data_reg);
|
|
|
|
sl811_write(sl811, SL811_EP_A(SL11H_HOSTCTLREG),
|
|
|
|
SL11H_HCTLMASK_ARM);
|
|
|
|
|
2014-09-19 15:32:23 +00:00
|
|
|
/* hub_wq provides debounce delay */
|
2005-04-16 22:20:36 +00:00
|
|
|
} else {
|
|
|
|
sl811->ctrl1 = 0;
|
|
|
|
}
|
|
|
|
sl811_write(sl811, SL11H_CTLREG1, sl811->ctrl1);
|
|
|
|
|
|
|
|
/* reenable irqs */
|
|
|
|
sl811_write(sl811, SL11H_IRQ_ENABLE, sl811->irq_enable);
|
|
|
|
spin_unlock_irqrestore(&sl811->lock, flags);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
sl811h_hub_control(
|
|
|
|
struct usb_hcd *hcd,
|
|
|
|
u16 typeReq,
|
|
|
|
u16 wValue,
|
|
|
|
u16 wIndex,
|
|
|
|
char *buf,
|
|
|
|
u16 wLength
|
|
|
|
) {
|
|
|
|
struct sl811 *sl811 = hcd_to_sl811(hcd);
|
|
|
|
int retval = 0;
|
|
|
|
unsigned long flags;
|
|
|
|
|
|
|
|
spin_lock_irqsave(&sl811->lock, flags);
|
|
|
|
|
|
|
|
switch (typeReq) {
|
|
|
|
case ClearHubFeature:
|
|
|
|
case SetHubFeature:
|
|
|
|
switch (wValue) {
|
|
|
|
case C_HUB_OVER_CURRENT:
|
|
|
|
case C_HUB_LOCAL_POWER:
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case ClearPortFeature:
|
|
|
|
if (wIndex != 1 || wLength != 0)
|
|
|
|
goto error;
|
|
|
|
|
|
|
|
switch (wValue) {
|
|
|
|
case USB_PORT_FEAT_ENABLE:
|
2010-03-04 22:05:08 +00:00
|
|
|
sl811->port1 &= USB_PORT_STAT_POWER;
|
2005-04-16 22:20:36 +00:00
|
|
|
sl811->ctrl1 = 0;
|
|
|
|
sl811_write(sl811, SL11H_CTLREG1, sl811->ctrl1);
|
|
|
|
sl811->irq_enable = SL11H_INTMASK_INSRMV;
|
|
|
|
sl811_write(sl811, SL11H_IRQ_ENABLE,
|
|
|
|
sl811->irq_enable);
|
|
|
|
break;
|
|
|
|
case USB_PORT_FEAT_SUSPEND:
|
2010-03-04 22:05:08 +00:00
|
|
|
if (!(sl811->port1 & USB_PORT_STAT_SUSPEND))
|
2005-04-16 22:20:36 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
/* 20 msec of resume/K signaling, other irqs blocked */
|
2013-06-28 18:33:03 +00:00
|
|
|
dev_dbg(hcd->self.controller, "start resume...\n");
|
2005-04-16 22:20:36 +00:00
|
|
|
sl811->irq_enable = 0;
|
|
|
|
sl811_write(sl811, SL11H_IRQ_ENABLE,
|
|
|
|
sl811->irq_enable);
|
|
|
|
sl811->ctrl1 |= SL11H_CTL1MASK_K;
|
|
|
|
sl811_write(sl811, SL11H_CTLREG1, sl811->ctrl1);
|
|
|
|
|
|
|
|
mod_timer(&sl811->timer, jiffies
|
|
|
|
+ msecs_to_jiffies(20));
|
|
|
|
break;
|
|
|
|
case USB_PORT_FEAT_POWER:
|
|
|
|
port_power(sl811, 0);
|
|
|
|
break;
|
|
|
|
case USB_PORT_FEAT_C_ENABLE:
|
|
|
|
case USB_PORT_FEAT_C_SUSPEND:
|
|
|
|
case USB_PORT_FEAT_C_CONNECTION:
|
|
|
|
case USB_PORT_FEAT_C_OVER_CURRENT:
|
|
|
|
case USB_PORT_FEAT_C_RESET:
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
sl811->port1 &= ~(1 << wValue);
|
|
|
|
break;
|
|
|
|
case GetHubDescriptor:
|
|
|
|
sl811h_hub_descriptor(sl811, (struct usb_hub_descriptor *) buf);
|
|
|
|
break;
|
|
|
|
case GetHubStatus:
|
2009-12-21 17:53:24 +00:00
|
|
|
put_unaligned_le32(0, buf);
|
2005-04-16 22:20:36 +00:00
|
|
|
break;
|
|
|
|
case GetPortStatus:
|
|
|
|
if (wIndex != 1)
|
|
|
|
goto error;
|
2009-12-21 17:53:24 +00:00
|
|
|
put_unaligned_le32(sl811->port1, buf);
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
#ifndef VERBOSE
|
|
|
|
if (*(u16*)(buf+2)) /* only if wPortChange is interesting */
|
|
|
|
#endif
|
2013-06-28 18:33:03 +00:00
|
|
|
dev_dbg(hcd->self.controller, "GetPortStatus %08x\n",
|
|
|
|
sl811->port1);
|
2005-04-16 22:20:36 +00:00
|
|
|
break;
|
|
|
|
case SetPortFeature:
|
|
|
|
if (wIndex != 1 || wLength != 0)
|
|
|
|
goto error;
|
|
|
|
switch (wValue) {
|
|
|
|
case USB_PORT_FEAT_SUSPEND:
|
2010-03-04 22:05:08 +00:00
|
|
|
if (sl811->port1 & USB_PORT_STAT_RESET)
|
2005-04-16 22:20:36 +00:00
|
|
|
goto error;
|
2010-03-04 22:05:08 +00:00
|
|
|
if (!(sl811->port1 & USB_PORT_STAT_ENABLE))
|
2005-04-16 22:20:36 +00:00
|
|
|
goto error;
|
|
|
|
|
2013-06-28 18:33:03 +00:00
|
|
|
dev_dbg(hcd->self.controller,"suspend...\n");
|
2005-04-16 22:20:36 +00:00
|
|
|
sl811->ctrl1 &= ~SL11H_CTL1MASK_SOF_ENA;
|
|
|
|
sl811_write(sl811, SL11H_CTLREG1, sl811->ctrl1);
|
|
|
|
break;
|
|
|
|
case USB_PORT_FEAT_POWER:
|
|
|
|
port_power(sl811, 1);
|
|
|
|
break;
|
|
|
|
case USB_PORT_FEAT_RESET:
|
2010-03-04 22:05:08 +00:00
|
|
|
if (sl811->port1 & USB_PORT_STAT_SUSPEND)
|
2005-04-16 22:20:36 +00:00
|
|
|
goto error;
|
2010-03-04 22:05:08 +00:00
|
|
|
if (!(sl811->port1 & USB_PORT_STAT_POWER))
|
2005-04-16 22:20:36 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
/* 50 msec of reset/SE0 signaling, irqs blocked */
|
|
|
|
sl811->irq_enable = 0;
|
|
|
|
sl811_write(sl811, SL11H_IRQ_ENABLE,
|
|
|
|
sl811->irq_enable);
|
|
|
|
sl811->ctrl1 = SL11H_CTL1MASK_SE0;
|
|
|
|
sl811_write(sl811, SL11H_CTLREG1, sl811->ctrl1);
|
2010-03-04 22:05:08 +00:00
|
|
|
sl811->port1 |= USB_PORT_STAT_RESET;
|
2005-04-16 22:20:36 +00:00
|
|
|
mod_timer(&sl811->timer, jiffies
|
|
|
|
+ msecs_to_jiffies(50));
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
sl811->port1 |= 1 << wValue;
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
error:
|
|
|
|
/* "protocol stall" on error */
|
|
|
|
retval = -EPIPE;
|
|
|
|
}
|
|
|
|
|
|
|
|
spin_unlock_irqrestore(&sl811->lock, flags);
|
|
|
|
return retval;
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef CONFIG_PM
|
|
|
|
|
|
|
|
static int
|
2005-10-13 21:08:02 +00:00
|
|
|
sl811h_bus_suspend(struct usb_hcd *hcd)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
|
|
|
// SOFs off
|
2013-06-28 18:33:03 +00:00
|
|
|
dev_dbg(hcd->self.controller, "%s\n", __func__);
|
2005-04-16 22:20:36 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2005-10-13 21:08:02 +00:00
|
|
|
sl811h_bus_resume(struct usb_hcd *hcd)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
|
|
|
// SOFs on
|
2013-06-28 18:33:03 +00:00
|
|
|
dev_dbg(hcd->self.controller, "%s\n", __func__);
|
2005-04-16 22:20:36 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
#else
|
|
|
|
|
2005-10-13 21:08:02 +00:00
|
|
|
#define sl811h_bus_suspend NULL
|
|
|
|
#define sl811h_bus_resume NULL
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
/*-------------------------------------------------------------------------*/
|
|
|
|
|
|
|
|
static void dump_irq(struct seq_file *s, char *label, u8 mask)
|
|
|
|
{
|
|
|
|
seq_printf(s, "%s %02x%s%s%s%s%s%s\n", label, mask,
|
|
|
|
(mask & SL11H_INTMASK_DONE_A) ? " done_a" : "",
|
|
|
|
(mask & SL11H_INTMASK_DONE_B) ? " done_b" : "",
|
|
|
|
(mask & SL11H_INTMASK_SOFINTR) ? " sof" : "",
|
|
|
|
(mask & SL11H_INTMASK_INSRMV) ? " ins/rmv" : "",
|
|
|
|
(mask & SL11H_INTMASK_RD) ? " rd" : "",
|
|
|
|
(mask & SL11H_INTMASK_DP) ? " dp" : "");
|
|
|
|
}
|
|
|
|
|
2013-07-02 19:22:06 +00:00
|
|
|
static int sl811h_show(struct seq_file *s, void *unused)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
|
|
|
struct sl811 *sl811 = s->private;
|
|
|
|
struct sl811h_ep *ep;
|
|
|
|
unsigned i;
|
|
|
|
|
|
|
|
seq_printf(s, "%s\n%s version %s\nportstatus[1] = %08x\n",
|
|
|
|
sl811_to_hcd(sl811)->product_desc,
|
|
|
|
hcd_name, DRIVER_VERSION,
|
|
|
|
sl811->port1);
|
|
|
|
|
|
|
|
seq_printf(s, "insert/remove: %ld\n", sl811->stat_insrmv);
|
|
|
|
seq_printf(s, "current session: done_a %ld done_b %ld "
|
|
|
|
"wake %ld sof %ld overrun %ld lost %ld\n\n",
|
|
|
|
sl811->stat_a, sl811->stat_b,
|
|
|
|
sl811->stat_wake, sl811->stat_sof,
|
|
|
|
sl811->stat_overrun, sl811->stat_lost);
|
|
|
|
|
|
|
|
spin_lock_irq(&sl811->lock);
|
|
|
|
|
|
|
|
if (sl811->ctrl1 & SL11H_CTL1MASK_SUSPEND)
|
|
|
|
seq_printf(s, "(suspended)\n\n");
|
|
|
|
else {
|
|
|
|
u8 t = sl811_read(sl811, SL11H_CTLREG1);
|
|
|
|
|
|
|
|
seq_printf(s, "ctrl1 %02x%s%s%s%s\n", t,
|
|
|
|
(t & SL11H_CTL1MASK_SOF_ENA) ? " sofgen" : "",
|
|
|
|
({char *s; switch (t & SL11H_CTL1MASK_FORCE) {
|
|
|
|
case SL11H_CTL1MASK_NORMAL: s = ""; break;
|
|
|
|
case SL11H_CTL1MASK_SE0: s = " se0/reset"; break;
|
|
|
|
case SL11H_CTL1MASK_K: s = " k/resume"; break;
|
|
|
|
default: s = "j"; break;
|
2013-10-08 23:01:37 +00:00
|
|
|
} s; }),
|
2005-04-16 22:20:36 +00:00
|
|
|
(t & SL11H_CTL1MASK_LSPD) ? " lowspeed" : "",
|
|
|
|
(t & SL11H_CTL1MASK_SUSPEND) ? " suspend" : "");
|
|
|
|
|
|
|
|
dump_irq(s, "irq_enable",
|
|
|
|
sl811_read(sl811, SL11H_IRQ_ENABLE));
|
|
|
|
dump_irq(s, "irq_status",
|
|
|
|
sl811_read(sl811, SL11H_IRQ_STATUS));
|
|
|
|
seq_printf(s, "frame clocks remaining: %d\n",
|
|
|
|
sl811_read(sl811, SL11H_SOFTMRREG) << 6);
|
|
|
|
}
|
|
|
|
|
|
|
|
seq_printf(s, "A: qh%p ctl %02x sts %02x\n", sl811->active_a,
|
|
|
|
sl811_read(sl811, SL811_EP_A(SL11H_HOSTCTLREG)),
|
|
|
|
sl811_read(sl811, SL811_EP_A(SL11H_PKTSTATREG)));
|
|
|
|
seq_printf(s, "B: qh%p ctl %02x sts %02x\n", sl811->active_b,
|
|
|
|
sl811_read(sl811, SL811_EP_B(SL11H_HOSTCTLREG)),
|
|
|
|
sl811_read(sl811, SL811_EP_B(SL11H_PKTSTATREG)));
|
|
|
|
seq_printf(s, "\n");
|
|
|
|
list_for_each_entry (ep, &sl811->async, schedule) {
|
|
|
|
struct urb *urb;
|
|
|
|
|
|
|
|
seq_printf(s, "%s%sqh%p, ep%d%s, maxpacket %d"
|
|
|
|
" nak %d err %d\n",
|
|
|
|
(ep == sl811->active_a) ? "(A) " : "",
|
|
|
|
(ep == sl811->active_b) ? "(B) " : "",
|
|
|
|
ep, ep->epnum,
|
|
|
|
({ char *s; switch (ep->nextpid) {
|
|
|
|
case USB_PID_IN: s = "in"; break;
|
|
|
|
case USB_PID_OUT: s = "out"; break;
|
|
|
|
case USB_PID_SETUP: s = "setup"; break;
|
|
|
|
case USB_PID_ACK: s = "status"; break;
|
|
|
|
default: s = "?"; break;
|
2013-10-08 23:01:37 +00:00
|
|
|
} s;}),
|
2005-04-16 22:20:36 +00:00
|
|
|
ep->maxpacket,
|
|
|
|
ep->nak_count, ep->error_count);
|
|
|
|
list_for_each_entry (urb, &ep->hep->urb_list, urb_list) {
|
|
|
|
seq_printf(s, " urb%p, %d/%d\n", urb,
|
|
|
|
urb->actual_length,
|
|
|
|
urb->transfer_buffer_length);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!list_empty(&sl811->async))
|
|
|
|
seq_printf(s, "\n");
|
|
|
|
|
|
|
|
seq_printf(s, "periodic size= %d\n", PERIODIC_SIZE);
|
|
|
|
|
|
|
|
for (i = 0; i < PERIODIC_SIZE; i++) {
|
|
|
|
ep = sl811->periodic[i];
|
|
|
|
if (!ep)
|
|
|
|
continue;
|
|
|
|
seq_printf(s, "%2d [%3d]:\n", i, sl811->load[i]);
|
|
|
|
|
|
|
|
/* DUMB: prints shared entries multiple times */
|
|
|
|
do {
|
|
|
|
seq_printf(s,
|
|
|
|
" %s%sqh%d/%p (%sdev%d ep%d%s max %d) "
|
|
|
|
"err %d\n",
|
|
|
|
(ep == sl811->active_a) ? "(A) " : "",
|
|
|
|
(ep == sl811->active_b) ? "(B) " : "",
|
|
|
|
ep->period, ep,
|
|
|
|
(ep->udev->speed == USB_SPEED_FULL)
|
|
|
|
? "" : "ls ",
|
|
|
|
ep->udev->devnum, ep->epnum,
|
|
|
|
(ep->epnum == 0) ? ""
|
|
|
|
: ((ep->nextpid == USB_PID_IN)
|
|
|
|
? "in"
|
|
|
|
: "out"),
|
|
|
|
ep->maxpacket, ep->error_count);
|
|
|
|
ep = ep->next;
|
|
|
|
} while (ep);
|
|
|
|
}
|
|
|
|
|
|
|
|
spin_unlock_irq(&sl811->lock);
|
|
|
|
seq_printf(s, "\n");
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2013-07-02 19:22:06 +00:00
|
|
|
static int sl811h_open(struct inode *inode, struct file *file)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
2013-07-02 19:22:06 +00:00
|
|
|
return single_open(file, sl811h_show, inode->i_private);
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
2013-07-02 19:22:06 +00:00
|
|
|
static const struct file_operations debug_ops = {
|
|
|
|
.open = sl811h_open,
|
2005-04-16 22:20:36 +00:00
|
|
|
.read = seq_read,
|
|
|
|
.llseek = seq_lseek,
|
|
|
|
.release = single_release,
|
|
|
|
};
|
|
|
|
|
|
|
|
/* expect just one sl811 per system */
|
|
|
|
static void create_debug_file(struct sl811 *sl811)
|
|
|
|
{
|
2013-07-02 19:22:06 +00:00
|
|
|
sl811->debug_file = debugfs_create_file("sl811h", S_IRUGO,
|
|
|
|
usb_debug_root, sl811,
|
|
|
|
&debug_ops);
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void remove_debug_file(struct sl811 *sl811)
|
|
|
|
{
|
2013-07-02 19:22:06 +00:00
|
|
|
debugfs_remove(sl811->debug_file);
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*-------------------------------------------------------------------------*/
|
|
|
|
|
|
|
|
static void
|
|
|
|
sl811h_stop(struct usb_hcd *hcd)
|
|
|
|
{
|
|
|
|
struct sl811 *sl811 = hcd_to_sl811(hcd);
|
|
|
|
unsigned long flags;
|
|
|
|
|
|
|
|
del_timer_sync(&hcd->rh_timer);
|
|
|
|
|
|
|
|
spin_lock_irqsave(&sl811->lock, flags);
|
|
|
|
port_power(sl811, 0);
|
|
|
|
spin_unlock_irqrestore(&sl811->lock, flags);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
sl811h_start(struct usb_hcd *hcd)
|
|
|
|
{
|
|
|
|
struct sl811 *sl811 = hcd_to_sl811(hcd);
|
|
|
|
|
|
|
|
/* chip has been reset, VBUS power is off */
|
|
|
|
hcd->state = HC_STATE_RUNNING;
|
|
|
|
|
2005-04-25 15:21:31 +00:00
|
|
|
if (sl811->board) {
|
2005-11-07 23:31:25 +00:00
|
|
|
if (!device_can_wakeup(hcd->self.controller))
|
|
|
|
device_init_wakeup(hcd->self.controller,
|
|
|
|
sl811->board->can_wakeup);
|
2005-04-25 15:21:31 +00:00
|
|
|
hcd->power_budget = sl811->board->power * 2;
|
|
|
|
}
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2007-10-19 21:10:43 +00:00
|
|
|
/* enable power and interrupts */
|
2005-05-26 12:55:55 +00:00
|
|
|
port_power(sl811, 1);
|
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*-------------------------------------------------------------------------*/
|
|
|
|
|
|
|
|
static struct hc_driver sl811h_hc_driver = {
|
|
|
|
.description = hcd_name,
|
|
|
|
.hcd_priv_size = sizeof(struct sl811),
|
|
|
|
|
|
|
|
/*
|
|
|
|
* generic hardware linkage
|
|
|
|
*/
|
|
|
|
.irq = sl811h_irq,
|
|
|
|
.flags = HCD_USB11 | HCD_MEMORY,
|
|
|
|
|
|
|
|
/* Basic lifecycle operations */
|
|
|
|
.start = sl811h_start,
|
|
|
|
.stop = sl811h_stop,
|
|
|
|
|
|
|
|
/*
|
|
|
|
* managing i/o requests and associated device resources
|
|
|
|
*/
|
|
|
|
.urb_enqueue = sl811h_urb_enqueue,
|
|
|
|
.urb_dequeue = sl811h_urb_dequeue,
|
|
|
|
.endpoint_disable = sl811h_endpoint_disable,
|
|
|
|
|
|
|
|
/*
|
|
|
|
* periodic schedule support
|
|
|
|
*/
|
|
|
|
.get_frame_number = sl811h_get_frame,
|
|
|
|
|
|
|
|
/*
|
|
|
|
* root hub support
|
|
|
|
*/
|
|
|
|
.hub_status_data = sl811h_hub_status_data,
|
|
|
|
.hub_control = sl811h_hub_control,
|
2005-10-13 21:08:02 +00:00
|
|
|
.bus_suspend = sl811h_bus_suspend,
|
|
|
|
.bus_resume = sl811h_bus_resume,
|
2005-04-16 22:20:36 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/*-------------------------------------------------------------------------*/
|
|
|
|
|
2012-11-19 18:26:20 +00:00
|
|
|
static int
|
2005-11-09 22:32:44 +00:00
|
|
|
sl811h_remove(struct platform_device *dev)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
2005-11-09 22:32:44 +00:00
|
|
|
struct usb_hcd *hcd = platform_get_drvdata(dev);
|
2005-04-16 22:20:36 +00:00
|
|
|
struct sl811 *sl811 = hcd_to_sl811(hcd);
|
|
|
|
struct resource *res;
|
|
|
|
|
|
|
|
remove_debug_file(sl811);
|
|
|
|
usb_remove_hcd(hcd);
|
|
|
|
|
2005-05-26 12:55:55 +00:00
|
|
|
/* some platforms may use IORESOURCE_IO */
|
2005-11-09 22:32:44 +00:00
|
|
|
res = platform_get_resource(dev, IORESOURCE_MEM, 1);
|
2005-05-26 12:55:55 +00:00
|
|
|
if (res)
|
|
|
|
iounmap(sl811->data_reg);
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2005-11-09 22:32:44 +00:00
|
|
|
res = platform_get_resource(dev, IORESOURCE_MEM, 0);
|
2005-05-26 12:55:55 +00:00
|
|
|
if (res)
|
|
|
|
iounmap(sl811->addr_reg);
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
usb_put_hcd(hcd);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2012-11-19 18:21:48 +00:00
|
|
|
static int
|
2005-11-09 22:32:44 +00:00
|
|
|
sl811h_probe(struct platform_device *dev)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
|
|
|
struct usb_hcd *hcd;
|
|
|
|
struct sl811 *sl811;
|
2008-08-18 11:08:42 +00:00
|
|
|
struct resource *addr, *data, *ires;
|
2005-04-16 22:20:36 +00:00
|
|
|
int irq;
|
|
|
|
void __iomem *addr_reg;
|
|
|
|
void __iomem *data_reg;
|
|
|
|
int retval;
|
2005-05-26 12:55:55 +00:00
|
|
|
u8 tmp, ioaddr = 0;
|
2008-08-18 11:08:42 +00:00
|
|
|
unsigned long irqflags;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2012-02-28 11:57:23 +00:00
|
|
|
if (usb_disabled())
|
|
|
|
return -ENODEV;
|
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
/* basic sanity checks first. board-specific init logic should
|
|
|
|
* have initialized these three resources and probably board
|
|
|
|
* specific platform_data. we don't probe for IRQs, and do only
|
|
|
|
* minimal sanity checking.
|
|
|
|
*/
|
2008-08-18 11:08:42 +00:00
|
|
|
ires = platform_get_resource(dev, IORESOURCE_IRQ, 0);
|
|
|
|
if (dev->num_resources < 3 || !ires)
|
2005-04-16 22:20:36 +00:00
|
|
|
return -ENODEV;
|
|
|
|
|
2008-08-18 11:08:42 +00:00
|
|
|
irq = ires->start;
|
|
|
|
irqflags = ires->flags & IRQF_TRIGGER_MASK;
|
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
/* refuse to confuse usbcore */
|
2005-11-09 22:32:44 +00:00
|
|
|
if (dev->dev.dma_mask) {
|
2013-06-28 18:33:03 +00:00
|
|
|
dev_dbg(&dev->dev, "no we won't dma\n");
|
2005-04-16 22:20:36 +00:00
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
2005-05-26 12:55:55 +00:00
|
|
|
/* the chip may be wired for either kind of addressing */
|
2005-11-09 22:32:44 +00:00
|
|
|
addr = platform_get_resource(dev, IORESOURCE_MEM, 0);
|
|
|
|
data = platform_get_resource(dev, IORESOURCE_MEM, 1);
|
2005-05-26 12:55:55 +00:00
|
|
|
retval = -EBUSY;
|
|
|
|
if (!addr || !data) {
|
2005-11-09 22:32:44 +00:00
|
|
|
addr = platform_get_resource(dev, IORESOURCE_IO, 0);
|
|
|
|
data = platform_get_resource(dev, IORESOURCE_IO, 1);
|
2005-05-26 12:55:55 +00:00
|
|
|
if (!addr || !data)
|
|
|
|
return -ENODEV;
|
|
|
|
ioaddr = 1;
|
2006-06-13 00:07:52 +00:00
|
|
|
/*
|
|
|
|
* NOTE: 64-bit resource->start is getting truncated
|
|
|
|
* to avoid compiler warning, assuming that ->start
|
|
|
|
* is always 32-bit for this case
|
|
|
|
*/
|
|
|
|
addr_reg = (void __iomem *) (unsigned long) addr->start;
|
|
|
|
data_reg = (void __iomem *) (unsigned long) data->start;
|
2005-05-26 12:55:55 +00:00
|
|
|
} else {
|
|
|
|
addr_reg = ioremap(addr->start, 1);
|
|
|
|
if (addr_reg == NULL) {
|
|
|
|
retval = -ENOMEM;
|
|
|
|
goto err2;
|
|
|
|
}
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2005-05-26 12:55:55 +00:00
|
|
|
data_reg = ioremap(data->start, 1);
|
|
|
|
if (data_reg == NULL) {
|
|
|
|
retval = -ENOMEM;
|
|
|
|
goto err4;
|
|
|
|
}
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* allocate and initialize hcd */
|
2008-05-02 04:02:41 +00:00
|
|
|
hcd = usb_create_hcd(&sl811h_hc_driver, &dev->dev, dev_name(&dev->dev));
|
2005-04-16 22:20:36 +00:00
|
|
|
if (!hcd) {
|
|
|
|
retval = -ENOMEM;
|
|
|
|
goto err5;
|
|
|
|
}
|
|
|
|
hcd->rsrc_start = addr->start;
|
|
|
|
sl811 = hcd_to_sl811(hcd);
|
|
|
|
|
|
|
|
spin_lock_init(&sl811->lock);
|
|
|
|
INIT_LIST_HEAD(&sl811->async);
|
2013-07-30 10:59:40 +00:00
|
|
|
sl811->board = dev_get_platdata(&dev->dev);
|
2014-12-26 14:35:52 +00:00
|
|
|
setup_timer(&sl811->timer, sl811h_timer, (unsigned long)sl811);
|
2005-04-16 22:20:36 +00:00
|
|
|
sl811->addr_reg = addr_reg;
|
|
|
|
sl811->data_reg = data_reg;
|
|
|
|
|
|
|
|
spin_lock_irq(&sl811->lock);
|
|
|
|
port_power(sl811, 0);
|
|
|
|
spin_unlock_irq(&sl811->lock);
|
|
|
|
msleep(200);
|
|
|
|
|
|
|
|
tmp = sl811_read(sl811, SL11H_HWREVREG);
|
|
|
|
switch (tmp >> 4) {
|
|
|
|
case 1:
|
|
|
|
hcd->product_desc = "SL811HS v1.2";
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
hcd->product_desc = "SL811HS v1.5";
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
/* reject case 0, SL11S is less functional */
|
2013-06-28 18:33:03 +00:00
|
|
|
dev_dbg(&dev->dev, "chiprev %02x\n", tmp);
|
2005-04-16 22:20:36 +00:00
|
|
|
retval = -ENXIO;
|
|
|
|
goto err6;
|
|
|
|
}
|
|
|
|
|
2005-05-26 12:55:55 +00:00
|
|
|
/* The chip's IRQ is level triggered, active high. A requirement
|
|
|
|
* for platform device setup is to cope with things like signal
|
|
|
|
* inverters (e.g. CF is active low) or working only with edge
|
|
|
|
* triggers (e.g. most ARM CPUs). Initial driver stress testing
|
|
|
|
* was on a system with single edge triggering, so most sorts of
|
|
|
|
* triggering arrangement should work.
|
2008-08-18 11:08:42 +00:00
|
|
|
*
|
|
|
|
* Use resource IRQ flags if set by platform device setup.
|
2005-05-26 12:55:55 +00:00
|
|
|
*/
|
2008-08-18 11:08:42 +00:00
|
|
|
irqflags |= IRQF_SHARED;
|
2011-09-07 08:10:52 +00:00
|
|
|
retval = usb_add_hcd(hcd, irq, irqflags);
|
2005-04-16 22:20:36 +00:00
|
|
|
if (retval != 0)
|
|
|
|
goto err6;
|
|
|
|
|
2013-11-05 02:46:02 +00:00
|
|
|
device_wakeup_enable(hcd->self.controller);
|
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
create_debug_file(sl811);
|
|
|
|
return retval;
|
|
|
|
|
|
|
|
err6:
|
|
|
|
usb_put_hcd(hcd);
|
|
|
|
err5:
|
2005-05-26 12:55:55 +00:00
|
|
|
if (!ioaddr)
|
|
|
|
iounmap(data_reg);
|
2005-04-16 22:20:36 +00:00
|
|
|
err4:
|
2005-05-26 12:55:55 +00:00
|
|
|
if (!ioaddr)
|
|
|
|
iounmap(addr_reg);
|
2005-04-16 22:20:36 +00:00
|
|
|
err2:
|
2013-06-28 18:33:03 +00:00
|
|
|
dev_dbg(&dev->dev, "init error, %d\n", retval);
|
2005-04-16 22:20:36 +00:00
|
|
|
return retval;
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef CONFIG_PM
|
|
|
|
|
|
|
|
/* for this device there's no useful distinction between the controller
|
2014-11-29 22:47:05 +00:00
|
|
|
* and its root hub.
|
2005-04-16 22:20:36 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
static int
|
2005-11-09 22:32:44 +00:00
|
|
|
sl811h_suspend(struct platform_device *dev, pm_message_t state)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
2005-11-09 22:32:44 +00:00
|
|
|
struct usb_hcd *hcd = platform_get_drvdata(dev);
|
2005-04-16 22:20:36 +00:00
|
|
|
struct sl811 *sl811 = hcd_to_sl811(hcd);
|
|
|
|
int retval = 0;
|
|
|
|
|
2006-08-15 06:11:06 +00:00
|
|
|
switch (state.event) {
|
|
|
|
case PM_EVENT_FREEZE:
|
2005-10-13 21:08:02 +00:00
|
|
|
retval = sl811h_bus_suspend(hcd);
|
2006-08-15 06:11:06 +00:00
|
|
|
break;
|
|
|
|
case PM_EVENT_SUSPEND:
|
2008-02-23 18:13:25 +00:00
|
|
|
case PM_EVENT_HIBERNATE:
|
2006-08-15 06:11:06 +00:00
|
|
|
case PM_EVENT_PRETHAW: /* explicitly discard hw state */
|
2005-04-16 22:20:36 +00:00
|
|
|
port_power(sl811, 0);
|
2006-08-15 06:11:06 +00:00
|
|
|
break;
|
|
|
|
}
|
2005-04-16 22:20:36 +00:00
|
|
|
return retval;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2005-11-09 22:32:44 +00:00
|
|
|
sl811h_resume(struct platform_device *dev)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
2005-11-09 22:32:44 +00:00
|
|
|
struct usb_hcd *hcd = platform_get_drvdata(dev);
|
2005-04-16 22:20:36 +00:00
|
|
|
struct sl811 *sl811 = hcd_to_sl811(hcd);
|
|
|
|
|
|
|
|
/* with no "check to see if VBUS is still powered" board hook,
|
|
|
|
* let's assume it'd only be powered to enable remote wakeup.
|
|
|
|
*/
|
2008-03-06 22:00:58 +00:00
|
|
|
if (!sl811->port1 || !device_can_wakeup(&hcd->self.root_hub->dev)) {
|
2005-04-16 22:20:36 +00:00
|
|
|
sl811->port1 = 0;
|
|
|
|
port_power(sl811, 1);
|
2005-11-14 16:45:38 +00:00
|
|
|
usb_root_hub_lost_power(hcd->self.root_hub);
|
2005-04-16 22:20:36 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2005-10-13 21:08:02 +00:00
|
|
|
return sl811h_bus_resume(hcd);
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#else
|
|
|
|
|
|
|
|
#define sl811h_suspend NULL
|
|
|
|
#define sl811h_resume NULL
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
2005-05-26 12:55:55 +00:00
|
|
|
/* this driver is exported so sl811_cs can depend on it */
|
2005-11-09 22:32:44 +00:00
|
|
|
struct platform_driver sl811h_driver = {
|
2005-04-16 22:20:36 +00:00
|
|
|
.probe = sl811h_probe,
|
2012-11-19 18:21:08 +00:00
|
|
|
.remove = sl811h_remove,
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
.suspend = sl811h_suspend,
|
|
|
|
.resume = sl811h_resume,
|
2005-11-09 22:32:44 +00:00
|
|
|
.driver = {
|
|
|
|
.name = (char *) hcd_name,
|
|
|
|
.owner = THIS_MODULE,
|
|
|
|
},
|
2005-04-16 22:20:36 +00:00
|
|
|
};
|
2005-05-26 12:55:55 +00:00
|
|
|
EXPORT_SYMBOL(sl811h_driver);
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2012-02-28 11:57:23 +00:00
|
|
|
module_platform_driver(sl811h_driver);
|