?? sdhcslot.h
字號:
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
//
// Use of this sample source code is subject to the terms of the Microsoft
// license agreement under which you licensed this sample source code. If
// you did not accept the terms of the license agreement, you are not
// authorized to use this sample source code. For the terms of the license,
// please see the license agreement between you and Microsoft or, if applicable,
// see the LICENSE.RTF on your install media or the root of your tools installation.
// THE SAMPLE SOURCE CODE IS PROVIDED "AS IS", WITH NO WARRANTIES OR INDEMNITIES.
//
// Copyright (c) 2002 BSQUARE Corporation. All rights reserved.
// DO NOT REMOVE --- BEGIN EXTERNALLY DEVELOPED SOURCE CODE ID 40973--- DO NOT REMOVE
#ifndef _SDHCSLOT_DEFINED
#define _SDHCSLOT_DEFINED
#include "SDCardDDK.h"
#include "SDHCD.h"
#include <ceddk.h>
#include "SDHCRegs.h"
#include "Sdhcdma.hpp"
#include <s3c6410.h>
#define SDHC_MAX_POWER_SUPPLY_RAMP_UP 250 // SD Phys Layer 6.6
#define NUM_BYTE_FOR_POLLING_MODE 0x800
#define POLLING_MODE_TIMEOUT_DEFAULT 2
#define SDHC_POWER_UP_DELAY_KEY _T("PowerUpDelay")
#define SDHC_WAKEUP_SOURCES_KEY _T("DefaultWakeupSources")
#define SDHC_CAN_WAKE_ON_INT_KEY _T("AllowWakeOnSDIOInterrupts")
#define SDHC_FREQUENCY_KEY _T("BaseClockFrequency")
#define SDHC_TIMEOUT_FREQUENCY_KEY _T("TimeoutClockFrequency")
#define SDHC_TIMEOUT_KEY _T("TimeoutInMS")
#define SDHC_POLLINGMODE_SIZE _T("PollingModeSize")
#define SDHC_POLLINGMODE_TIMEOUT _T("PollingModeTiemout")
#define SDHC_DISABLE_DMA_KEY _T("DisableDMA")
#ifdef _SMDK6410_CH0_EXTCD_
// The enumeration for factors is used in card detect interrupt handler of HSMMC ch0 on SMRP6400.
typedef enum _SDSLOT_INT_TYPE {
SDSLOT_INT_NULL = 0,
SDSLOT_INT_CARD_DETECTED = 1,
} SDSLOT_INT_TYPE, *PSDSLOT_INT_TYPE;
#endif
typedef class CSDHCSlotBase {
friend class CSDHCSlotBaseDMA;
friend class CSDHCSlotBaseSDMA;
friend class CSDHCSlotBase32BitADMA2;
public:
// Constructor - only initializes the member data. True initialization
// occurs in Init().
CSDHCSlotBase();
virtual ~CSDHCSlotBase();
// Perform basic initialization including initializing the hardware
// so that the capabilities register can be read.
virtual BOOL Init(DWORD dwSlot, volatile BYTE *pbRegisters,
PSDCARD_HC_CONTEXT pHCDContext, DWORD dwSysIntr, HANDLE hBusAccess,
INTERFACE_TYPE interfaceType, DWORD dwBusNumber, CReg *pregDevice);
// Second stage of hardware initialization. Complete slot configuration
// and enable interrupts.
virtual SD_API_STATUS Start();
// Signals card removal disables the slot.
virtual SD_API_STATUS Stop();
// Process a slot option call.
virtual SD_API_STATUS SlotOptionHandler(SD_SLOT_OPTION_CODE sdOption,
PVOID pData, DWORD cbData);
// Get this slot's power state.
virtual CEDEVICE_POWER_STATE GetPowerState() { return m_cpsCurrent; }
// What power state is required upon power up?
virtual CEDEVICE_POWER_STATE GetPowerUpRequirement() { return m_cpsAtPowerDown; }
// Called when the device is suspending.
virtual VOID PowerDown();
// Called when the device is resuming.
virtual VOID PowerUp();
// Start this bus request.
virtual SD_API_STATUS BusRequestHandler(PSD_BUS_REQUEST pRequest);
// Returns TRUE if the interrupt routine needs servicing, say at
// initialization to see if a card is present.
virtual BOOL NeedsServicing() { return m_fCheckSlot; }
#ifndef _SMDK6410_CH0_EXTCD_
// Handle a slot interrupt. Also called when NeedsServicing() returns TRUE.
virtual VOID HandleInterrupt();
#else
// Prototype for the new Interrupt handler function can process factors on new card detect interrupt of HSMMC ch0 on SMDK6410.
virtual VOID HandleInterrupt(SDSLOT_INT_TYPE intType = SDSLOT_INT_NULL);
#endif
// In order to prevent infinite CARD INT occuring, below code is needed because of the architecture of HSMMC on s3c6410.
inline BOOL IsOnlySDIOInterrupt() {
WORD wIntStatus = ReadWord(SDHC_NORMAL_INT_STATUS);
if (wIntStatus == NORMAL_INT_STATUS_CARD_INT && m_isSDIOInterrupt == TRUE ) {
return TRUE;
}
return FALSE;
}
// Called by the controller to get the controller interrupt register.
inline WORD ReadControllerInterrupts() {
// We must use NORMAL_INT_STATUS instead of SLOT_INT_STATUS because SLOT_INT_STATUS is not apply to our controller.
return ReadWord(SDHC_NORMAL_INT_STATUS);
}
protected:
virtual SD_API_STATUS SubmitBusRequestHandler(PSD_BUS_REQUEST pRequest );
// What is this slot's maximum clock rate?
virtual DWORD DetermineMaxClockRate();
// What is this slot's maximum block length?
virtual DWORD DetermineMaxBlockLen();
// What should this slot use for timeout control?
virtual DWORD DetermineTimeoutControl();
// What are the default wakeup sources?
virtual DWORD DetermineWakeupSources();
// Set the slot voltage.
virtual VOID SetVoltage(DWORD dwVddSetting);
// Set the bus width and clock rate.
virtual VOID SetInterface(PSD_CARD_INTERFACE_EX pInterface);
// Set this slot's power state.
virtual VOID SetPowerState(CEDEVICE_POWER_STATE cpsNew);
// Get the capabilities register.
virtual SSDHC_CAPABILITIES GetCapabilities() {
SSDHC_CAPABILITIES caps;
caps.dw = ReadDword(SDHC_CAPABILITIES);
return caps;
}
virtual SSDHC_VERSION GetSDHCVersion() {
SSDHC_VERSION version;
version.uw = ReadWord(SDHC_HOST_CONTROLLER_VER);
return version;
}
// Fill in the slot info structure.
virtual SD_API_STATUS GetSlotInfo(PSDCARD_HC_SLOT_INFO pSlotInfo);
// Get the desired Vdd window.
virtual DWORD GetDesiredVddWindow();
// Get the max Vdd window.
virtual DWORD GetMaxVddWindow();
// Is the card write-protected?
virtual BOOL IsWriteProtected();
// Enable/disable SDIO card interrupts.
virtual VOID EnableSDIOInterrupts(BOOL fEnable);
// How much extra time in ms for initial clocks is needed upon
// insertion of a card for the power supply ramp up?
virtual DWORD GetPowerSupplyRampUpMs() {
return m_pregDevice->ValueDW(SDHC_POWER_UP_DELAY_KEY,
SDHC_MAX_POWER_SUPPLY_RAMP_UP);
}
// Register access routines. These are not virtual so that we get
// good inline read/write perf.
template <class T>
inline VOID WriteReg (DWORD dwOffset, T tValue) {
CheckRegOffset(dwOffset, sizeof(T));
volatile T *ptRegister = (volatile T *) (m_pbRegisters + dwOffset);
*ptRegister = tValue;
}
template <class T>
inline T ReadReg (DWORD dwOffset) {
CheckRegOffset(dwOffset, sizeof(T));
volatile T *ptRegister = (volatile T *) (m_pbRegisters + dwOffset);
return *ptRegister;
}
inline BYTE ReadByte (DWORD dwOffset) {
return ReadReg<BYTE>(dwOffset);
}
inline VOID WriteByte (DWORD dwOffset, BYTE bValue) {
WriteReg(dwOffset, bValue);
}
inline WORD ReadWord (DWORD dwOffset) {
return ReadReg<WORD>(dwOffset);
}
inline VOID WriteWord (DWORD dwOffset, WORD wValue) {
WriteReg(dwOffset, wValue);
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -