Lines Matching refs:usbHostState

27 static usb_status_t USB_HostOhciLinkGtdControlTr(usb_host_ohci_state_struct_t *usbHostState,
31 static usb_status_t USB_HostOhciLinkItdTr(usb_host_ohci_state_struct_t *usbHostState,
34 static usb_status_t USB_HostOhciFreeItd(usb_host_ohci_state_struct_t *usbHostState,
37 static usb_status_t USB_HostOhciLinkGtdTr(usb_host_ohci_state_struct_t *usbHostState,
40 static usb_status_t USB_HostOhciFreeGtd(usb_host_ohci_state_struct_t *usbHostState,
42 static void USB_HostOhciTdDoneHandle(usb_host_ohci_state_struct_t *usbHostState,
61 static void USB_HostOhciDisableIsr(usb_host_ohci_state_struct_t *usbHostState) in USB_HostOhciDisableIsr() argument
67 if (0U == usbHostState->isrLevel) in USB_HostOhciDisableIsr()
69 NVIC_DisableIRQ((IRQn_Type)usbHostState->isrNumber); in USB_HostOhciDisableIsr()
71 usbHostState->isrLevel++; in USB_HostOhciDisableIsr()
75 static void USB_HostOhciEnableIsr(usb_host_ohci_state_struct_t *usbHostState) in USB_HostOhciEnableIsr() argument
81 usbHostState->isrLevel--; in USB_HostOhciEnableIsr()
82 if (0U == usbHostState->isrLevel) in USB_HostOhciEnableIsr()
84 NVIC_EnableIRQ((IRQn_Type)usbHostState->isrNumber); in USB_HostOhciEnableIsr()
89 static void USB_HostOhciDelay(usb_host_ohci_state_struct_t *usbHostState, uint32_t ms) in USB_HostOhciDelay() argument
97 …((uint32_t)s_UsbHostOhciHcca[usbHostState->controllerId].HccaFrameNumber & USB_HOST_OHCI_FMNUMBER_… in USB_HostOhciDelay()
101 … SofEnd = (uint32_t)((uint32_t)s_UsbHostOhciHcca[usbHostState->controllerId].HccaFrameNumber & in USB_HostOhciDelay()
107 static usb_status_t USB_HostOhciControlBus(usb_host_ohci_state_struct_t *usbHostState, uint8_t busC… in USB_HostOhciControlBus() argument
123 usbHostState->controlIsBusy = 0U; in USB_HostOhciControlBus()
131 … if (0U != (usbHostState->usbRegBase->HcRhPortStatus[0] & USB_HOST_OHCI_RHPORTSTATUS_CCS_MASK)) in USB_HostOhciControlBus()
133 usb_host_instance_t *hostPointer = (usb_host_instance_t *)usbHostState->hostHandle; in USB_HostOhciControlBus()
134 portStatus = usbHostState->usbRegBase->HcRhPortStatus[0]; in USB_HostOhciControlBus()
138 usbHostState->usbRegBase->HcRhPortStatus[0] = portStatus; in USB_HostOhciControlBus()
140 portStatus = usbHostState->usbRegBase->HcControl; in USB_HostOhciControlBus()
144 usbHostState->usbRegBase->HcControl = portStatus; in USB_HostOhciControlBus()
146 usbHostState->matchTick = hostPointer->hwTick; in USB_HostOhciControlBus()
147 usbHostState->busSuspendStatus = kBus_OhciStartSuspend; in USB_HostOhciControlBus()
149 while ((hostPointer->hwTick - usbHostState->matchTick) <= 3U) in USB_HostOhciControlBus()
153 usbHostState->usbRegBase->HcRhStatus |= USB_HOST_OHCI_RHSTATUS_DRWE_MASK; in USB_HostOhciControlBus()
157 usbHostState->busSuspendStatus = kBus_OhciSuspended; in USB_HostOhciControlBus()
166 … if (0u != (usbHostState->usbRegBase->HcRhPortStatus[0] & USB_HOST_OHCI_RHPORTSTATUS_CCS_MASK)) in USB_HostOhciControlBus()
168 portStatus = usbHostState->usbRegBase->HcRhPortStatus[0]; in USB_HostOhciControlBus()
171 usbHostState->usbRegBase->HcRhPortStatus[0] = portStatus; in USB_HostOhciControlBus()
172 usbHostState->busSuspendStatus = kBus_OhciStartResume; in USB_HostOhciControlBus()
176 usb_host_instance_t *hostPointer = (usb_host_instance_t *)usbHostState->hostHandle; in USB_HostOhciControlBus()
178 portStatus = usbHostState->usbRegBase->HcControl; in USB_HostOhciControlBus()
182 usbHostState->usbRegBase->HcControl = portStatus; in USB_HostOhciControlBus()
183 portStatus = usbHostState->usbRegBase->HcRhPortStatus[0]; in USB_HostOhciControlBus()
186 usbHostState->usbRegBase->HcRhPortStatus[0] = portStatus; in USB_HostOhciControlBus()
188 usbHostState->busSuspendStatus = kBus_OhciIdle; in USB_HostOhciControlBus()
345 static usb_status_t USB_HostOhciGetGtd(usb_host_ohci_state_struct_t *usbHostState, in USB_HostOhciGetGtd() argument
357 if (count > usbHostState->gtdCount) in USB_HostOhciGetGtd()
363 while ((0U != count) && (NULL != usbHostState->gtdList)) in USB_HostOhciGetGtd()
367 *gtd = usbHostState->gtdList; in USB_HostOhciGetGtd()
371 p->NextTD = (uint32_t)usbHostState->gtdList; in USB_HostOhciGetGtd()
373 p = usbHostState->gtdList; in USB_HostOhciGetGtd()
375usbHostState->gtdList = (usb_host_ohci_general_transfer_descritpor_struct_t *)usbHostState->gtdLis… in USB_HostOhciGetGtd()
378 usbHostState->gtdCount--; in USB_HostOhciGetGtd()
396 static usb_status_t USB_HostOhciFreeGtd(usb_host_ohci_state_struct_t *usbHostState, in USB_HostOhciFreeGtd() argument
410 p = usbHostState->gtdList; in USB_HostOhciFreeGtd()
420 gtd->nextGtd = usbHostState->gtdList; in USB_HostOhciFreeGtd()
421 usbHostState->gtdList = gtd; in USB_HostOhciFreeGtd()
422 usbHostState->gtdCount++; in USB_HostOhciFreeGtd()
429 static usb_status_t USB_HostOhciGetItd(usb_host_ohci_state_struct_t *usbHostState, in USB_HostOhciGetItd() argument
441 if (count > usbHostState->itdCount) in USB_HostOhciGetItd()
447 while ((0U != count) && (NULL != usbHostState->itdList)) in USB_HostOhciGetItd()
451 *itd = usbHostState->itdList; in USB_HostOhciGetItd()
455 p->NextTD = (uint32_t)usbHostState->itdList; in USB_HostOhciGetItd()
457 p = usbHostState->itdList; in USB_HostOhciGetItd()
458usbHostState->itdList = (usb_host_ohci_isochronous_transfer_descritpor_struct_t *)usbHostState->it… in USB_HostOhciGetItd()
461 usbHostState->itdCount--; in USB_HostOhciGetItd()
480 static usb_status_t USB_HostOhciFreeItd(usb_host_ohci_state_struct_t *usbHostState, in USB_HostOhciFreeItd() argument
495 p = usbHostState->itdList; in USB_HostOhciFreeItd()
508 usbHostState->itdList = itd; in USB_HostOhciFreeItd()
515 usbHostState->itdCount++; in USB_HostOhciFreeItd()
521 static void USB_HostOhciLinkTdToDoneList(usb_host_ohci_state_struct_t *usbHostState) in USB_HostOhciLinkTdToDoneList() argument
526 … *)(s_UsbHostOhciHcca[usbHostState->controllerId].HccaDoneHead & USB_HOST_OHCI_HD_MASK); in USB_HostOhciLinkTdToDoneList()
532 if (NULL != usbHostState->tdDoneListTail) in USB_HostOhciLinkTdToDoneList()
534 usbHostState->tdDoneListTail->NextTD = (uint32_t)tdList; in USB_HostOhciLinkTdToDoneList()
538 usbHostState->tdDoneListHead = tdList; in USB_HostOhciLinkTdToDoneList()
540 usbHostState->tdDoneListTail = tdList; in USB_HostOhciLinkTdToDoneList()
544 if (NULL != usbHostState->tdDoneListTail) in USB_HostOhciLinkTdToDoneList()
546 usbHostState->tdDoneListTail->NextTD = 0U; in USB_HostOhciLinkTdToDoneList()
548 usbHostState->writeBackCount++; in USB_HostOhciLinkTdToDoneList()
549 s_UsbHostOhciHcca[usbHostState->controllerId].HccaDoneHead = 0U; in USB_HostOhciLinkTdToDoneList()
552 static usb_status_t USB_HostOhciPortChange(usb_host_ohci_state_struct_t *usbHostState) in USB_HostOhciPortChange() argument
556 …uint32_t portCount = (usbHostState->usbRegBase->HcRhDescriptorA & USB_HOST_OHCI_RHDESCRIPTORA_NDP_… in USB_HostOhciPortChange()
560 portStatus = usbHostState->usbRegBase->HcRhPortStatus[i]; in USB_HostOhciPortChange()
564 if (kBus_OhciIdle != usbHostState->busSuspendStatus) in USB_HostOhciPortChange()
566 usb_host_instance_t *hostPointer = (usb_host_instance_t *)usbHostState->hostHandle; in USB_HostOhciPortChange()
567 portStatus = usbHostState->usbRegBase->HcRhPortStatus[i]; in USB_HostOhciPortChange()
569usbHostState->usbRegBase->HcRhPortStatus[i] = portStatus | USB_HOST_OHCI_RHPORTSTATUS_PSSC_MASK; in USB_HostOhciPortChange()
570 … while (0U != (usbHostState->usbRegBase->HcRhPortStatus[i] & USB_HOST_OHCI_RHPORTSTATUS_PSS_MASK)) in USB_HostOhciPortChange()
573 portStatus = usbHostState->usbRegBase->HcControl; in USB_HostOhciPortChange()
577 usbHostState->usbRegBase->HcControl = portStatus; in USB_HostOhciPortChange()
578 portStatus = usbHostState->usbRegBase->HcRhPortStatus[i]; in USB_HostOhciPortChange()
581 usbHostState->usbRegBase->HcRhPortStatus[i] = portStatus; in USB_HostOhciPortChange()
583 usbHostState->busSuspendStatus = kBus_OhciIdle; in USB_HostOhciPortChange()
586 … uint32_t sofStart = (uint32_t)s_UsbHostOhciHcca[usbHostState->controllerId].HccaFrameNumber & in USB_HostOhciPortChange()
591 portStatus = usbHostState->usbRegBase->HcRhPortStatus[i]; in USB_HostOhciPortChange()
595usbHostState->usbRegBase->HcRhPortStatus[i] = portStatus | USB_HOST_OHCI_RHPORTSTATUS_CSC_MASK; in USB_HostOhciPortChange()
597 … sof = (uint32_t)((uint32_t)s_UsbHostOhciHcca[usbHostState->controllerId].HccaFrameNumber & in USB_HostOhciPortChange()
606 portStatus = usbHostState->usbRegBase->HcRhPortStatus[i]; in USB_HostOhciPortChange()
611 if (((uint8_t)kUSB_DeviceOhciPortDetached) != usbHostState->portState[i].portStatus) in USB_HostOhciPortChange()
614 if ((kBus_OhciSuspended == usbHostState->busSuspendStatus) || in USB_HostOhciPortChange()
615 (kBus_OhciStartResume == usbHostState->busSuspendStatus)) in USB_HostOhciPortChange()
619 … usb_host_instance_t *hostPointer = (usb_host_instance_t *)usbHostState->hostHandle; in USB_HostOhciPortChange()
620 usbHostState->busSuspendStatus = kBus_OhciStartResume; in USB_HostOhciPortChange()
625usbHostState->usbRegBase->HcRhPortStatus[i] = portStatus | USB_HOST_OHCI_RHPORTSTATUS_PSSC_MASK; in USB_HostOhciPortChange()
627 … (usbHostState->usbRegBase->HcRhPortStatus[i] & USB_HOST_OHCI_RHPORTSTATUS_PSS_MASK)) in USB_HostOhciPortChange()
630 portStatus = usbHostState->usbRegBase->HcControl; in USB_HostOhciPortChange()
634 usbHostState->usbRegBase->HcControl = portStatus; in USB_HostOhciPortChange()
635 … portStatus = usbHostState->usbRegBase->HcRhPortStatus[i]; in USB_HostOhciPortChange()
638 usbHostState->usbRegBase->HcRhPortStatus[i] = portStatus; in USB_HostOhciPortChange()
643 usbHostState->busSuspendStatus = kBus_OhciIdle; in USB_HostOhciPortChange()
650 usbHostState->busSuspendStatus = kBus_OhciIdle; in USB_HostOhciPortChange()
654 (void)USB_HostOhciDelay(usbHostState, 1); in USB_HostOhciPortChange()
655 … if (0U == ((usbHostState->usbRegBase->HcRhPortStatus[i] & USB_HOST_OHCI_RHPORTSTATUS_CCS_MASK))) in USB_HostOhciPortChange()
661 portStatus = usbHostState->usbRegBase->HcRhPortStatus[i]; in USB_HostOhciPortChange()
667 usbHostState->portState[i].portStatus = (uint8_t)kUSB_DeviceOhciPortDetached; in USB_HostOhciPortChange()
672usbHostState->usbRegBase->HcRhPortStatus[i] = portStatus | USB_HOST_OHCI_RHPORTSTATUS_PRS_MASK; in USB_HostOhciPortChange()
674 … while (0U != (usbHostState->usbRegBase->HcRhPortStatus[i] & USB_HOST_OHCI_RHPORTSTATUS_PRS_MASK)) in USB_HostOhciPortChange()
679 usbHostState->portState[i].portSpeed = in USB_HostOhciPortChange()
680 … (0U != (usbHostState->usbRegBase->HcRhPortStatus[i] & USB_HOST_OHCI_RHPORTSTATUS_LSDA_MASK)) ? in USB_HostOhciPortChange()
684 (void)USB_HostOhciDelay(usbHostState, USB_HOST_OHCI_PORT_RESET_RECOVERY_DELAY); in USB_HostOhciPortChange()
685 usbHostState->portState[i].portStatus = (uint8_t)kUSB_DeviceOhciPortPhyAttached; in USB_HostOhciPortChange()
686 (void)OSA_EventSet(usbHostState->ohciEvent, USB_HOST_OHCI_EVENT_ATTACH); in USB_HostOhciPortChange()
690 if ((uint8_t)kUSB_DeviceOhciPortDetached == usbHostState->portState[i].portStatus) in USB_HostOhciPortChange()
695 usbHostState->busSuspendStatus = kBus_OhciIdle; in USB_HostOhciPortChange()
697 usbHostState->portState[i].portStatus = (uint8_t)kUSB_DeviceOhciPortPhyDetached; in USB_HostOhciPortChange()
698 (void)OSA_EventSet(usbHostState->ohciEvent, USB_HOST_OHCI_EVENT_DETACH); in USB_HostOhciPortChange()
704 static usb_status_t USB_HostOhciFindStartFrame(usb_host_ohci_state_struct_t *usbHostState, in USB_HostOhciFindStartFrame() argument
715 if (NULL == usbHostState->pipeListInUsing) in USB_HostOhciFindStartFrame()
725 temp = (void *)usbHostState->pipeListInUsing; in USB_HostOhciFindStartFrame()
749 static usb_status_t USB_HostOhciAddToPeriodicList(usb_host_ohci_state_struct_t *usbHostState, in USB_HostOhciAddToPeriodicList() argument
753 …uint32_t dummy = (uint32_t)&s_UsbHostOhciTd[usbHostState->controllerId].ed[USB_HOST_OHCI_PERIODIC_… in USB_HostOhciAddToPeriodicList()
759 … ed = (usb_host_ohci_endpoint_descritpor_struct_t *)s_UsbHostOhciHcca[usbHostState->controllerId] in USB_HostOhciAddToPeriodicList()
800 … s_UsbHostOhciHcca[usbHostState->controllerId].HccaInterrruptTable[i] = (uint32_t)pipe->ed; in USB_HostOhciAddToPeriodicList()
806 static usb_status_t USB_HostOhciOpenControlBulkPipe(usb_host_ohci_state_struct_t *usbHostState, in USB_HostOhciOpenControlBulkPipe() argument
812 error = USB_HostOhciGetGtd(usbHostState, &gtd, 1); in USB_HostOhciOpenControlBulkPipe()
825 …pipe->ed->NextED = s_UsbHostOhciTd[usbHostState->controllerId].ed[USB_HOST_OHCI_CONTROL_ED_DUMMY].… in USB_HostOhciOpenControlBulkPipe()
826 …s_UsbHostOhciTd[usbHostState->controllerId].ed[USB_HOST_OHCI_CONTROL_ED_DUMMY].NextED = (uint32_t)… in USB_HostOhciOpenControlBulkPipe()
827 usbHostState->usbRegBase->HcControl |= USB_HOST_OHCI_CONTROL_CLE_MASK; in USB_HostOhciOpenControlBulkPipe()
831 …pipe->ed->NextED = s_UsbHostOhciTd[usbHostState->controllerId].ed[USB_HOST_OHCI_BULK_ED_DUMMY].Nex… in USB_HostOhciOpenControlBulkPipe()
832 …s_UsbHostOhciTd[usbHostState->controllerId].ed[USB_HOST_OHCI_BULK_ED_DUMMY].NextED = (uint32_t)pip… in USB_HostOhciOpenControlBulkPipe()
833 usbHostState->usbRegBase->HcControl |= USB_HOST_OHCI_CONTROL_BLE_MASK; in USB_HostOhciOpenControlBulkPipe()
840 static usb_status_t USB_HostOhciOpenIsoPipe(usb_host_ohci_state_struct_t *usbHostState, in USB_HostOhciOpenIsoPipe() argument
855 error = USB_HostOhciFindStartFrame(usbHostState, pipe); in USB_HostOhciOpenIsoPipe()
863 error = USB_HostOhciGetItd(usbHostState, &itd, 1); in USB_HostOhciOpenIsoPipe()
878usbHostState->usbRegBase->HcControl &= ~(USB_HOST_OHCI_CONTROL_PLE_MASK | USB_HOST_OHCI_CONTROL_IE… in USB_HostOhciOpenIsoPipe()
880 (void)USB_HostOhciAddToPeriodicList(usbHostState, pipe); in USB_HostOhciOpenIsoPipe()
882usbHostState->usbRegBase->HcControl |= USB_HOST_OHCI_CONTROL_PLE_MASK | USB_HOST_OHCI_CONTROL_IE_M… in USB_HostOhciOpenIsoPipe()
889 static usb_status_t USB_HostOhciOpenInterruptPipe(usb_host_ohci_state_struct_t *usbHostState, in USB_HostOhciOpenInterruptPipe() argument
902 error = USB_HostOhciFindStartFrame(usbHostState, pipe); in USB_HostOhciOpenInterruptPipe()
909 error = USB_HostOhciGetGtd(usbHostState, &gtd, 1); in USB_HostOhciOpenInterruptPipe()
921 (void)USB_HostOhciAddToPeriodicList(usbHostState, pipe); in USB_HostOhciOpenInterruptPipe()
924 usbHostState->usbRegBase->HcControl |= USB_HOST_OHCI_CONTROL_PLE_MASK; in USB_HostOhciOpenInterruptPipe()
929 static void USB_HostOhciTdDoneHandle(usb_host_ohci_state_struct_t *usbHostState, in USB_HostOhciTdDoneHandle() argument
961 (void)USB_HostOhciFreeItd(usbHostState, itd); in USB_HostOhciTdDoneHandle()
1073 (void)USB_HostOhciFreeItd(usbHostState, itd); in USB_HostOhciTdDoneHandle()
1117 (void)USB_HostOhciFreeGtd(usbHostState, gtd); in USB_HostOhciTdDoneHandle()
1129 … if (kStatus_USB_Success == USB_HostOhciLinkGtdControlTr(usbHostState, pipe, pipe->ed->trListHead)) in USB_HostOhciTdDoneHandle()
1182 p = usbHostState->pipeListInUsing; in USB_HostOhciTdDoneHandle()
1201 … startFrame = s_UsbHostOhciHcca[usbHostState->controllerId].HccaFrameNumber; in USB_HostOhciTdDoneHandle()
1206 … currentFrame = s_UsbHostOhciHcca[usbHostState->controllerId].HccaFrameNumber; in USB_HostOhciTdDoneHandle()
1218 (void)USB_HostOhciWritePipe(usbHostState, pipe, currentTr); in USB_HostOhciTdDoneHandle()
1232 usbHostState->controlIsBusy = 0U; in USB_HostOhciTdDoneHandle()
1240 if (0U == usbHostState->controlIsBusy) in USB_HostOhciTdDoneHandle()
1242 p = usbHostState->pipeListInUsing; in USB_HostOhciTdDoneHandle()
1251 … if (kStatus_USB_Success == USB_HostOhciLinkGtdControlTr(usbHostState, p, p->ed->trListHead)) in USB_HostOhciTdDoneHandle()
1253 usbHostState->controlIsBusy = 1U; in USB_HostOhciTdDoneHandle()
1276 … if (kStatus_USB_Success != USB_HostOhciLinkGtdTr(usbHostState, pipe, pipe->ed->trListHead)) in USB_HostOhciTdDoneHandle()
1299 static usb_status_t USB_HostOhciCancelPipe(usb_host_ohci_state_struct_t *usbHostState, in USB_HostOhciCancelPipe() argument
1315 …startFrame = s_UsbHostOhciHcca[usbHostState->controllerId].HccaFrameNumb… in USB_HostOhciCancelPipe()
1320 currentFrame = s_UsbHostOhciHcca[usbHostState->controllerId].HccaFrameNumber; in USB_HostOhciCancelPipe()
1324 USB_HostOhciDisableIsr(usbHostState); in USB_HostOhciCancelPipe()
1329 …gtd = (usb_host_ohci_general_transfer_descritpor_struct_t *)((uint32_t)usbHostState->tdDoneList… in USB_HostOhciCancelPipe()
1333 if (((uint32_t)gtd) < ((uint32_t)&s_UsbHostOhciTd[usbHostState->controllerId].gtd[0])) in USB_HostOhciCancelPipe()
1351 USB_HostOhciTdDoneHandle(usbHostState, pipe, trCurrent, gtd, itd); in USB_HostOhciCancelPipe()
1354 usbHostState->tdDoneListHead = gtdPos; in USB_HostOhciCancelPipe()
1393 USB_HostOhciTdDoneHandle(usbHostState, pipe, trCurrent, gtd, itd); in USB_HostOhciCancelPipe()
1431 USB_HostOhciEnableIsr(usbHostState); in USB_HostOhciCancelPipe()
1438 static usb_status_t USB_HostOhciRemoveFromPeriodicList(usb_host_ohci_state_struct_t *usbHostState, in USB_HostOhciRemoveFromPeriodicList() argument
1448 … ed = (usb_host_ohci_endpoint_descritpor_struct_t *)s_UsbHostOhciHcca[usbHostState->controllerId] in USB_HostOhciRemoveFromPeriodicList()
1457 … s_UsbHostOhciHcca[usbHostState->controllerId].HccaInterrruptTable[i] = ed->NextED; in USB_HostOhciRemoveFromPeriodicList()
1472 static usb_status_t USB_HostOhciCloseControlBulkPipe(usb_host_ohci_state_struct_t *usbHostState, in USB_HostOhciCloseControlBulkPipe() argument
1478 (void)USB_HostOhciCancelPipe(usbHostState, pipe, NULL); in USB_HostOhciCloseControlBulkPipe()
1484 edHead = &s_UsbHostOhciTd[usbHostState->controllerId].ed[USB_HOST_OHCI_CONTROL_ED_DUMMY]; in USB_HostOhciCloseControlBulkPipe()
1488 edHead = &s_UsbHostOhciTd[usbHostState->controllerId].ed[USB_HOST_OHCI_BULK_ED_DUMMY]; in USB_HostOhciCloseControlBulkPipe()
1492 usbHostState, in USB_HostOhciCloseControlBulkPipe()
1510 static usb_status_t USB_HostOhciCloseIsoInterruptPipe(usb_host_ohci_state_struct_t *usbHostState, in USB_HostOhciCloseIsoInterruptPipe() argument
1513 (void)USB_HostOhciCancelPipe(usbHostState, pipe, NULL); in USB_HostOhciCloseIsoInterruptPipe()
1520 usbHostState, in USB_HostOhciCloseIsoInterruptPipe()
1527 usbHostState, in USB_HostOhciCloseIsoInterruptPipe()
1531 (void)USB_HostOhciRemoveFromPeriodicList(usbHostState, pipe); in USB_HostOhciCloseIsoInterruptPipe()
1557 static usb_status_t USB_HostOhciLinkGtdControlTr(usb_host_ohci_state_struct_t *usbHostState, in USB_HostOhciLinkGtdControlTr() argument
1584 status = USB_HostOhciGetGtd(usbHostState, &p, 1); in USB_HostOhciLinkGtdControlTr()
1608 status = USB_HostOhciGetGtd(usbHostState, &p, 1); in USB_HostOhciLinkGtdControlTr()
1627 status = USB_HostOhciGetGtd(usbHostState, &p, 1); in USB_HostOhciLinkGtdControlTr()
1681 usbHostState->usbRegBase->HcCommandStatus |= USB_HOST_OHCI_COMMAND_STATUS_CLF_MASK; in USB_HostOhciLinkGtdControlTr()
1686 static usb_status_t USB_HostOhciLinkGtdTr(usb_host_ohci_state_struct_t *usbHostState, in USB_HostOhciLinkGtdTr() argument
1733 status = USB_HostOhciGetGtd(usbHostState, &p, tdCount); in USB_HostOhciLinkGtdTr()
1792 usbHostState->usbRegBase->HcCommandStatus |= USB_HOST_OHCI_COMMAND_STATUS_BLF_MASK; in USB_HostOhciLinkGtdTr()
1828 static usb_status_t USB_HostOhciLinkItdTr(usb_host_ohci_state_struct_t *usbHostState, in USB_HostOhciLinkItdTr() argument
1861 status = USB_HostOhciGetItd(usbHostState, &p, tdCount); in USB_HostOhciLinkItdTr()
1876 currentFrame = s_UsbHostOhciHcca[usbHostState->controllerId].HccaFrameNumber; in USB_HostOhciLinkItdTr()
1911 static usb_status_t USB_HostOhciTokenDone(usb_host_ohci_state_struct_t *usbHostState) in USB_HostOhciTokenDone() argument
1922 USB_HostOhciDisableIsr(usbHostState); in USB_HostOhciTokenDone()
1924 …gtd = (usb_host_ohci_general_transfer_descritpor_struct_t *)((uint32_t)usbHostState->tdDoneListHea… in USB_HostOhciTokenDone()
1927 if (((uint32_t)gtd) < ((uint32_t)&s_UsbHostOhciTd[usbHostState->controllerId].gtd[0])) in USB_HostOhciTokenDone()
1942 USB_HostOhciTdDoneHandle(usbHostState, pipe, trCurrent, gtd, itd); in USB_HostOhciTokenDone()
1943 if (usbHostState->tdDoneListTail == gtd) in USB_HostOhciTokenDone()
1949 usbHostState->tdDoneListHead = NULL; in USB_HostOhciTokenDone()
1950 usbHostState->tdDoneListTail = NULL; in USB_HostOhciTokenDone()
1952 USB_HostOhciEnableIsr(usbHostState); in USB_HostOhciTokenDone()
1957 static usb_status_t USB_HostOhciSof(usb_host_ohci_state_struct_t *usbHostState) in USB_HostOhciSof() argument
1971 USB_HostOhciDisableIsr(usbHostState); in USB_HostOhciSof()
1972 pipe = usbHostState->pipeListInUsing; in USB_HostOhciSof()
1982 (void)USB_HostOhciCancelPipe(usbHostState, pipe, pipe->ed->trListHead); in USB_HostOhciSof()
2011 if (pipe->startWriteBackCount != usbHostState->writeBackCount) in USB_HostOhciSof()
2028 … USB_HostOhciTdDoneHandle(usbHostState, pipe, pipe->ed->trListHead, gtd, itd); in USB_HostOhciSof()
2037 pipe->startWriteBackCount = usbHostState->writeBackCount; in USB_HostOhciSof()
2049 USB_HostOhciEnableIsr(usbHostState); in USB_HostOhciSof()
2055 static usb_status_t UBS_HostOhciControllerReset(usb_host_ohci_state_struct_t *usbHostState) in UBS_HostOhciControllerReset() argument
2057 usbHostState->usbRegBase->HcCommandStatus = USB_HOST_OHCI_COMMAND_STATUS_HCR_MASK; in UBS_HostOhciControllerReset()
2058 … while (0U != (usbHostState->usbRegBase->HcCommandStatus & USB_HOST_OHCI_COMMAND_STATUS_HCR_MASK)) in UBS_HostOhciControllerReset()
2065 static usb_status_t UBS_HostOhciControllerInit(usb_host_ohci_state_struct_t *usbHostState) in UBS_HostOhciControllerInit() argument
2081 for (i = 0; i < (sizeof(s_UsbHostOhciTd[usbHostState->controllerId].ed) / in UBS_HostOhciControllerInit()
2085 s_UsbHostOhciTd[usbHostState->controllerId].ed[i].stateUnion.stateBitField.K = 1U; in UBS_HostOhciControllerInit()
2090 *((uint8_t *)(&s_UsbHostOhciHcca[usbHostState->controllerId]) + i) = 0x00U; in UBS_HostOhciControllerInit()
2093 usbHostState->pipeListInUsing = NULL; in UBS_HostOhciControllerInit()
2094 usbHostState->pipeList = &usbHostState->pipePool[0]; in UBS_HostOhciControllerInit()
2095 pipe = usbHostState->pipeList; in UBS_HostOhciControllerInit()
2096 pipe->ed = &s_UsbHostOhciTd[usbHostState->controllerId].ed[3]; in UBS_HostOhciControllerInit()
2099 temp = (void *)(&usbHostState->pipePool[i]); in UBS_HostOhciControllerInit()
2103 pipe->ed = &s_UsbHostOhciTd[usbHostState->controllerId].ed[3U + i]; in UBS_HostOhciControllerInit()
2108 usbHostState->gtdList = &s_UsbHostOhciTd[usbHostState->controllerId].gtd[0]; in UBS_HostOhciControllerInit()
2109 gtd = usbHostState->gtdList; in UBS_HostOhciControllerInit()
2112 gtd->nextGtd = &s_UsbHostOhciTd[usbHostState->controllerId].gtd[i]; in UBS_HostOhciControllerInit()
2116 usbHostState->gtdCount = USB_HOST_CONFIG_OHCI_MAX_GTD; in UBS_HostOhciControllerInit()
2120 usbHostState->itdList = &s_UsbHostOhciTd[usbHostState->controllerId].itd[0]; in UBS_HostOhciControllerInit()
2121 itd = usbHostState->itdList; in UBS_HostOhciControllerInit()
2124 itd->NextTD = (uint32_t)&s_UsbHostOhciTd[usbHostState->controllerId].itd[i]; in UBS_HostOhciControllerInit()
2128 usbHostState->itdCount = USB_HOST_CONFIG_OHCI_MAX_ITD; in UBS_HostOhciControllerInit()
2130 usbHostState->tdDoneListTail = NULL; in UBS_HostOhciControllerInit()
2131 usbHostState->tdDoneListHead = NULL; in UBS_HostOhciControllerInit()
2132 usbHostState->writeBackCount = 0U; in UBS_HostOhciControllerInit()
2137 usbHostState->usbRegBase->HcControl = 0U; in UBS_HostOhciControllerInit()
2138 usbHostState->usbRegBase->HcControl &= ~USB_HOST_OHCI_CONTROL_HCFS_MASK; in UBS_HostOhciControllerInit()
2139usbHostState->usbRegBase->HcControl |= USB_HOST_OHCI_CONTROL_HCFS(USB_HOST_OHCI_CONTROL_HCFS_OPERA… in UBS_HostOhciControllerInit()
2140 usbHostState->usbRegBase->HcFmInterval = in UBS_HostOhciControllerInit()
2143 usbHostState->usbRegBase->HcPeriodicStart = USB_HOST_OHCI_PERIODIC_START_PS( in UBS_HostOhciControllerInit()
2145 s_UsbHostOhciTd[usbHostState->controllerId].ed[USB_HOST_OHCI_CONTROL_ED_DUMMY].NextED = 0U; in UBS_HostOhciControllerInit()
2146 usbHostState->usbRegBase->HcControlHeadED = in UBS_HostOhciControllerInit()
2147 (uint32_t)&s_UsbHostOhciTd[usbHostState->controllerId].ed[USB_HOST_OHCI_CONTROL_ED_DUMMY]; in UBS_HostOhciControllerInit()
2148 s_UsbHostOhciTd[usbHostState->controllerId].ed[USB_HOST_OHCI_BULK_ED_DUMMY].NextED = 0U; in UBS_HostOhciControllerInit()
2149 usbHostState->usbRegBase->HcBulkHeadED = in UBS_HostOhciControllerInit()
2150 (uint32_t)&s_UsbHostOhciTd[usbHostState->controllerId].ed[USB_HOST_OHCI_BULK_ED_DUMMY]; in UBS_HostOhciControllerInit()
2151 s_UsbHostOhciTd[usbHostState->controllerId].ed[USB_HOST_OHCI_PERIODIC_ED_DUMMY].NextED = 0U; in UBS_HostOhciControllerInit()
2154 s_UsbHostOhciHcca[usbHostState->controllerId].HccaInterrruptTable[i] = in UBS_HostOhciControllerInit()
2155 … (uint32_t)&s_UsbHostOhciTd[usbHostState->controllerId].ed[USB_HOST_OHCI_PERIODIC_ED_DUMMY]; in UBS_HostOhciControllerInit()
2157 usbHostState->usbRegBase->HcHCCA = (uint32_t)&s_UsbHostOhciHcca[usbHostState->controllerId]; in UBS_HostOhciControllerInit()
2158usbHostState->usbRegBase->HcControl |= USB_HOST_OHCI_CONTROL_CBSR(USB_HOST_OHCI_CONTROL_CBSR_C1_B1… in UBS_HostOhciControllerInit()
2159 if (0U != (usbHostState->usbRegBase->HcRhDescriptorA & USB_HOST_OHCI_RHDESCRIPTORA_NPS_MASK)) in UBS_HostOhciControllerInit()
2166 if (usbHostState->usbRegBase->HcRhDescriptorA & USB_HOST_OHCI_RHDESCRIPTORA_PSM_MASK) in UBS_HostOhciControllerInit()
2168 usbHostState->usbRegBase->HcRhDescriptorB |= USB_HOST_OHCI_RHDESCRIPTORB_PPCM(0xFFFEUL); in UBS_HostOhciControllerInit()
2169 …for (i = 0; i < (usbHostState->usbRegBase->HcRhDescriptorA & USB_HOST_OHCI_RHDESCRIPTORA_NDP_MASK)… in UBS_HostOhciControllerInit()
2171 uint32_t portStatus = usbHostState->usbRegBase->HcRhPortStatus[i]; in UBS_HostOhciControllerInit()
2174 usbHostState->usbRegBase->HcRhPortStatus[i] = portStatus; in UBS_HostOhciControllerInit()
2176 usbHostState->usbRegBase->HcRhStatus = USB_HOST_OHCI_RHSTATUS_LPSC_MASK; in UBS_HostOhciControllerInit()
2180 usbHostState->usbRegBase->HcRhStatus = USB_HOST_OHCI_RHSTATUS_LPSC_MASK; in UBS_HostOhciControllerInit()
2183 usbHostState->usbRegBase->HcRhDescriptorB &= ~USB_HOST_OHCI_RHDESCRIPTORB_PPCM(0xFFFEUL); in UBS_HostOhciControllerInit()
2184 usbHostState->usbRegBase->HcRhStatus = USB_HOST_OHCI_RHSTATUS_LPSC_MASK; in UBS_HostOhciControllerInit()
2187 usbHostState->usbRegBase->HcInterruptDisable |= USB_HOST_OHCI_INTERRUPT_DISABLE_MASK; in UBS_HostOhciControllerInit()
2188 usbHostState->usbRegBase->HcInterruptEnable |= in UBS_HostOhciControllerInit()
2213 usb_host_ohci_state_struct_t *usbHostState; in USB_HostOhciCreate() local
2223 usbHostState = &s_UsbHostOhciState[controllerId - (uint8_t)kUSB_ControllerOhci0]; in USB_HostOhciCreate()
2225 usbHostState->hostHandle = hostHandle; in USB_HostOhciCreate()
2226 usbHostState->controllerId = controllerId - (uint8_t)kUSB_ControllerOhci0; in USB_HostOhciCreate()
2228usbHostState->usbRegBase = (usb_host_ohci_hcor_struct_t *)usb_base_addrs[usbHostState->controllerI… in USB_HostOhciCreate()
2229 usbHostState->isrNumber = (uint8_t)usb_irq[usbHostState->controllerId]; in USB_HostOhciCreate()
2230 usbHostState->ohciEvent = (osa_event_handle_t)&usbHostState->taskEventHandleBuffer[0]; in USB_HostOhciCreate()
2231 if (KOSA_StatusSuccess != OSA_EventCreate(usbHostState->ohciEvent, 1U)) in USB_HostOhciCreate()
2233 usbHostState->ohciEvent = NULL; in USB_HostOhciCreate()
2239 usbHostState->mutex = (osa_mutex_handle_t)(&usbHostState->mutexBuffer[0]); in USB_HostOhciCreate()
2240 if (KOSA_StatusSuccess != OSA_MutexCreate(usbHostState->mutex)) in USB_HostOhciCreate()
2242 usbHostState->mutex = NULL; in USB_HostOhciCreate()
2243 (void)USB_HostOhciDestory(usbHostState); in USB_HostOhciCreate()
2251 usbHostState->usbRegBase->PortMode &= ~USB_HOST_OHCI_PORTMODE_DEV_ENABLE_MASK; in USB_HostOhciCreate()
2252 usbHostState->portNumber = in USB_HostOhciCreate()
2253 (uint8_t)(usbHostState->usbRegBase->HcRhDescriptorA & USB_HOST_OHCI_RHDESCRIPTORA_NDP_MASK); in USB_HostOhciCreate()
2254 if (0U == usbHostState->portNumber) in USB_HostOhciCreate()
2259 (void)USB_HostOhciDestory(usbHostState); in USB_HostOhciCreate()
2263 usbHostState->portState = (usb_host_ohci_port_state_struct_t *)OSA_MemoryAllocate( in USB_HostOhciCreate()
2265 ((uint32_t)usbHostState->portNumber)); /* malloc host ohci port state */ in USB_HostOhciCreate()
2266 if (NULL == usbHostState->portState) in USB_HostOhciCreate()
2268 (void)USB_HostOhciDestory(usbHostState); in USB_HostOhciCreate()
2275 (void)UBS_HostOhciControllerReset(usbHostState); in USB_HostOhciCreate()
2277 (void)UBS_HostOhciControllerInit(usbHostState); in USB_HostOhciCreate()
2279 *controllerHandle = (usb_host_handle)usbHostState; in USB_HostOhciCreate()
2294 usb_host_ohci_state_struct_t *usbHostState = (usb_host_ohci_state_struct_t *)controllerHandle; in USB_HostOhciDestory() local
2296 usbHostState->usbRegBase->HcInterruptDisable |= USB_HOST_OHCI_INTERRUPT_DISABLE_MASK; in USB_HostOhciDestory()
2297 usbHostState->usbRegBase->HcRhStatus |= USB_HOST_OHCI_RHSTATUS_LPS_MASK; in USB_HostOhciDestory()
2298 usbHostState->usbRegBase->HcControl = 0U; in USB_HostOhciDestory()
2300 if (NULL != usbHostState->portState) in USB_HostOhciDestory()
2302 (void)OSA_MemoryFree(usbHostState->portState); in USB_HostOhciDestory()
2303 usbHostState->portState = NULL; in USB_HostOhciDestory()
2306 if (NULL != usbHostState->mutex) in USB_HostOhciDestory()
2308 (void)OSA_MutexDestroy(usbHostState->mutex); in USB_HostOhciDestory()
2309 usbHostState->mutex = NULL; in USB_HostOhciDestory()
2312 if (NULL != usbHostState->ohciEvent) in USB_HostOhciDestory()
2314 (void)OSA_EventDestroy(usbHostState->ohciEvent); in USB_HostOhciDestory()
2315 usbHostState->ohciEvent = NULL; in USB_HostOhciDestory()
2327 usb_host_ohci_state_struct_t *usbHostState = (usb_host_ohci_state_struct_t *)controllerHandle; in USB_HostOhciOpenPipe() local
2329 status = USB_HostOhciGetPipe(&usbHostState->pipeList, &pipe); in USB_HostOhciOpenPipe()
2417 … status = USB_HostOhciOpenControlBulkPipe(usbHostState, pipe); in USB_HostOhciOpenPipe()
2420 status = USB_HostOhciOpenControlBulkPipe(usbHostState, pipe); in USB_HostOhciOpenPipe()
2425 status = USB_HostOhciOpenIsoPipe(usbHostState, pipe); in USB_HostOhciOpenPipe()
2429 status = USB_HostOhciOpenInterruptPipe(usbHostState, pipe); in USB_HostOhciOpenPipe()
2442 (void)USB_HostOhciInsertPipe(&usbHostState->pipeList, pipe); in USB_HostOhciOpenPipe()
2446 (void)USB_HostOhciInsertPipe(&usbHostState->pipeListInUsing, pipe); in USB_HostOhciOpenPipe()
2454 usb_host_ohci_state_struct_t *usbHostState = (usb_host_ohci_state_struct_t *)controllerHandle; in USB_HostOhciClosePipe() local
2461 (void)USB_HostOhciCloseControlBulkPipe(usbHostState, pipe); in USB_HostOhciClosePipe()
2468 (void)USB_HostOhciCloseIsoInterruptPipe(usbHostState, pipe); in USB_HostOhciClosePipe()
2475 (void)USB_HostOhciRemovePipe(&usbHostState->pipeListInUsing, pipe); in USB_HostOhciClosePipe()
2477 (void)USB_HostOhciInsertPipe(&usbHostState->pipeList, pipe); in USB_HostOhciClosePipe()
2486 usb_host_ohci_state_struct_t *usbHostState = (usb_host_ohci_state_struct_t *)controllerHandle; in USB_HostOhciWritePipe() local
2509 if (0U != usbHostState->controlIsBusy) in USB_HostOhciWritePipe()
2515 status = USB_HostOhciLinkGtdControlTr(usbHostState, pipe, transfer); in USB_HostOhciWritePipe()
2519 usbHostState->controlIsBusy = 1U; in USB_HostOhciWritePipe()
2526 status = USB_HostOhciLinkGtdTr(usbHostState, pipe, transfer); in USB_HostOhciWritePipe()
2600 usb_host_ohci_state_struct_t *usbHostState = (usb_host_ohci_state_struct_t *)controllerHandle; in USB_HostOhciIoctl() local
2618 …USB_HostOhciCancelPipe(usbHostState, (usb_host_ohci_pipe_struct_t *)param->pipeHandle, param->tran… in USB_HostOhciIoctl()
2623 status = USB_HostOhciControlBus(usbHostState, *((uint8_t *)ioctlParam)); in USB_HostOhciIoctl()
2628 … *((uint32_t *)ioctlParam) = (s_UsbHostOhciHcca[usbHostState->controllerId].HccaFrameNumber); in USB_HostOhciIoctl()
2639 USB_HostOhciDelay(usbHostState, 2U); in USB_HostOhciIoctl()
2664 usb_host_ohci_state_struct_t *usbHostState; in USB_HostOhciTaskFunction() local
2671usbHostState = (usb_host_ohci_state_struct_t *)((usb_host_instance_t *)hostHandle)->controllerHand… in USB_HostOhciTaskFunction()
2674 …if (KOSA_StatusSuccess == OSA_EventWait(usbHostState->ohciEvent, 0xFFU, 0, USB_OSA_WAIT_TIMEOUT, &… in USB_HostOhciTaskFunction()
2678 (void)USB_HostOhciPortChange(usbHostState); in USB_HostOhciTaskFunction()
2682 (void)USB_HostOhciTokenDone(usbHostState); in USB_HostOhciTaskFunction()
2686 (void)USB_HostOhciSof(usbHostState); in USB_HostOhciTaskFunction()
2690 for (uint8_t i = 0; i < usbHostState->portNumber; i++) in USB_HostOhciTaskFunction()
2692 … if ((uint8_t)kUSB_DeviceOhciPortPhyAttached == usbHostState->portState[i].portStatus) in USB_HostOhciTaskFunction()
2695 if (kStatus_USB_Success == USB_HostAttachDevice(usbHostState->hostHandle, in USB_HostOhciTaskFunction()
2696usbHostState->portState[i].portSpeed, 0U, i, 1U, in USB_HostOhciTaskFunction()
2699usbHostState->portState[i].portStatus = (uint8_t)kUSB_DeviceOhciPortAttached; in USB_HostOhciTaskFunction()
2706 for (uint8_t i = 0; i < usbHostState->portNumber; i++) in USB_HostOhciTaskFunction()
2708 … if ((uint8_t)kUSB_DeviceOhciPortPhyDetached == usbHostState->portState[i].portStatus) in USB_HostOhciTaskFunction()
2710 usbHostState->portState[i].portStatus = (uint8_t)kUSB_DeviceOhciPortDetached; in USB_HostOhciTaskFunction()
2711 (void)USB_HostDetachDevice(usbHostState->hostHandle, 0U, i); in USB_HostOhciTaskFunction()
2720 usb_host_ohci_state_struct_t *usbHostState; in USB_HostOhciIsrFunction() local
2729usbHostState = (usb_host_ohci_state_struct_t *)((usb_host_instance_t *)hostHandle)->controllerHand… in USB_HostOhciIsrFunction()
2731 interruptStatus = usbHostState->usbRegBase->HcInterruptStatus; in USB_HostOhciIsrFunction()
2732 interruptStatus &= usbHostState->usbRegBase->HcInterruptEnable; in USB_HostOhciIsrFunction()
2736 USB_HostOhciLinkTdToDoneList(usbHostState); in USB_HostOhciIsrFunction()
2737 (void)OSA_EventSet(usbHostState->ohciEvent, USB_HOST_OHCI_EVENT_TOKEN_DONE); in USB_HostOhciIsrFunction()
2745 temp = (void *)usbHostState->pipeListInUsing; in USB_HostOhciIsrFunction()
2758 … if (kStatus_USB_Success == USB_HostOhciLinkItdTr(usbHostState, pipe, pipe->ed->dealTr)) in USB_HostOhciIsrFunction()
2776 (void)OSA_EventSet(usbHostState->ohciEvent, USB_HOST_OHCI_EVENT_SOF); in USB_HostOhciIsrFunction()
2782 (void)OSA_EventSet(usbHostState->ohciEvent, USB_HOST_OHCI_EVENT_PORT_CHANGE); in USB_HostOhciIsrFunction()
2785 usbHostState->usbRegBase->HcInterruptStatus = interruptStatus; /* clear interrupt */ in USB_HostOhciIsrFunction()