cdnsp-ep0.c (118b2a3237cf499727649b1c018dd2f1d329af08) cdnsp-ep0.c (16e3610154d0c992a0558d684213201f5355bd76)
1// SPDX-License-Identifier: GPL-2.0
2/*
3 * Cadence CDNSP DRD Driver.
4 *
5 * Copyright (C) 2020 Cadence.
6 *
7 * Author: Pawel Laszczak <pawell@cadence.com>
8 *

--- 123 unchanged lines hidden (view full) ---

132{
133 trace_cdnsp_ep0_status_stage("preparing");
134 pdev->ep0_stage = CDNSP_STATUS_STAGE;
135 pdev->ep0_preq.request.length = 0;
136
137 return cdnsp_ep_enqueue(pdev->ep0_preq.pep, &pdev->ep0_preq);
138}
139
1// SPDX-License-Identifier: GPL-2.0
2/*
3 * Cadence CDNSP DRD Driver.
4 *
5 * Copyright (C) 2020 Cadence.
6 *
7 * Author: Pawel Laszczak <pawell@cadence.com>
8 *

--- 123 unchanged lines hidden (view full) ---

132{
133 trace_cdnsp_ep0_status_stage("preparing");
134 pdev->ep0_stage = CDNSP_STATUS_STAGE;
135 pdev->ep0_preq.request.length = 0;
136
137 return cdnsp_ep_enqueue(pdev->ep0_preq.pep, &pdev->ep0_preq);
138}
139
140static int cdnsp_w_index_to_ep_index(__le32 wIndex)
140static int cdnsp_w_index_to_ep_index(u16 wIndex)
141{
141{
142 wIndex = le32_to_cpu(wIndex);
143
144 if (!(wIndex & USB_ENDPOINT_NUMBER_MASK))
145 return 0;
146
147 return ((wIndex & USB_ENDPOINT_NUMBER_MASK) * 2) +
148 (wIndex & USB_ENDPOINT_DIR_MASK ? 1 : 0) - 1;
149}
150
151static int cdnsp_ep0_handle_status(struct cdnsp_device *pdev,

--- 19 unchanged lines hidden (view full) ---

171 break;
172 case USB_RECIP_INTERFACE:
173 /*
174 * Function Remote Wake Capable D0
175 * Function Remote Wakeup D1
176 */
177 return cdnsp_ep0_delegate_req(pdev, ctrl);
178 case USB_RECIP_ENDPOINT:
142 if (!(wIndex & USB_ENDPOINT_NUMBER_MASK))
143 return 0;
144
145 return ((wIndex & USB_ENDPOINT_NUMBER_MASK) * 2) +
146 (wIndex & USB_ENDPOINT_DIR_MASK ? 1 : 0) - 1;
147}
148
149static int cdnsp_ep0_handle_status(struct cdnsp_device *pdev,

--- 19 unchanged lines hidden (view full) ---

169 break;
170 case USB_RECIP_INTERFACE:
171 /*
172 * Function Remote Wake Capable D0
173 * Function Remote Wakeup D1
174 */
175 return cdnsp_ep0_delegate_req(pdev, ctrl);
176 case USB_RECIP_ENDPOINT:
179 pep = &pdev->eps[cdnsp_w_index_to_ep_index(ctrl->wIndex)];
177 ep_sts = cdnsp_w_index_to_ep_index(le16_to_cpu(ctrl->wIndex));
178 pep = &pdev->eps[ep_sts];
180 ep_sts = GET_EP_CTX_STATE(pep->out_ctx);
181
182 /* check if endpoint is stalled */
183 if (ep_sts == EP_STATE_HALTED)
184 status = BIT(USB_ENDPOINT_HALT);
185 break;
186 default:
187 return -EINVAL;

--- 112 unchanged lines hidden (view full) ---

300 return 0;
301}
302
303static int cdnsp_ep0_handle_feature_endpoint(struct cdnsp_device *pdev,
304 struct usb_ctrlrequest *ctrl,
305 int set)
306{
307 struct cdnsp_ep *pep;
179 ep_sts = GET_EP_CTX_STATE(pep->out_ctx);
180
181 /* check if endpoint is stalled */
182 if (ep_sts == EP_STATE_HALTED)
183 status = BIT(USB_ENDPOINT_HALT);
184 break;
185 default:
186 return -EINVAL;

--- 112 unchanged lines hidden (view full) ---

299 return 0;
300}
301
302static int cdnsp_ep0_handle_feature_endpoint(struct cdnsp_device *pdev,
303 struct usb_ctrlrequest *ctrl,
304 int set)
305{
306 struct cdnsp_ep *pep;
308 u32 wValue;
307 u16 wValue;
309
310 wValue = le16_to_cpu(ctrl->wValue);
308
309 wValue = le16_to_cpu(ctrl->wValue);
311 pep = &pdev->eps[cdnsp_w_index_to_ep_index(ctrl->wIndex)];
310 pep = &pdev->eps[cdnsp_w_index_to_ep_index(le16_to_cpu(ctrl->wIndex))];
312
313 switch (wValue) {
314 case USB_ENDPOINT_HALT:
315 if (!set && (pep->ep_state & EP_WEDGE)) {
316 /* Resets Sequence Number */
317 cdnsp_halt_endpoint(pdev, pep, 0);
318 cdnsp_halt_endpoint(pdev, pep, 1);
319 break;

--- 110 unchanged lines hidden (view full) ---

430
431 return ret;
432}
433
434void cdnsp_setup_analyze(struct cdnsp_device *pdev)
435{
436 struct usb_ctrlrequest *ctrl = &pdev->setup;
437 int ret = 0;
311
312 switch (wValue) {
313 case USB_ENDPOINT_HALT:
314 if (!set && (pep->ep_state & EP_WEDGE)) {
315 /* Resets Sequence Number */
316 cdnsp_halt_endpoint(pdev, pep, 0);
317 cdnsp_halt_endpoint(pdev, pep, 1);
318 break;

--- 110 unchanged lines hidden (view full) ---

429
430 return ret;
431}
432
433void cdnsp_setup_analyze(struct cdnsp_device *pdev)
434{
435 struct usb_ctrlrequest *ctrl = &pdev->setup;
436 int ret = 0;
438 __le16 len;
437 u16 len;
439
440 trace_cdnsp_ctrl_req(ctrl);
441
442 if (!pdev->gadget_driver)
443 goto out;
444
445 if (pdev->gadget.state == USB_STATE_NOTATTACHED) {
446 dev_err(pdev->dev, "ERR: Setup detected in unattached state\n");

--- 49 unchanged lines hidden ---
438
439 trace_cdnsp_ctrl_req(ctrl);
440
441 if (!pdev->gadget_driver)
442 goto out;
443
444 if (pdev->gadget.state == USB_STATE_NOTATTACHED) {
445 dev_err(pdev->dev, "ERR: Setup detected in unattached state\n");

--- 49 unchanged lines hidden ---