⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 bsppcc_mx31.cpp

📁 Freescale ARM11系列CPU MX31的WINCE 5.0下的BSP
💻 CPP
字号:
//
// 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.

//------------------------------------------------------------------------------
// Copyright (C) 2006, Freescale Semiconductor, Inc. All Rights Reserved.
// THIS SOURCE CODE, AND ITS USE AND DISTRIBUTION, IS SUBJECT TO THE TERMS
// AND CONDITIONS OF THE APPLICABLE LICENSE AGREEMENT 
//------------------------------------------------------------------------------

Module Name:  

Abstract:

    Platform dependent PCMCIA initialization functions

Notes: 
--*/

#include <windows.h>
#include <ceddk.h>

#include "bsp.h"
#include "socksv2.h"
#include "socket.h"
#include "pcmciabridge.h"

static PCSP_PBC_REGS g_pPBC = NULL;

class BSPCPcmciaBusBridge : public CPcmciaBusBridge
{
public:
    BSPCPcmciaBusBridge( LPCTSTR RegPath );
    ~BSPCPcmciaBusBridge( void );
    
    virtual void   SetPccPower(UINT8 fVCC, BOOL bInPowerMode);

protected:
    virtual BOOL   InitGpio(void);
    virtual void   DeinitGpio(void);
 };

BSPCPcmciaBusBridge::BSPCPcmciaBusBridge( LPCTSTR RegPath )
                 :CPcmciaBusBridge(RegPath)
{
}

BSPCPcmciaBusBridge::~BSPCPcmciaBusBridge()              
{
}

//
// Initialize GPIO pins for PCMCIA
//
BOOL BSPCPcmciaBusBridge::InitGpio(void)
{
    PHYSICAL_ADDRESS phyAddr_pbc;
    	
	//CPLD registers
	phyAddr_pbc.QuadPart = BSP_BASE_REG_PA_PBC_BASE;
	g_pPBC = (PCSP_PBC_REGS) MmMapIoSpace(phyAddr_pbc, sizeof(CSP_PBC_REGS), FALSE);
	
	//EMI MUX Settings
	DDKIomuxSetPinMux (DDK_IOMUX_PIN_SDBA0, DDK_IOMUX_OUT_FUNC, DDK_IOMUX_IN_NONE);
	DDKIomuxSetPinMux (DDK_IOMUX_PIN_SDBA1, DDK_IOMUX_OUT_FUNC, DDK_IOMUX_IN_NONE);
	DDKIomuxSetPinMux (DDK_IOMUX_PIN_LBA, DDK_IOMUX_OUT_FUNC, DDK_IOMUX_IN_NONE);
	DDKIomuxSetPinMux (DDK_IOMUX_PIN_RW, DDK_IOMUX_OUT_FUNC, DDK_IOMUX_IN_NONE);
	DDKIomuxSetPinMux (DDK_IOMUX_PIN_EB0, DDK_IOMUX_OUT_FUNC, DDK_IOMUX_IN_NONE);
	DDKIomuxSetPinMux (DDK_IOMUX_PIN_EB1, DDK_IOMUX_OUT_FUNC, DDK_IOMUX_IN_NONE);
	DDKIomuxSetPinMux (DDK_IOMUX_PIN_OE, DDK_IOMUX_OUT_FUNC, DDK_IOMUX_IN_NONE);
	
	// PCMCIA IOMUX settings
	DDKIomuxSetPinMux (DDK_IOMUX_PIN_PC_POE, DDK_IOMUX_OUT_FUNC, DDK_IOMUX_IN_NONE);
	DDKIomuxSetPinMux (DDK_IOMUX_PIN_PC_RW_B, DDK_IOMUX_OUT_FUNC, DDK_IOMUX_IN_NONE);
	DDKIomuxSetPinMux (DDK_IOMUX_PIN_IOIS16, DDK_IOMUX_OUT_FUNC, DDK_IOMUX_IN_FUNC);
	DDKIomuxSetPinMux (DDK_IOMUX_PIN_PC_RST, DDK_IOMUX_OUT_FUNC, DDK_IOMUX_IN_NONE);
	DDKIomuxSetPinMux (DDK_IOMUX_PIN_PC_BVD2, DDK_IOMUX_OUT_FUNC, DDK_IOMUX_IN_FUNC);
	DDKIomuxSetPinMux (DDK_IOMUX_PIN_PC_BVD1, DDK_IOMUX_OUT_FUNC, DDK_IOMUX_IN_FUNC);
	DDKIomuxSetPinMux (DDK_IOMUX_PIN_PC_VS2, DDK_IOMUX_OUT_FUNC, DDK_IOMUX_IN_FUNC);
	DDKIomuxSetPinMux (DDK_IOMUX_PIN_PC_VS1, DDK_IOMUX_OUT_FUNC, DDK_IOMUX_IN_FUNC);
	DDKIomuxSetPinMux (DDK_IOMUX_PIN_PC_PWRON, DDK_IOMUX_OUT_FUNC, DDK_IOMUX_IN_FUNC);
	DDKIomuxSetPinMux (DDK_IOMUX_PIN_PC_READY, DDK_IOMUX_OUT_FUNC, DDK_IOMUX_IN_FUNC);
	DDKIomuxSetPinMux (DDK_IOMUX_PIN_PC_WAIT_B, DDK_IOMUX_OUT_FUNC, DDK_IOMUX_IN_FUNC);
	DDKIomuxSetPinMux (DDK_IOMUX_PIN_PC_CD2_B, DDK_IOMUX_OUT_FUNC, DDK_IOMUX_IN_FUNC);
	DDKIomuxSetPinMux (DDK_IOMUX_PIN_PC_CD1_B, DDK_IOMUX_OUT_FUNC, DDK_IOMUX_IN_FUNC);

	OUTREG16(&g_pPBC->BCTRL2_SET, CSP_BITFMASK(PBC_BCTRL2_VPPEN));
	OUTREG16(&g_pPBC->BCTRL2_SET, CSP_BITFMASK(PBC_BCTRL2_VCCEN));

 	OUTREG16(&g_pPBC->BCTRL3_CLEAR,(1<<PBC_BCTRL3_CARD2_SEL));
#define PBC_BCTRL4_PCMCIA_EN	4 // To enable PCMCIA buffer
	OUTREG16(&g_pPBC->BCTRL4_CLEAR, (1<<PBC_BCTRL4_PCMCIA_EN));	

	return TRUE;
}

//
// Set the PCCARD Power Supply
//
void   BSPCPcmciaBusBridge::SetPccPower(UINT8 fVCC, BOOL bInPowerMode)
{
	UINT8 voltage = fVCC;
	
	switch( voltage ) {
		case 0:
			if (bInPowerMode)
			{
				// Set to 0V Voltage
				OUTREG16(&g_pPBC->BCTRL2_CLEAR, CSP_BITFMASK(PBC_BCTRL2_VPPEN));
				OUTREG16(&g_pPBC->BCTRL2_CLEAR, CSP_BITFMASK(PBC_BCTRL2_VCCEN));
			}
			break;			
		case 33:
			// Set to 3.3V Voltage
		case 50:
			// Set to 5.0V Voltage - PBC supports only 3.3V
			OUTREG16(&g_pPBC->BCTRL2_SET, CSP_BITFMASK(PBC_BCTRL2_VPPEN));
			OUTREG16(&g_pPBC->BCTRL2_SET, CSP_BITFMASK(PBC_BCTRL2_VCCEN));

			OUTREG16(&g_pPBC->BCTRL3_CLEAR,(1<<PBC_BCTRL3_CARD2_SEL));
			OUTREG16(&g_pPBC->BCTRL4_CLEAR, (1<<PBC_BCTRL4_PCMCIA_EN));	

			break;
		
		default:
			break;
	}
}

//
// Deinitialize GPIO pins for PCMCIA
//
void BSPCPcmciaBusBridge::DeinitGpio()
{
	OUTREG16(&g_pPBC->BCTRL3_SET,(1<<PBC_BCTRL3_CARD2_SEL));
	OUTREG16(&g_pPBC->BCTRL4_SET, (1<<PBC_BCTRL4_PCMCIA_EN));

	if(g_pPBC) {
		MmUnmapIoSpace((void *)g_pPBC, sizeof(CSP_PBC_REGS));
		g_pPBC= NULL;
	}
}

// this function will be used to create a new instance of the bridge class
CPcmciaBusBridge* CreatePCCardBusBridge( LPCTSTR pwszInfo )
{
    return new BSPCPcmciaBusBridge( pwszInfo );
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -