Browse Source

pinmux gpios, sm2130 add irq handler

Signed-off-by: surenyi <surenyi82@163.com>
master
surenyi 2 weeks ago
parent
commit
2d4406c2bc
  1. 20
      bspStubs.c
  2. 13
      hwconf.c
  3. 11
      sysLib.c
  4. 35
      vxbFtSpi.c
  5. 14
      vxbLfsLib.c
  6. 15
      vxbSm2130SpiDev.c
  7. 1
      vxbSm2130SpiDev.h

20
bspStubs.c

@ -6,7 +6,10 @@
#include <cacheLib.h>
#include <sysSymTbl.h>
#include <fcntl.h>
#include <hwif/vxbus/vxBus.h>
#include "config.h"
#include "vxbFtGpio.h"
#if defined(INCLUDE_IPFTPS)
#include <ipcom_sysvar.h>
#include <ipcom_sock.h>
@ -18,7 +21,7 @@
/* externs */
extern int lfsLowRawWrite(unsigned long offset, const char *buffer, int size);
extern void gpioIsrSetTest (UINT32 gpio, UINT32 pin);
int bspLoadUserApp()
{
SEGMENT_ID seg;
@ -120,6 +123,21 @@ int bsp_ipftps_authenticate_nopasswd(Ipftps_session *session, char *password)
}
#endif
/* GPIO1_A4 */
int bspSm1553bIrqConnect(void *data, void (*isr)(void *data))
{
VXB_DEVICE_ID pDev;
FT_GPIO_DRVCTRL * pCtrl;
pDev = vxbInstByNameFind("ftGpio", 1);
if (pDev == NULL) {
return ERROR;
}
pCtrl = pDev->pDrvCtrl;
pCtrl->gpioISRSet(pDev, 4, isr, data);
return OK;
}
int mw(unsigned long addr, unsigned int val)
{
volatile unsigned int long *ptr = (volatile unsigned long *)(addr);

13
hwconf.c

@ -366,8 +366,8 @@ struct hcfResource i2cDev3Resources[] = {
LOCAL UINT8 gpio0PortAModeTable[] = {
/*pin of portA can be used as interrupt mode*/
/*portA-pinX: 0 1 2 3 4 5 6 7 */
0, 2, 0, 0, 0, 0, 0, 0 /* 0:GPIO_MODE_NOT_USED 1:GPIO_MODE_IN
2:GPIO_MODE_OUT 3:GPIO_MODE_INT*/
0, 2, 0, 1, 0, 1, 1, 0 /* 0:GPIO_MODE_NOT_USED 1:GPIO_MODE_IN
2:GPIO_MODE_OUT 3:GPIO_MODE_INT*/ /* GPIO0_A3, GPIO0_A5, GPIO0_A6 as uart irq */
};
/*This table is used to set the default pin mode of portB*/
LOCAL UINT8 gpio0PortBModeTable[] = {
@ -524,6 +524,14 @@ struct hcfResource lfsResources[] = {
#define lfsResNum NELEMENTS(lfsResources)
#endif
extern int bspSm1553bIrqConnect(void *data, void (*isr)(void *data));
struct hcfResource sm2130Resources[] = {
{ "devName" , HCF_RES_STRING, {(void *)"/sm1553b"}},
{ "reqIsr" , HCF_RES_ADDR, {(void *)bspSm1553bIrqConnect}},
};
#define sm2130ResNum NELEMENTS(sm2130Resources)
const struct hcfDevice hcfDeviceList[] = {
#ifdef DRV_ARM_GICV3
{ "armGicDev", 0, VXB_BUSID_PLB, 0, armGICv3Num, armGICv3Resources},
@ -586,6 +594,7 @@ const struct hcfDevice hcfDeviceList[] = {
#ifdef DRV_FS_LITTLEFS
{ "lfs", 0, VXB_BUSID_PLB, 0, lfsResNum, lfsResources},
#endif
{ "SM2130", 0, VXB_BUSID_SPI, 0, sm2130ResNum, sm2130Resources},
};
const int hcfDeviceNum = NELEMENTS(hcfDeviceList);

11
sysLib.c

@ -570,6 +570,17 @@ void sysHwInit(void)
reg |= (0x1 << 8);
writel(reg, PIN_DEMUX_BASE + REG218);
/* GPIO0_A3, GPIO0_A5, GPIO0_A6
*
* sjtag_ntrst_pad: N gpio0_porta_3 uart_0_dsr_n
* tjtag_tdo_pad: N gpio0_porta_5 uart_0_rts_n
* tjtag_ntrst_pad: N gpio0_porta_6 uart_0_dtr_n
*/
reg = readl(PIN_DEMUX_BASE + REG200);
reg &= ~((0x3 << 12) | (0x3 << 8) | 0x3);
reg |= (1 << 12) | ( 1 << 8) | 1;
writel(reg, PIN_DEMUX_BASE + REG200);
#ifdef DRV_X100DC
ftX100DcDevicePciRegister();
#endif

35
vxbFtSpi.c

@ -240,23 +240,28 @@ LOCAL struct drvBusFuncs vxbFtSpiVxbFuncs = {
vxbFtSpiInstConnect /* devConnect */
};
LOCAL device_method_t vxbFtSpiDeviceMethods[] = { DEVMETHOD(vxbSpiControlGet, vxbFtSpiCtrlGet),
DEVMETHOD(busDevShow, vxbFtSpiShow),
DEVMETHOD(vxbDrvUnlink, vxbFtSpiInstUnlink), DEVMETHOD_END };
/* clang-format off */
LOCAL device_method_t vxbFtSpiDeviceMethods[] = {
DEVMETHOD(vxbSpiControlGet, vxbFtSpiCtrlGet),
DEVMETHOD(busDevShow, vxbFtSpiShow),
DEVMETHOD(vxbDrvUnlink, vxbFtSpiInstUnlink),
DEVMETHOD_END
};
LOCAL struct vxbPlbRegister vxbFtSpiDevRegistration = {
{
NULL, /* pNext */
VXB_DEVID_DEVICE, /* devID */
VXB_BUSID_PLB, /* busID = PLB */
VXB_VER_4_0_0, /* vxbVersion */
FT_SPI_NAME, /* drvName */
&vxbFtSpiVxbFuncs, /* pDrvBusFuncs */
&vxbFtSpiDeviceMethods[0], /* pMethods */
NULL, /* devProbe */
NULL, /* pParamDefaults */
NULL , /* pNext */
VXB_DEVID_DEVICE , /* devID */
VXB_BUSID_PLB , /* busID = PLB */
VXB_VER_4_0_0 , /* vxbVersion */
FT_SPI_NAME , /* drvName */
&vxbFtSpiVxbFuncs , /* pDrvBusFuncs */
&vxbFtSpiDeviceMethods[0] , /* pMethods */
NULL , /* devProbe */
NULL , /* pParamDefaults */
},
};
/* clang-format on */
/*
* vxbFtSpiRegister - register with the VxBus subsystem
@ -1049,13 +1054,13 @@ LOCAL STATUS vxbFtSpiTransfer(VXB_DEVICE_ID pDev, /* controller pDev */
FSpimSetEnable(pDrvCtrl, FALSE);
/* FSpimSetChipSelection(pDrvCtrl, TRUE); */
/* FSpimSetChipSelection(pDrvCtrl, TRUE); */
FSpimTransferPollFifo(pDrvCtrl, pPkg->txBuf, pPkg->rxBuf, max(pPkg->txLen, pPkg->rxLen));
/* FSpimSetChipSelection(pDrvCtrl, FALSE); */
/* FSpimSetChipSelection(pDrvCtrl, FALSE); */
SPI_DBG(SPI_DBG_ERR," xfer : tx %d bytes, rx %d bytes\n", pPkg->txLen, pPkg->rxLen, 3, 4, 5, 6);
SPI_DBG(SPI_DBG_ERR, " xfer : tx %d bytes, rx %d bytes\n", pPkg->txLen, pPkg->rxLen, 3, 4, 5, 6);
if (pDrvCtrl->initPhase >= 2) {
semGive(pDrvCtrl->muxSem);

14
vxbLfsLib.c

@ -507,14 +507,14 @@ LOCAL void lfsDevShow(VXB_DEVICE_ID pDev, int verbose)
printf(" with busInfo %p\n", pDev->u.pSubordinateBus);
if (verbose) {
printf(" mountPoint: %s\n", pDrvCtrl->mountPoint);
printf(" flashName: %s\n", pDrvCtrl->flashDrvName);
printf(" mtd: %p\n", pDrvCtrl->mtd);
printf(" read_size: %d\n", pDrvCtrl->lfsConfig.read_size);
printf(" prog_size: %d\n", pDrvCtrl->lfsConfig.prog_size);
printf(" block_size: %d\n", pDrvCtrl->lfsConfig.block_size);
printf(" mountPoint: %s\n", pDrvCtrl->mountPoint);
printf(" flashName: %s\n", pDrvCtrl->flashDrvName);
printf(" mtd: %p\n", pDrvCtrl->mtd);
printf(" read_size: %d\n", pDrvCtrl->lfsConfig.read_size);
printf(" prog_size: %d\n", pDrvCtrl->lfsConfig.prog_size);
printf(" block_size: %d\n", pDrvCtrl->lfsConfig.block_size);
if (pDrvCtrl->mtd) {
printf(" flashChip: %s\n", pDrvCtrl->mtd->chipName);
printf(" flashChip: %s\n", pDrvCtrl->mtd->chipName);
}
}
}

15
vxbSm2130SpiDev.c

@ -125,6 +125,9 @@ LOCAL void sm2130SpiDevInstInit(VXB_DEVICE_ID pDev)
if (devResourceGet(pHcf, "devName", HCF_RES_STRING, (void *)&pDrvCtrl->devName) != OK) {
pDrvCtrl->devName = pDrvCtrl->name;
}
if (devResourceGet(pHcf, "reqIsr", HCF_RES_ADDR, (void *)&pDrvCtrl->reqIsr) != OK) {
pDrvCtrl->reqIsr = NULL;
}
}
pDrvCtrl->read = sm2130BusDevRead;
@ -243,6 +246,14 @@ LOCAL void sm2130SpiDevInstInit2(VXB_DEVICE_ID pDev)
(*pFunc)(vxbDevParent(pDev), &pDrvCtrl->specialInfo);
}
LOCAL void sm1553isr(void *data)
{
SM2310_DEV_HANDLE *dev = data;
logMsg("sm1553isr interrupt", 1, 2, 3, 4, 5, 6);
selWakeupAll(&dev->selList, SELREAD);
}
/*
* sm2130SpiDevInstConnect - third level initialization routine of spi flash
*
@ -284,6 +295,9 @@ LOCAL void sm2130SpiDevInstConnect(VXB_DEVICE_ID pDev)
if (iosDevAdd(&dev->devHdr, pDrvCtrl->devName, sm2130_driver_node) == OK) {
pDrvCtrl->devHandle = dev;
dev->pDevCtrl = pDrvCtrl;
if (pDrvCtrl->reqIsr) {
pDrvCtrl->reqIsr(dev, sm1553isr);
}
} else {
#ifndef _VXBUS_BASIC_HWMEMLIB
hwMemFree((char *)dev);
@ -351,6 +365,7 @@ LOCAL void sm2130SpiDevShow(VXB_DEVICE_ID pDev, int verbose)
printf(" devName: %s\n", pDrvCtrl->devName);
printf(" devHandle: %p\n", pDrvCtrl->devHandle);
printf(" refCount: %d\n", pDrvCtrl->refcount);
printf(" reqIsr: %p\n", pDrvCtrl->reqIsr);
}
return;

1
vxbSm2130SpiDev.h

@ -41,6 +41,7 @@ typedef struct _spi_1553b_drv_ctrl {
int refcount;
void *devHandle;
int (*reqIsr)(void *data, void (*isr)(void *data));
INT32 (*read)(VXB_DEVICE_ID pDev, UINT8 cmd);
STATUS (*write)(VXB_DEVICE_ID pDev, UINT8 cmd, UINT16 var);

Loading…
Cancel
Save