Lines Matching refs:udc

97 	struct fsl_udc *udc = NULL;  in done()  local
102 udc = (struct fsl_udc *)ep->udc; in done()
119 dma_pool_free(udc->td_pool, curr_td, curr_td->td_dma); in done()
123 dma_unmap_single(ep->udc->gadget.dev.parent, in done()
131 dma_sync_single_for_cpu(ep->udc->gadget.dev.parent, in done()
144 spin_unlock(&ep->udc->lock); in done()
150 spin_lock(&ep->udc->lock); in done()
178 static int dr_controller_setup(struct fsl_udc *udc) in dr_controller_setup() argument
190 switch (udc->phy_mode) { in dr_controller_setup()
237 tmp = udc->ep_qh_dma; in dr_controller_setup()
242 udc->ep_qh, (int)tmp, in dr_controller_setup()
267 static void dr_controller_run(struct fsl_udc *udc) in dr_controller_run() argument
279 udc->stopped = 0; in dr_controller_run()
292 static void dr_controller_stop(struct fsl_udc *udc) in dr_controller_stop() argument
300 udc->stopped = 1; in dr_controller_stop()
382 static void struct_ep_qh_setup(struct fsl_udc *udc, unsigned char ep_num, in struct_ep_qh_setup() argument
387 struct ep_queue_head *p_QH = &udc->ep_qh[2 * ep_num + dir]; in struct_ep_qh_setup()
418 static void ep0_setup(struct fsl_udc *udc) in ep0_setup() argument
422 struct_ep_qh_setup(udc, 0, USB_RECV, USB_ENDPOINT_XFER_CONTROL, in ep0_setup()
424 struct_ep_qh_setup(udc, 0, USB_SEND, USB_ENDPOINT_XFER_CONTROL, in ep0_setup()
446 struct fsl_udc *udc = NULL; in fsl_ep_enable() local
460 udc = ep->udc; in fsl_ep_enable()
462 if (!udc->driver || (udc->gadget.speed == USB_SPEED_UNKNOWN)) in fsl_ep_enable()
495 spin_lock_irqsave(&udc->lock, flags); in fsl_ep_enable()
503 struct_ep_qh_setup(udc, (unsigned char) ep_index(ep), in fsl_ep_enable()
517 spin_unlock_irqrestore(&udc->lock, flags); in fsl_ep_enable()
534 struct fsl_udc *udc = NULL; in fsl_ep_disable() local
555 udc = (struct fsl_udc *)ep->udc; in fsl_ep_disable()
556 spin_lock_irqsave(&udc->lock, flags); in fsl_ep_disable()
563 spin_unlock_irqrestore(&udc->lock, flags); in fsl_ep_disable()
604 struct ep_queue_head *dQH = &ep->udc->ep_qh[i]; in fsl_queue_td()
767 struct fsl_udc *udc; in fsl_ep_queue() local
785 udc = ep->udc; in fsl_ep_queue()
786 if (!udc->driver || udc->gadget.speed == USB_SPEED_UNKNOWN) in fsl_ep_queue()
793 req->req.dma = dma_map_single(ep->udc->gadget.dev.parent, in fsl_ep_queue()
800 dma_sync_single_for_device(ep->udc->gadget.dev.parent, in fsl_ep_queue()
812 spin_lock_irqsave(&udc->lock, flags); in fsl_ep_queue()
818 spin_unlock_irqrestore(&udc->lock, flags); in fsl_ep_queue()
824 udc->ep0_state = DATA_STATE_XMIT; in fsl_ep_queue()
829 spin_unlock_irqrestore(&udc->lock, flags); in fsl_ep_queue()
846 spin_lock_irqsave(&ep->udc->lock, flags); in fsl_ep_dequeue()
908 spin_unlock_irqrestore(&ep->udc->lock, flags); in fsl_ep_dequeue()
926 struct fsl_udc *udc = NULL; in fsl_ep_set_halt() local
929 udc = ep->udc; in fsl_ep_set_halt()
950 spin_lock_irqsave(&ep->udc->lock, flags); in fsl_ep_set_halt()
952 spin_unlock_irqrestore(&ep->udc->lock, flags); in fsl_ep_set_halt()
955 udc->ep0_state = WAIT_FOR_SETUP; in fsl_ep_set_halt()
956 udc->ep0_dir = 0; in fsl_ep_set_halt()
1037 struct fsl_udc *udc = container_of(gadget, struct fsl_udc, gadget); in fsl_wakeup() local
1041 if (!udc->remote_wakeup) in fsl_wakeup()
1054 static int can_pullup(struct fsl_udc *udc) in can_pullup() argument
1056 return udc->driver && udc->softconnect && udc->vbus_active; in can_pullup()
1063 struct fsl_udc *udc; in fsl_vbus_session() local
1066 udc = container_of(gadget, struct fsl_udc, gadget); in fsl_vbus_session()
1067 spin_lock_irqsave(&udc->lock, flags); in fsl_vbus_session()
1069 udc->vbus_active = (is_active != 0); in fsl_vbus_session()
1070 if (can_pullup(udc)) in fsl_vbus_session()
1076 spin_unlock_irqrestore(&udc->lock, flags); in fsl_vbus_session()
1089 struct fsl_udc *udc; in fsl_vbus_draw() local
1091 udc = container_of(gadget, struct fsl_udc, gadget); in fsl_vbus_draw()
1092 if (udc->transceiver) in fsl_vbus_draw()
1093 return otg_set_power(udc->transceiver, mA); in fsl_vbus_draw()
1102 struct fsl_udc *udc; in fsl_pullup() local
1104 udc = container_of(gadget, struct fsl_udc, gadget); in fsl_pullup()
1105 udc->softconnect = (is_on != 0); in fsl_pullup()
1106 if (can_pullup(udc)) in fsl_pullup()
1128 static void ep0stall(struct fsl_udc *udc) in ep0stall() argument
1136 udc->ep0_state = WAIT_FOR_SETUP; in ep0stall()
1137 udc->ep0_dir = 0; in ep0stall()
1141 static int ep0_prime_status(struct fsl_udc *udc, int direction) in ep0_prime_status() argument
1143 struct fsl_req *req = udc->status_req; in ep0_prime_status()
1147 udc->ep0_dir = USB_DIR_IN; in ep0_prime_status()
1149 udc->ep0_dir = USB_DIR_OUT; in ep0_prime_status()
1151 ep = &udc->eps[0]; in ep0_prime_status()
1152 udc->ep0_state = WAIT_FOR_OUT_STATUS; in ep0_prime_status()
1171 static void udc_reset_ep_queue(struct fsl_udc *udc, u8 pipe) in udc_reset_ep_queue() argument
1173 struct fsl_ep *ep = get_ep_by_pipe(udc, pipe); in udc_reset_ep_queue()
1182 static void ch9setaddress(struct fsl_udc *udc, u16 value, u16 index, u16 length) in ch9setaddress() argument
1185 udc->device_address = (u8) value; in ch9setaddress()
1187 udc->usb_state = USB_STATE_ADDRESS; in ch9setaddress()
1189 if (ep0_prime_status(udc, EP_DIR_IN)) in ch9setaddress()
1190 ep0stall(udc); in ch9setaddress()
1196 static void ch9getstatus(struct fsl_udc *udc, u8 request_type, u16 value, in ch9getstatus() argument
1203 ep = &udc->eps[0]; in ch9getstatus()
1208 tmp |= udc->remote_wakeup << USB_DEVICE_REMOTE_WAKEUP; in ch9getstatus()
1217 target_ep = get_ep_by_pipe(udc, get_pipe_by_windex(index)); in ch9getstatus()
1226 udc->ep0_dir = USB_DIR_IN; in ch9getstatus()
1228 req = udc->status_req; in ch9getstatus()
1245 udc->ep0_state = DATA_STATE_XMIT; in ch9getstatus()
1248 ep0stall(udc); in ch9getstatus()
1251 static void setup_received_irq(struct fsl_udc *udc, in setup_received_irq() argument
1258 udc_reset_ep_queue(udc, 0); in setup_received_irq()
1267 ch9getstatus(udc, setup->bRequestType, wValue, wIndex, wLength); in setup_received_irq()
1275 ch9setaddress(udc, wValue, wIndex, wLength); in setup_received_irq()
1289 if (wValue != 0 || wLength != 0 || pipe > udc->max_ep) in setup_received_irq()
1291 ep = get_ep_by_pipe(udc, pipe); in setup_received_irq()
1293 spin_unlock(&udc->lock); in setup_received_irq()
1297 spin_lock(&udc->lock); in setup_received_irq()
1304 if (!gadget_is_otg(&udc->gadget)) in setup_received_irq()
1307 udc->gadget.b_hnp_enable = 1; in setup_received_irq()
1309 udc->gadget.a_hnp_support = 1; in setup_received_irq()
1312 udc->gadget.a_alt_hnp_support = 1; in setup_received_irq()
1320 if (ep0_prime_status(udc, EP_DIR_IN)) in setup_received_irq()
1321 ep0stall(udc); in setup_received_irq()
1333 udc->ep0_dir = (setup->bRequestType & USB_DIR_IN) in setup_received_irq()
1335 spin_unlock(&udc->lock); in setup_received_irq()
1336 if (udc->driver->setup(&udc->gadget, in setup_received_irq()
1337 &udc->local_setup_buff) < 0) in setup_received_irq()
1338 ep0stall(udc); in setup_received_irq()
1339 spin_lock(&udc->lock); in setup_received_irq()
1340 udc->ep0_state = (setup->bRequestType & USB_DIR_IN) in setup_received_irq()
1344 udc->ep0_dir = USB_DIR_IN; in setup_received_irq()
1345 spin_unlock(&udc->lock); in setup_received_irq()
1346 if (udc->driver->setup(&udc->gadget, in setup_received_irq()
1347 &udc->local_setup_buff) < 0) in setup_received_irq()
1348 ep0stall(udc); in setup_received_irq()
1349 spin_lock(&udc->lock); in setup_received_irq()
1350 udc->ep0_state = WAIT_FOR_OUT_STATUS; in setup_received_irq()
1356 static void ep0_req_complete(struct fsl_udc *udc, struct fsl_ep *ep0, in ep0_req_complete() argument
1359 if (udc->usb_state == USB_STATE_ADDRESS) { in ep0_req_complete()
1361 u32 new_address = (u32) udc->device_address; in ep0_req_complete()
1368 switch (udc->ep0_state) { in ep0_req_complete()
1371 if (ep0_prime_status(udc, EP_DIR_OUT)) in ep0_req_complete()
1372 ep0stall(udc); in ep0_req_complete()
1376 if (ep0_prime_status(udc, EP_DIR_IN)) in ep0_req_complete()
1377 ep0stall(udc); in ep0_req_complete()
1380 udc->ep0_state = WAIT_FOR_SETUP; in ep0_req_complete()
1386 ep0stall(udc); in ep0_req_complete()
1393 static void tripwire_handler(struct fsl_udc *udc, u8 ep_num, u8 *buffer_ptr) in tripwire_handler() argument
1398 qh = &udc->ep_qh[ep_num * 2 + EP_DIR_OUT]; in tripwire_handler()
1420 static int process_ep_req(struct fsl_udc *udc, int pipe, in process_ep_req() argument
1427 struct ep_queue_head *curr_qh = &udc->ep_qh[pipe]; in process_ep_req()
1497 static void dtd_complete_irq(struct fsl_udc *udc) in dtd_complete_irq() argument
1511 for (i = 0; i < udc->max_ep * 2; i++) { in dtd_complete_irq()
1520 curr_ep = get_ep_by_pipe(udc, i); in dtd_complete_irq()
1531 status = process_ep_req(udc, i, curr_req); in dtd_complete_irq()
1541 ep0_req_complete(udc, curr_ep, curr_req); in dtd_complete_irq()
1550 static void port_change_irq(struct fsl_udc *udc) in port_change_irq() argument
1561 udc->gadget.speed = USB_SPEED_HIGH; in port_change_irq()
1564 udc->gadget.speed = USB_SPEED_FULL; in port_change_irq()
1567 udc->gadget.speed = USB_SPEED_LOW; in port_change_irq()
1570 udc->gadget.speed = USB_SPEED_UNKNOWN; in port_change_irq()
1576 if (!udc->resume_state) in port_change_irq()
1577 udc->usb_state = USB_STATE_DEFAULT; in port_change_irq()
1581 static void suspend_irq(struct fsl_udc *udc) in suspend_irq() argument
1583 udc->resume_state = udc->usb_state; in suspend_irq()
1584 udc->usb_state = USB_STATE_SUSPENDED; in suspend_irq()
1587 if (udc->driver->suspend) in suspend_irq()
1588 udc->driver->suspend(&udc->gadget); in suspend_irq()
1591 static void bus_resume(struct fsl_udc *udc) in bus_resume() argument
1593 udc->usb_state = udc->resume_state; in bus_resume()
1594 udc->resume_state = 0; in bus_resume()
1597 if (udc->driver->resume) in bus_resume()
1598 udc->driver->resume(&udc->gadget); in bus_resume()
1602 static int reset_queues(struct fsl_udc *udc) in reset_queues() argument
1606 for (pipe = 0; pipe < udc->max_pipes; pipe++) in reset_queues()
1607 udc_reset_ep_queue(udc, pipe); in reset_queues()
1610 spin_unlock(&udc->lock); in reset_queues()
1611 udc->driver->disconnect(&udc->gadget); in reset_queues()
1612 spin_lock(&udc->lock); in reset_queues()
1618 static void reset_irq(struct fsl_udc *udc) in reset_irq() argument
1627 udc->device_address = 0; in reset_irq()
1630 udc->resume_state = 0; in reset_irq()
1631 udc->ep0_dir = 0; in reset_irq()
1632 udc->ep0_state = WAIT_FOR_SETUP; in reset_irq()
1633 udc->remote_wakeup = 0; /* default to 0 on reset */ in reset_irq()
1634 udc->gadget.b_hnp_enable = 0; in reset_irq()
1635 udc->gadget.a_hnp_support = 0; in reset_irq()
1636 udc->gadget.a_alt_hnp_support = 0; in reset_irq()
1663 reset_queues(udc); in reset_irq()
1664 udc->usb_state = USB_STATE_DEFAULT; in reset_irq()
1669 dr_controller_setup(udc); in reset_irq()
1672 reset_queues(udc); in reset_irq()
1674 ep0_setup(udc); in reset_irq()
1677 dr_controller_run(udc); in reset_irq()
1678 udc->usb_state = USB_STATE_ATTACHED; in reset_irq()
1687 struct fsl_udc *udc = _udc; in fsl_udc_irq() local
1693 if (udc->stopped) in fsl_udc_irq()
1695 spin_lock_irqsave(&udc->lock, flags); in fsl_udc_irq()
1703 if (udc->usb_state == USB_STATE_SUSPENDED) in fsl_udc_irq()
1705 bus_resume(udc); in fsl_udc_irq()
1712 tripwire_handler(udc, 0, in fsl_udc_irq()
1713 (u8 *) (&udc->local_setup_buff)); in fsl_udc_irq()
1714 setup_received_irq(udc, &udc->local_setup_buff); in fsl_udc_irq()
1720 dtd_complete_irq(udc); in fsl_udc_irq()
1732 port_change_irq(udc); in fsl_udc_irq()
1738 reset_irq(udc); in fsl_udc_irq()
1744 suspend_irq(udc); in fsl_udc_irq()
1752 spin_unlock_irqrestore(&udc->lock, flags); in fsl_udc_irq()
1878 struct fsl_udc *udc = udc_controller; in fsl_proc_read() local
1882 spin_lock_irqsave(&udc->lock, flags); in fsl_proc_read()
1890 udc->driver ? udc->driver->driver.name : "(none)"); in fsl_proc_read()
2034 for (i = 0; i < udc->max_ep / 2; i++) { in fsl_proc_read()
2060 ep = &udc->eps[0]; in fsl_proc_read()
2081 list_for_each_entry(ep, &udc->gadget.ep_list, ep.ep_list) { in fsl_proc_read()
2110 spin_unlock_irqrestore(&udc->lock, flags); in fsl_proc_read()
2146 static int __init struct_udc_setup(struct fsl_udc *udc, in struct_udc_setup() argument
2153 udc->phy_mode = pdata->phy_mode; in struct_udc_setup()
2155 udc->eps = kzalloc(sizeof(struct fsl_ep) * udc->max_ep, GFP_KERNEL); in struct_udc_setup()
2156 if (!udc->eps) { in struct_udc_setup()
2162 size = udc->max_ep * sizeof(struct ep_queue_head); in struct_udc_setup()
2169 udc->ep_qh = dma_alloc_coherent(&pdev->dev, size, in struct_udc_setup()
2170 &udc->ep_qh_dma, GFP_KERNEL); in struct_udc_setup()
2171 if (!udc->ep_qh) { in struct_udc_setup()
2173 kfree(udc->eps); in struct_udc_setup()
2177 udc->ep_qh_size = size; in struct_udc_setup()
2181 udc->status_req = container_of(fsl_alloc_request(NULL, GFP_KERNEL), in struct_udc_setup()
2184 udc->status_req->req.buf = kmalloc(8, GFP_KERNEL); in struct_udc_setup()
2185 udc->status_req->req.dma = virt_to_phys(udc->status_req->req.buf); in struct_udc_setup()
2187 udc->resume_state = USB_STATE_NOTATTACHED; in struct_udc_setup()
2188 udc->usb_state = USB_STATE_POWERED; in struct_udc_setup()
2189 udc->ep0_dir = 0; in struct_udc_setup()
2190 udc->remote_wakeup = 0; /* default to 0 on reset */ in struct_udc_setup()
2201 static int __init struct_ep_setup(struct fsl_udc *udc, unsigned char index, in struct_ep_setup() argument
2204 struct fsl_ep *ep = &udc->eps[index]; in struct_ep_setup()
2206 ep->udc = udc; in struct_ep_setup()
2223 list_add_tail(&ep->ep.ep_list, &udc->gadget.ep_list); in struct_ep_setup()
2224 ep->gadget = &udc->gadget; in struct_ep_setup()
2225 ep->qh = &udc->ep_qh[index]; in struct_ep_setup()