|
|
@ -11,12 +11,12 @@ |
|
|
|
#include <iosLib.h> |
|
|
|
#include <selectLib.h> |
|
|
|
#include <errnoLib.h> |
|
|
|
#include <spinLockLib.h> |
|
|
|
#include <hwif/vxbus/vxBus.h> |
|
|
|
#include <hwif/vxbus/hwConf.h> |
|
|
|
#include <hwif/vxbus/vxbPlbLib.h> |
|
|
|
#include <hwif/util/hwMemLib.h> |
|
|
|
#include <hwif/util/vxbParamSys.h> |
|
|
|
|
|
|
|
#include <hwif/vxbus/vxbSpiLib.h> |
|
|
|
#include "vxbSm2130SpiDev.h" |
|
|
|
#include <usrLib.h> |
|
|
@ -28,7 +28,7 @@ typedef struct _Sm2310_DEV_HANDLE { |
|
|
|
|
|
|
|
SEL_WAKEUP_LIST selList; |
|
|
|
|
|
|
|
volatile BOOL irqFlag; |
|
|
|
BOOL ackable; |
|
|
|
|
|
|
|
void (*usrIsr)(); |
|
|
|
|
|
|
@ -353,13 +353,16 @@ LOCAL int drv1553bIoctl(SM2310_DEV_HANDLE *dev, int cmd, _Vx_ioctl_arg_t arg) |
|
|
|
semTake(pDrvCtrl->muteSem, WAIT_FOREVER); |
|
|
|
switch (cmd) { |
|
|
|
case FIOSELECT: |
|
|
|
if (dev->irqFlag) { |
|
|
|
selWakeup((SEL_WAKEUP_NODE *)arg); |
|
|
|
} else { |
|
|
|
if (selNodeAdd(&dev->selList, (SEL_WAKEUP_NODE *)arg) == ERROR) { |
|
|
|
spinLockIsrTake(&pDrvCtrl->spinLock); |
|
|
|
if (dev->ackable && pDrvCtrl->irqFlag) { |
|
|
|
selWakeup((SEL_WAKEUP_NODE *)arg); |
|
|
|
spinLockIsrGive(&pDrvCtrl->spinLock); |
|
|
|
break; |
|
|
|
} |
|
|
|
if (selNodeAdd(&dev->selList, (SEL_WAKEUP_NODE *)arg) != OK) { |
|
|
|
selWakeup((SEL_WAKEUP_NODE *)arg); |
|
|
|
} |
|
|
|
spinLockIsrGive(&pDrvCtrl->spinLock); |
|
|
|
break; |
|
|
|
case FIOUNSELECT: |
|
|
|
selNodeDelete(&dev->selList, (SEL_WAKEUP_NODE *)arg); |
|
|
@ -368,6 +371,10 @@ LOCAL int drv1553bIoctl(SM2310_DEV_HANDLE *dev, int cmd, _Vx_ioctl_arg_t arg) |
|
|
|
xfer = (SM2130_XFER *)(arg); |
|
|
|
pDrvCtrl->write(pDrvCtrl->pDev, xfer->reg, xfer->val); |
|
|
|
break; |
|
|
|
case FIOC_SM2130_ACKABLE: |
|
|
|
dev->ackable = (BOOL)arg; |
|
|
|
break; |
|
|
|
|
|
|
|
case FIOC_SM2130_RD: |
|
|
|
xfer = (SM2130_XFER *)(arg); |
|
|
|
xfer->val = pDrvCtrl->read(pDrvCtrl->pDev, xfer->reg); |
|
|
@ -393,15 +400,18 @@ LOCAL int drv1553bIoctl(SM2310_DEV_HANDLE *dev, int cmd, _Vx_ioctl_arg_t arg) |
|
|
|
break; |
|
|
|
|
|
|
|
case FIOC_SM2130_ACKIRQ: |
|
|
|
iflag = dev->irqFlag; |
|
|
|
dev->irqFlag = FALSE; |
|
|
|
if (pDrvCtrl->funcAckIrq && iflag) { |
|
|
|
iflag = pDrvCtrl->irqFlag; |
|
|
|
pDrvCtrl->irqFlag = FALSE; |
|
|
|
if (pDrvCtrl->funcAckIrq) { |
|
|
|
UINT32 us = (UINT32)arg; |
|
|
|
if (us == 0) { |
|
|
|
us = 100; |
|
|
|
} |
|
|
|
pDrvCtrl->funcAckIrq(FALSE); |
|
|
|
pDrvCtrl->funcAckIrq(TRUE); |
|
|
|
if (iflag) { |
|
|
|
sysUsDelay(us); |
|
|
|
} |
|
|
|
pDrvCtrl->funcAckIrq(FALSE); |
|
|
|
} else { |
|
|
|
if (!pDrvCtrl->funcAckIrq) { |
|
|
@ -440,6 +450,9 @@ LOCAL int drv1553bIoctl(SM2310_DEV_HANDLE *dev, int cmd, _Vx_ioctl_arg_t arg) |
|
|
|
break; |
|
|
|
} |
|
|
|
semGive(pDrvCtrl->muteSem); |
|
|
|
if (ret == OK) { |
|
|
|
errnoSet(OK); |
|
|
|
} |
|
|
|
return (ret); |
|
|
|
} |
|
|
|
/* }}} */ |
|
|
@ -466,6 +479,8 @@ LOCAL void sm2130SpiDevInstInit2(VXB_DEVICE_ID pDev) |
|
|
|
/* Mutex semaphore is initialized and necessary at this point */ |
|
|
|
pDrvCtrl->muteSem = semMCreate(SPI_DEV_MUTEX_OPT); |
|
|
|
|
|
|
|
spinLockIsrInit(&pDrvCtrl->spinLock, SPIN_LOCK_EMPTY); |
|
|
|
|
|
|
|
pFunc = vxbDevMethodGet(vxbDevParent(pDev), (VXB_METHOD_ID)vxbSpiSpecialGet_desc); |
|
|
|
|
|
|
|
/* Retrieve the SPI master special information */ |
|
|
@ -480,14 +495,15 @@ LOCAL void sm1553isr(void *data) |
|
|
|
|
|
|
|
++pDrvCtrl->irqCount; |
|
|
|
|
|
|
|
dev->irqFlag = TRUE; |
|
|
|
pDrvCtrl->irqFlag = TRUE; |
|
|
|
|
|
|
|
//logMsg("sm1553isr interrupt", 1, 2, 3, 4, 5, 6);
|
|
|
|
if (dev->usrIsr) { |
|
|
|
dev->usrIsr(); |
|
|
|
} |
|
|
|
|
|
|
|
spinLockIsrTake(&pDrvCtrl->spinLock); |
|
|
|
selWakeupAll(&dev->selList, SELREAD); |
|
|
|
spinLockIsrGive(&pDrvCtrl->spinLock); |
|
|
|
} |
|
|
|
|
|
|
|
/*
|
|
|
@ -538,7 +554,8 @@ LOCAL void sm2130SpiDevInstConnect(VXB_DEVICE_ID pDev) |
|
|
|
if (dev) { |
|
|
|
pDrvCtrl->refcount = 0; |
|
|
|
dev->usrIsr = NULL; |
|
|
|
dev->irqFlag = FALSE; |
|
|
|
dev->ackable = FALSE; |
|
|
|
pDrvCtrl->irqFlag = FALSE; |
|
|
|
selWakeupListInit(&dev->selList); |
|
|
|
if (iosDevAdd(&dev->devHdr, pDrvCtrl->devName, sm2130_driver_node) == OK) { |
|
|
|
pDrvCtrl->devHandle = dev; |
|
|
@ -625,6 +642,7 @@ LOCAL void sm2130SpiDevShow(VXB_DEVICE_ID pDev, int verbose) |
|
|
|
printf(" refCount: %d\n", pDrvCtrl->refcount); |
|
|
|
printf(" funcReqIsr: %p\n", pDrvCtrl->funcReqIsr); |
|
|
|
printf(" irqCount: %u\n", pDrvCtrl->irqCount); |
|
|
|
printf(" irqFlag: %s\n", pDrvCtrl->irqFlag ? "TRUE" : "FALSE"); |
|
|
|
printf(" isReady: %s\n", checkReady(pDrvCtrl)); |
|
|
|
} |
|
|
|
|
|
|
|