static void toggle_port(int toggle_idx)
{
	int i;
	i = allport[toggle_idx].master;
	if (i < SMI_LARB_NUMBER) {
		smi_larb[i].port = allport[toggle_idx].port;
		smi_larb[i].rwtype = allport[toggle_idx].rwtype;
		smi_larb[i].desttype = allport[toggle_idx].desttype;
		smi_larb[i].bustype = allport[toggle_idx].bustype;
		SMI_Disable(i);
		SMI_Clear(i);
		SMI_SetSMIBMCfg(i, smi_larb[i].port, smi_larb[i].desttype, smi_larb[i].rwtype);
		//SMI_SetMonitorControl(0);  //SMIBMCfgEx default
		SMI_SetMonitorControl(&monitorctrl);
		SMI_Enable(i, smi_larb[i].bustype);
	} else {
		i = i - SMI_LARB_NUMBER;
		smi_comm[i].port = allport[toggle_idx].port;
		smi_comm[i].rwtype = allport[toggle_idx].rwtype;
		smi_comm[i].desttype = allport[toggle_idx].desttype;
		smi_comm[i].bustype = allport[toggle_idx].bustype;
		SMI_Comm_Disable(i);
		SMI_Comm_Clear(i);
		SMI_SetCommBMCfg(i, smi_comm[i].port, smi_comm[i].desttype, smi_comm[i].rwtype);
		SMI_Comm_Enable(i);
	};
}
Пример #2
0
static void smi_init(void)
{
	int i;
	SMI_Init();
	SMI_PowerOn();

	if (do_smi() == 1) {
		for (i=0; i< SMI_LARB_NUMBER; i++) {
			// TODO: need to re-check here
			if ((i==3) || (i==4))
				continue;
			SMI_Disable(i);
			SMI_SetSMIBMCfg(i, smi_larb[i].port, smi_larb[i].desttype, smi_larb[i].rwtype);
			if (smi_larb[i].mode == 1) {
				enable_master_cnt += 1;
			}
		}
		//SMI_SetMonitorControl(0);  //SMIBMCfgEx default
		SMI_SetMonitorControl(&monitorctrl);

		for (i=0; i< SMI_COMM_NUMBER; i++) {
			SMI_Comm_Disable(i);
			SMI_SetCommBMCfg(i, smi_comm[i].port, smi_comm[i].desttype, smi_comm[i].rwtype);
			if (smi_comm[i].mode == 1) {
				enable_master_cnt += 1;
			}
		}
	} else if (do_smi() == 2) {
		toggle_idx = 0;
		toggle_port(toggle_idx);
	} else if (do_smi() == 3) {
		toggle_master_max = toggle_master_min = -1;
		for (i=0; i<SMI_ALLPORT_COUNT*4; i++) {
			if (allport[i].master == toggle_master) {
				if (toggle_master_min == -1) {
					toggle_master_max = i;
					toggle_master_min = i;
				}
				if (i > toggle_master_max) {
					toggle_master_max = i;
				}
				if (i < toggle_master_min) {
					toggle_master_min = i;
				}
			}
		}
		printk("smi toggle min=%d, max=%d\n",toggle_master_min,toggle_master_max);
		if (toggle_master_min >=0 ) {
			toggle_idx = toggle_master_min;
			toggle_port(toggle_idx);
		}
	} else if (do_smi() == 4) {

	}
}
static unsigned int smi_dump_polling(unsigned int *smi_value)
{
	int j = -1;
	int i ;

	i = allport[toggle_idx].master;
	//return 0;
	if (allport[toggle_idx].master < SMI_LARB_NUMBER) {
		SMI_Pause(i);
		smi_value[++j] = allport[toggle_idx].master;   //larb master
		smi_value[++j] = allport[toggle_idx].port;   //portNo
		smi_value[++j] = allport[toggle_idx].rwtype;
		smi_value[++j] = allport[toggle_idx].desttype;
		smi_value[++j] = allport[toggle_idx].bustype;

		smi_value[++j] = SMI_GetActiveCnt(i);    //ActiveCnt
		smi_value[++j] = SMI_GetRequestCnt(i);    //RequestCnt
		smi_value[++j] = SMI_GetIdleCnt(i);      //IdleCnt
		smi_value[++j] = SMI_GetBeatCnt(i);    //BeatCnt
		smi_value[++j] = SMI_GetByteCnt(i);    //ByteCnt
		smi_value[++j] = SMI_GetCPCnt(i);    //CPCnt
		smi_value[++j] = SMI_GetDPCnt(i);    //DPCnt
		smi_value[++j] = SMI_GetCDP_MAX(i);    //CDP_MAX
		smi_value[++j] = SMI_GetCOS_MAX(i);    //COS_MAX
		smi_value[++j] = SMI_GetBUS_REQ0(i);    //BUS_REQ0
		smi_value[++j] = SMI_GetBUS_REQ1(i);    //BUS_REQ1
		smi_value[++j] = SMI_GetWDTCnt(i);    //WDTCnt
		smi_value[++j] = SMI_GetRDTCnt(i);    //RDTCnt
		smi_value[++j] = SMI_GetOSTCnt(i);    //OSTCnt

	} else {
		i = allport[toggle_idx].master - SMI_LARB_NUMBER;
		SMI_Comm_Disable(i);
		smi_value[++j] = allport[toggle_idx].master;   //fake master
		smi_value[++j] = allport[toggle_idx].port;   //portNo
		smi_value[++j] = allport[toggle_idx].rwtype;
		smi_value[++j] = allport[toggle_idx].desttype;
		smi_value[++j] = allport[toggle_idx].bustype;

		smi_value[++j] = SMI_Comm_GetActiveCnt(i);    //ActiveCnt
		smi_value[++j] = SMI_Comm_GetRequestCnt(i);    //RequestCnt
		smi_value[++j] = SMI_Comm_GetIdleCnt(i);      //IdleCnt
		smi_value[++j] = SMI_Comm_GetBeatCnt(i);    //BeatCnt
		smi_value[++j] = SMI_Comm_GetByteCnt(i);    //ByteCnt
		smi_value[++j] = SMI_Comm_GetCPCnt(i);    //CPCnt
		smi_value[++j] = SMI_Comm_GetDPCnt(i);    //DPCnt
		smi_value[++j] = SMI_Comm_GetCDP_MAX(i);    //CDP_MAX
		smi_value[++j] = SMI_Comm_GetCOS_MAX(i);    //COS_MAX
	}
	smi_stop_master(allport[toggle_idx].master);
	smi_start_master(allport[toggle_idx].master);

	return j+1;
}
static unsigned int smi_polling(unsigned int *smi_value)
{
	int i=0,j=-1;

	//return 0;
	for (i=0; i<SMI_LARB_NUMBER; i++) {
		SMI_Pause(i);
	}

	for (i=0; i<SMI_COMM_NUMBER; i++) {
		SMI_Comm_Disable(i);
	}
#if 0
	smi_value[++j] = SMI_LARB_NUMBER+SMI_COMM_NUMBER;
	smi_value[++j] = 7;
	// read counter
	for (i=0; i<SMI_LARB_NUMBER; i++) {
		if (smi_larb[i].mode == 1) {
			smi_value[++j] = smi_larb[i].master;   //master
			smi_value[++j] = smi_larb[i].port;   //portNo
			smi_value[++j] = SMI_GetActiveCnt(i);    //ActiveCnt
			smi_value[++j] = SMI_GetRequestCnt(i);    //RequestCnt
			smi_value[++j] = SMI_GetIdleCnt(i);      //IdleCnt
			smi_value[++j] = SMI_GetBeatCnt(i);    //BeatCnt
			smi_value[++j] = SMI_GetByteCnt(i);    //ByteCnt
		}
	}
	for (i=0; i<SMI_COMM_NUMBER; i++) {
		if (smi_comm[i].mode == 1) {
			smi_value[++j] = SMI_LARB_NUMBER+i;   //fake master
			smi_value[++j] = smi_comm[i].port;   //portNo
			smi_value[++j] = SMI_Comm_GetActiveCnt(i);    //ActiveCnt
			smi_value[++j] = SMI_Comm_GetRequestCnt(i);    //RequestCnt
			smi_value[++j] = SMI_Comm_GetIdleCnt(i);      //IdleCnt
			smi_value[++j] = SMI_Comm_GetBeatCnt(i);    //BeatCnt
			smi_value[++j] = SMI_Comm_GetByteCnt(i);    //ByteCnt
		}
	}
#else
	smi_value[++j] = enable_master_cnt;
	smi_value[++j] = 16;
	// read counter
	for (i=0; i<SMI_LARB_NUMBER; i++) {
		if (smi_larb[i].mode == 1) {
			smi_value[++j] = smi_larb[i].master;   //master
			smi_value[++j] = smi_larb[i].port;   //portNo
			smi_value[++j] = SMI_GetActiveCnt(i);    //ActiveCnt
			smi_value[++j] = SMI_GetRequestCnt(i);    //RequestCnt
			smi_value[++j] = SMI_GetIdleCnt(i);      //IdleCnt
			smi_value[++j] = SMI_GetBeatCnt(i);    //BeatCnt
			smi_value[++j] = SMI_GetByteCnt(i);    //ByteCnt

			smi_value[++j] = SMI_GetCPCnt(i);    //CPCnt
			smi_value[++j] = SMI_GetDPCnt(i);    //DPCnt
			smi_value[++j] = SMI_GetCDP_MAX(i);    //CDP_MAX
			smi_value[++j] = SMI_GetCOS_MAX(i);    //COS_MAX
			smi_value[++j] = SMI_GetBUS_REQ0(i);    //BUS_REQ0
			smi_value[++j] = SMI_GetBUS_REQ1(i);    //BUS_REQ1
			smi_value[++j] = SMI_GetWDTCnt(i);    //WDTCnt
			smi_value[++j] = SMI_GetRDTCnt(i);    //RDTCnt
			smi_value[++j] = SMI_GetOSTCnt(i);    //OSTCnt
		}
	}
	for (i=0; i<SMI_COMM_NUMBER; i++) {
		if (smi_comm[i].mode == 1) {
			smi_value[++j] = SMI_LARB_NUMBER+i;   //fake master
			smi_value[++j] = smi_comm[i].port;   //portNo
			smi_value[++j] = SMI_Comm_GetActiveCnt(i);    //ActiveCnt
			smi_value[++j] = SMI_Comm_GetRequestCnt(i);    //RequestCnt
			smi_value[++j] = SMI_Comm_GetIdleCnt(i);      //IdleCnt
			smi_value[++j] = SMI_Comm_GetBeatCnt(i);    //BeatCnt
			smi_value[++j] = SMI_Comm_GetByteCnt(i);    //ByteCnt

			smi_value[++j] = SMI_Comm_GetCPCnt(i);    //CPCnt
			smi_value[++j] = SMI_Comm_GetDPCnt(i);    //DPCnt
			smi_value[++j] = SMI_Comm_GetCDP_MAX(i);    //CDP_MAX
			smi_value[++j] = SMI_Comm_GetCOS_MAX(i);    //COS_MAX
			smi_value[++j] = 0;    //BUS_REQ0
			smi_value[++j] = 0;    //BUS_REQ1
			smi_value[++j] = 0;    //WDTCnt
			smi_value[++j] = 0;    //RDTCnt
			smi_value[++j] = 0;    //OSTCnt
		}
	}
#endif

	smi_stop();
	smi_start();

	return j+1;
}