1 /**************************************************************************/ 2 /* */ 3 /* Copyright (c) Microsoft Corporation. All rights reserved. */ 4 /* */ 5 /* This software is licensed under the Microsoft Software License */ 6 /* Terms for Microsoft Azure RTOS. Full text of the license can be */ 7 /* found in the LICENSE file at https://aka.ms/AzureRTOS_EULA */ 8 /* and in the root directory of this software. */ 9 /* */ 10 /**************************************************************************/ 11 12 13 /**************************************************************************/ 14 /**************************************************************************/ 15 /** */ 16 /** USBX Component */ 17 /** */ 18 /** EHCI Controller Driver */ 19 /** */ 20 /**************************************************************************/ 21 /**************************************************************************/ 22 23 24 /* Include necessary system files. */ 25 26 #define UX_SOURCE_CODE 27 28 #include "ux_api.h" 29 #include "ux_hcd_ehci.h" 30 #include "ux_host_stack.h" 31 32 33 /**************************************************************************/ 34 /* */ 35 /* FUNCTION RELEASE */ 36 /* */ 37 /* _ux_hcd_ehci_door_bell_wait PORTABLE C */ 38 /* 6.1.10 */ 39 /* AUTHOR */ 40 /* */ 41 /* Chaoqiong Xiao, Microsoft Corporation */ 42 /* */ 43 /* DESCRIPTION */ 44 /* */ 45 /* This function will raise the doorbell and wait for its */ 46 /* acknowledgement. This mechanism is used to safely remove a physical */ 47 /* endpoint from EHCI. */ 48 /* */ 49 /* INPUT */ 50 /* */ 51 /* hcd_ehci Pointer to EHCI controller */ 52 /* */ 53 /* OUTPUT */ 54 /* */ 55 /* None */ 56 /* */ 57 /* CALLS */ 58 /* */ 59 /* _ux_hcd_ehci_register_read Read EHCI register */ 60 /* _ux_hcd_ehci_register_write Write EHCI register */ 61 /* _ux_host_semaphore_get Get semaphore */ 62 /* _ux_host_semaphore_put Release semaphore */ 63 /* */ 64 /* CALLED BY */ 65 /* */ 66 /* EHCI Controller Driver */ 67 /* */ 68 /* RELEASE HISTORY */ 69 /* */ 70 /* DATE NAME DESCRIPTION */ 71 /* */ 72 /* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */ 73 /* 09-30-2020 Chaoqiong Xiao Modified comment(s), */ 74 /* resulting in version 6.1 */ 75 /* 01-31-2022 Chaoqiong Xiao Modified comment(s), */ 76 /* refined macros names, */ 77 /* resulting in version 6.1.10 */ 78 /* */ 79 /**************************************************************************/ _ux_hcd_ehci_door_bell_wait(UX_HCD_EHCI * hcd_ehci)80VOID _ux_hcd_ehci_door_bell_wait(UX_HCD_EHCI *hcd_ehci) 81 { 82 83 ULONG ehci_register; 84 UINT status; 85 86 87 /* Protect against multiple thread entry to this HCD. */ 88 status = _ux_host_semaphore_get(&hcd_ehci -> ux_hcd_ehci_protect_semaphore, UX_WAIT_FOREVER); 89 if (status != UX_SUCCESS) 90 return; 91 92 /* Raise the doorbell to the HCD. */ 93 ehci_register = _ux_hcd_ehci_register_read(hcd_ehci, EHCI_HCOR_USB_COMMAND); 94 ehci_register |= EHCI_HC_IO_IAAD; 95 _ux_hcd_ehci_register_write(hcd_ehci, EHCI_HCOR_USB_COMMAND, ehci_register); 96 97 /* Wait for the doorbell to be awaken. */ 98 _ux_host_semaphore_get_norc(&hcd_ehci -> ux_hcd_ehci_doorbell_semaphore, UX_WAIT_FOREVER); 99 100 /* Free the protection semaphore. */ 101 _ux_host_semaphore_put(&hcd_ehci -> ux_hcd_ehci_protect_semaphore); 102 103 /* Return to caller. */ 104 return; 105 } 106 107