Lines Matching refs:pdev
18 static void cdnsp_ep0_stall(struct cdnsp_device *pdev) in cdnsp_ep0_stall() argument
23 pep = &pdev->eps[0]; in cdnsp_ep0_stall()
26 if (pdev->three_stage_setup) { in cdnsp_ep0_stall()
27 cdnsp_halt_endpoint(pdev, pep, true); in cdnsp_ep0_stall()
37 cdnsp_status_stage(pdev); in cdnsp_ep0_stall()
41 static int cdnsp_ep0_delegate_req(struct cdnsp_device *pdev, in cdnsp_ep0_delegate_req() argument
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()
53 static int cdnsp_ep0_set_config(struct cdnsp_device *pdev, in cdnsp_ep0_set_config() argument
56 enum usb_device_state state = pdev->gadget.state; in cdnsp_ep0_set_config()
70 dev_err(pdev->dev, "Set Configuration - bad device state\n"); in cdnsp_ep0_set_config()
74 ret = cdnsp_ep0_delegate_req(pdev, ctrl); in cdnsp_ep0_set_config()
79 usb_gadget_set_state(&pdev->gadget, USB_STATE_ADDRESS); in cdnsp_ep0_set_config()
84 static int cdnsp_ep0_set_address(struct cdnsp_device *pdev, in cdnsp_ep0_set_address() argument
87 enum usb_device_state state = pdev->gadget.state; in cdnsp_ep0_set_address()
96 dev_err(pdev->dev, "Invalid device address %d\n", addr); 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()
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()
112 cdnsp_reset_device(pdev); in cdnsp_ep0_set_address()
115 ret = cdnsp_setup_device(pdev, SETUP_CONTEXT_ADDRESS); 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()
127 int cdnsp_status_stage(struct cdnsp_device *pdev) in cdnsp_status_stage() argument
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()
144 static int cdnsp_ep0_handle_status(struct cdnsp_device *pdev, in cdnsp_ep0_handle_status() argument
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()
170 return cdnsp_ep0_delegate_req(pdev, ctrl); in cdnsp_ep0_handle_status()
173 pep = &pdev->eps[ep_sts]; 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()
193 static void cdnsp_enter_test_mode(struct cdnsp_device *pdev) in cdnsp_enter_test_mode() argument
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()
202 static int cdnsp_ep0_handle_feature_device(struct cdnsp_device *pdev, in cdnsp_ep0_handle_feature_device() argument
210 state = pdev->gadget.state; in cdnsp_ep0_handle_feature_device()
211 speed = pdev->gadget.speed; in cdnsp_ep0_handle_feature_device()
215 pdev->may_wakeup = !!set; in cdnsp_ep0_handle_feature_device()
222 pdev->u1_allowed = !!set; in cdnsp_ep0_handle_feature_device()
229 pdev->u2_allowed = !!set; in cdnsp_ep0_handle_feature_device()
248 pdev->test_mode = tmode; in cdnsp_ep0_handle_feature_device()
254 cdnsp_enter_test_mode(pdev); in cdnsp_ep0_handle_feature_device()
263 static int cdnsp_ep0_handle_feature_intf(struct cdnsp_device *pdev, in cdnsp_ep0_handle_feature_intf() argument
275 ret = cdnsp_ep0_delegate_req(pdev, ctrl); 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()
297 static int cdnsp_ep0_handle_feature_endpoint(struct cdnsp_device *pdev, in cdnsp_ep0_handle_feature_endpoint() argument
305 pep = &pdev->eps[cdnsp_w_index_to_ep_index(le16_to_cpu(ctrl->wIndex))]; in cdnsp_ep0_handle_feature_endpoint()
311 cdnsp_halt_endpoint(pdev, pep, 0); in cdnsp_ep0_handle_feature_endpoint()
312 cdnsp_halt_endpoint(pdev, pep, 1); in cdnsp_ep0_handle_feature_endpoint()
316 return cdnsp_halt_endpoint(pdev, pep, set); in cdnsp_ep0_handle_feature_endpoint()
318 dev_warn(pdev->dev, "WARN Incorrect wValue %04x\n", wValue); in cdnsp_ep0_handle_feature_endpoint()
325 static int cdnsp_ep0_handle_feature(struct cdnsp_device *pdev, in cdnsp_ep0_handle_feature() argument
331 return cdnsp_ep0_handle_feature_device(pdev, ctrl, set); in cdnsp_ep0_handle_feature()
333 return cdnsp_ep0_handle_feature_intf(pdev, ctrl, set); in cdnsp_ep0_handle_feature()
335 return cdnsp_ep0_handle_feature_endpoint(pdev, ctrl, set); in cdnsp_ep0_handle_feature()
341 static int cdnsp_ep0_set_sel(struct cdnsp_device *pdev, in cdnsp_ep0_set_sel() argument
344 enum usb_device_state state = pdev->gadget.state; in cdnsp_ep0_set_sel()
353 dev_err(pdev->dev, "Set SEL should be 6 bytes, got %d\n", 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()
368 static int cdnsp_ep0_set_isoch_delay(struct cdnsp_device *pdev, in cdnsp_ep0_set_isoch_delay() argument
374 pdev->gadget.isoch_delay = le16_to_cpu(ctrl->wValue); in cdnsp_ep0_set_isoch_delay()
379 static int cdnsp_ep0_std_request(struct cdnsp_device *pdev, in cdnsp_ep0_std_request() argument
386 ret = cdnsp_ep0_handle_status(pdev, ctrl); in cdnsp_ep0_std_request()
389 ret = cdnsp_ep0_handle_feature(pdev, ctrl, 0); in cdnsp_ep0_std_request()
392 ret = cdnsp_ep0_handle_feature(pdev, ctrl, 1); in cdnsp_ep0_std_request()
395 ret = cdnsp_ep0_set_address(pdev, ctrl); in cdnsp_ep0_std_request()
398 ret = cdnsp_ep0_set_config(pdev, ctrl); in cdnsp_ep0_std_request()
401 ret = cdnsp_ep0_set_sel(pdev, ctrl); in cdnsp_ep0_std_request()
404 ret = cdnsp_ep0_set_isoch_delay(pdev, ctrl); in cdnsp_ep0_std_request()
411 list_add_tail(&pdev->ep0_preq.list, in cdnsp_ep0_std_request()
412 &pdev->ep0_preq.pep->pending_list); in cdnsp_ep0_std_request()
414 ret = cdnsp_ep0_delegate_req(pdev, ctrl); in cdnsp_ep0_std_request()
418 list_del(&pdev->ep0_preq.list); in cdnsp_ep0_std_request()
421 ret = cdnsp_ep0_delegate_req(pdev, ctrl); in cdnsp_ep0_std_request()
428 void cdnsp_setup_analyze(struct cdnsp_device *pdev) in cdnsp_setup_analyze() argument
430 struct usb_ctrlrequest *ctrl = &pdev->setup; in cdnsp_setup_analyze()
436 if (!pdev->gadget_driver) in cdnsp_setup_analyze()
439 if (pdev->gadget.state == USB_STATE_NOTATTACHED) { in cdnsp_setup_analyze()
440 dev_err(pdev->dev, "ERR: Setup detected in unattached state\n"); in cdnsp_setup_analyze()
446 if (pdev->eps[0].ep_state & EP_HALTED) { in cdnsp_setup_analyze()
448 cdnsp_halt_endpoint(pdev, &pdev->eps[0], 0); in cdnsp_setup_analyze()
455 if (!list_empty(&pdev->eps[0].pending_list)) { in cdnsp_setup_analyze()
459 req = next_request(&pdev->eps[0].pending_list); in cdnsp_setup_analyze()
460 cdnsp_ep_dequeue(&pdev->eps[0], req); in cdnsp_setup_analyze()
465 pdev->three_stage_setup = false; in cdnsp_setup_analyze()
466 pdev->ep0_expect_in = false; in cdnsp_setup_analyze()
468 pdev->three_stage_setup = true; in cdnsp_setup_analyze()
469 pdev->ep0_expect_in = !!(ctrl->bRequestType & USB_DIR_IN); in cdnsp_setup_analyze()
473 ret = cdnsp_ep0_std_request(pdev, ctrl); in cdnsp_setup_analyze()
475 ret = cdnsp_ep0_delegate_req(pdev, ctrl); in cdnsp_setup_analyze()
478 pdev->ep0_stage = CDNSP_STATUS_STAGE; in cdnsp_setup_analyze()
486 cdnsp_ep0_stall(pdev); in cdnsp_setup_analyze()
487 else if (pdev->ep0_stage == CDNSP_STATUS_STAGE) in cdnsp_setup_analyze()
488 cdnsp_status_stage(pdev); in cdnsp_setup_analyze()