亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? sdio.c

?? AU1100嵌入式處理器SD卡驅動程序源碼
?? C
?? 第 1 頁 / 共 5 頁
字號:
///////////////////////////////////////////////////////////////////////////////
// Copyright (c) 2002 BSQUARE Corporation.  All rights reserved.
//
// Module Name:
//
//    SDIO.c
//
// Abstract:
//
//    Au1100 SDIO controller driver implementation
//
// Notes:
//
///////////////////////////////////////////////////////////////////////////////

#include "sdcardddk.h"
#include "sdhcd.h"
#include "sdio.h"
#include <gpio.h>

    // clock rate table structure
typedef struct _CLOCK_RATE_ENTRY {
    DWORD  Frequency;
    USHORT ControlValue;
} CLOCK_RATE_ENTRY, *PCLOCK_RATE_ENTRY;

    // lookup table of some of the more useful SD clock frequencies
CLOCK_RATE_ENTRY SDIOClockTable[] = 
    
{       // FREQ                         Divisor    Rate assuming 50MHz MCLK
    {CONTROLLER_CLOCK_FREQUENCY/512,    511},   // 98 Khz 
    {CONTROLLER_CLOCK_FREQUENCY/256,    255},   // 195 Khz
    {CONTROLLER_CLOCK_FREQUENCY/128,    127},   // 391 Khz
    {CONTROLLER_CLOCK_FREQUENCY/64,     63},    // 781 Khz
    {CONTROLLER_CLOCK_FREQUENCY/32,     31},    // 1.5 Mhz
    {CONTROLLER_CLOCK_FREQUENCY/16,     15},    // 3.13 Mhz
    {CONTROLLER_CLOCK_FREQUENCY/8,      7},     // 6.25 Mhz
    {CONTROLLER_CLOCK_FREQUENCY/4,      3},     // 12.5 Mhz
    {CONTROLLER_CLOCK_FREQUENCY/2,      1},     // 25 Mhz
};

#define NUM_CLOCK_ENTRIES sizeof(SDIOClockTable)/sizeof(CLOCK_RATE_ENTRY)

// structure containing configuration information for each slot
typedef struct {
	ULONG SDPhysAddr;
	ULONG TxDmaDeviceId;
	ULONG RxDmaDeviceId;
} AUSDIO_CONFIG;

AUSDIO_CONFIG AuSdConfig[] = {
	{ SD0_PHYS_ADDR, DMA_SD0_TX, DMA_SD0_RX },
	{ SD1_PHYS_ADDR, DMA_SD1_TX, DMA_SD1_RX }
};



///////////////////////////////////////////////////////////////////////////////
//  ResetSlot - reset the slot to its initial state
//  Input:  pSlot -   slot context
//  Output: 
//  Return: 
///////////////////////////////////////////////////////////////////////////////
VOID ResetSlot(PSDIO_SLOT pSlot, BOOL IsInitPath)
{
	ULONG divisor = 0;
	ULONG config2 = 0;

	if (!IsInitPath)
    {
		config2 = READ_REGISTER_ULONG((PULONG)&pSlot->pSD->config2);
		divisor = READ_REGISTER_ULONG((PULONG)&pSlot->pSD->config);
		divisor &= SD_CONFIG_DIV;
	}

		// reset the controller
	WRITE_REGISTER_ULONG((PULONG)&pSlot->pSD->enable, 0);
	WRITE_REGISTER_ULONG((PULONG)&pSlot->pSD->enable, SD_ENABLE_CE);
	WRITE_REGISTER_ULONG((PULONG)&pSlot->pSD->enable, SD_ENABLE_R | SD_ENABLE_CE);

		// enable the state machines
	WRITE_REGISTER_ULONG((PULONG)&pSlot->pSD->config2, config2 | SD_CONFIG2_EN );
		// set the timeout to max
	WRITE_REGISTER_ULONG((PULONG)&pSlot->pSD->timeout, SD_TIMEOUT_MAX );
   
		// write clock
	WRITE_REGISTER_ULONG((PULONG)&pSlot->pSD->config, divisor | SD_CONFIG_DE);

		// Disable all interrupts
	SD_INTERRUPTS_DISABLE(pSlot,0xFFFFFFFF);
		// Clear interrupt status
	SD_INTERRUPTS_CLEAR(pSlot,0xFFFFFFFF);
		// Enable master inerrupt
	SD_INTERRUPTS_ENABLE(pSlot, SD_Int_Master );
}     

///////////////////////////////////////////////////////////////////////////////
//  DumpSlot - dump the states of the slot 
//  Input:  pSlot -   slot context
//  Output: 
//  Return: 
///////////////////////////////////////////////////////////////////////////////
VOID DumpSlot( PSDIO_SLOT pSlot )
{
    RETAILMSG(1,(TEXT("SDIO SLOT %d\r\n"),pSlot->SlotNumber));
    RETAILMSG(1,(TEXT("SD_CONFIG = 0x%08X\r\n"),READ_REGISTER_ULONG((PULONG)&pSlot->pSD->config)));
    RETAILMSG(1,(TEXT("SD_ENABLE = 0x%08X\r\n"),READ_REGISTER_ULONG((PULONG)&pSlot->pSD->enable)));
    RETAILMSG(1,(TEXT("SD_CONFIG2 = 0x%08X\r\n"),READ_REGISTER_ULONG((PULONG)&pSlot->pSD->config2)));
    RETAILMSG(1,(TEXT("SD_BLKSIZE = 0x%08X\r\n"),READ_REGISTER_ULONG((PULONG)&pSlot->pSD->blksize)));
    RETAILMSG(1,(TEXT("SD_STATUS = 0x%08X\r\n"),READ_REGISTER_ULONG((PULONG)&pSlot->pSD->status)));
    RETAILMSG(1,(TEXT("SD_DEBUG = 0x%08X\r\n"),READ_REGISTER_ULONG((PULONG)&pSlot->pSD->debug)));
    RETAILMSG(1,(TEXT("SD_CMD = 0x%08X\r\n"),READ_REGISTER_ULONG((PULONG)&pSlot->pSD->cmd)));
    RETAILMSG(1,(TEXT("SD_CMDARG = 0x%08X\r\n"),READ_REGISTER_ULONG((PULONG)&pSlot->pSD->cmdarg)));
    RETAILMSG(1,(TEXT("SD_TIMEOUT = 0x%08X\r\n"),READ_REGISTER_ULONG((PULONG)&pSlot->pSD->timeout)));

    if (NULL!=pSlot->pCurrentRequest) {
        RETAILMSG(1, (TEXT("pCurrentRequest->CommandCode = %d\r\n"),pSlot->pCurrentRequest->CommandCode));
        RETAILMSG(1, (TEXT("pCurrentRequest->NumBlocks = %d\r\n"),pSlot->pCurrentRequest->NumBlocks));
        RETAILMSG(1, (TEXT("pCurrentRequest->BlockSize = %d\r\n"),pSlot->pCurrentRequest->BlockSize));
        RETAILMSG(1, (TEXT("pCurrentRequest->HCParam = %d\r\n"),pSlot->pCurrentRequest->HCParam));
    }

    RETAILMSG(1,(TEXT("InterruptMask = 0x%08X\r\n"),pSlot->InterruptMask));
    RETAILMSG(1,(TEXT("CardPresent   = %d\r\n"),pSlot->CardPresent));
    RETAILMSG(1,(TEXT("CheckSlotOnStartUp = %d\r\n"),pSlot->CheckSlotOnStartUp));
    RETAILMSG(1,(TEXT("CardInitialised = %d\r\n"),pSlot->CardInitialised));
}

///////////////////////////////////////////////////////////////////////////////
//  DumpController - dump the states of the controller 
//  Input:  pController -   controller context
//  Output: 
//  Return: 
///////////////////////////////////////////////////////////////////////////////
VOID DumpController( PSDIO_HW_CONTEXT pController )
{
	int i;
	
	for (i=0;i<SDIOPlatNumSlots();i++) {
		DumpSlot(&pController->Slots[i]);
	}
}

///////////////////////////////////////////////////////////////////////////////
//  SDIOClockOff - turn off the SD clock
//  Input:  pSlot -   slot context
//  Output: 
//  Return: 
//  Notes:  Currently simply leave the clock along for now.
///////////////////////////////////////////////////////////////////////////////
VOID SDIOClockOff(PSDIO_SLOT pSlot)
{
	ULONG tmp;

	    // turn off the clock
	tmp = READ_REGISTER_ULONG((PULONG)&pSlot->pSD->enable);
	tmp &= ~SD_ENABLE_CE;
//	WRITE_REGISTER_ULONG((PULONG)&pSlot->pSD->enable,tmp);

    DbgPrintZo(SDIO_CLOCK_ZONE, (TEXT("SDIOClockOff - Clock is now off \n")));
}

///////////////////////////////////////////////////////////////////////////////
//  SDIOClockOn - turn on the MMC Clock
//  Input:  pSlot -   slot context
//  Output: 
//  Return: 
//  Notes:  
///////////////////////////////////////////////////////////////////////////////
VOID SDIOClockOn(PSDIO_SLOT pSlot)
{
	ULONG tmp;

	    // turn on the clock
	tmp = READ_REGISTER_ULONG((PULONG)&pSlot->pSD->enable);
	tmp |= SD_ENABLE_CE;
	WRITE_REGISTER_ULONG((PULONG)&pSlot->pSD->enable,tmp);

    DbgPrintZo(SDIO_CLOCK_ZONE, (TEXT("SDIOClockOn  - Clock is now on \n")));
}

///////////////////////////////////////////////////////////////////////////////
//  SDIOSetRate - sets rate of SD Clock
//  Input:  pSlot -   slot context
//          pRate - desired clock rate in Hz
//  Output: pRate - the clock rate now in use
//  Return: 
//  Notes:  Divisor could easily be calculated
///////////////////////////////////////////////////////////////////////////////
VOID SDIOSetRate(PSDIO_SLOT pSlot, PDWORD pRate)
{
    ULONG ii;           // table index variable
	ULONG regValue;		// temp register value

        // check to see if the rate is below the first entry in the table
    if (*pRate <= SDIOClockTable[0].Frequency) {
        ii = 0;
    } else {
            // scan through the table looking for a frequency that
            // is close to the requested rate
        for (ii = 0; ii < (NUM_CLOCK_ENTRIES - 1); ii++) {
            if ((*pRate >= SDIOClockTable[ii].Frequency) &&
                (*pRate < SDIOClockTable[ii+1].Frequency)) {
                break;
            } 
        }
    }

    DbgPrintZo(SDIO_CLOCK_ZONE, (TEXT("SDIOSetRate - Requested Rate: %d, Setting clock rate to %d Hz \n"),
           *pRate, SDIOClockTable[ii].Frequency ));

        // return the actual frequency
    *pRate = SDIOClockTable[ii].Frequency;
		// update the divisor setting
	regValue = READ_REGISTER_ULONG((PULONG)&pSlot->pSD->config );
        // clear old divisor
	regValue &= ~SD_CONFIG_DIV;
        // set new divisot
	regValue |= SDIOClockTable[ii].ControlValue;
	regValue |= SD_CONFIG_DE;
        // write new value back
	WRITE_REGISTER_ULONG((PULONG)&pSlot->pSD->config, regValue );
}

#ifdef USE_DMA
///////////////////////////////////////////////////////////////////////////////
//  CopyFromDmaBuffer - Copy data from a DMA buffer into a requests data buffer
//  Input:  pRequest   - the request that this data belongs to
//          pDmaBuffer - which buffer to copy from
//  Output: 
//  Return:
//  Notes:  
///////////////////////////////////////////////////////////////////////////////
VOID CopyFromDmaBuffer(PSD_BUS_REQUEST pRequest,
                       PULONG          pDmaBuffer)
{
        // we are touching the block buffer, set the process permissions
    SD_SET_PROC_PERMISSIONS_FROM_REQUEST(pRequest) {
            // safe copy data into block buffer
        SDPerformSafeCopy(pRequest->pBlockBuffer+(pRequest->HCParam*pRequest->BlockSize),
                          pDmaBuffer, 
                          pRequest->BlockSize);
    } SD_RESTORE_PROC_PERMISSIONS();
}

///////////////////////////////////////////////////////////////////////////////
//  CopyToDmaBuffer - Copy data to a DMA buffer from a requests data buffer
//  Input:  pRequest   - the request that this data belongs to
//          pDmaBuffer - which buffer to copy to
//  Output: 
//  Return:
//  Notes:  
///////////////////////////////////////////////////////////////////////////////
VOID CopyToDmaBuffer(PSD_BUS_REQUEST pRequest,
                     PULONG          pDmaBuffer)
{
        // we are touching the block buffer, set the process permissions
    SD_SET_PROC_PERMISSIONS_FROM_REQUEST(pRequest) {
            // safe copy data into block buffer
        SDPerformSafeCopy(pDmaBuffer,
                          pRequest->pBlockBuffer+(pRequest->HCParam*pRequest->BlockSize),
                          pRequest->BlockSize);
    } SD_RESTORE_PROC_PERMISSIONS();
}

///////////////////////////////////////////////////////////////////////////////
//  SDIOInitializeDMA - Initialize DMA resources for an SD slot
//  Input:  pSlot        - slot context
//  Output: 
//  Return:
//  Notes:  
///////////////////////////////////////////////////////////////////////////////
BOOL SDIOInitializeDMA(PSDIO_SLOT pSlot)
{
    ULONG hwIntr;
    DWORD threadID;                         // thread ID

	// Allocate Tx DMA Channel
	pSlot->TxDmaChannel = HalAllocateDMAChannel();

	if (pSlot->TxDmaChannel==NULL) {
        DbgPrintZo(SDCARD_ZONE_ERROR,(TEXT("SDIO[%d]: Can't allocate Tx DMA Channel\r\n"),
                   pSlot->SlotNumber));
		goto ErrorReturn;
	}

	// Allocate Rx DMA Channel
	pSlot->RxDmaChannel = HalAllocateDMAChannel();

	if (pSlot->RxDmaChannel==NULL) {
        DbgPrintZo(SDCARD_ZONE_ERROR,(TEXT("SDIO[%d]: Can't allocate Rx DMA Channel\r\n"),
                   pSlot->SlotNumber));
		goto ErrorReturn;
	}

    pSlot->UsingDma = TRUE;

	// Initialize channels
	HalInitDmaChannel(pSlot->TxDmaChannel,
	                  AuSdConfig[pSlot->SlotNumber].TxDmaDeviceId,
	                  pSlot->DmaBufferSize,
					  TRUE);

	// Initialize channels
	HalInitDmaChannel(pSlot->RxDmaChannel,
	                  AuSdConfig[pSlot->SlotNumber].RxDmaDeviceId,
	                  pSlot->DmaBufferSize,
					  TRUE);

	HalSetDMAForReceive(pSlot->RxDmaChannel);

	// set up DMA interrupt
	hwIntr = HalGetDMAHwIntr(pSlot->TxDmaChannel);
	hwIntr |= (HalGetDMAHwIntr(pSlot->RxDmaChannel) << 8);

	RETAILMSG(1,(TEXT("SDIO Hooking HWINTR %08X\r\n"),hwIntr));

    pSlot->DmaSysIntr = InterruptConnect(Internal, 0, hwIntr, 0);
        
    if (SYSINTR_NOP==pSlot->DmaSysIntr) {
        DbgPrintZo(SDCARD_ZONE_ERROR,(TEXT("SDIO[%d]: Can't allocate DMA SYSINTR\r\n"),
                   pSlot->SlotNumber));
        goto ErrorReturn;
    }

	RETAILMSG(1,(TEXT("DmaSysIntr = %X\r\n"),pSlot->DmaSysIntr));

        // allocate the dma interrupt event
    pSlot->hDmaInterruptEvent = CreateEvent(NULL, FALSE, FALSE, NULL);

    if (NULL == pSlot->hDmaInterruptEvent) {
        DbgPrintZo(SDCARD_ZONE_ERROR,(TEXT("SDIO[%d]: Can't create DMA interrupt event\r\n"),
                   pSlot->SlotNumber));
        goto ErrorReturn;
    }

    if (!InterruptInitialize(pSlot->DmaSysIntr,

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
亚洲欧洲99久久| 美腿丝袜亚洲综合| 国内偷窥港台综合视频在线播放| 国产高清不卡二三区| 欧美日韩在线播| 日本一二三四高清不卡| 男女性色大片免费观看一区二区| 波多野结衣欧美| 精品国产乱码久久| 日韩中文字幕一区二区三区| 99精品视频一区二区三区| 亚洲精品在线网站| 日本午夜精品一区二区三区电影| 一本大道av一区二区在线播放 | 国产精品久久久久四虎| 久久99国产精品尤物| 欧美久久久影院| 五月开心婷婷久久| 日韩一区二区电影网| 日韩激情视频在线观看| 欧美视频一区二区在线观看| 亚洲最大成人综合| 在线免费亚洲电影| 亚洲人成电影网站色mp4| 成人午夜激情视频| 国产精品久久久久久久蜜臀| 成人性生交大合| 国产精品久久久久久福利一牛影视| 国产精品一区二区91| 国产日韩av一区二区| 国产精品一区2区| 国产日韩亚洲欧美综合| 粉嫩嫩av羞羞动漫久久久 | 亚洲人精品一区| 91社区在线播放| 亚洲一区视频在线| 欧美视频自拍偷拍| 日韩和欧美一区二区| 欧美一区二区三区四区高清| 久久se精品一区精品二区| 精品1区2区在线观看| 丁香亚洲综合激情啪啪综合| 国产精品私人影院| 在线观看日韩一区| 日韩一区精品视频| ww亚洲ww在线观看国产| 东方aⅴ免费观看久久av| 国产精品久久久久久久裸模| 欧美亚洲一区二区在线| 天堂在线一区二区| 久久久噜噜噜久噜久久综合| 9i看片成人免费高清| 亚洲高清久久久| 久久久天堂av| 色婷婷av一区| 日本aⅴ免费视频一区二区三区| 2021久久国产精品不只是精品| 国产成人av影院| 亚洲精品成人天堂一二三| 51精品秘密在线观看| 成人在线视频首页| 亚洲高清一区二区三区| 久久先锋影音av| 91国产福利在线| 久久激情综合网| 亚洲欧美日韩久久| 欧美精品一区二区三区很污很色的| av影院午夜一区| 裸体一区二区三区| 一区二区在线观看视频 | 欧美日韩视频在线观看一区二区三区| 蜜桃一区二区三区在线| 久久精品国产精品亚洲红杏| 国产精品你懂的在线| 欧美精品在线一区二区| 成人深夜福利app| 青青草97国产精品免费观看无弹窗版 | 久久久91精品国产一区二区精品| 一本色道亚洲精品aⅴ| 国内成人自拍视频| 婷婷六月综合亚洲| 樱桃国产成人精品视频| 久久亚洲精精品中文字幕早川悠里 | 欧美肥妇bbw| 91在线你懂得| 国产成人一级电影| 日本不卡视频在线观看| 一区二区三区在线观看动漫| 久久综合狠狠综合久久综合88| 欧美视频一区在线| 91福利国产精品| 99久久久久久99| 处破女av一区二区| 国产精品一二三| 美女久久久精品| 日本三级韩国三级欧美三级| 亚洲午夜电影在线| 亚洲人成伊人成综合网小说| 国产精品天天看| 国产亚洲一区二区三区在线观看| 91麻豆精品国产自产在线| 欧洲一区二区三区在线| 色欧美片视频在线观看在线视频| 成人午夜免费av| 成人久久视频在线观看| 国产精品亚洲视频| 国产精品69毛片高清亚洲| 国产在线视视频有精品| 国产在线观看一区二区| 国模娜娜一区二区三区| 狠狠色丁香婷婷综合久久片| 久久成人综合网| 国产综合成人久久大片91| 狠狠色丁香久久婷婷综合丁香| 美女一区二区在线观看| 久久成人18免费观看| 国产麻豆欧美日韩一区| 国产成人免费视频一区| 丰满亚洲少妇av| 91偷拍与自偷拍精品| 色综合 综合色| 欧美日韩在线不卡| 日韩一区二区精品葵司在线| 欧美va天堂va视频va在线| 精品盗摄一区二区三区| 久久久久国产精品厨房| 国产精品每日更新在线播放网址| 国产精品进线69影院| 一区二区三区四区高清精品免费观看 | 亚洲色图欧美偷拍| 一区二区三区在线观看欧美| 亚洲成人7777| 激情文学综合网| 成人黄色小视频在线观看| 一本久久精品一区二区| 欧美一区二区三区喷汁尤物| 久久综合狠狠综合久久综合88| 中文字幕第一区二区| 亚洲一二三四在线| 精品一区二区国语对白| 成人黄色一级视频| 7777精品伊人久久久大香线蕉| 久久综合九色综合久久久精品综合| 国产欧美日韩卡一| 五月天中文字幕一区二区| 极品少妇一区二区三区精品视频| 99在线热播精品免费| 欧美一区二区三区四区视频 | 亚洲1区2区3区4区| 国产一区二区福利| 欧美在线短视频| 久久婷婷国产综合国色天香 | 国产精品天干天干在观线| 亚洲精品视频一区二区| 久草热8精品视频在线观看| 91丝袜呻吟高潮美腿白嫩在线观看| 91精品国产91久久久久久最新毛片| 国产午夜精品福利| 蜜臀国产一区二区三区在线播放| 91在线国产福利| 久久亚洲影视婷婷| 亚洲成av人片www| eeuss鲁一区二区三区| 欧美成人猛片aaaaaaa| 亚洲激情在线激情| 岛国精品一区二区| 精品久久人人做人人爱| 亚洲成人第一页| 99r国产精品| 国产午夜精品一区二区三区嫩草| 天堂成人免费av电影一区| 色综合久久88色综合天天6| 国产无人区一区二区三区| 蜜桃91丨九色丨蝌蚪91桃色| 欧美午夜片在线观看| 亚洲欧洲成人av每日更新| 国产精品一二三区| 精品久久久久久久久久久院品网 | 一区二区三区.www| 成人黄色网址在线观看| 久久精品夜色噜噜亚洲aⅴ| 蜜臀91精品一区二区三区| 欧美猛男超大videosgay| 亚洲精品ww久久久久久p站| 成人午夜精品在线| 国产精品免费丝袜| 国产suv精品一区二区6| 久久久久久日产精品| 国产一区二区调教| 日韩一区二区三区视频| 日韩成人伦理电影在线观看| 538在线一区二区精品国产| 午夜精品久久久久影视| 欧美色图第一页| 香蕉加勒比综合久久| 欧美裸体bbwbbwbbw| 99国内精品久久| 亚洲欧洲综合另类在线| 色噜噜狠狠色综合中国| 亚洲bdsm女犯bdsm网站|