Lines Matching refs:fc_usb
71 struct flexcop_usb *fc_usb = fc->bus_specific; in flexcop_usb_readwrite_dw() local
78 mutex_lock(&fc_usb->data_mutex); in flexcop_usb_readwrite_dw()
80 memcpy(fc_usb->data, val, sizeof(*val)); in flexcop_usb_readwrite_dw()
82 ret = usb_control_msg(fc_usb->udev, in flexcop_usb_readwrite_dw()
88 fc_usb->data, in flexcop_usb_readwrite_dw()
100 memcpy(val, fc_usb->data, sizeof(*val)); in flexcop_usb_readwrite_dw()
101 mutex_unlock(&fc_usb->data_mutex); in flexcop_usb_readwrite_dw()
108 static int flexcop_usb_v8_memory_req(struct flexcop_usb *fc_usb, in flexcop_usb_v8_memory_req() argument
117 if (buflen > sizeof(fc_usb->data)) { in flexcop_usb_v8_memory_req()
146 mutex_lock(&fc_usb->data_mutex); in flexcop_usb_v8_memory_req()
149 memcpy(fc_usb->data, pbBuffer, buflen); in flexcop_usb_v8_memory_req()
151 ret = usb_control_msg(fc_usb->udev, pipe, in flexcop_usb_v8_memory_req()
156 fc_usb->data, in flexcop_usb_v8_memory_req()
165 memcpy(pbBuffer, fc_usb->data, buflen); in flexcop_usb_v8_memory_req()
168 mutex_unlock(&fc_usb->data_mutex); in flexcop_usb_v8_memory_req()
178 static int flexcop_usb_memory_req(struct flexcop_usb *fc_usb, in flexcop_usb_memory_req() argument
209 ret = flexcop_usb_v8_memory_req(fc_usb, req, in flexcop_usb_memory_req()
235 struct flexcop_usb *fc_usb = i2c->fc->bus_specific; in flexcop_usb_i2c_req() local
240 if (buflen > sizeof(fc_usb->data)) { in flexcop_usb_i2c_req()
273 mutex_lock(&fc_usb->data_mutex); in flexcop_usb_i2c_req()
276 memcpy(fc_usb->data, buf, buflen); in flexcop_usb_i2c_req()
278 ret = usb_control_msg(fc_usb->udev, pipe, in flexcop_usb_i2c_req()
283 fc_usb->data, in flexcop_usb_i2c_req()
293 memcpy(buf, fc_usb->data, buflen); in flexcop_usb_i2c_req()
296 mutex_unlock(&fc_usb->data_mutex); in flexcop_usb_i2c_req()
329 static void flexcop_usb_process_frame(struct flexcop_usb *fc_usb, in flexcop_usb_process_frame() argument
336 fc_usb->tmp_buffer_length, buffer_length); in flexcop_usb_process_frame()
338 if (fc_usb->tmp_buffer_length > 0) { in flexcop_usb_process_frame()
339 memcpy(fc_usb->tmp_buffer+fc_usb->tmp_buffer_length, buffer, in flexcop_usb_process_frame()
341 fc_usb->tmp_buffer_length += buffer_length; in flexcop_usb_process_frame()
342 b = fc_usb->tmp_buffer; in flexcop_usb_process_frame()
343 l = fc_usb->tmp_buffer_length; in flexcop_usb_process_frame()
355 fc_usb->fc_dev, b+2, 1); in flexcop_usb_process_frame()
373 memcpy(fc_usb->tmp_buffer, b, l); in flexcop_usb_process_frame()
374 fc_usb->tmp_buffer_length = l; in flexcop_usb_process_frame()
379 struct flexcop_usb *fc_usb = urb->context; in flexcop_usb_urb_complete() local
395 flexcop_usb_process_frame(fc_usb, in flexcop_usb_urb_complete()
412 static void flexcop_usb_transfer_exit(struct flexcop_usb *fc_usb) in flexcop_usb_transfer_exit() argument
416 if (fc_usb->iso_urb[i] != NULL) { in flexcop_usb_transfer_exit()
418 usb_kill_urb(fc_usb->iso_urb[i]); in flexcop_usb_transfer_exit()
419 usb_free_urb(fc_usb->iso_urb[i]); in flexcop_usb_transfer_exit()
422 usb_free_coherent(fc_usb->udev, fc_usb->buffer_size, in flexcop_usb_transfer_exit()
423 fc_usb->iso_buffer, fc_usb->dma_addr); in flexcop_usb_transfer_exit()
427 static int flexcop_usb_transfer_init(struct flexcop_usb *fc_usb) in flexcop_usb_transfer_init() argument
430 fc_usb->uintf->cur_altsetting->endpoint[0].desc.wMaxPacketSize); in flexcop_usb_transfer_init()
439 fc_usb->iso_buffer = usb_alloc_coherent(fc_usb->udev, in flexcop_usb_transfer_init()
440 bufsize, GFP_KERNEL, &fc_usb->dma_addr); in flexcop_usb_transfer_init()
441 if (fc_usb->iso_buffer == NULL) in flexcop_usb_transfer_init()
444 memset(fc_usb->iso_buffer, 0, bufsize); in flexcop_usb_transfer_init()
445 fc_usb->buffer_size = bufsize; in flexcop_usb_transfer_init()
449 fc_usb->iso_urb[i] = usb_alloc_urb(B2C2_USB_FRAMES_PER_ISO, in flexcop_usb_transfer_init()
451 if (fc_usb->iso_urb[i] == NULL) { in flexcop_usb_transfer_init()
460 struct urb *urb = fc_usb->iso_urb[i]; in flexcop_usb_transfer_init()
464 urb->dev = fc_usb->udev; in flexcop_usb_transfer_init()
465 urb->context = fc_usb; in flexcop_usb_transfer_init()
472 urb->transfer_buffer = fc_usb->iso_buffer + buffer_offset; in flexcop_usb_transfer_init()
483 if ((ret = usb_submit_urb(fc_usb->iso_urb[i],GFP_ATOMIC))) { in flexcop_usb_transfer_init()
491 flexcop_sram_set_dest(fc_usb->fc_dev, FC_SRAM_DEST_MEDIA | in flexcop_usb_transfer_init()
494 flexcop_wan_set_speed(fc_usb->fc_dev, FC_WAN_SPEED_8MBITS); in flexcop_usb_transfer_init()
495 flexcop_sram_ctrl(fc_usb->fc_dev, 1, 1, 1); in flexcop_usb_transfer_init()
499 flexcop_usb_transfer_exit(fc_usb); in flexcop_usb_transfer_init()
503 static int flexcop_usb_init(struct flexcop_usb *fc_usb) in flexcop_usb_init() argument
506 int ret = usb_set_interface(fc_usb->udev, 0, 1); in flexcop_usb_init()
513 if (fc_usb->uintf->cur_altsetting->desc.bNumEndpoints < 1) in flexcop_usb_init()
515 if (!usb_endpoint_is_isoc_in(&fc_usb->uintf->cur_altsetting->endpoint[1].desc)) in flexcop_usb_init()
518 switch (fc_usb->udev->speed) { in flexcop_usb_init()
534 usb_set_intfdata(fc_usb->uintf, fc_usb); in flexcop_usb_init()
538 static void flexcop_usb_exit(struct flexcop_usb *fc_usb) in flexcop_usb_exit() argument
540 usb_set_intfdata(fc_usb->uintf, NULL); in flexcop_usb_exit()
547 struct flexcop_usb *fc_usb = NULL; in flexcop_usb_probe() local
557 fc_usb = fc->bus_specific; in flexcop_usb_probe()
558 fc_usb->fc_dev = fc; in flexcop_usb_probe()
559 mutex_init(&fc_usb->data_mutex); in flexcop_usb_probe()
575 fc_usb->udev = udev; in flexcop_usb_probe()
576 fc_usb->uintf = intf; in flexcop_usb_probe()
577 if ((ret = flexcop_usb_init(fc_usb)) != 0) in flexcop_usb_probe()
585 if ((ret = flexcop_usb_transfer_init(fc_usb)) != 0) in flexcop_usb_probe()
594 flexcop_usb_exit(fc_usb); in flexcop_usb_probe()
602 struct flexcop_usb *fc_usb = usb_get_intfdata(intf); in flexcop_usb_disconnect() local
603 flexcop_usb_transfer_exit(fc_usb); in flexcop_usb_disconnect()
604 flexcop_device_exit(fc_usb->fc_dev); in flexcop_usb_disconnect()
605 flexcop_usb_exit(fc_usb); in flexcop_usb_disconnect()
606 flexcop_device_kfree(fc_usb->fc_dev); in flexcop_usb_disconnect()