From 96a2c4034bcd5e134495a1d02659c07a4b17de61 Mon Sep 17 00:00:00 2001 From: lzl Date: Tue, 8 Jun 2021 06:28:34 +0000 Subject: [PATCH 1/5] mmc driver linux adapter Signed-off-by: lzl --- Kconfig | 1 + Makefile | 1 + platform/Kconfig | 7 + platform/Makefile | 1 + platform/common/Makefile | 5 + platform/emmc/Makefile | 3 +- platform/emmc/emmc_adapter.c | 147 ++++++++++------ platform/mmc/Makefile | 23 +++ platform/platform.mk | 5 +- platform/sdio/Makefile | 3 +- platform/sdio/sdio_adapter.c | 332 +++++++++++++++++++++-------------- 11 files changed, 344 insertions(+), 184 deletions(-) create mode 100644 platform/mmc/Makefile diff --git a/Kconfig b/Kconfig index 2e4c0fd..3aa2fbb 100755 --- a/Kconfig +++ b/Kconfig @@ -11,3 +11,4 @@ source "drivers/hdf/khdf/model/display/Kconfig" source "drivers/hdf/khdf/model/input/Kconfig" source "drivers/hdf/khdf/model/network/wifi/Kconfig" source "drivers/hdf/khdf/model/sensor/Kconfig" +source "drivers/hdf/khdf/model/storage/Kconfig" diff --git a/Makefile b/Makefile index 9320fea..aa85a3d 100644 --- a/Makefile +++ b/Makefile @@ -39,3 +39,4 @@ obj-$(CONFIG_DRIVERS_HDF_DISP) += model/display/ obj-$(CONFIG_DRIVERS_HDF_INPUT) += model/input/ obj-$(CONFIG_DRIVERS_HDF_WIFI) += model/network/wifi/ obj-$(CONFIG_DRIVERS_HDF_SENSOR) += model/sensor/ +obj-$(CONFIG_DRIVERS_HDF_STORAGE) += model/storage/ diff --git a/platform/Kconfig b/platform/Kconfig index 1ac18b5..658fbf5 100644 --- a/platform/Kconfig +++ b/platform/Kconfig @@ -65,6 +65,13 @@ config DRIVERS_HDF_PLATFORM_EMMC help Answer Y to enable HDF platform emmc driver. +config DRIVERS_HDF_PLATFORM_MMC + bool "Enable HDF platform mmc driver" + default n + depends on DRIVERS_HDF_PLATFORM + help + Answer Y to enable HDF platform mmc driver. + config DRIVERS_HDF_PLATFORM_SPI bool "Enable HDF platform spi driver" default n diff --git a/platform/Makefile b/platform/Makefile index f6ade0b..40eb613 100644 --- a/platform/Makefile +++ b/platform/Makefile @@ -19,6 +19,7 @@ obj-$(CONFIG_DRIVERS_HDF_PLATFORM_I2C) += i2c/ obj-$(CONFIG_DRIVERS_HDF_PLATFORM_WATCHDOG) += watchdog/ obj-$(CONFIG_DRIVERS_HDF_PLATFORM_PWM) += pwm/ obj-$(CONFIG_DRIVERS_HDF_PLATFORM_UART) += uart/ +obj-$(CONFIG_DRIVERS_HDF_PLATFORM_MMC) += mmc/ obj-$(CONFIG_DRIVERS_HDF_PLATFORM_SDIO) += sdio/ obj-$(CONFIG_DRIVERS_HDF_PLATFORM_EMMC) += emmc/ obj-$(CONFIG_DRIVERS_HDF_PLATFORM_SPI) += spi/ diff --git a/platform/common/Makefile b/platform/common/Makefile index 39b2e7e..ea9f743 100644 --- a/platform/common/Makefile +++ b/platform/common/Makefile @@ -14,4 +14,9 @@ include drivers/hdf/khdf/platform/platform.mk +obj-y += $(HDF_PLATFORM_FRAMEWORKS_ROOT)/src/common/platform_device.o \ + $(HDF_PLATFORM_FRAMEWORKS_ROOT)/src/common/platform_common.o \ + $(HDF_PLATFORM_FRAMEWORKS_ROOT)/src/common/platform_manager.o \ + $(HDF_PLATFORM_FRAMEWORKS_ROOT)/src/common/platform_queue.o + obj-y += ./plat_common.o diff --git a/platform/emmc/Makefile b/platform/emmc/Makefile index 5fb61cb..7cc5ea0 100644 --- a/platform/emmc/Makefile +++ b/platform/emmc/Makefile @@ -14,6 +14,5 @@ include drivers/hdf/khdf/platform/platform.mk -obj-y += $(HDF_PLATFORM_FRAMEWORKS_ROOT)/src/emmc_core.o \ - $(HDF_PLATFORM_FRAMEWORKS_ROOT)/src/emmc_if.o \ +obj-y += $(HDF_PLATFORM_FRAMEWORKS_ROOT)/src/mmc/emmc_if.o \ ./emmc_adapter.o diff --git a/platform/emmc/emmc_adapter.c b/platform/emmc/emmc_adapter.c index 5ab9576..449cab0 100644 --- a/platform/emmc/emmc_adapter.c +++ b/platform/emmc/emmc_adapter.c @@ -18,20 +18,24 @@ #include #include -#include "emmc_core.h" +#include +#include "mmc_corex.h" +#include "mmc_emmc.h" +#include "device_resource_if.h" +#include "emmc_if.h" #include "hdf_log.h" -#include "securec.h" #define HDF_LOG_TAG emmc_adapter_c struct mmc_host *himci_get_mmc_host(int slot); -int32_t Hi35xxLinuxEmmcGetCid(struct EmmcCntlr *cntlr, uint8_t *cid, uint32_t size) +int32_t Hi35xxLinuxEmmcGetCid(struct EmmcDevice *dev, uint8_t *cid, uint32_t size) { struct mmc_host *mmcHost = NULL; + struct MmcCntlr *cntlr = NULL; - if (cntlr == NULL) { - HDF_LOGE("Hi35xxLinuxEmmcGetCid: cntlr is null."); + if (dev == NULL || dev->mmc.cntlr == NULL) { + HDF_LOGE("Hi35xxLinuxEmmcGetCid: dev or cntlr is null."); return HDF_ERR_INVALID_OBJECT; } if (cid == NULL || size < EMMC_CID_LEN) { @@ -39,14 +43,11 @@ int32_t Hi35xxLinuxEmmcGetCid(struct EmmcCntlr *cntlr, uint8_t *cid, uint32_t si return HDF_ERR_INVALID_PARAM; } + cntlr = dev->mmc.cntlr; mmcHost = (struct mmc_host *)cntlr->priv; if (mmcHost == NULL) { - mmcHost = himci_get_mmc_host(cntlr->configData.hostId); - if (mmcHost == NULL) { - HDF_LOGE("Hi35xxLinuxEmmcGetCid: get_mmc_host fail again!"); - return HDF_ERR_NOT_SUPPORT; - } - cntlr->priv = (void *)mmcHost; + HDF_LOGE("Hi35xxLinuxEmmcGetCid: mmcHost is NULL!"); + return HDF_ERR_NOT_SUPPORT; } if (mmcHost->card == NULL) { HDF_LOGE("Hi35xxLinuxEmmcGetCid: card is null."); @@ -60,79 +61,121 @@ int32_t Hi35xxLinuxEmmcGetCid(struct EmmcCntlr *cntlr, uint8_t *cid, uint32_t si return HDF_SUCCESS; } -int32_t Hi35xxLinuxEmmcFindHost(struct EmmcCntlr *cntlr, struct EmmcConfigData *data) +static struct EmmcDeviceOps g_emmcMethod = { + .getCid = Hi35xxLinuxEmmcGetCid, +}; + +static void Hi35xxLinuxEmmcDeleteCntlr(struct MmcCntlr *cntlr) { - if (cntlr == NULL || data == NULL) { - HDF_LOGE("Hi35xxLinuxEmmcFindHost: cntlr or data is null."); - return HDF_ERR_INVALID_OBJECT; + if (cntlr == NULL) { + return; } - cntlr->priv = (void *)himci_get_mmc_host(data->hostId); - if (cntlr->priv == NULL) { - HDF_LOGE("Hi35xxLinuxEmmcFindHost: get_mmc_host fail!"); - return HDF_FAILURE; + if (cntlr->curDev != NULL) { + MmcDeviceRemove(cntlr->curDev); + OsalMemFree(cntlr->curDev); } - return HDF_SUCCESS; + MmcCntlrRemove(cntlr); + OsalMemFree(cntlr); } -static struct EmmcMethod g_emmcMethod = { - .getCid = Hi35xxLinuxEmmcGetCid, - .findHost = Hi35xxLinuxEmmcFindHost, -}; - -static int32_t Hi35xxLinuxEmmcBind(struct HdfDeviceObject *device) +static int32_t Hi35xxLinuxEmmcCntlrParse(struct MmcCntlr *cntlr, struct HdfDeviceObject *obj) { - if (device == NULL) { - HDF_LOGE("Hi35xxLinuxEmmcBind: Fail, device is NULL."); - return HDF_ERR_INVALID_OBJECT; + const struct DeviceResourceNode *node = NULL; + struct DeviceResourceIface *drsOps = NULL; + int32_t ret; + + if (obj == NULL || cntlr == NULL) { + HDF_LOGE("Hi35xxLinuxEmmcCntlrParse: input para is NULL."); + return HDF_FAILURE; } - if (EmmcCntlrCreateAndBind(device) == NULL) { + + node = obj->property; + if (node == NULL) { + HDF_LOGE("Hi35xxLinuxEmmcCntlrParse: drs node is NULL."); return HDF_FAILURE; } - HDF_LOGI("Hi35xxLinuxEmmcBind: Success."); + drsOps = DeviceResourceGetIfaceInstance(HDF_CONFIG_SOURCE); + if (drsOps == NULL || drsOps->GetUint16 == NULL || drsOps->GetUint32 == NULL) { + HDF_LOGE("Hi35xxLinuxEmmcCntlrParse: invalid drs ops fail!"); + return HDF_FAILURE; + } + + ret = drsOps->GetUint16(node, "hostId", &(cntlr->index), 0); + if (ret != HDF_SUCCESS) { + HDF_LOGE("Hi35xxLinuxEmmcCntlrParse: read hostIndex fail!"); + return ret; + } + ret = drsOps->GetUint32(node, "devType", &(cntlr->devType), 0); + if (ret != HDF_SUCCESS) { + HDF_LOGE("Hi35xxLinuxEmmcCntlrParse: read devType fail!"); + return ret; + } return HDF_SUCCESS; } -static int32_t Hi35xxLinuxEmmcInit(struct HdfDeviceObject *device) +static int32_t Hi35xxLinuxEmmcBind(struct HdfDeviceObject *obj) { - struct EmmcCntlr *cntlr = NULL; + struct MmcCntlr *cntlr = NULL; int32_t ret; - if (device == NULL) { - HDF_LOGE("Hi35xxLinuxEmmcInit: device is NULL."); + HDF_LOGE("Hi35xxLinuxEmmcBind: entry!"); + if (obj == NULL) { + HDF_LOGE("Hi35xxLinuxEmmcBind: Fail, obj is NULL."); return HDF_ERR_INVALID_OBJECT; } - cntlr = EmmcCntlrFromDevice(device); + cntlr = (struct MmcCntlr *)OsalMemCalloc(sizeof(struct MmcCntlr)); if (cntlr == NULL) { - HDF_LOGE("Hi35xxLinuxEmmcInit: EmmcCntlrFromDevice fail."); - return HDF_ERR_IO; + HDF_LOGE("Hi35xxLinuxEmmcBind: no mem for MmcCntlr."); + return HDF_ERR_MALLOC_FAIL; + } + + cntlr->ops = NULL; + cntlr->hdfDevObj = obj; + obj->service = &cntlr->service; + ret = Hi35xxLinuxEmmcCntlrParse(cntlr, obj); + if (ret != HDF_SUCCESS) { + HDF_LOGE("Hi35xxLinuxEmmcBind: cntlr parse fail."); + goto _ERR; } + cntlr->priv = (void *)himci_get_mmc_host((int32_t)cntlr->index); - ret = EmmcFillConfigData(device, &(cntlr->configData)); + ret = MmcCntlrAdd(cntlr); if (ret != HDF_SUCCESS) { - HDF_LOGE("Hi35xxLinuxEmmcInit: EmmcFillConfigData fail."); - return HDF_ERR_IO; + HDF_LOGE("Hi35xxLinuxEmmcBind: cntlr add fail."); + goto _ERR; } - cntlr->priv = (void *)himci_get_mmc_host(cntlr->configData.hostId); - cntlr->method = &g_emmcMethod; - HDF_LOGI("Hi35xxLinuxEmmcInit: Success!"); + ret = MmcCntlrAllocDev(cntlr, (enum MmcDevType)cntlr->devType); + if (ret != HDF_SUCCESS) { + HDF_LOGE("Hi35xxLinuxEmmcBind: alloc dev fail."); + goto _ERR; + } + MmcDeviceAddOps(cntlr->curDev, &g_emmcMethod); + HDF_LOGD("Hi35xxLinuxEmmcBind: Success!"); return HDF_SUCCESS; + +_ERR: + Hi35xxLinuxEmmcDeleteCntlr(cntlr); + HDF_LOGE("Hi35xxLinuxEmmcBind: Fail!"); + return HDF_FAILURE; } -static void Hi35xxLinuxEmmcRelease(struct HdfDeviceObject *device) +static int32_t Hi35xxLinuxEmmcInit(struct HdfDeviceObject *obj) { - struct EmmcCntlr *cntlr = NULL; + (void)obj; - cntlr = EmmcCntlrFromDevice(device); - if (cntlr == NULL) { - HDF_LOGE("Hi35xxLinuxEmmcRelease: Fail, cntlr is NULL."); + HDF_LOGD("Hi35xxLinuxEmmcInit: Success!"); + return HDF_SUCCESS; +} + +static void Hi35xxLinuxEmmcRelease(struct HdfDeviceObject *obj) +{ + if (obj == NULL) { return; } - - EmmcCntlrDestroy(cntlr); - HDF_LOGD("Hi35xxLinuxEmmcRelease: Success."); + Hi35xxLinuxEmmcDeleteCntlr((struct MmcCntlr *)obj->service); } struct HdfDriverEntry g_emmcDriverEntry = { diff --git a/platform/mmc/Makefile b/platform/mmc/Makefile new file mode 100644 index 0000000..b3e6494 --- /dev/null +++ b/platform/mmc/Makefile @@ -0,0 +1,23 @@ +# +# Copyright (c) 2020-2021 Huawei Device Co., Ltd. +# +# This software is licensed under the terms of the GNU General Public +# License version 2, as published by the Free Software Foundation, and +# may be copied, distributed, and modified under those terms. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# + +include drivers/hdf/khdf/platform/platform.mk + +obj-y += $(HDF_PLATFORM_FRAMEWORKS_ROOT)/src/mmc/mmc_core.o \ + $(HDF_PLATFORM_FRAMEWORKS_ROOT)/src/mmc/mmc_emmc.o \ + $(HDF_PLATFORM_FRAMEWORKS_ROOT)/src/mmc/mmc_sdio.o \ + $(HDF_PLATFORM_FRAMEWORKS_ROOT)/src/mmc/mmc_dispatch.o \ + $(HDF_PLATFORM_FRAMEWORKS_ROOT)/src/mmc/mmc_if.o \ + $(HDF_PLATFORM_FRAMEWORKS_ROOT)/src/mmc/mmc_block.o \ + $(HDF_PLATFORM_FRAMEWORKS_ROOT)/src/mmc/mmc_protocol.o diff --git a/platform/platform.mk b/platform/platform.mk index 3544e29..0b66468 100644 --- a/platform/platform.mk +++ b/platform/platform.mk @@ -1,4 +1,4 @@ -# +i# # Copyright (c) 2020-2021 Huawei Device Co., Ltd. # # This software is licensed under the terms of the GNU General Public @@ -15,6 +15,9 @@ HDF_PLATFORM_FRAMEWORKS_ROOT = ../../../../../framework/support/platform ccflags-$(CONFIG_DRIVERS_HDF_PLATFORM) += -Idrivers/hdf/framework/include/platform \ -Idrivers/hdf/framework/support/platform/include \ + -Idrivers/hdf/framework/support/platform/include/mmc \ + -Idrivers/hdf/framework/support/platform/include/common \ + -Idrivers/hdf/framework/model/storage/include/common \ -Iinclude/hdf \ -Iinclude/hdf/osal \ -Iinclude/hdf/utils \ diff --git a/platform/sdio/Makefile b/platform/sdio/Makefile index 7193a2e..2c0d97e 100644 --- a/platform/sdio/Makefile +++ b/platform/sdio/Makefile @@ -14,6 +14,5 @@ include drivers/hdf/khdf/platform/platform.mk -obj-y += $(HDF_PLATFORM_FRAMEWORKS_ROOT)/src/sdio_core.o \ - $(HDF_PLATFORM_FRAMEWORKS_ROOT)/src/sdio_if.o \ +obj-y += $(HDF_PLATFORM_FRAMEWORKS_ROOT)/src/mmc/sdio_if.o \ ./sdio_adapter.o diff --git a/platform/sdio/sdio_adapter.c b/platform/sdio/sdio_adapter.c index f999ac9..59fdba5 100644 --- a/platform/sdio/sdio_adapter.c +++ b/platform/sdio/sdio_adapter.c @@ -21,7 +21,9 @@ #include #include #include "plat_log.h" -#include "sdio_core.h" +#include "device_resource_if.h" +#include "mmc_corex.h" +#include "mmc_sdio.h" #define HDF_LOG_TAG sdio_adapter_c @@ -29,22 +31,24 @@ #define DATA_LEN_TWO_BYTES 2 #define DATA_LEN_FOUR_BYTES 4 #define MMC_SLOT_NUM 3 +#define SDIO_RESCAN_WAIT_TIME 40 struct mmc_host *himci_get_mmc_host(int slot); +void hisi_sdio_rescan(int slot); -static struct sdio_func *Hi35xxLinuxSdioGetFunc(struct SdioCntlr *cntlr) +static struct sdio_func *Hi35xxLinuxSdioGetFunc(struct SdioDevice *dev) { - if (cntlr == NULL) { - HDF_LOGE("Hi35xxLinuxSdioGetFunc: cntlr is null."); + if (dev == NULL) { + HDF_LOGE("Hi35xxLinuxSdioGetFunc: dev is null."); return NULL; } - return (struct sdio_func *)cntlr->priv; + return (struct sdio_func *)dev->sd.mmc.priv; } -static int32_t Hi35xxLinuxSdioIncrAddrReadBytes(struct SdioCntlr *cntlr, - uint8_t *data, uint32_t addr, uint32_t size, uint32_t timeOut) +static int32_t Hi35xxLinuxSdioIncrAddrReadBytes(struct SdioDevice *dev, + uint8_t *data, uint32_t addr, uint32_t size) { - struct sdio_func *func = Hi35xxLinuxSdioGetFunc(cntlr); + struct sdio_func *func = Hi35xxLinuxSdioGetFunc(dev); int32_t ret = HDF_SUCCESS; uint16_t *output16 = NULL; uint32_t *output32 = NULL; @@ -58,36 +62,28 @@ static int32_t Hi35xxLinuxSdioIncrAddrReadBytes(struct SdioCntlr *cntlr, return HDF_ERR_INVALID_PARAM; } - if (timeOut > 0) { - PLAT_LOGV("Hi35xxLinuxSdioIncrAddrReadBytes: use current timeOut value."); - func->enable_timeout = timeOut; - } if (size == DATA_LEN_ONE_BYTE) { - PLAT_LOGV("Hi35xxLinuxSdioIncrAddrReadBytes: Read one byte Success!"); *data = sdio_readb(func, addr, &ret); return ret; } if (size == DATA_LEN_TWO_BYTES) { - PLAT_LOGV("Hi35xxLinuxSdioIncrAddrReadBytes: Read two bytes Success!"); output16 = (uint16_t *)data; *output16 = sdio_readw(func, addr, &ret); return ret; } if (size == DATA_LEN_FOUR_BYTES) { - PLAT_LOGV("Hi35xxLinuxSdioIncrAddrReadBytes: Read four bytes Success!"); output32 = (uint32_t *)data; *output32 = sdio_readl(func, addr, &ret); return ret; } - PLAT_LOGV("Hi35xxLinuxSdioIncrAddrReadBytes: Success!"); return sdio_memcpy_fromio(func, data, addr, size); } -static int32_t Hi35xxLinuxSdioIncrAddrWriteBytes(struct SdioCntlr *cntlr, - uint8_t *data, uint32_t addr, uint32_t size, uint32_t timeOut) +static int32_t Hi35xxLinuxSdioIncrAddrWriteBytes(struct SdioDevice *dev, + uint8_t *data, uint32_t addr, uint32_t size) { int32_t ret = HDF_SUCCESS; - struct sdio_func *func = Hi35xxLinuxSdioGetFunc(cntlr); + struct sdio_func *func = Hi35xxLinuxSdioGetFunc(dev); if (func == NULL) { HDF_LOGE("Hi35xxLinuxSdioIncrAddrWriteBytes: func is NULL."); @@ -98,33 +94,25 @@ static int32_t Hi35xxLinuxSdioIncrAddrWriteBytes(struct SdioCntlr *cntlr, return HDF_ERR_INVALID_PARAM; } - if (timeOut > 0) { - PLAT_LOGV("Hi35xxLinuxSdioIncrAddrWriteBytes: use current timeOut value."); - func->enable_timeout = timeOut; - } if (size == DATA_LEN_ONE_BYTE) { - PLAT_LOGV("Hi35xxLinuxSdioIncrAddrWriteBytes: write one byte Success!"); sdio_writeb(func, *data, addr, &ret); return ret; } if (size == DATA_LEN_TWO_BYTES) { - PLAT_LOGV("Hi35xxLinuxSdioIncrAddrWriteBytes: write two bytes Success!"); sdio_writew(func, *(uint16_t *)data, addr, &ret); return ret; } if (size == DATA_LEN_FOUR_BYTES) { - PLAT_LOGV("Hi35xxLinuxSdioIncrAddrWriteBytes: write four bytes Success!"); sdio_writel(func, *(uint32_t *)data, addr, &ret); return ret; } - PLAT_LOGV("Hi35xxLinuxSdioIncrAddrWriteBytes: Success!"); return sdio_memcpy_toio(func, addr, data, size); } -static int32_t Hi35xxLinuxSdioFixedAddrReadBytes(struct SdioCntlr *cntlr, - uint8_t *data, uint32_t addr, uint32_t size, uint32_t timeOut) +static int32_t Hi35xxLinuxSdioFixedAddrReadBytes(struct SdioDevice *dev, + uint8_t *data, uint32_t addr, uint32_t size, uint32_t scatterLen) { - struct sdio_func *func = Hi35xxLinuxSdioGetFunc(cntlr); + struct sdio_func *func = Hi35xxLinuxSdioGetFunc(dev); if (func == NULL) { HDF_LOGE("Hi35xxLinuxSdioFixedAddrReadBytes: func is NULL."); @@ -135,18 +123,17 @@ static int32_t Hi35xxLinuxSdioFixedAddrReadBytes(struct SdioCntlr *cntlr, return HDF_ERR_INVALID_PARAM; } - if (timeOut > 0) { - PLAT_LOGV("Hi35xxLinuxSdioFixedAddrReadBytes: use current timeOut value."); - func->enable_timeout = timeOut; + if (scatterLen > 0) { + HDF_LOGE("Hi35xxLinuxSdioFixedAddrReadBytes: not support!"); + return HDF_ERR_NOT_SUPPORT; } - PLAT_LOGV("Hi35xxLinuxSdioFixedAddrReadBytes: Success!"); return sdio_readsb(func, data, addr, size); } -static int32_t Hi35xxLinuxSdioFixedAddrWriteBytes(struct SdioCntlr *cntlr, - uint8_t *data, uint32_t addr, uint32_t size, uint32_t timeOut) +static int32_t Hi35xxLinuxSdioFixedAddrWriteBytes(struct SdioDevice *dev, + uint8_t *data, uint32_t addr, uint32_t size, uint32_t scatterLen) { - struct sdio_func *func = Hi35xxLinuxSdioGetFunc(cntlr); + struct sdio_func *func = Hi35xxLinuxSdioGetFunc(dev); if (func == NULL) { HDF_LOGE("Hi35xxLinuxSdioFixedAddrWriteBytes: func is NULL."); @@ -157,19 +144,18 @@ static int32_t Hi35xxLinuxSdioFixedAddrWriteBytes(struct SdioCntlr *cntlr, return HDF_ERR_INVALID_PARAM; } - if (timeOut > 0) { - PLAT_LOGV("Hi35xxLinuxSdioFixedAddrWriteBytes: use current timeOut value."); - func->enable_timeout = timeOut; + if (scatterLen > 0) { + HDF_LOGE("Hi35xxLinuxSdioFixedAddrWriteBytes: not support!"); + return HDF_ERR_NOT_SUPPORT; } - PLAT_LOGV("Hi35xxLinuxSdioFixedAddrWriteBytes: Success!"); return sdio_writesb(func, addr, data, size); } -static int32_t Hi35xxLinuxSdioFunc0ReadBytes(struct SdioCntlr *cntlr, - uint8_t *data, uint32_t addr, uint32_t size, uint32_t timeOut) +static int32_t Hi35xxLinuxSdioFunc0ReadBytes(struct SdioDevice *dev, + uint8_t *data, uint32_t addr, uint32_t size) { int32_t ret = HDF_SUCCESS; - struct sdio_func *func = Hi35xxLinuxSdioGetFunc(cntlr); + struct sdio_func *func = Hi35xxLinuxSdioGetFunc(dev); if (func == NULL) { HDF_LOGE("Hi35xxLinuxSdioFunc0ReadBytes: func is NULL."); @@ -180,21 +166,15 @@ static int32_t Hi35xxLinuxSdioFunc0ReadBytes(struct SdioCntlr *cntlr, return HDF_ERR_INVALID_PARAM; } - if (timeOut > 0) { - PLAT_LOGV("Hi35xxLinuxSdioFunc0ReadBytes: use current timeOut value."); - func->enable_timeout = timeOut; - } - *data = sdio_f0_readb(func, addr, &ret); - PLAT_LOGV("Hi35xxLinuxSdioFunc0ReadBytes: Success!"); return ret; } -static int32_t Hi35xxLinuxSdioFunc0WriteBytes(struct SdioCntlr *cntlr, - uint8_t *data, uint32_t addr, uint32_t size, uint32_t timeOut) +static int32_t Hi35xxLinuxSdioFunc0WriteBytes(struct SdioDevice *dev, + uint8_t *data, uint32_t addr, uint32_t size) { int32_t ret = HDF_SUCCESS; - struct sdio_func *func = Hi35xxLinuxSdioGetFunc(cntlr); + struct sdio_func *func = Hi35xxLinuxSdioGetFunc(dev); if (func == NULL) { HDF_LOGE("Hi35xxLinuxSdioFunc0WriteBytes: func is NULL."); @@ -205,32 +185,25 @@ static int32_t Hi35xxLinuxSdioFunc0WriteBytes(struct SdioCntlr *cntlr, return HDF_ERR_INVALID_PARAM; } - if (timeOut > 0) { - PLAT_LOGV("Hi35xxLinuxSdioFunc0WriteBytes: use current timeOut value."); - func->enable_timeout = timeOut; - } - sdio_f0_writeb(func, *data, addr, &ret); - PLAT_LOGV("Hi35xxLinuxSdioFunc0WriteBytes: Success!"); return ret; } -static int32_t Hi35xxLinuxSdioSetBlockSize(struct SdioCntlr *cntlr, uint32_t blockSize) +static int32_t Hi35xxLinuxSdioSetBlockSize(struct SdioDevice *dev, uint32_t blockSize) { - struct sdio_func *func = Hi35xxLinuxSdioGetFunc(cntlr); + struct sdio_func *func = Hi35xxLinuxSdioGetFunc(dev); if (func == NULL) { HDF_LOGE("Hi35xxLinuxSdioSetBlockSize, func is NULL."); return HDF_ERR_INVALID_OBJECT; } - PLAT_LOGV("Hi35xxLinuxSdioSetBlockSize: Success!"); return sdio_set_block_size(func, blockSize); } -static int32_t Hi35xxLinuxSdioGetCommonInfo(struct SdioCntlr *cntlr, +static int32_t Hi35xxLinuxSdioGetCommonInfo(struct SdioDevice *dev, SdioCommonInfo *info, uint32_t infoType) { - struct sdio_func *func = Hi35xxLinuxSdioGetFunc(cntlr); + struct sdio_func *func = Hi35xxLinuxSdioGetFunc(dev); if (func == NULL) { HDF_LOGE("Hi35xxLinuxSdioGetCommonInfo: func is NULL."); @@ -260,14 +233,13 @@ static int32_t Hi35xxLinuxSdioGetCommonInfo(struct SdioCntlr *cntlr, info->funcInfo.funcNum = func->num; info->funcInfo.irqCap = func->card->host->caps & MMC_CAP_SDIO_IRQ; info->funcInfo.data = func; - PLAT_LOGV("Hi35xxLinuxSdioGetCommonInfo: get %d info Success!", infoType); return HDF_SUCCESS; } -static int32_t Hi35xxLinuxSdioSetCommonInfo(struct SdioCntlr *cntlr, +static int32_t Hi35xxLinuxSdioSetCommonInfo(struct SdioDevice *dev, SdioCommonInfo *info, uint32_t infoType) { - struct sdio_func *func = Hi35xxLinuxSdioGetFunc(cntlr); + struct sdio_func *func = Hi35xxLinuxSdioGetFunc(dev); if (func == NULL) { HDF_LOGE("Hi35xxLinuxSdioSetCommonInfo: func is NULL."); @@ -295,13 +267,12 @@ static int32_t Hi35xxLinuxSdioSetCommonInfo(struct SdioCntlr *cntlr, func->card->host->max_blk_size = info->funcInfo.maxBlockSize; func->card->host->max_req_size = info->funcInfo.maxRequestSize; func->num = info->funcInfo.funcNum; - PLAT_LOGV("Hi35xxLinuxSdioSetCommonInfo: set %d info Success!", infoType); return HDF_SUCCESS; } -static int32_t Hi35xxLinuxSdioFlushData(struct SdioCntlr *cntlr) +static int32_t Hi35xxLinuxSdioFlushData(struct SdioDevice *dev) { - struct sdio_func *func = Hi35xxLinuxSdioGetFunc(cntlr); + struct sdio_func *func = Hi35xxLinuxSdioGetFunc(dev); if (func == NULL) { HDF_LOGE("Hi35xxLinuxSdioFlushData: func is NULL."); @@ -315,57 +286,55 @@ static int32_t Hi35xxLinuxSdioFlushData(struct SdioCntlr *cntlr) return mmc_sw_reset(func->card->host); } -static void Hi35xxLinuxSdioClaimHost(struct SdioCntlr *cntlr) +static int32_t Hi35xxLinuxSdioClaimHost(struct SdioDevice *dev) { - struct sdio_func *func = Hi35xxLinuxSdioGetFunc(cntlr); + struct sdio_func *func = Hi35xxLinuxSdioGetFunc(dev); if (func == NULL) { HDF_LOGE("Hi35xxLinuxSdioClaimHost: func is NULL."); - return; + return HDF_ERR_INVALID_OBJECT; } - PLAT_LOGV("Hi35xxLinuxSdioClaimHost: Success!"); sdio_claim_host(func); + return HDF_SUCCESS; } -static void Hi35xxLinuxSdioReleaseHost(struct SdioCntlr *cntlr) +static int32_t Hi35xxLinuxSdioReleaseHost(struct SdioDevice *dev) { - struct sdio_func *func = Hi35xxLinuxSdioGetFunc(cntlr); + struct sdio_func *func = Hi35xxLinuxSdioGetFunc(dev); if (func == NULL) { HDF_LOGE("Hi35xxLinuxSdioReleaseHost: func is NULL."); - return; + return HDF_ERR_INVALID_OBJECT; } - PLAT_LOGV("Hi35xxLinuxSdioReleaseHost: Success!"); sdio_release_host(func); + return HDF_SUCCESS; } -static int32_t Hi35xxLinuxSdioEnableFunc(struct SdioCntlr *cntlr) +static int32_t Hi35xxLinuxSdioEnableFunc(struct SdioDevice *dev) { - struct sdio_func *func = Hi35xxLinuxSdioGetFunc(cntlr); + struct sdio_func *func = Hi35xxLinuxSdioGetFunc(dev); if (func == NULL) { HDF_LOGE("Hi35xxLinuxSdioEnableFunc: func is NULL."); return HDF_ERR_INVALID_OBJECT; } - PLAT_LOGV("Hi35xxLinuxSdioEnableFunc: Success!"); return sdio_enable_func(func); } -static int32_t Hi35xxLinuxSdioDisableFunc(struct SdioCntlr *cntlr) +static int32_t Hi35xxLinuxSdioDisableFunc(struct SdioDevice *dev) { - struct sdio_func *func = Hi35xxLinuxSdioGetFunc(cntlr); + struct sdio_func *func = Hi35xxLinuxSdioGetFunc(dev); if (func == NULL) { HDF_LOGE("Hi35xxLinuxSdioDisableFunc: func is NULL."); return HDF_ERR_INVALID_OBJECT; } - PLAT_LOGV("Hi35xxLinuxSdioDisableFunc: Success!"); return sdio_disable_func(func); } -static int32_t Hi35xxLinuxSdioClaimIrq(struct SdioCntlr *cntlr, SdioIrqHandler *handler) +static int32_t Hi35xxLinuxSdioClaimIrq(struct SdioDevice *dev, SdioIrqHandler *handler) { - struct sdio_func *func = Hi35xxLinuxSdioGetFunc(cntlr); + struct sdio_func *func = Hi35xxLinuxSdioGetFunc(dev); if (func == NULL) { HDF_LOGE("Hi35xxLinuxSdioClaimIrq: func is NULL."); @@ -375,23 +344,21 @@ static int32_t Hi35xxLinuxSdioClaimIrq(struct SdioCntlr *cntlr, SdioIrqHandler * HDF_LOGE("Hi35xxLinuxSdioClaimIrq: handler is null."); return HDF_ERR_INVALID_PARAM; } - PLAT_LOGV("Hi35xxLinuxSdioClaimIrq: Success!"); return sdio_claim_irq(func, (sdio_irq_handler_t *)handler); } -static int32_t Hi35xxLinuxSdioReleaseIrq(struct SdioCntlr *cntlr) +static int32_t Hi35xxLinuxSdioReleaseIrq(struct SdioDevice *dev) { - struct sdio_func *func = Hi35xxLinuxSdioGetFunc(cntlr); + struct sdio_func *func = Hi35xxLinuxSdioGetFunc(dev); if (func == NULL) { HDF_LOGE("Hi35xxLinuxSdioReleaseIrq: func is NULL."); return HDF_ERR_INVALID_OBJECT; } - PLAT_LOGV("Hi35xxLinuxSdioReleaseIrq: Success!"); return sdio_release_irq(func); } -static struct sdio_func *Hi35xxLinuxSdioSearchFunc(uint32_t funcNum, uint32_t vendorId, uint32_t deviceId) +static struct sdio_func *Hi35xxLinuxSdioSearchFunc(uint32_t funcNum, uint16_t vendorId, uint16_t deviceId) { struct mmc_card *card = NULL; struct mmc_host *host = NULL; @@ -413,6 +380,7 @@ static struct sdio_func *Hi35xxLinuxSdioSearchFunc(uint32_t funcNum, uint32_t ve (func->num == funcNum) && (func->vendor == vendorId) && (func->device == deviceId)) { + HDF_LOGD("Hi35xxLinuxSdioSearchFunc: find func!"); return func; } } @@ -422,23 +390,22 @@ static struct sdio_func *Hi35xxLinuxSdioSearchFunc(uint32_t funcNum, uint32_t ve return NULL; } -static int32_t Hi35xxLinuxSdioFindFunc(struct SdioCntlr *cntlr, struct SdioConfigData *configData) +static int32_t Hi35xxLinuxSdioFindFunc(struct SdioDevice *dev, struct SdioFunctionConfig *configData) { - if (cntlr == NULL || configData == NULL) { - HDF_LOGE("Hi35xxLinuxSdioFindFunc: cntlr or configData is NULL."); + if (dev == NULL || configData == NULL) { + HDF_LOGE("Hi35xxLinuxSdioFindFunc: dev or configData is NULL."); return HDF_ERR_INVALID_OBJECT; } - cntlr->priv = Hi35xxLinuxSdioSearchFunc(configData->funcNum, configData->vendorId, configData->deviceId); - if (cntlr->priv == NULL) { + dev->sd.mmc.priv = Hi35xxLinuxSdioSearchFunc(configData->funcNr, configData->vendorId, configData->deviceId); + if (dev->sd.mmc.priv == NULL) { HDF_LOGE("Hi35xxLinuxSdioFindFunc: Hi35xxLinuxSdioSearchFunc fail."); return HDF_ERR_NOT_SUPPORT; } - PLAT_LOGV("Hi35xxLinuxSdioFindFunc: Success."); return HDF_SUCCESS; } -static struct SdioMethod g_method = { +static struct SdioDeviceOps g_sdioDeviceOps = { .incrAddrReadBytes = Hi35xxLinuxSdioIncrAddrReadBytes, .incrAddrWriteBytes = Hi35xxLinuxSdioIncrAddrWriteBytes, .fixedAddrReadBytes = Hi35xxLinuxSdioFixedAddrReadBytes, @@ -449,65 +416,176 @@ static struct SdioMethod g_method = { .getCommonInfo = Hi35xxLinuxSdioGetCommonInfo, .setCommonInfo = Hi35xxLinuxSdioSetCommonInfo, .flushData = Hi35xxLinuxSdioFlushData, - .claimHost = Hi35xxLinuxSdioClaimHost, - .releaseHost = Hi35xxLinuxSdioReleaseHost, .enableFunc = Hi35xxLinuxSdioEnableFunc, .disableFunc = Hi35xxLinuxSdioDisableFunc, .claimIrq = Hi35xxLinuxSdioClaimIrq, .releaseIrq = Hi35xxLinuxSdioReleaseIrq, .findFunc = Hi35xxLinuxSdioFindFunc, + .claimHost = Hi35xxLinuxSdioClaimHost, + .releaseHost = Hi35xxLinuxSdioReleaseHost, }; -static int32_t Hi35xxLinuxSdioBind(struct HdfDeviceObject *device) +static bool Hi35xxLinuxSdioRescanFinish(struct MmcCntlr *cntlr) { - HDF_LOGI("Hi35xxLinuxSdioBind: entry."); - if (device == NULL) { - HDF_LOGE("Hi35xxLinuxSdioBind: Fail, device is NULL."); + struct mmc_host *host = NULL; + struct mmc_card *card = NULL; + + host = himci_get_mmc_host(cntlr->index); + if (host == NULL) { + return false; + } + + card = host->card; + if (card == NULL) { + return false; + } + if (card->sdio_funcs > 0) { + return true; + } + return false; +} + +static int32_t Hi35xxLinuxSdioRescan(struct MmcCntlr *cntlr) +{ + bool rescanFinish = false; + uint32_t count = 0; + + if (cntlr == NULL) { + HDF_LOGE("Hi35xxLinuxSdioRescan: cntlr is NULL."); return HDF_ERR_INVALID_OBJECT; } - HDF_LOGI("Hi35xxLinuxSdioBind: Success."); - return (SdioCntlrCreateAndBind(device) == NULL) ? HDF_FAILURE : HDF_SUCCESS; + + hisi_sdio_rescan(cntlr->index); + while (rescanFinish == false && count < SDIO_RESCAN_WAIT_TIME) { + OsalMSleep(50); + count++; + rescanFinish = Hi35xxLinuxSdioRescanFinish(cntlr); + } + + if (rescanFinish == false) { + HDF_LOGE("Hi35xxLinuxSdioRescan: fail!"); + return HDF_FAILURE; + } + + OsalMSleep(10); + return HDF_SUCCESS; } -static int32_t Hi35xxLinuxSdioInit(struct HdfDeviceObject *device) +struct MmcCntlrOps g_sdioCntlrOps = { + .rescanSdioDev = Hi35xxLinuxSdioRescan, +}; + +static void Hi35xxLinuxSdioDeleteCntlr(struct MmcCntlr *cntlr) +{ + if (cntlr == NULL) { + return; + } + + if (cntlr->curDev != NULL) { + MmcDeviceRemove(cntlr->curDev); + OsalMemFree(cntlr->curDev); + } + MmcCntlrRemove(cntlr); + OsalMemFree(cntlr); +} + +static int32_t Hi35xxLinuxSdioCntlrParse(struct MmcCntlr *cntlr, struct HdfDeviceObject *obj) { - struct SdioCntlr *cntlr = NULL; + const struct DeviceResourceNode *node = NULL; + struct DeviceResourceIface *drsOps = NULL; int32_t ret; - HDF_LOGI("Hi35xxLinuxSdioInit: entry!"); - if (device == NULL) { - HDF_LOGE("Hi35xxLinuxSdioInit: device is NULL."); + if (obj == NULL || cntlr == NULL) { + HDF_LOGE("Hi35xxLinuxSdioCntlrParse: input para is NULL."); + return HDF_FAILURE; + } + + node = obj->property; + if (node == NULL) { + HDF_LOGE("Hi35xxLinuxSdioCntlrParse: drs node is NULL."); + return HDF_FAILURE; + } + drsOps = DeviceResourceGetIfaceInstance(HDF_CONFIG_SOURCE); + if (drsOps == NULL || drsOps->GetUint16 == NULL || drsOps->GetUint32 == NULL) { + HDF_LOGE("Hi35xxLinuxSdioCntlrParse: invalid drs ops fail!"); + return HDF_FAILURE; + } + + ret = drsOps->GetUint16(node, "hostId", &(cntlr->index), 0); + if (ret != HDF_SUCCESS) { + HDF_LOGE("Hi35xxLinuxSdioCntlrParse: read hostIndex fail!"); + return ret; + } + ret = drsOps->GetUint32(node, "devType", &(cntlr->devType), 0); + if (ret != HDF_SUCCESS) { + HDF_LOGE("Hi35xxLinuxSdioCntlrParse: read devType fail!"); + return ret; + } + HDF_LOGD("Hi35xxLinuxSdioCntlrParse: hostIndex = %d, devType = %d.", cntlr->index, cntlr->devType); + return HDF_SUCCESS; +} + +static int32_t Hi35xxLinuxSdioBind(struct HdfDeviceObject *obj) +{ + struct MmcCntlr *cntlr = NULL; + int32_t ret; + + HDF_LOGE("Hi35xxLinuxSdioBind: entry!"); + if (obj == NULL) { + HDF_LOGE("Hi35xxLinuxSdioBind: Fail, obj is NULL."); return HDF_ERR_INVALID_OBJECT; } - cntlr = SdioCntlrFromDevice(device); + cntlr = (struct MmcCntlr *)OsalMemCalloc(sizeof(struct MmcCntlr)); if (cntlr == NULL) { - HDF_LOGE("Hi35xxLinuxSdioInit: SdioHostFromDevice fail."); - return HDF_ERR_IO; + HDF_LOGE("Hi35xxLinuxSdioBind: no mem for MmcCntlr."); + return HDF_ERR_MALLOC_FAIL; + } + + cntlr->ops = &g_sdioCntlrOps; + cntlr->hdfDevObj = obj; + obj->service = &cntlr->service; + /* init cntlr. */ + ret = Hi35xxLinuxSdioCntlrParse(cntlr, obj); + if (ret != HDF_SUCCESS) { + HDF_LOGE("Hi35xxLinuxSdioBind: cntlr parse fail."); + goto _ERR; } - ret = SdioFillConfigData(device, &(cntlr->configData)); + ret = MmcCntlrAdd(cntlr); if (ret != HDF_SUCCESS) { - HDF_LOGE("Hi35xxLinuxSdioInit: SdioFillConfigData fail."); - return HDF_ERR_IO; + HDF_LOGE("Hi35xxLinuxSdioBind: cntlr add fail."); + goto _ERR; } - cntlr->method = &g_method; - HDF_LOGI("Hi35xxLinuxSdioInit: Success!"); + + ret = MmcCntlrAllocDev(cntlr, (enum MmcDevType)cntlr->devType); + if (ret != HDF_SUCCESS) { + HDF_LOGE("Hi35xxLinuxSdioBind: alloc dev fail."); + goto _ERR; + } + MmcDeviceAddOps(cntlr->curDev, &g_sdioDeviceOps); + HDF_LOGD("Hi35xxLinuxSdioBind: Success!"); return HDF_SUCCESS; + +_ERR: + Hi35xxLinuxSdioDeleteCntlr(cntlr); + HDF_LOGE("Hi35xxLinuxSdioBind: Fail!"); + return HDF_FAILURE; } -static void Hi35xxLinuxSdioRelease(struct HdfDeviceObject *device) +static int32_t Hi35xxLinuxSdioInit(struct HdfDeviceObject *obj) { - struct SdioCntlr *cntlr = NULL; + (void)obj; + HDF_LOGD("Hi35xxLinuxSdioInit: Success!"); + return HDF_SUCCESS; +} - PLAT_LOGV("Hi35xxLinuxSdioRelease: entry!"); - cntlr = SdioCntlrFromDevice(device); - if (cntlr == NULL) { - HDF_LOGE("Hi35xxLinuxSdioRelease: Fail, cntlr is NULL."); +static void Hi35xxLinuxSdioRelease(struct HdfDeviceObject *obj) +{ + if (obj == NULL) { return; } - SdioCntlrDestroy(cntlr); - PLAT_LOGV("Hi35xxLinuxSdioRelease: Success."); + Hi35xxLinuxSdioDeleteCntlr((struct MmcCntlr *)obj->service); } struct HdfDriverEntry g_sdioDriverEntry = { -- Gitee From 49d4481d1a5382043d96c76b87e4a51b3ffceb76 Mon Sep 17 00:00:00 2001 From: lzl Date: Tue, 8 Jun 2021 06:31:50 +0000 Subject: [PATCH 2/5] mmc driver linux adapter Signed-off-by: lzl --- platform/platform.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platform/platform.mk b/platform/platform.mk index 0b66468..dc849b7 100644 --- a/platform/platform.mk +++ b/platform/platform.mk @@ -1,4 +1,4 @@ -i# +# # Copyright (c) 2020-2021 Huawei Device Co., Ltd. # # This software is licensed under the terms of the GNU General Public -- Gitee From a18caabddfa25fcbe9beba7b19e40cc234000346 Mon Sep 17 00:00:00 2001 From: lzl Date: Tue, 8 Jun 2021 07:36:59 +0000 Subject: [PATCH 3/5] mmc driver linux adapter Signed-off-by: lzl --- model/storage/Kconfig | 17 +++++++++++++++ model/storage/Makefile | 34 +++++++++++++++++++++++++++++ model/storage/storage_block_linux.c | 30 +++++++++++++++++++++++++ 3 files changed, 81 insertions(+) create mode 100644 model/storage/Kconfig create mode 100644 model/storage/Makefile create mode 100644 model/storage/storage_block_linux.c diff --git a/model/storage/Kconfig b/model/storage/Kconfig new file mode 100644 index 0000000..08059de --- /dev/null +++ b/model/storage/Kconfig @@ -0,0 +1,17 @@ +# Copyright (c) 2021 Huawei Device Co., Ltd. +# +# This software is licensed under the terms of the GNU General Public +# License version 2, as published by the Free Software Foundation, and +# may be copied, distributed, and modified under those terms. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +config DRIVERS_HDF_STORAGE + bool "Enable HDF storage driver" + default n + depends on DRIVERS_HDF + help + Answer Y to enable HDF storage driver. diff --git a/model/storage/Makefile b/model/storage/Makefile new file mode 100644 index 0000000..40feff3 --- /dev/null +++ b/model/storage/Makefile @@ -0,0 +1,34 @@ +# Copyright (c) 2021 Huawei Device Co., Ltd. +# +# This software is licensed under the terms of the GNU General Public +# License version 2, as published by the Free Software Foundation, and +# may be copied, distributed, and modified under those terms. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +SEC_LIB_SOURCES = memcpy_s.c memmove_s.c memset_s.c securecutil.c secureinput_a.c secureprintoutput_a.c snprintf_s.c sprintf_s.c strcat_s.c strcpy_s.c strncat_s.c strncpy_s.c strtok_s.c vsnprintf_s.c vsprintf_s.c + +PWD:=$(shell pwd) +SEC_OBJECTS:=$(patsubst %.c,%.o,$(SEC_LIB_SOURCES)) + +STORAGE_ROOT_DIR = ../../../../../framework/model/storage + +obj-$(CONFIG_DRIVERS_HDF_STORAGE) += \ + $(STORAGE_ROOT_DIR)/src/common/storage_block.o \ + ./storage_block_linux.o + +ccflags-y += -Idrivers/hdf/framework/model/storage/include/common \ + -Idrivers/hdf/framework/include/core \ + -Idrivers/hdf/framework/core/common/include/host \ + -Idrivers/hdf/framework/include/utils \ + -Idrivers/hdf/framework/include/osal \ + -Idrivers/hdf/framework/ability/sbuf/include \ + -Idrivers/hdf/framework/include/platform \ + -Idrivers/hdf/framework/support/platform/include/common \ + -Idrivers/hdf/framework/include/config \ + -Idrivers/hdf/khdf/osal/include \ + -Idrivers/hdf/../../../../../../../../../../../../../third_party/bounds_checking_function/include + diff --git a/model/storage/storage_block_linux.c b/model/storage/storage_block_linux.c new file mode 100644 index 0000000..e5a75bd --- /dev/null +++ b/model/storage/storage_block_linux.c @@ -0,0 +1,30 @@ +/* + * storage_block_linux.c + * + * storage block adapter of linux + * + * Copyright (c) 2020-2021 Huawei Device Co., Ltd. + * + * This software is licensed under the terms of the GNU General Public + * License version 2, as published by the Free Software Foundation, and + * may be copied, distributed, and modified under those terms. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + */ + +#include "storage_block.h" + +int32_t StorageBlockOsInit(struct StorageBlock *sb) +{ + (void)sb; + return HDF_SUCCESS; +} + +void StorageBlockOsUninit(struct StorageBlock *sb) +{ + (void)sb; +} -- Gitee From b20e24186db1e8e20b32fe5d69f1d93ec3bb6d2b Mon Sep 17 00:00:00 2001 From: lzl Date: Tue, 8 Jun 2021 10:54:05 +0000 Subject: [PATCH 4/5] mmc && wifi_bus linux adapter Signed-off-by: lzl --- model/network/wifi/Makefile | 4 ++++ model/network/wifi/hdfwifi.mk | 4 +++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/model/network/wifi/Makefile b/model/network/wifi/Makefile index 4a0ee7e..c0d8f82 100755 --- a/model/network/wifi/Makefile +++ b/model/network/wifi/Makefile @@ -27,6 +27,7 @@ QOS_PATH := platform/src/qos MESSAGE_PATH := platform/src/message PLATFORM_PATH := platform/src CORE_PATH := core +IBUS_PATH := bus obj-$(CONFIG_DRIVERS_HDF_WIFI) += $(MODULE_NAME).o $(MODULE_NAME)-objs := $(HDF_WIFI_FRAMEWORKS_ROOT)/$(WAP_PATH)/ap.o \ @@ -52,6 +53,8 @@ $(MODULE_NAME)-objs := $(HDF_WIFI_FRAMEWORKS_ROOT)/$(WAP_PATH)/ap.o \ $(HDF_WIFI_FRAMEWORKS_ROOT)/$(PLATFORM_PATH)/hdf_wlan_product.o \ $(HDF_WIFI_FRAMEWORKS_ROOT)/$(PLATFORM_PATH)/hdf_wlan_reset_manager.o \ $(HDF_WIFI_FRAMEWORKS_ROOT)/$(PLATFORM_PATH)/hdf_wlan_utils.o \ + $(HDF_WIFI_FRAMEWORKS_ROOT)/$(IBUS_PATH)/hdf_ibus_intf.o \ + $(HDF_WIFI_FRAMEWORKS_ROOT)/$(IBUS_PATH)/hdf_sdio_intf.o \ ccflags-$(CONFIG_DRIVERS_HDF_WIFI) += \ $(HDF_FRAMEWORKS_INC) \ @@ -60,3 +63,4 @@ ccflags-$(CONFIG_DRIVERS_HDF_WIFI) += \ $(SECURE_LIB_INC) obj-$(CONFIG_DRIVERS_HDF_WIFI) += vendor/ + diff --git a/model/network/wifi/hdfwifi.mk b/model/network/wifi/hdfwifi.mk index 28c358c..92953c5 100644 --- a/model/network/wifi/hdfwifi.mk +++ b/model/network/wifi/hdfwifi.mk @@ -51,7 +51,8 @@ HDF_WIFI_FRAMEWORKS_INC := \ -Idrivers/hdf/framework/model/network/wifi/platform/include/message \ -Idrivers/hdf/framework/model/network/wifi/client/include \ -Idrivers/hdf/framework/include/wifi \ - -Idrivers/hdf/framework/include/net + -Idrivers/hdf/framework/include/net \ + -Idrivers/hdf/frameworks/model/network/wifi/bus HDF_WIFI_ADAPTER_INC := \ -Idrivers/hdf/khdf/network/include @@ -69,3 +70,4 @@ HDF_WIFI_VENDOR_INC := \ SECURE_LIB_INC := \ -I$(PROJECT_ROOT)/third_party/bounds_checking_function/include endif + -- Gitee From 0610640929639b7807afeb607e5c9a257ccfa8e2 Mon Sep 17 00:00:00 2001 From: lzl Date: Tue, 8 Jun 2021 11:06:08 +0000 Subject: [PATCH 5/5] mmc && wifi_bus linux adapter Signed-off-by: lzl --- hcs/device_info/device_info.hcs | 12 ++---------- hcs/hdf_test/sdio_test_config.hcs | 2 +- hcs/platform/emmc_config.hcs | 2 ++ hcs/platform/sdio_config.hcs | 12 +++--------- 4 files changed, 8 insertions(+), 20 deletions(-) diff --git a/hcs/device_info/device_info.hcs b/hcs/device_info/device_info.hcs index be5823e..7060d58 100644 --- a/hcs/device_info/device_info.hcs +++ b/hcs/device_info/device_info.hcs @@ -116,17 +116,9 @@ priority = 70; permission = 0644; moduleName = "HDF_PLATFORM_SDIO"; - serviceName = "HDF_PLATFORM_SDIO_0"; + serviceName = "HDF_PLATFORM_MMC_2"; deviceMatchAttr = "hisilicon_hi35xx_sdio_0"; } - device1 :: deviceNode { - policy = 1; - priority = 70; - permission = 0644; - moduleName = "HDF_PLATFORM_SDIO"; - serviceName = "HDF_PLATFORM_SDIO_1"; - deviceMatchAttr = "hisilicon_hi35xx_sdio_1"; - } } device_emmc :: device { device0 :: deviceNode { @@ -134,7 +126,7 @@ priority = 20; permission = 0644; moduleName = "HDF_PLATFORM_EMMC"; - serviceName = "HDF_PLATFORM_EMMC_0"; + serviceName = "HDF_PLATFORM_MMC_0"; deviceMatchAttr = "hisilicon_hi35xx_emmc_0"; } } diff --git a/hcs/hdf_test/sdio_test_config.hcs b/hcs/hdf_test/sdio_test_config.hcs index 3141f07..9f1835a 100644 --- a/hcs/hdf_test/sdio_test_config.hcs +++ b/hcs/hdf_test/sdio_test_config.hcs @@ -3,7 +3,7 @@ root { sdio_config { sdio_controller_tester { match_attr = "SDIO_TEST"; - busNum = 1; + busNum = 2; funcNum = 1; vendorId = 0x296; deviceId = 0x5347; diff --git a/hcs/platform/emmc_config.hcs b/hcs/platform/emmc_config.hcs index 0df7f43..3351c0c 100644 --- a/hcs/platform/emmc_config.hcs +++ b/hcs/platform/emmc_config.hcs @@ -4,6 +4,7 @@ root { template emmc_controller { match_attr = ""; hostId = 0; + devType = 0; } controller_0x00 :: emmc_controller { @@ -12,3 +13,4 @@ root { } } } + diff --git a/hcs/platform/sdio_config.hcs b/hcs/platform/sdio_config.hcs index c4fd83d..5e1018f 100644 --- a/hcs/platform/sdio_config.hcs +++ b/hcs/platform/sdio_config.hcs @@ -3,19 +3,13 @@ root { sdio_config { template sdio_controller { match_attr = ""; - funcNum = 1; - vendorId = 0x296; - deviceId = 0x5347; + hostId = 2; + devType = 2; } - controller_0x2dd1 :: sdio_controller { match_attr = "hisilicon_hi35xx_sdio_0"; - deviceId = 0x2dd1; - } - - controller_0x5347 :: sdio_controller { - match_attr = "hisilicon_hi35xx_sdio_1"; } } } } + -- Gitee