Lines Matching +full:wakeup +full:- +full:capable

1 // SPDX-License-Identifier: GPL-2.0
15 #include "cdnsp-gadget.h"
16 #include "cdnsp-trace.h"
23 pep = &pdev->eps[0]; in cdnsp_ep0_stall()
24 preq = next_request(&pep->pending_list); in cdnsp_ep0_stall()
26 if (pdev->three_stage_setup) { in cdnsp_ep0_stall()
30 cdnsp_gadget_giveback(pep, preq, -ECONNRESET); in cdnsp_ep0_stall()
32 pep->ep_state |= EP0_HALTED_STATUS; in cdnsp_ep0_stall()
35 list_del(&preq->list); in cdnsp_ep0_stall()
46 spin_unlock(&pdev->lock); in cdnsp_ep0_delegate_req()
47 ret = pdev->gadget_driver->setup(&pdev->gadget, ctrl); in cdnsp_ep0_delegate_req()
48 spin_lock(&pdev->lock); in cdnsp_ep0_delegate_req()
56 enum usb_device_state state = pdev->gadget.state; in cdnsp_ep0_set_config()
60 cfg = le16_to_cpu(ctrl->wValue); in cdnsp_ep0_set_config()
70 dev_err(pdev->dev, "Set Configuration - bad device state\n"); in cdnsp_ep0_set_config()
71 return -EINVAL; in cdnsp_ep0_set_config()
79 usb_gadget_set_state(&pdev->gadget, USB_STATE_ADDRESS); in cdnsp_ep0_set_config()
87 enum usb_device_state state = pdev->gadget.state; in cdnsp_ep0_set_address()
93 addr = le16_to_cpu(ctrl->wValue); in cdnsp_ep0_set_address()
96 dev_err(pdev->dev, "Invalid device address %d\n", addr); in cdnsp_ep0_set_address()
97 return -EINVAL; in cdnsp_ep0_set_address()
100 slot_ctx = cdnsp_get_slot_ctx(&pdev->out_ctx); in cdnsp_ep0_set_address()
103 dev_err(pdev->dev, "Can't Set Address from Configured State\n"); in cdnsp_ep0_set_address()
104 return -EINVAL; in cdnsp_ep0_set_address()
107 pdev->device_address = le16_to_cpu(ctrl->wValue); in cdnsp_ep0_set_address()
109 slot_ctx = cdnsp_get_slot_ctx(&pdev->out_ctx); in cdnsp_ep0_set_address()
110 slot_state = GET_SLOT_STATE(le32_to_cpu(slot_ctx->dev_state)); in cdnsp_ep0_set_address()
120 usb_gadget_set_state(&pdev->gadget, USB_STATE_ADDRESS); in cdnsp_ep0_set_address()
122 usb_gadget_set_state(&pdev->gadget, USB_STATE_DEFAULT); in cdnsp_ep0_set_address()
129 pdev->ep0_stage = CDNSP_STATUS_STAGE; in cdnsp_status_stage()
130 pdev->ep0_preq.request.length = 0; in cdnsp_status_stage()
132 return cdnsp_ep_enqueue(pdev->ep0_preq.pep, &pdev->ep0_preq); in cdnsp_status_stage()
141 (wIndex & USB_ENDPOINT_DIR_MASK ? 1 : 0) - 1; in cdnsp_w_index_to_ep_index()
153 recipient = ctrl->bRequestType & USB_RECIP_MASK; in cdnsp_ep0_handle_status()
157 status = pdev->gadget.is_selfpowered; in cdnsp_ep0_handle_status()
158 status |= pdev->may_wakeup << USB_DEVICE_REMOTE_WAKEUP; in cdnsp_ep0_handle_status()
160 if (pdev->gadget.speed >= USB_SPEED_SUPER) { in cdnsp_ep0_handle_status()
161 status |= pdev->u1_allowed << USB_DEV_STAT_U1_ENABLED; in cdnsp_ep0_handle_status()
162 status |= pdev->u2_allowed << USB_DEV_STAT_U2_ENABLED; in cdnsp_ep0_handle_status()
167 * Function Remote Wake Capable D0 in cdnsp_ep0_handle_status()
168 * Function Remote Wakeup D1 in cdnsp_ep0_handle_status()
172 ep_sts = cdnsp_w_index_to_ep_index(le16_to_cpu(ctrl->wIndex)); in cdnsp_ep0_handle_status()
173 pep = &pdev->eps[ep_sts]; in cdnsp_ep0_handle_status()
174 ep_sts = GET_EP_CTX_STATE(pep->out_ctx); in cdnsp_ep0_handle_status()
181 return -EINVAL; in cdnsp_ep0_handle_status()
184 response = (__le16 *)pdev->setup_buf; in cdnsp_ep0_handle_status()
187 pdev->ep0_preq.request.length = sizeof(*response); in cdnsp_ep0_handle_status()
188 pdev->ep0_preq.request.buf = pdev->setup_buf; in cdnsp_ep0_handle_status()
190 return cdnsp_ep_enqueue(pdev->ep0_preq.pep, &pdev->ep0_preq); in cdnsp_ep0_handle_status()
197 temp = readl(&pdev->active_port->regs->portpmsc) & ~GENMASK(31, 28); in cdnsp_enter_test_mode()
198 temp |= PORT_TEST_MODE(pdev->test_mode); in cdnsp_enter_test_mode()
199 writel(temp, &pdev->active_port->regs->portpmsc); in cdnsp_enter_test_mode()
210 state = pdev->gadget.state; in cdnsp_ep0_handle_feature_device()
211 speed = pdev->gadget.speed; in cdnsp_ep0_handle_feature_device()
213 switch (le16_to_cpu(ctrl->wValue)) { in cdnsp_ep0_handle_feature_device()
215 pdev->may_wakeup = !!set; in cdnsp_ep0_handle_feature_device()
220 return -EINVAL; in cdnsp_ep0_handle_feature_device()
222 pdev->u1_allowed = !!set; in cdnsp_ep0_handle_feature_device()
227 return -EINVAL; in cdnsp_ep0_handle_feature_device()
229 pdev->u2_allowed = !!set; in cdnsp_ep0_handle_feature_device()
233 return -EINVAL; in cdnsp_ep0_handle_feature_device()
236 return -EINVAL; in cdnsp_ep0_handle_feature_device()
238 tmode = le16_to_cpu(ctrl->wIndex); in cdnsp_ep0_handle_feature_device()
241 return -EINVAL; in cdnsp_ep0_handle_feature_device()
246 return -EINVAL; in cdnsp_ep0_handle_feature_device()
248 pdev->test_mode = tmode; in cdnsp_ep0_handle_feature_device()
257 return -EINVAL; in cdnsp_ep0_handle_feature_device()
270 wValue = le16_to_cpu(ctrl->wValue); in cdnsp_ep0_handle_feature_intf()
271 wIndex = le16_to_cpu(ctrl->wIndex); in cdnsp_ep0_handle_feature_intf()
280 * Remote wakeup is enabled when any function within a device in cdnsp_ep0_handle_feature_intf()
281 * is enabled for function remote wakeup. in cdnsp_ep0_handle_feature_intf()
284 pdev->may_wakeup++; in cdnsp_ep0_handle_feature_intf()
286 if (pdev->may_wakeup > 0) in cdnsp_ep0_handle_feature_intf()
287 pdev->may_wakeup--; in cdnsp_ep0_handle_feature_intf()
291 return -EINVAL; in cdnsp_ep0_handle_feature_intf()
304 wValue = le16_to_cpu(ctrl->wValue); in cdnsp_ep0_handle_feature_endpoint()
305 pep = &pdev->eps[cdnsp_w_index_to_ep_index(le16_to_cpu(ctrl->wIndex))]; in cdnsp_ep0_handle_feature_endpoint()
309 if (!set && (pep->ep_state & EP_WEDGE)) { in cdnsp_ep0_handle_feature_endpoint()
318 dev_warn(pdev->dev, "WARN Incorrect wValue %04x\n", wValue); in cdnsp_ep0_handle_feature_endpoint()
319 return -EINVAL; in cdnsp_ep0_handle_feature_endpoint()
329 switch (ctrl->bRequestType & USB_RECIP_MASK) { in cdnsp_ep0_handle_feature()
337 return -EINVAL; in cdnsp_ep0_handle_feature()
344 enum usb_device_state state = pdev->gadget.state; in cdnsp_ep0_set_sel()
348 return -EINVAL; in cdnsp_ep0_set_sel()
350 wLength = le16_to_cpu(ctrl->wLength); in cdnsp_ep0_set_sel()
353 dev_err(pdev->dev, "Set SEL should be 6 bytes, got %d\n", in cdnsp_ep0_set_sel()
355 return -EINVAL; in cdnsp_ep0_set_sel()
362 pdev->ep0_preq.request.length = 6; in cdnsp_ep0_set_sel()
363 pdev->ep0_preq.request.buf = pdev->setup_buf; in cdnsp_ep0_set_sel()
365 return cdnsp_ep_enqueue(pdev->ep0_preq.pep, &pdev->ep0_preq); in cdnsp_ep0_set_sel()
371 if (le16_to_cpu(ctrl->wIndex) || le16_to_cpu(ctrl->wLength)) in cdnsp_ep0_set_isoch_delay()
372 return -EINVAL; in cdnsp_ep0_set_isoch_delay()
374 pdev->gadget.isoch_delay = le16_to_cpu(ctrl->wValue); in cdnsp_ep0_set_isoch_delay()
384 switch (ctrl->bRequest) { in cdnsp_ep0_std_request()
416 struct usb_ctrlrequest *ctrl = &pdev->setup; in cdnsp_setup_analyze()
418 int ret = -EINVAL; in cdnsp_setup_analyze()
423 if (!pdev->gadget_driver) in cdnsp_setup_analyze()
426 if (pdev->gadget.state == USB_STATE_NOTATTACHED) { in cdnsp_setup_analyze()
427 dev_err(pdev->dev, "ERR: Setup detected in unattached state\n"); in cdnsp_setup_analyze()
431 pep = &pdev->eps[0]; in cdnsp_setup_analyze()
434 if (pep->ep_state & EP_HALTED) { in cdnsp_setup_analyze()
435 if (GET_EP_CTX_STATE(pep->out_ctx) == EP_STATE_HALTED) in cdnsp_setup_analyze()
444 pep->ep_state &= ~EP_HALTED; in cdnsp_setup_analyze()
445 pep->ep_state |= EP_STOPPED; in cdnsp_setup_analyze()
452 if (!list_empty(&pdev->eps[0].pending_list)) { in cdnsp_setup_analyze()
456 req = next_request(&pdev->eps[0].pending_list); in cdnsp_setup_analyze()
457 cdnsp_ep_dequeue(&pdev->eps[0], req); in cdnsp_setup_analyze()
460 len = le16_to_cpu(ctrl->wLength); in cdnsp_setup_analyze()
462 pdev->three_stage_setup = false; in cdnsp_setup_analyze()
463 pdev->ep0_expect_in = false; in cdnsp_setup_analyze()
465 pdev->three_stage_setup = true; in cdnsp_setup_analyze()
466 pdev->ep0_expect_in = !!(ctrl->bRequestType & USB_DIR_IN); in cdnsp_setup_analyze()
469 if ((ctrl->bRequestType & USB_TYPE_MASK) == USB_TYPE_STANDARD) in cdnsp_setup_analyze()
481 else if (!len && pdev->ep0_stage != CDNSP_STATUS_STAGE) in cdnsp_setup_analyze()