?? ms2_ohci2.cpp.svn-base
字號:
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
//
// Use of this source code is subject to the terms of the Microsoft end-user
// license agreement (EULA) under which you licensed this SOFTWARE PRODUCT.
// If you did not accept the terms of the EULA, you are not authorized to use
// this source code. For a copy of the EULA, please see the LICENSE.RTF on your
// install media.
//
/*++
THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
PARTICULAR PURPOSE.
Module Name:
ms2_ohci2.cpp
Abstract:
MainStoneII platform dependant part of the USB Open Host Controller Driver (OHCD).
Notes:
--*/
#include <windows.h>
#include <ceddk.h>
#include <hcdddsi.h>
#include <bulverde.h>
#include <bulverde_usbohci.h>
class MainStoneOhciPdd : public SOhcdPdd {
private:
volatile PBULVERDE_GPIO_REG m_pDCGPIOReg;
public:
MainStoneOhciPdd(LPCTSTR lpActiveRegistry) : SOhcdPdd(lpActiveRegistry)
{
m_pDCGPIOReg = NULL;
};
virtual BOOL Init() {
NKDbgPrintfW(TEXT("++ USBH Init...\r\n"));
if (m_pDCGPIOReg==NULL) {
PHYSICAL_ADDRESS ioPhysicalBase = { BULVERDE_BASE_REG_PA_GPIO, 0};
m_pDCGPIOReg = (PBULVERDE_GPIO_REG)MmMapIoSpace(ioPhysicalBase, sizeof(BULVERDE_GPIO_REG),FALSE);
}
if (m_pDCGPIOReg)
return SOhcdPdd::Init();
return FALSE;
}
~MainStoneOhciPdd() {
if (m_pDCGPIOReg)
MmUnmapIoSpace((PVOID)m_pDCGPIOReg,0);
}
// SetupUSBHostPWR:
//
// The root hub status register has some over-current indicator bits.
//
// The USB Host cannot detect over-current indications itself. Over-
// current detection must be performed by some external device on the
// platform. In the case of the Mainstone, this is done by U53, a
// MAX1693EUB USB Power Switch, which provides 5.0 volts to the USB
// and also provides an over-current detection signal for use here.
//
// Bulverde expects to get over-current indication as an input from
// GPIO 88. Therefore, the nFAULT signal of the MAX1693EUB USB Power
// switch on the Mainstone must be connected to GPIO 88.
//
// GPIO 88 must be configured as an input and set to alternate function 1.
//
// With the external circuitry wired in this fashion, and GPIO 88
// configured as above, an assertion on the MAX1693EUB USB Power
// Switch's nFAULT line will appear in the USB Host Root Hub status
// register, UHCRHS, or a status register for a specific port on the
// root hub, UHCRHPS1 or UHCRHPS2, depending on the setting of the
// UHCRHDA OverCurrentProtectionMode field.
//
// Note: Over current detection must be enabled in the USB Host
// Root Hub Descriptor A register, UHCRHDA, before assertions on
// GPIO 88 are detected. Furthermore, over current detection must
// be selected as global or per-port, also via the UHCRHDA register.
virtual void SetupUSBHostPWR(int port)
{
unsigned long ulPinArrayParms[3];
unsigned long ulAlternateFunctionParms[3];
// Configure GPIO 88 according to the discussion above:
// Direction: Input
// Alternate function: 1
// direction & alternate function gpio apis both use the same pin array
ulPinArrayParms[0] = 1;
ulPinArrayParms[1] = 88;
XllpGpioSetDirectionIn( m_pDCGPIOReg, ulPinArrayParms );
ulAlternateFunctionParms[0] = 1;
ulAlternateFunctionParms[1] = XLLP_GPIO_ALT_FN_1;
XllpGpioSetAlternateFn( m_pDCGPIOReg, ulPinArrayParms, ulAlternateFunctionParms );
}
// SetupUSBHostPEN:
//
// A USBHost platform must provide 5V to the USB. Bulverde cannot do this.
// Bulverde cannot source 5 volts, so some external circuitry is required.
// The MAX1693EUB USB Power Switch is a component used to provide 5 volts
// for a USB; it also can provide an over-current indicator if any device
// on the USB begins to draw too much current.
//
// U53 on the Mainstone has a MAX1693EUB USB Power Switch. This part
// is connected to a 5V power supply from the Mainstone. However, the
// Bulverde USB Host is in control of enabling or disabling the MAX
// 1693EUB USB Power Switch. When the USB Host enables the MAX1693EUB
// USB Power Switch by asserting the MAX1693EUB USB Power Switch's nON
// signal, the USB V+ and V- signals provide 5 Volts. When the nON signal
// is deasserted, the MAX1693EUB USB Power Switch turns the USB off.
//
// The Bulverde USB Host expects to use GPIO 89 as a power enable signal.
// The USB Host asserts or deasserts GPIO 89 by setting different bits
// depending on the configuration of the USB Host. The configuration bits
// that are important here are:
//
// UHCRHDA:NoPowerSwitching (aka NPS)
// 0: the port power will follow the global or per-port
// power enable bits, depending UHCRHDA:PortSwitchingMode
// 1: Not able to switch power on and off, so
// the port power will always be enabled.
//
// UHCRHDA:PowerSwitchingMode (aka PSM)
// 0: Global Power Switching Mode, power for all ports is
// enabled or disabled in response to SetGlobalPower or
// ClearGlobalPower commands.
// 1: Per-Port Power Switching Mode, some ports can have
// their power enabled or disabled individually with
// SetPortPower and ClearPortPower commands to the
// corresponding USB Host Root Hub Port Status registers
// UHCRHPS1 or UHCRHPS2. In this mode, other ports can
// respond to the global commands SetGlobalPower and
// ClearGlobalPower. Which type of power command the port
// responds to is controlled by the setting of the Port
// Power Control Mask bit for each port, found in the
// UHCRHDB:PPCM field
//
// Enabling / Disabling Global Power:
// Enable: Write 1 to UHCRHDB:LPSC
// Disable: Write 1 to UHCRHDB:LPS
//
// Enabling / Disabling a specific Port's power
// Enable: Write 1 to UHCRHPSx:PPS
// Disable: Write 1 to UHCRHPSx:LDA
// where x is 1 for Port1 or 2 for Port2
//
// Inclusion / Exclusion from Global Set/Clear Port Power Commands
// Inclusion: Write 0 to UHCRHDB:PPCM[x], the corresponding port
// will only recognize Global Set/Clear Power commands.
// It will not respond to specific SetPortPower or
// ClearPortPower commands.
// Exclusion: Write 1 to UHCRHDB:PPCM[x], the corresponding port
// will not recognize Global Set/Clear Power commands.
// It will only respond to specific SetPortPower or
// ClearPortPower commands.
// where x is 1 for Port1 or 2 for Prt2
// note: x=0 or x>3 are reserved bits in the PPCM field.
//
//
// Power Enable/Disable Configurations, in order of simplicity:
//
// 1. No Power Switching:
// Setup:
// A. Set UHCRHDA:NoPowerSwitching to 1. (Disallows power switching)
//
// Comments:
// The ports will be powered on as long as the USH Host block is on.
//
//
// 2. Global Power Switching Mode Only:
// Setup:
// A. Set UHCRHDA:NoPowerSwitching to 0. (Allows power switching)
// B. Set UHCRHDA:PowerSwitchingMode to 0. (Selects PowerSwitchingMode = Global)
//
// To Enable Global Power:
// Set UHCRHDB:LPSC to 1. (Turn on power to all ports)
//
// To Disable Global Power:
// Set UHCRHDB:LPS to 1. (Turn off power to all ports)
//
// Comments:
// Power switching is enabled.
// Global Power Mode is enabled.
// Power to all ports is enabled or disabled at the same time.
//
//
// 3. Per Port Power Switching Mode Only:
// Setup:
// A. Set UHCRHDA:NoPowerSwitching to 0. (Allows power switching)
// B. Set UHCRHDA:PowerSwitchingMode to 1. (Selects PowerSwitchingMode = Per-Port)
// C. Set UHCRHDB:PPCM[1] to 1. (Makes UHCRHP1 respond only to per port power commands)
// D. Set UHCRHDB:PPCM[2] to 1. (Makes UHCRHP2 respond only to per port power commands)
//
// To Enable Port1 Power:
// Set UHCRHPS1:PPS to 1 (Turn on power to port 1)
//
// To Disable Port1 Power:
// Set UHCRHPS1:LDA to 1 (Turn off power to port 1)
//
// To Enable Port2 Power:
// Set UHCRHPS2:PPS to 1 (Turn on power to port 2)
//
// To Disable Port2 Power:
// Set UHCRHPS2:LDA to 1 (Turn off power to port 2)
//
// Comments:
// Power switching is enabled.
// Per Port Power switching mode is enabled.
// Each port to participate in Per Port Power switching must set
// its corresponding bit in the UHCRHDB:PPCM mask.
// Power to individual ports is enabled or disabled without effecting other ports.
//
//
// 4. Combination Global Power Mode Switching and Per Port Power Switching Mode Only:
// Setup:
// A. Set UHCRHDA:NoPowerSwitching to 0. (Allows power switching)
// B. Set UHCRHDA:PowerSwitchingMode to 1. (Selects PowerSwitchingMode = Per-Port)
// C. Set UHCRHDB:PPCM[1] to 0. (Makes UHCRHP1 respond only to per port power commands)
// D. Set UHCRHDB:PPCM[2] to 1. (Makes UHCRHP2 respond only to per port power commands)
//
// To Enable Port1 Power:
// Set UHCRHDB:LPSC to 1. (A Global Power Command: port1 responds by turning on)
// (Port2 remains unaffected)
//
// To Disable Port1 Power:
// Set UHCRHDB:LPS to 1. (A Global Power Command: port1 responds by turning off)
// (Port2 remains unaffected)
//
// To Enable Port2 Power:
// Set UHCRHPS2:PPS to 1 (Turn on power to port 2)
// (Port1 remains unaffected)
//
// To Disable Port2 Power:
// Set UHCRHPS2:LDA to 1 (Turn off power to port 2)
// (Port1 remains unaffected)
//
// Comments:
// This example shows port1 being controlled by Global Power Mode commands,
// and port2 is controlled only by specific set or clear port power commands.
// Power switching is enabled.
// Per Port Power switching mode is enabled.
// Each port to participate in Per Port Power switching must set
// its corresponding bit in the UHCRHDB:PPCM mask.
// In this case:
// Port1 responds to Global Power Mode commands
// Port2 response to Per Port Power Mode commands
// All ports without their bits set in UHCRHDB:PPCM mask are effect by Global Power Mode commands.
// Power to individual ports is enabled or disabled without effecting other ports.
//
//
virtual void SetupUSBHostPEN(int Port)
{
unsigned long ulPinArrayParms[3];
unsigned long ulAlternateFunctionParms[3];
// Configure GPIO 89 according to the discussion above:
// 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;
XllpGpioSetOutputState1( m_pDCGPIOReg, ulPinArrayParms ); //GPIO89 output "1" for sp2525-1EN
// XllpGpioSetOutput0( m_pDCGPIOReg, ulPinArrayParms ); //GPIO89 output "0"
XllpGpioSetDirectionOut( m_pDCGPIOReg, ulPinArrayParms );
ulAlternateFunctionParms[0] = 1;
ulAlternateFunctionParms[1] = XLLP_GPIO_ALT_FN_2;
XllpGpioSetAlternateFn( m_pDCGPIOReg, ulPinArrayParms, ulAlternateFunctionParms );
}
};
SOhcdPdd * CreateBulverdeOhci(LPCTSTR lpActiveRegistry)
{
return new MainStoneOhciPdd(lpActiveRegistry);
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -