1 /* 2 * Copyright (c) 2015, Freescale Semiconductor, Inc. 3 * Copyright 2016 - 2017 NXP 4 * All rights reserved. 5 * 6 * SPDX-License-Identifier: BSD-3-Clause 7 */ 8 #ifndef __USB_PHY_H__ 9 #define __USB_PHY_H__ 10 11 /******************************************************************************* 12 * Definitions 13 ******************************************************************************/ 14 typedef struct _usb_phy_config_struct 15 { 16 uint8_t D_CAL; /* Decode to trim the nominal 17.78mA current source */ 17 uint8_t TXCAL45DP; /* Decode to trim the nominal 45-Ohm series termination resistance to the USB_DP output pin */ 18 uint8_t TXCAL45DM; /* Decode to trim the nominal 45-Ohm series termination resistance to the USB_DM output pin */ 19 } usb_phy_config_struct_t; 20 21 #if defined(__cplusplus) 22 extern "C" { 23 #endif 24 25 /******************************************************************************* 26 * API 27 ******************************************************************************/ 28 /*! 29 * @brief EHCI PHY get USB phy bass address. 30 * 31 * This function is used to get USB phy bass address. 32 * 33 * @param[in] controllerId EHCI controller ID; See the #usb_controller_index_t. 34 * 35 * @retval USB phy bass address. 36 */ 37 extern void *USB_EhciPhyGetBase(uint8_t controllerId); 38 39 /*! 40 * @brief EHCI PHY initialization. 41 * 42 * This function initializes the EHCI PHY IP. 43 * 44 * @param[in] controllerId EHCI controller ID; See the #usb_controller_index_t. 45 * @param[in] freq The external input clock. 46 * 47 * @retval kStatus_USB_Success Cancel successfully. 48 * @retval kStatus_USB_Error The freq value is incorrect. 49 */ 50 extern uint32_t USB_EhciPhyInit(uint8_t controllerId, uint32_t freq, usb_phy_config_struct_t *phyConfig); 51 52 /*! 53 * @brief ehci phy initialization for suspend and resume. 54 * 55 * This function initialize ehci phy IP for suspend and resume. 56 * 57 * @param[in] controllerId ehci controller id, please reference to #usb_controller_index_t. 58 * @param[in] freq the external input clock. 59 * for example: if the external input clock is 16M, the parameter freq should be 16000000. 60 * 61 * @retval kStatus_USB_Success cancel successfully. 62 * @retval kStatus_USB_Error the freq value is incorrect. 63 */ 64 extern uint32_t USB_EhciLowPowerPhyInit(uint8_t controllerId, uint32_t freq, usb_phy_config_struct_t *phyConfig); 65 66 /*! 67 * @brief EHCI PHY deinitialization. 68 * 69 * This function deinitializes the EHCI PHY IP. 70 * 71 * @param[in] controllerId EHCI controller ID; See #usb_controller_index_t. 72 */ 73 extern void USB_EhciPhyDeinit(uint8_t controllerId); 74 75 /*! 76 * @brief EHCI PHY disconnect detection enable or disable. 77 * 78 * This function enable/disable the host EHCI disconnect detection. 79 * 80 * @param[in] controllerId EHCI controller ID; See #usb_controller_index_t. 81 * @param[in] enable 82 * 1U - enable; 83 * 0U - disable; 84 */ 85 extern void USB_EhcihostPhyDisconnectDetectCmd(uint8_t controllerId, uint8_t enable); 86 #if ((defined FSL_FEATURE_SOC_USBPHY_COUNT) && (FSL_FEATURE_SOC_USBPHY_COUNT > 0U)) 87 #if ((defined FSL_FEATURE_USBHSD_HAS_EXIT_HS_ISSUE) && (FSL_FEATURE_USBHSD_HAS_EXIT_HS_ISSUE > 0U)) 88 /*! 89 * @brief Force the PHY enter FS Mode 90 * 91 * on RT500 and RT600, the device doesn't enter FS Mode after vbus is invalide and the controller works as HS. 92 * 93 * @param[in] controllerId EHCI controller ID; See #usb_controller_index_t. 94 * @param[in] enable 95 * 1U - enable; 96 * 0U - disable; 97 */ 98 extern void USB_PhyDeviceForceEnterFSMode(uint8_t controllerId, uint8_t enable); 99 #endif 100 #endif 101 #if defined(__cplusplus) 102 } 103 #endif 104 105 #endif /* __USB_PHY_H__ */ 106