|
From: Steve L. <slo...@us...> - 2002-06-13 18:42:30
|
Update of /cvsroot/linux-mips/linux/arch/mips/au1000/common
In directory usw-pr-cvs1:/tmp/cvs-serv31034
Modified Files:
usbdev.c
Log Message:
Allow the device state to remain in the CONFIGURED state when a set
address request is received but the requested address hasn't changed.
Index: usbdev.c
===================================================================
RCS file: /cvsroot/linux-mips/linux/arch/mips/au1000/common/usbdev.c,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -d -r1.11 -r1.12
--- usbdev.c 29 May 2002 00:23:16 -0000 1.11
+++ usbdev.c 13 Jun 2002 18:42:22 -0000 1.12
@@ -449,10 +449,10 @@
dma_cache_wback_inv((unsigned long)pkt->payload, pkt->size);
/*
- * The write fifo should already be drained if things are
- * working right, but flush it anyway just in case.
+ * make sure FIFO is empty
*/
flush_write_fifo(ep);
+
cs = au_readl(ep->reg->ctrl_stat) & USBDEV_CS_STALL;
cs |= (pkt->size << USBDEV_CS_TSIZE_BIT);
au_writel(cs, ep->reg->ctrl_stat);
@@ -491,6 +491,12 @@
"NAK" : "ACK", pkt, ep->inlist.count);
}
+ /*
+ * The write fifo should already be drained if things are
+ * working right, but flush it anyway just in case.
+ */
+ flush_write_fifo(ep);
+
// begin transmitting next packet in the inlist
if (ep->inlist.count) {
kickstart_send_packet(ep);
@@ -555,11 +561,6 @@
return;
}
- /*
- * The read fifo should already be drained if things are
- * working right, but flush it anyway just in case.
- */
- flush_read_fifo(ep);
if (get_dma_active_buffer(ep->outdma) == 1) {
clear_dma_done1(ep->outdma);
set_dma_count1(ep->outdma, ep->max_pkt_size);
@@ -607,6 +608,10 @@
* need to pull out any remaining bytes in the FIFO.
*/
endpoint_fifo_read(ep);
+ /*
+ * should be drained now, but flush anyway just in case.
+ */
+ flush_read_fifo(ep);
pkt->status = (cs & USBDEV_CS_NAK) ? PKT_STATUS_NAK : PKT_STATUS_ACK;
if (ep->address == 0 && (cs & USBDEV_CS_SU))
@@ -648,7 +653,7 @@
break;
}
- return SETUP_STAGE; // FIXME: must be status stage!
+ return STATUS_STAGE;
}
static ep0_stage_t
@@ -713,20 +718,26 @@
static ep0_stage_t
do_set_address(struct usb_dev* dev, devrequest* setup)
{
- dev->address = le16_to_cpu(setup->value);
- dbg(__FUNCTION__ ": our address=%d", dev->address);
- if (dev->address > 127 || dev->state == CONFIGURED) {
+ int new_state = dev->state;
+ int new_addr = le16_to_cpu(setup->value);
+
+ dbg(__FUNCTION__ ": our address=%d", new_addr);
+
+ if (new_addr > 127) {
// usb spec doesn't tell us what to do, so just go to
// default state
- dev->state = DEFAULT;
+ new_state = DEFAULT;
dev->address = 0;
- } else if (dev->address)
- dev->state = ADDRESS;
- else
- dev->state = DEFAULT;
-
- /* inform function layer of usbdev state change */
- dev->func_cb(CB_NEW_STATE, dev->state, dev->cb_data);
+ } else if (dev->address != new_addr) {
+ dev->address = new_addr;
+ new_state = ADDRESS;
+ }
+
+ if (dev->state != new_state) {
+ dev->state = new_state;
+ /* inform function layer of usbdev state change */
+ dev->func_cb(CB_NEW_STATE, dev->state, dev->cb_data);
+ }
return SETUP_STAGE;
}
@@ -931,7 +942,7 @@
}
/*
- * A complete packet (SETUP, DATA0, or DATA1) has been received
+ * A SETUP, DATA0, or DATA1 packet has been received
* on the default control endpoint's fifo.
*/
static void
@@ -959,6 +970,9 @@
switch (dev->ep0_stage) {
case SETUP_STAGE:
+ vdbg("SU bit is %s in setup stage",
+ (pkt->status & PKT_STATUS_SU) ? "set" : "not set");
+
if (pkt->size == sizeof(devrequest)) {
#ifdef VDEBUG
if (pkt->status & PKT_STATUS_ACK)
@@ -978,7 +992,7 @@
* now, set_descriptor not implemented.
*
* Need to place a byte in the write FIFO here, to prepare
- * to send a zero-length ACK packet to the host in the
+ * to send a zero-length DATA ack packet to the host in the
* STATUS stage.
*/
au_writel(0, ep0->reg->write_fifo);
@@ -1005,7 +1019,7 @@
/*
- * A complete packet has been received on one of the OUT endpoints (4 or 5)
+ * A DATA0/1 packet has been received on one of the OUT endpoints (4 or 5)
*/
static void
process_ep_receive (struct usb_dev* dev, endpoint_t *ep)
|