diff options
-rw-r--r-- | drivers/usb/gadget/fsl_usb2_udc.c | 77 |
1 files changed, 41 insertions, 36 deletions
diff --git a/drivers/usb/gadget/fsl_usb2_udc.c b/drivers/usb/gadget/fsl_usb2_udc.c index 10b2b33b8698..d57bcfbc08a5 100644 --- a/drivers/usb/gadget/fsl_usb2_udc.c +++ b/drivers/usb/gadget/fsl_usb2_udc.c | |||
@@ -1277,31 +1277,32 @@ static void setup_received_irq(struct fsl_udc *udc, | |||
1277 | 1277 | ||
1278 | udc_reset_ep_queue(udc, 0); | 1278 | udc_reset_ep_queue(udc, 0); |
1279 | 1279 | ||
1280 | /* We process some stardard setup requests here */ | ||
1280 | switch (setup->bRequest) { | 1281 | switch (setup->bRequest) { |
1281 | /* Request that need Data+Status phase from udc */ | ||
1282 | case USB_REQ_GET_STATUS: | 1282 | case USB_REQ_GET_STATUS: |
1283 | if ((setup->bRequestType & (USB_DIR_IN | USB_TYPE_STANDARD)) | 1283 | /* Data+Status phase from udc */ |
1284 | if ((setup->bRequestType & (USB_DIR_IN | USB_TYPE_MASK)) | ||
1284 | != (USB_DIR_IN | USB_TYPE_STANDARD)) | 1285 | != (USB_DIR_IN | USB_TYPE_STANDARD)) |
1285 | break; | 1286 | break; |
1286 | ch9getstatus(udc, setup->bRequestType, wValue, wIndex, wLength); | 1287 | ch9getstatus(udc, setup->bRequestType, wValue, wIndex, wLength); |
1287 | break; | 1288 | return; |
1288 | 1289 | ||
1289 | /* Requests that need Status phase from udc */ | ||
1290 | case USB_REQ_SET_ADDRESS: | 1290 | case USB_REQ_SET_ADDRESS: |
1291 | /* Status phase from udc */ | ||
1291 | if (setup->bRequestType != (USB_DIR_OUT | USB_TYPE_STANDARD | 1292 | if (setup->bRequestType != (USB_DIR_OUT | USB_TYPE_STANDARD |
1292 | | USB_RECIP_DEVICE)) | 1293 | | USB_RECIP_DEVICE)) |
1293 | break; | 1294 | break; |
1294 | ch9setaddress(udc, wValue, wIndex, wLength); | 1295 | ch9setaddress(udc, wValue, wIndex, wLength); |
1295 | break; | 1296 | return; |
1296 | 1297 | ||
1297 | /* Handled by udc, no data, status by udc */ | ||
1298 | case USB_REQ_CLEAR_FEATURE: | 1298 | case USB_REQ_CLEAR_FEATURE: |
1299 | case USB_REQ_SET_FEATURE: | 1299 | case USB_REQ_SET_FEATURE: |
1300 | { /* status transaction */ | 1300 | /* Status phase from udc */ |
1301 | { | ||
1301 | int rc = -EOPNOTSUPP; | 1302 | int rc = -EOPNOTSUPP; |
1302 | 1303 | ||
1303 | if ((setup->bRequestType & USB_RECIP_MASK) | 1304 | if ((setup->bRequestType & (USB_RECIP_MASK | USB_TYPE_MASK)) |
1304 | == USB_RECIP_ENDPOINT) { | 1305 | == (USB_RECIP_ENDPOINT | USB_TYPE_STANDARD)) { |
1305 | int pipe = get_pipe_by_windex(wIndex); | 1306 | int pipe = get_pipe_by_windex(wIndex); |
1306 | struct fsl_ep *ep; | 1307 | struct fsl_ep *ep; |
1307 | 1308 | ||
@@ -1315,8 +1316,9 @@ static void setup_received_irq(struct fsl_udc *udc, | |||
1315 | ? 1 : 0); | 1316 | ? 1 : 0); |
1316 | spin_lock(&udc->lock); | 1317 | spin_lock(&udc->lock); |
1317 | 1318 | ||
1318 | } else if ((setup->bRequestType & USB_RECIP_MASK) | 1319 | } else if ((setup->bRequestType & (USB_RECIP_MASK |
1319 | == USB_RECIP_DEVICE) { | 1320 | | USB_TYPE_MASK)) == (USB_RECIP_DEVICE |
1321 | | USB_TYPE_STANDARD)) { | ||
1320 | /* Note: The driver has not include OTG support yet. | 1322 | /* Note: The driver has not include OTG support yet. |
1321 | * This will be set when OTG support is added */ | 1323 | * This will be set when OTG support is added */ |
1322 | if (!udc->gadget.is_otg) | 1324 | if (!udc->gadget.is_otg) |
@@ -1329,39 +1331,42 @@ static void setup_received_irq(struct fsl_udc *udc, | |||
1329 | USB_DEVICE_A_ALT_HNP_SUPPORT) | 1331 | USB_DEVICE_A_ALT_HNP_SUPPORT) |
1330 | udc->gadget.a_alt_hnp_support = 1; | 1332 | udc->gadget.a_alt_hnp_support = 1; |
1331 | rc = 0; | 1333 | rc = 0; |
1332 | } | 1334 | } else |
1335 | break; | ||
1336 | |||
1333 | if (rc == 0) { | 1337 | if (rc == 0) { |
1334 | if (ep0_prime_status(udc, EP_DIR_IN)) | 1338 | if (ep0_prime_status(udc, EP_DIR_IN)) |
1335 | ep0stall(udc); | 1339 | ep0stall(udc); |
1336 | } | 1340 | } |
1337 | break; | 1341 | return; |
1338 | } | 1342 | } |
1339 | /* Requests handled by gadget */ | ||
1340 | default: | ||
1341 | if (wLength) { | ||
1342 | /* Data phase from gadget, status phase from udc */ | ||
1343 | udc->ep0_dir = (setup->bRequestType & USB_DIR_IN) | ||
1344 | ? USB_DIR_IN : USB_DIR_OUT; | ||
1345 | spin_unlock(&udc->lock); | ||
1346 | if (udc->driver->setup(&udc->gadget, | ||
1347 | &udc->local_setup_buff) < 0) | ||
1348 | ep0stall(udc); | ||
1349 | spin_lock(&udc->lock); | ||
1350 | udc->ep0_state = (setup->bRequestType & USB_DIR_IN) | ||
1351 | ? DATA_STATE_XMIT : DATA_STATE_RECV; | ||
1352 | 1343 | ||
1353 | } else { | 1344 | default: |
1354 | /* No data phase, IN status from gadget */ | ||
1355 | udc->ep0_dir = USB_DIR_IN; | ||
1356 | spin_unlock(&udc->lock); | ||
1357 | if (udc->driver->setup(&udc->gadget, | ||
1358 | &udc->local_setup_buff) < 0) | ||
1359 | ep0stall(udc); | ||
1360 | spin_lock(&udc->lock); | ||
1361 | udc->ep0_state = WAIT_FOR_OUT_STATUS; | ||
1362 | } | ||
1363 | break; | 1345 | break; |
1364 | } | 1346 | } |
1347 | |||
1348 | /* Requests handled by gadget */ | ||
1349 | if (wLength) { | ||
1350 | /* Data phase from gadget, status phase from udc */ | ||
1351 | udc->ep0_dir = (setup->bRequestType & USB_DIR_IN) | ||
1352 | ? USB_DIR_IN : USB_DIR_OUT; | ||
1353 | spin_unlock(&udc->lock); | ||
1354 | if (udc->driver->setup(&udc->gadget, | ||
1355 | &udc->local_setup_buff) < 0) | ||
1356 | ep0stall(udc); | ||
1357 | spin_lock(&udc->lock); | ||
1358 | udc->ep0_state = (setup->bRequestType & USB_DIR_IN) | ||
1359 | ? DATA_STATE_XMIT : DATA_STATE_RECV; | ||
1360 | } else { | ||
1361 | /* No data phase, IN status from gadget */ | ||
1362 | udc->ep0_dir = USB_DIR_IN; | ||
1363 | spin_unlock(&udc->lock); | ||
1364 | if (udc->driver->setup(&udc->gadget, | ||
1365 | &udc->local_setup_buff) < 0) | ||
1366 | ep0stall(udc); | ||
1367 | spin_lock(&udc->lock); | ||
1368 | udc->ep0_state = WAIT_FOR_OUT_STATUS; | ||
1369 | } | ||
1365 | } | 1370 | } |
1366 | 1371 | ||
1367 | /* Process request for Data or Status phase of ep0 | 1372 | /* Process request for Data or Status phase of ep0 |