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; } }
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; }
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; }
INT32 wmt_func_gps_off(P_WMT_IC_OPS pOps, P_WMT_GEN_CONF pConf) { INT32 iRet = 0; UINT32 ctrlPa1 = 0; UINT32 ctrlPa2 = 0; iRet = wmt_func_gps_pre_off(pOps, pConf); if (0 == iRet) { iRet = wmt_func_gps_ctrl(FUNC_OFF); if(!iRet) { osal_clear_bit(WMT_GPS_ON, &gBtWifiGpsState); if((osal_test_bit(WMT_BT_ON,&gBtWifiGpsState)) || (osal_test_bit(WMT_WIFI_ON,&gBtWifiGpsState))) { //send msg to GPS native for stop sending de-sense CMD ctrlPa1 = 0; ctrlPa2 = 0; wmt_core_ctrl(WMT_CTRL_BGW_DESENSE_CTRL,&ctrlPa1,&ctrlPa2); } } } return iRet; }
INT32 wmt_func_fm_on(P_WMT_IC_OPS pOps, P_WMT_GEN_CONF pConf) { /* return wmt_func_fm_ctrl(FUNC_ON); */ UINT32 ctrlPa1 = 0; UINT32 ctrlPa2 = 0; INT32 iRet = -1; UINT8 co_clock_type = (pConf->co_clock_flag & 0x0f); if (co_clock_type) { if (!osal_test_bit(WMT_GPS_ON, &gGpsFmState)) { ctrlPa1 = FM_PALDO; ctrlPa2 = PALDO_ON; wmt_core_ctrl(WMT_CTRL_SOC_PALDO_CTRL, &ctrlPa1, &ctrlPa2); } else { WMT_INFO_FUNC("LDO VCN28 has been turn on by GPS\n"); } } iRet = wmt_core_func_ctrl_cmd(WMTDRV_TYPE_FM, MTK_WCN_BOOL_TRUE); if (!iRet) { if (co_clock_type) osal_set_bit(WMT_FM_ON, &gGpsFmState); } return iRet; }
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; }
INT32 wmt_func_gps_off(P_WMT_IC_OPS pOps, P_WMT_GEN_CONF pConf) { INT32 iRet = 0; UINT32 ctrlPa1 = 0; UINT32 ctrlPa2 = 0; UINT8 co_clock_type = (pConf->co_clock_flag & 0x0f); iRet = wmt_func_gps_pre_off(pOps, pConf); if (0 == iRet) { iRet = wmt_func_gps_ctrl(FUNC_OFF); if (!iRet) { osal_clear_bit(WMT_GPS_ON, &gBtWifiGpsState); if ((osal_test_bit(WMT_BT_ON, &gBtWifiGpsState)) || (osal_test_bit(WMT_WIFI_ON, &gBtWifiGpsState))) { /* send msg to GPS native for stop sending de-sense CMD */ ctrlPa1 = 0; ctrlPa2 = 0; wmt_core_ctrl(WMT_CTRL_BGW_DESENSE_CTRL, &ctrlPa1, &ctrlPa2); } } } if ((co_clock_type) && (0 == pConf->wmt_gps_lna_enable)) { /* use SOC external LNA */ if (osal_test_bit(WMT_FM_ON, &gGpsFmState)) WMT_INFO_FUNC("FM is still on, do not turn off LDO VCN28\n"); else { ctrlPa1 = GPS_PALDO; ctrlPa2 = PALDO_OFF; wmt_core_ctrl(WMT_CTRL_SOC_PALDO_CTRL, &ctrlPa1, &ctrlPa2); } osal_clear_bit(WMT_GPS_ON, &gGpsFmState); } return iRet; }
INT32 wmt_func_fm_off(P_WMT_IC_OPS pOps, P_WMT_GEN_CONF pConf) { //return wmt_func_fm_ctrl(FUNC_OFF); UINT32 ctrlPa1 = 0; UINT32 ctrlPa2 = 0; if(pConf->co_clock_flag) { ctrlPa1 = FM_PALDO; ctrlPa2 = PALDO_OFF; wmt_core_ctrl(WMT_CTRL_SOC_PALDO_CTRL,&ctrlPa1,&ctrlPa2); } return wmt_core_func_ctrl_cmd(WMTDRV_TYPE_FM, MTK_WCN_BOOL_FALSE); }
INT32 wmt_func_gps_on(P_WMT_IC_OPS pOps, P_WMT_GEN_CONF pConf) { INT32 iRet = 0; UINT32 ctrlPa1; UINT32 ctrlPa2; UINT8 co_clock_type = (pConf->co_clock_flag & 0x0f); if ((co_clock_type) && (0 == pConf->wmt_gps_lna_enable)) { /* use SOC external LNA */ if (!osal_test_bit(WMT_FM_ON, &gGpsFmState)) { ctrlPa1 = GPS_PALDO; ctrlPa2 = PALDO_ON; wmt_core_ctrl(WMT_CTRL_SOC_PALDO_CTRL, &ctrlPa1, &ctrlPa2); } else { WMT_INFO_FUNC("LDO VCN28 has been turn on by FM\n"); } } iRet = wmt_func_gps_pre_on(pOps, pConf); if (0 == iRet) { iRet = wmt_func_gps_ctrl(FUNC_ON); if (!iRet) { osal_set_bit(WMT_GPS_ON, &gBtWifiGpsState); if ((osal_test_bit(WMT_BT_ON, &gBtWifiGpsState)) || (osal_test_bit(WMT_WIFI_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); } if ((co_clock_type) && (0 == pConf->wmt_gps_lna_enable)) /* use SOC external LNA */ osal_set_bit(WMT_GPS_ON, &gGpsFmState); } } return iRet; }
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 }
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 }
INT32 wmt_func_fm_off(P_WMT_IC_OPS pOps, P_WMT_GEN_CONF pConf) { /* return wmt_func_fm_ctrl(FUNC_OFF); */ UINT32 ctrlPa1 = 0; UINT32 ctrlPa2 = 0; INT32 iRet = -1; UINT8 co_clock_type = (pConf->co_clock_flag & 0x0f); iRet = wmt_core_func_ctrl_cmd(WMTDRV_TYPE_FM, MTK_WCN_BOOL_FALSE); if (co_clock_type) { if (osal_test_bit(WMT_GPS_ON, &gGpsFmState)) { WMT_INFO_FUNC("GPS is still on, do not turn off LDO VCN28\n"); } else { ctrlPa1 = FM_PALDO; ctrlPa2 = PALDO_OFF; wmt_core_ctrl(WMT_CTRL_SOC_PALDO_CTRL, &ctrlPa1, &ctrlPa2); } osal_clear_bit(WMT_FM_ON, &gGpsFmState); } return iRet; }