Browse Source

update usb driver by reference embed code.

Change-Id: I5ab1ebd2931bcbac0ec389a18dd21fd855af954e
master
zhangbaoqi 7 years ago
parent
commit
d4a83e8a1e
  1. 10
      sys/dev/usb/usb-ohci.c
  2. 2
      sys/dev/usb/usb-ohci.h
  3. 25
      sys/dev/usb/usb.c
  4. 1
      sys/dev/usb/usb_defs.h

10
sys/dev/usb/usb-ohci.c

@ -142,7 +142,7 @@
#define writel(val, addr) *(volatile u32*)((((u32)(addr))>= 0x40000000) ? ((u32)(addr)) | 0x80000000:((u32)(addr)) | 0xa0000000) = (val)
#endif
#define MAX_OHCI_C 4 /*In most case it is enough */
#define MAX_OHCI_C 32 /*In most case it is enough */
//#define MAX_OHCI_C 8 /* Changed for RS690 */
ohci_t *usb_ohci_dev[MAX_OHCI_C];
/* RHSC flag */
@ -2828,13 +2828,16 @@ int submit_common_msg(struct usb_device *dev, unsigned long pipe, void *buffer,
lurb_priv = &ohci_urb[dev_num][ed_num];
if (usb_pipetype(pipe) != PIPE_INTERRUPT) { /*FIXME, might not done bulk */
dev->status = stat;
//dev->status = stat;
if(!dev->status && timeout)
dev->act_len = transfer_len;
/* free TDs in urb_priv */
urb_free_priv(lurb_priv);
memset(lurb_priv, 0, sizeof(*lurb_priv));
}
if(dev->status || timeout==0) return -1;
return 0;
}
@ -2903,7 +2906,7 @@ static int ohci_submit_control_msg(struct usb_device *dev, unsigned long pipe,
if (ohci_debug)
printf("submit_control_msg(%d) %x/%d\n", (pipe >> 8) & 0x7f,
buffer, transfer_len);
#if 1
#if 0
wait_ms(1);
#endif
if (!maxsize) {
@ -3220,6 +3223,7 @@ static int hc_interrupt(void *hc_data)
if (ints & OHCI_INTR_WDH) {
writel(OHCI_INTR_WDH, &regs->intrdisable);
while(!ohci->hcca->done_head) delay(1);
#ifndef LOONGSON_3A2H
if (td == NULL) {

2
sys/dev/usb/usb-ohci.h

@ -19,7 +19,7 @@ static int cc_to_error[16] = {
/* Bit Stuff */ USB_ST_BIT_ERR,
/* Data Togg */ USB_ST_CRC_ERR,
/* Stall */ USB_ST_STALLED,
/* DevNotResp */ -1,
/* DevNotResp */ USB_ST_NOT_RESPONSE,
/* PIDCheck */ USB_ST_BIT_ERR,
/* UnExpPID */ USB_ST_BIT_ERR,
/* DataOver */ USB_ST_BUF_ERR,

25
sys/dev/usb/usb.c

@ -80,6 +80,7 @@
#include <linux/types.h>
#include <stdio.h>
#include <machine/cpu.h>
#include <sys/malloc.h>
#include "usb.h"
@ -1589,7 +1590,7 @@ static void usb_hub_power_on(struct usb_hub_device *hub)
for (i = 0; i < dev->maxchild; i++) {
usb_set_port_feature(dev, i + 1, USB_PORT_FEAT_POWER);
USB_HUB_PRINTF("port %d returns %lX\n",i+1,dev->status);
wait_ms(hub->desc.bPwrOn2PwrGood * 2);
wait_ms(max(hub->desc.bPwrOn2PwrGood * 2,100));
}
}
@ -1698,6 +1699,26 @@ static int hub_port_reset(struct usb_device *dev, int port,
}
extern struct devicelist alldevs;
void usb_disconnect(struct usb_device *usbdev)
{
if (usbdev->match != NULL)
{
struct device *dev, *next_dev;
struct device *localdev = usbdev->match;
for (dev = TAILQ_FIRST(&alldevs); dev != NULL; dev = next_dev)
{
next_dev = TAILQ_NEXT(dev, dv_list);
if (strcmp(dev->dv_xname, localdev->dv_xname) == 0)
{
TAILQ_REMOVE(&alldevs, dev, dv_list);
free(dev, M_DEVBUF);
}
}
}
dev_index--;
}
/*===========================================================================
*
*FUNTION: usb_hub_port_connect_change
@ -1764,6 +1785,8 @@ void usb_hub_port_connect_change(struct usb_device *dev, int port)
/* Woops, disable the port */
USB_HUB_PRINTF("hub: disabling port %d\n", port + 1);
usb_clear_port_feature(dev, port + 1, USB_PORT_FEAT_ENABLE);
usb_disconnect(dev->children[port]);
dev->children[port] = NULL;
}
}

1
sys/dev/usb/usb_defs.h

@ -172,6 +172,7 @@
#define USB_ST_NAK_REC 0x10 /* NAK Received*/
#define USB_ST_CRC_ERR 0x20 /* CRC/timeout Error */
#define USB_ST_BIT_ERR 0x40 /* Bitstuff error */
#define USB_ST_NOT_RESPONSE 0x40000000 /* Not response */
#define USB_ST_NOT_PROC 0x80000000UL /* Not yet processed */

Loading…
Cancel
Save