• Home
  • Raw
  • Download

Lines Matching refs:ci

65 static inline int ep_to_bit(struct ci_hdrc *ci, int n)  in ep_to_bit()  argument
67 int fill = 16 - ci->hw_ep_max / 2; in ep_to_bit()
69 if (n >= ci->hw_ep_max / 2) in ep_to_bit()
81 static int hw_device_state(struct ci_hdrc *ci, u32 dma) in hw_device_state() argument
84 hw_write(ci, OP_ENDPTLISTADDR, ~0, dma); in hw_device_state()
86 hw_write(ci, OP_USBINTR, ~0, in hw_device_state()
89 hw_write(ci, OP_USBINTR, ~0, 0); in hw_device_state()
101 static int hw_ep_flush(struct ci_hdrc *ci, int num, int dir) in hw_ep_flush() argument
107 hw_write(ci, OP_ENDPTFLUSH, ~0, BIT(n)); in hw_ep_flush()
108 while (hw_read(ci, OP_ENDPTFLUSH, BIT(n))) in hw_ep_flush()
110 } while (hw_read(ci, OP_ENDPTSTAT, BIT(n))); in hw_ep_flush()
122 static int hw_ep_disable(struct ci_hdrc *ci, int num, int dir) in hw_ep_disable() argument
124 hw_write(ci, OP_ENDPTCTRL + num, in hw_ep_disable()
137 static int hw_ep_enable(struct ci_hdrc *ci, int num, int dir, int type) in hw_ep_enable() argument
160 hw_write(ci, OP_ENDPTCTRL + num, mask, data); in hw_ep_enable()
171 static int hw_ep_get_halt(struct ci_hdrc *ci, int num, int dir) in hw_ep_get_halt() argument
175 return hw_read(ci, OP_ENDPTCTRL + num, mask) ? 1 : 0; in hw_ep_get_halt()
186 static int hw_ep_prime(struct ci_hdrc *ci, int num, int dir, int is_ctrl) in hw_ep_prime() argument
193 if (is_ctrl && dir == RX && hw_read(ci, OP_ENDPTSETUPSTAT, BIT(num))) in hw_ep_prime()
196 hw_write(ci, OP_ENDPTPRIME, ~0, BIT(n)); in hw_ep_prime()
198 while (hw_read(ci, OP_ENDPTPRIME, BIT(n))) in hw_ep_prime()
200 if (is_ctrl && dir == RX && hw_read(ci, OP_ENDPTSETUPSTAT, BIT(num))) in hw_ep_prime()
216 static int hw_ep_set_halt(struct ci_hdrc *ci, int num, int dir, int value) in hw_ep_set_halt() argument
227 hw_write(ci, reg, mask_xs|mask_xr, in hw_ep_set_halt()
229 } while (value != hw_ep_get_halt(ci, num, dir)); in hw_ep_set_halt()
239 static int hw_port_is_high_speed(struct ci_hdrc *ci) in hw_port_is_high_speed() argument
241 return ci->hw_bank.lpm ? hw_read(ci, OP_DEVLC, DEVLC_PSPD) : in hw_port_is_high_speed()
242 hw_read(ci, OP_PORTSC, PORTSC_HSP); in hw_port_is_high_speed()
252 static int hw_test_and_clear_complete(struct ci_hdrc *ci, int n) in hw_test_and_clear_complete() argument
254 n = ep_to_bit(ci, n); in hw_test_and_clear_complete()
255 return hw_test_and_clear(ci, OP_ENDPTCOMPLETE, BIT(n)); in hw_test_and_clear_complete()
264 static u32 hw_test_and_clear_intr_active(struct ci_hdrc *ci) in hw_test_and_clear_intr_active() argument
266 u32 reg = hw_read_intr_status(ci) & hw_read_intr_enable(ci); in hw_test_and_clear_intr_active()
268 hw_write(ci, OP_USBSTS, ~0, reg); in hw_test_and_clear_intr_active()
278 static int hw_test_and_clear_setup_guard(struct ci_hdrc *ci) in hw_test_and_clear_setup_guard() argument
280 return hw_test_and_write(ci, OP_USBCMD, USBCMD_SUTW, 0); in hw_test_and_clear_setup_guard()
289 static int hw_test_and_set_setup_guard(struct ci_hdrc *ci) in hw_test_and_set_setup_guard() argument
291 return hw_test_and_write(ci, OP_USBCMD, USBCMD_SUTW, USBCMD_SUTW); in hw_test_and_set_setup_guard()
301 static void hw_usb_set_address(struct ci_hdrc *ci, u8 value) in hw_usb_set_address() argument
303 hw_write(ci, OP_DEVICEADDR, DEVICEADDR_USBADR, in hw_usb_set_address()
313 static int hw_usb_reset(struct ci_hdrc *ci) in hw_usb_reset() argument
315 hw_usb_set_address(ci, 0); in hw_usb_reset()
318 hw_write(ci, OP_ENDPTFLUSH, ~0, ~0); in hw_usb_reset()
321 hw_write(ci, OP_ENDPTSETUPSTAT, 0, 0); in hw_usb_reset()
324 hw_write(ci, OP_ENDPTCOMPLETE, 0, 0); in hw_usb_reset()
327 while (hw_read(ci, OP_ENDPTPRIME, ~0)) in hw_usb_reset()
414 struct ci_hdrc *ci = hwep->ci; in _hardware_enqueue() local
426 ret = usb_gadget_map_request(&ci->gadget, &hwreq->req, hwep->dir); in _hardware_enqueue()
485 if (hw_read(ci, OP_ENDPTPRIME, BIT(n))) in _hardware_enqueue()
488 hw_write(ci, OP_USBCMD, USBCMD_ATDTW, USBCMD_ATDTW); in _hardware_enqueue()
489 tmp_stat = hw_read(ci, OP_ENDPTSTAT, BIT(n)); in _hardware_enqueue()
490 } while (!hw_read(ci, OP_USBCMD, USBCMD_ATDTW)); in _hardware_enqueue()
491 hw_write(ci, OP_USBCMD, USBCMD_ATDTW, 0); in _hardware_enqueue()
510 ret = hw_ep_prime(ci, hwep->num, hwep->dir, in _hardware_enqueue()
529 static int reprime_dtd(struct ci_hdrc *ci, struct ci_hw_ep *hwep, in reprime_dtd() argument
536 return hw_ep_prime(ci, hwep->num, hwep->dir, in reprime_dtd()
553 struct ci_hdrc *ci = hwep->ci; in _hardware_dequeue() local
565 if (ci->rev == CI_REVISION_24) in _hardware_dequeue()
566 if (!hw_read(ci, OP_ENDPTSTAT, BIT(n))) in _hardware_dequeue()
567 reprime_dtd(ci, hwep, node); in _hardware_dequeue()
606 usb_gadget_unmap_request(&hwep->ci->gadget, &hwreq->req, hwep->dir); in _hardware_dequeue()
631 hw_ep_flush(hwep->ci, hwep->num, hwep->dir); in _ep_nuke()
685 retval |= hw_ep_set_halt(hwep->ci, hwep->num, hwep->dir, value); in _ep_set_halt()
709 struct ci_hdrc *ci = container_of(gadget, struct ci_hdrc, gadget); in _gadget_stop_activity() local
712 spin_lock_irqsave(&ci->lock, flags); in _gadget_stop_activity()
713 ci->gadget.speed = USB_SPEED_UNKNOWN; in _gadget_stop_activity()
714 ci->remote_wakeup = 0; in _gadget_stop_activity()
715 ci->suspended = 0; in _gadget_stop_activity()
716 spin_unlock_irqrestore(&ci->lock, flags); in _gadget_stop_activity()
722 usb_ep_fifo_flush(&ci->ep0out->ep); in _gadget_stop_activity()
723 usb_ep_fifo_flush(&ci->ep0in->ep); in _gadget_stop_activity()
730 if (ci->status != NULL) { in _gadget_stop_activity()
731 usb_ep_free_request(&ci->ep0in->ep, ci->status); in _gadget_stop_activity()
732 ci->status = NULL; in _gadget_stop_activity()
747 static void isr_reset_handler(struct ci_hdrc *ci) in isr_reset_handler() argument
748 __releases(ci->lock) in isr_reset_handler()
749 __acquires(ci->lock) in isr_reset_handler()
753 spin_unlock(&ci->lock); in isr_reset_handler()
754 if (ci->gadget.speed != USB_SPEED_UNKNOWN) in isr_reset_handler()
755 usb_gadget_udc_reset(&ci->gadget, ci->driver); in isr_reset_handler()
757 retval = _gadget_stop_activity(&ci->gadget); in isr_reset_handler()
761 retval = hw_usb_reset(ci); in isr_reset_handler()
765 ci->status = usb_ep_alloc_request(&ci->ep0in->ep, GFP_ATOMIC); in isr_reset_handler()
766 if (ci->status == NULL) in isr_reset_handler()
770 spin_lock(&ci->lock); in isr_reset_handler()
773 dev_err(ci->dev, "error: %i\n", retval); in isr_reset_handler()
806 struct ci_hdrc *ci = hwep->ci; in _ep_queue() local
814 hwep = (ci->ep0_dir == RX) ? in _ep_queue()
815 ci->ep0out : ci->ep0in; in _ep_queue()
818 dev_warn(hwep->ci->dev, "endpoint ctrl %X nuked\n", in _ep_queue()
825 dev_err(hwep->ci->dev, "request length too big for isochronous\n"); in _ep_queue()
831 dev_err(hwep->ci->dev, "request already in queue\n"); in _ep_queue()
856 static int isr_get_status_response(struct ci_hdrc *ci, in isr_get_status_response() argument
861 struct ci_hw_ep *hwep = ci->ep0in; in isr_get_status_response()
884 *(u16 *)req->buf = (ci->remote_wakeup << 1) | in isr_get_status_response()
885 ci->gadget.is_selfpowered; in isr_get_status_response()
891 *(u16 *)req->buf = hw_ep_get_halt(ci, num, dir); in isr_get_status_response()
921 struct ci_hdrc *ci = req->context; in isr_setup_status_complete() local
924 if (ci->setaddr) { in isr_setup_status_complete()
925 hw_usb_set_address(ci, ci->address); in isr_setup_status_complete()
926 ci->setaddr = false; in isr_setup_status_complete()
927 if (ci->address) in isr_setup_status_complete()
928 usb_gadget_set_state(&ci->gadget, USB_STATE_ADDRESS); in isr_setup_status_complete()
931 spin_lock_irqsave(&ci->lock, flags); in isr_setup_status_complete()
932 if (ci->test_mode) in isr_setup_status_complete()
933 hw_port_test_set(ci, ci->test_mode); in isr_setup_status_complete()
934 spin_unlock_irqrestore(&ci->lock, flags); in isr_setup_status_complete()
943 static int isr_setup_status_phase(struct ci_hdrc *ci) in isr_setup_status_phase() argument
954 if (WARN_ON_ONCE(!ci->status)) in isr_setup_status_phase()
957 hwep = (ci->ep0_dir == TX) ? ci->ep0out : ci->ep0in; in isr_setup_status_phase()
958 ci->status->context = ci; in isr_setup_status_phase()
959 ci->status->complete = isr_setup_status_complete; in isr_setup_status_phase()
961 retval = _ep_queue(&hwep->ep, ci->status, GFP_ATOMIC); in isr_setup_status_phase()
991 hweptemp = hwep->ci->ep0in; in isr_tr_complete_low()
1003 static int otg_a_alt_hnp_support(struct ci_hdrc *ci) in otg_a_alt_hnp_support() argument
1005 dev_warn(&ci->gadget.dev, in otg_a_alt_hnp_support()
1007 return isr_setup_status_phase(ci); in otg_a_alt_hnp_support()
1016 static void isr_setup_packet_handler(struct ci_hdrc *ci) in isr_setup_packet_handler() argument
1017 __releases(ci->lock) in isr_setup_packet_handler()
1018 __acquires(ci->lock) in isr_setup_packet_handler()
1020 struct ci_hw_ep *hwep = &ci->ci_hw_ep[0]; in isr_setup_packet_handler()
1029 _ep_nuke(ci->ep0out); in isr_setup_packet_handler()
1030 _ep_nuke(ci->ep0in); in isr_setup_packet_handler()
1034 hw_test_and_set_setup_guard(ci); in isr_setup_packet_handler()
1036 } while (!hw_test_and_clear_setup_guard(ci)); in isr_setup_packet_handler()
1040 ci->ep0_dir = (type & USB_DIR_IN) ? TX : RX; in isr_setup_packet_handler()
1053 num += ci->hw_ep_max / 2; in isr_setup_packet_handler()
1054 if (!ci->ci_hw_ep[num].wedge) { in isr_setup_packet_handler()
1055 spin_unlock(&ci->lock); in isr_setup_packet_handler()
1057 &ci->ci_hw_ep[num].ep); in isr_setup_packet_handler()
1058 spin_lock(&ci->lock); in isr_setup_packet_handler()
1062 err = isr_setup_status_phase(ci); in isr_setup_packet_handler()
1068 ci->remote_wakeup = 0; in isr_setup_packet_handler()
1069 err = isr_setup_status_phase(ci); in isr_setup_packet_handler()
1083 err = isr_get_status_response(ci, &req); in isr_setup_packet_handler()
1091 ci->address = (u8)le16_to_cpu(req.wValue); in isr_setup_packet_handler()
1092 ci->setaddr = true; in isr_setup_packet_handler()
1093 err = isr_setup_status_phase(ci); in isr_setup_packet_handler()
1105 num += ci->hw_ep_max / 2; in isr_setup_packet_handler()
1107 spin_unlock(&ci->lock); in isr_setup_packet_handler()
1108 err = _ep_set_halt(&ci->ci_hw_ep[num].ep, 1, false); in isr_setup_packet_handler()
1109 spin_lock(&ci->lock); in isr_setup_packet_handler()
1111 isr_setup_status_phase(ci); in isr_setup_packet_handler()
1117 ci->remote_wakeup = 1; in isr_setup_packet_handler()
1118 err = isr_setup_status_phase(ci); in isr_setup_packet_handler()
1128 ci->test_mode = tmode; in isr_setup_packet_handler()
1130 ci); in isr_setup_packet_handler()
1137 if (ci_otg_is_fsm_mode(ci)) { in isr_setup_packet_handler()
1138 ci->gadget.b_hnp_enable = 1; in isr_setup_packet_handler()
1140 ci); in isr_setup_packet_handler()
1144 if (ci_otg_is_fsm_mode(ci)) in isr_setup_packet_handler()
1145 err = otg_a_alt_hnp_support(ci); in isr_setup_packet_handler()
1148 if (ci_otg_is_fsm_mode(ci)) { in isr_setup_packet_handler()
1149 ci->gadget.a_hnp_support = 1; in isr_setup_packet_handler()
1151 ci); in isr_setup_packet_handler()
1164 ci->ep0_dir = TX; in isr_setup_packet_handler()
1166 spin_unlock(&ci->lock); in isr_setup_packet_handler()
1167 err = ci->driver->setup(&ci->gadget, &req); in isr_setup_packet_handler()
1168 spin_lock(&ci->lock); in isr_setup_packet_handler()
1173 spin_unlock(&ci->lock); in isr_setup_packet_handler()
1175 dev_err(ci->dev, "error: _ep_set_halt\n"); in isr_setup_packet_handler()
1176 spin_lock(&ci->lock); in isr_setup_packet_handler()
1186 static void isr_tr_complete_handler(struct ci_hdrc *ci) in isr_tr_complete_handler() argument
1187 __releases(ci->lock) in isr_tr_complete_handler()
1188 __acquires(ci->lock) in isr_tr_complete_handler()
1193 for (i = 0; i < ci->hw_ep_max; i++) { in isr_tr_complete_handler()
1194 struct ci_hw_ep *hwep = &ci->ci_hw_ep[i]; in isr_tr_complete_handler()
1199 if (hw_test_and_clear_complete(ci, i)) { in isr_tr_complete_handler()
1203 err = isr_setup_status_phase(ci); in isr_tr_complete_handler()
1205 spin_unlock(&ci->lock); in isr_tr_complete_handler()
1207 dev_err(ci->dev, in isr_tr_complete_handler()
1209 spin_lock(&ci->lock); in isr_tr_complete_handler()
1216 hw_test_and_clear(ci, OP_ENDPTSETUPSTAT, BIT(0))) in isr_tr_complete_handler()
1217 isr_setup_packet_handler(ci); in isr_tr_complete_handler()
1245 dev_warn(hwep->ci->dev, "enabling a non-empty endpoint!\n"); in ep_enable()
1276 dev_err(hwep->ci->dev, "Set control xfer at non-ep0\n"); in ep_enable()
1285 retval |= hw_ep_enable(hwep->ci, hwep->num, hwep->dir, in ep_enable()
1315 retval |= hw_ep_disable(hwep->ci, hwep->num, hwep->dir); in ep_disable()
1364 dev_err(hwep->ci->dev, "freeing queued request\n"); in ep_free_request()
1422 hw_ep_flush(hwep->ci, hwep->num, hwep->dir); in ep_dequeue()
1433 usb_gadget_unmap_request(&hwep->ci->gadget, req, hwep->dir); in ep_dequeue()
1488 dev_err(hwep->ci->dev, "%02X: -EINVAL\n", _usb_addr(hwep)); in ep_fifo_flush()
1494 hw_ep_flush(hwep->ci, hwep->num, hwep->dir); in ep_fifo_flush()
1520 struct ci_hdrc *ci = container_of(_gadget, struct ci_hdrc, gadget); in ci_udc_vbus_session() local
1524 spin_lock_irqsave(&ci->lock, flags); in ci_udc_vbus_session()
1525 ci->vbus_active = is_active; in ci_udc_vbus_session()
1526 if (ci->driver) in ci_udc_vbus_session()
1528 spin_unlock_irqrestore(&ci->lock, flags); in ci_udc_vbus_session()
1533 hw_device_reset(ci); in ci_udc_vbus_session()
1534 hw_device_state(ci, ci->ep0out->qh.dma); in ci_udc_vbus_session()
1539 if (ci->driver) in ci_udc_vbus_session()
1540 ci->driver->disconnect(&ci->gadget); in ci_udc_vbus_session()
1541 hw_device_state(ci, 0); in ci_udc_vbus_session()
1542 if (ci->platdata->notify_event) in ci_udc_vbus_session()
1543 ci->platdata->notify_event(ci, in ci_udc_vbus_session()
1545 _gadget_stop_activity(&ci->gadget); in ci_udc_vbus_session()
1556 struct ci_hdrc *ci = container_of(_gadget, struct ci_hdrc, gadget); in ci_udc_wakeup() local
1560 spin_lock_irqsave(&ci->lock, flags); in ci_udc_wakeup()
1561 if (!ci->remote_wakeup) { in ci_udc_wakeup()
1565 if (!hw_read(ci, OP_PORTSC, PORTSC_SUSP)) { in ci_udc_wakeup()
1569 hw_write(ci, OP_PORTSC, PORTSC_FPR, PORTSC_FPR); in ci_udc_wakeup()
1571 spin_unlock_irqrestore(&ci->lock, flags); in ci_udc_wakeup()
1577 struct ci_hdrc *ci = container_of(_gadget, struct ci_hdrc, gadget); in ci_udc_vbus_draw() local
1579 if (ci->usb_phy) in ci_udc_vbus_draw()
1580 return usb_phy_set_power(ci->usb_phy, ma); in ci_udc_vbus_draw()
1586 struct ci_hdrc *ci = container_of(_gadget, struct ci_hdrc, gadget); in ci_udc_selfpowered() local
1587 struct ci_hw_ep *hwep = ci->ep0in; in ci_udc_selfpowered()
1602 struct ci_hdrc *ci = container_of(_gadget, struct ci_hdrc, gadget); in ci_udc_pullup() local
1608 if (ci_otg_is_fsm_mode(ci) || ci->role == CI_ROLE_HOST) in ci_udc_pullup()
1611 pm_runtime_get_sync(&ci->gadget.dev); in ci_udc_pullup()
1613 hw_write(ci, OP_USBCMD, USBCMD_RS, USBCMD_RS); in ci_udc_pullup()
1615 hw_write(ci, OP_USBCMD, USBCMD_RS, 0); in ci_udc_pullup()
1616 pm_runtime_put_sync(&ci->gadget.dev); in ci_udc_pullup()
1639 static int init_eps(struct ci_hdrc *ci) in init_eps() argument
1643 for (i = 0; i < ci->hw_ep_max/2; i++) in init_eps()
1645 int k = i + j * ci->hw_ep_max/2; in init_eps()
1646 struct ci_hw_ep *hwep = &ci->ci_hw_ep[k]; in init_eps()
1651 hwep->ci = ci; in init_eps()
1652 hwep->lock = &ci->lock; in init_eps()
1653 hwep->td_pool = ci->td_pool; in init_eps()
1679 hwep->qh.ptr = dma_pool_zalloc(ci->qh_pool, GFP_KERNEL, in init_eps()
1690 ci->ep0out = hwep; in init_eps()
1692 ci->ep0in = hwep; in init_eps()
1698 list_add_tail(&hwep->ep.ep_list, &ci->gadget.ep_list); in init_eps()
1704 static void destroy_eps(struct ci_hdrc *ci) in destroy_eps() argument
1708 for (i = 0; i < ci->hw_ep_max; i++) { in destroy_eps()
1709 struct ci_hw_ep *hwep = &ci->ci_hw_ep[i]; in destroy_eps()
1713 dma_pool_free(ci->qh_pool, hwep->qh.ptr, hwep->qh.dma); in destroy_eps()
1727 struct ci_hdrc *ci = container_of(gadget, struct ci_hdrc, gadget); in ci_udc_start() local
1735 ci->ep0out->ep.desc = &ctrl_endpt_out_desc; in ci_udc_start()
1736 retval = usb_ep_enable(&ci->ep0out->ep); in ci_udc_start()
1740 ci->ep0in->ep.desc = &ctrl_endpt_in_desc; in ci_udc_start()
1741 retval = usb_ep_enable(&ci->ep0in->ep); in ci_udc_start()
1745 ci->driver = driver; in ci_udc_start()
1748 if (ci_otg_is_fsm_mode(ci) && ci->fsm.id) { in ci_udc_start()
1749 ci_hdrc_otg_fsm_start(ci); in ci_udc_start()
1753 pm_runtime_get_sync(&ci->gadget.dev); in ci_udc_start()
1754 if (ci->vbus_active) { in ci_udc_start()
1755 spin_lock_irqsave(&ci->lock, flags); in ci_udc_start()
1756 hw_device_reset(ci); in ci_udc_start()
1758 usb_udc_vbus_handler(&ci->gadget, false); in ci_udc_start()
1759 pm_runtime_put_sync(&ci->gadget.dev); in ci_udc_start()
1763 retval = hw_device_state(ci, ci->ep0out->qh.dma); in ci_udc_start()
1764 spin_unlock_irqrestore(&ci->lock, flags); in ci_udc_start()
1766 pm_runtime_put_sync(&ci->gadget.dev); in ci_udc_start()
1771 static void ci_udc_stop_for_otg_fsm(struct ci_hdrc *ci) in ci_udc_stop_for_otg_fsm() argument
1773 if (!ci_otg_is_fsm_mode(ci)) in ci_udc_stop_for_otg_fsm()
1776 mutex_lock(&ci->fsm.lock); in ci_udc_stop_for_otg_fsm()
1777 if (ci->fsm.otg->state == OTG_STATE_A_PERIPHERAL) { in ci_udc_stop_for_otg_fsm()
1778 ci->fsm.a_bidl_adis_tmout = 1; in ci_udc_stop_for_otg_fsm()
1779 ci_hdrc_otg_fsm_start(ci); in ci_udc_stop_for_otg_fsm()
1780 } else if (ci->fsm.otg->state == OTG_STATE_B_PERIPHERAL) { in ci_udc_stop_for_otg_fsm()
1781 ci->fsm.protocol = PROTO_UNDEF; in ci_udc_stop_for_otg_fsm()
1782 ci->fsm.otg->state = OTG_STATE_UNDEFINED; in ci_udc_stop_for_otg_fsm()
1784 mutex_unlock(&ci->fsm.lock); in ci_udc_stop_for_otg_fsm()
1792 struct ci_hdrc *ci = container_of(gadget, struct ci_hdrc, gadget); in ci_udc_stop() local
1795 spin_lock_irqsave(&ci->lock, flags); in ci_udc_stop()
1797 if (ci->vbus_active) { in ci_udc_stop()
1798 hw_device_state(ci, 0); in ci_udc_stop()
1799 if (ci->platdata->notify_event) in ci_udc_stop()
1800 ci->platdata->notify_event(ci, in ci_udc_stop()
1802 spin_unlock_irqrestore(&ci->lock, flags); in ci_udc_stop()
1803 _gadget_stop_activity(&ci->gadget); in ci_udc_stop()
1804 spin_lock_irqsave(&ci->lock, flags); in ci_udc_stop()
1805 pm_runtime_put(&ci->gadget.dev); in ci_udc_stop()
1808 ci->driver = NULL; in ci_udc_stop()
1809 spin_unlock_irqrestore(&ci->lock, flags); in ci_udc_stop()
1811 ci_udc_stop_for_otg_fsm(ci); in ci_udc_stop()
1824 static irqreturn_t udc_irq(struct ci_hdrc *ci) in udc_irq() argument
1829 if (ci == NULL) in udc_irq()
1832 spin_lock(&ci->lock); in udc_irq()
1834 if (ci->platdata->flags & CI_HDRC_REGS_SHARED) { in udc_irq()
1835 if (hw_read(ci, OP_USBMODE, USBMODE_CM) != in udc_irq()
1837 spin_unlock(&ci->lock); in udc_irq()
1841 intr = hw_test_and_clear_intr_active(ci); in udc_irq()
1846 isr_reset_handler(ci); in udc_irq()
1849 ci->gadget.speed = hw_port_is_high_speed(ci) ? in udc_irq()
1851 if (ci->suspended && ci->driver->resume) { in udc_irq()
1852 spin_unlock(&ci->lock); in udc_irq()
1853 ci->driver->resume(&ci->gadget); in udc_irq()
1854 spin_lock(&ci->lock); in udc_irq()
1855 ci->suspended = 0; in udc_irq()
1860 isr_tr_complete_handler(ci); in udc_irq()
1863 if (ci->gadget.speed != USB_SPEED_UNKNOWN && in udc_irq()
1864 ci->driver->suspend) { in udc_irq()
1865 ci->suspended = 1; in udc_irq()
1866 spin_unlock(&ci->lock); in udc_irq()
1867 ci->driver->suspend(&ci->gadget); in udc_irq()
1868 usb_gadget_set_state(&ci->gadget, in udc_irq()
1870 spin_lock(&ci->lock); in udc_irq()
1877 spin_unlock(&ci->lock); in udc_irq()
1886 static int udc_start(struct ci_hdrc *ci) in udc_start() argument
1888 struct device *dev = ci->dev; in udc_start()
1889 struct usb_otg_caps *otg_caps = &ci->platdata->ci_otg_caps; in udc_start()
1892 ci->gadget.ops = &usb_gadget_ops; in udc_start()
1893 ci->gadget.speed = USB_SPEED_UNKNOWN; in udc_start()
1894 ci->gadget.max_speed = USB_SPEED_HIGH; in udc_start()
1895 ci->gadget.name = ci->platdata->name; in udc_start()
1896 ci->gadget.otg_caps = otg_caps; in udc_start()
1898 if (ci->is_otg && (otg_caps->hnp_support || otg_caps->srp_support || in udc_start()
1900 ci->gadget.is_otg = 1; in udc_start()
1902 INIT_LIST_HEAD(&ci->gadget.ep_list); in udc_start()
1905 ci->qh_pool = dma_pool_create("ci_hw_qh", dev, in udc_start()
1908 if (ci->qh_pool == NULL) in udc_start()
1911 ci->td_pool = dma_pool_create("ci_hw_td", dev, in udc_start()
1914 if (ci->td_pool == NULL) { in udc_start()
1919 retval = init_eps(ci); in udc_start()
1923 ci->gadget.ep0 = &ci->ep0in->ep; in udc_start()
1925 retval = usb_add_gadget_udc(dev, &ci->gadget); in udc_start()
1929 pm_runtime_no_callbacks(&ci->gadget.dev); in udc_start()
1930 pm_runtime_enable(&ci->gadget.dev); in udc_start()
1935 destroy_eps(ci); in udc_start()
1937 dma_pool_destroy(ci->td_pool); in udc_start()
1939 dma_pool_destroy(ci->qh_pool); in udc_start()
1948 void ci_hdrc_gadget_destroy(struct ci_hdrc *ci) in ci_hdrc_gadget_destroy() argument
1950 if (!ci->roles[CI_ROLE_GADGET]) in ci_hdrc_gadget_destroy()
1953 usb_del_gadget_udc(&ci->gadget); in ci_hdrc_gadget_destroy()
1955 destroy_eps(ci); in ci_hdrc_gadget_destroy()
1957 dma_pool_destroy(ci->td_pool); in ci_hdrc_gadget_destroy()
1958 dma_pool_destroy(ci->qh_pool); in ci_hdrc_gadget_destroy()
1961 static int udc_id_switch_for_device(struct ci_hdrc *ci) in udc_id_switch_for_device() argument
1963 if (ci->is_otg) in udc_id_switch_for_device()
1965 hw_write_otgsc(ci, OTGSC_BSVIS | OTGSC_BSVIE, in udc_id_switch_for_device()
1971 static void udc_id_switch_for_host(struct ci_hdrc *ci) in udc_id_switch_for_host() argument
1977 if (ci->is_otg) in udc_id_switch_for_host()
1978 hw_write_otgsc(ci, OTGSC_BSVIE | OTGSC_BSVIS, OTGSC_BSVIS); in udc_id_switch_for_host()
1987 int ci_hdrc_gadget_init(struct ci_hdrc *ci) in ci_hdrc_gadget_init() argument
1992 if (!hw_read(ci, CAP_DCCPARAMS, DCCPARAMS_DC)) in ci_hdrc_gadget_init()
1995 rdrv = devm_kzalloc(ci->dev, sizeof(*rdrv), GFP_KERNEL); in ci_hdrc_gadget_init()
2004 ret = udc_start(ci); in ci_hdrc_gadget_init()
2006 ci->roles[CI_ROLE_GADGET] = rdrv; in ci_hdrc_gadget_init()