Lines Matching +full:ctrl +full:- +full:b
1 // SPDX-License-Identifier: GPL-1.0+
10 #include <linux/dma-mapping.h>
61 struct usb_ctrlrequest *ctrl);
63 struct usb_ctrlrequest *ctrl);
65 struct usb_ctrlrequest *ctrl);
78 ((i) < (g)->uep_size) && ((pos) = (g)->uep + (i)); \
94 #define usbhsg_gpriv_to_dev(gp) usbhs_priv_to_dev((gp)->mod.priv)
95 #define usbhsg_gpriv_to_priv(gp) ((gp)->mod.priv)
96 #define usbhsg_gpriv_to_dcp(gp) ((gp)->uep)
97 #define usbhsg_gpriv_to_nth_uep(gp, i) ((gp)->uep + i)
98 #define usbhsg_uep_to_gpriv(u) ((u)->gpriv)
99 #define usbhsg_uep_to_pipe(u) ((u)->pipe)
100 #define usbhsg_pipe_to_uep(p) ((p)->mod_private)
101 #define usbhsg_is_dcp(u) ((u) == usbhsg_gpriv_to_dcp((u)->gpriv))
103 #define usbhsg_ureq_to_pkt(u) (&(u)->pkt)
107 #define usbhsg_is_not_connected(gp) ((gp)->gadget.speed == USB_SPEED_UNKNOWN)
110 #define usbhsg_status_init(gp) do {(gp)->status = 0; } while (0)
111 #define usbhsg_status_set(gp, b) (gp->status |= b) argument
112 #define usbhsg_status_clr(gp, b) (gp->status &= ~b) argument
113 #define usbhsg_status_has(gp, b) (gp->status & b) argument
130 ureq->req.status = status; in __usbhsg_queue_pop()
132 usb_gadget_giveback_request(&uep->ep, &ureq->req); in __usbhsg_queue_pop()
151 struct usbhs_pipe *pipe = pkt->pipe; in usbhsg_queue_done()
156 ureq->req.actual = pkt->actual; in usbhsg_queue_done()
171 struct usb_request *req = &ureq->req; in usbhsg_queue_push()
173 req->actual = 0; in usbhsg_queue_push()
174 req->status = -EINPROGRESS; in usbhsg_queue_push()
176 req->buf, req->length, req->zero, -1); in usbhsg_queue_push()
181 req->length); in usbhsg_queue_push()
191 struct usb_request *req = &ureq->req; in usbhsg_dma_map_ctrl()
192 struct usbhs_pipe *pipe = pkt->pipe; in usbhsg_dma_map_ctrl()
200 WARN_ON(req->num_sgs); in usbhsg_dma_map_ctrl()
206 pkt->dma = req->dma; in usbhsg_dma_map_ctrl()
219 struct usb_ctrlrequest *ctrl) in usbhsg_recip_handler_std_control_done() argument
232 struct usb_ctrlrequest *ctrl) in usbhsg_recip_handler_std_clear_endpoint() argument
243 usbhsg_recip_handler_std_control_done(priv, uep, ctrl); in usbhsg_recip_handler_std_clear_endpoint()
262 struct usb_ctrlrequest *ctrl) in usbhsg_recip_handler_std_set_device() argument
264 switch (le16_to_cpu(ctrl->wValue)) { in usbhsg_recip_handler_std_set_device()
266 usbhsg_recip_handler_std_control_done(priv, uep, ctrl); in usbhsg_recip_handler_std_set_device()
268 usbhs_sys_set_test_mode(priv, le16_to_cpu(ctrl->wIndex) >> 8); in usbhsg_recip_handler_std_set_device()
271 usbhsg_recip_handler_std_control_done(priv, uep, ctrl); in usbhsg_recip_handler_std_set_device()
280 struct usb_ctrlrequest *ctrl) in usbhsg_recip_handler_std_set_endpoint() argument
286 usbhsg_recip_handler_std_control_done(priv, uep, ctrl); in usbhsg_recip_handler_std_set_endpoint()
306 /* free allocated recip-buffer/usb_request */ in __usbhsg_recip_send_complete()
307 kfree(ureq->pkt.buf); in __usbhsg_recip_send_complete()
321 req = usb_ep_alloc_request(&dcp->ep, GFP_ATOMIC); in __usbhsg_recip_send_status()
330 usb_ep_free_request(&dcp->ep, req); in __usbhsg_recip_send_status()
338 req->complete = __usbhsg_recip_send_complete; in __usbhsg_recip_send_status()
339 req->buf = buf; in __usbhsg_recip_send_status()
340 req->length = sizeof(*buf); in __usbhsg_recip_send_status()
341 req->zero = 0; in __usbhsg_recip_send_status()
344 pipe->handler = &usbhs_fifo_pio_push_handler; in __usbhsg_recip_send_status()
350 struct usb_ctrlrequest *ctrl) in usbhsg_recip_handler_std_get_device() argument
365 struct usb_ctrlrequest *ctrl) in usbhsg_recip_handler_std_get_interface() argument
377 struct usb_ctrlrequest *ctrl) in usbhsg_recip_handler_std_get_endpoint() argument
403 struct usb_ctrlrequest *ctrl) in usbhsg_recip_run_handle() argument
409 int recip = ctrl->bRequestType & USB_RECIP_MASK; in usbhsg_recip_run_handle()
410 int nth = le16_to_cpu(ctrl->wIndex) & USB_ENDPOINT_NUMBER_MASK; in usbhsg_recip_run_handle()
413 struct usb_ctrlrequest *ctrl); in usbhsg_recip_run_handle()
420 return -EINVAL; in usbhsg_recip_run_handle()
426 func = handler->device; in usbhsg_recip_run_handle()
430 func = handler->interface; in usbhsg_recip_run_handle()
434 func = handler->endpoint; in usbhsg_recip_run_handle()
439 ret = -EINVAL; in usbhsg_recip_run_handle()
443 dev_dbg(dev, "%s (pipe %d :%s)\n", handler->name, nth, msg); in usbhsg_recip_run_handle()
444 ret = func(priv, uep, ctrl); in usbhsg_recip_run_handle()
462 gpriv->gadget.speed = usbhs_bus_get_speed(priv); in usbhsg_irq_dev_state()
464 dev_dbg(dev, "state = %x : speed : %d\n", state, gpriv->gadget.speed); in usbhsg_irq_dev_state()
466 if (gpriv->gadget.speed != USB_SPEED_UNKNOWN && in usbhsg_irq_dev_state()
468 if (gpriv->driver && gpriv->driver->suspend) in usbhsg_irq_dev_state()
469 gpriv->driver->suspend(&gpriv->gadget); in usbhsg_irq_dev_state()
470 usb_gadget_set_state(&gpriv->gadget, USB_STATE_SUSPENDED); in usbhsg_irq_dev_state()
483 struct usb_ctrlrequest ctrl; in usbhsg_irq_ctrl_stage() local
494 * - "Interrupt Function" in usbhsg_irq_ctrl_stage()
495 * - "Control Transfer Stage Transition Interrupt" in usbhsg_irq_ctrl_stage()
496 * - Fig. "Control Transfer Stage Transitions" in usbhsg_irq_ctrl_stage()
501 pipe->handler = &usbhs_fifo_pio_push_handler; in usbhsg_irq_ctrl_stage()
504 pipe->handler = &usbhs_fifo_pio_pop_handler; in usbhsg_irq_ctrl_stage()
507 pipe->handler = &usbhs_ctrl_stage_end_handler; in usbhsg_irq_ctrl_stage()
520 usbhs_usbreq_get_val(priv, &ctrl); in usbhsg_irq_ctrl_stage()
522 switch (ctrl.bRequestType & USB_TYPE_MASK) { in usbhsg_irq_ctrl_stage()
524 switch (ctrl.bRequest) { in usbhsg_irq_ctrl_stage()
541 ret = usbhsg_recip_run_handle(priv, recip_handler, &ctrl); in usbhsg_irq_ctrl_stage()
543 ret = gpriv->driver->setup(&gpriv->gadget, &ctrl); in usbhsg_irq_ctrl_stage()
566 usbhsg_queue_pop(uep, usbhsg_pkt_to_ureq(pkt), -ESHUTDOWN); in usbhsg_pipe_disable()
586 int ret = -EIO; in usbhsg_ep_enable()
595 if (uep->pipe) { in usbhsg_ep_enable()
596 usbhs_pipe_clear(uep->pipe); in usbhsg_ep_enable()
597 usbhs_pipe_sequence_data0(uep->pipe); in usbhsg_ep_enable()
606 uep->pipe = pipe; in usbhsg_ep_enable()
607 pipe->mod_private = uep; in usbhsg_ep_enable()
620 pipe->handler = &usbhs_fifo_dma_push_handler; in usbhsg_ep_enable()
622 pipe->handler = &usbhs_fifo_dma_pop_handler; in usbhsg_ep_enable()
642 spin_lock_irqsave(&uep->lock, flags); in usbhsg_ep_disable()
650 uep->pipe->mod_private = NULL; in usbhsg_ep_disable()
651 uep->pipe = NULL; in usbhsg_ep_disable()
654 spin_unlock_irqrestore(&uep->lock, flags); in usbhsg_ep_disable()
670 return &ureq->req; in usbhsg_ep_alloc_request()
678 WARN_ON(!list_empty(&ureq->pkt.node)); in usbhsg_ep_free_request()
692 unlikely(!gpriv->driver) || in usbhsg_ep_queue()
694 return -ESHUTDOWN; in usbhsg_ep_queue()
708 spin_lock_irqsave(&uep->lock, flags); in usbhsg_ep_dequeue()
717 usbhsg_queue_pop(uep, ureq, -ECONNRESET); in usbhsg_ep_dequeue()
718 spin_unlock_irqrestore(&uep->lock, flags); in usbhsg_ep_dequeue()
741 * return -EAGAIN if the IN endpoint has any queue or data. Note in __usbhsg_ep_set_halt_wedge()
747 ret = -EAGAIN; in __usbhsg_ep_set_halt_wedge()
799 return gpriv->driver && in usbhsg_can_pullup()
829 ret = -1; /* not ready */ in usbhsg_try_start()
850 dcp->pipe = usbhs_dcp_malloc(priv); in usbhsg_try_start()
851 dcp->pipe->mod_private = dcp; in usbhsg_try_start()
852 usbhs_pipe_config_update(dcp->pipe, 0, 0, 64); in usbhsg_try_start()
856 * - HI speed in usbhsg_try_start()
857 * - function in usbhsg_try_start()
858 * - usb module in usbhsg_try_start()
866 mod->irq_dev_state = usbhsg_irq_dev_state; in usbhsg_try_start()
867 mod->irq_ctrl_stage = usbhsg_irq_ctrl_stage; in usbhsg_try_start()
888 ret = -1; /* already done */ in usbhsg_try_stop()
902 mod->irq_dev_state = NULL; in usbhsg_try_stop()
903 mod->irq_ctrl_stage = NULL; in usbhsg_try_stop()
906 gpriv->gadget.speed = USB_SPEED_UNKNOWN; in usbhsg_try_stop()
914 usbhsg_ep_disable(&uep->ep); in usbhsg_try_stop()
929 return gpriv->vbus_active; in usbhsm_phy_get_vbus()
934 struct usbhs_mod_info *info = &priv->mod_info; in usbhs_mod_phy_mode()
936 info->irq_vbus = NULL; in usbhs_mod_phy_mode()
937 info->get_vbus = usbhsm_phy_get_vbus; in usbhs_mod_phy_mode()
956 !driver->setup || in usbhsg_gadget_start()
957 driver->max_speed < USB_SPEED_FULL) in usbhsg_gadget_start()
958 return -EINVAL; in usbhsg_gadget_start()
961 if (!IS_ERR_OR_NULL(gpriv->transceiver)) { in usbhsg_gadget_start()
962 ret = otg_set_peripheral(gpriv->transceiver->otg, in usbhsg_gadget_start()
963 &gpriv->gadget); in usbhsg_gadget_start()
966 gpriv->gadget.name); in usbhsg_gadget_start()
975 gpriv->driver = driver; in usbhsg_gadget_start()
987 if (!IS_ERR_OR_NULL(gpriv->transceiver)) in usbhsg_gadget_stop()
988 otg_set_peripheral(gpriv->transceiver->otg, NULL); in usbhsg_gadget_stop()
990 gpriv->driver = NULL; in usbhsg_gadget_stop()
1032 gadget->is_selfpowered = (is_self != 0); in usbhsg_set_selfpowered()
1043 gpriv->vbus_active = !!is_active; in usbhsg_vbus_session()
1069 if (gpriv->driver && in usbhsg_stop()
1070 gpriv->driver->disconnect) in usbhsg_stop()
1071 gpriv->driver->disconnect(&gpriv->gadget); in usbhsg_stop()
1089 return -ENOMEM; in usbhs_mod_gadget_probe()
1093 ret = -ENOMEM; in usbhs_mod_gadget_probe()
1097 gpriv->transceiver = devm_usb_get_phy(dev, USB_PHY_TYPE_UNDEFINED); in usbhs_mod_gadget_probe()
1099 !IS_ERR(gpriv->transceiver) ? "" : "no "); in usbhs_mod_gadget_probe()
1112 usbhs_mod_register(priv, &gpriv->mod, USBHS_GADGET); in usbhs_mod_gadget_probe()
1115 gpriv->mod.name = "gadget"; in usbhs_mod_gadget_probe()
1116 gpriv->mod.start = usbhsg_start; in usbhs_mod_gadget_probe()
1117 gpriv->mod.stop = usbhsg_stop; in usbhs_mod_gadget_probe()
1118 gpriv->uep = uep; in usbhs_mod_gadget_probe()
1119 gpriv->uep_size = pipe_size; in usbhs_mod_gadget_probe()
1125 gpriv->gadget.dev.parent = dev; in usbhs_mod_gadget_probe()
1126 gpriv->gadget.name = "renesas_usbhs_udc"; in usbhs_mod_gadget_probe()
1127 gpriv->gadget.ops = &usbhsg_gadget_ops; in usbhs_mod_gadget_probe()
1128 gpriv->gadget.max_speed = USB_SPEED_HIGH; in usbhs_mod_gadget_probe()
1129 gpriv->gadget.quirk_avoids_skb_reserve = usbhs_get_dparam(priv, in usbhs_mod_gadget_probe()
1132 INIT_LIST_HEAD(&gpriv->gadget.ep_list); in usbhs_mod_gadget_probe()
1138 uep->gpriv = gpriv; in usbhs_mod_gadget_probe()
1139 uep->pipe = NULL; in usbhs_mod_gadget_probe()
1140 snprintf(uep->ep_name, EP_NAME_SIZE, "ep%d", i); in usbhs_mod_gadget_probe()
1142 uep->ep.name = uep->ep_name; in usbhs_mod_gadget_probe()
1143 uep->ep.ops = &usbhsg_ep_ops; in usbhs_mod_gadget_probe()
1144 INIT_LIST_HEAD(&uep->ep.ep_list); in usbhs_mod_gadget_probe()
1145 spin_lock_init(&uep->lock); in usbhs_mod_gadget_probe()
1149 gpriv->gadget.ep0 = &uep->ep; in usbhs_mod_gadget_probe()
1150 usb_ep_set_maxpacket_limit(&uep->ep, 64); in usbhs_mod_gadget_probe()
1151 uep->ep.caps.type_control = true; in usbhs_mod_gadget_probe()
1155 uep->ep.caps.type_iso = true; in usbhs_mod_gadget_probe()
1157 uep->ep.caps.type_bulk = true; in usbhs_mod_gadget_probe()
1159 uep->ep.caps.type_int = true; in usbhs_mod_gadget_probe()
1160 usb_ep_set_maxpacket_limit(&uep->ep, in usbhs_mod_gadget_probe()
1162 list_add_tail(&uep->ep.ep_list, &gpriv->gadget.ep_list); in usbhs_mod_gadget_probe()
1164 uep->ep.caps.dir_in = true; in usbhs_mod_gadget_probe()
1165 uep->ep.caps.dir_out = true; in usbhs_mod_gadget_probe()
1168 ret = usb_add_gadget_udc(dev, &gpriv->gadget); in usbhs_mod_gadget_probe()
1178 kfree(gpriv->uep); in usbhs_mod_gadget_probe()
1190 usb_del_gadget_udc(&gpriv->gadget); in usbhs_mod_gadget_remove()
1192 kfree(gpriv->uep); in usbhs_mod_gadget_remove()