sync l2weekly to l1

This commit is contained in:
NickYang
2021-05-19 19:52:53 +08:00
parent b08ddeff7c
commit 42cc2dd44f
12 changed files with 79 additions and 78 deletions
+22 -20
View File
@@ -6,16 +6,17 @@
* See the LICENSE file in the root of this repository for complete details.
*/
#include "dmac_core.h"
#include <string.h>
#include "hdf_log.h"
#include "osal_io.h"
#include "osal_irq.h"
#include "osal_mem.h"
#include "dmac_core.h"
#define HDF_LOG_TAG dmac_core
#define DMA_ALIGN_SIZE 256
#define DMA_MAX_TRANS_SIZE_DEFAULT 256
static int DmacCheck(struct DmaCntlr *cntlr)
{
@@ -66,7 +67,7 @@ static void DmacFreeLli(struct DmacChanInfo *chanInfo)
*/
void DmaCntlrDestroy(struct DmaCntlr *cntlr)
{
int i;
unsigned int i;
if (cntlr == NULL || cntlr->channelNum > DMAC_CHAN_NUM_MAX) {
HDF_LOGE("%s: cntlr null or channel invalid!", __func__);
@@ -107,7 +108,7 @@ static void DmacCallbackHandle(struct DmacChanInfo *chanInfo)
static int DmacWaitM2mSendComplete(struct DmaCntlr *cntlr, struct DmacChanInfo *chanInfo)
{
unsigned int ret;
uint32_t ret;
if (DmacCheck(cntlr) != HDF_SUCCESS) {
HDF_LOGE("check fail");
@@ -130,7 +131,7 @@ static int DmacWaitM2mSendComplete(struct DmaCntlr *cntlr, struct DmacChanInfo *
static int DmacAllocateChannel(struct DmaCntlr *cntlr)
{
unsigned int flags;
uint32_t flags;
int i;
if (DmacCheck(cntlr) != HDF_SUCCESS) {
@@ -190,7 +191,7 @@ static struct DmacChanInfo *DmacRequestChannel(struct DmaCntlr *cntlr,
HDF_LOGE("%s: get channel fail ret = %d", __func__, ret);
return NULL;
}
HDF_LOGD("channel = %d, transfer type = %d width = %u, config = 0x%x, lliflag = 0x%x",
HDF_LOGD("channel = %d, transfer type = %u width = %u, config = 0x%x, lliflag = 0x%x",
ret, chanInfo->transferType, chanInfo->width, chanInfo->config, chanInfo->lliEnFlag);
return chanInfo;
}
@@ -220,19 +221,13 @@ static int DmacFillLli(struct DmaCntlr *cntlr, struct DmacChanInfo *chanInfo,
plli->count = cntlr->maxTransSize;
} else {
plli->nextLli = 0;
plli->count = (length % cntlr->maxTransSize);
plli->count = cntlr->maxTransSize == 0 ? length : (length % cntlr->maxTransSize);
}
plli->srcAddr = (long long)srcaddr;
plli->destAddr = (long long)dstaddr;
plli->config = chanInfo->config;
HDF_LOGD("plli->srcAddr = 0x%llx\n", plli->srcAddr);
HDF_LOGD("plli->destAddr = 0x%llx\n", plli->destAddr);
HDF_LOGD("plli->nextLli = 0x%llx\n", plli->nextLli);
HDF_LOGD("plli->config = 0x%x\n", plli->config);
HDF_LOGD("plli->count = 0x%x\n", plli->count);
if (chanInfo->transferType == TRASFER_TYPE_P2M) {
dstaddr += plli->count;
} else if (chanInfo->transferType == TRASFER_TYPE_M2P) {
@@ -240,6 +235,7 @@ static int DmacFillLli(struct DmaCntlr *cntlr, struct DmacChanInfo *chanInfo,
}
plli++;
}
plli = chanInfo->lli;
cntlr->dmacCacheFlush((UINTPTR)plli, (UINTPTR)plli + (UINTPTR)(sizeof(struct DmacLli) * lliNum));
HDF_LOGD("alloc_addr = 0x%x, alloc_addr + (sizeof(DmacLli) * lli_num)= 0x%x\n",
(UINTPTR)plli, (UINTPTR)plli + (UINTPTR)(sizeof(struct DmacLli) * lliNum));
@@ -369,6 +365,7 @@ static int DmacM2mTransfer(struct DmaCntlr *cntlr, struct DmacMsg *msg)
return HDF_FAILURE;
}
if (dmaSize == 0) {
DmacFreeChannel(cntlr, chanInfo->channel);
return HDF_FAILURE;
}
leftSize -= dmaSize;
@@ -403,7 +400,7 @@ int32_t DmaCntlrTransfer(struct DmaCntlr *cntlr, struct DmacMsg *msg)
} else if (msg->direct == TRASFER_TYPE_M2M) {
return DmacM2mTransfer(cntlr, msg);
} else {
HDF_LOGE("%s: invalid direct %d", __func__, msg->direct);
HDF_LOGE("%s: invalid direct %u", __func__, msg->direct);
return HDF_FAILURE;
}
return DmacPeriphTransfer(cntlr, msg, periphAddr);
@@ -419,7 +416,7 @@ unsigned int DmaGetCurrChanDestAddr(struct DmaCntlr *cntlr, unsigned int chan)
return cntlr->dmacGetCurrDestAddr(cntlr, chan);
}
static uint32_t DmacIsr(int irq, void *dev)
static uint32_t DmacIsr(uint32_t irq, void *dev)
{
struct DmaCntlr *cntlr = (struct DmaCntlr *)dev;
unsigned int channelStatus;
@@ -431,9 +428,9 @@ static uint32_t DmacIsr(int irq, void *dev)
}
if (irq != cntlr->irq || cntlr->channelNum > DMAC_CHAN_NUM_MAX) {
HDF_LOGE("%s: cntlr parm err! irq:%d, channel:%u",
HDF_LOGE("%s: cntlr param err! irq:%u, channel:%u",
__func__, cntlr->irq, cntlr->channelNum);
return HDF_SUCCESS;
return HDF_ERR_INVALID_PARAM;
}
for (i = 0; i < cntlr->channelNum; i++) {
channelStatus = cntlr->dmacGetChanStatus(cntlr, i);
@@ -455,15 +452,19 @@ int DmacInit(struct DmaCntlr *cntlr)
HDF_LOGE("check fail");
return HDF_FAILURE;
}
if (cntlr->channelNum > DMAC_CHAN_NUM_MAX) {
HDF_LOGE("%s: invalid channel:%d", __func__, cntlr->channelNum);
if (cntlr->channelNum == 0 || cntlr->channelNum > DMAC_CHAN_NUM_MAX) {
HDF_LOGE("%s: invalid channel:%u", __func__, cntlr->channelNum);
return HDF_FAILURE;
}
if (cntlr->maxTransSize == 0) {
cntlr->maxTransSize = DMA_MAX_TRANS_SIZE_DEFAULT;
}
cntlr->remapBase = (char *)OsalIoRemap((unsigned long)cntlr->phyBase, (unsigned long)cntlr->regSize);
OsalSpinInit(&cntlr->lock);
(void)OsalSpinInit(&cntlr->lock);
cntlr->channelList = (struct DmacChanInfo *)OsalMemCalloc(sizeof(struct DmacChanInfo) * cntlr->channelNum);
if (cntlr->channelList == NULL) {
HDF_LOGE("channel list malloc fail");
(void)OsalSpinDestroy(&cntlr->lock);
OsalIoUnmap((void *)cntlr->remapBase);
return HDF_FAILURE;
}
@@ -474,9 +475,10 @@ int DmacInit(struct DmaCntlr *cntlr)
}
ret = OsalRegisterIrq(cntlr->irq, 0, (OsalIRQHandle)DmacIsr, "PlatDmac", cntlr);
if (ret != HDF_SUCCESS) {
HDF_LOGE("DMA Irq %d request failed, ret = %d\n", cntlr->irq, ret);
HDF_LOGE("DMA Irq %u request failed, ret = %d\n", cntlr->irq, ret);
OsalMemFree(cntlr->channelList);
cntlr->channelList = NULL;
(void)OsalSpinDestroy(&cntlr->lock);
OsalIoUnmap((void *)cntlr->remapBase);
}
return ret;
+17 -17
View File
@@ -6,8 +6,8 @@
* See the LICENSE file in the root of this repository for complete details.
*/
#include "device_resource_if.h"
#include "emmc_core.h"
#include "device_resource_if.h"
#include "hdf_log.h"
#include "osal_mem.h"
@@ -16,11 +16,11 @@
int32_t EmmcCntlrFindHost(struct EmmcCntlr *cntlr)
{
if (cntlr == NULL || cntlr->method == NULL || cntlr->method->findHost == NULL) {
HDF_LOGE("EmmcCntlrFindHost: cntlr or method or findHost is NULL!");
HDF_LOGE("EmmcCntlrFindHost: cntlr or method or findHost is null!");
return HDF_ERR_INVALID_PARAM;
}
if (cntlr->method->findHost(cntlr, &(cntlr->configData)) != HDF_SUCCESS) {
HDF_LOGE("EmmcCntlrFindHost: findHost fail!");
HDF_LOGE("EmmcCntlrFindHost: findHost failed");
return HDF_ERR_INVALID_OBJECT;
}
return HDF_SUCCESS;
@@ -42,8 +42,8 @@ int32_t EmmcCntlrGetCid(struct EmmcCntlr *cntlr, uint8_t *cid, uint32_t size)
static int32_t EmmcGetCidWriteBackReply(struct HdfSBuf *reply, uint8_t *cid, uint32_t size)
{
if (HdfSbufWriteBuffer(reply, cid, size) == false) {
HDF_LOGE("EmmcGetCidWriteBackReply: write to reply fail!");
if (!HdfSbufWriteBuffer(reply, cid, size)) {
HDF_LOGE("EmmcGetCidWriteBackReply: write to reply failed");
return HDF_ERR_IO;
}
return HDF_SUCCESS;
@@ -56,7 +56,7 @@ static int32_t EmmcGetCidDispatch(struct EmmcCntlr *cntlr, struct HdfSBuf *reply
ret = EmmcCntlrGetCid(cntlr, cid, EMMC_CID_LEN);
if (ret != HDF_SUCCESS) {
HDF_LOGE("EmmcGetCidDispatch: EmmcCntlrGetCid fail!");
HDF_LOGE("EmmcGetCidDispatch: EmmcCntlrGetCid failed");
return ret;
}
return EmmcGetCidWriteBackReply(reply, cid, EMMC_CID_LEN);
@@ -69,23 +69,23 @@ static int32_t EmmcIoDispatch(struct HdfDeviceIoClient *client, int cmd, struct
(void)data;
if (client == NULL || client->device == NULL) {
HDF_LOGE("EmmcIoDispatch: client or client->device is NULL");
HDF_LOGE("EmmcIoDispatch: client or client->device is null");
return HDF_ERR_INVALID_OBJECT;
}
if (reply == NULL) {
HDF_LOGE("EmmcIoDispatch: reply is NULL");
HDF_LOGE("EmmcIoDispatch: reply is null");
return HDF_ERR_INVALID_PARAM;
}
cntlr = (struct EmmcCntlr *)client->device->service;
if (cntlr == NULL) {
HDF_LOGE("EmmcIoDispatch: service is NULL");
HDF_LOGE("EmmcIoDispatch: service is null");
return HDF_ERR_INVALID_OBJECT;
}
if (cntlr->priv == NULL) {
if (EmmcCntlrFindHost(cntlr) != HDF_SUCCESS) {
HDF_LOGE("EmmcIoDispatch: find host fail!");
HDF_LOGE("EmmcIoDispatch: find host failed");
return HDF_ERR_INVALID_OBJECT;
}
}
@@ -107,13 +107,13 @@ struct EmmcCntlr *EmmcCntlrCreateAndBind(struct HdfDeviceObject *device)
struct EmmcCntlr *cntlr = NULL;
if (device == NULL) {
HDF_LOGE("EmmcCntlrCreateAndBind: device is NULL!");
HDF_LOGE("EmmcCntlrCreateAndBind: device is null!");
return NULL;
}
cntlr = (struct EmmcCntlr *)OsalMemCalloc(sizeof(*cntlr));
if (cntlr == NULL) {
HDF_LOGE("EmmcCntlrCreateAndBind: malloc host fail!");
HDF_LOGE("EmmcCntlrCreateAndBind: malloc host failed");
return NULL;
}
cntlr->device = device;
@@ -139,27 +139,27 @@ int32_t EmmcFillConfigData(struct HdfDeviceObject *device, struct EmmcConfigData
int32_t ret;
if (device == NULL || configData == NULL) {
HDF_LOGE("EmmcFillConfigData: input para is NULL.");
HDF_LOGE("EmmcFillConfigData: input para is null.");
return HDF_FAILURE;
}
node = device->property;
if (node == NULL) {
HDF_LOGE("EmmcFillConfigData: drs node is NULL.");
HDF_LOGE("EmmcFillConfigData: drs node is null.");
return HDF_FAILURE;
}
drsOps = DeviceResourceGetIfaceInstance(HDF_CONFIG_SOURCE);
if (drsOps == NULL || drsOps->GetUint32 == NULL) {
HDF_LOGE("EmmcFillConfigData: invalid drs ops fail!");
HDF_LOGE("EmmcFillConfigData: invalid drs ops failed");
return HDF_FAILURE;
}
ret = drsOps->GetUint32(node, "hostId", &(configData->hostId), 0);
if (ret != HDF_SUCCESS) {
HDF_LOGE("EmmcFillConfigData: read funcNum fail!");
HDF_LOGE("EmmcFillConfigData: read funcNum failed");
return ret;
}
HDF_LOGD("EmmcFillConfigData: Success! hostId = %d.", configData->hostId);
HDF_LOGD("EmmcFillConfigData: Success! hostId = %u.", configData->hostId);
return HDF_SUCCESS;
}
+7 -13
View File
@@ -6,12 +6,12 @@
* See the LICENSE file in the root of this repository for complete details.
*/
#include "emmc_if.h"
#include <securec.h>
#ifndef __USER__
#include "devsvc_manager_clnt.h"
#include "emmc_core.h"
#endif
#include "emmc_if.h"
#include "hdf_base.h"
#ifdef __USER__
#include "hdf_io_service_if.h"
@@ -96,16 +96,10 @@ static int32_t EmmcGetCidReadReplyData(struct HdfSBuf *reply, uint8_t *cid, uint
uint32_t rLen;
const void *rBuf = NULL;
if (HdfSbufReadBuffer(reply, &rBuf, &rLen) == false) {
if (!HdfSbufReadBuffer(reply, &rBuf, &rLen)) {
HDF_LOGE("EmmcGetCidReadReplyData: read rBuf fail!");
return HDF_ERR_IO;
}
if (size != rLen) {
HDF_LOGE("EmmcGetCidReadReplyData: err len:%u, rLen:%u", size, rLen);
if (rLen > size) {
rLen = size;
}
}
if (memcpy_s(cid, size, rBuf, rLen) != EOK) {
HDF_LOGE("EmmcGetCidReadReplyData: memcpy rBuf fail!");
@@ -115,7 +109,7 @@ static int32_t EmmcGetCidReadReplyData(struct HdfSBuf *reply, uint8_t *cid, uint
return HDF_SUCCESS;
}
int32_t EmmcServiceGetCid(struct HdfIoService *service, uint8_t *cid, uint32_t size)
static int32_t EmmcServiceGetCid(struct HdfIoService *service, uint8_t *cid, uint32_t size)
{
int32_t ret;
struct HdfSBuf *reply = NULL;
@@ -161,7 +155,7 @@ int32_t EmmcGetCid(DevHandle handle, uint8_t *cid, uint32_t size)
}
if (cid == NULL || size < EMMC_CID_LEN) {
HDF_LOGE("EmmcGetCid: error parms!");
HDF_LOGE("EmmcGetCid: error params!");
return HDF_ERR_INVALID_PARAM;
}
#ifdef __USER__
@@ -176,7 +170,7 @@ void EmmcGetHuid(uint8_t *cid, uint32_t size)
DevHandle handle = NULL;
if (cid == NULL || size == 0) {
HDF_LOGE("EmmcGetUdid: error parms!");
HDF_LOGE("EmmcGetUdid: error params!");
return;
}
if (memset_s(cid, sizeof(uint8_t) * size, 0, sizeof(uint8_t) * size) != EOK) {
@@ -186,11 +180,11 @@ void EmmcGetHuid(uint8_t *cid, uint32_t size)
handle = EmmcOpen(0);
if (handle == NULL) {
HDF_LOGD("EmmcGetUdid: open fail, use default value!");
HDF_LOGW("EmmcGetUdid: open fail, use default value!");
return;
}
if (EmmcGetCid(handle, cid, size) != HDF_SUCCESS) {
HDF_LOGD("EmmcGetUdid: get fail, use default value!");
HDF_LOGW("EmmcGetUdid: get fail, use default value!");
}
EmmcClose(handle);
}
+1 -1
View File
@@ -267,7 +267,7 @@ int32_t I2cTransfer(DevHandle handle, struct I2cMsg *msgs, int16_t count)
}
if (msgs == NULL || count <= 0) {
HDF_LOGE("I2cTransfer: err parms! msgs:%s, count:%d",
HDF_LOGE("I2cTransfer: err params! msgs:%s, count:%d",
(msgs == NULL) ? "0" : "x", count);
return HDF_ERR_INVALID_PARAM;
}
+14 -11
View File
@@ -6,10 +6,10 @@
* See the LICENSE file in the root of this repository for complete details.
*/
#include "osal_time.h"
#include "osal_mem.h"
#include "hdf_log.h"
#include "mipi_dsi_core.h"
#include "hdf_log.h"
#include "osal_mem.h"
#include "osal_time.h"
#define HDF_LOG_TAG mipi_dsi_core
@@ -36,21 +36,21 @@ int32_t MipiDsiRegisterCntlr(struct MipiDsiCntlr *cntlr)
return HDF_FAILURE;
}
DevHandle MipiDsiOpen(uint8_t id)
DevHandle MipiDsiOpen(uint8_t number)
{
if (id >= MAX_CNTLR_CNT) {
HDF_LOGE("id invalid");
if (number >= MAX_CNTLR_CNT) {
HDF_LOGE("invalid number");
return NULL;
}
if (g_mipiDsihandle[id].cntlr == NULL) {
HDF_LOGE("no mipi_dsi %d cntlr", id);
if (g_mipiDsihandle[number].cntlr == NULL) {
HDF_LOGE("no mipi_dsi %d cntlr", number);
return NULL;
}
if (OsalMutexLock(&(g_mipiDsihandle[id].lock)) != HDF_SUCCESS) {
if (OsalMutexLock(&(g_mipiDsihandle[number].lock)) != HDF_SUCCESS) {
HDF_LOGE("mutex lock fail");
return NULL;
}
return (DevHandle)(&(g_mipiDsihandle[id]));
return (DevHandle)(&(g_mipiDsihandle[number]));
}
void MipiDsiClose(DevHandle handle)
@@ -64,7 +64,7 @@ void MipiDsiClose(DevHandle handle)
static int32_t MipiDsiSetDevCfg(struct MipiDsiCntlr *cntlr)
{
/* set controler config */
/* set controller config */
if (cntlr->setCntlrCfg == NULL) {
HDF_LOGE("setCntlrCfg is NULL");
return HDF_FAILURE;
@@ -137,6 +137,7 @@ void MipiDsiSetLpMode(DevHandle handle)
HDF_LOGI("toLp not support!");
}
}
void MipiDsiSetHsMode(DevHandle handle)
{
struct MipiDsiCntlr *cntlr = NULL;
@@ -151,6 +152,7 @@ void MipiDsiSetHsMode(DevHandle handle)
HDF_LOGI("toHs not support!");
}
}
void MipiDsiEnterUlps(DevHandle handle)
{
struct MipiDsiCntlr *cntlr = NULL;
@@ -165,6 +167,7 @@ void MipiDsiEnterUlps(DevHandle handle)
HDF_LOGI("enterUlps not support!");
}
}
void MipiDsiExitUlps(DevHandle handle)
{
struct MipiDsiCntlr *cntlr = NULL;
+2 -2
View File
@@ -6,9 +6,9 @@
* See the LICENSE file in the root of this repository for complete details.
*/
#include "rtc_base.h"
#include "hdf_log.h"
#include "plat_log.h"
#include "rtc_base.h"
#define HDF_LOG_TAG rtc_base
@@ -21,7 +21,7 @@ uint8_t RtcGetMonthDays(const uint8_t isLeapYear, const uint8_t month)
return 0;
}
if (RTC_FEBRUARY == month) {
if (month == RTC_FEBRUARY) {
days = RTC_TWO_MONTH_DAY + isLeapYear;
} else {
oddMonth = (month >= RTC_AUGUST) ? (month - RTC_UNIT_DIFF) : month;
+1 -1
View File
@@ -6,9 +6,9 @@
* See the LICENSE file in the root of this repository for complete details.
*/
#include "rtc_core.h"
#include "hdf_log.h"
#include "osal_mem.h"
#include "rtc_core.h"
#define HDF_LOG_TAG rtc_core
+2 -2
View File
@@ -6,13 +6,13 @@
* See the LICENSE file in the root of this repository for complete details.
*/
#include "rtc_if.h"
#include "devsvc_manager_clnt.h"
#include "hdf_base.h"
#include "hdf_log.h"
#include "devsvc_manager_clnt.h"
#include "osal_mem.h"
#include "rtc_base.h"
#include "rtc_core.h"
#include "rtc_if.h"
#define HDF_LOG_TAG rtc_if
+1 -1
View File
@@ -6,10 +6,10 @@
* See the LICENSE file in the root of this repository for complete details.
*/
#include "sdio_core.h"
#include "device_resource_if.h"
#include "osal_mem.h"
#include "plat_log.h"
#include "sdio_core.h"
#define HDF_LOG_TAG sdio_core
+10 -8
View File
@@ -6,12 +6,12 @@
* See the LICENSE file in the root of this repository for complete details.
*/
#include "securec.h"
#include "spi_if.h"
#include "devsvc_manager_clnt.h"
#include "hdf_log.h"
#include "osal_mem.h"
#include "securec.h"
#include "spi_core.h"
#include "spi_if.h"
#define HDF_LOG_TAG spi_if
#define HOST_NAME_LEN 32
@@ -128,17 +128,19 @@ DevHandle SpiOpen(const struct SpiDevInfo *info)
return NULL;
}
ret = SpiCntlrOpen(cntlr, info->csNum);
if (ret != HDF_SUCCESS) {
HDF_LOGE("%s: SpiCntlrOpen error, ret is %d", __func__, ret);
return NULL;
}
object = (struct SpiObject *)OsalMemCalloc(sizeof(*object));
if (object == NULL) {
HDF_LOGE("%s: object malloc error", __func__);
return NULL;
}
ret = SpiCntlrOpen(cntlr, info->csNum);
if (ret != HDF_SUCCESS) {
HDF_LOGE("%s: SpiCntlrOpen error, ret is %d", __func__, ret);
OsalMemFree(object);
return NULL;
}
object->cntlr = cntlr;
object->csNum = info->csNum;
return (DevHandle)object;
+1 -1
View File
@@ -154,7 +154,7 @@ static int32_t UartUserSetTransMode(struct UartHost *host, struct HdfSBuf *data)
size_t size;
enum UartTransMode *mode = NULL;
if (!HdfSbufReadBuffer(data, (const void **)&mode, &size)) {
if (!HdfSbufReadBuffer(data, (const void **)&mode, &size) || mode == NULL) {
HDF_LOGE("%s: sbuf read buffer failed", __func__);
return HDF_ERR_IO;
}
+1 -1
View File
@@ -6,6 +6,7 @@
* See the LICENSE file in the root of this repository for complete details.
*/
#include "uart_if.h"
#include "securec.h"
#ifndef __USER__
#include "devsvc_manager_clnt.h"
@@ -17,7 +18,6 @@
#ifndef __USER__
#include "uart_core.h"
#endif
#include "uart_if.h"
#define HDF_LOG_TAG uart_if_c
#define UART_HOST_NAME_LEN 32