|
@ -1,3 +1,4 @@ |
|
|
|
|
|
/* vim: set ts=4 sw=4 et fdm=marker: */ |
|
|
#include <vxWorks.h> |
|
|
#include <vxWorks.h> |
|
|
#include <stdio.h> |
|
|
#include <stdio.h> |
|
|
#include <string.h> |
|
|
#include <string.h> |
|
@ -7,6 +8,9 @@ |
|
|
#include <taskLib.h> |
|
|
#include <taskLib.h> |
|
|
#include <sysLib.h> |
|
|
#include <sysLib.h> |
|
|
#include <tickLib.h> |
|
|
#include <tickLib.h> |
|
|
|
|
|
#include <iosLib.h> |
|
|
|
|
|
#include <selectLib.h> |
|
|
|
|
|
#include <errnoLib.h> |
|
|
#include <hwif/vxbus/vxBus.h> |
|
|
#include <hwif/vxbus/vxBus.h> |
|
|
#include <hwif/vxbus/hwConf.h> |
|
|
#include <hwif/vxbus/hwConf.h> |
|
|
#include <hwif/vxbus/vxbPlbLib.h> |
|
|
#include <hwif/vxbus/vxbPlbLib.h> |
|
@ -17,10 +21,20 @@ |
|
|
#include "vxbSm2130SpiDev.h" |
|
|
#include "vxbSm2130SpiDev.h" |
|
|
#include <usrLib.h> |
|
|
#include <usrLib.h> |
|
|
|
|
|
|
|
|
|
|
|
#define SPI_DEV_MUTEX_OPT (SEM_Q_PRIORITY | SEM_DELETE_SAFE | SEM_INVERSION_SAFE) |
|
|
|
|
|
|
|
|
|
|
|
typedef struct _Sm2310_DEV_HANDLE { |
|
|
|
|
|
DEV_HDR devHdr; |
|
|
|
|
|
|
|
|
|
|
|
SEL_WAKEUP_LIST selList; |
|
|
|
|
|
|
|
|
|
|
|
SM2130_SPI_DEV *pDevCtrl; |
|
|
|
|
|
} SM2310_DEV_HANDLE; |
|
|
|
|
|
|
|
|
/* locals */ |
|
|
/* locals */ |
|
|
LOCAL void sm2130SpiDevShow(VXB_DEVICE_ID pDev, int verbose); |
|
|
LOCAL void sm2130SpiDevShow(VXB_DEVICE_ID pDev, int verbose); |
|
|
LOCAL INT32 spiDevRead(VXB_DEVICE_ID pDev, UINT8 cmd); |
|
|
LOCAL INT32 sm2130BusDevRead(VXB_DEVICE_ID pDev, UINT8 cmd); |
|
|
LOCAL STATUS spiDevWrite(VXB_DEVICE_ID pDev, UINT8 cmd, UINT16 var); |
|
|
LOCAL STATUS sm2130BusDevWrite(VXB_DEVICE_ID pDev, UINT8 cmd, UINT16 var); |
|
|
|
|
|
|
|
|
/* VxBus methods */ |
|
|
/* VxBus methods */ |
|
|
LOCAL void sm2130SpiDevInstInit(VXB_DEVICE_ID pDev); |
|
|
LOCAL void sm2130SpiDevInstInit(VXB_DEVICE_ID pDev); |
|
@ -37,26 +51,28 @@ LOCAL struct drvBusFuncs sm2130SpiDevFuncs = { |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
/* Publish the methods for the resources controlled with this file */ |
|
|
/* Publish the methods for the resources controlled with this file */ |
|
|
|
|
|
/* clang-format off */ |
|
|
LOCAL struct vxbDeviceMethod sm2130SpiDevMethods[] = { |
|
|
LOCAL struct vxbDeviceMethod sm2130SpiDevMethods[] = { |
|
|
DEVMETHOD(busDevShow, sm2130SpiDevShow), |
|
|
DEVMETHOD(busDevShow , sm2130SpiDevShow), |
|
|
DEVMETHOD(vxbDrvUnlink, sm2130SpiDevInstUnlink), |
|
|
DEVMETHOD(vxbDrvUnlink, sm2130SpiDevInstUnlink), |
|
|
{ 0, 0 } |
|
|
{ 0, 0 } |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
LOCAL struct vxbSpiRegister sm2130SpiDevRegister = { |
|
|
LOCAL struct vxbSpiRegister sm2130SpiDevRegister = { |
|
|
{ |
|
|
{ |
|
|
NULL, /* pNext */ |
|
|
NULL, /* pNext */ |
|
|
VXB_DEVID_DEVICE, /* devID */ |
|
|
VXB_DEVID_DEVICE, /* devID */ |
|
|
VXB_BUSID_SPI, /* busID = SPI */ |
|
|
VXB_BUSID_SPI, /* busID = SPI */ |
|
|
VXB_VER_4_0_0, /* vxbVersion */ |
|
|
VXB_VER_4_0_0, /* vxbVersion */ |
|
|
SPI_DEV_SM2130, /* drvName */ |
|
|
SPI_DEV_SM2130, /* drvName */ |
|
|
&sm2130SpiDevFuncs, /* pDrvBusFuncs */ |
|
|
&sm2130SpiDevFuncs, /* pDrvBusFuncs */ |
|
|
sm2130SpiDevMethods, /* pMethods */ |
|
|
sm2130SpiDevMethods, /* pMethods */ |
|
|
NULL, //sm2130Probe, /* devProbe */
|
|
|
NULL, /* devProbe */ |
|
|
NULL, /* pParamDefaults */ |
|
|
NULL, /* pParamDefaults */ |
|
|
}, |
|
|
}, |
|
|
}; |
|
|
}; |
|
|
|
|
|
/* clang-format on */ |
|
|
|
|
|
|
|
|
/*
|
|
|
/*
|
|
|
* |
|
|
* |
|
|
* vxbSm2130SpiDevRegister - register with the VxBus subsystem |
|
|
* vxbSm2130SpiDevRegister - register with the VxBus subsystem |
|
@ -85,6 +101,7 @@ void vxbSm2130SpiDevRegister(void) |
|
|
LOCAL void sm2130SpiDevInstInit(VXB_DEVICE_ID pDev) |
|
|
LOCAL void sm2130SpiDevInstInit(VXB_DEVICE_ID pDev) |
|
|
{ |
|
|
{ |
|
|
SM2130_SPI_DEV *pDrvCtrl; |
|
|
SM2130_SPI_DEV *pDrvCtrl; |
|
|
|
|
|
struct hcfDevice *pHcf; |
|
|
|
|
|
|
|
|
/* Check for vaild parameter */ |
|
|
/* Check for vaild parameter */ |
|
|
VXB_ASSERT_NONNULL_V(pDev); |
|
|
VXB_ASSERT_NONNULL_V(pDev); |
|
@ -97,9 +114,19 @@ LOCAL void sm2130SpiDevInstInit(VXB_DEVICE_ID pDev) |
|
|
pDrvCtrl->pDev = pDev; |
|
|
pDrvCtrl->pDev = pDev; |
|
|
pDev->pDrvCtrl = pDrvCtrl; |
|
|
pDev->pDrvCtrl = pDrvCtrl; |
|
|
|
|
|
|
|
|
pDrvCtrl->read = spiDevRead; |
|
|
pDrvCtrl->drvNode = -1; |
|
|
pDrvCtrl->write = spiDevWrite; |
|
|
pDrvCtrl->devHandle = NULL; |
|
|
|
|
|
pDrvCtrl->devName = SM2310_DEV_NAME; |
|
|
|
|
|
pHcf = (struct hcfDevice *)hcfDeviceGet(pDev); |
|
|
|
|
|
if (pHcf) { |
|
|
|
|
|
if (devResourceGet(pHcf, "devName", HCF_RES_STRING, (void *)&pDrvCtrl->devName) != OK) { |
|
|
|
|
|
pDrvCtrl->devName = SM2310_DEV_NAME; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
pDrvCtrl->read = sm2130BusDevRead; |
|
|
|
|
|
pDrvCtrl->write = sm2130BusDevWrite; |
|
|
|
|
|
|
|
|
vxbNextUnitGet(pDev); |
|
|
vxbNextUnitGet(pDev); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -125,14 +152,75 @@ LOCAL void sm2130SpiDevInstInit2(VXB_DEVICE_ID pDev) |
|
|
/* Mutex semaphore is initialized and necessary at this point */ |
|
|
/* Mutex semaphore is initialized and necessary at this point */ |
|
|
pDrvCtrl->muteSem = semMCreate(SPI_DEV_MUTEX_OPT); |
|
|
pDrvCtrl->muteSem = semMCreate(SPI_DEV_MUTEX_OPT); |
|
|
|
|
|
|
|
|
pFunc = vxbDevMethodGet(vxbDevParent(pDev), |
|
|
pFunc = vxbDevMethodGet(vxbDevParent(pDev), (VXB_METHOD_ID)vxbSpiSpecialGet_desc); |
|
|
(VXB_METHOD_ID)vxbSpiSpecialGet_desc); |
|
|
|
|
|
|
|
|
|
|
|
/* Retrieve the SPI master special information */ |
|
|
/* Retrieve the SPI master special information */ |
|
|
if (pFunc != NULL) |
|
|
if (pFunc != NULL) |
|
|
(*pFunc)(vxbDevParent(pDev), &pDrvCtrl->specialInfo); |
|
|
(*pFunc)(vxbDevParent(pDev), &pDrvCtrl->specialInfo); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/* {{{ device driver api */ |
|
|
|
|
|
LOCAL SM2310_DEV_HANDLE *drv1553bOpen(SM2310_DEV_HANDLE *dev, const char *name, int flags, int mode) |
|
|
|
|
|
{ |
|
|
|
|
|
SM2130_SPI_DEV *pDrvCtrl = dev->pDevCtrl; |
|
|
|
|
|
|
|
|
|
|
|
(void)semTake(pDrvCtrl->muteSem, WAIT_FOREVER); |
|
|
|
|
|
++pDrvCtrl->refcount; |
|
|
|
|
|
(void)semGive(pDrvCtrl->muteSem); |
|
|
|
|
|
printf("open: %p\n", dev); |
|
|
|
|
|
return dev; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
LOCAL int drv1553bClose(SM2310_DEV_HANDLE *dev) |
|
|
|
|
|
{ |
|
|
|
|
|
SM2130_SPI_DEV *pDrvCtrl = dev->pDevCtrl; |
|
|
|
|
|
|
|
|
|
|
|
(void)semTake(pDrvCtrl->muteSem, WAIT_FOREVER); |
|
|
|
|
|
--pDrvCtrl->refcount; |
|
|
|
|
|
(void)semGive(pDrvCtrl->muteSem); |
|
|
|
|
|
|
|
|
|
|
|
printf("close: %p\n", dev); |
|
|
|
|
|
return (OK); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
LOCAL int drv1553bIoctl(SM2310_DEV_HANDLE *dev, int cmd, _Vx_ioctl_arg_t arg) |
|
|
|
|
|
{ |
|
|
|
|
|
SM2130_XFER *xfer; |
|
|
|
|
|
SM2130_SPI_DEV *pDrvCtrl = dev->pDevCtrl; |
|
|
|
|
|
STATUS ret = OK; |
|
|
|
|
|
|
|
|
|
|
|
printf("ioctl: %p\n", dev); |
|
|
|
|
|
|
|
|
|
|
|
(void)semTake(pDrvCtrl->muteSem, WAIT_FOREVER); |
|
|
|
|
|
switch (cmd) { |
|
|
|
|
|
case FIOSELECT: |
|
|
|
|
|
ret = selNodeAdd(&dev->selList, (SEL_WAKEUP_NODE *)arg); |
|
|
|
|
|
break; |
|
|
|
|
|
case FIOUNSELECT: |
|
|
|
|
|
ret = selNodeDelete(&dev->selList, (SEL_WAKEUP_NODE *)arg); |
|
|
|
|
|
break; |
|
|
|
|
|
case FIO_XFER: |
|
|
|
|
|
xfer = (SM2130_XFER *)(arg); |
|
|
|
|
|
switch (xfer->type) { |
|
|
|
|
|
case FIO_XFER_TX: |
|
|
|
|
|
pDrvCtrl->write(pDrvCtrl->pDev, xfer->reg, xfer->val); |
|
|
|
|
|
break; |
|
|
|
|
|
case FIO_XFER_RX: |
|
|
|
|
|
xfer->val = pDrvCtrl->read(pDrvCtrl->pDev, xfer->reg); |
|
|
|
|
|
break; |
|
|
|
|
|
default: |
|
|
|
|
|
errnoSet(EINVAL); |
|
|
|
|
|
ret = ERROR; |
|
|
|
|
|
} |
|
|
|
|
|
break; |
|
|
|
|
|
default: |
|
|
|
|
|
break; |
|
|
|
|
|
} |
|
|
|
|
|
(void)semGive(pDrvCtrl->muteSem); |
|
|
|
|
|
return (ret); |
|
|
|
|
|
} |
|
|
|
|
|
/* }}} */ |
|
|
|
|
|
|
|
|
/*
|
|
|
/*
|
|
|
* sm2130SpiDevInstConnect - third level initialization routine of spi flash |
|
|
* sm2130SpiDevInstConnect - third level initialization routine of spi flash |
|
|
* |
|
|
* |
|
@ -146,11 +234,41 @@ LOCAL void sm2130SpiDevInstInit2(VXB_DEVICE_ID pDev) |
|
|
LOCAL void sm2130SpiDevInstConnect(VXB_DEVICE_ID pDev) |
|
|
LOCAL void sm2130SpiDevInstConnect(VXB_DEVICE_ID pDev) |
|
|
{ |
|
|
{ |
|
|
SM2130_SPI_DEV *pDrvCtrl; |
|
|
SM2130_SPI_DEV *pDrvCtrl; |
|
|
|
|
|
SM2310_DEV_HANDLE *dev; |
|
|
/* Check for vaild parameter */ |
|
|
/* Check for vaild parameter */ |
|
|
VXB_ASSERT_NONNULL_V(pDev); |
|
|
VXB_ASSERT_NONNULL_V(pDev); |
|
|
|
|
|
|
|
|
pDrvCtrl = (SM2130_SPI_DEV *)pDev->pDrvCtrl; |
|
|
pDrvCtrl = (SM2130_SPI_DEV *)pDev->pDrvCtrl; |
|
|
|
|
|
|
|
|
|
|
|
(void)semTake(pDrvCtrl->muteSem, WAIT_FOREVER); |
|
|
|
|
|
if (pDrvCtrl->drvNode < 0) { |
|
|
|
|
|
/* clang-format off */ |
|
|
|
|
|
pDrvCtrl->drvNode = iosDrvInstall( |
|
|
|
|
|
(DRV_CREATE_PTR)drv1553bOpen , |
|
|
|
|
|
(DRV_REMOVE_PTR)NULL , |
|
|
|
|
|
(DRV_OPEN_PTR)drv1553bOpen , |
|
|
|
|
|
(DRV_CLOSE_PTR)drv1553bClose , |
|
|
|
|
|
(DRV_READ_PTR)NULL , |
|
|
|
|
|
(DRV_WRITE_PTR)NULL , |
|
|
|
|
|
(DRV_IOCTL_PTR)drv1553bIoctl); |
|
|
|
|
|
/* clang-format on */ |
|
|
|
|
|
if (pDrvCtrl->drvNode > 0) { |
|
|
|
|
|
dev = (SM2310_DEV_HANDLE *)hwMemAlloc(sizeof(SM2310_DEV_HANDLE)); |
|
|
|
|
|
if (dev) { |
|
|
|
|
|
pDrvCtrl->refcount = 0; |
|
|
|
|
|
selWakeupListInit(&dev->selList); |
|
|
|
|
|
if (iosDevAdd(&dev->devHdr, pDrvCtrl->devName, pDrvCtrl->drvNode) == OK) { |
|
|
|
|
|
pDrvCtrl->devHandle = dev; |
|
|
|
|
|
dev->pDevCtrl = pDrvCtrl; |
|
|
|
|
|
} else { |
|
|
|
|
|
#ifndef _VXBUS_BASIC_HWMEMLIB |
|
|
|
|
|
hwMemFree((char *)dev); |
|
|
|
|
|
#endif /* _VXBUS_BASIC_HWMEMLIB */ |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
(void)semGive(pDrvCtrl->muteSem); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/*
|
|
|
/*
|
|
@ -198,19 +316,26 @@ LOCAL STATUS sm2130SpiDevInstUnlink(VXB_DEVICE_ID pDev, void *unused) |
|
|
*/ |
|
|
*/ |
|
|
LOCAL void sm2130SpiDevShow(VXB_DEVICE_ID pDev, int verbose) |
|
|
LOCAL void sm2130SpiDevShow(VXB_DEVICE_ID pDev, int verbose) |
|
|
{ |
|
|
{ |
|
|
printf(" %s unit %d on %s @ 0x%08x", pDev->pName, pDev->unitNumber, |
|
|
SM2130_SPI_DEV *pDrvCtrl = (SM2130_SPI_DEV *)pDev->pDrvCtrl; |
|
|
vxbBusTypeString(pDev->busID), pDev); |
|
|
|
|
|
|
|
|
printf(" %s unit %d on %s @ 0x%08x", pDev->pName, pDev->unitNumber, vxbBusTypeString(pDev->busID), pDev); |
|
|
printf(" with busInfo %p\n", pDev->u.pSubordinateBus); |
|
|
printf(" with busInfo %p\n", pDev->u.pSubordinateBus); |
|
|
|
|
|
|
|
|
if (verbose) { |
|
|
if (verbose) { |
|
|
|
|
|
printf(" chipSelect: %d\n", pDrvCtrl->cs); |
|
|
|
|
|
printf(" mode: %d\n", pDrvCtrl->mode); |
|
|
|
|
|
printf(" speed: %u\n", pDrvCtrl->freq); |
|
|
|
|
|
printf(" devName: %s\n", pDrvCtrl->devName); |
|
|
|
|
|
printf(" devHandle: %p\n", pDrvCtrl->devHandle); |
|
|
|
|
|
printf(" drvNode: %d\n", pDrvCtrl->drvNode); |
|
|
|
|
|
printf(" refCount: %d\n", pDrvCtrl->refcount); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
return; |
|
|
return; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/*
|
|
|
/*
|
|
|
* spiDevWrite - VxBus SPI device write by name support routine |
|
|
* sm2130BusDevWrite - VxBus SPI device write by name support routine |
|
|
* |
|
|
* |
|
|
* This routine firstly finds the VXB_DEVICE_ID for a given instance |
|
|
* This routine firstly finds the VXB_DEVICE_ID for a given instance |
|
|
* identified by name and unit number, then call vxbI2cDevWrite() routine to |
|
|
* identified by name and unit number, then call vxbI2cDevWrite() routine to |
|
@ -220,25 +345,25 @@ LOCAL void sm2130SpiDevShow(VXB_DEVICE_ID pDev, int verbose) |
|
|
* |
|
|
* |
|
|
* ERRNO : N/A |
|
|
* ERRNO : N/A |
|
|
*/ |
|
|
*/ |
|
|
LOCAL STATUS spiDevWrite(VXB_DEVICE_ID pDev, UINT8 cmd, UINT16 var) |
|
|
LOCAL STATUS sm2130BusDevWrite(VXB_DEVICE_ID pDev, UINT8 cmd, UINT16 var) |
|
|
{ |
|
|
{ |
|
|
SPI_TRANSFER transInfo = {NULL, NULL, 0, 0, 0}; |
|
|
SPI_TRANSFER transInfo = { NULL, NULL, 0, 0, 0 }; |
|
|
UINT8 buf[3]; |
|
|
UINT8 buf[3]; |
|
|
/* Check if the pDev pointer is valid */ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Check if the pDev pointer is valid */ |
|
|
VXB_ASSERT(pDev != NULL, ERROR) |
|
|
VXB_ASSERT(pDev != NULL, ERROR) |
|
|
buf[0] = cmd; |
|
|
buf[0] = cmd; |
|
|
buf[1] = var & 0xff; |
|
|
buf[1] = var & 0xff; |
|
|
buf[1] = (var >> 8) & 0xff; |
|
|
buf[1] = (var >> 8) & 0xff; |
|
|
|
|
|
|
|
|
transInfo.txBuf = buf; |
|
|
transInfo.txBuf = buf; |
|
|
transInfo.txLen = 3; |
|
|
transInfo.txLen = 3; |
|
|
|
|
|
|
|
|
return (vxbSpiTransfer(pDev, &transInfo)); |
|
|
return vxbSpiTransfer(pDev, &transInfo); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/*
|
|
|
/*
|
|
|
* spiDevRead - read register routine |
|
|
* sm2130BusDevRead - read register routine |
|
|
* |
|
|
* |
|
|
* This is the SPI flash status /config register read out routine. |
|
|
* This is the SPI flash status /config register read out routine. |
|
|
* |
|
|
* |
|
@ -246,57 +371,62 @@ LOCAL STATUS spiDevWrite(VXB_DEVICE_ID pDev, UINT8 cmd, UINT16 var) |
|
|
* |
|
|
* |
|
|
* ERRNO: N/A |
|
|
* ERRNO: N/A |
|
|
*/ |
|
|
*/ |
|
|
LOCAL INT32 spiDevRead(VXB_DEVICE_ID pDev, UINT8 cmd) |
|
|
LOCAL INT32 sm2130BusDevRead(VXB_DEVICE_ID pDev, UINT8 cmd) |
|
|
{ |
|
|
{ |
|
|
SPI_TRANSFER transInfo = {NULL, NULL, 0, 0, 0}; |
|
|
SPI_TRANSFER transInfo = { NULL, NULL, 0, 0, 0 }; |
|
|
UINT16 buffer = 0xffff; |
|
|
UINT16 buffer; |
|
|
|
|
|
UINT8 buf[3] = { 0xff, 0xff, 0xff }; |
|
|
|
|
|
|
|
|
/* check if the pDev pointer is valid */ |
|
|
/* check if the pDev pointer is valid */ |
|
|
|
|
|
|
|
|
VXB_ASSERT(pDev != NULL, ERROR) |
|
|
VXB_ASSERT(pDev != NULL, ERROR) |
|
|
|
|
|
|
|
|
transInfo.txBuf = &cmd; |
|
|
buf[0] = cmd; |
|
|
|
|
|
|
|
|
|
|
|
transInfo.txBuf = buf; |
|
|
transInfo.txLen = 1; |
|
|
transInfo.txLen = 1; |
|
|
transInfo.rxBuf = (UINT8 *)&buffer; |
|
|
transInfo.rxBuf = buf; |
|
|
transInfo.rxLen = 2; |
|
|
transInfo.rxLen = 3; |
|
|
|
|
|
|
|
|
if (vxbSpiTransfer(pDev, &transInfo) != OK) |
|
|
if (vxbSpiTransfer(pDev, &transInfo) != OK) |
|
|
return ERROR; |
|
|
return ERROR; |
|
|
else |
|
|
|
|
|
return (buffer); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
buffer = (buf[2] << 8) | buf[1]; |
|
|
|
|
|
return (buffer); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/* {{{ Test Read write */ |
|
|
INT32 sm2130Read(UINT8 cmd) |
|
|
INT32 sm2130Read(UINT8 cmd) |
|
|
{ |
|
|
{ |
|
|
VXB_DEVICE_ID pDev; |
|
|
VXB_DEVICE_ID pDev; |
|
|
SM2130_SPI_DEV * pCtrl; |
|
|
SM2130_SPI_DEV *pCtrl; |
|
|
|
|
|
|
|
|
pDev = vxbInstByNameFind(SPI_DEV_SM2130, 0); |
|
|
pDev = vxbInstByNameFind(SPI_DEV_SM2130, 0); |
|
|
if (pDev == NULL) { |
|
|
if (pDev == NULL) { |
|
|
return ERROR; |
|
|
return ERROR; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
pCtrl = pDev->pDrvCtrl; |
|
|
pCtrl = pDev->pDrvCtrl; |
|
|
|
|
|
|
|
|
/* printf("pDev @ %p, pCtrl %p\n", pDev, pCtrl); */ |
|
|
/* printf("pDev @ %p, pCtrl %p\n", pDev, pCtrl); */ |
|
|
|
|
|
|
|
|
return pCtrl->read(pDev, cmd); |
|
|
return pCtrl->read(pDev, cmd); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
STATUS sm2130Write(UINT8 cmd, UINT16 var) |
|
|
STATUS sm2130Write(UINT8 cmd, UINT16 var) |
|
|
{ |
|
|
{ |
|
|
VXB_DEVICE_ID pDev; |
|
|
VXB_DEVICE_ID pDev; |
|
|
SM2130_SPI_DEV * pCtrl; |
|
|
SM2130_SPI_DEV *pCtrl; |
|
|
|
|
|
|
|
|
pDev = vxbInstByNameFind(SPI_DEV_SM2130, 0); |
|
|
pDev = vxbInstByNameFind(SPI_DEV_SM2130, 0); |
|
|
if (pDev == NULL) { |
|
|
if (pDev == NULL) { |
|
|
return ERROR; |
|
|
return ERROR; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
pCtrl = pDev->pDrvCtrl; |
|
|
pCtrl = pDev->pDrvCtrl; |
|
|
|
|
|
|
|
|
/* printf("pDev @ %p, pCtrl %p\n", pDev, pCtrl); */ |
|
|
/* printf("pDev @ %p, pCtrl %p\n", pDev, pCtrl); */ |
|
|
|
|
|
|
|
|
return pCtrl->write(pDev, cmd, var); |
|
|
return pCtrl->write(pDev, cmd, var); |
|
|
} |
|
|
} |
|
|
|
|
|
/* }}} */ |
|
|