Example #1
0
INT32 wmt_func_bt_off(P_WMT_IC_OPS pOps, P_WMT_GEN_CONF pConf)
{
    //return wmt_func_bt_ctrl(FUNC_OFF);
    INT32 iRet1 = -1;
	INT32 iRet2 = -1;
   	UINT32 ctrlPa1;
   	UINT32 ctrlPa2;
    iRet1 = wmt_core_func_ctrl_cmd(WMTDRV_TYPE_BT, MTK_WCN_BOOL_FALSE);
	if(iRet1){
		WMT_ERR_FUNC("wmt-func: wmt_core_func_ctrl_cmd(bt_off) failed(%d)\n",iRet1);
	}
	ctrlPa1 = BT_PALDO;
	ctrlPa2 = PALDO_OFF;
	iRet2 = wmt_core_ctrl(WMT_CTRL_SOC_PALDO_CTRL,&ctrlPa1,&ctrlPa2);
	if(iRet2){
		WMT_ERR_FUNC("wmt-func: wmt_ctrl_soc_paldo_ctrl(bt_off) failed(%d)\n",iRet2);
	}
	if(iRet1 + iRet2)
	{
		return -1;
	}

	osal_clear_bit(WMT_BT_ON,&gBtWifiGpsState);
	if((!osal_test_bit(WMT_WIFI_ON,&gBtWifiGpsState)) && (osal_test_bit(WMT_GPS_ON,&gBtWifiGpsState)))
	{
		//send msg to GPS native for stopping send de-sense CMD
		ctrlPa1 = 0;
		ctrlPa2 = 0;
		wmt_core_ctrl(WMT_CTRL_BGW_DESENSE_CTRL,&ctrlPa1,&ctrlPa2);
	}
	return 0;
}
Example #2
0
static int wmt_conf_parse_int(P_DEV_WMT pWmtDev, const struct parse_data *data, const PINT8 pos)
{
	PUINT32 dst;
	long res;
	int ret;
	dst = (PINT32) (((PUINT8) pWmtDev) + (long)data->param1);

	/* WMT_INFO_FUNC(">strlen(pos)=%d\n", strlen(pos)); */

	if ((osal_strlen(pos) > 2) && ((*pos) == '0') && (*(pos + 1) == 'x')) {
		ret = osal_strtol(pos + 2, 16, &res);
		if (ret)
			WMT_ERR_FUNC("fail(%d)\n", ret);
		*dst = res;
		WMT_DBG_FUNC("wmtcfg==> %s=0x%x\n", data->name, *dst);
	} else {
		ret = osal_strtol(pos, 10, &res);
		if (ret)
			WMT_ERR_FUNC("fail(%d)\n", ret);
		*dst = res;
		WMT_DBG_FUNC("wmtcfg==> %s=%d\n", data->name, *dst);
	}

	return 0;
}
Example #3
0
INT32 wmt_func_bt_off(P_WMT_IC_OPS pOps, P_WMT_GEN_CONF pConf)
{
	/* return wmt_func_bt_ctrl(FUNC_OFF); */
	INT32 iRet1 = -1;
	INT32 iRet2 = -1;
	UINT32 ctrlPa1;
	UINT32 ctrlPa2;
	iRet1 = wmt_core_func_ctrl_cmd(WMTDRV_TYPE_BT, MTK_WCN_BOOL_FALSE);
	if (iRet1)
		WMT_ERR_FUNC("wmt-func: wmt_core_func_ctrl_cmd(bt_off) failed(%d)\n", iRet1);

	ctrlPa1 = BT_PALDO;
	ctrlPa2 = PALDO_OFF;
	iRet2 = wmt_core_ctrl(WMT_CTRL_SOC_PALDO_CTRL, &ctrlPa1, &ctrlPa2);
	if (iRet2)
		WMT_ERR_FUNC("wmt-func: wmt_ctrl_soc_paldo_ctrl(bt_off) failed(%d)\n", iRet2);

	if (iRet1 + iRet2) {
		/*do coredump when bt off fail */
		wmt_core_set_coredump_state(DRV_STS_FUNC_ON);
		ctrlPa1 = WMTDRV_TYPE_BT;
		ctrlPa2 = 32;
		wmt_core_ctrl(WMT_CTRL_EVT_ERR_TRG_ASSERT, &ctrlPa1, &ctrlPa2);
		return -1;
	}

	osal_clear_bit(WMT_BT_ON, &gBtWifiGpsState);
	if ((!osal_test_bit(WMT_WIFI_ON, &gBtWifiGpsState)) && (osal_test_bit(WMT_GPS_ON, &gBtWifiGpsState))) {
		/* send msg to GPS native for stopping send de-sense CMD */
		ctrlPa1 = 0;
		ctrlPa2 = 0;
		wmt_core_ctrl(WMT_CTRL_BGW_DESENSE_CTRL, &ctrlPa1, &ctrlPa2);
	}
	return 0;
}
Example #4
0
static INT32 wmt_conf_parse_pair (
    P_DEV_WMT pWmtDev,
    const PCHAR pKey,
    const PCHAR pVal
    )
{
    int i = 0;
    int ret = 0;

    //WMT_INFO_FUNC( DBG_NAME "cfg(%s) val(%s) \n", pKey, pVal);

    for (i = 0; i < NUM_WMTCFG_FIELDS; i++) {
        const struct parse_data *field = &wmtcfg_fields[i];
            if (osal_strcmp(pKey, field->name) != 0)
                continue;
            if (field->parser(pWmtDev, field, pVal)) {
                WMT_ERR_FUNC("failed to parse %s '%s'.\n", pKey, pVal);
                ret = -1;
            }
        break;
    }
    if (i == NUM_WMTCFG_FIELDS) {
        WMT_ERR_FUNC("unknown field '%s'.\n", pKey);
        ret = -1;
    }

    return ret;
}
Example #5
0
INT32 wmt_func_bt_on(P_WMT_IC_OPS pOps, P_WMT_GEN_CONF pConf)
{
    //return wmt_func_bt_ctrl(FUNC_ON);
   	INT32 iRet = -1;
   	UINT32 ctrlPa1;
   	UINT32 ctrlPa2;

	ctrlPa1 = BT_PALDO;
	ctrlPa2 = PALDO_ON;
	iRet = wmt_core_ctrl(WMT_CTRL_SOC_PALDO_CTRL,&ctrlPa1,&ctrlPa2);
	if(iRet){
		WMT_ERR_FUNC("wmt-func: wmt_ctrl_soc_paldo_ctrl failed(%d)(%d)(%d)\n",iRet,ctrlPa1,ctrlPa2);
		return -1;
	}
    iRet = wmt_core_func_ctrl_cmd(WMTDRV_TYPE_BT, MTK_WCN_BOOL_TRUE);
	if(iRet){
		WMT_ERR_FUNC("wmt-func: wmt_core_func_ctrl_cmd(bt_on) failed(%d)\n",iRet);
		ctrlPa1 = BT_PALDO;
		ctrlPa2 = PALDO_OFF;
		wmt_core_ctrl(WMT_CTRL_SOC_PALDO_CTRL,&ctrlPa1,&ctrlPa2);
		return -2;
	}else
	{
		osal_set_bit(WMT_BT_ON,&gBtWifiGpsState);
		if(osal_test_bit(WMT_GPS_ON,&gBtWifiGpsState))
		{
			//send msg to GPS native for sending de-sense CMD
			ctrlPa1 = 1;
			ctrlPa2 = 0;
			wmt_core_ctrl(WMT_CTRL_BGW_DESENSE_CTRL,&ctrlPa1,&ctrlPa2);
		}
		return 0;
	}
}
MTK_WCN_BOOL wmt_dev_is_file_exist(PUINT8 pFileName)
{
	struct file *fd = NULL;
	/* ssize_t iRet; */
	INT32 fileLen = -1;
	const struct cred *cred = get_current_cred();
	if (pFileName == NULL) {
		WMT_ERR_FUNC("invalid file name pointer(%p)\n", pFileName);
		return MTK_WCN_BOOL_FALSE;
	}
	if (osal_strlen(pFileName) < osal_strlen(defaultPatchName)) {
		WMT_ERR_FUNC("invalid file name(%s)\n", pFileName);
		return MTK_WCN_BOOL_FALSE;
	}

	/* struct cred *cred = get_task_cred(current); */

	fd = filp_open(pFileName, O_RDONLY, 0);
	if (!fd || IS_ERR(fd) || !fd->f_op || !fd->f_op->read) {
		WMT_ERR_FUNC("failed to open or read(%s)!(0x%p, %d, %d)\n", pFileName, fd,
			     cred->fsuid, cred->fsgid);
		return MTK_WCN_BOOL_FALSE;
	}
	fileLen = fd->f_path.dentry->d_inode->i_size;
	filp_close(fd, NULL);
	fd = NULL;
	if (fileLen <= 0) {
		WMT_ERR_FUNC("invalid file(%s), length(%d)\n", pFileName, fileLen);
		return MTK_WCN_BOOL_FALSE;
	}
	WMT_ERR_FUNC("valid file(%s), length(%d)\n", pFileName, fileLen);
	return true;

}
Example #7
0
INT8 mtk_wcn_wmt_therm_ctrl(ENUM_WMTTHERM_TYPE_T eType)
#endif
{
	P_OSAL_OP pOp;
	P_WMT_OP pOpData;
	MTK_WCN_BOOL bRet;
	P_OSAL_SIGNAL pSignal;

	/*parameter validation check */
	if (WMTTHERM_MAX < eType || WMTTHERM_ENABLE > eType) {
		WMT_ERR_FUNC("invalid thermal control command (%d)\n", eType);
		return MTK_WCN_BOOL_FALSE;
	}

	/*check if chip support thermal control function or not */
	bRet = wmt_lib_is_therm_ctrl_support();
	if (MTK_WCN_BOOL_FALSE == bRet) {
        WMT_DBG_FUNC("thermal ctrl function not supported\n");
		return MTK_WCN_BOOL_FALSE;
	}

	pOp = wmt_lib_get_free_op();
	if (!pOp) {
		WMT_DBG_FUNC("get_free_lxop fail\n");
		return MTK_WCN_BOOL_FALSE;
	}

	pSignal = &pOp->signal;
	pOpData = &pOp->op;
	pOpData->opId = WMT_OPID_THERM_CTRL;
	/*parameter fill */
	pOpData->au4OpData[0] = eType;
	pSignal->timeoutValue = MAX_EACH_WMT_CMD;

    WMT_DBG_FUNC("OPID(%d) type(%d) start\n",
            pOp->op.opId,
            pOp->op.au4OpData[0]);

	if (DISABLE_PSM_MONITOR()) {
		WMT_ERR_FUNC("wake up failed\n");
		wmt_lib_put_op_to_free_queue(pOp);
		return -1;
	}

	bRet = wmt_lib_put_act_op(pOp);
	ENABLE_PSM_MONITOR();

	if (MTK_WCN_BOOL_FALSE == bRet) {
		WMT_WARN_FUNC("OPID(%d) type(%d) fail\n\n", pOpData->opId, pOpData->au4OpData[0]);
		/*0xFF means read error occurs */
		pOpData->au4OpData[1] = (eType == WMTTHERM_READ) ? 0xFF : MTK_WCN_BOOL_FALSE;	/*will return to function driver */
	} else {
		WMT_DBG_FUNC("OPID(%d) type(%d) return(%d) ok\n\n",
			      pOpData->opId, pOpData->au4OpData[0], pOpData->au4OpData[1]);
	}
	/*return value will be put to lxop->op.au4OpData[1] */
	WMT_DBG_FUNC("therm ctrl type(%d), iRet(0x%08x)\n", eType, pOpData->au4OpData[1]);
	return (INT8) pOpData->au4OpData[1];
}
INT32 mtk_wcn_consys_stp_btif_tx(const UINT8 *pBuf, const UINT32 len, UINT32 *written_len)
{
	INT32 retry_left = STP_BTIF_TX_RTY_LMT;
	INT32 wr_count = 0;
	INT32 written = 0;

	if (!stpBtifId) {
		WMT_WARN_FUNC("NULL BTIF ID reference!\n");
		return -1;
	}

	if (len == 0) {
		*written_len = 0;
		WMT_INFO_FUNC("special case for STP-CORE,pbuf(%p)\n", pBuf);
		return 0;
	}

	*written_len = 0;

	if (len > STP_MAX_PACKAGE_ALLOWED) {
		WMT_WARN_FUNC("abnormal pacage length,len(%d),pid[%d/%s]\n", len, current->pid, current->comm);
		return -2;
	}
	wr_count = mtk_wcn_btif_write(stpBtifId, pBuf, len);

	if (wr_count < 0) {
		WMT_ERR_FUNC("mtk_wcn_btif_write err(%d)\n", wr_count);
		*written_len = 0;
		return -3;
	}
	if (wr_count == len) {
		/*perfect case */
		*written_len = wr_count;
		return wr_count;
	}

	while ((retry_left--) && (wr_count < len)) {
		osal_sleep_ms(STP_BTIF_TX_RTY_DLY);
		written = mtk_wcn_btif_write(stpBtifId, pBuf + wr_count, len - wr_count);
		if (written < 0) {
			WMT_ERR_FUNC("mtk_wcn_btif_write err(%d)when do recovered\n", written);
			break;
		}
		wr_count += written;
	}

	if (wr_count == len) {
		WMT_INFO_FUNC("recovered,len(%d),retry_left(%d)\n", len, retry_left);
		/*recovered case */
		*written_len = wr_count;
		return wr_count;
	}

	WMT_ERR_FUNC("stp btif write fail,len(%d),written(%d),retry_left(%d),pid[%d/%s]\n",
		     len, wr_count, retry_left, current->pid, current->comm);
	*written_len = 0;
	return -wr_count;
}
Example #9
0
INT32 wmt_conf_read_file(VOID)
{
	INT32 ret = -1;

	osal_memset(&gDevWmt.rWmtGenConf, 0, osal_sizeof(gDevWmt.rWmtGenConf));
	osal_memset(&gDevWmt.pWmtCfg, 0, osal_sizeof(gDevWmt.pWmtCfg));

#if 1
	osal_memset(&gDevWmt.cWmtcfgName[0], 0, osal_sizeof(gDevWmt.cWmtcfgName));

	osal_strncat(&(gDevWmt.cWmtcfgName[0]), CUST_CFG_WMT_PREFIX, osal_sizeof(CUST_CFG_WMT_PREFIX));
	osal_strncat(&(gDevWmt.cWmtcfgName[0]), CUST_CFG_WMT, osal_sizeof(CUST_CFG_WMT));
#endif

	if (!osal_strlen(&(gDevWmt.cWmtcfgName[0]))) {
		WMT_ERR_FUNC("empty Wmtcfg name\n");
		osal_assert(0);
		return ret;
	}
	WMT_INFO_FUNC("WMT config file:%s\n", &(gDevWmt.cWmtcfgName[0]));
	if (0 == wmt_dev_patch_get(&gDevWmt.cWmtcfgName[0], (osal_firmware **) &gDevWmt.pWmtCfg, 0)) {
		/*get full name patch success */
		WMT_INFO_FUNC("get full file name(%s) buf(0x%p) size(%d)\n",
			      &gDevWmt.cWmtcfgName[0], gDevWmt.pWmtCfg->data, gDevWmt.pWmtCfg->size);

		if (0 == wmt_conf_parse(&gDevWmt, (const PINT8)gDevWmt.pWmtCfg->data, gDevWmt.pWmtCfg->size)) {
			/*config file exists */
			gDevWmt.rWmtGenConf.cfgExist = 1;

			WMT_INFO_FUNC("&gDevWmt.rWmtGenConf=%p\n", &gDevWmt.rWmtGenConf);
			ret = 0;
		} else {
			WMT_ERR_FUNC("wmt conf parsing fail\n");
			osal_assert(0);
			ret = -1;
		}
		wmt_dev_patch_put((osal_firmware **) &gDevWmt.pWmtCfg);
/*
	if (gDevWmt.pWmtCfg)
	{
	    if (gDevWmt.pWmtCfg->data)
	    {
		osal_free(gDevWmt.pWmtCfg->data);
	    }
	    osal_free(gDevWmt.pWmtCfg);
	    gDevWmt.pWmtCfg = 0;
	}
*/
		return ret;
	} else {
		WMT_ERR_FUNC("read %s file fails\n", &(gDevWmt.cWmtcfgName[0]));
		osal_assert(0);

		gDevWmt.rWmtGenConf.cfgExist = 0;
		return ret;
	}
}
Example #10
0
MTK_WCN_BOOL mtk_wcn_wmt_dsns_ctrl(ENUM_WMTDSNS_TYPE_T eType)
#endif
{
	P_OSAL_OP pOp;
	P_WMT_OP pOpData;
	MTK_WCN_BOOL bRet;
	P_OSAL_SIGNAL pSignal;

	if (WMTDSNS_MAX <= eType) {
		WMT_ERR_FUNC("invalid desense control command (%d)\n", eType);
		return MTK_WCN_BOOL_FALSE;
	}

	/*check if chip support thermal control function or not */
	bRet = wmt_lib_is_dsns_ctrl_support();
	if (MTK_WCN_BOOL_FALSE == bRet) {
		WMT_ERR_FUNC("thermal ctrl function not supported\n");
		return MTK_WCN_BOOL_FALSE;
	}

	pOp = wmt_lib_get_free_op();
	if (!pOp) {
		WMT_DBG_FUNC("get_free_lxop fail\n");
		return MTK_WCN_BOOL_FALSE;
	}

	pSignal = &pOp->signal;
	pOpData = &pOp->op;
	pOpData->opId = WMT_OPID_DSNS;
	pSignal->timeoutValue = MAX_EACH_WMT_CMD;
	/*parameter fill */
	if ((WMTDSNS_FM_DISABLE <= eType) && (WMTDSNS_FM_GPS_ENABLE >= eType)) {
		pOpData->au4OpData[0] = WMTDRV_TYPE_FM;
		pOpData->au4OpData[1] = eType;
	}

	WMT_INFO_FUNC("OPID(%d) type(%d) start\n", pOp->op.opId, pOp->op.au4OpData[0]);

	if (DISABLE_PSM_MONITOR()) {
		WMT_ERR_FUNC("wake up failed\n");
		wmt_lib_put_op_to_free_queue(pOp);
		return MTK_WCN_BOOL_FALSE;
	}

	bRet = wmt_lib_put_act_op(pOp);
	ENABLE_PSM_MONITOR();

	if (MTK_WCN_BOOL_FALSE == bRet) {
		WMT_WARN_FUNC("OPID(%d) type(%d) fail\n\n", pOpData->opId, pOpData->au4OpData[0]);
	} else {
		WMT_INFO_FUNC("OPID(%d) type(%d) ok\n\n", pOpData->opId, pOpData->au4OpData[0]);
	}

	return bRet;
}
ssize_t wmt_aee_read(struct file *filp, char __user *buf, size_t count, loff_t *f_pos)
{
	INT32 retval = 0;
	UINT32 len = 0;
	WMT_INFO_FUNC("%s: count %d pos %lld\n", __func__, count, *f_pos);

	if (0 == *f_pos) {
		pBuf = wmt_lib_get_cpupcr_xml_format(&len);
		g_buf_len = len;
		WMT_INFO_FUNC("wmt_dev:wmt for aee buffer len(%d)\n", g_buf_len);
	}

	if (g_buf_len >= count) {

		retval = copy_to_user(buf, pBuf, count);
		if (retval) {
			WMT_ERR_FUNC("copy to aee buffer failed, ret:%d\n", retval);
			retval = -EFAULT;
			goto err_exit;
		}

		*f_pos += count;
		g_buf_len -= count;
		pBuf += count;
		WMT_INFO_FUNC("wmt_dev:after read,wmt for aee buffer len(%d)\n", g_buf_len);

		retval = count;
	} else if (0 != g_buf_len) {

		retval = copy_to_user(buf, pBuf, g_buf_len);
		if (retval) {
			WMT_ERR_FUNC("copy to aee buffer failed, ret:%d\n", retval);
			retval = -EFAULT;
			goto err_exit;
		}

		*f_pos += g_buf_len;
		len = g_buf_len;
		g_buf_len = 0;
		pBuf += len;
		retval = len;
		WMT_INFO_FUNC("wmt_dev:after read,wmt for aee buffer len(%d)\n", g_buf_len);
	} else {
		WMT_INFO_FUNC("wmt_dev: no data avaliable for aee\n");
		retval = 0;
	}
 err_exit:
	return retval;
}
Example #12
0
static MTK_WCN_BOOL
mtk_wcn_wmt_func_ctrl (
    ENUM_WMTDRV_TYPE_T type,
    ENUM_WMT_OPID_T opId
    )
{
    P_OSAL_OP pOp;
    MTK_WCN_BOOL bRet;
    P_OSAL_SIGNAL pSignal;

    pOp = wmt_lib_get_free_op();
    if (!pOp) {
        WMT_WARN_FUNC("get_free_lxop fail\n");
        return MTK_WCN_BOOL_FALSE;
    }
    
    pSignal = &pOp->signal;

    pOp->op.opId = opId;
#if MTK_WCN_CMB_FOR_SDIO_1V_AUTOK
	if(WMTDRV_TYPE_AUTOK == type)
        pOp->op.au4OpData[0] = WMTDRV_TYPE_WIFI;
	else
#endif
        pOp->op.au4OpData[0] = type;
	
	if (WMTDRV_TYPE_WIFI == type)
		pSignal->timeoutValue = 4000; /*workaround, donot block system server/Init/Netd from longer than 5s, in case of ANR happens*/
	else
	    pSignal->timeoutValue = (WMT_OPID_FUNC_ON == pOp->op.opId) ? MAX_FUNC_ON_TIME : MAX_FUNC_OFF_TIME;

    WMT_INFO_FUNC("OPID(%d) type(%d) start\n",
            pOp->op.opId,
            pOp->op.au4OpData[0]);

    /*do not check return value, we will do this either way*/
    wmt_lib_host_awake_get();
    /*wake up chip first*/
    if (DISABLE_PSM_MONITOR()) {
        WMT_ERR_FUNC("wake up failed\n");
        wmt_lib_put_op_to_free_queue(pOp);
        return MTK_WCN_BOOL_FALSE;
    }
    
    bRet = wmt_lib_put_act_op(pOp);
    ENABLE_PSM_MONITOR();
    wmt_lib_host_awake_put();
    
    if (MTK_WCN_BOOL_FALSE == bRet) {
        WMT_WARN_FUNC("OPID(%d) type(%d) fail\n",
            pOp->op.opId,
            pOp->op.au4OpData[0]);
    }
    else{ 
        WMT_INFO_FUNC("OPID(%d) type(%d) ok\n",
            pOp->op.opId,
            pOp->op.au4OpData[0]);
    }
    return bRet;
}
INT32 wmt_ctrl_get_patch_info(P_WMT_CTRL_DATA pWmtCtrlData)
{
	P_DEV_WMT pDev = &gDevWmt; /* single instance */
	UINT32 downLoadSeq = 0;
	P_WMT_PATCH_INFO pPatchinfo = NULL;
	PUCHAR pNbuf = NULL;
	PUCHAR pAbuf =NULL;
	
	downLoadSeq = pWmtCtrlData->au4CtrlData[0];
	WMT_DBG_FUNC("download seq is %d\n",downLoadSeq);

	pPatchinfo = pDev->pWmtPatchInfo + downLoadSeq - 1;
	pNbuf = (PUCHAR)pWmtCtrlData->au4CtrlData[1];
	pAbuf = (PUCHAR)pWmtCtrlData->au4CtrlData[2];
	if(pPatchinfo)
	{
		osal_memcpy(pNbuf,pPatchinfo->patchName,osal_sizeof(pPatchinfo->patchName));
		osal_memcpy(pAbuf,pPatchinfo->addRess,osal_sizeof(pPatchinfo->addRess));
		WMT_DBG_FUNC("get 4 address bytes is 0x%2x,0x%2x,0x%2x,0x%2x",pAbuf[0],pAbuf[1],pAbuf[2],pAbuf[3]);
	}
	else
	{
		WMT_ERR_FUNC("NULL patchinfo pointer\n");
	}

	return 0;
}
INT32  wmt_ctrl_crystal_triming_get(P_WMT_CTRL_DATA pWmtCtrlData)
{
    INT32 iRet = 0x0;
     UCHAR *pFileName = (UCHAR *)pWmtCtrlData->au4CtrlData[0];
	 PUINT8 *ppBuf = (PUINT8 *)pWmtCtrlData->au4CtrlData[1];
	 PUINT32 pSize = (PUINT32)pWmtCtrlData->au4CtrlData[2];

	 osal_firmware *pNvram = NULL;

	 if ((NULL == pFileName) || (NULL == pSize))
	 {
	     WMT_ERR_FUNC("parameter error, pFileName(0x%08x), pSize(0x%08x)\n", pFileName, pSize);
		 iRet = -1;
		 return iRet;
	 }
	 if (0 == wmt_dev_patch_get(pFileName, &pNvram, 0))
	 {
	     *ppBuf = (PUINT8)(pNvram)->data;
         *pSize = (pNvram)->size;
		 gDevWmt.pNvram = pNvram;
		 return 0;
	 }
	 return -1;

	 
}
Example #15
0
INT32 wmt_conf_set_cfg_file(const char *name)
{
	if (NULL == name) {
		WMT_ERR_FUNC("name is NULL\n");
		return -1;
	}
	if (osal_strlen(name) >= osal_sizeof(gDevWmt.cWmtcfgName)) {
		WMT_ERR_FUNC("name is too long, length=%d, expect to < %d\n", osal_strlen(name),
			     osal_sizeof(gDevWmt.cWmtcfgName));
		return -2;
	}
	osal_memset(&gDevWmt.cWmtcfgName[0], 0, osal_sizeof(gDevWmt.cWmtcfgName));
	osal_strcpy(&(gDevWmt.cWmtcfgName[0]), name);
	WMT_ERR_FUNC("WMT config file is set to (%s)\n", &(gDevWmt.cWmtcfgName[0]));

	return 0;
}
Example #16
0
INT32 wmt_idc_msg_from_lte_handing(ipc_ilm_t *ilm)
{
	MTK_WCN_BOOL bRet;

	if(NULL == ilm)
	{
		WMT_ERR_FUNC("NULL pointer\n");
		return -1;
	}
	
	bRet = wmt_lib_handle_idc_msg(ilm);
	if(MTK_WCN_BOOL_FALSE == bRet)
	{
		WMT_ERR_FUNC("wmt handing idc msg fail\n");
		return -2;
	}

	return 0;
}
VOID wmt_dev_rx_event_cb(VOID)
{
	if (NULL != gpRxEvent) {
		u4RxFlag = 1;
		atomic_inc(&gRxCount);
		wake_up_interruptible(&gpRxEvent->waitQueue);
	} else {
		WMT_ERR_FUNC("null gpRxEvent, flush rx!\n");
		wmt_lib_flush_rx();
	}
}
Example #18
0
INT32 wmt_idc_msg_from_lte_handing(ipc_ilm_t *ilm)
{
	MTK_WCN_BOOL bRet;

	if (NULL == ilm) {
		WMT_ERR_FUNC("NULL pointer\n");
		return -1;
	}
	if (mtk_wcn_stp_is_ready()) {
		bRet = wmt_lib_handle_idc_msg(ilm);
		if (MTK_WCN_BOOL_FALSE == bRet) {
			WMT_ERR_FUNC("wmt handing idc msg fail\n");
			return -2;
		}
		wmt_lib_notify_stp_sleep();
	} else {
		WMT_INFO_FUNC("Received LTE msg,but STP is not ready,drop it!\n");
	}
	return 0;
}
Example #19
0
INT32 wmt_dev_dbg_setup(VOID)
{
    gWmtDbgEntry = create_proc_entry(WMT_DBG_PROCNAME, 0664, NULL);
    if(gWmtDbgEntry == NULL){
        WMT_ERR_FUNC("Unable to create /proc entry\n\r");
        return -1;
    }
    gWmtDbgEntry->read_proc = wmt_dev_dbg_read;
    gWmtDbgEntry->write_proc = wmt_dev_dbg_write;
    return 0;
}
INT32 wmt_ctrl_soc_wakeup_consys(P_WMT_CTRL_DATA pWmtCtrlData)
{
	INT32 iRet = 0;

	iRet = mtk_wcn_stp_wakeup_consys();
	if(iRet){
		WMT_ERR_FUNC("soc palod ctrl fail(%d)\n",iRet);
	}
	
	return iRet;
}
UINT8  *mtk_wcn_consys_emi_base_addr_get(ENUM_EMI_BASE_INDEX emi_addr_index)
{
	UINT8 *p_virtual_addr = NULL;

	if(!pEmibaseaddr)
	{
		WMT_ERR_FUNC("EMI base address is NULL\n");
		return NULL;
	}

	switch(emi_addr_index){

	case EMI_CTRL_STATE_BASE_INDEX:
	{
		p_virtual_addr = pEmibaseaddr;
		break;
	}
	case EMI_PAGED_TRACE_BASE_INDEX:
	{
		p_virtual_addr = pEmibaseaddr + CONSYS_EMI_PAGED_TRACE_OFFSET;
		break;
	}
	case EMI_PAGED_DUMP_BASE_INDEX:
	{
		p_virtual_addr = pEmibaseaddr + CONSYS_EMI_PAGED_DUMP_OFFSET;
		break;
	}
	case EMI_FULL_DUMP_BASE_INDEX:
	{
		p_virtual_addr = pEmibaseaddr + CONSYS_EMI_FULL_DUMP_OFFSET;
		break;
	}
	default:
		WMT_ERR_FUNC("invalid EMI base address index\n");
		p_virtual_addr = NULL;
		break;
		
	}

	return p_virtual_addr;
}
Example #22
0
INT32 wmt_idc_deinit(VOID)
{
	INT32 iRet;

	iRet = mtk_conn_md_bridge_unreg(gWmtIdcInfo.iit.src_mod_id);
	if (iRet)
		WMT_ERR_FUNC("mtk_conn_md_bridge_unreg fail(%d)\n", iRet);

	osal_memset(&gWmtIdcInfo, 0, osal_sizeof(gWmtIdcInfo));

	return 0;
}
INT32
wmt_ctrl_tx_ex (
    const UINT8 *pData,
    const UINT32 size,
    UINT32 *writtenSize,
    const MTK_WCN_BOOL bRawFlag
    )
{
    P_DEV_WMT pDev = &gDevWmt; /* single instance */
    INT32 iRet;

    if (NULL != writtenSize) {
        *writtenSize = 0;
    }

    /* sanity check */
    if (0 == size) {
        WMT_WARN_FUNC("size to tx is 0\n");
        osal_assert(size);
        return -1;
    }

    /* if STP is not enabled yet, can't use this function. Use tx_raw instead */
    if ( !osal_test_bit(WMT_STAT_STP_OPEN, &pDev->state) ||
        !osal_test_bit(WMT_STAT_STP_EN, &pDev->state) ) {
        WMT_ERR_FUNC("wmt state(0x%lx) \n", pDev->state);
        osal_assert(osal_test_bit(WMT_STAT_STP_EN, &pDev->state));
        osal_assert(osal_test_bit(WMT_STAT_STP_OPEN, &pDev->state));
        return -2;
    }

    /* sanity ok, proceeding tx operation */
    /*retval = mtk_wcn_stp_send_data(data, size, WMTDRV_TYPE_WMT);*/
    mtk_wcn_stp_flush_rx_queue(WMT_TASK_INDX);
    if (bRawFlag) {
        iRet = mtk_wcn_stp_send_data_raw(pData, size, WMT_TASK_INDX);
    }
    else {
        iRet = mtk_wcn_stp_send_data(pData, size, WMT_TASK_INDX);
    }

    if (iRet != size){
        WMT_WARN_FUNC("write(%d) written(%d)\n", size, iRet);
        osal_assert(iRet == size);
    }

    if (writtenSize) {
        *writtenSize = iRet;
    }

    return 0;

}
INT32 wmt_dev_proc_for_aee_setup(VOID)
{
	INT32 i_ret = 0;
#if USE_NEW_PROC_FS_FLAG
	gWmtAeeEntry = proc_create(WMT_AEE_PROCNAME, 0664, NULL, &wmt_aee_fops);
	if (gWmtAeeEntry == NULL) {
		WMT_ERR_FUNC("Unable to create / wmt_aee proc entry\n\r");
		i_ret = -1;
	}
#else

	gWmtAeeEntry = create_proc_entry(WMT_AEE_PROCNAME, 0664, NULL);
	if (gWmtAeeEntry == NULL) {
		WMT_ERR_FUNC("Unable to create / wmt_aee proc entry\n\r");
		i_ret = -1;
	}
	gWmtAeeEntry->read_proc = wmt_dev_proc_for_aee_read;
	gWmtAeeEntry->write_proc = wmt_dev_proc_for_aee_write;
#endif
	return i_ret;
}
INT32 wmt_ctrl_set_stp_dbg_info(P_WMT_CTRL_DATA pWmtCtrlData)
{
	UINT8 *pRomVer = NULL;
	P_WMT_PATCH pPatch = NULL;
	UINT32 chipID = 0;
	
	chipID = pWmtCtrlData->au4CtrlData[0];
	pRomVer = (UINT8 *)(pWmtCtrlData->au4CtrlData[1]);
	pPatch = (P_WMT_PATCH)(pWmtCtrlData->au4CtrlData[2]);
	if (!pRomVer) {
		WMT_ERR_FUNC("pRomVer null pointer\n");
		return -1;
	}
    
	if (!pPatch) {
		WMT_ERR_FUNC("pPatch null pointer\n");
		return -2;
	}
	WMT_DBG_FUNC("chipid(0x%x),rom(%s),patch date(%s),patch plat(%s)\n", chipID, pRomVer, pPatch->ucDateTime, pPatch->ucPLat);
	return stp_dbg_set_version_info(chipID, pRomVer, NULL, &(pPatch->ucDateTime[0]), &(pPatch->ucPLat[0]));
}
INT32 wmt_func_wifi_ctrl(ENUM_FUNC_STATE funcState)
{
	INT32 iRet = 0;
	unsigned long ctrlPa1 = WMT_SDIO_FUNC_WIFI;
	unsigned long ctrlPa2 = (FUNC_ON == funcState) ? 1 : 0;	/* turn on Wi-Fi driver */
	iRet = wmt_core_ctrl(WMT_CTRL_SDIO_FUNC, &ctrlPa1, &ctrlPa2);
	if (iRet) {
		WMT_ERR_FUNC("WMT-FUNC: turn on WIFI function fail (%d)", iRet);
		return -1;
	}
	return 0;
}
static INT32 mtk_wmt_func_on_background(void)
{
	INT32 iRet = 0;
	OSAL_THREAD bgFuncOnThread;
	P_OSAL_THREAD pThread = &bgFuncOnThread;
	/* Create background power on thread */
    osal_strncpy(pThread->threadName, ("mtk_wmtd_pwr_bg"), sizeof(pThread->threadName));
    pThread->pThreadData = NULL;
    pThread->pThreadFunc = (VOID *)wmt_pwr_on_thread;
    iRet = osal_thread_create(pThread);
    if (iRet) {
        WMT_ERR_FUNC("osal_thread_create(0x%p) fail(%d)\n", pThread, iRet);
        return -1;
    }
	/* 3. start: start running background power on thread*/
    iRet = osal_thread_run(pThread);
    if (iRet) {
        WMT_ERR_FUNC("osal_thread_run(0x%p) fail(%d)\n", pThread, iRet);
        return -2;
    }
	return 0;
}
static MTK_WCN_BOOL
mtk_wcn_wmt_func_ctrl (
    ENUM_WMTDRV_TYPE_T type,
    ENUM_WMT_OPID_T opId
    )
{
    P_OSAL_OP pOp;
    MTK_WCN_BOOL bRet;
    P_OSAL_SIGNAL pSignal;

    pOp = wmt_lib_get_free_op();
    if (!pOp) {
        WMT_WARN_FUNC("get_free_lxop fail\n");
        return MTK_WCN_BOOL_FALSE;
    }
    
    pSignal = &pOp->signal;

    pOp->op.opId = opId;
    pOp->op.au4OpData[0] = type;
    pSignal->timeoutValue= (WMT_OPID_FUNC_ON == pOp->op.opId) ? MAX_FUNC_ON_TIME : MAX_FUNC_OFF_TIME;

    WMT_INFO_FUNC("OPID(%d) type(%d) start\n",
            pOp->op.opId,
            pOp->op.au4OpData[0]);

    /*do not check return value, we will do this either way*/
    wmt_lib_host_awake_get();
    /*wake up chip first*/
    if (DISABLE_PSM_MONITOR()) {
        WMT_ERR_FUNC("wake up failed\n");
        wmt_lib_put_op_to_free_queue(pOp);
        return MTK_WCN_BOOL_FALSE;
    }
    
    bRet = wmt_lib_put_act_op(pOp);
    ENABLE_PSM_MONITOR();
    wmt_lib_host_awake_put();
    
    if (MTK_WCN_BOOL_FALSE == bRet) {
        WMT_WARN_FUNC("OPID(%d) type(%d) fail\n",
            pOp->op.opId,
            pOp->op.au4OpData[0]);
    }
    else{ 
        WMT_INFO_FUNC("OPID(%d) type(%d) ok\n",
            pOp->op.opId,
            pOp->op.au4OpData[0]);
    }
    return bRet;
}
Example #29
0
INT32 wmt_func_wifi_on(P_WMT_IC_OPS pOps, P_WMT_GEN_CONF pConf)
{
	int iRet = 0;
	UINT32 ctrlPa1;
	UINT32 ctrlPa2;
	
	if(NULL != mtk_wcn_wlan_probe){
		
		WMT_INFO_FUNC("WMT-FUNC: wmt wlan func on befor wlan probe\n");
		iRet = (*mtk_wcn_wlan_probe)();
		if(iRet){
			WMT_ERR_FUNC("WMT-FUNC: wmt call wlan probe fail(%d)\n",iRet);
			iRet = -1;
		}else{
			WMT_INFO_FUNC("WMT-FUNC: wmt call wlan probe ok\n");
		}
	}else{
		WMT_ERR_FUNC("WMT-FUNC: null pointer mtk_wcn_wlan_probe\n");
		gWifiProbed = 1;
		iRet = -2;
	}

	if(!iRet)
	{
		osal_set_bit(WMT_WIFI_ON,&gBtWifiGpsState);
		if(osal_test_bit(WMT_GPS_ON,&gBtWifiGpsState))
		{
			//send msg to GPS native for sending de-sense CMD
			ctrlPa1 = 1;
			ctrlPa2 = 0;
			wmt_core_ctrl(WMT_CTRL_BGW_DESENSE_CTRL,&ctrlPa1,&ctrlPa2);
		}
	}
	return iRet;
#if 0
	return wmt_func_wifi_ctrl(FUNC_ON);
#endif
}
Example #30
0
INT32 wmt_func_wifi_off(P_WMT_IC_OPS pOps, P_WMT_GEN_CONF pConf)
{
	int iRet = 0;

	UINT32 ctrlPa1 = 0;
	UINT32 ctrlPa2 = 0;
	
	if(NULL != mtk_wcn_wlan_remove){
		
		WMT_INFO_FUNC("WMT-FUNC: wmt wlan func on befor wlan remove\n");
		iRet = (*mtk_wcn_wlan_remove)();
		if(iRet){
			WMT_ERR_FUNC("WMT-FUNC: wmt call wlan remove fail(%d)\n",iRet);
			iRet = -1;
		}else{
			WMT_INFO_FUNC("WMT-FUNC: wmt call wlan remove ok\n");
		}
	}else{
		WMT_ERR_FUNC("WMT-FUNC: null pointer mtk_wcn_wlan_remove\n");
		iRet = -2;
	}

	if(!iRet)
	{
		osal_clear_bit(WMT_WIFI_ON,&gBtWifiGpsState);
		if((!osal_test_bit(WMT_BT_ON,&gBtWifiGpsState)) && (osal_test_bit(WMT_GPS_ON,&gBtWifiGpsState)))
		{
			//send msg to GPS native for stopping send de-sense CMD
			ctrlPa1 = 0;
			ctrlPa2 = 0;
			wmt_core_ctrl(WMT_CTRL_BGW_DESENSE_CTRL,&ctrlPa1,&ctrlPa2);
		}
	}
	return iRet; 
#if 0
    return wmt_func_wifi_ctrl(FUNC_OFF);
#endif
}