Пример #1
0
//#define MULTI_ADDR_MODE 1
GT_STATUS qdStart(int cpuPort)
{
	GT_STATUS status;


	/*
	 *   Register all the required functions to QuarterDeck Driver.
	 * */
	memset((char*)&cfg,0,sizeof(GT_SYS_CONFIG));
	memset((char*)&diagDev,0,sizeof(GT_QD_DEV));

	dev = &diagDev;

	cfg.BSPFunctions.readMii   = switchReadReg;
	cfg.BSPFunctions.writeMii  = switchWriteReg;
#ifdef GT_RMGMT_ACCESS
	cfg.BSPFunctions.hwAccess  = gtBspHwAccess; 
#endif
#ifdef USE_SEMAPHORE
	cfg.BSPFunctions.semCreate = osSemCreate;
	cfg.BSPFunctions.semDelete = osSemDelete;
	cfg.BSPFunctions.semTake   = osSemWait;
	cfg.BSPFunctions.semGive   = osSemSignal;
#else
	cfg.BSPFunctions.semCreate = NULL;
	cfg.BSPFunctions.semDelete = NULL;
	cfg.BSPFunctions.semTake   = NULL;
	cfg.BSPFunctions.semGive   = NULL;
#endif
	gtBspMiiInit(dev);

	cfg.initPorts = GT_TRUE;    /* Set switch ports to Forwarding mode. If GT_FALSE, use Default Setting. */
	cfg.cpuPortNum = cpuPort;
#ifdef MANUAL_MODE    /* not defined. this is only for sample */
	/* user may want to use this mode when there are two QD switchs on the same MII bus. */
	cfg.mode.scanMode = SMI_MANUAL_MODE;    /* Use QD located at manually defined base addr */
	cfg.mode.baseAddr = 0x10;    /* valid value in this case is either 0 or 0x10 */
#else
#ifdef MULTI_ADDR_MODE
	cfg.mode.scanMode = SMI_MULTI_ADDR_MODE;    /* find a QD in indirect access mode */
	cfg.mode.baseAddr = 1;        /* this is the phyAddr used by QD family device. 
									 Valid value are 1 ~ 31.*/
#else
	cfg.mode.scanMode = SMI_AUTO_SCAN_MODE;    /* Scan 0 or 0x10 base address to find the QD */
	cfg.mode.baseAddr = 0;
#endif
#endif


	if((status=qdLoadDriver(&cfg, dev)) != GT_OK)
	{
		ERROR(GLOBAL_OUT_GROUP, "qdLoadDriver return Failed\n");
		return status;
	}

	INFO(GLOBAL_OUT_GROUP,"Device ID     : 0x%x\n",dev->deviceId);
	INFO(GLOBAL_OUT_GROUP,"Base Reg Addr : 0x%x\n",dev->baseRegAddr);
	INFO(GLOBAL_OUT_GROUP,"No of Ports   : %d\n",(int)dev->numOfPorts);
	INFO(GLOBAL_OUT_GROUP,"CPU Ports     : %d\n",(int)dev->cpuPortNum);

	/*
	 *      *  start the QuarterDeck
	 *          */
	if((status=sysEnable(dev)) != GT_OK)
	{
		ERROR(GLOBAL_OUT_GROUP,"sysConfig return Failed\n");
		return status;
	}

	INFO(GLOBAL_OUT_GROUP,"QuarterDeck has been started.\n");


	return GT_OK;
}
Пример #2
0
GT_QD_DEV* loadDev(GT_QD_DEV* dev, int mode, int phyAddr, int cpuPort, unsigned int cfgMode)
{
	GT_QD_DEV* d = dev;
	GT_STATUS status = GT_FAIL;
	GT_SYS_CONFIG   cfg;

	if((int)dev == -1)
		goto printUse;

	memset((char*)&cfg,0,sizeof(GT_SYS_CONFIG));

	if(d == NULL)
	{
		d = (GT_QD_DEV*)malloc(sizeof(GT_QD_DEV));

		if(d == NULL)
		{
			MSG_PRINT(("Failed to allocate Device Structure\n"));
			return NULL;
		}
	}

	memset((char*)d,0,sizeof(GT_QD_DEV));

	cfg.BSPFunctions.readMii   = ffReadMii;
	cfg.BSPFunctions.writeMii  = ffWriteMii;
#ifdef USE_SEMAPHORE
	cfg.BSPFunctions.semCreate = osSemCreate;
	cfg.BSPFunctions.semDelete = osSemDelete;
	cfg.BSPFunctions.semTake   = osSemWait;
	cfg.BSPFunctions.semGive   = osSemSignal;
#else
	cfg.BSPFunctions.semCreate = NULL;
	cfg.BSPFunctions.semDelete = NULL;
	cfg.BSPFunctions.semTake   = NULL;
	cfg.BSPFunctions.semGive   = NULL;
#endif

	cfg.initPorts = GT_TRUE;	/* Set switch ports to Forwarding mode. If GT_FALSE, use Default Setting. */
	cfg.cpuPortNum = cpuPort;
	cfg.skipInitSetup = (GT_U32)cfgMode;

	switch(mode)
	{
		case SMI_MANUAL_MODE:		/* Use QD located at manually defined base addr */
		case SMI_MULTI_ADDR_MODE:	/* Use QD in multi chip address mode */
			cfg.mode.scanMode = mode;
			cfg.mode.baseAddr = phyAddr;	/* valid value in this case is either 0 or 0x10 */
			break;
		case SMI_AUTO_SCAN_MODE:	/* Scan 0 or 0x10 base address to find the QD */
			cfg.mode.scanMode = mode;
			cfg.mode.baseAddr = 0;
			break;
		default:
			MSG_PRINT(("Unknown Mode %i\n",mode));
			goto printUse;
	}

	if((status=qdLoadDriver(&cfg, d)) != GT_OK)
	{
		MSG_PRINT(("qdLoadDriver return Failed\n"));
		goto loadErr;
	}

	MSG_PRINT(("Device ID     : 0x%x\n",d->deviceId));
	MSG_PRINT(("PHY Addr      : 0x%x\n",d->phyAddr));
	MSG_PRINT(("Base Addr     : 0x%x\n",d->baseRegAddr));
	MSG_PRINT(("CPU Ports     : %d\n",d->cpuPortNum));

	/*
	 *  start the QuarterDeck
	*/
	if((status=sysEnable(d)) != GT_OK)
	{
		MSG_PRINT(("sysConfig return Failed\n"));
		goto loadErr;
	}

	return d;

printUse:
	MSG_PRINT(("Usage: loadDev(Dev,mode,phyAddr,cpuPort)\n",SMI_AUTO_SCAN_MODE));
	MSG_PRINT(("\tSMI_AUTO_SCAN_MODE :  %i\n",SMI_AUTO_SCAN_MODE));
	MSG_PRINT(("\tSMI_MANUAL_MODE :     %i\n",SMI_MANUAL_MODE));
	MSG_PRINT(("\tSMI_MULTI_ADDR_MODE : %i\n",SMI_MULTI_ADDR_MODE));
	MSG_PRINT(("Example: loadDev(0,1,0x10,5)\n"));
	MSG_PRINT(("for Manual mode, phy base address 0x10, and cpu port 5\n"));

loadErr:

	if(dev)
		return NULL;

	if(d)
		free(d);

	return NULL;
}
Пример #3
0
GT_STATUS RubyStart(int phyAddr, GT_QD_DEV* d)
{
	GT_STATUS status = GT_FAIL;
	GT_SYS_CONFIG   cfg;

	memset((char*)&cfg,0,sizeof(GT_SYS_CONFIG));
	MSG_PRINT(("Size of GT_QD_DEV %i\n",sizeof(GT_QD_DEV)));

	if(d == NULL)
	{
		MSG_PRINT(("Device Structure is NULL.\n"));
		return GT_FAIL;
	}

	memset((char*)d,0,sizeof(GT_QD_DEV));

	cfg.BSPFunctions.readMii   = ffReadMii;
	cfg.BSPFunctions.writeMii  = ffWriteMii;
#ifdef USE_SEMAPHORE
	cfg.BSPFunctions.semCreate = osSemCreate;
	cfg.BSPFunctions.semDelete = osSemDelete;
	cfg.BSPFunctions.semTake   = osSemWait;
	cfg.BSPFunctions.semGive   = osSemSignal;
#else
	cfg.BSPFunctions.semCreate = NULL;
	cfg.BSPFunctions.semDelete = NULL;
	cfg.BSPFunctions.semTake   = NULL;
	cfg.BSPFunctions.semGive   = NULL;
#endif

	cfg.initPorts = GT_TRUE;	/* Set switch ports to Forwarding mode. If GT_FALSE, use Default Setting. */
	cfg.cpuPortNum = 10;

	cfg.mode.scanMode = SMI_MULTI_ADDR_MODE;
	cfg.mode.baseAddr = phyAddr;	/* valid value in this case is either 0 or 0x10 */

	if((status=qdLoadDriver(&cfg, d)) != GT_OK)
	{
		MSG_PRINT(("qdLoadDriver return Failed\n"));
		return status;
	}

	MSG_PRINT(("Device ID     : 0x%x\n",d->deviceId));
	MSG_PRINT(("PHY Addr      : 0x%x\n",d->phyAddr));
	MSG_PRINT(("Base Addr     : 0x%x\n",d->baseRegAddr));
	MSG_PRINT(("CPU Ports     : %d\n",d->cpuPortNum));
	MSG_PRINT(("N Ports       : %d\n",d->numOfPorts));
	MSG_PRINT(("Device Group  : 0x%x\n",d->devName));
	MSG_PRINT(("QDDev         : %#x\n",(unsigned long)&d));

	/*
	 *  start the QuarterDeck
	*/
	if((status=sysEnable(d)) != GT_OK)
	{
		MSG_PRINT(("sysConfig return Failed\n"));
		return status;
	}

	return GT_OK;
}
Пример #4
0
GT_STATUS qdStart(int cpuPort, int useQdSim, int devId) /* devId is used for simulator only */
{
GT_STATUS status;

    /*
     *  Register all the required functions to QuarterDeck Driver.
    */
    memset((char*)&cfg,0,sizeof(GT_SYS_CONFIG));
    memset((char*)&diagDev,0,sizeof(GT_QD_DEV));

    if(useQdSim == 0) /* use EV-96122 */
    {
        cfg.BSPFunctions.readMii   = gtBspReadMii;
        cfg.BSPFunctions.writeMii  = gtBspWriteMii;
#ifdef GT_RMGMT_ACCESS
    cfg.BSPFunctions.hwAccess  = gtBspHwAccess;
#endif
#ifdef USE_SEMAPHORE
        cfg.BSPFunctions.semCreate = osSemCreate;
        cfg.BSPFunctions.semDelete = osSemDelete;
        cfg.BSPFunctions.semTake   = osSemWait;
        cfg.BSPFunctions.semGive   = osSemSignal;
#else
        cfg.BSPFunctions.semCreate = NULL;
        cfg.BSPFunctions.semDelete = NULL;
        cfg.BSPFunctions.semTake   = NULL;
        cfg.BSPFunctions.semGive   = NULL;
#endif
        gtBspMiiInit(dev);
    }
    else    /* use QuaterDeck Simulator (No QD Device Required.) */
    {
        cfg.BSPFunctions.readMii   = qdSimRead;
        cfg.BSPFunctions.writeMii  = qdSimWrite;
#ifdef USE_SEMAPHORE
        cfg.BSPFunctions.semCreate = osSemCreate;
        cfg.BSPFunctions.semDelete = osSemDelete;
        cfg.BSPFunctions.semTake   = osSemWait;
        cfg.BSPFunctions.semGive   = osSemSignal;
#else
        cfg.BSPFunctions.semCreate = NULL;
        cfg.BSPFunctions.semDelete = NULL;
        cfg.BSPFunctions.semTake   = NULL;
        cfg.BSPFunctions.semGive   = NULL;
#endif

        qdSimInit(devId,0);
    }

    cfg.initPorts = GT_TRUE;    /* Set switch ports to Forwarding mode. If GT_FALSE, use Default Setting. */
    cfg.cpuPortNum = cpuPort;
#ifdef MANUAL_MODE    /* not defined. this is only for sample */
    /* user may want to use this mode when there are two QD switchs on the same MII bus. */
    cfg.mode.scanMode = SMI_MANUAL_MODE;    /* Use QD located at manually defined base addr */
    cfg.mode.baseAddr = 0x10;    /* valid value in this case is either 0 or 0x10 */
#else
#ifdef MULTI_ADDR_MODE
    cfg.mode.scanMode = SMI_MULTI_ADDR_MODE;    /* find a QD in indirect access mode */
    cfg.mode.baseAddr = 1;        /* this is the phyAddr used by QD family device.
                                Valid value are 1 ~ 31.*/
#else
    cfg.mode.scanMode = SMI_AUTO_SCAN_MODE;    /* Scan 0 or 0x10 base address to find the QD */
    cfg.mode.baseAddr = 0;
#endif
#endif
    if((status=qdLoadDriver(&cfg, dev)) != GT_OK)
    {
        MSG_PRINT(("qdLoadDriver return Failed\n"));
        return status;
    }

    MSG_PRINT(("Device ID     : 0x%x\n",dev->deviceId));
    MSG_PRINT(("Base Reg Addr : 0x%x\n",dev->baseRegAddr));
    MSG_PRINT(("No of Ports   : %d\n",dev->numOfPorts));
    MSG_PRINT(("CPU Ports     : %d\n",dev->cpuPortNum));

    /*
     *  start the QuarterDeck
    */
    if((status=sysEnable(dev)) != GT_OK)
    {
        MSG_PRINT(("sysConfig return Failed\n"));
        return status;
    }

    MSG_PRINT(("QuarterDeck has been started.\n"));

    return GT_OK;
}