hwinit.c

来自「Windows CE 6.0 BSP for VOIPAC Board (PXA」· C语言 代码 · 共 86 行

C
86
字号
//
// 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.
//
//------------------------------------------------------------------------------
//
//  File:  hwinit.c
//
#include <windows.h>
#include <oal.h>
#include <omap730.h>

//------------------------------------------------------------------------------

BOOL InitOTGTransceiver();

//------------------------------------------------------------------------------

BOOL InitOTGController()
{
    OMAP730_OTG_REGS *pOTGRegs = OALPAtoUA(OMAP730_OTG_REGS_PA);

    // Reset all USB controllers
    OUTREG32(&pOTGRegs->SYSCON_1, OTG_SYSCON_1_SOFT_RESET);
    while ((INREG32(&pOTGRegs->SYSCON_1) & OTG_SYSCON_1_RESET_DONE) == 0);
    // Configure OTG controller
    OUTREG32(&pOTGRegs->SYSCON_1, (1 << 24)|(1 << 20)|(1 << 16));
    OUTREG32(&pOTGRegs->SYSCON_2, 0x5B240400);
    // Done
    return TRUE;
}

//------------------------------------------------------------------------------

BOOL InitClockController()
{
    OMAP730_ULPD_REGS *pULPDRegs = OALPAtoUA(OMAP730_ULPD_REGS_PA);
    OMAP730_CLKM_REGS *pCLKMRegs = OALPAtoUA(OMAP730_CLKM_REGS_PA);

    // Enable CLK_CLOCK_USBO_PLL
    SETREG16(&pULPDRegs->SOFT_REQ, SOFT_USBO_PLL_REQ);
    // Enable CLK_CLOCK_USBD_PLL
    SETREG16(&pULPDRegs->SOFT_REQ, SOFT_USBD_PLL_REQ);
    // Request clock
    SETREG16(&pCLKMRegs->IDLECT3, EN_OCPI_CK);
    // It must be present even if CPU waits for interrupt
    CLRREG16(&pCLKMRegs->IDLECT3, IDLOCPI_ARM);
    // Done
    return TRUE;
}

//------------------------------------------------------------------------------

BOOL InitializeHardware()
{
    // Configure clock controller
    InitClockController();
    // Configure OTG transceiver
    InitOTGTransceiver();
    // Configure OTG controller
    InitOTGController();
    // Done
    return TRUE;
}

//------------------------------------------------------------------------------

DWORD GetUniqueDeviceID()
{
    OMAP730_CONFIG_REGS *pConfigRegs = OALPAtoUA(OMAP730_CONFIG_REGS_PA);
    DWORD dwID0, dwID1;

    dwID0 = INREG32(&pConfigRegs->MPU_DIE_ID0);
    dwID1 = INREG32(&pConfigRegs->MPU_DIE_ID1);
    return dwID0 ^ dwID1;
}

//------------------------------------------------------------------------------

⌨️ 快捷键说明

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