greybus: es2.c: Increase the number of bulk endpoints

ES2 support 16 endpoints. Update es2.c to allocate endpoints, urbs
and buffers for these new endpoints.

Currently, they are not yet used and es2.c is working in legacy mode
(only original endpoints are used).

Signed-off-by: Alexandre Bailon <abailon@baylibre.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
This commit is contained in:
Alexandre Bailon 2015-06-15 18:08:13 +02:00 committed by Greg Kroah-Hartman
parent ddc09acd46
commit 606addd284
1 changed files with 51 additions and 38 deletions

View File

@ -34,6 +34,9 @@ static struct dentry *apb1_log_enable_dentry;
static struct task_struct *apb1_log_task; static struct task_struct *apb1_log_task;
static DEFINE_KFIFO(apb1_log_fifo, char, APB1_LOG_SIZE); static DEFINE_KFIFO(apb1_log_fifo, char, APB1_LOG_SIZE);
/* Number of bulk in and bulk out couple */
#define NUM_BULKS 7
/* /*
* Number of CPort IN urbs in flight at any point in time. * Number of CPort IN urbs in flight at any point in time.
* Adjust if we are having stalls in the USB buffer due to not enough urbs in * Adjust if we are having stalls in the USB buffer due to not enough urbs in
@ -44,7 +47,7 @@ static DEFINE_KFIFO(apb1_log_fifo, char, APB1_LOG_SIZE);
/* Number of CPort OUT urbs in flight at any point in time. /* Number of CPort OUT urbs in flight at any point in time.
* Adjust if we get messages saying we are out of urbs in the system log. * Adjust if we get messages saying we are out of urbs in the system log.
*/ */
#define NUM_CPORT_OUT_URB 8 #define NUM_CPORT_OUT_URB (8 * NUM_BULKS)
/* vendor request AP message */ /* vendor request AP message */
#define REQUEST_SVC 0x01 #define REQUEST_SVC 0x01
@ -98,8 +101,8 @@ struct es1_ap_dev {
u8 *svc_buffer; u8 *svc_buffer;
struct urb *svc_urb; struct urb *svc_urb;
struct es1_cport_in cport_in; struct es1_cport_in cport_in[NUM_BULKS];
struct es1_cport_out cport_out; struct es1_cport_out cport_out[NUM_BULKS];
struct urb *cport_out_urb[NUM_CPORT_OUT_URB]; struct urb *cport_out_urb[NUM_CPORT_OUT_URB];
bool cport_out_urb_busy[NUM_CPORT_OUT_URB]; bool cport_out_urb_busy[NUM_CPORT_OUT_URB];
spinlock_t cport_out_urb_lock; spinlock_t cport_out_urb_lock;
@ -201,6 +204,7 @@ static void *message_send(struct greybus_host_device *hd, u16 cport_id,
size_t buffer_size; size_t buffer_size;
int retval; int retval;
struct urb *urb; struct urb *urb;
int bulk_ep_set = 0;
buffer = message->buffer; buffer = message->buffer;
buffer_size = sizeof(*message->header) + message->payload_size; buffer_size = sizeof(*message->header) + message->payload_size;
@ -227,7 +231,8 @@ static void *message_send(struct greybus_host_device *hd, u16 cport_id,
put_unaligned_le16(cport_id, message->header->pad); put_unaligned_le16(cport_id, message->header->pad);
usb_fill_bulk_urb(urb, udev, usb_fill_bulk_urb(urb, udev,
usb_sndbulkpipe(udev, es1->cport_out.endpoint), usb_sndbulkpipe(udev,
es1->cport_out[bulk_ep_set].endpoint),
buffer, buffer_size, buffer, buffer_size,
cport_out_callback, message); cport_out_callback, message);
retval = usb_submit_urb(urb, gfp_mask); retval = usb_submit_urb(urb, gfp_mask);
@ -296,6 +301,7 @@ static void ap_disconnect(struct usb_interface *interface)
{ {
struct es1_ap_dev *es1; struct es1_ap_dev *es1;
struct usb_device *udev; struct usb_device *udev;
int bulk_in;
int i; int i;
es1 = usb_get_intfdata(interface); es1 = usb_get_intfdata(interface);
@ -316,15 +322,18 @@ static void ap_disconnect(struct usb_interface *interface)
es1->cport_out_urb_busy[i] = false; /* just to be anal */ es1->cport_out_urb_busy[i] = false; /* just to be anal */
} }
for (i = 0; i < NUM_CPORT_IN_URB; ++i) { for (bulk_in = 0; bulk_in < NUM_BULKS; bulk_in++) {
struct urb *urb = es1->cport_in.urb[i]; struct es1_cport_in *cport_in = &es1->cport_in[bulk_in];
for (i = 0; i < NUM_CPORT_IN_URB; ++i) {
struct urb *urb = cport_in->urb[i];
if (!urb) if (!urb)
break; break;
usb_kill_urb(urb); usb_kill_urb(urb);
usb_free_urb(urb); usb_free_urb(urb);
kfree(es1->cport_in.buffer[i]); kfree(cport_in->buffer[i]);
es1->cport_in.buffer[i] = NULL; cport_in->buffer[i] = NULL;
}
} }
usb_kill_urb(es1->svc_urb); usb_kill_urb(es1->svc_urb);
@ -563,8 +572,8 @@ static int ap_probe(struct usb_interface *interface,
struct usb_host_interface *iface_desc; struct usb_host_interface *iface_desc;
struct usb_endpoint_descriptor *endpoint; struct usb_endpoint_descriptor *endpoint;
bool int_in_found = false; bool int_in_found = false;
bool bulk_in_found = false; int bulk_in = 0;
bool bulk_out_found = false; int bulk_out = 0;
int retval = -ENOMEM; int retval = -ENOMEM;
int i; int i;
u16 endo_id = 0x4755; // FIXME - get endo "ID" from the SVC u16 endo_id = 0x4755; // FIXME - get endo "ID" from the SVC
@ -600,11 +609,11 @@ static int ap_probe(struct usb_interface *interface,
svc_interval = endpoint->bInterval; svc_interval = endpoint->bInterval;
int_in_found = true; int_in_found = true;
} else if (usb_endpoint_is_bulk_in(endpoint)) { } else if (usb_endpoint_is_bulk_in(endpoint)) {
es1->cport_in.endpoint = endpoint->bEndpointAddress; es1->cport_in[bulk_in++].endpoint =
bulk_in_found = true; endpoint->bEndpointAddress;
} else if (usb_endpoint_is_bulk_out(endpoint)) { } else if (usb_endpoint_is_bulk_out(endpoint)) {
es1->cport_out.endpoint = endpoint->bEndpointAddress; es1->cport_out[bulk_out++].endpoint =
bulk_out_found = true; endpoint->bEndpointAddress;
} else { } else {
dev_err(&udev->dev, dev_err(&udev->dev,
"Unknown endpoint type found, address %x\n", "Unknown endpoint type found, address %x\n",
@ -612,8 +621,8 @@ static int ap_probe(struct usb_interface *interface,
} }
} }
if ((int_in_found == false) || if ((int_in_found == false) ||
(bulk_in_found == false) || (bulk_in == 0) ||
(bulk_out_found == false)) { (bulk_out == 0)) {
dev_err(&udev->dev, "Not enough endpoints found in device, aborting!\n"); dev_err(&udev->dev, "Not enough endpoints found in device, aborting!\n");
goto error; goto error;
} }
@ -633,26 +642,30 @@ static int ap_probe(struct usb_interface *interface,
hd, svc_interval); hd, svc_interval);
/* Allocate buffers for our cport in messages and start them up */ /* Allocate buffers for our cport in messages and start them up */
for (i = 0; i < NUM_CPORT_IN_URB; ++i) { for (bulk_in = 0; bulk_in < NUM_BULKS; bulk_in++) {
struct urb *urb; struct es1_cport_in *cport_in = &es1->cport_in[bulk_in];
u8 *buffer; for (i = 0; i < NUM_CPORT_IN_URB; ++i) {
struct urb *urb;
u8 *buffer;
urb = usb_alloc_urb(0, GFP_KERNEL); urb = usb_alloc_urb(0, GFP_KERNEL);
if (!urb) if (!urb)
goto error; goto error;
buffer = kmalloc(ES1_GBUF_MSG_SIZE_MAX, GFP_KERNEL); buffer = kmalloc(ES1_GBUF_MSG_SIZE_MAX, GFP_KERNEL);
if (!buffer) if (!buffer)
goto error; goto error;
usb_fill_bulk_urb(urb, udev, usb_fill_bulk_urb(urb, udev,
usb_rcvbulkpipe(udev, es1->cport_in.endpoint), usb_rcvbulkpipe(udev,
buffer, ES1_GBUF_MSG_SIZE_MAX, cport_in->endpoint),
cport_in_callback, hd); buffer, ES1_GBUF_MSG_SIZE_MAX,
es1->cport_in.urb[i] = urb; cport_in_callback, hd);
es1->cport_in.buffer[i] = buffer; cport_in->urb[i] = urb;
retval = usb_submit_urb(urb, GFP_KERNEL); cport_in->buffer[i] = buffer;
if (retval) retval = usb_submit_urb(urb, GFP_KERNEL);
goto error; if (retval)
goto error;
}
} }
/* Allocate urbs for our CPort OUT messages */ /* Allocate urbs for our CPort OUT messages */