From d34db1740ec024fc3429ca7d1720cbda92c88c75 Mon Sep 17 00:00:00 2001 From: pvvx Date: Mon, 5 Dec 2016 15:39:49 +0300 Subject: [PATCH] add hal sdioh --- .../realtek/8195a/fwlib/src/hal_sdio_host.c | 110 ++++++++++++++++++ 1 file changed, 110 insertions(+) create mode 100644 RTL00_SDKV35a/component/soc/realtek/8195a/fwlib/src/hal_sdio_host.c diff --git a/RTL00_SDKV35a/component/soc/realtek/8195a/fwlib/src/hal_sdio_host.c b/RTL00_SDKV35a/component/soc/realtek/8195a/fwlib/src/hal_sdio_host.c new file mode 100644 index 0000000..11a4c9e --- /dev/null +++ b/RTL00_SDKV35a/component/soc/realtek/8195a/fwlib/src/hal_sdio_host.c @@ -0,0 +1,110 @@ +/* + * hal_sdio_host.c (disasm hal_sdio_host.o) + * + * RTL8710/11 pvvx 12/2016 + */ +#include "rtl8195a.h" +#include "sd.h" +#include "sdio_host.h" +#include "hal_sdio_host.h" +#include "rtl8195a_sdio_host.h" +#include "hal_pinmux.h" + +//------------------------------------------------------------------------- +// Function declarations + +//------------------------------------------------------------------------- +// Data declarations + +//----- HalSdioHostInit(PHAL_SDIO_HOST_ADAPTER) +HAL_Status HalSdioHostInit(IN VOID *Data) { + PHAL_SDIO_HOST_ADAPTER pSdioHostAdapter = (PHAL_SDIO_HOST_ADAPTER) Data; + HAL_Status result; + if (FunctionChk(SDIOH, 0) != 0) { + if (pSdioHostAdapter != NULL) { + if (HalSdioHostInitHostRtl8195a(pSdioHostAdapter) != HAL_OK) { + result = HAL_ERR_HW; + } else { + result = HalSdioHostInitCardRtl8195a(pSdioHostAdapter); + if (result == HAL_OK) { + REG_POWER_STATE RegPwrState; + RegPwrState.FuncIdx = SDIOH; + RegPwrState.PwrState = ACT; + RegPowerState(RegPwrState); + } + } + } else + result = HAL_ERR_PARA; + } else + result = HAL_ERR_UNKNOWN; + return result; +} + +//----- HalSdioHostEnable(PHAL_SDIO_HOST_ADAPTER) +HAL_Status HalSdioHostEnable(void *Data) { +// PHAL_SDIO_HOST_ADAPTER pSdioHostAdapter = (PHAL_SDIO_HOST_ADAPTER) Data; + HAL_Status result = HalSdioHostEnableRtl8195a(Data); + REG_POWER_STATE RegPwrState; + RegPwrState.FuncIdx = SDIOH; + RegPwrState.PwrState = ACT; + if (result == HAL_OK) + RegPowerState(RegPwrState); + return result; +} + +//----- HalSdioHostDeInit(PHAL_SDIO_HOST_ADAPTER) +HAL_Status HalSdioHostDeInit(IN VOID *Data) { + PHAL_SDIO_HOST_ADAPTER pSdioHostAdapter = (PHAL_SDIO_HOST_ADAPTER) Data; + REG_POWER_STATE SdioHostPwrState; + u8 HwState; + HAL_Status result; + SdioHostPwrState.FuncIdx = SDIOH; + SdioHostPwrState.PwrState = ACT; + + QueryRegPwrState(SdioHostPwrState.FuncIdx, &SdioHostPwrState.PwrState, + &HwState); + if (SdioHostPwrState.PwrState & 0xF7) { + HalSdioHostEnable(pSdioHostAdapter); + QueryRegPwrState(SdioHostPwrState.FuncIdx, &SdioHostPwrState.PwrState, + &HwState); + } + if (SdioHostPwrState.PwrState == ACT) { + SdioHostPwrState.PwrState = INACT; + RegPowerState(SdioHostPwrState); + } + if (pSdioHostAdapter != NULL) + result = HalSdioHostDeInitRtl8195a(pSdioHostAdapter); + else + result = HAL_ERR_PARA; + return result; +} + +//----- HalSdioHostDisable(PHAL_SDIO_HOST_ADAPTER) +HAL_Status HalSdioHostDisable(IN VOID *Data) { + HAL_Status result = HalSdioHostDisableRtl8195a(Data); + if (result == HAL_OK) { + REG_POWER_STATE RegPwrState; + RegPwrState.FuncIdx = SDIOH; + RegPwrState.PwrState = SLPCG; + RegPowerState(RegPwrState); // 0x0441 + } + return result; +} + +//----- HalSdioHostOpInit(PHAL_SDIO_HOST_ADAPTER) +void HalSdioHostOpInit(void *Data) { + PHAL_SDIO_HOST_OP phsha = Data; + phsha->HalSdioHostInitHost = &HalSdioHostInitHostRtl8195a; + phsha->HalSdioHostInitCard = &HalSdioHostInitCardRtl8195a; + phsha->HalSdioHostDeInit = &HalSdioHostDeInitRtl8195a; + phsha->HalSdioHostRegIrq = &HalSdioHostIrqInitRtl8195a; + phsha->HalSdioHostReadBlocksDma = &HalSdioHostReadBlocksDmaRtl8195a; + phsha->HalSdioHostWriteBlocksDma = &HalSdioHostWriteBlocksDmaRtl8195a; + phsha->HalSdioHostStopTransfer = &HalSdioHostStopTransferRtl8195a; + phsha->HalSdioHostGetCardStatus = &HalSdioHostGetCardStatusRtl8195a; + phsha->HalSdioHostGetSdStatus = &HalSdioHostGetSdStatusRtl8195a; + phsha->HalSdioHostChangeSdClock = &HalSdioHostChangeSdClockRtl8195a; + phsha->HalSdioHostErase = &HalSdioHostEraseRtl8195a; + phsha->HalSdioHostGetWriteProtect = &HalSdioHostGetWriteProtectRtl8195a; + phsha->HalSdioHostSetWriteProtect = &HalSdioHostSetWriteProtectRtl8195a; +}