diff options
author | tzafrir <tzafrir@5390a7c7-147a-4af0-8ec9-7488f05a26cb> | 2007-08-16 20:08:58 +0000 |
---|---|---|
committer | tzafrir <tzafrir@5390a7c7-147a-4af0-8ec9-7488f05a26cb> | 2007-08-16 20:08:58 +0000 |
commit | 63222a138f730af14565fa60e8a0b6c1bced30e6 (patch) | |
tree | 71408b04d050e570a88ced2a7a565fd06d953cc3 /xpp/xpp_usb.c | |
parent | 22f5056196575c3ec7516c9acf55cb5786565d15 (diff) |
xpp rev. 4515:
* BRI improvement: an 'nt_keepalive' parameter to xpd_bri forces
a BRI_NT to retry a connection indefinitely (this is our default).
When false it revert to the behaviour in changeset:4415 ("Bezeq like")
* Improvement in DBG macros. The print_dbg parameter is now set of
flags to debug. They are defined in zap_debug.h
* Don't use Astribanks connected to USB1 interfaces
Unless the user set the option usb1=1 for xpp_usb (r4504).
* And some more documentation...
* Include some of our variables in the default zaptel sample file.
git-svn-id: http://svn.digium.com/svn/zaptel/branches/1.2@2860 5390a7c7-147a-4af0-8ec9-7488f05a26cb
Diffstat (limited to 'xpp/xpp_usb.c')
-rw-r--r-- | xpp/xpp_usb.c | 62 |
1 files changed, 42 insertions, 20 deletions
diff --git a/xpp/xpp_usb.c b/xpp/xpp_usb.c index b5ed7e3..c147285 100644 --- a/xpp/xpp_usb.c +++ b/xpp/xpp_usb.c @@ -50,6 +50,7 @@ static const char rcsid[] = "$Id$"; DEF_PARM(int, print_dbg, 0, 0644, "Print DBG statements"); /* must be before zap_debug.h */ +DEF_PARM(int, usb1, 0, 0644, "Allow using USB 1.1 interfaces"); #include "zap_debug.h" @@ -326,7 +327,7 @@ freepack: static void xpp_urb_delete(struct urb *urb) { BUG_ON(!urb); - // DBG("%s: (%d) %p %X", __FUNCTION__, urb->transfer_buffer_length, urb->transfer_buffer, urb->transfer_dma); + // DBG(GENERAL, "%s: (%d) %p %X", __FUNCTION__, urb->transfer_buffer_length, urb->transfer_buffer, urb->transfer_dma); usb_buffer_free (urb->dev, urb->transfer_buffer_length, urb->transfer_buffer, urb->transfer_dma); @@ -364,7 +365,7 @@ static struct urb *xpp_urb_new(xusb_t *xusb, enum xusb_dir dir, size_t size) */ urb->transfer_flags = (URB_NO_TRANSFER_DMA_MAP | URB_ASYNC_UNLINK); buffer = usb_buffer_alloc(udev, size, GFP_ATOMIC, &urb->transfer_dma); - // DBG("(%d) %p / %x", size, buffer, urb->transfer_dma); + // DBG(GENERAL, "(%d) %p / %x", size, buffer, urb->transfer_dma); if (!buffer) { err("Couldn't allocate buffer"); usb_free_urb(urb); @@ -456,6 +457,29 @@ static struct usb_class_driver xusb_class = { }; /* + * Check that an endpoint's wMaxPacketSize attribute is 512. This + * indicates that it is a USB2's high speed end point. + * + * If it is 64, it means we have a USB1 controller. By default we do not + * support it and just fail the probe of the device. However if the user + * has set usb1=1, we continue and just put a notice. + */ +int is_usb1_endpoint_size(int ep_addr, int max_packet_size, const char *type) +{ + if(max_packet_size >= sizeof(xpacket_t)) + return 0; + + if(usb1) { + NOTICE("USB1 endpoint detected: USB %s endpoint 0x%X support only wMaxPacketSize=%d.\n", + type, ep_addr, max_packet_size); + return 0; + } + NOTICE("USB1 endpoint detected. Device disabled. To enable: usb1=1, and read docs. (%s, endpoint %d, size %d).\n", + type, ep_addr, max_packet_size); + return 1; +} + +/* * set up the endpoint information * check out the endpoints * FIXME: Should be simplified (above 2.6.10) to use usb_dev->ep_in[0..16] and usb_dev->ep_out[0..16] @@ -469,7 +493,7 @@ static int set_endpoints(xusb_t *xusb, struct usb_interface *interface, struct x int i; iface_desc = &interface->altsetting[0]; - DBG("Found interface. Endpoints: %d\n", iface_desc->desc.bNumEndpoints); + DBG(GENERAL, "Found interface. Endpoints: %d\n", iface_desc->desc.bNumEndpoints); #define BULK_ENDPOINT(ep) (((ep)->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) == USB_ENDPOINT_XFER_BULK) @@ -478,15 +502,14 @@ static int set_endpoints(xusb_t *xusb, struct usb_interface *interface, struct x ep_addr = endpoint->bEndpointAddress; if(!BULK_ENDPOINT(endpoint)) { - DBG("endpoint 0x%x is not bulk: mbAttributes=0x%X\n", + DBG(GENERAL, "endpoint 0x%x is not bulk: mbAttributes=0x%X\n", ep_addr, endpoint->bmAttributes); continue; } if(usb_pipein(ep_addr)) { // Input if(ep_addr == model_info->in.ep_addr) { - if(endpoint->wMaxPacketSize < sizeof(xframe_t)) { - NOTICE("USB input endpoint 0x%X support only wMaxPacketSize=%d (need USB-2)\n", ep_addr, endpoint->wMaxPacketSize); - } + if (is_usb1_endpoint_size(ep_addr, endpoint->wMaxPacketSize, "input")) + return 0; xusb_ep = &xusb->endpoints[XUSB_RECV]; xusb_ep->ep_addr = ep_addr; xusb_ep->max_size = endpoint->wMaxPacketSize; @@ -494,9 +517,8 @@ static int set_endpoints(xusb_t *xusb, struct usb_interface *interface, struct x } } else { // Output if(ep_addr == model_info->out.ep_addr) { - if(endpoint->wMaxPacketSize < sizeof(xframe_t)) { - NOTICE("USB output endpoint 0x%X support only wMaxPacketSize=%d (need USB-2)\n", ep_addr, endpoint->wMaxPacketSize); - } + if (is_usb1_endpoint_size(ep_addr, endpoint->wMaxPacketSize, "output")) + return 0; xusb_ep = &xusb->endpoints[XUSB_SEND]; xusb_ep->ep_addr = ep_addr; xusb_ep->max_size = endpoint->wMaxPacketSize; @@ -508,7 +530,7 @@ static int set_endpoints(xusb_t *xusb, struct usb_interface *interface, struct x ERR("Couldn't find bulk-in or bulk-out endpoints\n"); return 0; } - DBG("in=0x%02X out=0x%02X\n", xusb->endpoints[XUSB_RECV].ep_addr, xusb->endpoints[XUSB_SEND].ep_addr); + DBG(GENERAL, "in=0x%02X out=0x%02X\n", xusb->endpoints[XUSB_RECV].ep_addr, xusb->endpoints[XUSB_SEND].ep_addr); return 1; } @@ -621,13 +643,13 @@ static int xusb_probe(struct usb_interface *interface, const struct usb_device_i snprintf(xbus->busdesc, XBUS_DESCLEN, "%s", path); } - DBG("GOT XPP USB BUS #%d: %s (type=%d)\n", i, xbus->busdesc, xbus->bus_type); + DBG(GENERAL, "GOT XPP USB BUS #%d: %s (type=%d)\n", i, xbus->busdesc, xbus->bus_type); xusb_array[i] = xusb; #ifdef CONFIG_PROC_FS - DBG("Creating proc entry " PROC_USBXPP_SUMMARY " in bus proc dir.\n"); + DBG(PROC, "Creating proc entry " PROC_USBXPP_SUMMARY " in bus proc dir.\n"); procsummary = create_proc_read_entry(PROC_USBXPP_SUMMARY, 0444, xbus->proc_xbus_dir, xusb_read_proc, xusb); if (!procsummary) { @@ -659,7 +681,7 @@ probe_failed: } if(xbus) { if(procsummary) { - XBUS_DBG(xbus, "Remove proc_entry: " PROC_USBXPP_SUMMARY "\n"); + XBUS_DBG(PROC, xbus, "Remove proc_entry: " PROC_USBXPP_SUMMARY "\n"); remove_proc_entry(PROC_USBXPP_SUMMARY, xbus->proc_xbus_dir); procsummary = NULL; } @@ -686,7 +708,7 @@ static void xusb_disconnect(struct usb_interface *interface) int minor; int i; - DBG("CALLED\n"); + DBG(GENERAL, "CALLED\n"); /* prevent races with open() */ down (&disconnect_sem); @@ -704,7 +726,7 @@ static void xusb_disconnect(struct usb_interface *interface) #ifdef CONFIG_PROC_FS if(xbus->proc_xbus_dir) { - XBUS_DBG(xbus, "Remove proc_entry: " PROC_USBXPP_SUMMARY "\n"); + XBUS_DBG(GENERAL, xbus, "Remove proc_entry: " PROC_USBXPP_SUMMARY "\n"); remove_proc_entry(PROC_USBXPP_SUMMARY, xbus->proc_xbus_dir); } #endif @@ -726,7 +748,7 @@ static void xusb_disconnect(struct usb_interface *interface) xpp_urb_delete(xusb->read_urb); up (&xusb->sem); - DBG("Semaphore released\n"); + DBG(GENERAL, "Semaphore released\n"); kfree(xusb); @@ -761,7 +783,7 @@ static void xpp_send_callback(USB_PASS_CB(urb)) if (urb->status && !(urb->status == -ENOENT || urb->status == -ECONNRESET)) { static int rate_limit; if((rate_limit++ % 1000) < 10) - DBG("nonzero read bulk status received: %d\n", urb->status); + DBG(GENERAL, "nonzero read bulk status received: %d\n", urb->status); XUSB_COUNTER(xusb, TX_ERRORS)++; } xpp_urb_delete(urb); @@ -792,7 +814,7 @@ static void xpp_receive_callback(USB_PASS_CB(urb)) } //flip_parport_bit(7); if (urb->status) { - DBG("nonzero read bulk status received: %d\n", urb->status); + DBG(GENERAL, "nonzero read bulk status received: %d\n", urb->status); XUSB_COUNTER(xusb, RX_ERRORS)++; /* Free old URB, allocate a fresh one */ if(xusb->read_urb) @@ -872,7 +894,7 @@ int __init xpp_usb_init(void) void __exit xpp_usb_cleanup(void) { - DBG("\n"); + DBG(GENERAL, "\n"); /* deregister this driver with the USB subsystem */ usb_deregister(&xusb_driver); } |