summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMahesh Radhakrishnan2019-09-26 09:18:37 -0500
committerMahesh Radhakrishnan2019-10-01 11:29:53 -0500
commit427a910bdb2b2c192de64d8d892da2a7d569b46c (patch)
treecd15bdccc0f3f17b3f06e9da17a4de939821b12f
parent3baef1492ef4dbf8ad2f7afbbad2352bca8a751e (diff)
downloadmcasp-lld-427a910bdb2b2c192de64d8d892da2a7d569b46c.tar.gz
mcasp-lld-427a910bdb2b2c192de64d8d892da2a7d569b46c.tar.xz
mcasp-lld-427a910bdb2b2c192de64d8d892da2a7d569b46c.zip
-rw-r--r--include/McaspLocal.h16
-rw-r--r--mcasp_drv.h1
-rw-r--r--src/dma/V0/mcasp_dma.c10
-rwxr-xr-xsrc/dma/V1/mcasp_dma.c74
-rwxr-xr-xsrc/mcasp_drv.c744
-rw-r--r--src/mcasp_ioctl.c179
6 files changed, 616 insertions, 408 deletions
diff --git a/include/McaspLocal.h b/include/McaspLocal.h
index a7df5b1..8093f1c 100644
--- a/include/McaspLocal.h
+++ b/include/McaspLocal.h
@@ -1008,9 +1008,9 @@ extern int32_t Mcasp_localConfigRcvSection(Mcasp_Object *instHandle,
1008extern int32_t Mcasp_localConfigXmtSection(Mcasp_Object *instHandle, 1008extern int32_t Mcasp_localConfigXmtSection(Mcasp_Object *instHandle,
1009 Mcasp_HwSetupData *const xmtData); 1009 Mcasp_HwSetupData *const xmtData);
1010 1010
1011extern void Mcasp_localSmReset(Mcasp_ChannelHandle chanHandle); 1011extern int32_t Mcasp_localSmReset(Mcasp_ChannelHandle chanHandle);
1012 1012
1013extern void Mcasp_localSmSet(Mcasp_ChannelHandle chanHandle); 1013extern int32_t Mcasp_localSmSet(Mcasp_ChannelHandle chanHandle);
1014 1014
1015extern int32_t Mcasp_localAbortReset(Mcasp_ChannelHandle chanHandle); 1015extern int32_t Mcasp_localAbortReset(Mcasp_ChannelHandle chanHandle);
1016 1016
@@ -1024,18 +1024,18 @@ extern int32_t Mcasp_localDmaProcessPkt(void *chanp, MCASP_Packet *ioPacket);
1024 1024
1025extern int32_t Mcasp_localCancelAndAbortAllIo(Mcasp_ChannelHandle chanHandle); 1025extern int32_t Mcasp_localCancelAndAbortAllIo(Mcasp_ChannelHandle chanHandle);
1026 1026
1027extern void Mcasp_localSetupHwInfo(Mcasp_HwHandle hMcasp, 1027extern int32_t Mcasp_localSetupHwInfo(Mcasp_HwHandle hMcasp,
1028 const Mcasp_HwSetup *myHwSetup); 1028 const Mcasp_HwSetup *myHwSetup);
1029 1029
1030extern void Mcasp_localActivateSmFsForBoth(const Mcasp_Object *instHandle); 1030extern int32_t Mcasp_localActivateSmFsForBoth(const Mcasp_Object *instHandle);
1031 1031
1032extern void Mcasp_localActivateSmFsForXmt(const Mcasp_Object *instHandle); 1032extern int32_t Mcasp_localActivateSmFsForXmt(const Mcasp_Object *instHandle);
1033 1033
1034extern void Mcasp_localActivateSmFsForRcv(const Mcasp_Object *instHandle); 1034extern int32_t Mcasp_localActivateSmFsForRcv(const Mcasp_Object *instHandle);
1035 1035
1036extern void Mcasp_localDeactivateSmFsForXmt(const Mcasp_Object *instHandle); 1036extern int32_t Mcasp_localDeactivateSmFsForXmt(const Mcasp_Object *instHandle);
1037 1037
1038extern void Mcasp_localDeactivateSmFsForRcv(const Mcasp_Object *instHandle); 1038extern int32_t Mcasp_localDeactivateSmFsForRcv(const Mcasp_Object *instHandle);
1039 1039
1040 1040
1041extern int32_t Mcasp_localSubmitIoctl(Mcasp_ChannelHandle chanHandle, 1041extern int32_t Mcasp_localSubmitIoctl(Mcasp_ChannelHandle chanHandle,
diff --git a/mcasp_drv.h b/mcasp_drv.h
index 0094ee2..d9b2f40 100644
--- a/mcasp_drv.h
+++ b/mcasp_drv.h
@@ -124,6 +124,7 @@ extern "C" {
124#define MCASP_EBADARGS (-(10)) /* Illegal arguments specified */ 124#define MCASP_EBADARGS (-(10)) /* Illegal arguments specified */
125#define MCASP_ETIMEOUTUNREC (-(11)) /* Unrecoverable timeout occurred */ 125#define MCASP_ETIMEOUTUNREC (-(11)) /* Unrecoverable timeout occurred */
126#define MCASP_EINUSE (-(12)) /* Device already in use */ 126#define MCASP_EINUSE (-(12)) /* Device already in use */
127#define MCASP_EINVALIDVAL (-(13)) /* Invalid value encountered (Unexpected) */
127#define MCASP_COMPLETED (0) /* I/O completed successfully */ 128#define MCASP_COMPLETED (0) /* I/O completed successfully */
128#define MCASP_PENDING (1) /* I/O queued and pending */ 129#define MCASP_PENDING (1) /* I/O queued and pending */
129 130
diff --git a/src/dma/V0/mcasp_dma.c b/src/dma/V0/mcasp_dma.c
index 11403f8..61c1f5a 100644
--- a/src/dma/V0/mcasp_dma.c
+++ b/src/dma/V0/mcasp_dma.c
@@ -1388,9 +1388,10 @@ int32_t Mcasp_localGetIndicesSyncType(Mcasp_ChannelHandle chanHandle,
1388 Uint16 temp_var = 0x0U; 1388 Uint16 temp_var = 0x0U;
1389 Uint16 aCntByBCnt = 0x0U; 1389 Uint16 aCntByBCnt = 0x0U;
1390 1390
1391 assert(((NULL != chanHandle) && (NULL != bIndex) && (NULL != cIndex) 1391 if(((NULL != chanHandle) && (NULL != bIndex) && (NULL != cIndex)
1392 && (NULL != aCnt) && (NULL != bCnt) && (NULL != cCnt) 1392 && (NULL != aCnt) && (NULL != bCnt) && (NULL != cCnt)
1393 && (NULL != syncType))); 1393 && (NULL != syncType)))
1394 {
1394 1395
1395 1396
1396#ifdef Mcasp_LOOPJOB_ENABLED 1397#ifdef Mcasp_LOOPJOB_ENABLED
@@ -1531,6 +1532,11 @@ int32_t Mcasp_localGetIndicesSyncType(Mcasp_ChannelHandle chanHandle,
1531 *cIndex = 0; 1532 *cIndex = 0;
1532 } 1533 }
1533 } 1534 }
1535 }
1536 else
1537 {
1538 status = MCASP_EBADARGS;
1539 }
1534 return status; 1540 return status;
1535} 1541}
1536 1542
diff --git a/src/dma/V1/mcasp_dma.c b/src/dma/V1/mcasp_dma.c
index 15f6f79..243ce2e 100755
--- a/src/dma/V1/mcasp_dma.c
+++ b/src/dma/V1/mcasp_dma.c
@@ -127,8 +127,8 @@ static void Mcasp_udmaTrpdInit(Mcasp_ChannelHandle handle,
127 uint32_t cqRingNum = Udma_chGetCqRingNum(chHandle); 127 uint32_t cqRingNum = Udma_chGetCqRingNum(chHandle);
128 uint32_t descType = CSL_UDMAP_CPPI5_PD_DESCINFO_DTYPE_VAL_TR; 128 uint32_t descType = CSL_UDMAP_CPPI5_PD_DESCINFO_DTYPE_VAL_TR;
129 129
130 uint32_t trType=15; /* TR15 by default */ 130 uint32_t trType=NAVSS_TRTYPE_TR15; /* TR15 by default */
131 uint64_t hostAddr = (uint64_t)bufPtr; 131 uint64_t hostAddr;
132 uint32_t trpdLength = 16; 132 uint32_t trpdLength = 16;
133 uint32_t aCnt=0; 133 uint32_t aCnt=0;
134 uint32_t bCnt=0; 134 uint32_t bCnt=0;
@@ -141,19 +141,16 @@ static void Mcasp_udmaTrpdInit(Mcasp_ChannelHandle handle,
141 trParams = (NAVSS_TR_Params *)&(chanHandle->trParams); 141 trParams = (NAVSS_TR_Params *)&(chanHandle->trParams);
142 142
143 143
144 if(trParams) 144 aCnt=trParams->hostMemTransferParams.aCnt;
145 { 145 bCnt=trParams->hostMemTransferParams.bCnt;
146 aCnt=trParams->hostMemTransferParams.aCnt; 146 cCnt=trParams->hostMemTransferParams.cCnt;
147 bCnt=trParams->hostMemTransferParams.bCnt;
148 cCnt=trParams->hostMemTransferParams.cCnt;
149 147
150 bIndex=trParams->hostMemTransferParams.bIndex; 148 bIndex=trParams->hostMemTransferParams.bIndex;
151 cIndex=trParams->hostMemTransferParams.cIndex; 149 cIndex=trParams->hostMemTransferParams.cIndex;
152 150
153 hostAddr = (uint64_t)trParams->hostMemTransferParams.hostAddr; 151 hostAddr = (uint64_t)trParams->hostMemTransferParams.hostAddr;
154 152
155 trType=trParams->type; 153 trType=trParams->type;
156 }
157 /* Setup descriptor */ 154 /* Setup descriptor */
158 CSL_udmapCppi5SetDescType(pTrpd, descType); 155 CSL_udmapCppi5SetDescType(pTrpd, descType);
159 CSL_udmapCppi5TrSetReload(pTrpd, 0U, 0U); 156 CSL_udmapCppi5TrSetReload(pTrpd, 0U, 0U);
@@ -375,7 +372,6 @@ int32_t Mcasp_submitUdmaPkt(Mcasp_ChannelHandle chanHandle)
375 Udma_ChHandle udmaChanHandle; 372 Udma_ChHandle udmaChanHandle;
376 Mcasp_Object *instHandle; 373 Mcasp_Object *instHandle;
377 MCASP_Packet *ioPacket; 374 MCASP_Packet *ioPacket;
378 int32_t retval=UDMA_SOK;
379 Mcasp_dmaInfo_t *pDmaInfo; 375 Mcasp_dmaInfo_t *pDmaInfo;
380 uint8_t *pHpdMem; 376 uint8_t *pHpdMem;
381 void *buffer; 377 void *buffer;
@@ -422,7 +418,7 @@ int32_t Mcasp_submitUdmaPkt(Mcasp_ChannelHandle chanHandle)
422 MCASP_DEBUG_ERR_TRAP 418 MCASP_DEBUG_ERR_TRAP
423 } 419 }
424 420
425 return (retval); 421 return (retVal);
426} 422}
427 423
428/* ========================================================================== */ 424/* ========================================================================== */
@@ -826,16 +822,12 @@ int32_t Mcasp_setupDmaDuringOpen(Mcasp_ChannelHandle chan_handle, Mcasp_HwObj *h
826 */ 822 */
827int32_t Mcasp_setupDmaChan(Mcasp_ChannelHandle chanHandle) 823int32_t Mcasp_setupDmaChan(Mcasp_ChannelHandle chanHandle)
828{ 824{
829 Mcasp_Object *instHandle = NULL;
830 int32_t status = MCASP_COMPLETED; 825 int32_t status = MCASP_COMPLETED;
831 826
832 assert((NULL != chanHandle) && (NULL != chanHandle->devHandle)); 827 if(!((NULL != chanHandle) && (NULL != chanHandle->devHandle)))
833 828 {
834 829 status = MCASP_EBADARGS;
835 instHandle = (Mcasp_Object *)chanHandle->devHandle; 830 }
836
837 assert(NULL != instHandle);
838
839 return status; 831 return status;
840} 832}
841 833
@@ -867,7 +859,7 @@ int32_t Mcasp_submitPktToDma(Mcasp_ChannelHandle chanHandle,
867 uint32_t trType=0; 859 uint32_t trType=0;
868 int16_t bIndex=0, cIndex=0; 860 int16_t bIndex=0, cIndex=0;
869 uintptr_t host_addr=(uintptr_t)NULL; /* HOst memory address */ 861 uintptr_t host_addr=(uintptr_t)NULL; /* HOst memory address */
870 if (NULL == ioPacket) 862 if ( (NULL == ioPacket) || (NULL == chanHandle) || (NULL == chanHandle->devHandle) )
871 { 863 {
872 status = MCASP_EBADARGS; 864 status = MCASP_EBADARGS;
873 } 865 }
@@ -877,11 +869,8 @@ int32_t Mcasp_submitPktToDma(Mcasp_ChannelHandle chanHandle,
877 { 869 {
878 falsewhile = FALSE; 870 falsewhile = FALSE;
879 871
880 assert((NULL != chanHandle) && (NULL != chanHandle->devHandle));
881
882 instHandle = (Mcasp_Object *)chanHandle->devHandle; 872 instHandle = (Mcasp_Object *)chanHandle->devHandle;
883 873
884 assert(NULL != instHandle);
885 874
886 /* if at all this is the first packet we will update the main params * 875 /* if at all this is the first packet we will update the main params *
887 * else we will update the link params */ 876 * else we will update the link params */
@@ -900,8 +889,9 @@ int32_t Mcasp_submitPktToDma(Mcasp_ChannelHandle chanHandle,
900 if (TRUE == instHandle->isDataBufferPayloadStructure) 889 if (TRUE == instHandle->isDataBufferPayloadStructure)
901 { 890 {
902 payLoad = (Mcasp_PktAddrPayload *)ioPacket->addr; 891 payLoad = (Mcasp_PktAddrPayload *)ioPacket->addr;
903 assert(NULL != payLoad); 892 if(NULL != payLoad) {
904 host_addr = (uintptr_t)payLoad->addr; 893 host_addr = (uintptr_t)payLoad->addr;
894 }
905 } 895 }
906 else 896 else
907 { 897 {
@@ -947,7 +937,10 @@ int32_t Mcasp_submitPktToDma(Mcasp_ChannelHandle chanHandle,
947 if (TRUE == instHandle->isDataBufferPayloadStructure) 937 if (TRUE == instHandle->isDataBufferPayloadStructure)
948 { 938 {
949 payLoad = (Mcasp_PktAddrPayload *)ioPacket->addr; 939 payLoad = (Mcasp_PktAddrPayload *)ioPacket->addr;
950 host_addr = (uintptr_t)payLoad->addr; 940 if(payLoad != NULL)
941 {
942 host_addr = (uintptr_t)payLoad->addr;
943 }
951 } 944 }
952 else 945 else
953 { 946 {
@@ -983,11 +976,11 @@ int32_t Mcasp_submitPktToDma(Mcasp_ChannelHandle chanHandle,
983 trParams->hostMemTransferParams.hostAddr = (void *)host_addr; 976 trParams->hostMemTransferParams.hostAddr = (void *)host_addr;
984 977
985 trParams->type = (NAVSS_TR_Type_e)trType; 978 trParams->type = (NAVSS_TR_Type_e)trType;
986 979
987 } while(falsewhile); 980 } while(falsewhile);
988 981
989 chanHandle->dataPacket = ioPacket; 982 chanHandle->dataPacket = ioPacket;
990 Mcasp_submitUdmaPkt(chanHandle); 983 Mcasp_submitUdmaPkt(chanHandle);
991 } 984 }
992 return status; 985 return status;
993} 986}
@@ -1031,10 +1024,10 @@ int32_t Mcasp_localGetIndicesSyncType(Mcasp_ChannelHandle chanHandle,
1031 Uint16 temp_var = 0x0U; 1024 Uint16 temp_var = 0x0U;
1032 Uint16 aCntByBCnt = 0x0U; 1025 Uint16 aCntByBCnt = 0x0U;
1033 1026
1034 assert(((NULL != chanHandle) && (NULL != bIndex) && (NULL != cIndex) 1027 if(((NULL != chanHandle) && (NULL != bIndex) && (NULL != cIndex)
1035 && (NULL != aCnt) && (NULL != bCnt) && (NULL != cCnt) 1028 && (NULL != aCnt) && (NULL != bCnt) && (NULL != cCnt)
1036 )); 1029 ))
1037 1030 {
1038 1031
1039#ifdef Mcasp_LOOPJOB_ENABLED 1032#ifdef Mcasp_LOOPJOB_ENABLED
1040 /* Get the size of the buffer to be used. In case of mute command and * 1033 /* Get the size of the buffer to be used. In case of mute command and *
@@ -1183,6 +1176,12 @@ int32_t Mcasp_localGetIndicesSyncType(Mcasp_ChannelHandle chanHandle,
1183 *cIndex = 0; 1176 *cIndex = 0;
1184 } 1177 }
1185 } 1178 }
1179 }
1180 else
1181 {
1182 status = MCASP_EBADARGS;
1183 }
1184
1186 return status; 1185 return status;
1187} 1186}
1188 1187
@@ -1280,19 +1279,16 @@ void Mcasp_getDmaPosition(Mcasp_ChannelHandle chanHandle, uint32_t *dmaPosition)
1280void Mcasp_clearDmaErrors(Mcasp_ChannelHandle chanHandle) 1279void Mcasp_clearDmaErrors(Mcasp_ChannelHandle chanHandle)
1281{ 1280{
1282 /* Todo: implement for UDMA */ 1281 /* Todo: implement for UDMA */
1283 chanHandle = chanHandle;
1284} 1282}
1285 1283
1286void Mcasp_initiateDummyDMAXfer(Mcasp_ChannelHandle chanHandle) 1284void Mcasp_initiateDummyDMAXfer(Mcasp_ChannelHandle chanHandle)
1287{ 1285{
1288 /* Todo: implement for UDMA */ 1286 /* Todo: implement for UDMA */
1289 chanHandle = chanHandle;
1290} 1287}
1291 1288
1292void Mcasp_triggerDMA(Mcasp_ChannelHandle chanHandle) 1289void Mcasp_triggerDMA(Mcasp_ChannelHandle chanHandle)
1293{ 1290{
1294 /* Todo: implement for UDMA */ 1291 /* Todo: implement for UDMA */
1295 chanHandle = chanHandle;
1296} 1292}
1297/* ========================================================================== */ 1293/* ========================================================================== */
1298/* END OF FILE */ 1294/* END OF FILE */
diff --git a/src/mcasp_drv.c b/src/mcasp_drv.c
index ae40c0b..bc7d60b 100755
--- a/src/mcasp_drv.c
+++ b/src/mcasp_drv.c
@@ -539,7 +539,7 @@ static void Mcasp_disableInterrupt(int32_t cpuEventNum,int32_t intNum);
539 539
540 if (MCASP_COMPLETED == status) 540 if (MCASP_COMPLETED == status)
541 { 541 {
542 Mcasp_localSetupHwInfo( 542 status = Mcasp_localSetupHwInfo(
543 &instHandle->hwInfo, 543 &instHandle->hwInfo,
544 &instHandle->mcaspHwSetup); 544 &instHandle->mcaspHwSetup);
545 545
@@ -1308,7 +1308,7 @@ static void Mcasp_disableInterrupt(int32_t cpuEventNum,int32_t intNum);
1308 if(chanHandle->userIntValue) { 1308 if(chanHandle->userIntValue) {
1309 Mcasp_enableInterrupt(chanHandle->cpuEventNum,chanHandle->intNum); 1309 Mcasp_enableInterrupt(chanHandle->cpuEventNum,chanHandle->intNum);
1310 } 1310 }
1311 Mcasp_localActivateSmFsForRcv(instHandle); 1311 status = Mcasp_localActivateSmFsForRcv(instHandle);
1312 } 1312 }
1313 else 1313 else
1314 { 1314 {
@@ -1318,7 +1318,7 @@ static void Mcasp_disableInterrupt(int32_t cpuEventNum,int32_t intNum);
1318 if(chanHandle->userIntValue) { 1318 if(chanHandle->userIntValue) {
1319 Mcasp_enableInterrupt(chanHandle->cpuEventNum,chanHandle->intNum); 1319 Mcasp_enableInterrupt(chanHandle->cpuEventNum,chanHandle->intNum);
1320 } 1320 }
1321 Mcasp_localActivateSmFsForXmt(instHandle); 1321 status = Mcasp_localActivateSmFsForXmt(instHandle);
1322 } 1322 }
1323 } 1323 }
1324 /* dma driven */ 1324 /* dma driven */
@@ -1361,7 +1361,7 @@ static void Mcasp_disableInterrupt(int32_t cpuEventNum,int32_t intNum);
1361 /* Leave critical section */ 1361 /* Leave critical section */
1362 HwiP_restore(key); 1362 HwiP_restore(key);
1363 /* channel opening for transaction has failed */ 1363 /* channel opening for transaction has failed */
1364 chanHandle = NULL; 1364 *chanp = NULL;
1365 } 1365 }
1366 else 1366 else
1367 { 1367 {
@@ -1433,13 +1433,13 @@ static void Mcasp_disableInterrupt(int32_t cpuEventNum,int32_t intNum);
1433 else if ((MCASP_WRITE == ioPacket->cmd) || (MCASP_READ == ioPacket->cmd)) 1433 else if ((MCASP_WRITE == ioPacket->cmd) || (MCASP_READ == ioPacket->cmd))
1434 { 1434 {
1435 instHandle = (Mcasp_Object *)chanHandle->devHandle; 1435 instHandle = (Mcasp_Object *)chanHandle->devHandle;
1436 assert(NULL != instHandle); 1436 if(NULL != instHandle)
1437
1438 /* switch on the device in the PSC */
1439 status = Mcasp_localLpscOn(instHandle);
1440
1441 if (MCASP_COMPLETED == status)
1442 { 1437 {
1438 /* switch on the device in the PSC */
1439 status = Mcasp_localLpscOn(instHandle);
1440
1441 if (MCASP_COMPLETED == status)
1442 {
1443 /* submit the IO request to the driver */ 1443 /* submit the IO request to the driver */
1444 status = mcaspSubmitReq(chanHandle,ioPacket); 1444 status = mcaspSubmitReq(chanHandle,ioPacket);
1445 1445
@@ -1447,7 +1447,12 @@ static void Mcasp_disableInterrupt(int32_t cpuEventNum,int32_t intNum);
1447 { 1447 {
1448 status = Mcasp_localLpscOff(instHandle); 1448 status = Mcasp_localLpscOff(instHandle);
1449 } 1449 }
1450 } 1450 }
1451 }
1452 else
1453 {
1454 status = MCASP_EINVALIDVAL;
1455 }
1451 } 1456 }
1452 else 1457 else
1453 { 1458 {
@@ -1504,9 +1509,9 @@ static void Mcasp_disableInterrupt(int32_t cpuEventNum,int32_t intNum);
1504 /* check if the input parameters are valid */ 1509 /* check if the input parameters are valid */
1505 if (MCASP_COMPLETED == status) 1510 if (MCASP_COMPLETED == status)
1506 { 1511 {
1507 instHandle = (Mcasp_Object*)chanHandle->devHandle; 1512 instHandle = (Mcasp_Object*)chanHandle->devHandle;
1508 assert(NULL != instHandle); 1513 if(NULL != instHandle)
1509 1514 {
1510#if defined (BIOS_PWRM_ENABLE) && !defined (Mcasp_LOOPJOB_ENABLED) 1515#if defined (BIOS_PWRM_ENABLE) && !defined (Mcasp_LOOPJOB_ENABLED)
1511 if (TRUE == instHandle->pscPwrmEnable) 1516 if (TRUE == instHandle->pscPwrmEnable)
1512 { 1517 {
@@ -1548,12 +1553,12 @@ static void Mcasp_disableInterrupt(int32_t cpuEventNum,int32_t intNum);
1548 if (Mcasp_ChanMode_RCV == chanHandle->channelOpMode) 1553 if (Mcasp_ChanMode_RCV == chanHandle->channelOpMode)
1549 { 1554 {
1550 /* Reset state m/c and frame sync of receive section */ 1555 /* Reset state m/c and frame sync of receive section */
1551 Mcasp_localDeactivateSmFsForRcv(instHandle); 1556 status = Mcasp_localDeactivateSmFsForRcv(instHandle);
1552 } 1557 }
1553 else 1558 else
1554 { 1559 {
1555 /* Reset state m/c and frame sync of transmit section */ 1560 /* Reset state m/c and frame sync of transmit section */
1556 Mcasp_localDeactivateSmFsForXmt(instHandle); 1561 status = Mcasp_localDeactivateSmFsForXmt(instHandle);
1557 } 1562 }
1558 } 1563 }
1559 1564
@@ -1611,6 +1616,11 @@ static void Mcasp_disableInterrupt(int32_t cpuEventNum,int32_t intNum);
1611 status = retVal; 1616 status = retVal;
1612 } 1617 }
1613 } 1618 }
1619 }
1620 else
1621 {
1622 status = MCASP_EINVALIDVAL;
1623 }
1614 } 1624 }
1615 return (status); 1625 return (status);
1616} 1626}
@@ -1714,13 +1724,14 @@ static void Mcasp_disableInterrupt(int32_t cpuEventNum,int32_t intNum);
1714 * \leave Not implemented 1724 * \leave Not implemented
1715 * 1725 *
1716 */ 1726 */
1717void Mcasp_localSetupHwInfo(Mcasp_HwHandle hMcasp, 1727int32_t Mcasp_localSetupHwInfo(Mcasp_HwHandle hMcasp,
1718 const Mcasp_HwSetup *myHwSetup) 1728 const Mcasp_HwSetup *myHwSetup)
1719{ 1729{
1720 Int16 serNum = 0; 1730 Int16 serNum = 0;
1731 int32_t status = MCASP_COMPLETED;
1721 1732
1722 assert((NULL != hMcasp) && (NULL != myHwSetup) && (0 != hMcasp->regs)); 1733 if((NULL != hMcasp) && (NULL != myHwSetup) && (0 != hMcasp->regs))
1723 1734 {
1724 /* Reset McASP to default values by setting GBLCTL = 0 */ 1735 /* Reset McASP to default values by setting GBLCTL = 0 */
1725 McASPGlobalCtlReset(hMcasp->regs); 1736 McASPGlobalCtlReset(hMcasp->regs);
1726 1737
@@ -1878,7 +1889,12 @@ void Mcasp_localSetupHwInfo(Mcasp_HwHandle hMcasp,
1878 1889
1879 /* Initialize the global control register */ 1890 /* Initialize the global control register */
1880 McASPGlobalCtlSet(hMcasp->regs, myHwSetup->glb.ctl); 1891 McASPGlobalCtlSet(hMcasp->regs, myHwSetup->glb.ctl);
1881 1892 }
1893 else
1894 {
1895 status = MCASP_EBADARGS;
1896 }
1897 return(status);
1882} 1898}
1883 1899
1884 1900
@@ -1904,15 +1920,14 @@ int32_t Mcasp_localAbortReset(Mcasp_ChannelHandle chanHandle)
1904 uint32_t dmaPos = 0; 1920 uint32_t dmaPos = 0;
1905 int32_t status = MCASP_COMPLETED; 1921 int32_t status = MCASP_COMPLETED;
1906 1922
1907 assert((NULL != chanHandle) && (NULL != chanHandle->devHandle)); 1923 if((NULL != chanHandle) && (NULL != chanHandle->devHandle))
1908 1924 {
1909 do 1925 do
1910 { 1926 {
1911 falsewhile = (Bool)FALSE; 1927 falsewhile = (Bool)FALSE;
1912 1928
1913 instHandle = (Mcasp_Object *)chanHandle->devHandle; 1929 instHandle = (Mcasp_Object *)chanHandle->devHandle;
1914 1930
1915 assert(NULL != instHandle);
1916 1931
1917 /* This function services both transmit and receive channels. Define * 1932 /* This function services both transmit and receive channels. Define *
1918 * critical section to avoid corruption of local variables. * 1933 * critical section to avoid corruption of local variables. *
@@ -1923,12 +1938,12 @@ int32_t Mcasp_localAbortReset(Mcasp_ChannelHandle chanHandle)
1923 if (Mcasp_ChanMode_RCV == chanHandle->channelOpMode) 1938 if (Mcasp_ChanMode_RCV == chanHandle->channelOpMode)
1924 { 1939 {
1925 /* Reset state m/c and frame sync of receive section */ 1940 /* Reset state m/c and frame sync of receive section */
1926 Mcasp_localDeactivateSmFsForRcv(instHandle); 1941 status = Mcasp_localDeactivateSmFsForRcv(instHandle);
1927 } 1942 }
1928 else 1943 else
1929 { 1944 {
1930 /* Reset state m/c and frame sync of transmit section */ 1945 /* Reset state m/c and frame sync of transmit section */
1931 Mcasp_localDeactivateSmFsForXmt(instHandle); 1946 status = Mcasp_localDeactivateSmFsForXmt(instHandle);
1932 } 1947 }
1933 1948
1934 /* Disable the FIFO */ 1949 /* Disable the FIFO */
@@ -2013,13 +2028,10 @@ int32_t Mcasp_localAbortReset(Mcasp_ChannelHandle chanHandle)
2013 /* set packet status equal to Mcasp_E_aborted */ 2028 /* set packet status equal to Mcasp_E_aborted */
2014 ioPacket->status = MCASP_ABORTED; /* Mcasp_E_aborted; */ 2029 ioPacket->status = MCASP_ABORTED; /* Mcasp_E_aborted; */
2015 2030
2016 if (NULL != ioPacket) 2031 if (NULL != chanHandle->cbFxn)
2017 { 2032 {
2018 if (NULL != chanHandle->cbFxn)
2019 {
2020 /* Application callback */ 2033 /* Application callback */
2021 (*chanHandle->cbFxn)((Ptr) chanHandle->cbArg, ioPacket); 2034 (*chanHandle->cbFxn)((Ptr) chanHandle->cbArg, ioPacket);
2022 }
2023 } 2035 }
2024 } 2036 }
2025 } 2037 }
@@ -2067,19 +2079,23 @@ int32_t Mcasp_localAbortReset(Mcasp_ChannelHandle chanHandle)
2067 if (Mcasp_ChanMode_RCV == chanHandle->channelOpMode) 2079 if (Mcasp_ChanMode_RCV == chanHandle->channelOpMode)
2068 { 2080 {
2069 /* Reset state m/c and frame sync of receive section */ 2081 /* Reset state m/c and frame sync of receive section */
2070 Mcasp_localActivateSmFsForRcv(instHandle); 2082 status = Mcasp_localActivateSmFsForRcv(instHandle);
2071 } 2083 }
2072 else 2084 else
2073 { 2085 {
2074 /* Reset state m/c and frame sync of transmit section */ 2086 /* Reset state m/c and frame sync of transmit section */
2075 Mcasp_localActivateSmFsForXmt(instHandle); 2087 status = Mcasp_localActivateSmFsForXmt(instHandle);
2076 } 2088 }
2077#endif 2089#endif
2078 /* CRITICAL SECTION: ends! */ 2090 /* CRITICAL SECTION: ends! */
2079 HwiP_restore(hwiKey); 2091 HwiP_restore(hwiKey);
2080 2092
2081 }while(falsewhile); 2093 }while(falsewhile);
2082 2094 }
2095 else
2096 {
2097 status = MCASP_EBADARGS;
2098 }
2083 return (status); 2099 return (status);
2084} 2100}
2085 2101
@@ -2096,10 +2112,11 @@ int32_t Mcasp_localAbortReset(Mcasp_ChannelHandle chanHandle)
2096 * \leave Not implemented 2112 * \leave Not implemented
2097 * 2113 *
2098 */ 2114 */
2099void Mcasp_localActivateSmFsForRcv(const Mcasp_Object *instHandle) 2115int32_t Mcasp_localActivateSmFsForRcv(const Mcasp_Object *instHandle)
2100{ 2116{
2101 assert(NULL != instHandle); 2117 int32_t status = MCASP_COMPLETED;
2102 2118 if(NULL != instHandle)
2119 {
2103 McASPRxStatusSet(instHandle->hwInfo.regs, 2120 McASPRxStatusSet(instHandle->hwInfo.regs,
2104 ((uint32_t) MCASP_RXSTAT_RERR_MASK | 2121 ((uint32_t) MCASP_RXSTAT_RERR_MASK |
2105 (uint32_t) MCASP_RXSTAT_RDMAERR_MASK | 2122 (uint32_t) MCASP_RXSTAT_RDMAERR_MASK |
@@ -2121,7 +2138,13 @@ void Mcasp_localActivateSmFsForRcv(const Mcasp_Object *instHandle)
2121 /*frame sync*/ 2138 /*frame sync*/
2122 mcaspBitSetGblRCtl(instHandle, 2139 mcaspBitSetGblRCtl(instHandle,
2123 (uint32_t) MCASP_GBLCTLR_RFRST_MASK); 2140 (uint32_t) MCASP_GBLCTLR_RFRST_MASK);
2124 2141
2142 }
2143 else
2144 {
2145 status = MCASP_EBADARGS;
2146 }
2147 return(status);
2125} 2148}
2126 2149
2127/** 2150/**
@@ -2137,10 +2160,12 @@ void Mcasp_localActivateSmFsForRcv(const Mcasp_Object *instHandle)
2137 * \leave Not implemented 2160 * \leave Not implemented
2138 * 2161 *
2139 */ 2162 */
2140void Mcasp_localActivateSmFsForXmt(const Mcasp_Object *instHandle) 2163int32_t Mcasp_localActivateSmFsForXmt(const Mcasp_Object *instHandle)
2141{ 2164{
2142 assert(NULL != instHandle); 2165 int32_t status = MCASP_COMPLETED;
2143 2166
2167 if(NULL != instHandle)
2168 {
2144 McASPTxStatusSet(instHandle->hwInfo.regs, 2169 McASPTxStatusSet(instHandle->hwInfo.regs,
2145 ((uint32_t) MCASP_TXSTAT_XERR_MASK | 2170 ((uint32_t) MCASP_TXSTAT_XERR_MASK |
2146 (uint32_t) MCASP_TXSTAT_XDMAERR_MASK | 2171 (uint32_t) MCASP_TXSTAT_XDMAERR_MASK |
@@ -2158,7 +2183,12 @@ void Mcasp_localActivateSmFsForXmt(const Mcasp_Object *instHandle)
2158 (uint32_t) MCASP_GBLCTLX_XSMRST_MASK); 2183 (uint32_t) MCASP_GBLCTLX_XSMRST_MASK);
2159 mcaspBitSetGblXCtl(instHandle, 2184 mcaspBitSetGblXCtl(instHandle,
2160 (uint32_t) MCASP_GBLCTLX_XFRST_MASK); 2185 (uint32_t) MCASP_GBLCTLX_XFRST_MASK);
2161 2186 }
2187 else
2188 {
2189 status = MCASP_EBADARGS;
2190 }
2191 return(status);
2162} 2192}
2163 2193
2164/** 2194/**
@@ -2174,9 +2204,11 @@ void Mcasp_localActivateSmFsForXmt(const Mcasp_Object *instHandle)
2174 * \leave Not implemented 2204 * \leave Not implemented
2175 * 2205 *
2176 */ 2206 */
2177void Mcasp_localActivateSmFsForBoth(const Mcasp_Object *instHandle) 2207int32_t Mcasp_localActivateSmFsForBoth(const Mcasp_Object *instHandle)
2178{ 2208{
2179 assert((NULL != instHandle)); 2209 int32_t status = MCASP_COMPLETED;
2210 if((NULL != instHandle))
2211 {
2180 2212
2181 /* Clear the interrupts */ 2213 /* Clear the interrupts */
2182 McASPTxStatusSet(instHandle->hwInfo.regs, 2214 McASPTxStatusSet(instHandle->hwInfo.regs,
@@ -2209,7 +2241,12 @@ void Mcasp_localActivateSmFsForBoth(const Mcasp_Object *instHandle)
2209 mcaspBitSetGblCtl(instHandle, 2241 mcaspBitSetGblCtl(instHandle,
2210 (uint32_t) (MCASP_GBLCTLX_XFRST_MASK | 2242 (uint32_t) (MCASP_GBLCTLX_XFRST_MASK |
2211 MCASP_GBLCTLR_RFRST_MASK)); 2243 MCASP_GBLCTLR_RFRST_MASK));
2212 2244 }
2245 else
2246 {
2247 status = MCASP_EBADARGS;
2248 }
2249 return(status);
2213} 2250}
2214 2251
2215 2252
@@ -2228,41 +2265,48 @@ void Mcasp_localActivateSmFsForBoth(const Mcasp_Object *instHandle)
2228 * 2265 *
2229 * \leave Not implemented 2266 * \leave Not implemented
2230 */ 2267 */
2231void Mcasp_localSmReset(Mcasp_ChannelHandle chanHandle) 2268int32_t Mcasp_localSmReset(Mcasp_ChannelHandle chanHandle)
2232{ 2269{
2233 Mcasp_Object *instHandle = NULL; 2270 Mcasp_Object *instHandle = NULL;
2271 int32_t status = MCASP_COMPLETED;
2234 2272
2235 assert((NULL != chanHandle) && (NULL != chanHandle->devHandle)); 2273 if((NULL != chanHandle) && (NULL != chanHandle->devHandle))
2236
2237 instHandle = (Mcasp_Object *)chanHandle->devHandle;
2238
2239 if (Mcasp_ChanMode_RCV == chanHandle->channelOpMode)
2240 { 2274 {
2275 instHandle = (Mcasp_Object *)chanHandle->devHandle;
2276
2277 if (Mcasp_ChanMode_RCV == chanHandle->channelOpMode)
2278 {
2241 /* Reset state m/c and frame sync of receive section */ 2279 /* Reset state m/c and frame sync of receive section */
2242 Mcasp_localDeactivateSmFsForRcv(instHandle); 2280 status = Mcasp_localDeactivateSmFsForRcv(instHandle);
2243 } 2281 }
2244 else 2282 else
2245 { 2283 {
2246 /* Reset state m/c and frame sync of transmit section */ 2284 /* Reset state m/c and frame sync of transmit section */
2247 Mcasp_localDeactivateSmFsForXmt(instHandle); 2285 status = Mcasp_localDeactivateSmFsForXmt(instHandle);
2248 } 2286 }
2249 2287
2250 /* Disable the FIFO */ 2288 /* Disable the FIFO */
2251 mcaspConfigureFifo(&instHandle->hwInfo, chanHandle, FALSE); 2289 mcaspConfigureFifo(&instHandle->hwInfo, chanHandle, FALSE);
2252 2290
2253 if (FALSE == chanHandle->isDmaDriven) 2291 if (FALSE == chanHandle->isDmaDriven)
2254 { 2292 {
2255 /* Interrupt driven transactions */ 2293 /* Interrupt driven transactions */
2256 2294
2257 /* When iohandle state m/c is reactivated, it will require two * 2295 /* When iohandle state m/c is reactivated, it will require two *
2258 * requests to service it. Reset count to ensure this. */ 2296 * requests to service it. Reset count to ensure this. */
2259 chanHandle->dataQueuedOnReset = 0; 2297 chanHandle->dataQueuedOnReset = 0;
2260 chanHandle->xferinProgressIntmode = (Bool)FALSE; 2298 chanHandle->xferinProgressIntmode = (Bool)FALSE;
2261 } 2299 }
2262 else 2300 else
2263 { 2301 {
2264 Mcasp_disableDMA(chanHandle); 2302 Mcasp_disableDMA(chanHandle);
2265 } 2303 }
2304 }
2305 else
2306 {
2307 status = MCASP_EBADARGS;
2308 }
2309 return (status);
2266} 2310}
2267 2311
2268/** 2312/**
@@ -2278,11 +2322,13 @@ void Mcasp_localSmReset(Mcasp_ChannelHandle chanHandle)
2278 * 2322 *
2279 * \leave Not implemented 2323 * \leave Not implemented
2280 */ 2324 */
2281void Mcasp_localSmSet(Mcasp_ChannelHandle chanHandle) 2325int32_t Mcasp_localSmSet(Mcasp_ChannelHandle chanHandle)
2282{ 2326{
2283 Mcasp_Object *instHandle = NULL; 2327 Mcasp_Object *instHandle = NULL;
2328 int32_t status = MCASP_COMPLETED;
2284 2329
2285 assert((NULL != chanHandle) && (NULL != chanHandle->devHandle)); 2330 if((NULL != chanHandle) && (NULL != chanHandle->devHandle))
2331 {
2286 2332
2287 instHandle = (Mcasp_Object *)chanHandle->devHandle; 2333 instHandle = (Mcasp_Object *)chanHandle->devHandle;
2288 2334
@@ -2309,14 +2355,21 @@ void Mcasp_localSmSet(Mcasp_ChannelHandle chanHandle)
2309 if (Mcasp_ChanMode_RCV == chanHandle->channelOpMode) 2355 if (Mcasp_ChanMode_RCV == chanHandle->channelOpMode)
2310 { 2356 {
2311 /* Reset state m/c and frame sync of receive section */ 2357 /* Reset state m/c and frame sync of receive section */
2312 Mcasp_localActivateSmFsForRcv(instHandle); 2358 status = Mcasp_localActivateSmFsForRcv(instHandle);
2313 } 2359 }
2314 else 2360 else
2315 { 2361 {
2316 /* Reset state m/c and frame sync of transmit section */ 2362 /* Reset state m/c and frame sync of transmit section */
2317 Mcasp_localActivateSmFsForXmt(instHandle); 2363 status = Mcasp_localActivateSmFsForXmt(instHandle);
2318 } 2364 }
2319 2365 }
2366 else
2367 {
2368 status = MCASP_EBADARGS;
2369 }
2370
2371 return(status);
2372
2320} 2373}
2321 2374
2322/** 2375/**
@@ -2349,10 +2402,10 @@ int32_t Mcasp_localConfigXmtSection(Mcasp_Object *instHandle,
2349 uint8_t xMinTemp = 0x00; 2402 uint8_t xMinTemp = 0x00;
2350 uint8_t xMaxTemp = 0x00; 2403 uint8_t xMaxTemp = 0x00;
2351 2404
2352 assert((NULL != instHandle) 2405 if((NULL != instHandle)
2353 && (NULL != xmtData) 2406 && (NULL != xmtData)
2354 && (0 != (instHandle->hwInfo.regs))); 2407 && (0 != (instHandle->hwInfo.regs)))
2355 2408 {
2356 /* Configure TXMASK register */ 2409 /* Configure TXMASK register */
2357 McASPTxFmtMaskSet(instHandle->hwInfo.regs, xmtData->mask); 2410 McASPTxFmtMaskSet(instHandle->hwInfo.regs, xmtData->mask);
2358 2411
@@ -2552,7 +2605,12 @@ int32_t Mcasp_localConfigXmtSection(Mcasp_Object *instHandle,
2552 /* Configure XEVTCTL register */ 2605 /* Configure XEVTCTL register */
2553 McASPTxRxDMAEvtCntrlWrite(instHandle->hwInfo.regs, (uint8_t) TX, 2606 McASPTxRxDMAEvtCntrlWrite(instHandle->hwInfo.regs, (uint8_t) TX,
2554 xmtData->evtCtl); 2607 xmtData->evtCtl);
2555 2608
2609 }
2610 else
2611 {
2612 status = MCASP_EBADARGS;
2613 }
2556 return (status); 2614 return (status);
2557} 2615}
2558 2616
@@ -2586,9 +2644,11 @@ int32_t Mcasp_localConfigRcvSection(Mcasp_Object *instHandle,
2586 uint8_t rMinTemp = 0x00; 2644 uint8_t rMinTemp = 0x00;
2587 uint8_t rMaxTemp = 0x00; 2645 uint8_t rMaxTemp = 0x00;
2588 2646
2589 assert((NULL != instHandle) 2647 if((NULL != instHandle)
2590 && (NULL != rcvData) 2648 && (NULL != rcvData)
2591 && (0 != instHandle->hwInfo.regs)); 2649 && (0 != instHandle->hwInfo.regs))
2650 {
2651
2592 2652
2593 /* Configure RMASK register */ 2653 /* Configure RMASK register */
2594 McASPRxFmtMaskSet(instHandle->hwInfo.regs, rcvData->mask); 2654 McASPRxFmtMaskSet(instHandle->hwInfo.regs, rcvData->mask);
@@ -2780,6 +2840,11 @@ int32_t Mcasp_localConfigRcvSection(Mcasp_Object *instHandle,
2780 2840
2781 McASPTxRxDMAEvtCntrlWrite(instHandle->hwInfo.regs, (uint8_t) RX, 2841 McASPTxRxDMAEvtCntrlWrite(instHandle->hwInfo.regs, (uint8_t) RX,
2782 rcvData->evtCtl); 2842 rcvData->evtCtl);
2843 }
2844 else
2845 {
2846 status = MCASP_EBADARGS;
2847 }
2783 return (status); 2848 return (status);
2784} 2849}
2785 2850
@@ -2801,10 +2866,14 @@ int32_t Mcasp_localResetXmt(Mcasp_HwHandle hMcasp)
2801{ 2866{
2802 int32_t status = MCASP_COMPLETED; 2867 int32_t status = MCASP_COMPLETED;
2803 2868
2804 assert((NULL != hMcasp) && (0 != hMcasp->regs)); 2869 if((NULL != hMcasp) && (0 != hMcasp->regs))
2805 2870 {
2806 McASPTxReset(hMcasp->regs); 2871 McASPTxReset(hMcasp->regs);
2807 2872 }
2873 else
2874 {
2875 status = MCASP_EBADARGS;
2876 }
2808 return (status); 2877 return (status);
2809 2878
2810} 2879}
@@ -2826,10 +2895,14 @@ int32_t Mcasp_localResetRcv(Mcasp_HwHandle hMcasp)
2826{ 2895{
2827 int32_t status = MCASP_COMPLETED; 2896 int32_t status = MCASP_COMPLETED;
2828 2897
2829 assert((NULL != hMcasp) && (0 != hMcasp->regs)); 2898 if((NULL != hMcasp) && (0 != hMcasp->regs))
2830 2899 {
2831 McASPRxReset(hMcasp->regs); 2900 McASPRxReset(hMcasp->regs);
2832 2901 }
2902 else
2903 {
2904 status = MCASP_EBADARGS;
2905 }
2833 return (status); 2906 return (status);
2834 2907
2835} 2908}
@@ -2876,8 +2949,8 @@ void Mcasp_commonDmaCallback(Mcasp_ChannelHandle chanHandle, int32_t status)
2876 Mcasp_disableDMA(chanHandle); 2949 Mcasp_disableDMA(chanHandle);
2877 2950
2878 instHandle = (Mcasp_Object *)chanHandle->devHandle; 2951 instHandle = (Mcasp_Object *)chanHandle->devHandle;
2879 assert(NULL != instHandle); 2952 if(NULL != instHandle)
2880 2953 {
2881 /* close the IOP now */ 2954 /* close the IOP now */
2882 if (MCASP_OUTPUT == chanHandle->mode) 2955 if (MCASP_OUTPUT == chanHandle->mode)
2883 { 2956 {
@@ -2929,8 +3002,8 @@ void Mcasp_commonDmaCallback(Mcasp_ChannelHandle chanHandle, int32_t status)
2929 3002
2930 if (MCASP_LBCTL_DLBEN_ENABLE == dlbMode) 3003 if (MCASP_LBCTL_DLBEN_ENABLE == dlbMode)
2931 { 3004 {
2932 Mcasp_localDeactivateSmFsForRcv(instHandle); 3005 (void)Mcasp_localDeactivateSmFsForRcv(instHandle);
2933 Mcasp_localDeactivateSmFsForXmt(instHandle); 3006 (void)Mcasp_localDeactivateSmFsForXmt(instHandle);
2934 } 3007 }
2935 else 3008 else
2936 { 3009 {
@@ -2939,7 +3012,7 @@ void Mcasp_commonDmaCallback(Mcasp_ChannelHandle chanHandle, int32_t status)
2939 if (Mcasp_ChanMode_RCV == chanHandle->channelOpMode) 3012 if (Mcasp_ChanMode_RCV == chanHandle->channelOpMode)
2940 { 3013 {
2941 /* Reset state m/c & frame sync of receive section */ 3014 /* Reset state m/c & frame sync of receive section */
2942 Mcasp_localDeactivateSmFsForRcv(instHandle); 3015 status = Mcasp_localDeactivateSmFsForRcv(instHandle);
2943 3016
2944 /* reenable the RCV overrun error */ 3017 /* reenable the RCV overrun error */
2945 if (MCASP_RX_OVERRUN == 3018 if (MCASP_RX_OVERRUN ==
@@ -2958,6 +3031,11 @@ void Mcasp_commonDmaCallback(Mcasp_ChannelHandle chanHandle, int32_t status)
2958 3031
2959 /* clear the DMA error bits that have been set */ 3032 /* clear the DMA error bits that have been set */
2960 Mcasp_clearDmaErrors(chanHandle); 3033 Mcasp_clearDmaErrors(chanHandle);
3034 }
3035 else
3036 {
3037 status = MCASP_EINVALIDVAL;
3038 }
2961 } 3039 }
2962 3040
2963 if (MCASP_COMPLETED != status) 3041 if (MCASP_COMPLETED != status)
@@ -2995,8 +3073,8 @@ void Mcasp_commonDmaCallback(Mcasp_ChannelHandle chanHandle, int32_t status)
2995 HwiP_restore(hwiKey); 3073 HwiP_restore(hwiKey);
2996 3074
2997 instHandle = (Mcasp_Object *)chanHandle->devHandle; 3075 instHandle = (Mcasp_Object *)chanHandle->devHandle;
2998 assert(NULL != instHandle); 3076 if(NULL != instHandle)
2999 3077 {
3000 /* If stopSmFs flag for the channel is false and pause is not issued * 3078 /* If stopSmFs flag for the channel is false and pause is not issued *
3001 * control will go in the if part. In case when stopSmFS is issued or * 3079 * control will go in the if part. In case when stopSmFS is issued or *
3002 * pause is issued, control will go in else part */ 3080 * pause is issued, control will go in else part */
@@ -3104,6 +3182,7 @@ void Mcasp_commonDmaCallback(Mcasp_ChannelHandle chanHandle, int32_t status)
3104 Mcasp_localHandlePwrmEvent(instHandle,chanHandle); 3182 Mcasp_localHandlePwrmEvent(instHandle,chanHandle);
3105 } 3183 }
3106#endif /* #ifdef BIOS_PWRM_ENABLE */ 3184#endif /* #ifdef BIOS_PWRM_ENABLE */
3185 }
3107 } 3186 }
3108 } 3187 }
3109 } while (falseWhile); 3188 } while (falseWhile);
@@ -3141,12 +3220,9 @@ int32_t Mcasp_localDmaProcessPkt(void* chanp, MCASP_Packet *ioPacket)
3141 Bool falsewhile = (Bool)TRUE; 3220 Bool falsewhile = (Bool)TRUE;
3142 3221
3143 /* Validate pointers and parameters */ 3222 /* Validate pointers and parameters */
3144 assert((NULL != chanp) && (NULL != ioPacket)); 3223 if((NULL != chanp) && (NULL != ioPacket) && (NULL != ((Mcasp_ChannelHandle)chanp)->devHandle))
3145 3224 {
3146 chanHandle = (Mcasp_ChannelHandle)chanp; 3225 chanHandle = (Mcasp_ChannelHandle)chanp;
3147
3148 assert(NULL != chanHandle->devHandle);
3149
3150 do 3226 do
3151 { 3227 {
3152 falsewhile = (Bool)FALSE; 3228 falsewhile = (Bool)FALSE;
@@ -3157,9 +3233,9 @@ int32_t Mcasp_localDmaProcessPkt(void* chanp, MCASP_Packet *ioPacket)
3157 && (Mcasp_ChanMode_XMT_DIT == chanHandle->channelOpMode)) 3233 && (Mcasp_ChanMode_XMT_DIT == chanHandle->channelOpMode))
3158 { 3234 {
3159 /* The data should be a payload structure */ 3235 /* The data should be a payload structure */
3160 payLoad = (Mcasp_PktAddrPayload *)ioPacket->addr; 3236 payLoad = (Mcasp_PktAddrPayload *)ioPacket->addr;
3161 assert(NULL != payLoad); 3237 if(NULL != payLoad)
3162 3238 {
3163 if (TRUE == payLoad->writeDitParams) 3239 if (TRUE == payLoad->writeDitParams)
3164 { 3240 {
3165 /* DIT Mode: for DIT mode as of now each packet (IOP) * 3241 /* DIT Mode: for DIT mode as of now each packet (IOP) *
@@ -3185,6 +3261,11 @@ int32_t Mcasp_localDmaProcessPkt(void* chanp, MCASP_Packet *ioPacket)
3185 } 3261 }
3186 } 3262 }
3187 } 3263 }
3264 }
3265 else
3266 {
3267 status = MCASP_EINVALIDVAL;
3268 }
3188 } 3269 }
3189 3270
3190 if (MCASP_COMPLETED == status) 3271 if (MCASP_COMPLETED == status)
@@ -3203,6 +3284,11 @@ int32_t Mcasp_localDmaProcessPkt(void* chanp, MCASP_Packet *ioPacket)
3203 } 3284 }
3204 3285
3205 }while(falsewhile); 3286 }while(falsewhile);
3287 }
3288 else
3289 {
3290 status = MCASP_EBADARGS;
3291 }
3206 3292
3207 return (status); 3293 return (status);
3208} 3294}
@@ -3230,12 +3316,13 @@ void Mcasp_localCompleteCurrentIo(Mcasp_ChannelHandle chanHandle)
3230 3316
3231#endif 3317#endif
3232 3318
3233 assert(NULL != chanHandle); 3319 if(NULL != chanHandle)
3234 3320 {
3235 3321
3236#ifndef Mcasp_LOOPJOB_ENABLED 3322#ifndef Mcasp_LOOPJOB_ENABLED
3237 assert(NULL != chanHandle->devHandle); 3323 if(NULL != chanHandle->devHandle)
3238 instHandle = (Mcasp_Object *)chanHandle->devHandle; 3324 {
3325 instHandle = (Mcasp_Object *)chanHandle->devHandle;
3239 3326
3240#endif 3327#endif
3241 3328
@@ -3273,6 +3360,12 @@ void Mcasp_localCompleteCurrentIo(Mcasp_ChannelHandle chanHandle)
3273 } 3360 }
3274 chanHandle->dataPacket = NULL; 3361 chanHandle->dataPacket = NULL;
3275 chanHandle->userDataBufferSize = 0; 3362 chanHandle->userDataBufferSize = 0;
3363#ifndef Mcasp_LOOPJOB_ENABLED
3364 }
3365#endif
3366
3367 }
3368
3276} 3369}
3277 3370
3278/** 3371/**
@@ -3293,8 +3386,8 @@ int32_t Mcasp_localCancelAndAbortAllIo(Mcasp_ChannelHandle chanHandle)
3293 Mcasp_Object *instHandle = NULL; 3386 Mcasp_Object *instHandle = NULL;
3294 int32_t status = MCASP_COMPLETED; 3387 int32_t status = MCASP_COMPLETED;
3295 3388
3296 assert((NULL != chanHandle) && (NULL != chanHandle->devHandle)); 3389 if((NULL != chanHandle) && (NULL != chanHandle->devHandle))
3297 3390 {
3298 chanHandle->submitCount--; 3391 chanHandle->submitCount--;
3299 3392
3300 chanHandle->dataPacket->status = MCASP_ABORTED; 3393 chanHandle->dataPacket->status = MCASP_ABORTED;
@@ -3302,7 +3395,6 @@ int32_t Mcasp_localCancelAndAbortAllIo(Mcasp_ChannelHandle chanHandle)
3302 Mcasp_localCompleteCurrentIo(chanHandle); 3395 Mcasp_localCompleteCurrentIo(chanHandle);
3303 3396
3304 instHandle = (Mcasp_Object *)chanHandle->devHandle; 3397 instHandle = (Mcasp_Object *)chanHandle->devHandle;
3305 assert(NULL != instHandle);
3306 3398
3307 /* While aborting care should be taken about DLB mode otherwise * 3399 /* While aborting care should be taken about DLB mode otherwise *
3308 * aborting packets in only one direction will make the packet in * 3400 * aborting packets in only one direction will make the packet in *
@@ -3321,7 +3413,11 @@ int32_t Mcasp_localCancelAndAbortAllIo(Mcasp_ChannelHandle chanHandle)
3321 { 3413 {
3322 status = Mcasp_localAbortReset(chanHandle); 3414 status = Mcasp_localAbortReset(chanHandle);
3323 } 3415 }
3324 3416 }
3417 else
3418 {
3419 status = MCASP_EBADARGS;
3420 }
3325 return (status); 3421 return (status);
3326} 3422}
3327 3423
@@ -3345,8 +3441,8 @@ int32_t Mcasp_localCancelAndAbortAllIo(Mcasp_ChannelHandle chanHandle)
3345 Bool isTask = (Bool)FALSE; 3441 Bool isTask = (Bool)FALSE;
3346 3442
3347 uint32_t tempVal; 3443 uint32_t tempVal;
3348 assert(NULL != instHandle); 3444 if(NULL != instHandle)
3349 3445 {
3350 tempVal = McASPGlobalCtlGet(instHandle->hwInfo.regs); 3446 tempVal = McASPGlobalCtlGet(instHandle->hwInfo.regs);
3351 /* If already this bit is set then don't set again */ 3447 /* If already this bit is set then don't set again */
3352 if ((tempVal & bitMaskVal) != bitMaskVal) 3448 if ((tempVal & bitMaskVal) != bitMaskVal)
@@ -3373,6 +3469,7 @@ int32_t Mcasp_localCancelAndAbortAllIo(Mcasp_ChannelHandle chanHandle)
3373 } 3469 }
3374 assert(0U != timeout); 3470 assert(0U != timeout);
3375 } 3471 }
3472 }
3376} 3473}
3377 3474
3378/* 3475/*
@@ -3452,9 +3549,8 @@ int32_t Mcasp_localCancelAndAbortAllIo(Mcasp_ChannelHandle chanHandle)
3452 Bool chanStopped = (Bool) FALSE; 3549 Bool chanStopped = (Bool) FALSE;
3453#endif 3550#endif
3454 3551
3455 assert((NULL != chanHandle) && (NULL != ioPacket)); 3552 if((NULL != chanHandle) && (NULL != chanHandle->devHandle) && (NULL != ioPacket))
3456 3553 {
3457 assert(NULL != chanHandle->devHandle);
3458 3554
3459 /* check for the valid packet size */ 3555 /* check for the valid packet size */
3460 assert((0 != ioPacket->size) 3556 assert((0 != ioPacket->size)
@@ -3465,21 +3561,27 @@ int32_t Mcasp_localCancelAndAbortAllIo(Mcasp_ChannelHandle chanHandle)
3465 { 3561 {
3466 falsewhile = (Bool)FALSE; 3562 falsewhile = (Bool)FALSE;
3467 instHandle = (Mcasp_Object *)chanHandle->devHandle; 3563 instHandle = (Mcasp_Object *)chanHandle->devHandle;
3468 assert(NULL != instHandle);
3469 3564
3470 if (TRUE == instHandle->isDataBufferPayloadStructure) 3565 if (TRUE == instHandle->isDataBufferPayloadStructure)
3471 { 3566 {
3472 payLoad = (Mcasp_PktAddrPayload *)ioPacket->addr; 3567 payLoad = (Mcasp_PktAddrPayload *)ioPacket->addr;
3473 assert(NULL != payLoad); 3568 if(NULL != payLoad)
3474 3569 {
3475 pktAddr = payLoad->addr; 3570 pktAddr = payLoad->addr;
3571 }
3572 else
3573 {
3574 status = MCASP_EINVALIDVAL;
3575 break;
3576 }
3476 } 3577 }
3477 else 3578 else
3478 { 3579 {
3479 pktAddr = ioPacket->addr; 3580 pktAddr = ioPacket->addr;
3480 } 3581 }
3481 3582
3482 assert(NULL != pktAddr); 3583 if(NULL != pktAddr)
3584 {
3483 3585
3484 /* maintain cache coherency */ 3586 /* maintain cache coherency */
3485 if (MCASP_INPUT == chanHandle->mode) 3587 if (MCASP_INPUT == chanHandle->mode)
@@ -3553,7 +3655,17 @@ int32_t Mcasp_localCancelAndAbortAllIo(Mcasp_ChannelHandle chanHandle)
3553 } 3655 }
3554 /* return the status as pending as the packet will complete later */ 3656 /* return the status as pending as the packet will complete later */
3555 status = MCASP_PENDING; 3657 status = MCASP_PENDING;
3658 }
3659 else
3660 {
3661 status = MCASP_EINVALIDVAL;
3662 }
3556 }while(falsewhile); 3663 }while(falsewhile);
3664 }
3665 else
3666 {
3667 status = MCASP_EBADARGS;
3668 }
3557 return status; 3669 return status;
3558} 3670}
3559 3671
@@ -3576,10 +3688,6 @@ int32_t Mcasp_localCancelAndAbortAllIo(Mcasp_ChannelHandle chanHandle)
3576 uint32_t count = 0; 3688 uint32_t count = 0;
3577 Mcasp_Object *instHandle = NULL; 3689 Mcasp_Object *instHandle = NULL;
3578 3690
3579 /* To remove the compiler warning */
3580 arg0 = arg0;
3581 arg1 = arg1;
3582
3583 /* An interrupt has occured and it could be because of any one of the * 3691 /* An interrupt has occured and it could be because of any one of the *
3584 * mcasp instances and also either a TX or RX section interrupt.Hence we * 3692 * mcasp instances and also either a TX or RX section interrupt.Hence we *
3585 * will check all the instances to find which interrupt has occured. Also * 3693 * will check all the instances to find which interrupt has occured. Also *
@@ -3594,9 +3702,9 @@ int32_t Mcasp_localCancelAndAbortAllIo(Mcasp_ChannelHandle chanHandle)
3594 && ((Bool) TRUE == Mcasp_module.isrObject[count].isIsrRegistered[1]) 3702 && ((Bool) TRUE == Mcasp_module.isrObject[count].isIsrRegistered[1])
3595 && (NULL != Mcasp_module.isrObject[count].instHandle)) 3703 && (NULL != Mcasp_module.isrObject[count].instHandle))
3596 { 3704 {
3597 instHandle = Mcasp_module.isrObject[count].instHandle; 3705 instHandle = Mcasp_module.isrObject[count].instHandle;
3598 assert(NULL != instHandle); 3706 if(NULL != instHandle)
3599 3707 {
3600 /* check if the RX channel has registered the interrupts */ 3708 /* check if the RX channel has registered the interrupts */
3601 if (TRUE == Mcasp_module.isrObject[count].chanEnabled[0]) 3709 if (TRUE == Mcasp_module.isrObject[count].chanEnabled[0])
3602 { 3710 {
@@ -3620,6 +3728,8 @@ int32_t Mcasp_localCancelAndAbortAllIo(Mcasp_ChannelHandle chanHandle)
3620 mcaspIsrOutput((void *)&(instHandle->XmtObj)); 3728 mcaspIsrOutput((void *)&(instHandle->XmtObj));
3621 } 3729 }
3622 } 3730 }
3731 }
3732
3623 } 3733 }
3624 } 3734 }
3625} 3735}
@@ -3669,16 +3779,14 @@ void mcaspIsr(void * arg)
3669int32_t Mcasp_localCollectRcvErrorStats(Mcasp_ChannelHandle chanHandle,Mcasp_errCbStatus *errStatus) 3779int32_t Mcasp_localCollectRcvErrorStats(Mcasp_ChannelHandle chanHandle,Mcasp_errCbStatus *errStatus)
3670{ 3780{
3671 3781
3672 Mcasp_Object *instHandle = NULL; 3782 Mcasp_Object *instHandle = NULL;
3673 int32_t status = MCASP_COMPLETED; 3783 int32_t status = MCASP_COMPLETED;
3674 3784
3675 assert(NULL != errStatus);
3676
3677 assert((NULL != chanHandle) && (NULL != chanHandle->devHandle));
3678 3785
3786 if((NULL != errStatus) && (NULL != chanHandle) && (NULL != chanHandle->devHandle))
3787 {
3679 instHandle = (Mcasp_Object *)chanHandle->devHandle; 3788 instHandle = (Mcasp_Object *)chanHandle->devHandle;
3680 assert(NULL != instHandle); 3789
3681
3682 /* Initialize */ 3790 /* Initialize */
3683 errStatus->isClkFailErr=FALSE; 3791 errStatus->isClkFailErr=FALSE;
3684 errStatus->isDMAErr=FALSE; 3792 errStatus->isDMAErr=FALSE;
@@ -3731,8 +3839,12 @@ int32_t Mcasp_localCollectRcvErrorStats(Mcasp_ChannelHandle chanHandle,Mcasp_err
3731 errStatus->isClkFailErr = (Bool) TRUE; 3839 errStatus->isClkFailErr = (Bool) TRUE;
3732 } 3840 }
3733 } 3841 }
3734
3735 errStatus->retVal = (int32_t) status; 3842 errStatus->retVal = (int32_t) status;
3843 }
3844 else
3845 {
3846 status = MCASP_EBADARGS;
3847 }
3736 3848
3737 return(status); 3849 return(status);
3738} 3850}
@@ -3761,15 +3873,11 @@ void mcaspIsrInput(void * chanp)
3761 3873
3762 do 3874 do
3763 { 3875 {
3764 assert(NULL != chanp);
3765
3766 falsewhile = (Bool)FALSE; 3876 falsewhile = (Bool)FALSE;
3767
3768 chanHandle = (Mcasp_ChannelHandle)chanp; 3877 chanHandle = (Mcasp_ChannelHandle)chanp;
3769 assert((NULL != chanHandle) && (NULL != chanHandle->devHandle)); 3878 if((NULL != chanHandle) && (NULL != ((Mcasp_ChannelHandle)chanp)->devHandle))
3770 3879 {
3771 instHandle = (Mcasp_Object *)chanHandle->devHandle; 3880 instHandle = (Mcasp_Object *)chanHandle->devHandle;
3772 assert(NULL != instHandle);
3773 3881
3774 /* Interrupt handling starts */ 3882 /* Interrupt handling starts */
3775 3883
@@ -3808,16 +3916,16 @@ void mcaspIsrInput(void * chanp)
3808 status = Mcasp_localAbortReset(chanHandle); 3916 status = Mcasp_localAbortReset(chanHandle);
3809 } 3917 }
3810 break; 3918 break;
3811 } 3919 }
3812 3920 else
3813 /* if the error is a non- framesync error - we just send error * 3921 {
3922 /* if the error is a non- framesync error - we just send error *
3814 * status for the current packet in the callback function and * 3923 * status for the current packet in the callback function and *
3815 * continue with other packets for xfer */ 3924 * continue with other packets for xfer */
3816 if (MCASP_ETIMEOUT != status) 3925
3817 {
3818 /* Disable Serializer, State machine and Frame sync of RCV * 3926 /* Disable Serializer, State machine and Frame sync of RCV *
3819 * Section. Also Disable EDMA Transfer. */ 3927 * Section. Also Disable EDMA Transfer. */
3820 Mcasp_localSmReset(chanHandle); 3928 status = Mcasp_localSmReset(chanHandle);
3821 3929
3822 /* Todo: this probably isn't the best function to implement. 3930 /* Todo: this probably isn't the best function to implement.
3823 * Need to revisit after source has been merged. */ 3931 * Need to revisit after source has been merged. */
@@ -3831,9 +3939,10 @@ void mcaspIsrInput(void * chanp)
3831 3939
3832 /* Enable Serializer, State machine and Frame sync of RCV * 3940 /* Enable Serializer, State machine and Frame sync of RCV *
3833 * Section.Also Enable EDMA Transfer. */ 3941 * Section.Also Enable EDMA Transfer. */
3834 Mcasp_localSmSet(chanHandle); 3942 (void)Mcasp_localSmSet(chanHandle);
3835 }/*for errors except sync errors*/ 3943 }/*for errors except sync errors*/
3836 }/*dma transfer for all errors*/ 3944 }/*dma transfer for all errors*/
3945 }
3837 }while(falsewhile); 3946 }while(falsewhile);
3838} 3947}
3839/** 3948/**
@@ -3853,12 +3962,10 @@ int32_t Mcasp_localCollectXmtErrorStats(Mcasp_ChannelHandle chanHandle,Mcasp_err
3853 Mcasp_Object *instHandle = NULL; 3962 Mcasp_Object *instHandle = NULL;
3854 int32_t status = MCASP_COMPLETED; 3963 int32_t status = MCASP_COMPLETED;
3855 3964
3856 assert(NULL != errStatus);
3857
3858 assert((NULL != chanHandle) && (NULL != chanHandle->devHandle));
3859 3965
3966 if((NULL != errStatus) && (NULL != chanHandle) && (NULL != chanHandle->devHandle))
3967 {
3860 instHandle = (Mcasp_Object *)chanHandle->devHandle; 3968 instHandle = (Mcasp_Object *)chanHandle->devHandle;
3861 assert(NULL != instHandle);
3862 3969
3863 /* Initialize */ 3970 /* Initialize */
3864 errStatus->isClkFailErr=FALSE; 3971 errStatus->isClkFailErr=FALSE;
@@ -3919,7 +4026,12 @@ int32_t Mcasp_localCollectXmtErrorStats(Mcasp_ChannelHandle chanHandle,Mcasp_err
3919 } 4026 }
3920 4027
3921 errStatus->retVal = (int32_t) status; 4028 errStatus->retVal = (int32_t) status;
3922 4029 }
4030 else
4031 {
4032 status = MCASP_EBADARGS;
4033 }
4034
3923 return(status); 4035 return(status);
3924} 4036}
3925/** 4037/**
@@ -3943,17 +4055,14 @@ void mcaspIsrOutput(void * chanp)
3943 uint32_t dlbMode = 0; 4055 uint32_t dlbMode = 0;
3944 Mcasp_errCbStatus errStatuts = {FALSE, FALSE, FALSE, FALSE, 0}; 4056 Mcasp_errCbStatus errStatuts = {FALSE, FALSE, FALSE, FALSE, 0};
3945 4057
3946 assert(NULL != chanp);
3947
3948 do 4058 do
3949 { 4059 {
3950 falsewhile = (Bool)FALSE; 4060 falsewhile = (Bool)FALSE;
3951 4061
3952 chanHandle = (Mcasp_ChannelHandle)chanp; 4062 chanHandle = (Mcasp_ChannelHandle)chanp;
3953 assert((NULL != chanHandle) && (NULL != chanHandle->devHandle)); 4063 if((NULL != chanHandle) && (NULL != chanHandle->devHandle))
3954 4064 {
3955 instHandle = (Mcasp_Object *)chanHandle->devHandle; 4065 instHandle = (Mcasp_Object *)chanHandle->devHandle;
3956 assert(NULL != instHandle);
3957 4066
3958 /* Interrupt handling starts */ 4067 /* Interrupt handling starts */
3959 4068
@@ -3990,16 +4099,16 @@ void mcaspIsrOutput(void * chanp)
3990 status = Mcasp_localAbortReset(chanHandle); 4099 status = Mcasp_localAbortReset(chanHandle);
3991 } 4100 }
3992 break; 4101 break;
3993 } 4102 }
3994 4103 else
3995 /* if the error is a non- framesync error - we just send error *
3996 * status for the current packet in the callback function and *
3997 * continue with other packets for xfer */
3998 if (MCASP_ETIMEOUT != status)
3999 { 4104 {
4105 /* if the error is a non- framesync error - we just send error *
4106 * status for the current packet in the callback function and *
4107 * continue with other packets for xfer */
4108
4000 /* Disable Serializer, State machine and Frame sync of RCV * 4109 /* Disable Serializer, State machine and Frame sync of RCV *
4001 * Section.Also Disable EDMA Transfer. */ 4110 * Section.Also Disable EDMA Transfer. */
4002 Mcasp_localSmReset(chanHandle); 4111 status = Mcasp_localSmReset(chanHandle);
4003 4112
4004 /* Todo: note here we are replacing logic which set ccnt to 1, 4113 /* Todo: note here we are replacing logic which set ccnt to 1,
4005 * whereas before it was setting ccnt to 0. Further investigation 4114 * whereas before it was setting ccnt to 0. Further investigation
@@ -4019,9 +4128,10 @@ void mcaspIsrOutput(void * chanp)
4019 4128
4020 /* Enable Serializer, State machine and Frame sync of RCV * 4129 /* Enable Serializer, State machine and Frame sync of RCV *
4021 * Section. Also Enable EDMA Transfer. */ 4130 * Section. Also Enable EDMA Transfer. */
4022 Mcasp_localSmSet(chanHandle); 4131 (void)Mcasp_localSmSet(chanHandle);
4023 }/*for errors except sync errors*/ 4132 }/*for errors except sync errors*/
4024 }/*dma transfer for all errors*/ 4133 }/*dma transfer for all errors*/
4134 }
4025 }while(falsewhile); 4135 }while(falsewhile);
4026} 4136}
4027 4137
@@ -4047,8 +4157,8 @@ void mcaspIsrOutput(void * chanp)
4047 uint32_t tempVal1 = 0x00; 4157 uint32_t tempVal1 = 0x00;
4048 uint32_t tempVal2 = 0x00; 4158 uint32_t tempVal2 = 0x00;
4049 4159
4050 assert(NULL != instHandle); 4160 if(NULL != instHandle)
4051 4161 {
4052 tempVal1 = McASPGlobalCtlGet(instHandle->hwInfo.regs); 4162 tempVal1 = McASPGlobalCtlGet(instHandle->hwInfo.regs);
4053 tempVal2 = McASPRxGlobalCtlGet(instHandle->hwInfo.regs); 4163 tempVal2 = McASPRxGlobalCtlGet(instHandle->hwInfo.regs);
4054 /* If already this bit is set then don't set again */ 4164 /* If already this bit is set then don't set again */
@@ -4090,6 +4200,7 @@ void mcaspIsrOutput(void * chanp)
4090 4200
4091 } 4201 }
4092 } 4202 }
4203 }
4093} 4204}
4094 4205
4095/** 4206/**
@@ -4116,8 +4227,8 @@ void mcaspIsrOutput(void * chanp)
4116 4227
4117 temp_bitMaskVal = (0xFFFFFFFFu & (uint32_t)bitMaskVal); 4228 temp_bitMaskVal = (0xFFFFFFFFu & (uint32_t)bitMaskVal);
4118 4229
4119 assert(NULL != instHandle); 4230 if(NULL != instHandle)
4120 4231 {
4121 tempVal1 = McASPGlobalCtlGet(instHandle->hwInfo.regs); 4232 tempVal1 = McASPGlobalCtlGet(instHandle->hwInfo.regs);
4122 tempVal2 = McASPRxGlobalCtlGet(instHandle->hwInfo.regs); 4233 tempVal2 = McASPRxGlobalCtlGet(instHandle->hwInfo.regs);
4123 /* If already this bit is set then don't set again */ 4234 /* If already this bit is set then don't set again */
@@ -4148,6 +4259,7 @@ void mcaspIsrOutput(void * chanp)
4148 4259
4149 assert(0U != timeout); 4260 assert(0U != timeout);
4150 } 4261 }
4262 }
4151} 4263}
4152 4264
4153/** 4265/**
@@ -4171,8 +4283,8 @@ void mcaspIsrOutput(void * chanp)
4171 uint32_t tempVal1 = (uint32_t) 0x00U; 4283 uint32_t tempVal1 = (uint32_t) 0x00U;
4172 uint32_t tempVal2 = (uint32_t) 0x00U; 4284 uint32_t tempVal2 = (uint32_t) 0x00U;
4173 4285
4174 assert(NULL != instHandle); 4286 if(NULL != instHandle)
4175 4287 {
4176 tempVal1 = McASPGlobalCtlGet(instHandle->hwInfo.regs); 4288 tempVal1 = McASPGlobalCtlGet(instHandle->hwInfo.regs);
4177 tempVal2 = McASPTxGlobalCtlGet(instHandle->hwInfo.regs); 4289 tempVal2 = McASPTxGlobalCtlGet(instHandle->hwInfo.regs);
4178 4290
@@ -4215,6 +4327,7 @@ void mcaspIsrOutput(void * chanp)
4215 } 4327 }
4216 } 4328 }
4217 } 4329 }
4330 }
4218} 4331}
4219 4332
4220/** 4333/**
@@ -4240,8 +4353,8 @@ void mcaspIsrOutput(void * chanp)
4240 uint32_t tempVal1 = 0U; 4353 uint32_t tempVal1 = 0U;
4241 uint32_t tempVal2 = 0U; 4354 uint32_t tempVal2 = 0U;
4242 4355
4243 assert(NULL != instHandle); 4356 if(NULL != instHandle)
4244 4357 {
4245 tempVal1 = McASPGlobalCtlGet(instHandle->hwInfo.regs); 4358 tempVal1 = McASPGlobalCtlGet(instHandle->hwInfo.regs);
4246 tempVal2 = McASPTxGlobalCtlGet(instHandle->hwInfo.regs); 4359 tempVal2 = McASPTxGlobalCtlGet(instHandle->hwInfo.regs);
4247 temp_bitMaskVal = (0xFFFFFFFFu & (uint32_t)bitMaskVal); 4360 temp_bitMaskVal = (0xFFFFFFFFu & (uint32_t)bitMaskVal);
@@ -4274,6 +4387,7 @@ void mcaspIsrOutput(void * chanp)
4274 } 4387 }
4275 assert(0U != timeout); 4388 assert(0U != timeout);
4276 } 4389 }
4390 }
4277} 4391}
4278 4392
4279/* 4393/*
@@ -4293,13 +4407,11 @@ void mcaspIsrOutput(void * chanp)
4293 void mcaspSetSerXmt(Mcasp_HwHandle hMcasp, 4407 void mcaspSetSerXmt(Mcasp_HwHandle hMcasp,
4294 Mcasp_SerializerNum serNum) 4408 Mcasp_SerializerNum serNum)
4295{ 4409{
4296 assert(NULL != hMcasp); 4410 if( (NULL != hMcasp) && (serNum < hMcasp->numOfSerializers) )
4297 4411 {
4298 assert(serNum < hMcasp->numOfSerializers); 4412 McASPSerializerTxSet(hMcasp->regs, serNum);
4299 4413 McASPPinDirOutputSet(hMcasp->regs, ((uint32_t) 1U << serNum));
4300 McASPSerializerTxSet(hMcasp->regs, serNum); 4414 }
4301
4302 McASPPinDirOutputSet(hMcasp->regs, ((uint32_t) 1U << serNum));
4303} 4415}
4304 4416
4305/* 4417/*
@@ -4319,12 +4431,11 @@ void mcaspIsrOutput(void * chanp)
4319 void mcaspSetSerRcv(Mcasp_HwHandle hMcasp, 4431 void mcaspSetSerRcv(Mcasp_HwHandle hMcasp,
4320 Mcasp_SerializerNum serNum) 4432 Mcasp_SerializerNum serNum)
4321{ 4433{
4322 assert(NULL != hMcasp); 4434 if( (NULL != hMcasp) && (serNum < hMcasp->numOfSerializers) )
4323 assert(serNum < hMcasp->numOfSerializers); 4435 {
4324 4436 McASPSerializerRxSet(hMcasp->regs, serNum);
4325 McASPSerializerRxSet(hMcasp->regs, serNum); 4437 McASPPinDirInputSet(hMcasp->regs, ((uint32_t) 1U << serNum));
4326 4438 }
4327 McASPPinDirInputSet(hMcasp->regs, ((uint32_t) 1U << serNum));
4328} 4439}
4329 4440
4330/** 4441/**
@@ -4349,8 +4460,8 @@ void mcaspIsrOutput(void * chanp)
4349 int32_t status = MCASP_COMPLETED; 4460 int32_t status = MCASP_COMPLETED;
4350 uint32_t tempVal = 0x0; 4461 uint32_t tempVal = 0x0;
4351 4462
4352 assert(NULL != hMcasp); 4463 if(NULL != hMcasp)
4353 4464 {
4354 if (TRUE == hMcasp->ditStatus) 4465 if (TRUE == hMcasp->ditStatus)
4355 { 4466 {
4356 tempVal = McASPGlobalCtlGet(hMcasp->regs); 4467 tempVal = McASPGlobalCtlGet(hMcasp->regs);
@@ -4366,7 +4477,11 @@ void mcaspIsrOutput(void * chanp)
4366 McASPDITModeCtlWrite(hMcasp->regs, 4477 McASPDITModeCtlWrite(hMcasp->regs,
4367 ((uint32_t) ditFlag << MCASP_TXDITCTL_DITEN_SHIFT)); 4478 ((uint32_t) ditFlag << MCASP_TXDITCTL_DITEN_SHIFT));
4368 } 4479 }
4369 4480 }
4481 else
4482 {
4483 status = MCASP_EBADARGS;
4484 }
4370 return (status); 4485 return (status);
4371} 4486}
4372 4487
@@ -4401,7 +4516,6 @@ void mcaspIsrOutput(void * chanp)
4401 Uns hwiKey = 0; 4516 Uns hwiKey = 0;
4402 Mcasp_Object *instHandle = NULL; 4517 Mcasp_Object *instHandle = NULL;
4403 void * arg; 4518 void * arg;
4404 uint32_t temp_var = 0U;
4405 int32_t retVal = MCASP_COMPLETED; 4519 int32_t retVal = MCASP_COMPLETED;
4406 int i = 0; 4520 int i = 0;
4407 OsalRegisterIntrParams_t interruptRegParams; 4521 OsalRegisterIntrParams_t interruptRegParams;
@@ -4409,15 +4523,11 @@ void mcaspIsrOutput(void * chanp)
4409 MuxIntcP_inParams muxInParams; 4523 MuxIntcP_inParams muxInParams;
4410 MuxIntcP_outParams muxOutParams; 4524 MuxIntcP_outParams muxOutParams;
4411 HwiP_Handle hwiHandle = NULL; 4525 HwiP_Handle hwiHandle = NULL;
4412 assert((NULL != chanp) && (NULL != intIsr)); 4526 if((NULL != chanp) && (NULL != ((Mcasp_ChannelHandle)chanp)->devHandle) && (NULL != intIsr))
4413 4527 {
4414 /* get the handle to the channel to register the interrupt */ 4528 /* get the handle to the channel to register the interrupt */
4415 chanHandle = (Mcasp_ChannelHandle)chanp; 4529 chanHandle = (Mcasp_ChannelHandle)chanp;
4416
4417 assert((NULL != chanHandle) && (NULL != chanHandle->devHandle));
4418
4419 instHandle = (Mcasp_Object *)chanHandle->devHandle; 4530 instHandle = (Mcasp_Object *)chanHandle->devHandle;
4420 assert(NULL != instHandle);
4421 4531
4422 if ((MCASP_INPUT != chanHandle->mode) && (MCASP_OUTPUT != chanHandle->mode)) 4532 if ((MCASP_INPUT != chanHandle->mode) && (MCASP_OUTPUT != chanHandle->mode))
4423 { 4533 {
@@ -4435,7 +4545,6 @@ void mcaspIsrOutput(void * chanp)
4435 * interrupts */ 4545 * interrupts */
4436 Mcasp_module.isrObject[instNum].chanEnabled[chanHandle->mode - 1] = (Bool)TRUE; 4546 Mcasp_module.isrObject[instNum].chanEnabled[chanHandle->mode - 1] = (Bool)TRUE;
4437 4547
4438 temp_var = temp_var;
4439 /* update the information of the instance which is registering the ISR */ 4548 /* update the information of the instance which is registering the ISR */
4440 if ((Bool) FALSE == 4549 if ((Bool) FALSE ==
4441 Mcasp_module.isrObject[instNum].isIsrRegistered[chanHandle->mode - 4550 Mcasp_module.isrObject[instNum].isIsrRegistered[chanHandle->mode -
@@ -4529,7 +4638,11 @@ void mcaspIsrOutput(void * chanp)
4529 { /* interrupts cannot be registered for an invalid mcasp instance */ 4638 { /* interrupts cannot be registered for an invalid mcasp instance */
4530 assert(FALSE); 4639 assert(FALSE);
4531 } 4640 }
4532 4641 }
4642 else
4643 {
4644 retVal = MCASP_EBADARGS;
4645 }
4533} 4646}
4534 4647
4535/** 4648/**
@@ -4609,9 +4722,12 @@ void mcaspIsrOutput(void * chanp)
4609 * 4722 *
4610 * \leave Not implemented 4723 * \leave Not implemented
4611 */ 4724 */
4612void Mcasp_localDeactivateSmFsForRcv(const Mcasp_Object *instHandle) 4725int32_t Mcasp_localDeactivateSmFsForRcv(const Mcasp_Object *instHandle)
4613{ 4726{
4614 assert(NULL != instHandle); 4727 int32_t status = MCASP_COMPLETED;
4728
4729 if(NULL != instHandle)
4730 {
4615 4731
4616 /*frame sync*/ 4732 /*frame sync*/
4617 mcaspBitRemoveGblRCtl(instHandle, ~((uint32_t) MCASP_GBLCTLR_RFRST_MASK)); 4733 mcaspBitRemoveGblRCtl(instHandle, ~((uint32_t) MCASP_GBLCTLR_RFRST_MASK));
@@ -4638,6 +4754,12 @@ void Mcasp_localDeactivateSmFsForRcv(const Mcasp_Object *instHandle)
4638 (uint32_t) MCASP_RXSTAT_RCKFAIL_MASK | 4754 (uint32_t) MCASP_RXSTAT_RCKFAIL_MASK |
4639 (uint32_t) MCASP_RXSTAT_RSYNCERR_MASK | 4755 (uint32_t) MCASP_RXSTAT_RSYNCERR_MASK |
4640 (uint32_t) MCASP_RXSTAT_ROVRN_MASK)); 4756 (uint32_t) MCASP_RXSTAT_ROVRN_MASK));
4757 }
4758 else
4759 {
4760 status = MCASP_EBADARGS;
4761 }
4762 return(status);
4641} 4763}
4642 4764
4643/** 4765/**
@@ -4652,9 +4774,12 @@ void Mcasp_localDeactivateSmFsForRcv(const Mcasp_Object *instHandle)
4652 * 4774 *
4653 * \leave Not implemented 4775 * \leave Not implemented
4654 */ 4776 */
4655void Mcasp_localDeactivateSmFsForXmt(const Mcasp_Object *instHandle) 4777int32_t Mcasp_localDeactivateSmFsForXmt(const Mcasp_Object *instHandle)
4656{ 4778{
4657 assert(NULL != instHandle); 4779 int32_t status = MCASP_COMPLETED;
4780
4781 if(NULL != instHandle)
4782 {
4658 4783
4659 /*Start the Serializer, State M/C and Frame Sync Generator*/ 4784 /*Start the Serializer, State M/C and Frame Sync Generator*/
4660 mcaspBitRemoveGblXCtl(instHandle, ~((uint32_t) MCASP_GBLCTLX_XFRST_MASK)); 4785 mcaspBitRemoveGblXCtl(instHandle, ~((uint32_t) MCASP_GBLCTLX_XFRST_MASK));
@@ -4678,6 +4803,12 @@ void Mcasp_localDeactivateSmFsForXmt(const Mcasp_Object *instHandle)
4678 (uint32_t) MCASP_TXSTAT_XCKFAIL_MASK | 4803 (uint32_t) MCASP_TXSTAT_XCKFAIL_MASK |
4679 (uint32_t) MCASP_TX_STAT_SYNCERR | 4804 (uint32_t) MCASP_TX_STAT_SYNCERR |
4680 (uint32_t) MCASP_TX_STAT_UNDERRUN)); 4805 (uint32_t) MCASP_TX_STAT_UNDERRUN));
4806 }
4807 else
4808 {
4809 status = MCASP_EBADARGS;
4810 }
4811 return(status);
4681} 4812}
4682 4813
4683/** 4814/**
@@ -4704,8 +4835,8 @@ void Mcasp_localDeactivateSmFsForXmt(const Mcasp_Object *instHandle)
4704 Bool status = (Bool)TRUE; 4835 Bool status = (Bool)TRUE;
4705 Bool falsewhile = (Bool)TRUE; 4836 Bool falsewhile = (Bool)TRUE;
4706 4837
4707 assert((NULL != instHandle) && (NULL != params)); 4838 if((NULL != instHandle) && (NULL != params))
4708 4839 {
4709 do 4840 do
4710 { 4841 {
4711 falsewhile = (Bool)FALSE; 4842 falsewhile = (Bool)FALSE;
@@ -4723,7 +4854,7 @@ void Mcasp_localDeactivateSmFsForXmt(const Mcasp_Object *instHandle)
4723 } 4854 }
4724 } 4855 }
4725 }while(falsewhile); 4856 }while(falsewhile);
4726 4857 }
4727 return (status); 4858 return (status);
4728} 4859}
4729 4860
@@ -4750,8 +4881,8 @@ void Mcasp_localDeactivateSmFsForXmt(const Mcasp_Object *instHandle)
4750 uint32_t serNum = 0; 4881 uint32_t serNum = 0;
4751 Mcasp_SerializerNum serializerToConfigure = (Mcasp_SerializerNum)0; 4882 Mcasp_SerializerNum serializerToConfigure = (Mcasp_SerializerNum)0;
4752 4883
4753 assert((NULL != instHandle) && (NULL != params)); 4884 if((NULL != instHandle) && (NULL != params))
4754 4885 {
4755 chanParams = (Mcasp_ChanParams *)params; 4886 chanParams = (Mcasp_ChanParams *)params;
4756 4887
4757 for (count = 0; count < chanParams->noOfSerRequested; count++) 4888 for (count = 0; count < chanParams->noOfSerRequested; count++)
@@ -4768,6 +4899,7 @@ void Mcasp_localDeactivateSmFsForXmt(const Mcasp_Object *instHandle)
4768 mcaspSetSerRcv(&(instHandle->hwInfo),serializerToConfigure); 4899 mcaspSetSerRcv(&(instHandle->hwInfo),serializerToConfigure);
4769 } 4900 }
4770 } 4901 }
4902 }
4771} 4903}
4772 4904
4773 4905
@@ -4795,8 +4927,8 @@ void Mcasp_localDeactivateSmFsForXmt(const Mcasp_Object *instHandle)
4795 uint32_t serNum = 0; 4927 uint32_t serNum = 0;
4796 Mcasp_SerializerNum serializerToConfigure = (Mcasp_SerializerNum)0; 4928 Mcasp_SerializerNum serializerToConfigure = (Mcasp_SerializerNum)0;
4797 4929
4798 assert((NULL != instHandle) && (NULL != params)); 4930 if((NULL != instHandle) && (NULL != params))
4799 4931 {
4800 chanParams = (Mcasp_ChanParams *)params; 4932 chanParams = (Mcasp_ChanParams *)params;
4801 4933
4802 for (count = 0; count < chanParams->noOfSerRequested; count++) 4934 for (count = 0; count < chanParams->noOfSerRequested; count++)
@@ -4814,6 +4946,7 @@ void Mcasp_localDeactivateSmFsForXmt(const Mcasp_Object *instHandle)
4814 mcaspSetSerXmt(&(instHandle->hwInfo),serializerToConfigure); 4946 mcaspSetSerXmt(&(instHandle->hwInfo),serializerToConfigure);
4815 } 4947 }
4816 } 4948 }
4949 }
4817 4950
4818} 4951}
4819 4952
@@ -4832,18 +4965,14 @@ void Mcasp_localDeactivateSmFsForXmt(const Mcasp_Object *instHandle)
4832 */ 4965 */
4833 void mcaspMultiSerGlobalRestore(void* chanp) 4966 void mcaspMultiSerGlobalRestore(void* chanp)
4834{ 4967{
4835 Mcasp_ChannelHandle chanHandle = NULL; 4968 Mcasp_ChannelHandle chanHandle = NULL;
4836 Mcasp_Object *instHandle = NULL; 4969 Mcasp_Object *instHandle = NULL;
4837 uint32_t serNum = 0; 4970 uint32_t serNum = 0;
4838
4839 assert(NULL != chanp);
4840
4841 chanHandle = (Mcasp_ChannelHandle)chanp;
4842
4843 assert(NULL != chanHandle->devHandle);
4844 4971
4845 instHandle = (Mcasp_Object *)chanHandle->devHandle; 4972 if ( (NULL != chanp) && (NULL != ((Mcasp_ChannelHandle)chanp)->devHandle))
4846 assert(NULL != instHandle); 4973 {
4974 chanHandle = (Mcasp_ChannelHandle)chanp;
4975 instHandle = (Mcasp_Object *)chanHandle->devHandle;
4847 4976
4848 for (serNum=0; serNum < chanHandle->noOfSerAllocated; serNum++) 4977 for (serNum=0; serNum < chanHandle->noOfSerAllocated; serNum++)
4849 { 4978 {
@@ -4853,6 +4982,7 @@ void Mcasp_localDeactivateSmFsForXmt(const Mcasp_Object *instHandle)
4853 McASPSerializerInactivate(instHandle->hwInfo.regs, chanHandle->indexOfSersRequested[serNum]); 4982 McASPSerializerInactivate(instHandle->hwInfo.regs, chanHandle->indexOfSersRequested[serNum]);
4854 McASPPinDirInputSet(instHandle->hwInfo.regs, ((uint32_t) 1U << chanHandle->indexOfSersRequested[serNum])); 4983 McASPPinDirInputSet(instHandle->hwInfo.regs, ((uint32_t) 1U << chanHandle->indexOfSersRequested[serNum]));
4855 } 4984 }
4985 }
4856} 4986}
4857 4987
4858 4988
@@ -4878,8 +5008,8 @@ void Mcasp_localDeactivateSmFsForXmt(const Mcasp_Object *instHandle)
4878 int32_t status = MCASP_COMPLETED; 5008 int32_t status = MCASP_COMPLETED;
4879 Bool falsewhile = (Bool)TRUE; 5009 Bool falsewhile = (Bool)TRUE;
4880 5010
4881 assert((NULL != instHandle) && (NULL != params)); 5011 if((NULL != instHandle) && (NULL != params))
4882 5012 {
4883 do 5013 do
4884 { 5014 {
4885 falsewhile = (Bool)FALSE; 5015 falsewhile = (Bool)FALSE;
@@ -4916,7 +5046,11 @@ void Mcasp_localDeactivateSmFsForXmt(const Mcasp_Object *instHandle)
4916 } 5046 }
4917 5047
4918 }while(falsewhile); 5048 }while(falsewhile);
4919 5049 }
5050 else
5051 {
5052 status = MCASP_EBADARGS;
5053 }
4920 return(status); 5054 return(status);
4921} 5055}
4922 5056
@@ -4943,8 +5077,8 @@ void Mcasp_localDeactivateSmFsForXmt(const Mcasp_Object *instHandle)
4943 Mcasp_ChanParams *chanParams = NULL; 5077 Mcasp_ChanParams *chanParams = NULL;
4944 int32_t status = MCASP_COMPLETED ; 5078 int32_t status = MCASP_COMPLETED ;
4945 5079
4946 assert((NULL != instHandle) && (NULL != params)); 5080 if((NULL != instHandle) && (NULL != params))
4947 5081 {
4948 chanParams = (Mcasp_ChanParams *)params; 5082 chanParams = (Mcasp_ChanParams *)params;
4949 5083
4950 /* before touching McASP registers, place receive section in reset */ 5084 /* before touching McASP registers, place receive section in reset */
@@ -4959,6 +5093,11 @@ void Mcasp_localDeactivateSmFsForXmt(const Mcasp_Object *instHandle)
4959 chanParams->mcaspSetup); 5093 chanParams->mcaspSetup);
4960 5094
4961 } 5095 }
5096 }
5097 else
5098 {
5099 status = MCASP_EBADARGS;
5100 }
4962 return (status); 5101 return (status);
4963} 5102}
4964 5103
@@ -4984,9 +5123,7 @@ void Mcasp_localDeactivateSmFsForXmt(const Mcasp_Object *instHandle)
4984{ 5123{
4985 int32_t status = MCASP_COMPLETED; 5124 int32_t status = MCASP_COMPLETED;
4986 5125
4987 assert((NULL != hMcasp) && (NULL != chanStatRam)); 5126 if((NULL != hMcasp) && (TRUE == hMcasp->ditStatus) && (NULL != chanStatRam))
4988
4989 if (TRUE == hMcasp->ditStatus)
4990 { 5127 {
4991 /* Configure the DIT left channel status registers */ 5128 /* Configure the DIT left channel status registers */
4992 McASPDITLeftChanStatusSet( 5129 McASPDITLeftChanStatusSet(
@@ -5042,7 +5179,6 @@ void Mcasp_localDeactivateSmFsForXmt(const Mcasp_Object *instHandle)
5042 { 5179 {
5043 status = MCASP_EBADARGS; 5180 status = MCASP_EBADARGS;
5044 } 5181 }
5045
5046 return (status); 5182 return (status);
5047} 5183}
5048 5184
@@ -5067,9 +5203,7 @@ void Mcasp_localDeactivateSmFsForXmt(const Mcasp_Object *instHandle)
5067{ 5203{
5068 int32_t status = MCASP_COMPLETED; 5204 int32_t status = MCASP_COMPLETED;
5069 5205
5070 assert((NULL != hMcasp) && (NULL != userDataRam)); 5206 if((NULL != hMcasp) && (TRUE == hMcasp->ditStatus) && (NULL != userDataRam))
5071
5072 if (TRUE == hMcasp->ditStatus)
5073 { 5207 {
5074 /* Configure the DIT left user data registers */ 5208 /* Configure the DIT left user data registers */
5075 McASPDITLeftUserDataRamSet(hMcasp->regs, (uint32_t) 0, 5209 McASPDITLeftUserDataRamSet(hMcasp->regs, (uint32_t) 0,
@@ -5150,9 +5284,8 @@ void Mcasp_localDeactivateSmFsForXmt(const Mcasp_Object *instHandle)
5150 5284
5151{ 5285{
5152 /* validate the input parameters */ 5286 /* validate the input parameters */
5153 assert((NULL != hMcasp) && (NULL != hMcasp->fifoRegs) 5287 if((NULL != hMcasp) && (NULL != hMcasp->fifoRegs) && (NULL != chanHandle))
5154 && (NULL != chanHandle)); 5288 {
5155
5156 /* check if the HW FIFO usage is requested by the user for this channel */ 5289 /* check if the HW FIFO usage is requested by the user for this channel */
5157 if (TRUE == enableHwFifo) 5290 if (TRUE == enableHwFifo)
5158 { 5291 {
@@ -5189,6 +5322,7 @@ void Mcasp_localDeactivateSmFsForXmt(const Mcasp_Object *instHandle)
5189 McASPWriteFifoDisable(hMcasp->regs); 5322 McASPWriteFifoDisable(hMcasp->regs);
5190 } 5323 }
5191 } 5324 }
5325 }
5192} 5326}
5193 5327
5194 5328
@@ -5217,8 +5351,8 @@ void Mcasp_localDeactivateSmFsForXmt(const Mcasp_Object *instHandle)
5217 uint32_t tempVar = 0x0; 5351 uint32_t tempVar = 0x0;
5218 int32_t status = MCASP_COMPLETED; 5352 int32_t status = MCASP_COMPLETED;
5219 5353
5220 assert((NULL != chanHandle) && (params != NULL)); 5354 if((NULL != chanHandle) && (params != NULL))
5221 5355 {
5222 /* get the number of slots to be configured */ 5356 /* get the number of slots to be configured */
5223 tempVar = ((0x0000FF80u) & params->mcaspSetup->frSyncCtl); 5357 tempVar = ((0x0000FF80u) & params->mcaspSetup->frSyncCtl);
5224 tempVar = tempVar >> 7; 5358 tempVar = tempVar >> 7;
@@ -5281,6 +5415,11 @@ void Mcasp_localDeactivateSmFsForXmt(const Mcasp_Object *instHandle)
5281 /* copy the data format to the channel structure */ 5415 /* copy the data format to the channel structure */
5282 chanHandle->dataFormat = params->dataFormat; 5416 chanHandle->dataFormat = params->dataFormat;
5283 } 5417 }
5418 }
5419 else
5420 {
5421 status = MCASP_EBADARGS;
5422 }
5284 return status; 5423 return status;
5285} 5424}
5286 5425
@@ -5328,8 +5467,8 @@ int32_t Mcasp_localIsValidPacket(Mcasp_ChannelHandle chanHandle)
5328 { 5467 {
5329 falsewhile = FALSE; 5468 falsewhile = FALSE;
5330 5469
5331 assert((NULL != chanHandle) && (NULL != chanHandle->devHandle)); 5470 if((NULL != chanHandle) && (NULL != chanHandle->devHandle))
5332 5471 {
5333 /* Present request validation for int mode transfer */ 5472 /* Present request validation for int mode transfer */
5334 if (((FALSE == chanHandle->isDmaDriven) 5473 if (((FALSE == chanHandle->isDmaDriven)
5335 && (NULL != chanHandle->dataPacket)) 5474 && (NULL != chanHandle->dataPacket))
@@ -5398,6 +5537,11 @@ int32_t Mcasp_localIsValidPacket(Mcasp_ChannelHandle chanHandle)
5398 } 5537 }
5399 } /* Request List queue Empty is TRUE if loop */ 5538 } /* Request List queue Empty is TRUE if loop */
5400 } 5539 }
5540 }
5541 else
5542 {
5543 status = MCASP_EBADARGS;
5544 }
5401 }while(falsewhile); 5545 }while(falsewhile);
5402 5546
5403 return status; 5547 return status;
@@ -5425,11 +5569,11 @@ void Mcasp_localLoadPktToDma(Mcasp_ChannelObj *chanHandle,MCASP_Packet *ioPacket
5425 uint32_t hwiKey = 0; 5569 uint32_t hwiKey = 0;
5426 uint32_t temp_var = 0U; 5570 uint32_t temp_var = 0U;
5427 5571
5428 assert(NULL != chanHandle); 5572
5429 assert(NULL != ioPacket); 5573 if( (NULL != chanHandle) && (NULL!= chanHandle->devHandle) && (NULL != ioPacket) )
5574 {
5430 5575
5431 instHandle = (Mcasp_Object *)chanHandle->devHandle; 5576 instHandle = (Mcasp_Object *)chanHandle->devHandle;
5432 assert(NULL != instHandle);
5433 5577
5434 do 5578 do
5435 { 5579 {
@@ -5438,9 +5582,10 @@ void Mcasp_localLoadPktToDma(Mcasp_ChannelObj *chanHandle,MCASP_Packet *ioPacket
5438 if (TRUE == instHandle->isDataBufferPayloadStructure) 5582 if (TRUE == instHandle->isDataBufferPayloadStructure)
5439 { 5583 {
5440 payLoad = (Mcasp_PktAddrPayload *)ioPacket->addr; 5584 payLoad = (Mcasp_PktAddrPayload *)ioPacket->addr;
5441 assert(NULL != payLoad);
5442 } 5585 }
5443 5586
5587 if(payLoad != NULL)
5588 {
5444 /* For a DIT request, channel has to be programmed with its contents* 5589 /* For a DIT request, channel has to be programmed with its contents*
5445 * (DIT RAM registers also if this is an xmt channel in DIT mode). */ 5590 * (DIT RAM registers also if this is an xmt channel in DIT mode). */
5446 if (Mcasp_ChanMode_RCV != chanHandle->channelOpMode) 5591 if (Mcasp_ChanMode_RCV != chanHandle->channelOpMode)
@@ -5565,18 +5710,20 @@ void Mcasp_localLoadPktToDma(Mcasp_ChannelObj *chanHandle,MCASP_Packet *ioPacket
5565 { 5710 {
5566 /* Receive channel */ 5711 /* Receive channel */
5567 /* activate RX and TX state machine and frame sync*/ 5712 /* activate RX and TX state machine and frame sync*/
5568 Mcasp_localActivateSmFsForRcv(instHandle); 5713 status = Mcasp_localActivateSmFsForRcv(instHandle);
5569 } 5714 }
5570 else 5715 else
5571 { 5716 {
5572 /* Transmit channel */ 5717 /* Transmit channel */
5573 /* activate RX and TX state machine and frame sync*/ 5718 /* activate RX and TX state machine and frame sync*/
5574 Mcasp_localActivateSmFsForXmt(instHandle); 5719 status = Mcasp_localActivateSmFsForXmt(instHandle);
5575 } 5720 }
5576#endif 5721#endif
5577 } 5722 }
5578 } 5723 }
5724 }
5579 } while (falseWhile); 5725 } while (falseWhile);
5726 }
5580} 5727}
5581 5728
5582 5729
@@ -5606,9 +5753,8 @@ void Mcasp_swiTxFifo(void * arg0,void * arg1)
5606 chanHandle = (Mcasp_ChannelObj *)arg0; 5753 chanHandle = (Mcasp_ChannelObj *)arg0;
5607 instHandle = (Mcasp_Object *)arg1; 5754 instHandle = (Mcasp_Object *)arg1;
5608 5755
5609 assert(NULL != chanHandle); 5756 if( (NULL != chanHandle) && (NULL != instHandle))
5610 assert(NULL != instHandle); 5757 {
5611
5612 /* update the timeout value from the instance handle */ 5758 /* update the timeout value from the instance handle */
5613 timeOut = instHandle->retryCount; 5759 timeOut = instHandle->retryCount;
5614 5760
@@ -5650,13 +5796,13 @@ void Mcasp_swiTxFifo(void * arg0,void * arg1)
5650 /* Now we can disable the frame sync */ 5796 /* Now we can disable the frame sync */
5651 if (MCASP_LBCTL_DLBEN_ENABLE == dlbMode) 5797 if (MCASP_LBCTL_DLBEN_ENABLE == dlbMode)
5652 { 5798 {
5653 Mcasp_localDeactivateSmFsForRcv(instHandle); 5799 (void)Mcasp_localDeactivateSmFsForRcv(instHandle);
5654 Mcasp_localDeactivateSmFsForXmt(instHandle); 5800 (void)Mcasp_localDeactivateSmFsForXmt(instHandle);
5655 } 5801 }
5656 else 5802 else
5657 { 5803 {
5658 /* Reset state m/c & frame sync of TX section */ 5804 /* Reset state m/c & frame sync of TX section */
5659 Mcasp_localDeactivateSmFsForXmt(instHandle); 5805 (void)Mcasp_localDeactivateSmFsForXmt(instHandle);
5660 } 5806 }
5661 5807
5662 /* Disable the FIFO */ 5808 /* Disable the FIFO */
@@ -5697,6 +5843,7 @@ void Mcasp_swiTxFifo(void * arg0,void * arg1)
5697 Mcasp_localHandlePwrmEvent(instHandle,chanHandle); 5843 Mcasp_localHandlePwrmEvent(instHandle,chanHandle);
5698 } 5844 }
5699#endif /* #ifdef BIOS_PWRM_ENABLE */ 5845#endif /* #ifdef BIOS_PWRM_ENABLE */
5846 }
5700} 5847}
5701 5848
5702 5849
@@ -5719,8 +5866,8 @@ int32_t Mcasp_loadPendedIops(Mcasp_ChannelObj *chanHandle)
5719 uint32_t hwiKey = 0x00; 5866 uint32_t hwiKey = 0x00;
5720 uint32_t tempSubmitCount = 0x00; 5867 uint32_t tempSubmitCount = 0x00;
5721 5868
5722 assert(NULL != chanHandle); 5869 if(NULL != chanHandle)
5723 5870 {
5724 /* reset the submit count to indicate we are loading the first packet */ 5871 /* reset the submit count to indicate we are loading the first packet */
5725 tempSubmitCount = (uint32_t)chanHandle->submitCount; 5872 tempSubmitCount = (uint32_t)chanHandle->submitCount;
5726 chanHandle->submitCount = 0x00; 5873 chanHandle->submitCount = 0x00;
@@ -5753,7 +5900,11 @@ int32_t Mcasp_loadPendedIops(Mcasp_ChannelObj *chanHandle)
5753 /* restore the submit count */ 5900 /* restore the submit count */
5754 chanHandle->submitCount = (int32_t)tempSubmitCount; 5901 chanHandle->submitCount = (int32_t)tempSubmitCount;
5755 HwiP_restore(hwiKey); 5902 HwiP_restore(hwiKey);
5756 5903 }
5904 else
5905 {
5906 status = MCASP_EBADARGS;
5907 }
5757 return status; 5908 return status;
5758} 5909}
5759 5910
@@ -5785,7 +5936,8 @@ int32_t Mcasp_localLpscOn(const Mcasp_Object *instHandle)
5785{ 5936{
5786 int32_t status = MCASP_COMPLETED; 5937 int32_t status = MCASP_COMPLETED;
5787 5938
5788 assert(NULL != instHandle); 5939 if(NULL != instHandle)
5940 {
5789 if (TRUE == instHandle->pscPwrmEnable) 5941 if (TRUE == instHandle->pscPwrmEnable)
5790 { 5942 {
5791#ifdef BIOS_PWRM_ENABLE 5943#ifdef BIOS_PWRM_ENABLE
@@ -5802,6 +5954,11 @@ status = Psc_ModuleClkCtrl(
5802#endif 5954#endif
5803#endif 5955#endif
5804 } 5956 }
5957 }
5958 else
5959 {
5960 status = MCASP_EBADARGS;
5961 }
5805 return (status); 5962 return (status);
5806} 5963}
5807 5964
@@ -5823,8 +5980,8 @@ int32_t Mcasp_localLpscOff(const Mcasp_Object *instHandle)
5823{ 5980{
5824 int32_t status = MCASP_COMPLETED; 5981 int32_t status = MCASP_COMPLETED;
5825 5982
5826 assert(NULL != instHandle); 5983 if(NULL != instHandle)
5827 5984 {
5828 if (TRUE == instHandle->pscPwrmEnable) 5985 if (TRUE == instHandle->pscPwrmEnable)
5829 { 5986 {
5830#ifdef BIOS_PWRM_ENABLE 5987#ifdef BIOS_PWRM_ENABLE
@@ -5841,6 +5998,11 @@ int32_t Mcasp_localLpscOff(const Mcasp_Object *instHandle)
5841#endif 5998#endif
5842#endif 5999#endif
5843 } 6000 }
6001 }
6002 else
6003 {
6004 status = MCASP_EBADARGS;
6005 }
5844 return (status); 6006 return (status);
5845} 6007}
5846 6008
@@ -5864,9 +6026,8 @@ void Mcasp_localHandlePwrmEvent(Mcasp_Object *instHandle,
5864 uint32_t dlbMode = 0x00; 6026 uint32_t dlbMode = 0x00;
5865 uint32_t tempVal = 0x00; 6027 uint32_t tempVal = 0x00;
5866 6028
5867 assert(NULL != instHandle); 6029 if( (NULL != instHandle) && (NULL != chanHandle) )
5868 assert(NULL != chanHandle); 6030 {
5869
5870 /* check if the driver is waiting to go to sleep */ 6031 /* check if the driver is waiting to go to sleep */
5871 if ((TRUE == instHandle->pscPwrmEnable) && 6032 if ((TRUE == instHandle->pscPwrmEnable) &&
5872 (TRUE == instHandle->pwrmInfo.ioSuspend)) 6033 (TRUE == instHandle->pwrmInfo.ioSuspend))
@@ -5909,8 +6070,8 @@ void Mcasp_localHandlePwrmEvent(Mcasp_Object *instHandle,
5909 6070
5910 if (MCASP_LBCTL_DLBEN_ENABLE == dlbMode) 6071 if (MCASP_LBCTL_DLBEN_ENABLE == dlbMode)
5911 { 6072 {
5912 Mcasp_localDeactivateSmFsForRcv(instHandle); 6073 (void)Mcasp_localDeactivateSmFsForRcv(instHandle);
5913 Mcasp_localDeactivateSmFsForXmt(instHandle); 6074 (void)Mcasp_localDeactivateSmFsForXmt(instHandle);
5914 } 6075 }
5915 else 6076 else
5916 { 6077 {
@@ -5919,7 +6080,7 @@ void Mcasp_localHandlePwrmEvent(Mcasp_Object *instHandle,
5919 if (Mcasp_ChanMode_RCV == chanHandle->channelOpMode) 6080 if (Mcasp_ChanMode_RCV == chanHandle->channelOpMode)
5920 { 6081 {
5921 /* Reset state m/c & frame sync of receive section */ 6082 /* Reset state m/c & frame sync of receive section */
5922 Mcasp_localDeactivateSmFsForRcv(instHandle); 6083 (void)Mcasp_localDeactivateSmFsForRcv(instHandle);
5923 6084
5924 /* reenable the RCV overrun error */ 6085 /* reenable the RCV overrun error */
5925 if (MCASP_RX_OVERRUN == 6086 if (MCASP_RX_OVERRUN ==
@@ -5978,7 +6139,12 @@ void Mcasp_localHandlePwrmEvent(Mcasp_Object *instHandle,
5978 (instHandle->pwrmInfo.delayedCompletionFxn \ 6139 (instHandle->pwrmInfo.delayedCompletionFxn \
5979 [instHandle->pwrmInfo.pwrmEvent])(); 6140 [instHandle->pwrmInfo.pwrmEvent])();
5980 } 6141 }
5981 } 6142 }
6143 }
6144 else
6145 {
6146 status = MCASP_EBADARGS;
6147 }
5982} 6148}
5983 6149
5984/** 6150/**
@@ -5999,8 +6165,8 @@ void Mcasp_localHandlePwrmEvent(Mcasp_Object *instHandle,
5999 Power_Status retVal = Power_SOK; 6165 Power_Status retVal = Power_SOK;
6000 int32_t status = MCASP_COMPLETED; 6166 int32_t status = MCASP_COMPLETED;
6001 6167
6002 assert(NULL != instHandle); 6168 if(NULL != instHandle)
6003 6169 {
6004 /* register for the events to be notified by the driver */ 6170 /* register for the events to be notified by the driver */
6005 for (eventCnt = 0; eventCnt < Mcasp_MAX_PWRM_EVENTS; eventCnt++) 6171 for (eventCnt = 0; eventCnt < Mcasp_MAX_PWRM_EVENTS; eventCnt++)
6006 { 6172 {
@@ -6019,6 +6185,11 @@ void Mcasp_localHandlePwrmEvent(Mcasp_Object *instHandle,
6019 break; 6185 break;
6020 } 6186 }
6021 } 6187 }
6188 }
6189 else
6190 {
6191 status = MCASP_EBADARGS;
6192 }
6022 return (status); 6193 return (status);
6023} 6194}
6024 6195
@@ -6049,13 +6220,13 @@ void Mcasp_localHandlePwrmEvent(Mcasp_Object *instHandle,
6049 Power_NotifyResponse pwrmStatus = Power_NOTIFYDONE; 6220 Power_NotifyResponse pwrmStatus = Power_NOTIFYDONE;
6050 Power_Status status = Power_SOK; 6221 Power_Status status = Power_SOK;
6051 6222
6052 assert(NULL != clientArg); 6223 if(NULL != clientArg)
6224 {
6053 6225
6054 eventArg1 = eventArg1; 6226 eventArg1 = eventArg1;
6055 eventArg2 = eventArg2; 6227 eventArg2 = eventArg2;
6056 6228
6057 instHandle = (Mcasp_Object *)clientArg; 6229 instHandle = (Mcasp_Object *)clientArg;
6058 assert(NULL != instHandle);
6059 6230
6060 /* check the event notified by the PWRM module and process accordingly */ 6231 /* check the event notified by the PWRM module and process accordingly */
6061 switch (eventType) 6232 switch (eventType)
@@ -6110,6 +6281,11 @@ void Mcasp_localHandlePwrmEvent(Mcasp_Object *instHandle,
6110 default: 6281 default:
6111 break; 6282 break;
6112 } 6283 }
6284 }
6285 else
6286 {
6287 pwrmStatus = Power_NOTIFYNOTDONE;
6288 }
6113 return (pwrmStatus); 6289 return (pwrmStatus);
6114} 6290}
6115 6291
@@ -6130,7 +6306,8 @@ void Mcasp_localHandlePwrmEvent(Mcasp_Object *instHandle,
6130 uint32_t hwiKey = 0x00; 6306 uint32_t hwiKey = 0x00;
6131 Power_NotifyResponse status = Power_NOTIFYDONE; 6307 Power_NotifyResponse status = Power_NOTIFYDONE;
6132 6308
6133 assert(NULL != instHandle); 6309 if(NULL != instHandle)
6310 {
6134 6311
6135 hwiKey = HwiP_disable(); 6312 hwiKey = HwiP_disable();
6136 6313
@@ -6151,7 +6328,11 @@ void Mcasp_localHandlePwrmEvent(Mcasp_Object *instHandle,
6151 instHandle->pwrmInfo.ioSuspend = (Bool)TRUE; 6328 instHandle->pwrmInfo.ioSuspend = (Bool)TRUE;
6152 instHandle->pwrmInfo.pwrmEvent = eventType; 6329 instHandle->pwrmInfo.pwrmEvent = eventType;
6153 } 6330 }
6154 6331 }
6332 else
6333 {
6334 pwrmStatus = Power_NOTIFYNOTDONE;
6335 }
6155 HwiP_restore(hwiKey); 6336 HwiP_restore(hwiKey);
6156 return (status); 6337 return (status);
6157} 6338}
@@ -6172,12 +6353,12 @@ void Mcasp_localHandlePwrmEvent(Mcasp_Object *instHandle,
6172 */ 6353 */
6173 int32_t McaspUnregisterNotification(Mcasp_Object *instHandle) 6354 int32_t McaspUnregisterNotification(Mcasp_Object *instHandle)
6174{ 6355{
6175 uint32_t eventCnt = 0x00; 6356 uint32_t eventCnt = 0x00;
6176 Power_Status retVal = Power_SOK; 6357 Power_Status retVal = Power_SOK;
6177 int32_t status = MCASP_COMPLETED; 6358 int32_t status = MCASP_COMPLETED;
6178
6179 assert(NULL != instHandle);
6180 6359
6360 if(NULL != instHandle)
6361 {
6181 for (eventCnt = 0; eventCnt < Mcasp_MAX_PWRM_EVENTS; eventCnt++) 6362 for (eventCnt = 0; eventCnt < Mcasp_MAX_PWRM_EVENTS; eventCnt++)
6182 { 6363 {
6183 /* register the notify function for the PWRM event */ 6364 /* register the notify function for the PWRM event */
@@ -6197,6 +6378,11 @@ void Mcasp_localHandlePwrmEvent(Mcasp_Object *instHandle,
6197 } 6378 }
6198 } 6379 }
6199 } 6380 }
6381 }
6382 else
6383 {
6384 status = MCASP_EBADARGS;
6385 }
6200 return (status); 6386 return (status);
6201} 6387}
6202 6388
@@ -6213,13 +6399,14 @@ void Mcasp_localHandlePwrmEvent(Mcasp_Object *instHandle,
6213 * 6399 *
6214 * \leave Not implemented 6400 * \leave Not implemented
6215 */ 6401 */
6216 int32_t McaspUnregisterConstraints(Mcasp_Object *instHandle) 6402int32_t McaspUnregisterConstraints(Mcasp_Object *instHandle)
6217{ 6403{
6218 int32_t status = MCASP_COMPLETED; 6404 int32_t status = MCASP_COMPLETED;
6219 Power_Status retVal = Power_SOK; 6405 Power_Status retVal = Power_SOK;
6220 uint32_t count = 0x00; 6406 uint32_t count = 0x00;
6221 6407
6222 assert(NULL != instHandle); 6408 if(NULL != instHandle)
6409 {
6223 6410
6224 for (count = 0; count < Mcasp_MAX_PWRM_CONSTRAINTS; count++) 6411 for (count = 0; count < Mcasp_MAX_PWRM_CONSTRAINTS; count++)
6225 { 6412 {
@@ -6239,6 +6426,11 @@ void Mcasp_localHandlePwrmEvent(Mcasp_Object *instHandle,
6239 } 6426 }
6240 } 6427 }
6241 } 6428 }
6429 }
6430 else
6431 {
6432 status = MCASP_EBADARGS;
6433 }
6242 return (status); 6434 return (status);
6243} 6435}
6244 6436
diff --git a/src/mcasp_ioctl.c b/src/mcasp_ioctl.c
index c4ae312..779d73f 100644
--- a/src/mcasp_ioctl.c
+++ b/src/mcasp_ioctl.c
@@ -163,15 +163,10 @@ int32_t Mcasp_localSubmitIoctl(Mcasp_ChannelHandle chanHandle,
163 bool breakLoop = (Bool) FALSE; 163 bool breakLoop = (Bool) FALSE;
164#endif 164#endif
165 /* Validate the input parameters */ 165 /* Validate the input parameters */
166 assert((NULL != chanHandle) && (NULL != chanHandle->devHandle)); 166 if((NULL != chanHandle) && (NULL != chanHandle->devHandle))
167 167 {
168 instHandle = (Mcasp_Object *)chanHandle->devHandle; 168 instHandle = (Mcasp_Object *)chanHandle->devHandle;
169 169
170 assert(NULL != instHandle);
171
172 /* To remove the compiler warning */
173 param = param;
174
175 /*--------------------MCASP IOCTL FOR HANDLING TIMEOUT--------------------*/ 170 /*--------------------MCASP IOCTL FOR HANDLING TIMEOUT--------------------*/
176 171
177 if ((Mcasp_IOCTL_CHAN_TIMEDOUT == cmd) || 172 if ((Mcasp_IOCTL_CHAN_TIMEDOUT == cmd) ||
@@ -201,9 +196,9 @@ int32_t Mcasp_localSubmitIoctl(Mcasp_ChannelHandle chanHandle,
201 else if (Mcasp_IOCTL_QUERY_LOOPJOB_MODE == cmd) 196 else if (Mcasp_IOCTL_QUERY_LOOPJOB_MODE == cmd)
202 { 197 {
203 /* Query the working mode of the driver */ 198 /* Query the working mode of the driver */
204 assert(NULL != arg); 199 if(NULL != arg) {
205 200 *(Bool *)arg = instHandle->loopJobMode;
206 *(Bool *)arg = instHandle->loopJobMode; 201 }
207 } 202 }
208 /*---------------------MCASP SET CHANNEL SETTINGS CMD --------------------*/ 203 /*---------------------MCASP SET CHANNEL SETTINGS CMD --------------------*/
209 else if (Mcasp_IOCTL_CNTRL_SET_FORMAT_CHAN == cmd) 204 else if (Mcasp_IOCTL_CNTRL_SET_FORMAT_CHAN == cmd)
@@ -222,7 +217,7 @@ int32_t Mcasp_localSubmitIoctl(Mcasp_ChannelHandle chanHandle,
222 chanSetup = (Mcasp_HwSetupData *)arg; 217 chanSetup = (Mcasp_HwSetupData *)arg;
223 218
224 /* Stop the xmt/rcv state machine. */ 219 /* Stop the xmt/rcv state machine. */
225 Mcasp_localSmReset(chanHandle); 220 status = Mcasp_localSmReset(chanHandle);
226 221
227 if (Mcasp_ChanMode_RCV == chanHandle->channelOpMode) 222 if (Mcasp_ChanMode_RCV == chanHandle->channelOpMode)
228 { 223 {
@@ -345,7 +340,7 @@ int32_t Mcasp_localSubmitIoctl(Mcasp_ChannelHandle chanHandle,
345 { 340 {
346 /* Start the xmt/rcv state machine. 341 /* Start the xmt/rcv state machine.
347 * */ 342 * */
348 Mcasp_localSmSet((Mcasp_ChannelHandle) chanHandle); 343 status = Mcasp_localSmSet((Mcasp_ChannelHandle) chanHandle);
349 } 344 }
350 } 345 }
351#endif 346#endif
@@ -413,7 +408,7 @@ int32_t Mcasp_localSubmitIoctl(Mcasp_ChannelHandle chanHandle,
413 McASPRxReset(instHandle->hwInfo.regs); 408 McASPRxReset(instHandle->hwInfo.regs);
414 } 409 }
415 410
416 Mcasp_localSetupHwInfo(&instHandle->hwInfo, mcaspHwSetup); 411 status = Mcasp_localSetupHwInfo(&instHandle->hwInfo, mcaspHwSetup);
417 412
418 }while(falsewhile); 413 }while(falsewhile);
419 414
@@ -516,7 +511,7 @@ int32_t Mcasp_localSubmitIoctl(Mcasp_ChannelHandle chanHandle,
516 break; 511 break;
517 } 512 }
518 513
519 Mcasp_localActivateSmFsForBoth(instHandle); 514 status = Mcasp_localActivateSmFsForBoth(instHandle);
520 515
521 }while (falsewhile); 516 }while (falsewhile);
522 } 517 }
@@ -871,7 +866,7 @@ int32_t Mcasp_localSubmitIoctl(Mcasp_ChannelHandle chanHandle,
871 /* Activate the transmit and receive clocks */ 866 /* Activate the transmit and receive clocks */
872 mcaspActivateClkRcvXmt(&(instHandle->hwInfo)); 867 mcaspActivateClkRcvXmt(&(instHandle->hwInfo));
873 868
874 Mcasp_localActivateSmFsForBoth(instHandle); 869 status = Mcasp_localActivateSmFsForBoth(instHandle);
875 } 870 }
876 else 871 else
877 { 872 {
@@ -882,7 +877,7 @@ int32_t Mcasp_localSubmitIoctl(Mcasp_ChannelHandle chanHandle,
882 * section in reset */ 877 * section in reset */
883 mcaspActivateRcvClkSer(&(instHandle->hwInfo)); 878 mcaspActivateRcvClkSer(&(instHandle->hwInfo));
884 879
885 Mcasp_localActivateSmFsForRcv(instHandle); 880 status = Mcasp_localActivateSmFsForRcv(instHandle);
886 } 881 }
887 else 882 else
888 { 883 {
@@ -891,7 +886,7 @@ int32_t Mcasp_localSubmitIoctl(Mcasp_ChannelHandle chanHandle,
891 * section in reset */ 886 * section in reset */
892 mcaspActivateXmtClkSer(&(instHandle->hwInfo)); 887 mcaspActivateXmtClkSer(&(instHandle->hwInfo));
893 888
894 Mcasp_localActivateSmFsForXmt(instHandle); 889 status = Mcasp_localActivateSmFsForXmt(instHandle);
895 } 890 }
896 } 891 }
897 } /* DMA driven is TRUE if loop */ 892 } /* DMA driven is TRUE if loop */
@@ -1059,10 +1054,10 @@ int32_t Mcasp_localSubmitIoctl(Mcasp_ChannelHandle chanHandle,
1059 /*****************command to modify the Timeout count value****************/ 1054 /*****************command to modify the Timeout count value****************/
1060 else if (Mcasp_IOCTL_SET_TIMEOUT == cmd) 1055 else if (Mcasp_IOCTL_SET_TIMEOUT == cmd)
1061 { 1056 {
1062 assert(NULL != arg); 1057 if(NULL != arg) {
1063 1058 /* modify the retry count value to be used */
1064 /* modify the retry count value to be used */ 1059 instHandle->retryCount = *(uint32_t *) arg;
1065 instHandle->retryCount = *(uint32_t *) arg; 1060 }
1066 } 1061 }
1067#endif 1062#endif
1068 else if (Mcasp_IOCTL_FLUSH_RCV_FIFO == cmd) 1063 else if (Mcasp_IOCTL_FLUSH_RCV_FIFO == cmd)
@@ -1088,19 +1083,23 @@ int32_t Mcasp_localSubmitIoctl(Mcasp_ChannelHandle chanHandle,
1088 } 1083 }
1089 } else if (Mcasp_IOCTL_CHAN_QUERY_ERROR_STATS == cmd) 1084 } else if (Mcasp_IOCTL_CHAN_QUERY_ERROR_STATS == cmd)
1090 { 1085 {
1091 assert(NULL != arg); 1086 if(NULL != arg)
1092 if (MCASP_INPUT == chanHandle->mode) 1087 {
1093 { status = Mcasp_localCollectRcvErrorStats(chanHandle,(Mcasp_errCbStatus *)arg); 1088 if (MCASP_INPUT == chanHandle->mode)
1094 } 1089 { status = Mcasp_localCollectRcvErrorStats(chanHandle,(Mcasp_errCbStatus *)arg);
1095 else 1090 }
1096 { status = Mcasp_localCollectXmtErrorStats(chanHandle,(Mcasp_errCbStatus *)arg); 1091 else
1097 } 1092 { status = Mcasp_localCollectXmtErrorStats(chanHandle,(Mcasp_errCbStatus *)arg);
1093 }
1094 }
1098 } 1095 }
1099 else if (Mcasp_IOCTL_CHAN_PARAMS_WORD_WIDTH == cmd) 1096 else if (Mcasp_IOCTL_CHAN_PARAMS_WORD_WIDTH == cmd)
1100 { 1097 {
1101 assert(NULL != arg); 1098 if(NULL != arg)
1102 params = (Mcasp_ChanParams *) arg; 1099 {
1103 Mcasp_localConfigWordWidth(chanHandle, params); 1100 params = (Mcasp_ChanParams *) arg;
1101 Mcasp_localConfigWordWidth(chanHandle, params);
1102 }
1104 } 1103 }
1105 /*---------------MCASP GET TX CLOCK DIVIDE RATIO CMD -----------------*/ 1104 /*---------------MCASP GET TX CLOCK DIVIDE RATIO CMD -----------------*/
1106 else if (Mcasp_IOCTL_CNTRL_GET_FORMAT_CHAN_CLKXDIV == cmd) 1105 else if (Mcasp_IOCTL_CNTRL_GET_FORMAT_CHAN_CLKXDIV == cmd)
@@ -1137,7 +1136,12 @@ int32_t Mcasp_localSubmitIoctl(Mcasp_ChannelHandle chanHandle,
1137 /* command not executed hence not set status as not implemented */ 1136 /* command not executed hence not set status as not implemented */
1138 status = MCASP_ENOTIMPL; 1137 status = MCASP_ENOTIMPL;
1139 } 1138 }
1140 return (status); 1139 }
1140 else
1141 {
1142 status = MCASP_EBADARGS;
1143 }
1144 return (status);
1141} 1145}
1142 1146
1143/** 1147/**
@@ -1272,8 +1276,8 @@ static void mcaspConfigLoopBack(Mcasp_HwHandle hMcasp,Bool loopBack)
1272 uint32_t serMode = 0; 1276 uint32_t serMode = 0;
1273 uint32_t dlbMode = 0; 1277 uint32_t dlbMode = 0;
1274 uint32_t tempVal = 0; 1278 uint32_t tempVal = 0;
1275 assert((NULL != hMcasp) && (0 != (hMcasp->regs))); 1279 if((NULL != hMcasp) && (0 != (hMcasp->regs)))
1276 1280 {
1277 /* Reset the RSRCLR and XSRCLR registers in GBLCTL */ 1281 /* Reset the RSRCLR and XSRCLR registers in GBLCTL */
1278 tempVal = McASPGlobalCtlGet(hMcasp->regs); 1282 tempVal = McASPGlobalCtlGet(hMcasp->regs);
1279 tempVal &= ~((uint32_t) (MCASP_GBLCTLR_RSRCLR_MASK | MCASP_GBLCTLR_XSRCLR_MASK | 1283 tempVal &= ~((uint32_t) (MCASP_GBLCTLR_RSRCLR_MASK | MCASP_GBLCTLR_XSRCLR_MASK |
@@ -1336,6 +1340,7 @@ static void mcaspConfigLoopBack(Mcasp_HwHandle hMcasp,Bool loopBack)
1336 serNum++; 1340 serNum++;
1337 } 1341 }
1338 } 1342 }
1343 }
1339} 1344}
1340 1345
1341#ifdef Mcasp_LOOPJOB_ENABLED 1346#ifdef Mcasp_LOOPJOB_ENABLED
@@ -1356,9 +1361,8 @@ static void mcaspActivateClkRcvXmt(Mcasp_HwHandle hMcasp)
1356 uint32_t bitValue = 0U; 1361 uint32_t bitValue = 0U;
1357 uint32_t tempVal = 0; 1362 uint32_t tempVal = 0;
1358 1363
1359 assert(NULL != hMcasp); 1364 if((NULL != hMcasp) && (0 != (hMcasp->regs)))
1360 assert(0 != (hMcasp->regs)); 1365 {
1361
1362 /* Sequence of start: starting hclk first */ 1366 /* Sequence of start: starting hclk first */
1363 /* start AHCLKR */ 1367 /* start AHCLKR */
1364 tempVal = McASPGlobalCtlGet(hMcasp->regs); 1368 tempVal = McASPGlobalCtlGet(hMcasp->regs);
@@ -1438,6 +1442,7 @@ static void mcaspActivateClkRcvXmt(Mcasp_HwHandle hMcasp)
1438 >> MCASP_GBLCTL_XCLKRST_SHIFT; 1442 >> MCASP_GBLCTL_XCLKRST_SHIFT;
1439 } 1443 }
1440 } 1444 }
1445 }
1441} 1446}
1442 1447
1443/** 1448/**
@@ -1459,8 +1464,8 @@ static void mcaspActivateRcvClkSer(Mcasp_HwHandle hMcasp)
1459 uint32_t bitValue = 0U; 1464 uint32_t bitValue = 0U;
1460 uint32_t tempVal = 0; 1465 uint32_t tempVal = 0;
1461 1466
1462 assert(NULL != hMcasp); 1467 if((NULL != hMcasp) && (0 != (hMcasp->regs)))
1463 assert(0 != (hMcasp->regs)); 1468 {
1464 1469
1465 /* Sequence of start: starting hclk first */ 1470 /* Sequence of start: starting hclk first */
1466 /* start AHCLKR */ 1471 /* start AHCLKR */
@@ -1553,6 +1558,7 @@ static void mcaspActivateRcvClkSer(Mcasp_HwHandle hMcasp)
1553 >> MCASP_GBLCTL_RSRCLR_SHIFT; 1558 >> MCASP_GBLCTL_RSRCLR_SHIFT;
1554 } 1559 }
1555#endif 1560#endif
1561 }
1556} 1562}
1557 1563
1558/** 1564/**
@@ -1573,9 +1579,8 @@ static void mcaspActivateXmtClkSer(Mcasp_HwHandle hMcasp)
1573 uint32_t bitValue = 0U; 1579 uint32_t bitValue = 0U;
1574 uint32_t tempVal = 0; 1580 uint32_t tempVal = 0;
1575 1581
1576 assert(NULL != hMcasp); 1582 if((NULL != hMcasp) && (0 != (hMcasp->regs)))
1577 assert(0 != (hMcasp->regs)); 1583 {
1578
1579 /* Sequence of start: starting hclk first*/ 1584 /* Sequence of start: starting hclk first*/
1580 1585
1581 tempVal = McASPTxGlobalCtlGet(hMcasp->regs); 1586 tempVal = McASPTxGlobalCtlGet(hMcasp->regs);
@@ -1630,6 +1635,7 @@ static void mcaspActivateXmtClkSer(Mcasp_HwHandle hMcasp)
1630 bitValue = (bitValue & MCASP_GBLCTL_XSRCLR_MASK) 1635 bitValue = (bitValue & MCASP_GBLCTL_XSRCLR_MASK)
1631 >> MCASP_GBLCTL_XSRCLR_SHIFT; 1636 >> MCASP_GBLCTL_XSRCLR_SHIFT;
1632 } 1637 }
1638 }
1633} 1639}
1634 1640
1635#endif 1641#endif
@@ -1662,8 +1668,8 @@ static int32_t mcaspGetHwStatus(Mcasp_HwHandle hMcasp,
1662 Mcasp_SerModeQuery *serModeQuery = NULL; 1668 Mcasp_SerModeQuery *serModeQuery = NULL;
1663 1669
1664 1670
1665 assert((NULL != hMcasp) && (NULL != response)); 1671 if((NULL != hMcasp) && (NULL != response))
1666 1672 {
1667 switch (myQuery) 1673 switch (myQuery)
1668 { 1674 {
1669 /* Return current transmit slot being transmitted */ 1675 /* Return current transmit slot being transmitted */
@@ -1810,7 +1816,10 @@ static int32_t mcaspGetHwStatus(Mcasp_HwHandle hMcasp,
1810 status = MCASP_EBADARGS; 1816 status = MCASP_EBADARGS;
1811 break; 1817 break;
1812 } 1818 }
1813 1819 } else
1820 {
1821 status = MCASP_EBADARGS;
1822 }
1814 return status; 1823 return status;
1815} 1824}
1816 1825
@@ -1837,12 +1846,11 @@ static void mcaspGetSerXmtReady(Mcasp_HwHandle hMcasp,
1837 Bool *serXmtReady, 1846 Bool *serXmtReady,
1838 Mcasp_SerializerNum serNum) 1847 Mcasp_SerializerNum serNum)
1839{ 1848{
1840 assert((NULL != serXmtReady) && (NULL != hMcasp)); 1849 if((NULL != serXmtReady) && (NULL != hMcasp) && (serNum < hMcasp->numOfSerializers))
1841 1850 {
1842 assert (serNum < hMcasp->numOfSerializers); 1851 *(Bool *)serXmtReady =
1843 1852 (Bool) McASPIsSerializerXmtReady(hMcasp->regs, serNum);
1844 *(Bool *)serXmtReady = 1853 }
1845 (Bool) McASPIsSerializerXmtReady(hMcasp->regs, serNum);
1846} 1854}
1847 1855
1848/** 1856/**
@@ -1870,11 +1878,11 @@ static void mcaspGetSerRcvReady(Mcasp_HwHandle hMcasp,
1870 Mcasp_SerializerNum serNum) 1878 Mcasp_SerializerNum serNum)
1871{ 1879{
1872 1880
1873 assert((NULL != serRcvReady) && (NULL != hMcasp)); 1881 if((NULL != serRcvReady) && (NULL != hMcasp) && (serNum < hMcasp->numOfSerializers))
1874 assert(serNum < hMcasp->numOfSerializers); 1882 {
1875 1883 (*(Bool *) serRcvReady) =
1876 (*(Bool *) serRcvReady) = 1884 (Bool) McASPIsSerializerRcvReady(hMcasp->regs, serNum);
1877 (Bool) McASPIsSerializerRcvReady(hMcasp->regs, serNum); 1885 }
1878} 1886}
1879 1887
1880/** 1888/**
@@ -1900,12 +1908,12 @@ static void mcaspGetSerMode(Mcasp_HwHandle hMcasp,
1900{ 1908{
1901 uint32_t serializerVal = 0x0; 1909 uint32_t serializerVal = 0x0;
1902 1910
1903 assert((NULL != serMode) && (NULL != hMcasp)); 1911 if( (NULL != serMode) && (NULL != hMcasp) && (serNum < hMcasp->numOfSerializers) )
1904 assert(serNum < hMcasp->numOfSerializers); 1912 {
1905 1913 serializerVal = McASPSerializerGet(hMcasp->regs, serNum);
1906 serializerVal = McASPSerializerGet(hMcasp->regs, serNum); 1914 *serMode = (Mcasp_SerMode) ((serializerVal & MCASP_XRSRCTL0_SRMOD_MASK)
1907 *serMode = (Mcasp_SerMode) ((serializerVal & MCASP_XRSRCTL0_SRMOD_MASK)
1908 >> MCASP_XRSRCTL0_SRMOD_SHIFT); 1915 >> MCASP_XRSRCTL0_SRMOD_SHIFT);
1916 }
1909} 1917}
1910 1918
1911 1919
@@ -1929,8 +1937,8 @@ static void mcaspGetSerMode(Mcasp_HwHandle hMcasp,
1929static void mcaspReadRcvConfig(Mcasp_HwHandle hMcasp, 1937static void mcaspReadRcvConfig(Mcasp_HwHandle hMcasp,
1930 Mcasp_HwSetupData *const rcvData) 1938 Mcasp_HwSetupData *const rcvData)
1931{ 1939{
1932 assert((NULL != hMcasp) && (NULL != rcvData)); 1940 if ((NULL != hMcasp) && (NULL != rcvData))
1933 1941 {
1934 /* Read RMASK register */ 1942 /* Read RMASK register */
1935 rcvData->mask = (uint32_t) McASPRxFmtMaskGet(hMcasp->regs); 1943 rcvData->mask = (uint32_t) McASPRxFmtMaskGet(hMcasp->regs);
1936 1944
@@ -1967,6 +1975,7 @@ static void mcaspReadRcvConfig(Mcasp_HwHandle hMcasp,
1967 /* Read REVTCTL register */ 1975 /* Read REVTCTL register */
1968 rcvData->evtCtl = (uint32_t) 1976 rcvData->evtCtl = (uint32_t)
1969 McASPTxRxDMAEvtCntrlRead(hMcasp->regs, (uint8_t) RX); 1977 McASPTxRxDMAEvtCntrlRead(hMcasp->regs, (uint8_t) RX);
1978 }
1970} 1979}
1971 1980
1972/** 1981/**
@@ -1989,8 +1998,8 @@ static void mcaspReadRcvConfig(Mcasp_HwHandle hMcasp,
1989static void mcaspReadXmtConfig(Mcasp_HwHandle hMcasp, 1998static void mcaspReadXmtConfig(Mcasp_HwHandle hMcasp,
1990 Mcasp_HwSetupData *const xmtData) 1999 Mcasp_HwSetupData *const xmtData)
1991{ 2000{
1992 assert((NULL != hMcasp) && (NULL != xmtData)); 2001 if((NULL != hMcasp) && (NULL != xmtData))
1993 2002 {
1994 /* Read XMASK register */ 2003 /* Read XMASK register */
1995 xmtData->mask = (uint32_t) McASPTxFmtMaskGet(hMcasp->regs); 2004 xmtData->mask = (uint32_t) McASPTxFmtMaskGet(hMcasp->regs);
1996 2005
@@ -2026,6 +2035,7 @@ static void mcaspReadXmtConfig(Mcasp_HwHandle hMcasp,
2026 /* Read XEVTCTL register */ 2035 /* Read XEVTCTL register */
2027 xmtData->evtCtl = (uint32_t) 2036 xmtData->evtCtl = (uint32_t)
2028 McASPTxRxDMAEvtCntrlRead(hMcasp->regs, (uint8_t) TX); 2037 McASPTxRxDMAEvtCntrlRead(hMcasp->regs, (uint8_t) TX);
2038 }
2029} 2039}
2030 2040
2031/* 2041/*
@@ -2049,19 +2059,12 @@ int32_t Mcasp_localAbortRequests(void* handle,void* arg)
2049 Mcasp_Object *instHandle = NULL; 2059 Mcasp_Object *instHandle = NULL;
2050 int32_t status = MCASP_COMPLETED; 2060 int32_t status = MCASP_COMPLETED;
2051 2061
2052 assert(NULL != handle); 2062 if ( (NULL != handle) && (NULL != ((Mcasp_ChannelHandle)handle)->devHandle) )
2053 2063 {
2054 chanHandle = (Mcasp_ChannelHandle)handle; 2064 chanHandle = (Mcasp_ChannelHandle)handle;
2055 2065
2056 assert(NULL != chanHandle->devHandle);
2057
2058 instHandle = (Mcasp_Object *)chanHandle->devHandle; 2066 instHandle = (Mcasp_Object *)chanHandle->devHandle;
2059 2067
2060 assert(NULL != instHandle);
2061
2062 /* To remove compiler warning */
2063 arg = arg;
2064
2065 if (Mcasp_DriverState_OPENED == chanHandle->chanState) 2068 if (Mcasp_DriverState_OPENED == chanHandle->chanState)
2066 { 2069 {
2067 /* Abort the requested channels */ 2070 /* Abort the requested channels */
@@ -2074,7 +2077,11 @@ int32_t Mcasp_localAbortRequests(void* handle,void* arg)
2074 status = Mcasp_localAbortReset(&instHandle->XmtObj); 2077 status = Mcasp_localAbortReset(&instHandle->XmtObj);
2075 } 2078 }
2076 } 2079 }
2077 2080 }
2081 else
2082 {
2083 status = MCASP_EBADARGS;
2084 }
2078 return (status); 2085 return (status);
2079} 2086}
2080 2087
@@ -2106,12 +2113,11 @@ static int32_t mcaspSetSamplingRate(Mcasp_ChannelHandle chanHandle,
2106 Mcasp_HwSetup *hwSetUp = NULL; 2113 Mcasp_HwSetup *hwSetUp = NULL;
2107 int32_t status = MCASP_COMPLETED; 2114 int32_t status = MCASP_COMPLETED;
2108 2115
2109 assert((NULL != chanHandle) && (NULL != ioctlArg)); 2116 if ( (NULL != chanHandle) && (NULL != ((Mcasp_ChannelHandle)chanHandle)->devHandle) && (NULL != ioctlArg) )
2117 {
2110 2118
2111 instHandle = (Mcasp_Object *)chanHandle->devHandle; 2119 instHandle = (Mcasp_Object *)chanHandle->devHandle;
2112 2120
2113 assert(NULL != instHandle);
2114
2115 hwSetUp = (Mcasp_HwSetup *)ioctlArg; 2121 hwSetUp = (Mcasp_HwSetup *)ioctlArg;
2116 2122
2117 /* These values will not be changed hence we will take a copy of these * 2123 /* These values will not be changed hence we will take a copy of these *
@@ -2145,6 +2151,11 @@ static int32_t mcaspSetSamplingRate(Mcasp_ChannelHandle chanHandle,
2145 2151
2146 status = Mcasp_localConfigRcvSection(instHandle, &hwSetUp->rx); 2152 status = Mcasp_localConfigRcvSection(instHandle, &hwSetUp->rx);
2147 } 2153 }
2154 }
2155 else
2156 {
2157 status = MCASP_EBADARGS;
2158 }
2148 return status; 2159 return status;
2149} 2160}
2150 2161
@@ -2173,14 +2184,14 @@ static void mcaspDeviceInfoGet(Mcasp_ChannelHandle chanHandle,
2173 uint32_t tempVal1 = 0x0; 2184 uint32_t tempVal1 = 0x0;
2174 uint32_t tempVal2 = 0x0; 2185 uint32_t tempVal2 = 0x0;
2175 2186
2176 assert((chanHandle != NULL) && (NULL != arg)); 2187 if((chanHandle != NULL) && (NULL != arg))
2177 2188 {
2178 devData = (Mcasp_AudioDevData *)arg; 2189 devData = (Mcasp_AudioDevData *)arg;
2179 2190
2180 instHandle = (Mcasp_Object *)chanHandle->devHandle; 2191 instHandle = (Mcasp_Object *)chanHandle->devHandle;
2181 2192
2182 assert(NULL != instHandle); 2193 if(NULL != instHandle)
2183 2194 {
2184 tempVal1 = McASPTxClkPolarityGet(instHandle->hwInfo.regs); 2195 tempVal1 = McASPTxClkPolarityGet(instHandle->hwInfo.regs);
2185 tempVal2 = McASPRxClkPolarityGet(instHandle->hwInfo.regs); 2196 tempVal2 = McASPRxClkPolarityGet(instHandle->hwInfo.regs);
2186 /* check if the bit clock of the TX section is generated internally */ 2197 /* check if the bit clock of the TX section is generated internally */
@@ -2206,9 +2217,11 @@ static void mcaspDeviceInfoGet(Mcasp_ChannelHandle chanHandle,
2206 isMaster = TRUE; 2217 isMaster = TRUE;
2207 } 2218 }
2208 } 2219 }
2209 } 2220 }
2221 }
2210 /* update the information to the data structure */ 2222 /* update the information to the data structure */
2211 devData->isMaster = (uint16_t)isMaster; 2223 devData->isMaster = (uint16_t)isMaster;
2224 }
2212} 2225}
2213 2226
2214/* ========================================================================== */ 2227/* ========================================================================== */