📄 xllp_usbohci_platform.c
字号:
/******************************************************************************
**
** COPYRIGHT (C) 2002 Intel Corporation.
**
** This software as well as the software described in it is furnished under
** license and may only be used or copied in accordance with the terms of the
** license. The information in this file is furnished for informational use
** only, is subject to change without notice, and should not be construed as
** a commitment by Intel Corporation. Intel Corporation assumes no
** responsibility or liability for any errors or inaccuracies that may appear
** in this document or any software that may be provided in association with
** this document.
** Except as permitted by such license, no part of this document may be
** reproduced, stored in a retrieval system, or transmitted in any form or by
** any means without the express written consent of Intel Corporation.
**
** FILENAME: xllp_usbohci.c
**
** PURPOSE: XLLP USB Host APIs - Platform specific
**
** Valid for : PXA27x Platforms
**
**
******************************************************************************/
#include "xllp_usbohci.h"
#include "xllp_usbohci_platform.h"
/*******************************************************************************
*
* FUNCTION: XllpUsbhPortEnableOverCurrentNotification
*
* DESCRIPTION: Configure platform specific gpios to be able to get over-current notification
* to the USB Host port.
*
*
* INPUT PARAMETERS: P_XLLP_USBH_HANDLE_T pUsbhHandle
* XLLP_USBH_PORT_T Port - Port 1 (XLLP_USBH_PORT_1)
* or Port 2 (XLLP_USBH_PORT_2)
* or Port 3 (XLLP_USBH_PORT_3)
*
* RETURNS:
* Success: 0 (XLLP_USBH_SUCCESS)
* Failure: XLLP_USBH_FEATURE_NOT_SUPPORTED for XLLP_USBH_PORT_2 and XLLP_USBH_PORT_3
*
* CALLS: XllpGpioSetDirectionIn, XllpGpioSetAlternateFn
*
* CALLED BY: XllpUsbhPowerUp
*
* PROTOTYPE: XLLP_USBH_ERROR_T XllpUsbhPortEnableOverCurrentNotification(
* P_XLLP_USBH_HANDLE_T pUsbhHandle,
* XLLP_USBH_PORT_T Port) ;
*
*
*******************************************************************************/
XLLP_USBH_ERROR_T XllpUsbhPortEnableOverCurrentNotification(P_XLLP_USBH_HANDLE_T pUsbhHandle,XLLP_USBH_PORT_T Port)
{
unsigned long ulPinArrayParms[3];
unsigned long ulAlternateFunctionParms[3];
if (Port == XLLP_USBH_PORT_1)
{
// Configure GPIO 88 as follows:
// Direction: Input
// Alternate function: 1
// direction & alternate function gpio apis both use the same pin array
ulPinArrayParms[0] = 1;
ulPinArrayParms[1] = 88;
XllpGpioSetDirectionIn( pUsbhHandle->pGPIORegs, ulPinArrayParms );
ulAlternateFunctionParms[0] = 1;
ulAlternateFunctionParms[1] = XLLP_GPIO_ALT_FN_1;
XllpGpioSetAlternateFn( pUsbhHandle->pGPIORegs, ulPinArrayParms, ulAlternateFunctionParms );
return (XLLP_USBH_SUCCESS);
}
else
return (XLLP_USBH_FEATURE_NOT_SUPPORTED);
}
/*******************************************************************************
*
* FUNCTION: XllpUsbhPortEnablePower
*
* DESCRIPTION: Configure platform specific gpios to enable/disable power to the devices connected
* to USB Host port.
*
*
* INPUT PARAMETERS: P_XLLP_USBH_HANDLE_T pUsbhHandle
* XLLP_USBH_PORT_T Port - Port 1 (XLLP_USBH_PORT_1)
* or Port 2 (XLLP_USBH_PORT_2)
* or Port 3 (XLLP_USBH_PORT_3)
*
* RETURNS:
* Success: 0 (XLLP_USBH_SUCCESS)
* Failure: XLLP_USBH_FEATURE_NOT_SUPPORTED for XLLP_USBH_PORT_2 and XLLP_USBH_PORT_3
*
* CALLS: XllpGpioSetOutput0, XllpGpioSetDirectionOut, XllpGpioSetAlternateFn
*
* CALLED BY: XllpUsbhPowerUp
*
* PROTOTYPE: XLLP_USBH_ERROR_T XllpUsbhPortEnablePower(P_XLLP_USBH_HANDLE_T pUsbhHandle,
* XLLP_USBH_PORT_T Port);
*
*
*******************************************************************************/
XLLP_USBH_ERROR_T XllpUsbhPortEnablePower(P_XLLP_USBH_HANDLE_T pUsbhHandle, XLLP_USBH_PORT_T Port)
{
unsigned long ulPinArrayParms[3];
unsigned long ulAlternateFunctionParms[3];
if (Port == XLLP_USBH_PORT_1)
{
// Configure GPIO 89 as follows:
// Level: Low (enable)
// Direction: Output
// Alternate function: 2
// level, direction & alternate function gpio apis all use the same pin array
ulPinArrayParms[0] = 1;
ulPinArrayParms[1] = 89;
XllpGpioSetOutput0( pUsbhHandle->pGPIORegs, ulPinArrayParms );
XllpGpioSetDirectionOut( pUsbhHandle->pGPIORegs, ulPinArrayParms );
ulAlternateFunctionParms[0] = 1;
ulAlternateFunctionParms[1] = XLLP_GPIO_ALT_FN_2;
XllpGpioSetAlternateFn( pUsbhHandle->pGPIORegs, ulPinArrayParms, ulAlternateFunctionParms );
return (XLLP_USBH_SUCCESS);
}
else
return (XLLP_USBH_FEATURE_NOT_SUPPORTED);
}
/*******************************************************************************
*
* FUNCTION: XllpUsbhInitPlatformSpecificConfig
*
* DESCRIPTION: Initializes XLLP_PLATFORM_USBH_T struct according to
* platform specific details to enable platform specific
* USB Host reset.
*
*
* INPUT PARAMETERS: P_XLLP_USBH_HANDLE_T pUsbhHandle
*
*
* RETURNS:
* Success: 0 (XLLP_USBH_SUCCESS)
* Failure:
*
* CALLS: None.
*
* CALLED BY: HCD
*
* PROTOTYPE: XLLP_USBH_ERROR_T XllpUsbhInitPlatformSpecificConfig(P_XLLP_USBH_HANDLE_T pUsbhHandle);
*
*
*******************************************************************************/
XLLP_USBH_ERROR_T XllpUsbhInitPlatformSpecificConfig(P_XLLP_USBH_HANDLE_T pUsbhHandle)
{
//These settings are specific for Mainstone platform
//And, will change from platform to platform
// Setting power sense polarity to active low
pUsbhHandle->pPlatformUSBHConfig->usbhpwr_level = XLLP_LO;
// Setting power control polarity to active low
pUsbhHandle->pPlatformUSBHConfig->usbhpen_level = XLLP_LO;
// Enable power to the USB single-ended receivers and the USB port 1 power supply
pUsbhHandle->pPlatformUSBHConfig->port1_ssep_enable = XLLP_TRUE;
// Enable power to the USB single-ended receivers and the USB port 2 power supply
pUsbhHandle->pPlatformUSBHConfig->port2_ssep_enable = XLLP_TRUE;
// Disable power to the USB single-ended receivers and the USB port 3 power supply
pUsbhHandle->pPlatformUSBHConfig->port3_ssep_enable = XLLP_FALSE;
// Allow above settings to take effect
pUsbhHandle->pPlatformUSBHConfig->global_sse_enable = XLLP_TRUE;
return (XLLP_USBH_SUCCESS);
}
/*******************************************************************************
*
* FUNCTION: XllpUsbhConfigPlatformSpecificUSBHReset
*
* DESCRIPTION: Peroforms platform specific USBH Reset according to
* XLLP_PLATFORM_USBH_T struct initialized by
* XllpUsbhInitPlatformSpecificConfig
*
*
* INPUT PARAMETERS: P_XLLP_USBH_HANDLE_T pUsbhHandle
*
*
* RETURNS:
* Success: 0 (XLLP_USBH_SUCCESS)
* Failure:
*
* CALLS:
*
* CALLED BY: HCD
*
* PROTOTYPE: XLLP_USBH_ERROR_T XllpUsbhConfigPlatformSpecificUSBHReset(P_XLLP_USBH_HANDLE_T pUsbhHandle);
*
*
*******************************************************************************/
XLLP_USBH_ERROR_T XllpUsbhConfigPlatformSpecificUSBHReset(P_XLLP_USBH_HANDLE_T pUsbhHandle)
{
XLLP_LEVEL_T usbhpwr_level = pUsbhHandle->pPlatformUSBHConfig->usbhpwr_level;
XLLP_LEVEL_T usbhpen_level = pUsbhHandle->pPlatformUSBHConfig->usbhpen_level;
XLLP_BOOL_T port1_ssep_enable = pUsbhHandle->pPlatformUSBHConfig->port1_ssep_enable;
XLLP_BOOL_T port2_ssep_enable = pUsbhHandle->pPlatformUSBHConfig->port2_ssep_enable;
XLLP_BOOL_T port3_ssep_enable = pUsbhHandle->pPlatformUSBHConfig->port3_ssep_enable;
XLLP_BOOL_T global_sse_enable = pUsbhHandle->pPlatformUSBHConfig->global_sse_enable;
//Configure platform specific power sense polarity
XllpUsbhConfigurePowerSensePolarity(pUsbhHandle, usbhpwr_level) ;
//Configure platform specific power control polarity
XllpUsbhConfigurePowerControlPolarity(pUsbhHandle, usbhpen_level) ;
//Enable/disable power to the USB single-ended receivers and the USB port 1 power supply
XllpUsbhPortEnableSleepStandbyEnable(pUsbhHandle, XLLP_USBH_PORT_1, port1_ssep_enable);
//Enable/disable power to the USB single-ended receivers and the USB port 2 power supply
XllpUsbhPortEnableSleepStandbyEnable(pUsbhHandle, XLLP_USBH_PORT_2, port2_ssep_enable);
//Enable/disable power to the USB single-ended receivers and the USB port 3 power supply
XllpUsbhPortEnableSleepStandbyEnable(pUsbhHandle, XLLP_USBH_PORT_3, port3_ssep_enable);
//For all downstream ports, enable/disable power to the USB single-ended receivers and
//the USB ports power supply
XllpUsbhConfigureGlobalSleepStandbyEnable(pUsbhHandle, global_sse_enable);
return (XLLP_USBH_SUCCESS);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -