From 5a45d22dc57ae05071f88862648ec50b4a8a21e5 Mon Sep 17 00:00:00 2001 From: zhaoxc0502 Date: Sat, 25 Dec 2021 23:03:58 +0800 Subject: [PATCH 1/2] merge imx8mm content Signed-off-by: zhaoxc0502 --- Kconfig | 4 +- Makefile | 7 + model/audio/Makefile | 28 ++- model/input/Makefile | 2 + model/usb/device/f_generic.c | 1 + network/Makefile | 3 +- network/include/net_device_adapter.h | 5 +- network/src/Makefile | 4 +- osal/src/osal_mutex.c | 23 ++- platform/emmc/emmc_adapter.c | 85 ++++---- platform/mipi_dsi/mipi_tx_hi35xx.c | 7 + platform/pwm/pwm_adapter.c | 16 +- platform/pwm/pwm_hi35xx.h | 6 +- platform/pwm/pwm_hi35xx_linux.c | 40 ++-- platform/rtc/rtc_adapter.c | 2 +- platform/sdio/sdio_adapter.c | 279 +++++++++++++-------------- platform/spi/Makefile | 2 +- platform/watchdog/watchdog_adapter.c | 4 +- 18 files changed, 265 insertions(+), 253 deletions(-) diff --git a/Kconfig b/Kconfig index 037b190..b540920 100644 --- a/Kconfig +++ b/Kconfig @@ -25,4 +25,6 @@ source "drivers/hdf/khdf/model/usb/host/Kconfig" source "drivers/hdf/khdf/model/usb/device/Kconfig" source "drivers/hdf/khdf/model/audio/Kconfig" source "drivers/hdf/khdf/model/misc/vibrator/Kconfig" -source "drivers/hdf/khdf/model/misc/dsoftbus/Kconfig" \ No newline at end of file +source "drivers/hdf/khdf/model/misc/dsoftbus/Kconfig" +source "../../../../../device/nxp/drivers/ethernet/adapter/Kconfig" +source "drivers/hdf/framework/model/input/driver/touchscreen/Kconfig" diff --git a/Makefile b/Makefile index 33c8c23..76d0cac 100644 --- a/Makefile +++ b/Makefile @@ -13,6 +13,7 @@ # export HDF_ROOT := drivers/hdf +export PRODUCT_PATH := /vendor/nxp/imx8mm obj-$(CONFIG_DRIVERS_HDF) += osal/ obj-$(CONFIG_DRIVERS_HDF) += network/ obj-$(CONFIG_DRIVERS_HDF) += config/ @@ -51,3 +52,9 @@ obj-$(CONFIG_DRIVERS_HDF_BT) += model/network/bluetooth/ obj-$(CONFIG_DRIVERS_HDF_VIBRATOR) += model/misc/vibrator/ obj-$(CONFIG_DRIVERS_HDF_AUDIO) += model/audio/ obj-$(CONFIG_DRIVERS_HDF_DSOFTBUS) += model/misc/dsoftbus/ +# ThunderSoft for OpenHarmony start +obj-y += network/ +obj-$(CONFIG_DRIVERS_HDF_IMX8MM_ETHERNET) += ../../../../device/nxp/drivers/ethernet/adapter/ +ccflags-$(CONFIG_DRIVERS_HDF_IMX8MM_ETHERNET) += -Idrivers/net/ethernet/freescale/ +# ThunderSoft for OpenHarmony end +obj-$(CONFIG_DRIVERS_HDF_WIFI) += ../../../../device/nxp/drivers/wifi/ap6212/ \ No newline at end of file diff --git a/model/audio/Makefile b/model/audio/Makefile index f6eeeb8..99f2539 100755 --- a/model/audio/Makefile +++ b/model/audio/Makefile @@ -28,17 +28,16 @@ obj-y += \ $(KHDF_AUDIO_ROOT_DIR)/common/src/audio_platform_base.o \ $(KHDF_AUDIO_ROOT_DIR)/sapm/src/audio_sapm.o \ $(KHDF_AUDIO_ROOT_DIR)/dispatch/src/audio_stream_dispatch.o \ - $(KHDF_AUDIO_ROOT_DIR)/dispatch/src/audio_control_dispatch.o \ - $(KHDF_AUDIO_CODEC_DIR)/tfa9879/accessory/src/tfa9879_accessory_adapter.o \ - $(KHDF_AUDIO_CODEC_DIR)/tfa9879/accessory/src/tfa9879_accessory_impl.o \ - $(KHDF_AUDIO_CODEC_DIR)/hi3516dv300/codec/src/hi3516_codec_adapter.o \ - $(KHDF_AUDIO_CODEC_DIR)/hi3516dv300/codec/src/hi3516_codec_impl.o \ - $(KHDF_AUDIO_CODEC_DIR)/hi3516dv300/codec/src/hi3516_codec_ops.o \ - $(KHDF_AUDIO_CODEC_DIR)/hi3516dv300/dsp/src/dsp_adapter.o \ - $(KHDF_AUDIO_CODEC_DIR)/hi3516dv300/soc/src/hi3516_dai_adapter.o \ - $(KHDF_AUDIO_CODEC_DIR)/hi3516dv300/soc/src/hi3516_aiao_impl.o \ - $(KHDF_AUDIO_CODEC_DIR)/hi3516dv300/soc/src/hi3516_platform_ops.o \ - $(KHDF_AUDIO_CODEC_DIR)/hi3516dv300/soc/src/hi3516_platform_adapter.o + $(KHDF_AUDIO_ROOT_DIR)/dispatch/src/audio_control_dispatch.o + +obj-y += \ + $(KHDF_AUDIO_CODEC_DIR)/imx8mm/soc/src/sai_driver.o \ + $(KHDF_AUDIO_CODEC_DIR)/imx8mm/soc/src/dma_driver.o \ + $(KHDF_AUDIO_CODEC_DIR)/imx8mm/soc/src/imx8mm_platform_ops.o \ + $(KHDF_AUDIO_CODEC_DIR)/imx8mm/soc/src/imx8mm_dai_adapter.o \ + $(KHDF_AUDIO_CODEC_DIR)/imx8mm/soc/src/imx8mm_platform_adapter.o \ + $(KHDF_AUDIO_CODEC_DIR)/wm8904/codec/src/wm8904.o \ + $(KHDF_AUDIO_CODEC_DIR)/wm8904/codec/src/wm8904_impl.o obj-$(CONFIG_ARCH_HI3516DV300) += \ $(KHDF_AUDIO_ROOT_DIR)/core/src/audio_core.o \ @@ -83,9 +82,8 @@ ccflags-y += -lm -lc -lgcc -std=gnu99 -Werror \ -Iinclude/$(KHDF_FRAMEWORK_ROOT_DIR)/model/audio/sapm/include \ -Iinclude/$(KHDF_FRAMEWORK_ROOT_DIR)/model/audio/dispatch/include \ -Iinclude/$(KHDF_FRAMEWORK_ROOT_DIR)/model/audio/common/include \ - -Iinclude/$(KHDF_AUDIO_CODEC_DIR)/tfa9879/accessory/include \ - -Iinclude/$(KHDF_AUDIO_CODEC_DIR)/hi3516dv300/codec/include \ - -Iinclude/$(KHDF_AUDIO_CODEC_DIR)/hi3516dv300/soc/include \ - -Iinclude/$(KHDF_AUDIO_CODEC_DIR)/hi3516dv300/include \ + -Iinclude/$(KHDF_AUDIO_CODEC_DIR)/imx8mm/soc/include \ + -Iinclude/$(KHDF_AUDIO_CODEC_DIR)/imx8mm/include \ + -Iinclude/$(KHDF_AUDIO_CODEC_DIR)/wm8904/codec/include \ -Iinclude/$(KHDF_AUDIO_PERIPHERAL_ROOT_DIR)/audio/interfaces/include \ -Iinclude/$(KHDF_AUDIO_CODEC_DIR)/include diff --git a/model/input/Makefile b/model/input/Makefile index 024bc5e..ab7c92b 100644 --- a/model/input/Makefile +++ b/model/input/Makefile @@ -25,6 +25,8 @@ obj-$(CONFIG_DRIVERS_HDF_INPUT) += \ obj-$(CONFIG_DRIVERS_HDF_TP_5P5_GT911) += \ $(INPUT_ROOT_DIR)/touchscreen/touch_gt911.o +obj-$(CONFIG_ARCH_NXP_TOUCH) += \ + $(INPUT_ROOT_DIR)/touchscreen/touch_ft5x06.o obj-$(CONFIG_DRIVERS_HDF_TP_2P35_FT6236) += \ $(INPUT_ROOT_DIR)/touchscreen/touch_ft6336.o diff --git a/model/usb/device/f_generic.c b/model/usb/device/f_generic.c index 6878c95..1d9bde5 100644 --- a/model/usb/device/f_generic.c +++ b/model/usb/device/f_generic.c @@ -28,6 +28,7 @@ #include "u_f.h" #include "u_os_desc.h" #include "configfs.h" +#include "linux/swait.h" #define FUNCTIONFS_MAGIC 0xa647361 /* Chosen by a honest dice roll ;) */ diff --git a/network/Makefile b/network/Makefile index e6891c5..8afe670 100644 --- a/network/Makefile +++ b/network/Makefile @@ -12,4 +12,5 @@ # # -obj-$(CONFIG_DRIVERS_HDF_WIFI) += src/ \ No newline at end of file +obj-y += src/ +ccflags-$(CONFIG_DRIVERS_HDF_IMX8MM_ETHERNET) += -Idrivers/net/ethernet/freescale/ \ No newline at end of file diff --git a/network/include/net_device_adapter.h b/network/include/net_device_adapter.h index f124752..678414b 100755 --- a/network/include/net_device_adapter.h +++ b/network/include/net_device_adapter.h @@ -22,15 +22,12 @@ #include #include -#include "net_device_impl.h" - /** * data sending results, just define locked here, ok and busy reference linux definition for enum netdev_tx. */ #define NETDEV_TX_LOCKED 0x20 -int32_t RegisterNetDeviceImpl(struct NetDeviceImpl *ndImpl); -int32_t UnRegisterNetDeviceImpl(struct NetDeviceImpl *ndImpl); +struct net_device *GetKernelDev(void); struct FullNetDevicePriv { struct net_device *dev; diff --git a/network/src/Makefile b/network/src/Makefile index 34d25ae..408e229 100755 --- a/network/src/Makefile +++ b/network/src/Makefile @@ -12,9 +12,9 @@ # # -obj-$(CONFIG_DRIVERS_HDF_WIFI) += net_device_adapter.o netbuf_adapter.o +obj-y += net_device_adapter.o netbuf_adapter.o -ccflags-$(CONFIG_DRIVERS_HDF_WIFI) += \ +ccflags-y += \ -Idrivers/hdf/framework/model/network/common/netdevice \ -Idrivers/hdf/framework/include/net\ -Idrivers/hdf/khdf/network/include \ diff --git a/osal/src/osal_mutex.c b/osal/src/osal_mutex.c index 1809540..85f66c9 100644 --- a/osal/src/osal_mutex.c +++ b/osal/src/osal_mutex.c @@ -73,14 +73,27 @@ int32_t OsalMutexLock(struct OsalMutex *mutex) } EXPORT_SYMBOL(OsalMutexLock); +int32_t OsalMutexTryLock(struct OsalMutex *mutex) +{ + int32_t retVal = 0; + if (mutex == NULL || mutex->realMutex == NULL) { + HDF_LOGE("%s invalid param", __func__); + return HDF_ERR_INVALID_PARAM; + } + + retVal = mutex_trylock((struct mutex *)mutex->realMutex); + return HDF_SUCCESS; +} +EXPORT_SYMBOL(OsalMutexTryLock); + int32_t OsalMutexTimedLock(struct OsalMutex *mutex, uint32_t mSec) { - if (mutex == NULL || mutex->realMutex == NULL) { - HDF_LOGE("%s invalid param", __func__); - return HDF_ERR_INVALID_PARAM; - } + if (mutex == NULL || mutex->realMutex == NULL) { + HDF_LOGE("%s invalid param", __func__); + return HDF_ERR_INVALID_PARAM; + } - (void)mSec; + (void)mSec; mutex_lock((struct mutex *)mutex->realMutex); return HDF_SUCCESS; diff --git a/platform/emmc/emmc_adapter.c b/platform/emmc/emmc_adapter.c index 449cab0..ec20ab4 100644 --- a/platform/emmc/emmc_adapter.c +++ b/platform/emmc/emmc_adapter.c @@ -1,7 +1,7 @@ /* * emmc_adapter.c * - * hi35xx linux emmc driver implement. + * linux emmc driver implement. * * Copyright (c) 2020-2021 Huawei Device Co., Ltd. * @@ -27,45 +27,45 @@ #define HDF_LOG_TAG emmc_adapter_c -struct mmc_host *himci_get_mmc_host(int slot); +struct mmc_host *sdhci_esdhc_get_mmc_host(int slot); -int32_t Hi35xxLinuxEmmcGetCid(struct EmmcDevice *dev, uint8_t *cid, uint32_t size) +int32_t LinuxEmmcGetCid(struct EmmcDevice *dev, uint8_t *cid, uint32_t size) { struct mmc_host *mmcHost = NULL; struct MmcCntlr *cntlr = NULL; if (dev == NULL || dev->mmc.cntlr == NULL) { - HDF_LOGE("Hi35xxLinuxEmmcGetCid: dev or cntlr is null."); + HDF_LOGE("LinuxEmmcGetCid: dev or cntlr is null."); return HDF_ERR_INVALID_OBJECT; } if (cid == NULL || size < EMMC_CID_LEN) { - HDF_LOGE("Hi35xxLinuxEmmcGetCid: cid is null or size is invalid."); + HDF_LOGE("LinuxEmmcGetCid: cid is null or size is invalid."); return HDF_ERR_INVALID_PARAM; } cntlr = dev->mmc.cntlr; mmcHost = (struct mmc_host *)cntlr->priv; if (mmcHost == NULL) { - HDF_LOGE("Hi35xxLinuxEmmcGetCid: mmcHost is NULL!"); + HDF_LOGE("LinuxEmmcGetCid: mmcHost is NULL!"); return HDF_ERR_NOT_SUPPORT; } if (mmcHost->card == NULL) { - HDF_LOGE("Hi35xxLinuxEmmcGetCid: card is null."); + HDF_LOGE("LinuxEmmcGetCid: card is null."); return HDF_ERR_NOT_SUPPORT; } if (memcpy_s(cid, sizeof(uint8_t) * size, (uint8_t *)(mmcHost->card->raw_cid), sizeof(mmcHost->card->raw_cid)) != EOK) { - HDF_LOGE("Hi35xxLinuxEmmcGetCid: memcpy_s fail!"); + HDF_LOGE("LinuxEmmcGetCid: memcpy_s fail!"); return HDF_FAILURE; } return HDF_SUCCESS; } static struct EmmcDeviceOps g_emmcMethod = { - .getCid = Hi35xxLinuxEmmcGetCid, + .getCid = LinuxEmmcGetCid, }; -static void Hi35xxLinuxEmmcDeleteCntlr(struct MmcCntlr *cntlr) +static void LinuxEmmcDeleteCntlr(struct MmcCntlr *cntlr) { if (cntlr == NULL) { return; @@ -79,110 +79,109 @@ static void Hi35xxLinuxEmmcDeleteCntlr(struct MmcCntlr *cntlr) OsalMemFree(cntlr); } -static int32_t Hi35xxLinuxEmmcCntlrParse(struct MmcCntlr *cntlr, struct HdfDeviceObject *obj) +static int32_t LinuxEmmcCntlrParse(struct MmcCntlr *cntlr, struct HdfDeviceObject *obj) { const struct DeviceResourceNode *node = NULL; struct DeviceResourceIface *drsOps = NULL; int32_t ret; if (obj == NULL || cntlr == NULL) { - HDF_LOGE("Hi35xxLinuxEmmcCntlrParse: input para is NULL."); + HDF_LOGE("LinuxEmmcCntlrParse: input para is NULL."); return HDF_FAILURE; } node = obj->property; if (node == NULL) { - HDF_LOGE("Hi35xxLinuxEmmcCntlrParse: drs node is NULL."); + HDF_LOGE("LinuxEmmcCntlrParse: drs node is NULL."); return HDF_FAILURE; } drsOps = DeviceResourceGetIfaceInstance(HDF_CONFIG_SOURCE); if (drsOps == NULL || drsOps->GetUint16 == NULL || drsOps->GetUint32 == NULL) { - HDF_LOGE("Hi35xxLinuxEmmcCntlrParse: invalid drs ops fail!"); + HDF_LOGE("LinuxEmmcCntlrParse: 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!"); + HDF_LOGE("LinuxEmmcCntlrParse: read hostIndex fail!"); return ret; } ret = drsOps->GetUint32(node, "devType", &(cntlr->devType), 0); if (ret != HDF_SUCCESS) { - HDF_LOGE("Hi35xxLinuxEmmcCntlrParse: read devType fail!"); + HDF_LOGE("LinuxEmmcCntlrParse: read devType fail!"); return ret; } return HDF_SUCCESS; } -static int32_t Hi35xxLinuxEmmcBind(struct HdfDeviceObject *obj) +static int32_t LinuxEmmcBind(struct HdfDeviceObject *obj) { struct MmcCntlr *cntlr = NULL; int32_t ret; - HDF_LOGE("Hi35xxLinuxEmmcBind: entry!"); + HDF_LOGE("LinuxEmmcBind: entry!"); if (obj == NULL) { - HDF_LOGE("Hi35xxLinuxEmmcBind: Fail, obj is NULL."); + HDF_LOGE("LinuxEmmcBind: Fail, obj is NULL."); return HDF_ERR_INVALID_OBJECT; } cntlr = (struct MmcCntlr *)OsalMemCalloc(sizeof(struct MmcCntlr)); if (cntlr == NULL) { - HDF_LOGE("Hi35xxLinuxEmmcBind: no mem for MmcCntlr."); + HDF_LOGE("LinuxEmmcBind: no mem for MmcCntlr."); return HDF_ERR_MALLOC_FAIL; } cntlr->ops = NULL; cntlr->hdfDevObj = obj; obj->service = &cntlr->service; - ret = Hi35xxLinuxEmmcCntlrParse(cntlr, obj); + ret = LinuxEmmcCntlrParse(cntlr, obj); if (ret != HDF_SUCCESS) { - HDF_LOGE("Hi35xxLinuxEmmcBind: cntlr parse fail."); - goto _ERR; + HDF_LOGE("LinuxEmmcBind: cntlr parse fail."); + LinuxEmmcDeleteCntlr(cntlr); + return HDF_FAILURE; } - cntlr->priv = (void *)himci_get_mmc_host((int32_t)cntlr->index); + HDF_LOGE("LinuxEmmcBind cntlr->index= %d.", (int32_t)cntlr->index); + cntlr->priv = (void *)sdhci_esdhc_get_mmc_host((int32_t)cntlr->index); ret = MmcCntlrAdd(cntlr); if (ret != HDF_SUCCESS) { - HDF_LOGE("Hi35xxLinuxEmmcBind: cntlr add fail."); - goto _ERR; + HDF_LOGE("LinuxEmmcBind: cntlr add fail."); + LinuxEmmcDeleteCntlr(cntlr); + return HDF_FAILURE; } ret = MmcCntlrAllocDev(cntlr, (enum MmcDevType)cntlr->devType); if (ret != HDF_SUCCESS) { - HDF_LOGE("Hi35xxLinuxEmmcBind: alloc dev fail."); - goto _ERR; + HDF_LOGE("LinuxEmmcBind: alloc dev fail."); + LinuxEmmcDeleteCntlr(cntlr); + return HDF_FAILURE; } MmcDeviceAddOps(cntlr->curDev, &g_emmcMethod); - HDF_LOGD("Hi35xxLinuxEmmcBind: Success!"); + HDF_LOGD("LinuxEmmcBind: Success!"); return HDF_SUCCESS; - -_ERR: - Hi35xxLinuxEmmcDeleteCntlr(cntlr); - HDF_LOGE("Hi35xxLinuxEmmcBind: Fail!"); - return HDF_FAILURE; } -static int32_t Hi35xxLinuxEmmcInit(struct HdfDeviceObject *obj) +static int32_t LinuxEmmcInit(struct HdfDeviceObject *obj) { (void)obj; - HDF_LOGD("Hi35xxLinuxEmmcInit: Success!"); + HDF_LOGD("LinuxEmmcInit: Success!"); return HDF_SUCCESS; } -static void Hi35xxLinuxEmmcRelease(struct HdfDeviceObject *obj) +static void LinuxEmmcRelease(struct HdfDeviceObject *obj) { if (obj == NULL) { return; } - Hi35xxLinuxEmmcDeleteCntlr((struct MmcCntlr *)obj->service); + LinuxEmmcDeleteCntlr((struct MmcCntlr *)obj->service); } -struct HdfDriverEntry g_emmcDriverEntry = { +struct HdfDriverEntry g_emmcdriverentry = { .moduleVersion = 1, - .Bind = Hi35xxLinuxEmmcBind, - .Init = Hi35xxLinuxEmmcInit, - .Release = Hi35xxLinuxEmmcRelease, + .Bind = LinuxEmmcBind, + .Init = LinuxEmmcInit, + .Release = LinuxEmmcRelease, .moduleName = "HDF_PLATFORM_EMMC", }; -HDF_INIT(g_emmcDriverEntry); +HDF_INIT(g_emmcdriverentry); diff --git a/platform/mipi_dsi/mipi_tx_hi35xx.c b/platform/mipi_dsi/mipi_tx_hi35xx.c index 0c43806..dc8a2b8 100644 --- a/platform/mipi_dsi/mipi_tx_hi35xx.c +++ b/platform/mipi_dsi/mipi_tx_hi35xx.c @@ -704,6 +704,7 @@ static int32_t LinuxCopyToKernel(void *dest, uint32_t max, const void *src, uint HDF_LOGE("%s: [memcpy_s] failed.", __func__); } } + HDF_LOGI("%s: success.", __func__); return ret; } @@ -755,6 +756,7 @@ static int MipiTxDrvSetCmdInfo(const CmdInfoTag *cmdInfo) HDF_LOGE("%s: [MipiTxWaitWriteFifoEmpty] failed.", __func__); return HDF_FAILURE; } + HDF_LOGI("%s: cmdSize = 0x%x, dataType = 0x%x", __func__, cmdInfo->cmdSize, cmdInfo->dataType); return HDF_SUCCESS; } @@ -876,6 +878,7 @@ static void MipiTxReset(void) static int MipiTxDrvGetCmdInfo(GetCmdInfoTag *getCmdInfo) { unsigned char *dataBuf = NULL; + HDF_LOGI("%s: enter!", __func__); dataBuf = (unsigned char*)OsalMemAlloc(getCmdInfo->getDataSize); if (dataBuf == NULL) { @@ -913,6 +916,7 @@ static int MipiTxDrvGetCmdInfo(GetCmdInfoTag *getCmdInfo) } OsalMemFree(dataBuf); dataBuf = NULL; + HDF_LOGI("%s: success!", __func__); return HDF_SUCCESS; fail0: @@ -1080,6 +1084,7 @@ static int MipiTxCheckCombDevCfg(const ComboDevCfgTag *devCfg) return HDF_FAILURE; } + HDF_LOGI("%s: success!", __func__); return HDF_SUCCESS; } @@ -1225,6 +1230,7 @@ static int MipiTxGetCmd(GetCmdInfoTag *getCmdInfo) static int32_t Hi35xxGetCmd(struct MipiDsiCntlr *cntlr, struct DsiCmdDesc *cmd, uint32_t readLen, uint8_t *out) { GetCmdInfoTag cmdInfo; + HDF_LOGI("%s: enter!", __func__); (void)cntlr; if (cmd == NULL || out == NULL) { @@ -1271,6 +1277,7 @@ static struct MipiDsiCntlrMethod g_method = { static int32_t Hi35xxMipiTxInit(struct HdfDeviceObject *device) { int32_t ret; + HDF_LOGI("%s: enter!", __func__); g_mipiTx.priv = NULL; g_mipiTx.ops = &g_method; diff --git a/platform/pwm/pwm_adapter.c b/platform/pwm/pwm_adapter.c index 504f782..e94cb71 100644 --- a/platform/pwm/pwm_adapter.c +++ b/platform/pwm/pwm_adapter.c @@ -18,11 +18,14 @@ #include #include "device_resource_if.h" +#include "hdf_base.h" #include "hdf_log.h" +#include "osal_io.h" #include "osal_mem.h" #include "pwm_core.h" +#include "pwm_if.h" -#define HDF_LOG_TAG pwm_adapter +#define HDF_LOG_TAG HDF_PWM_LINUX_ADAPTER int32_t HdfPwmOpen(struct PwmDev *pwm) { @@ -57,7 +60,6 @@ int32_t HdfPwmClose(struct PwmDev *pwm) int32_t HdfPwmSetConfig(struct PwmDev *pwm, struct PwmConfig *config) { - int32_t ret; struct pwm_state state; if (pwm == NULL || pwm->priv == NULL || config == NULL) { @@ -69,15 +71,7 @@ int32_t HdfPwmSetConfig(struct PwmDev *pwm, struct PwmConfig *config) state.enabled = (config->status == PWM_ENABLE_STATUS) ? true : false; state.period = config->period; state.polarity = config->polarity; - HDF_LOGI("%s: set PwmConfig: number %u, period %u, duty %u, polarity %u, enable %u.", - __func__, config->number, config->period, config->duty, config->polarity, config->status); - ret = pwm_apply_state(pwm->priv, &state); - if (ret < 0) { - HDF_LOGE("%s: [pwm_apply_state] failed.", __func__); - return HDF_FAILURE; - } - HDF_LOGI("%s: success.", __func__); - return HDF_SUCCESS; + return pwm_apply_state(pwm->priv, &state); } struct PwmMethod g_pwmOps = { diff --git a/platform/pwm/pwm_hi35xx.h b/platform/pwm/pwm_hi35xx.h index fab0859..ecdb5a7 100644 --- a/platform/pwm/pwm_hi35xx.h +++ b/platform/pwm/pwm_hi35xx.h @@ -36,9 +36,9 @@ #define PWM_INV_OFFSET 1 #define PWM_KEEP_OFFSET 2 -#define PWM_DEFAULT_PERIOD 0x3E7 +#define PWM_DEFAULT_PERIOD 0x018F #define PWM_DEFAULT_POLARITY 0 -#define PWM_DEFAULT_DUTY_CYCLE 0x14D +#define PWM_DEFAULT_DUTY_CYCLE 0x00C7 struct HiPwmRegs { volatile uint32_t cfg0; @@ -55,7 +55,7 @@ static inline void HiPwmDisable(struct HiPwmRegs *reg) if (reg == NULL) { return; } - reg->ctrl &= ~1; + reg->ctrl = PWM_DISABLE; } static inline void HiPwmAlwaysOutput(struct HiPwmRegs *reg) diff --git a/platform/pwm/pwm_hi35xx_linux.c b/platform/pwm/pwm_hi35xx_linux.c index 68f1e7e..38c411d 100644 --- a/platform/pwm/pwm_hi35xx_linux.c +++ b/platform/pwm/pwm_hi35xx_linux.c @@ -16,15 +16,20 @@ * */ -#include "pwm_hi35xx.h" +#include #include +#include +#include +#include +#include +#include #include #include +#include #include #include -#include "hdf_log.h" +#include "pwm_hi35xx.h" -#define HDF_LOG_TAG pwm_hi35xx_linux #define PWM_ENABLE_MASK 0x1 #define PWM_HI35XX_N_CELLS 2 @@ -45,51 +50,42 @@ static int Hi35xxPwmApply(struct pwm_chip *chip, struct pwm_device *pwm, struct struct Hi35xxPwmChip *hi35xxChip = (struct Hi35xxPwmChip *)chip; if (hi35xxChip == NULL || pwm == NULL || state == NULL) { - HDF_LOGE("%s: parameter is null\n", __func__); + pr_err("%s: parameter is null\n", __func__); return -EINVAL; } reg = (struct HiPwmRegs *)hi35xxChip->base; if (state->polarity != PWM_POLARITY_NORMAL && state->polarity != PWM_POLARITY_INVERSED) { - HDF_LOGE("%s: polarity %u is invalid", __func__, state->polarity); + pr_err("%s: polarity %u is invalid", __func__, state->polarity); return -EINVAL; } if (state->period < PWM_MIN_PERIOD) { - HDF_LOGE("%s: period %llu is not support, min period %d", __func__, state->period, PWM_MIN_PERIOD); + pr_err("%s: period %u is not support, min period %u", __func__, state->period, PWM_MIN_PERIOD); return -EINVAL; } if (state->duty_cycle < 1 || state->duty_cycle > state->period) { - HDF_LOGE("%s: duty %llu is not support, duty must in [1, period = %llu].", - __func__, state->duty_cycle , state->period); + pr_err("%s: duty_cycle %u is not support, min duty_cycle 1 max duty_cycle %u", + __func__, state->duty_cycle , state->period); return -EINVAL; } HiPwmDisable(reg); - HDF_LOGI("%s: [HiPwmDisable] done.", __func__); if (pwm->state.polarity != state->polarity) { HiPwmSetPolarity(reg, state->polarity); - HDF_LOGI("%s: [HiPwmSetPolarity] done, polarity: %u -> %u.", __func__, pwm->state.polarity, state->polarity); } if (pwm->state.period != state->period) { HiPwmSetPeriod(reg, state->period); - HDF_LOGI("%s: [HiPwmSetPeriod] done, period: %llu -> %llu.", __func__, pwm->state.period, state->period); } if (pwm->state.duty_cycle != state->duty_cycle) { HiPwmSetDuty(reg, state->duty_cycle); - HDF_LOGI("%s: [HiPwmSetDuty] done, duty: %llu -> %llu.", __func__, pwm->state.duty_cycle, state->duty_cycle); } if (state->enabled) { HiPwmAlwaysOutput(reg); - HDF_LOGI("%s: [HiPwmAlwaysOutput] done, then enable.", __func__); } - - HDF_LOGI("%s: set PwmConfig done: number none, period %llu, duty %llu, polarity %u, enable %u.", - __func__, state->period, state->duty_cycle, state->polarity, state->enabled); - HDF_LOGI("%s: success.", __func__); - return 0; } + static void Hi35xxGetState(struct pwm_chip *chip, struct pwm_device *pwm, struct pwm_state *state) { struct HiPwmRegs *reg = NULL; @@ -100,13 +96,9 @@ static void Hi35xxGetState(struct pwm_chip *chip, struct pwm_device *pwm, struct return; } reg = (struct HiPwmRegs *)hi35xxChip->base; - state->period = reg->cfg0 * PWM_CLK_PERIOD; - state->duty_cycle = reg->cfg1 * PWM_CLK_PERIOD; - state->polarity = (reg->ctrl & (1 << PWM_INV_OFFSET)) >> PWM_INV_OFFSET; + state->period = reg->cfg0; + state->duty_cycle = reg->cfg1; state->enabled = reg->ctrl & PWM_ENABLE_MASK; - - HDF_LOGI("%s: get PwmConfig: number none, period %llu, duty %llu, polarity %u, enable %u.", - __func__, state->period, state->duty_cycle, state->polarity, state->enabled); } static struct pwm_ops Hi35xxPwmOps = { diff --git a/platform/rtc/rtc_adapter.c b/platform/rtc/rtc_adapter.c index 41262fd..031b529 100644 --- a/platform/rtc/rtc_adapter.c +++ b/platform/rtc/rtc_adapter.c @@ -51,7 +51,7 @@ static inline void LinuxTimeToHdfTime(struct RtcTime *hdfTime, const struct rtc_ static inline struct rtc_device *HdfGetRtcDevice(void) { - struct rtc_device *dev = rtc_class_open(CONFIG_RTC_SYSTOHC_DEVICE); + struct rtc_device *dev = rtc_class_open("rtc0"); if (dev == NULL) { HDF_LOGE("%s: failed to get rtc device", __func__); diff --git a/platform/sdio/sdio_adapter.c b/platform/sdio/sdio_adapter.c index 59fdba5..d7a006e 100644 --- a/platform/sdio/sdio_adapter.c +++ b/platform/sdio/sdio_adapter.c @@ -1,7 +1,7 @@ /* * sdio_adapter.c * - * hi35xx linux sdio driver implement. + * Linux sdio driver implement. * * Copyright (c) 2020-2021 Huawei Device Co., Ltd. * @@ -33,32 +33,32 @@ #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); +struct mmc_host *sdhci_esdhc_get_mmc_host(int slot); +void sdhci_esdhc_sdio_rescan(int slot); -static struct sdio_func *Hi35xxLinuxSdioGetFunc(struct SdioDevice *dev) +static struct sdio_func *LinuxSdioGetFunc(struct SdioDevice *dev) { if (dev == NULL) { - HDF_LOGE("Hi35xxLinuxSdioGetFunc: dev is null."); + HDF_LOGE("LinuxSdioGetFunc: dev is null."); return NULL; } return (struct sdio_func *)dev->sd.mmc.priv; } -static int32_t Hi35xxLinuxSdioIncrAddrReadBytes(struct SdioDevice *dev, +static int32_t LinuxSdioIncrAddrReadBytes(struct SdioDevice *dev, uint8_t *data, uint32_t addr, uint32_t size) { - struct sdio_func *func = Hi35xxLinuxSdioGetFunc(dev); + struct sdio_func *func = LinuxSdioGetFunc(dev); int32_t ret = HDF_SUCCESS; uint16_t *output16 = NULL; uint32_t *output32 = NULL; if (func == NULL) { - HDF_LOGE("Hi35xxLinuxSdioIncrAddrReadBytes: func is NULL."); + HDF_LOGE("LinuxSdioIncrAddrReadBytes: func is NULL."); return HDF_ERR_INVALID_OBJECT; } if ((data == NULL) || (size == 0)) { - HDF_LOGE("Hi35xxLinuxSdioIncrAddrReadBytes: data or size is invalid."); + HDF_LOGE("LinuxSdioIncrAddrReadBytes: data or size is invalid."); return HDF_ERR_INVALID_PARAM; } @@ -79,18 +79,18 @@ static int32_t Hi35xxLinuxSdioIncrAddrReadBytes(struct SdioDevice *dev, return sdio_memcpy_fromio(func, data, addr, size); } -static int32_t Hi35xxLinuxSdioIncrAddrWriteBytes(struct SdioDevice *dev, +static int32_t LinuxSdioIncrAddrWriteBytes(struct SdioDevice *dev, uint8_t *data, uint32_t addr, uint32_t size) { int32_t ret = HDF_SUCCESS; - struct sdio_func *func = Hi35xxLinuxSdioGetFunc(dev); + struct sdio_func *func = LinuxSdioGetFunc(dev); if (func == NULL) { - HDF_LOGE("Hi35xxLinuxSdioIncrAddrWriteBytes: func is NULL."); + HDF_LOGE("LinuxSdioIncrAddrWriteBytes: func is NULL."); return HDF_ERR_INVALID_OBJECT; } if ((data == NULL) || (size == 0)) { - HDF_LOGE("Hi35xxLinuxSdioIncrAddrWriteBytes: data or size is invalid."); + HDF_LOGE("LinuxSdioIncrAddrWriteBytes: data or size is invalid."); return HDF_ERR_INVALID_PARAM; } @@ -109,60 +109,60 @@ static int32_t Hi35xxLinuxSdioIncrAddrWriteBytes(struct SdioDevice *dev, return sdio_memcpy_toio(func, addr, data, size); } -static int32_t Hi35xxLinuxSdioFixedAddrReadBytes(struct SdioDevice *dev, +static int32_t LinuxSdioFixedAddrReadBytes(struct SdioDevice *dev, uint8_t *data, uint32_t addr, uint32_t size, uint32_t scatterLen) { - struct sdio_func *func = Hi35xxLinuxSdioGetFunc(dev); + struct sdio_func *func = LinuxSdioGetFunc(dev); if (func == NULL) { - HDF_LOGE("Hi35xxLinuxSdioFixedAddrReadBytes: func is NULL."); + HDF_LOGE("LinuxSdioFixedAddrReadBytes: func is NULL."); return HDF_ERR_INVALID_OBJECT; } if ((data == NULL) || (size == 0)) { - HDF_LOGE("Hi35xxLinuxSdioFixedAddrReadBytes: data or size is invalid."); + HDF_LOGE("LinuxSdioFixedAddrReadBytes: data or size is invalid."); return HDF_ERR_INVALID_PARAM; } if (scatterLen > 0) { - HDF_LOGE("Hi35xxLinuxSdioFixedAddrReadBytes: not support!"); + HDF_LOGE("LinuxSdioFixedAddrReadBytes: not support!"); return HDF_ERR_NOT_SUPPORT; } return sdio_readsb(func, data, addr, size); } -static int32_t Hi35xxLinuxSdioFixedAddrWriteBytes(struct SdioDevice *dev, +static int32_t LinuxSdioFixedAddrWriteBytes(struct SdioDevice *dev, uint8_t *data, uint32_t addr, uint32_t size, uint32_t scatterLen) { - struct sdio_func *func = Hi35xxLinuxSdioGetFunc(dev); + struct sdio_func *func = LinuxSdioGetFunc(dev); if (func == NULL) { - HDF_LOGE("Hi35xxLinuxSdioFixedAddrWriteBytes: func is NULL."); + HDF_LOGE("LinuxSdioFixedAddrWriteBytes: func is NULL."); return HDF_ERR_INVALID_OBJECT; } if ((data == NULL) || (size == 0)) { - HDF_LOGE("Hi35xxLinuxSdioFixedAddrReadBytes: data or size is invalid."); + HDF_LOGE("LinuxSdioFixedAddrReadBytes: data or size is invalid."); return HDF_ERR_INVALID_PARAM; } if (scatterLen > 0) { - HDF_LOGE("Hi35xxLinuxSdioFixedAddrWriteBytes: not support!"); + HDF_LOGE("LinuxSdioFixedAddrWriteBytes: not support!"); return HDF_ERR_NOT_SUPPORT; } return sdio_writesb(func, addr, data, size); } -static int32_t Hi35xxLinuxSdioFunc0ReadBytes(struct SdioDevice *dev, +static int32_t LinuxSdioFunc0ReadBytes(struct SdioDevice *dev, uint8_t *data, uint32_t addr, uint32_t size) { int32_t ret = HDF_SUCCESS; - struct sdio_func *func = Hi35xxLinuxSdioGetFunc(dev); + struct sdio_func *func = LinuxSdioGetFunc(dev); if (func == NULL) { - HDF_LOGE("Hi35xxLinuxSdioFunc0ReadBytes: func is NULL."); + HDF_LOGE("LinuxSdioFunc0ReadBytes: func is NULL."); return HDF_ERR_INVALID_OBJECT; } if ((data == NULL) || (size == 0)) { - HDF_LOGE("Hi35xxLinuxSdioFunc0ReadBytes: data or size is invalid."); + HDF_LOGE("LinuxSdioFunc0ReadBytes: data or size is invalid."); return HDF_ERR_INVALID_PARAM; } @@ -170,18 +170,18 @@ static int32_t Hi35xxLinuxSdioFunc0ReadBytes(struct SdioDevice *dev, return ret; } -static int32_t Hi35xxLinuxSdioFunc0WriteBytes(struct SdioDevice *dev, +static int32_t LinuxSdioFunc0WriteBytes(struct SdioDevice *dev, uint8_t *data, uint32_t addr, uint32_t size) { int32_t ret = HDF_SUCCESS; - struct sdio_func *func = Hi35xxLinuxSdioGetFunc(dev); + struct sdio_func *func = LinuxSdioGetFunc(dev); if (func == NULL) { - HDF_LOGE("Hi35xxLinuxSdioFunc0WriteBytes: func is NULL."); + HDF_LOGE("LinuxSdioFunc0WriteBytes: func is NULL."); return HDF_ERR_INVALID_OBJECT; } if ((data == NULL) || (size == 0)) { - HDF_LOGE("Hi35xxLinuxSdioFunc0WriteBytes: data or size is invalid."); + HDF_LOGE("LinuxSdioFunc0WriteBytes: data or size is invalid."); return HDF_ERR_INVALID_PARAM; } @@ -189,41 +189,41 @@ static int32_t Hi35xxLinuxSdioFunc0WriteBytes(struct SdioDevice *dev, return ret; } -static int32_t Hi35xxLinuxSdioSetBlockSize(struct SdioDevice *dev, uint32_t blockSize) +static int32_t LinuxSdioSetBlockSize(struct SdioDevice *dev, uint32_t blockSize) { - struct sdio_func *func = Hi35xxLinuxSdioGetFunc(dev); + struct sdio_func *func = LinuxSdioGetFunc(dev); if (func == NULL) { - HDF_LOGE("Hi35xxLinuxSdioSetBlockSize, func is NULL."); + HDF_LOGE("LinuxSdioSetBlockSize, func is NULL."); return HDF_ERR_INVALID_OBJECT; } return sdio_set_block_size(func, blockSize); } -static int32_t Hi35xxLinuxSdioGetCommonInfo(struct SdioDevice *dev, +static int32_t LinuxSdioGetCommonInfo(struct SdioDevice *dev, SdioCommonInfo *info, uint32_t infoType) { - struct sdio_func *func = Hi35xxLinuxSdioGetFunc(dev); + struct sdio_func *func = LinuxSdioGetFunc(dev); if (func == NULL) { - HDF_LOGE("Hi35xxLinuxSdioGetCommonInfo: func is NULL."); + HDF_LOGE("LinuxSdioGetCommonInfo: func is NULL."); return HDF_ERR_INVALID_OBJECT; } if (info == NULL) { - HDF_LOGE("Hi35xxLinuxSdioGetCommonInfo: info is null."); + HDF_LOGE("LinuxSdioGetCommonInfo: info is null."); return HDF_ERR_INVALID_PARAM; } if (infoType != SDIO_FUNC_INFO) { - HDF_LOGE("Hi35xxLinuxSdioGetCommonInfo: cur type %d is not support.", infoType); + HDF_LOGE("LinuxSdioGetCommonInfo: cur type %d is not support.", infoType); return HDF_ERR_NOT_SUPPORT; } if (func->card == NULL) { - HDF_LOGE("Hi35xxLinuxSdioGetCommonInfo fail, card is null."); + HDF_LOGE("LinuxSdioGetCommonInfo fail, card is null."); return HDF_ERR_INVALID_PARAM; } if (func->card->host == NULL) { - HDF_LOGE("Hi35xxLinuxSdioGetCommonInfo fail, host is null."); + HDF_LOGE("LinuxSdioGetCommonInfo fail, host is null."); return HDF_ERR_INVALID_PARAM; } info->funcInfo.enTimeout = func->enable_timeout; @@ -236,30 +236,30 @@ static int32_t Hi35xxLinuxSdioGetCommonInfo(struct SdioDevice *dev, return HDF_SUCCESS; } -static int32_t Hi35xxLinuxSdioSetCommonInfo(struct SdioDevice *dev, +static int32_t LinuxSdioSetCommonInfo(struct SdioDevice *dev, SdioCommonInfo *info, uint32_t infoType) { - struct sdio_func *func = Hi35xxLinuxSdioGetFunc(dev); + struct sdio_func *func = LinuxSdioGetFunc(dev); if (func == NULL) { - HDF_LOGE("Hi35xxLinuxSdioSetCommonInfo: func is NULL."); + HDF_LOGE("LinuxSdioSetCommonInfo: func is NULL."); return HDF_ERR_INVALID_OBJECT; } if (info == NULL) { - HDF_LOGE("Hi35xxLinuxSdioSetCommonInfo: info is null."); + HDF_LOGE("LinuxSdioSetCommonInfo: info is null."); return HDF_ERR_INVALID_PARAM; } if (infoType != SDIO_FUNC_INFO) { - HDF_LOGE("Hi35xxLinuxSdioSetCommonInfo: cur type %d is not support.", infoType); + HDF_LOGE("LinuxSdioSetCommonInfo: cur type %d is not support.", infoType); return HDF_ERR_NOT_SUPPORT; } if (func->card == NULL) { - HDF_LOGE("Hi35xxLinuxSdioSetCommonInfo fail, card is null."); + HDF_LOGE("LinuxSdioSetCommonInfo fail, card is null."); return HDF_ERR_INVALID_PARAM; } if (func->card->host == NULL) { - HDF_LOGE("Hi35xxLinuxSdioSetCommonInfo fail, host is null."); + HDF_LOGE("LinuxSdioSetCommonInfo fail, host is null."); return HDF_ERR_INVALID_PARAM; } func->enable_timeout = info->funcInfo.enTimeout; @@ -270,95 +270,95 @@ static int32_t Hi35xxLinuxSdioSetCommonInfo(struct SdioDevice *dev, return HDF_SUCCESS; } -static int32_t Hi35xxLinuxSdioFlushData(struct SdioDevice *dev) +static int32_t LinuxSdioFlushData(struct SdioDevice *dev) { - struct sdio_func *func = Hi35xxLinuxSdioGetFunc(dev); + struct sdio_func *func = LinuxSdioGetFunc(dev); if (func == NULL) { - HDF_LOGE("Hi35xxLinuxSdioFlushData: func is NULL."); + HDF_LOGE("LinuxSdioFlushData: func is NULL."); return HDF_ERR_INVALID_OBJECT; } if (func->card == NULL) { - HDF_LOGE("Hi35xxLinuxSdioFlushData: card is NULL."); + HDF_LOGE("LinuxSdioFlushData: card is NULL."); return HDF_ERR_INVALID_OBJECT; } return mmc_sw_reset(func->card->host); } -static int32_t Hi35xxLinuxSdioClaimHost(struct SdioDevice *dev) +static int32_t LinuxSdioClaimHost(struct SdioDevice *dev) { - struct sdio_func *func = Hi35xxLinuxSdioGetFunc(dev); + struct sdio_func *func = LinuxSdioGetFunc(dev); if (func == NULL) { - HDF_LOGE("Hi35xxLinuxSdioClaimHost: func is NULL."); + HDF_LOGE("LinuxSdioClaimHost: func is NULL."); return HDF_ERR_INVALID_OBJECT; } sdio_claim_host(func); return HDF_SUCCESS; } -static int32_t Hi35xxLinuxSdioReleaseHost(struct SdioDevice *dev) +static int32_t LinuxSdioReleaseHost(struct SdioDevice *dev) { - struct sdio_func *func = Hi35xxLinuxSdioGetFunc(dev); + struct sdio_func *func = LinuxSdioGetFunc(dev); if (func == NULL) { - HDF_LOGE("Hi35xxLinuxSdioReleaseHost: func is NULL."); + HDF_LOGE("LinuxSdioReleaseHost: func is NULL."); return HDF_ERR_INVALID_OBJECT; } sdio_release_host(func); return HDF_SUCCESS; } -static int32_t Hi35xxLinuxSdioEnableFunc(struct SdioDevice *dev) +static int32_t LinuxSdioEnableFunc(struct SdioDevice *dev) { - struct sdio_func *func = Hi35xxLinuxSdioGetFunc(dev); + struct sdio_func *func = LinuxSdioGetFunc(dev); if (func == NULL) { - HDF_LOGE("Hi35xxLinuxSdioEnableFunc: func is NULL."); + HDF_LOGE("LinuxSdioEnableFunc: func is NULL."); return HDF_ERR_INVALID_OBJECT; } return sdio_enable_func(func); } -static int32_t Hi35xxLinuxSdioDisableFunc(struct SdioDevice *dev) +static int32_t LinuxSdioDisableFunc(struct SdioDevice *dev) { - struct sdio_func *func = Hi35xxLinuxSdioGetFunc(dev); + struct sdio_func *func = LinuxSdioGetFunc(dev); if (func == NULL) { - HDF_LOGE("Hi35xxLinuxSdioDisableFunc: func is NULL."); + HDF_LOGE("LinuxSdioDisableFunc: func is NULL."); return HDF_ERR_INVALID_OBJECT; } return sdio_disable_func(func); } -static int32_t Hi35xxLinuxSdioClaimIrq(struct SdioDevice *dev, SdioIrqHandler *handler) +static int32_t LinuxSdioClaimIrq(struct SdioDevice *dev, SdioIrqHandler *handler) { - struct sdio_func *func = Hi35xxLinuxSdioGetFunc(dev); + struct sdio_func *func = LinuxSdioGetFunc(dev); if (func == NULL) { - HDF_LOGE("Hi35xxLinuxSdioClaimIrq: func is NULL."); + HDF_LOGE("LinuxSdioClaimIrq: func is NULL."); return HDF_ERR_INVALID_OBJECT; } if (handler == NULL) { - HDF_LOGE("Hi35xxLinuxSdioClaimIrq: handler is null."); + HDF_LOGE("LinuxSdioClaimIrq: handler is null."); return HDF_ERR_INVALID_PARAM; } return sdio_claim_irq(func, (sdio_irq_handler_t *)handler); } -static int32_t Hi35xxLinuxSdioReleaseIrq(struct SdioDevice *dev) +static int32_t LinuxSdioReleaseIrq(struct SdioDevice *dev) { - struct sdio_func *func = Hi35xxLinuxSdioGetFunc(dev); + struct sdio_func *func = LinuxSdioGetFunc(dev); if (func == NULL) { - HDF_LOGE("Hi35xxLinuxSdioReleaseIrq: func is NULL."); + HDF_LOGE("LinuxSdioReleaseIrq: func is NULL."); return HDF_ERR_INVALID_OBJECT; } return sdio_release_irq(func); } -static struct sdio_func *Hi35xxLinuxSdioSearchFunc(uint32_t funcNum, uint16_t vendorId, uint16_t deviceId) +static struct sdio_func *LinuxSdioSearchFunc(uint32_t funcNum, uint16_t vendorId, uint16_t deviceId) { struct mmc_card *card = NULL; struct mmc_host *host = NULL; @@ -366,7 +366,7 @@ static struct sdio_func *Hi35xxLinuxSdioSearchFunc(uint32_t funcNum, uint16_t ve uint32_t i, j; for (i = 0; i < MMC_SLOT_NUM; i++) { - host = himci_get_mmc_host(i); + host = sdhci_esdhc_get_mmc_host(i); if (host == NULL) { continue; } @@ -380,57 +380,57 @@ static struct sdio_func *Hi35xxLinuxSdioSearchFunc(uint32_t funcNum, uint16_t ve (func->num == funcNum) && (func->vendor == vendorId) && (func->device == deviceId)) { - HDF_LOGD("Hi35xxLinuxSdioSearchFunc: find func!"); + HDF_LOGE("LinuxSdioSearchFunc: find func!"); return func; } } } - HDF_LOGE("Hi35xxLinuxSdioSearchFunc: get sdio func fail!"); + HDF_LOGE("LinuxSdioSearchFunc: get sdio func fail!"); return NULL; } -static int32_t Hi35xxLinuxSdioFindFunc(struct SdioDevice *dev, struct SdioFunctionConfig *configData) +static int32_t LinuxSdioFindFunc(struct SdioDevice *dev, struct SdioFunctionConfig *configData) { if (dev == NULL || configData == NULL) { - HDF_LOGE("Hi35xxLinuxSdioFindFunc: dev or configData is NULL."); + HDF_LOGE("LinuxSdioFindFunc: dev or configData is NULL."); return HDF_ERR_INVALID_OBJECT; } - dev->sd.mmc.priv = Hi35xxLinuxSdioSearchFunc(configData->funcNr, configData->vendorId, configData->deviceId); + dev->sd.mmc.priv = LinuxSdioSearchFunc(configData->funcNr, configData->vendorId, configData->deviceId); if (dev->sd.mmc.priv == NULL) { - HDF_LOGE("Hi35xxLinuxSdioFindFunc: Hi35xxLinuxSdioSearchFunc fail."); + HDF_LOGE("LinuxSdioFindFunc: LinuxSdioSearchFunc fail."); return HDF_ERR_NOT_SUPPORT; } return HDF_SUCCESS; } static struct SdioDeviceOps g_sdioDeviceOps = { - .incrAddrReadBytes = Hi35xxLinuxSdioIncrAddrReadBytes, - .incrAddrWriteBytes = Hi35xxLinuxSdioIncrAddrWriteBytes, - .fixedAddrReadBytes = Hi35xxLinuxSdioFixedAddrReadBytes, - .fixedAddrWriteBytes = Hi35xxLinuxSdioFixedAddrWriteBytes, - .func0ReadBytes = Hi35xxLinuxSdioFunc0ReadBytes, - .func0WriteBytes = Hi35xxLinuxSdioFunc0WriteBytes, - .setBlockSize = Hi35xxLinuxSdioSetBlockSize, - .getCommonInfo = Hi35xxLinuxSdioGetCommonInfo, - .setCommonInfo = Hi35xxLinuxSdioSetCommonInfo, - .flushData = Hi35xxLinuxSdioFlushData, - .enableFunc = Hi35xxLinuxSdioEnableFunc, - .disableFunc = Hi35xxLinuxSdioDisableFunc, - .claimIrq = Hi35xxLinuxSdioClaimIrq, - .releaseIrq = Hi35xxLinuxSdioReleaseIrq, - .findFunc = Hi35xxLinuxSdioFindFunc, - .claimHost = Hi35xxLinuxSdioClaimHost, - .releaseHost = Hi35xxLinuxSdioReleaseHost, + .incrAddrReadBytes = LinuxSdioIncrAddrReadBytes, + .incrAddrWriteBytes = LinuxSdioIncrAddrWriteBytes, + .fixedAddrReadBytes = LinuxSdioFixedAddrReadBytes, + .fixedAddrWriteBytes = LinuxSdioFixedAddrWriteBytes, + .func0ReadBytes = LinuxSdioFunc0ReadBytes, + .func0WriteBytes = LinuxSdioFunc0WriteBytes, + .setBlockSize = LinuxSdioSetBlockSize, + .getCommonInfo = LinuxSdioGetCommonInfo, + .setCommonInfo = LinuxSdioSetCommonInfo, + .flushData = LinuxSdioFlushData, + .enableFunc = LinuxSdioEnableFunc, + .disableFunc = LinuxSdioDisableFunc, + .claimIrq = LinuxSdioClaimIrq, + .releaseIrq = LinuxSdioReleaseIrq, + .findFunc = LinuxSdioFindFunc, + .claimHost = LinuxSdioClaimHost, + .releaseHost = LinuxSdioReleaseHost, }; -static bool Hi35xxLinuxSdioRescanFinish(struct MmcCntlr *cntlr) +static bool LinuxSdioRescanFinish(struct MmcCntlr *cntlr) { struct mmc_host *host = NULL; struct mmc_card *card = NULL; - host = himci_get_mmc_host(cntlr->index); + host = sdhci_esdhc_get_mmc_host(cntlr->index); if (host == NULL) { return false; } @@ -445,25 +445,25 @@ static bool Hi35xxLinuxSdioRescanFinish(struct MmcCntlr *cntlr) return false; } -static int32_t Hi35xxLinuxSdioRescan(struct MmcCntlr *cntlr) +static int32_t LinuxSdioRescan(struct MmcCntlr *cntlr) { bool rescanFinish = false; uint32_t count = 0; if (cntlr == NULL) { - HDF_LOGE("Hi35xxLinuxSdioRescan: cntlr is NULL."); + HDF_LOGE("LinuxSdioRescan: cntlr is NULL."); return HDF_ERR_INVALID_OBJECT; } - hisi_sdio_rescan(cntlr->index); + sdhci_esdhc_sdio_rescan(cntlr->index); while (rescanFinish == false && count < SDIO_RESCAN_WAIT_TIME) { OsalMSleep(50); count++; - rescanFinish = Hi35xxLinuxSdioRescanFinish(cntlr); + rescanFinish = LinuxSdioRescanFinish(cntlr); } if (rescanFinish == false) { - HDF_LOGE("Hi35xxLinuxSdioRescan: fail!"); + HDF_LOGE("LinuxSdioRescan: fail!"); return HDF_FAILURE; } @@ -471,11 +471,11 @@ static int32_t Hi35xxLinuxSdioRescan(struct MmcCntlr *cntlr) return HDF_SUCCESS; } -struct MmcCntlrOps g_sdioCntlrOps = { - .rescanSdioDev = Hi35xxLinuxSdioRescan, +struct MmcCntlrOps g_sdiocntlrops = { + .rescanSdioDev = LinuxSdioRescan, }; -static void Hi35xxLinuxSdioDeleteCntlr(struct MmcCntlr *cntlr) +static void LinuxSdioDeleteCntlr(struct MmcCntlr *cntlr) { if (cntlr == NULL) { return; @@ -489,110 +489,109 @@ static void Hi35xxLinuxSdioDeleteCntlr(struct MmcCntlr *cntlr) OsalMemFree(cntlr); } -static int32_t Hi35xxLinuxSdioCntlrParse(struct MmcCntlr *cntlr, struct HdfDeviceObject *obj) +static int32_t LinuxSdioCntlrParse(struct MmcCntlr *cntlr, struct HdfDeviceObject *obj) { const struct DeviceResourceNode *node = NULL; struct DeviceResourceIface *drsOps = NULL; int32_t ret; if (obj == NULL || cntlr == NULL) { - HDF_LOGE("Hi35xxLinuxSdioCntlrParse: input para is NULL."); + HDF_LOGE("LinuxSdioCntlrParse: input para is NULL."); return HDF_FAILURE; } node = obj->property; if (node == NULL) { - HDF_LOGE("Hi35xxLinuxSdioCntlrParse: drs node is NULL."); + HDF_LOGE("LinuxSdioCntlrParse: 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!"); + HDF_LOGE("LinuxSdioCntlrParse: 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!"); + HDF_LOGE("LinuxSdioCntlrParse: read hostIndex fail!"); return ret; } ret = drsOps->GetUint32(node, "devType", &(cntlr->devType), 0); if (ret != HDF_SUCCESS) { - HDF_LOGE("Hi35xxLinuxSdioCntlrParse: read devType fail!"); + HDF_LOGE("LinuxSdioCntlrParse: read devType fail!"); return ret; } - HDF_LOGD("Hi35xxLinuxSdioCntlrParse: hostIndex = %d, devType = %d.", cntlr->index, cntlr->devType); + HDF_LOGE("LinuxSdioCntlrParse: hostIndex = %d, devType = %d.", cntlr->index, cntlr->devType); return HDF_SUCCESS; } -static int32_t Hi35xxLinuxSdioBind(struct HdfDeviceObject *obj) +static int32_t LinuxSdioBind(struct HdfDeviceObject *obj) { struct MmcCntlr *cntlr = NULL; int32_t ret; - HDF_LOGE("Hi35xxLinuxSdioBind: entry!"); + HDF_LOGE("LinuxSdioBind: entry!"); if (obj == NULL) { - HDF_LOGE("Hi35xxLinuxSdioBind: Fail, obj is NULL."); + HDF_LOGE("LinuxSdioBind: Fail, obj is NULL."); return HDF_ERR_INVALID_OBJECT; } cntlr = (struct MmcCntlr *)OsalMemCalloc(sizeof(struct MmcCntlr)); if (cntlr == NULL) { - HDF_LOGE("Hi35xxLinuxSdioBind: no mem for MmcCntlr."); + HDF_LOGE("LinuxSdioBind: no mem for MmcCntlr."); return HDF_ERR_MALLOC_FAIL; } - cntlr->ops = &g_sdioCntlrOps; + cntlr->ops = &g_sdiocntlrops; cntlr->hdfDevObj = obj; obj->service = &cntlr->service; /* init cntlr. */ - ret = Hi35xxLinuxSdioCntlrParse(cntlr, obj); + ret = LinuxSdioCntlrParse(cntlr, obj); if (ret != HDF_SUCCESS) { - HDF_LOGE("Hi35xxLinuxSdioBind: cntlr parse fail."); - goto _ERR; + HDF_LOGE("LinuxSdioBind: cntlr parse fail."); + LinuxSdioDeleteCntlr(cntlr); + return HDF_FAILURE; } ret = MmcCntlrAdd(cntlr); if (ret != HDF_SUCCESS) { - HDF_LOGE("Hi35xxLinuxSdioBind: cntlr add fail."); - goto _ERR; + HDF_LOGE("LinuxSdioBind: cntlr add fail."); + LinuxSdioDeleteCntlr(cntlr); + return HDF_FAILURE; } ret = MmcCntlrAllocDev(cntlr, (enum MmcDevType)cntlr->devType); if (ret != HDF_SUCCESS) { - HDF_LOGE("Hi35xxLinuxSdioBind: alloc dev fail."); - goto _ERR; + HDF_LOGE("LinuxSdioBind: alloc dev fail."); + LinuxSdioDeleteCntlr(cntlr); + return HDF_FAILURE; } + MmcDeviceAddOps(cntlr->curDev, &g_sdioDeviceOps); - HDF_LOGD("Hi35xxLinuxSdioBind: Success!"); + HDF_LOGE("LinuxSdioBind: Success!"); return HDF_SUCCESS; - -_ERR: - Hi35xxLinuxSdioDeleteCntlr(cntlr); - HDF_LOGE("Hi35xxLinuxSdioBind: Fail!"); - return HDF_FAILURE; } -static int32_t Hi35xxLinuxSdioInit(struct HdfDeviceObject *obj) +static int32_t LinuxSdioInit(struct HdfDeviceObject *obj) { (void)obj; - HDF_LOGD("Hi35xxLinuxSdioInit: Success!"); + HDF_LOGE("LinuxSdioInit: Success!"); return HDF_SUCCESS; } -static void Hi35xxLinuxSdioRelease(struct HdfDeviceObject *obj) +static void LinuxSdioRelease(struct HdfDeviceObject *obj) { if (obj == NULL) { return; } - Hi35xxLinuxSdioDeleteCntlr((struct MmcCntlr *)obj->service); + LinuxSdioDeleteCntlr((struct MmcCntlr *)obj->service); } -struct HdfDriverEntry g_sdioDriverEntry = { +struct HdfDriverEntry g_sdiodriverentry = { .moduleVersion = 1, - .Bind = Hi35xxLinuxSdioBind, - .Init = Hi35xxLinuxSdioInit, - .Release = Hi35xxLinuxSdioRelease, + .Bind = LinuxSdioBind, + .Init = LinuxSdioInit, + .Release = LinuxSdioRelease, .moduleName = "HDF_PLATFORM_SDIO", }; -HDF_INIT(g_sdioDriverEntry); +HDF_INIT(g_sdiodriverentry); diff --git a/platform/spi/Makefile b/platform/spi/Makefile index d049969..3574fa4 100644 --- a/platform/spi/Makefile +++ b/platform/spi/Makefile @@ -16,5 +16,5 @@ include drivers/hdf/khdf/platform/platform.mk obj-y += $(HDF_PLATFORM_FRAMEWORKS_ROOT)/src/spi_core.o \ $(HDF_PLATFORM_FRAMEWORKS_ROOT)/src/spi_if.o \ - hi35xx_spi_adapter.o + spi_adapter.o diff --git a/platform/watchdog/watchdog_adapter.c b/platform/watchdog/watchdog_adapter.c index 309a4d1..055a4ab 100644 --- a/platform/watchdog/watchdog_adapter.c +++ b/platform/watchdog/watchdog_adapter.c @@ -146,9 +146,9 @@ static struct watchdog_device *WdtCoreDataToWdd(void *wdCoreData) * struct watchdog_device *wdd; * ... * } - */ + */ struct WdtCoreDataHead { -#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,14,182) +#if LINUX_VERSION_CODE >= KERNEL_VERSION(5,6,0) struct device dev; #else struct kref kref; -- Gitee From 287582e0b6561f2572743dc372b1646a595678ea Mon Sep 17 00:00:00 2001 From: zhaoxc0502 Date: Tue, 28 Dec 2021 10:57:34 +0800 Subject: [PATCH 2/2] merge imx8mm content Signed-off-by: zhaoxc0502 --- platform/spi/{hi35xx_spi_adapter.c => spi_adapter.c} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename platform/spi/{hi35xx_spi_adapter.c => spi_adapter.c} (100%) diff --git a/platform/spi/hi35xx_spi_adapter.c b/platform/spi/spi_adapter.c similarity index 100% rename from platform/spi/hi35xx_spi_adapter.c rename to platform/spi/spi_adapter.c -- Gitee