VOID wmt_idc_dump_debug_msg(UINT8 *str,UINT8 *p_buf,UINT32 buf_len) { UINT32 idx = 0; WMT_DBG_FUNC("%s:, length:%d\n", str, buf_len); WMT_DBG_FUNC("ASCII output:\n"); for (idx = 0; idx < buf_len;) { WMT_DBG_FUNC("%c", p_buf[idx]); idx++; if (0 == idx % 16) WMT_DBG_FUNC("\n"); } WMT_DBG_FUNC("HEX output:\n"); for (idx = 0; idx < buf_len;) { WMT_DBG_FUNC("%02x ", p_buf[idx]); idx++; if (0 == idx % 16) WMT_DBG_FUNC("\n"); } }
INT32 wmt_plat_pcm_ctrl(ENUM_PIN_STATE state) { UINT32 normalPCMFlag = 0; /*check if combo chip support merge if or not*/ if (0 != wmt_plat_merge_if_flag_get()) { #if (MTK_WCN_CMB_MERGE_INTERFACE_SUPPORT) //Hardware support Merge IF function WMT_DBG_FUNC("WMT-PLAT:<Merge IF>set to Merge PCM function\n"); /*merge PCM function define*/ switch(state) { case PIN_STA_MUX: case PIN_STA_INIT: mt_set_gpio_mode(GPIO_PCM_DAICLK_PIN, GPIO_PCM_DAICLK_PIN_PINMUX_MODE); mt_set_gpio_mode(GPIO_PCM_DAIPCMOUT_PIN, GPIO_PCM_DAIPCMOUT_PIN_PINMUX_MODE); mt_set_gpio_mode(GPIO_PCM_DAIPCMIN_PIN, GPIO_PCM_DAIPCMIN_PIN_PINMUX_MODE); mt_set_gpio_mode(GPIO_PCM_DAISYNC_PIN, GPIO_PCM_DAISYNC_PIN_PINMUX_MODE); WMT_DBG_FUNC("WMT-PLAT:<Merge IF>PCM init (pcm) \n"); break; case PIN_STA_IN_L: case PIN_STA_DEINIT: mt_set_gpio_mode(GPIO_PCM_DAICLK_PIN, GPIO_PCM_DAICLK_PIN_PINMUX_MODE);//GPIO_PCM_DAICLK_PIN_M_GPIO); //mt_set_gpio_dir(GPIO_PCM_DAICLK_PIN, GPIO_DIR_OUT); //mt_set_gpio_out(GPIO_PCM_DAICLK_PIN, GPIO_OUT_ZERO); mt_set_gpio_mode(GPIO_PCM_DAIPCMOUT_PIN, GPIO_PCM_DAIPCMOUT_PIN_PINMUX_MODE);//GPIO_PCM_DAIPCMOUT_PIN_M_GPIO); //mt_set_gpio_dir(GPIO_PCM_DAIPCMOUT_PIN, GPIO_DIR_OUT); //mt_set_gpio_out(GPIO_PCM_DAIPCMOUT_PIN, GPIO_OUT_ZERO); mt_set_gpio_mode(GPIO_PCM_DAIPCMIN_PIN, GPIO_PCM_DAIPCMIN_PIN_PINMUX_MODE);//GPIO_PCM_DAIPCMIN_PIN_M_GPIO); //mt_set_gpio_dir(GPIO_PCM_DAIPCMIN_PIN, GPIO_DIR_OUT); //mt_set_gpio_out(GPIO_PCM_DAIPCMIN_PIN, GPIO_OUT_ZERO); mt_set_gpio_mode(GPIO_PCM_DAISYNC_PIN, GPIO_PCM_DAISYNC_PIN_PINMUX_MODE);//GPIO_PCM_DAISYNC_PIN_M_GPIO); //mt_set_gpio_dir(GPIO_PCM_DAISYNC_PIN, GPIO_DIR_OUT); //mt_set_gpio_out(GPIO_PCM_DAISYNC_PIN, GPIO_OUT_ZERO); WMT_DBG_FUNC("WMT-PLAT:<Merge IF>PCM deinit (out 0) \n"); break; default: WMT_WARN_FUNC("WMT-PLAT:<Merge IF>Warnning, invalid state(%d) on PCM Group\n", state); break; } #else //Hardware does not support Merge IF function normalPCMFlag = 1; WMT_DBG_FUNC("WMT-PLAT:set to normal PCM function\n"); #endif } else { normalPCMFlag = 1; } if (0 != normalPCMFlag) { /*normal PCM function define*/ switch(state) { case PIN_STA_MUX: case PIN_STA_INIT: mt_set_gpio_mode(GPIO_PCM_DAICLK_PIN, GPIO_PCM_DAICLK_PIN_PCMONLY_MODE); mt_set_gpio_mode(GPIO_PCM_DAIPCMOUT_PIN, GPIO_PCM_DAIPCMOUT_PIN_PCMONLY_MODE); mt_set_gpio_mode(GPIO_PCM_DAIPCMIN_PIN, GPIO_PCM_DAIPCMIN_PIN_PCMONLY_MODE); mt_set_gpio_mode(GPIO_PCM_DAISYNC_PIN, GPIO_PCM_DAISYNC_PIN_PCMONLY_MODE); WMT_DBG_FUNC("WMT-PLAT:MT6589 PCM init (pcm) \n"); break; case PIN_STA_IN_L: case PIN_STA_DEINIT: mt_set_gpio_mode(GPIO_PCM_DAICLK_PIN, GPIO_PCM_DAICLK_PIN_PCMONLY_MODE);//GPIO_PCM_DAICLK_PIN_M_GPIO); //mt_set_gpio_dir(GPIO_PCM_DAICLK_PIN, GPIO_DIR_OUT); //mt_set_gpio_out(GPIO_PCM_DAICLK_PIN, GPIO_OUT_ZERO); mt_set_gpio_mode(GPIO_PCM_DAIPCMOUT_PIN, GPIO_PCM_DAIPCMOUT_PIN_PCMONLY_MODE);//GPIO_PCM_DAIPCMOUT_PIN_M_GPIO); //mt_set_gpio_dir(GPIO_PCM_DAIPCMOUT_PIN, GPIO_DIR_OUT); //mt_set_gpio_out(GPIO_PCM_DAIPCMOUT_PIN, GPIO_OUT_ZERO); mt_set_gpio_mode(GPIO_PCM_DAIPCMIN_PIN, GPIO_PCM_DAIPCMIN_PIN_PCMONLY_MODE);//GPIO_PCM_DAIPCMIN_PIN_M_GPIO); //mt_set_gpio_dir(GPIO_PCM_DAIPCMIN_PIN, GPIO_DIR_OUT); //mt_set_gpio_out(GPIO_PCM_DAIPCMIN_PIN, GPIO_OUT_ZERO); mt_set_gpio_mode(GPIO_PCM_DAISYNC_PIN, GPIO_PCM_DAISYNC_PIN_PCMONLY_MODE);//GPIO_PCM_DAISYNC_PIN_M_GPIO); //mt_set_gpio_dir(GPIO_PCM_DAISYNC_PIN, GPIO_DIR_OUT); //mt_set_gpio_out(GPIO_PCM_DAISYNC_PIN, GPIO_OUT_ZERO); WMT_DBG_FUNC("WMT-PLAT:MT6589 PCM deinit (out 0) \n"); break; default: WMT_WARN_FUNC("WMT-PLAT:MT6589 Warnning, invalid state(%d) on PCM Group\n", state); break; } } return 0; }
INT32 wmt_plat_pmu_ctrl ( ENUM_PIN_STATE state ) { switch(state) { case PIN_STA_INIT: /*set to gpio output low, disable pull*/ mt_set_gpio_pull_enable(GPIO_COMBO_PMU_EN_PIN, GPIO_PULL_DISABLE); mt_set_gpio_dir(GPIO_COMBO_PMU_EN_PIN, GPIO_DIR_OUT); mt_set_gpio_mode(GPIO_COMBO_PMU_EN_PIN, GPIO_MODE_GPIO); mt_set_gpio_out(GPIO_COMBO_PMU_EN_PIN, GPIO_OUT_ZERO); #ifdef GPIO_COMBO_PMUV28_EN_PIN mt_set_gpio_pull_enable(GPIO_COMBO_PMUV28_EN_PIN, GPIO_PULL_DISABLE); mt_set_gpio_dir(GPIO_COMBO_PMUV28_EN_PIN, GPIO_DIR_OUT); mt_set_gpio_mode(GPIO_COMBO_PMUV28_EN_PIN, GPIO_MODE_GPIO); mt_set_gpio_out(GPIO_COMBO_PMUV28_EN_PIN, GPIO_OUT_ZERO); #endif WMT_DBG_FUNC("WMT-PLAT:PMU init (out 0) \n"); break; case PIN_STA_OUT_H: mt_set_gpio_out(GPIO_COMBO_PMU_EN_PIN, GPIO_OUT_ONE); #ifdef GPIO_COMBO_PMUV28_EN_PIN mt_set_gpio_out(GPIO_COMBO_PMUV28_EN_PIN, GPIO_OUT_ONE); #endif WMT_DBG_FUNC("WMT-PLAT:PMU (out 1) \n"); break; case PIN_STA_OUT_L: mt_set_gpio_out(GPIO_COMBO_PMU_EN_PIN, GPIO_OUT_ZERO); #ifdef GPIO_COMBO_PMUV28_EN_PIN mt_set_gpio_out(GPIO_COMBO_PMUV28_EN_PIN, GPIO_OUT_ZERO); #endif WMT_DBG_FUNC("WMT-PLAT:PMU (out 0) \n"); break; case PIN_STA_IN_L: case PIN_STA_DEINIT: /*set to gpio input low, pull down enable*/ mt_set_gpio_mode(GPIO_COMBO_PMU_EN_PIN, GPIO_COMBO_PMU_EN_PIN_M_GPIO); mt_set_gpio_dir(GPIO_COMBO_PMU_EN_PIN, GPIO_DIR_IN); mt_set_gpio_pull_select(GPIO_COMBO_PMU_EN_PIN, GPIO_PULL_DOWN); mt_set_gpio_pull_enable(GPIO_COMBO_PMU_EN_PIN, GPIO_PULL_ENABLE); #ifdef GPIO_COMBO_PMUV28_EN_PIN mt_set_gpio_mode(GPIO_COMBO_PMUV28_EN_PIN, GPIO_COMBO_PMUV28_EN_PIN_M_GPIO); mt_set_gpio_dir(GPIO_COMBO_PMUV28_EN_PIN, GPIO_DIR_IN); mt_set_gpio_pull_select(GPIO_COMBO_PMUV28_EN_PIN, GPIO_PULL_DOWN); mt_set_gpio_pull_enable(GPIO_COMBO_PMUV28_EN_PIN, GPIO_PULL_ENABLE); #endif WMT_DBG_FUNC("WMT-PLAT:PMU deinit (in pd) \n"); break; case PIN_STA_SHOW: WMT_INFO_FUNC("WMT-PLAT:PMU PIN_STA_SHOW start\n"); WMT_INFO_FUNC("WMT-PLAT:PMU Mode(%d)\n", mt_get_gpio_mode(GPIO_COMBO_PMU_EN_PIN)); WMT_INFO_FUNC("WMT-PLAT:PMU Dir(%d)\n", mt_get_gpio_dir(GPIO_COMBO_PMU_EN_PIN)); WMT_INFO_FUNC("WMT-PLAT:PMU Pull enable(%d)\n", mt_get_gpio_pull_enable(GPIO_COMBO_PMU_EN_PIN)); WMT_INFO_FUNC("WMT-PLAT:PMU Pull select(%d)\n", mt_get_gpio_pull_select(GPIO_COMBO_PMU_EN_PIN)); WMT_INFO_FUNC("WMT-PLAT:PMU out(%d)\n", mt_get_gpio_out(GPIO_COMBO_PMU_EN_PIN)); WMT_INFO_FUNC("WMT-PLAT:PMU PIN_STA_SHOW end\n"); break; default: WMT_WARN_FUNC("WMT-PLAT:Warnning, invalid state(%d) on PMU\n", state); break; } return 0; }
INT32 wmt_plat_eirq_ctrl ( ENUM_PIN_ID id, ENUM_PIN_STATE state ) { INT32 iret; // TODO: [ChangeFeature][GeorgeKuo]: use another function to handle this, as done in gpio_ctrls if ( (PIN_STA_INIT != state ) && (PIN_STA_DEINIT != state ) && (PIN_STA_EINT_EN != state ) && (PIN_STA_EINT_DIS != state ) ) { WMT_WARN_FUNC("WMT-PLAT:invalid PIN_STATE(%d) in eirq_ctrl for PIN(%d)\n", state, id); return -1; } iret = -2; switch (id) { case PIN_BGF_EINT: #ifdef GPIO_COMBO_BGF_EINT_PIN if (PIN_STA_INIT == state) { #if CUST_EINT_COMBO_BGF_DEBOUNCE_EN mt_eint_set_hw_debounce(CUST_EINT_COMBO_BGF_NUM, CUST_EINT_COMBO_BGF_DEBOUNCE_CN); #endif mt_eint_registration(CUST_EINT_COMBO_BGF_NUM, CUST_EINT_COMBO_BGF_POLARITY, wmt_plat_bgf_eirq_cb, 0); mt_eint_mask(CUST_EINT_COMBO_BGF_NUM); /*2*/ } else if (PIN_STA_EINT_EN == state) { mt_eint_unmask(CUST_EINT_COMBO_BGF_NUM); WMT_DBG_FUNC("WMT-PLAT:BGFInt (en) \n"); } else if (PIN_STA_EINT_DIS == state) { mt_eint_mask(CUST_EINT_COMBO_BGF_NUM); WMT_DBG_FUNC("WMT-PLAT:BGFInt (dis) \n"); } else { mt_eint_mask(CUST_EINT_COMBO_BGF_NUM); /* de-init: nothing to do in ALPS, such as un-registration... */ } #else WMT_INFO_FUNC("WMT-PLAT:BGF EINT not defined\n", state); #endif iret = 0; break; case PIN_ALL_EINT: #ifdef GPIO_COMBO_ALL_EINT_PIN if (PIN_STA_INIT == state) { #if 0 #if CUST_EINT_COMBO_ALL_DEBOUNCE_EN mt_eint_set_hw_debounce(CUST_EINT_COMBO_ALL_NUM, CUST_EINT_COMBO_ALL_DEBOUNCE_CN); #endif mt_eint_registration(CUST_EINT_COMBO_ALL_NUM, CUST_EINT_COMBO_ALL_TYPE, combo_bgf_eirq_handler, 0); #endif mt_eint_mask(CUST_EINT_COMBO_ALL_NUM); /*2*/ WMT_DBG_FUNC("WMT-PLAT:ALLInt (INIT but not used yet) \n"); } else if (PIN_STA_EINT_EN == state) { /*mt_eint_unmask(CUST_EINT_COMBO_ALL_NUM);*/ WMT_DBG_FUNC("WMT-PLAT:ALLInt (EN but not used yet) \n"); } else if (PIN_STA_EINT_DIS == state) { mt_eint_mask(CUST_EINT_COMBO_ALL_NUM); WMT_DBG_FUNC("WMT-PLAT:ALLInt (DIS but not used yet) \n"); } else { mt_eint_mask(CUST_EINT_COMBO_ALL_NUM); WMT_DBG_FUNC("WMT-PLAT:ALLInt (DEINIT but not used yet) \n"); /* de-init: nothing to do in ALPS, such as un-registration... */ } #else WMT_INFO_FUNC("WMT-PLAT:ALL EINT not defined\n", state); #endif iret = 0; break; default: WMT_WARN_FUNC("WMT-PLAT:unsupported EIRQ(PIN_ID:%d) in eirq_ctrl\n", id); iret = -1; break; } return iret; }
INT32 wmt_plat_eirq_ctrl ( ENUM_PIN_ID id, ENUM_PIN_STATE state ) { INT32 iret; // TODO: [ChangeFeature][GeorgeKuo]: use another function to handle this, as done in gpio_ctrls if ( (PIN_STA_INIT != state ) && (PIN_STA_DEINIT != state ) && (PIN_STA_EINT_EN != state ) && (PIN_STA_EINT_DIS != state ) ) { WMT_WARN_FUNC("WMT-PLAT:invalid PIN_STATE(%d) in eirq_ctrl for PIN(%d)\n", state, id); return -1; } iret = -2; switch (id) { case PIN_BGF_EINT: #if 1 if (PIN_STA_INIT == state) { iret = request_irq(MT_CONN2AP_BTIF_WAKEUP_IRQ_ID, (irq_handler_t)wmt_plat_bgf_irq_isr, IRQF_TRIGGER_LOW, "BTIF_WAKEUP_IRQ", NULL); if(iret) { WMT_ERR_FUNC("request_irq fail,irq_no(%d),iret(%d)\n",MT_CONN2AP_BTIF_WAKEUP_IRQ_ID,iret); return iret; } gbgfIrqBle.counter = 1; } else if (PIN_STA_EINT_EN == state) { osal_lock_unsleepable_lock(&gbgfIrqBle.lock); if(gbgfIrqBle.counter) { WMT_DBG_FUNC("BGF INT has been enabled,counter(%d)\n",gbgfIrqBle.counter);; } else { enable_irq(MT_CONN2AP_BTIF_WAKEUP_IRQ_ID); gbgfIrqBle.counter++; } WMT_DBG_FUNC("WMT-PLAT:BGFInt (en) \n"); osal_unlock_unsleepable_lock(&gbgfIrqBle.lock); } else if (PIN_STA_EINT_DIS == state) { osal_lock_unsleepable_lock(&gbgfIrqBle.lock); if(!gbgfIrqBle.counter) { WMT_INFO_FUNC("BGF INT has been disabled,counter(%d)\n",gbgfIrqBle.counter);; } else { disable_irq_nosync(MT_CONN2AP_BTIF_WAKEUP_IRQ_ID); gbgfIrqBle.counter--; } WMT_DBG_FUNC("WMT-PLAT:BGFInt (dis) \n"); osal_unlock_unsleepable_lock(&gbgfIrqBle.lock); } else { free_irq(MT_CONN2AP_BTIF_WAKEUP_IRQ_ID,NULL); /* de-init: nothing to do in ALPS, such as un-registration... */ } #else WMT_INFO_FUNC("WMT-PLAT:BGF EINT not defined\n", state); #endif iret = 0; break; default: WMT_WARN_FUNC("WMT-PLAT:unsupported EIRQ(PIN_ID:%d) in eirq_ctrl\n", id); iret = -1; break; } return iret; }
INT32 wmt_idc_msg_to_lte_handing(VOID) { UINT32 readlen = 0; local_para_struct *p_lps = NULL; UINT8 *p_data = NULL; UINT8 opcode = 0; UINT16 msg_len = 0; UINT32 handle_len = 0; #if CFG_WMT_LTE_ENABLE_MSGID_MAPPING MTK_WCN_BOOL unknow_msgid = MTK_WCN_BOOL_FALSE; #endif readlen = mtk_wcn_stp_receive_data(&gWmtIdcInfo.buffer[0], LTE_IDC_BUFFER_MAX_SIZE, COEX_TASK_INDX); if (readlen == 0) { osal_sleep_ms(5); readlen = mtk_wcn_stp_receive_data(&gWmtIdcInfo.buffer[0], LTE_IDC_BUFFER_MAX_SIZE, COEX_TASK_INDX); } if (readlen > 0) { WMT_DBG_FUNC("read data len from fw(%d)\n", readlen); wmt_idc_dump_debug_msg("WMT->LTE from STP buffer", &gWmtIdcInfo.buffer[0], readlen); p_data = &gWmtIdcInfo.buffer[0]; while (handle_len < readlen) { p_data += 2; /*omit direction & opcode 2 bytes */ osal_memcpy(&msg_len, p_data, 2); msg_len -= 1; /*flag byte */ WMT_DBG_FUNC("current raw data len(%d) from connsys firmware\n", msg_len); p_data += 2; /*length: 2 bytes */ /*how to handle flag(msg type) need to Scott comment */ /************************************************/ if (*p_data == WMT_IDC_RX_OPCODE_DEBUG_MONITOR) /*do not need transfer to LTE */ { p_data += 1; /*flag : 1 byte */ /*need to handle these debug message */ wmt_idc_dump_debug_msg("WIFI DEBUG MONITOR", p_data, msg_len); } else /*need to transfer to LTE */ { p_lps = (local_para_struct *) osal_malloc(osal_sizeof(local_para_struct) + osal_sizeof(UINT8) * msg_len); if (NULL == p_lps) { WMT_ERR_FUNC("allocate local_para_struct memory fail\n"); return -1; } p_lps->msg_len = msg_len + osal_sizeof(local_para_struct); opcode = *p_data; WMT_DBG_FUNC("current opcode(%d) to LTE\n", opcode); p_data += 1; /*flag : 1 byte */ osal_memcpy(p_lps->data, p_data, msg_len); gWmtIdcInfo.iit.local_para_ptr = p_lps; #if CFG_WMT_LTE_ENABLE_MSGID_MAPPING switch (opcode) { case WMT_IDC_RX_OPCODE_BTWF_DEF_PARA: gWmtIdcInfo.iit.msg_id = IPC_MSG_ID_EL1_WIFIBT_OPER_DEFAULT_PARAM_IND; break; case WMT_IDC_RX_OPCODE_BTWF_CHAN_RAN: gWmtIdcInfo.iit.msg_id = IPC_MSG_ID_EL1_WIFIBT_OPER_FREQ_IND; break; case WMT_IDC_RX_OPCODE_LTE_FREQ_IDX_TABLE: gWmtIdcInfo.iit.msg_id = IPC_MSG_ID_EL1_WIFIBT_FREQ_IDX_TABLE_IND; break; case WMT_IDC_RX_OPCODE_BTWF_PROFILE_IND: gWmtIdcInfo.iit.msg_id = IPC_MSG_ID_EL1_WIFIBT_PROFILE_IND; break; case WMT_IDC_RX_OPCODE_UART_PIN_SEL: gWmtIdcInfo.iit.msg_id = IPC_MSG_ID_EL1_PIN_TYPE_IND; break; /* case WMT_IDC_RX_OPCODE_TDM_REQ: */ /* gWmtIdcInfo.iit.msg_id = IPC_MSG_ID_EL1_WIFIBT_OPER_FREQ_IND; */ /* break; */ default: unknow_msgid = MTK_WCN_BOOL_TRUE; WMT_ERR_FUNC("unknow opcode(%d) from connsys firmware\n", opcode); break; } if (MTK_WCN_BOOL_FALSE == unknow_msgid) { /*handling flag value in wmt cmd */ mtk_conn_md_bridge_send_msg(&gWmtIdcInfo.iit); } #else if (opcode >= LTE_MSG_ID_OFFSET) { gWmtIdcInfo.iit.msg_id = opcode + IPC_EL1_MSG_ID_BEGIN - LTE_MSG_ID_OFFSET + 1; /*handling flag value in wmt cmd */ mtk_conn_md_bridge_send_msg(&gWmtIdcInfo.iit); WMT_INFO_FUNC("CONN->LTE: (0x%x->0x%x)\n", opcode, gWmtIdcInfo.iit.msg_id); } else { WMT_ERR_FUNC("opcode(%d)from connsys fw is out of range,drop it!\n", opcode); } #endif osal_free(p_lps); } p_data += msg_len; /*point to next package header */ handle_len += (msg_len + 5); } } else { WMT_ERR_FUNC("there is no coex data in stp buffer\n"); } osal_memset(&gWmtIdcInfo.buffer[0], 0, LTE_IDC_BUFFER_MAX_SIZE); return 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_WARN_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 pOpData->au4OpData[1]; }
// TODO: [ChangeFeature][George] refine this function name for general filesystem read operation, not patch only. INT32 wmt_dev_patch_get ( UCHAR *pPatchName, osal_firmware **ppPatch, INT32 padSzBuf ) { INT32 iRet = -1; osal_firmware *pfw; uid_t orig_uid; gid_t orig_gid; #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,29)) //struct cred *cred = get_task_cred(current); struct cred *cred = (struct cred *)get_current_cred(); #endif mm_segment_t orig_fs = get_fs(); if (*ppPatch) { WMT_WARN_FUNC("f/w patch already exists \n"); if ((*ppPatch)->data) { vfree((*ppPatch)->data); } kfree(*ppPatch); *ppPatch = NULL; } if (!osal_strlen(pPatchName)) { WMT_ERR_FUNC("empty f/w name\n"); osal_assert((osal_strlen(pPatchName) > 0)); return -1; } pfw = kzalloc(sizeof(osal_firmware), /*GFP_KERNEL*/GFP_ATOMIC); if (!pfw) { WMT_ERR_FUNC("kzalloc(%d) fail\n", sizeof(osal_firmware)); return -2; } #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,29)) orig_uid = cred->fsuid; orig_gid = cred->fsgid; cred->fsuid = cred->fsgid = 0; #else orig_uid = current->fsuid; orig_gid = current->fsgid; current->fsuid = current->fsgid = 0; #endif set_fs(get_ds()); /* load patch file from fs */ iRet = wmt_dev_read_file(pPatchName, &pfw->data, 0, padSzBuf); set_fs(orig_fs); #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,29)) cred->fsuid = orig_uid; cred->fsgid = orig_gid; #else current->fsuid = orig_uid; current->fsgid = orig_gid; #endif if (iRet > 0) { pfw->size = iRet; *ppPatch = pfw; WMT_DBG_FUNC("load (%s) to addr(0x%p) success\n", pPatchName, pfw->data); return 0; } else { kfree(pfw); *ppPatch = NULL; WMT_ERR_FUNC("load file (%s) fail, iRet(%d) \n", pPatchName, iRet); return -1; } }
INT32 wmt_plat_pcm_ctrl(ENUM_PIN_STATE state) { #if (CONFIG_ARCH_MT6589) #if defined(MTK_MERGE_INTERFACE_SUPPORT) /*merge PCM function define*/ switch(state) { case PIN_STA_MUX: case PIN_STA_INIT: mt_set_gpio_mode(GPIO_PCM_DAICLK_PIN, GPIO_PCM_DAICLK_PIN_M_CLK); mt_set_gpio_mode(GPIO_PCM_DAIPCMOUT_PIN, GPIO_PCM_DAIPCMOUT_PIN_M_MRG_I2S_PCM_TX); mt_set_gpio_mode(GPIO_PCM_DAIPCMIN_PIN, GPIO_PCM_DAIPCMIN_PIN_M_MRG_I2S_PCM_RX); mt_set_gpio_mode(GPIO_PCM_DAISYNC_PIN, GPIO_PCM_DAISYNC_PIN_M_MRG_I2S_PCM_SYNC); WMT_DBG_FUNC("WMT-PLAT:PCM init (pcm) \n"); break; case PIN_STA_IN_L: case PIN_STA_DEINIT: mt_set_gpio_mode(GPIO_PCM_DAICLK_PIN, GPIO_PCM_DAICLK_PIN_M_GPIO); mt_set_gpio_dir(GPIO_PCM_DAICLK_PIN, GPIO_DIR_OUT); mt_set_gpio_out(GPIO_PCM_DAICLK_PIN, GPIO_OUT_ZERO); mt_set_gpio_mode(GPIO_PCM_DAIPCMOUT_PIN, GPIO_PCM_DAIPCMOUT_PIN_M_GPIO); mt_set_gpio_dir(GPIO_PCM_DAIPCMOUT_PIN, GPIO_DIR_OUT); mt_set_gpio_out(GPIO_PCM_DAIPCMOUT_PIN, GPIO_OUT_ZERO); mt_set_gpio_mode(GPIO_PCM_DAIPCMIN_PIN, GPIO_PCM_DAIPCMIN_PIN_M_GPIO); mt_set_gpio_dir(GPIO_PCM_DAIPCMIN_PIN, GPIO_DIR_OUT); mt_set_gpio_out(GPIO_PCM_DAIPCMIN_PIN, GPIO_OUT_ZERO); mt_set_gpio_mode(GPIO_PCM_DAISYNC_PIN, GPIO_PCM_DAISYNC_PIN_M_GPIO); mt_set_gpio_dir(GPIO_PCM_DAISYNC_PIN, GPIO_DIR_OUT); mt_set_gpio_out(GPIO_PCM_DAISYNC_PIN, GPIO_OUT_ZERO); WMT_DBG_FUNC("WMT-PLAT:PCM deinit (out 0) \n"); break; default: WMT_WARN_FUNC("WMT-PLAT:Warnning, invalid state(%d) on PCM Group\n", state); break; } #else /*normal PCM function define*/ switch(state) { case PIN_STA_MUX: case PIN_STA_INIT: mt_set_gpio_mode(GPIO_PCM_DAICLK_PIN, GPIO_PCM_DAICLK_PIN_M_PCM0_CK); mt_set_gpio_mode(GPIO_PCM_DAIPCMOUT_PIN, GPIO_PCM_DAIPCMOUT_PIN_M_PCM0_DO); mt_set_gpio_mode(GPIO_PCM_DAIPCMIN_PIN, GPIO_PCM_DAIPCMIN_PIN_M_PCM0_DI); mt_set_gpio_mode(GPIO_PCM_DAISYNC_PIN, GPIO_PCM_DAISYNC_PIN_M_PCM0_WS); WMT_DBG_FUNC("WMT-PLAT:PCM init (pcm) \n"); break; case PIN_STA_IN_L: case PIN_STA_DEINIT: mt_set_gpio_mode(GPIO_PCM_DAICLK_PIN, GPIO_PCM_DAICLK_PIN_M_GPIO); mt_set_gpio_dir(GPIO_PCM_DAICLK_PIN, GPIO_DIR_OUT); mt_set_gpio_out(GPIO_PCM_DAICLK_PIN, GPIO_OUT_ZERO); mt_set_gpio_mode(GPIO_PCM_DAIPCMOUT_PIN, GPIO_PCM_DAIPCMOUT_PIN_M_GPIO); mt_set_gpio_dir(GPIO_PCM_DAIPCMOUT_PIN, GPIO_DIR_OUT); mt_set_gpio_out(GPIO_PCM_DAIPCMOUT_PIN, GPIO_OUT_ZERO); mt_set_gpio_mode(GPIO_PCM_DAIPCMIN_PIN, GPIO_PCM_DAIPCMIN_PIN_M_GPIO); mt_set_gpio_dir(GPIO_PCM_DAIPCMIN_PIN, GPIO_DIR_OUT); mt_set_gpio_out(GPIO_PCM_DAIPCMIN_PIN, GPIO_OUT_ZERO); mt_set_gpio_mode(GPIO_PCM_DAISYNC_PIN, GPIO_PCM_DAISYNC_PIN_M_GPIO); mt_set_gpio_dir(GPIO_PCM_DAISYNC_PIN, GPIO_DIR_OUT); mt_set_gpio_out(GPIO_PCM_DAISYNC_PIN, GPIO_OUT_ZERO); WMT_DBG_FUNC("WMT-PLAT:PCM deinit (out 0) \n"); break; default: WMT_WARN_FUNC("WMT-PLAT:Warnning, invalid state(%d) on PCM Group\n", state); break; } #endif #else switch(state) { case PIN_STA_MUX: case PIN_STA_INIT: mt_set_gpio_mode(GPIO_PCM_DAICLK_PIN, GPIO_PCM_DAICLK_PIN_M_CLK); mt_set_gpio_mode(GPIO_PCM_DAIPCMOUT_PIN, GPIO_PCM_DAIPCMOUT_PIN_M_DAIPCMOUT); mt_set_gpio_mode(GPIO_PCM_DAIPCMIN_PIN, GPIO_PCM_DAIPCMIN_PIN_M_DAIPCMIN); mt_set_gpio_mode(GPIO_PCM_DAISYNC_PIN, GPIO_PCM_DAISYNC_PIN_M_BTSYNC); WMT_DBG_FUNC("WMT-PLAT:PCM init (pcm) \n"); break; case PIN_STA_IN_L: case PIN_STA_DEINIT: mt_set_gpio_mode(GPIO_PCM_DAICLK_PIN, GPIO_PCM_DAICLK_PIN_M_GPIO); mt_set_gpio_dir(GPIO_PCM_DAICLK_PIN, GPIO_DIR_OUT); mt_set_gpio_out(GPIO_PCM_DAICLK_PIN, GPIO_OUT_ZERO); mt_set_gpio_mode(GPIO_PCM_DAIPCMOUT_PIN, GPIO_PCM_DAIPCMOUT_PIN_M_GPIO); mt_set_gpio_dir(GPIO_PCM_DAIPCMOUT_PIN, GPIO_DIR_OUT); mt_set_gpio_out(GPIO_PCM_DAIPCMOUT_PIN, GPIO_OUT_ZERO); mt_set_gpio_mode(GPIO_PCM_DAIPCMIN_PIN, GPIO_PCM_DAIPCMIN_PIN_M_GPIO); mt_set_gpio_dir(GPIO_PCM_DAIPCMIN_PIN, GPIO_DIR_OUT); mt_set_gpio_out(GPIO_PCM_DAIPCMIN_PIN, GPIO_OUT_ZERO); mt_set_gpio_mode(GPIO_PCM_DAISYNC_PIN, GPIO_PCM_DAISYNC_PIN_M_GPIO); mt_set_gpio_dir(GPIO_PCM_DAISYNC_PIN, GPIO_DIR_OUT); mt_set_gpio_out(GPIO_PCM_DAISYNC_PIN, GPIO_OUT_ZERO); WMT_DBG_FUNC("WMT-PLAT:PCM deinit (out 0) \n"); break; default: WMT_WARN_FUNC("WMT-PLAT:Warnning, invalid state(%d) on PCM Group\n", state); break; } #endif return 0; }
INT32 wmt_plat_i2s_ctrl(ENUM_PIN_STATE state) { // TODO: [NewFeature][GeorgeKuo]: GPIO_I2Sx is changed according to different project. // TODO: provide a translation table in board_custom.h for different ALPS project customization. #if (CONFIG_ARCH_MT6589) #if defined(MTK_MERGE_INTERFACE_SUPPORT) /*do nothing, since PCM will do right settings*/ #if defined(FM_DIGITAL_INPUT) || defined(FM_DIGITAL_OUTPUT) #if defined (GPIO_COMBO_I2S_CK_PIN) switch(state) { case PIN_STA_INIT: case PIN_STA_MUX: mt_set_gpio_mode(GPIO_COMBO_I2S_CK_PIN, GPIO_COMBO_I2S_CK_PIN_M_CLK); mt_set_gpio_mode(GPIO_COMBO_I2S_WS_PIN, GPIO_COMBO_I2S_WS_PIN_M_MRG_I2S_PCM_SYNC); mt_set_gpio_mode(GPIO_COMBO_I2S_DAT_PIN, GPIO_COMBO_I2S_DAT_PIN_M_MRG_I2S_PCM_RX); WMT_DBG_FUNC("WMT-PLAT:<Merge IF>I2S init (I2S0 system) \n"); break; case PIN_STA_IN_L: case PIN_STA_DEINIT: mt_set_gpio_mode(GPIO_COMBO_I2S_CK_PIN, GPIO_COMBO_I2S_CK_PIN_M_GPIO); mt_set_gpio_dir(GPIO_COMBO_I2S_CK_PIN, GPIO_DIR_OUT); mt_set_gpio_out(GPIO_COMBO_I2S_CK_PIN, GPIO_OUT_ZERO); mt_set_gpio_mode(GPIO_COMBO_I2S_WS_PIN, GPIO_COMBO_I2S_WS_PIN_M_GPIO); mt_set_gpio_dir(GPIO_COMBO_I2S_WS_PIN, GPIO_DIR_OUT); mt_set_gpio_out(GPIO_COMBO_I2S_WS_PIN, GPIO_OUT_ZERO); mt_set_gpio_mode(GPIO_COMBO_I2S_DAT_PIN, GPIO_COMBO_I2S_DAT_PIN_M_GPIO); mt_set_gpio_dir(GPIO_COMBO_I2S_DAT_PIN, GPIO_DIR_OUT); mt_set_gpio_out(GPIO_COMBO_I2S_DAT_PIN, GPIO_OUT_ZERO); WMT_DBG_FUNC("WMT-PLAT:<Merge IF>I2S deinit (out 0) \n"); break; default: WMT_WARN_FUNC("WMT-PLAT:<Merge IF>Warnning, invalid state(%d) on I2S Group\n", state); break; } #else WMT_ERR_FUNC( "[MT662x]<Merge IF>Error:FM digital mode set, but no I2S GPIOs defined\n"); #endif #else WMT_INFO_FUNC( "[MT662x]<Merge IF>warnning:FM digital mode is not set, no I2S GPIO settings should be modified by combo driver\n"); #endif #else #if defined(FM_DIGITAL_INPUT) || defined(FM_DIGITAL_OUTPUT) #if defined (GPIO_COMBO_I2S_CK_PIN) switch(state) { case PIN_STA_INIT: case PIN_STA_MUX: mt_set_gpio_mode(GPIO_COMBO_I2S_CK_PIN, GPIO_COMBO_I2S_CK_PIN_M_I2SIN_CK); mt_set_gpio_mode(GPIO_COMBO_I2S_WS_PIN, GPIO_COMBO_I2S_WS_PIN_M_I2SIN_WS); mt_set_gpio_mode(GPIO_COMBO_I2S_DAT_PIN, GPIO_COMBO_I2S_DAT_PIN_M_I2SIN_DAT); WMT_DBG_FUNC("WMT-PLAT:<I2S IF>I2S init (I2S0 system) \n"); break; case PIN_STA_IN_L: case PIN_STA_DEINIT: mt_set_gpio_mode(GPIO_COMBO_I2S_CK_PIN, GPIO_COMBO_I2S_CK_PIN_M_GPIO); mt_set_gpio_dir(GPIO_COMBO_I2S_CK_PIN, GPIO_DIR_OUT); mt_set_gpio_out(GPIO_COMBO_I2S_CK_PIN, GPIO_OUT_ZERO); mt_set_gpio_mode(GPIO_COMBO_I2S_WS_PIN, GPIO_COMBO_I2S_WS_PIN_M_GPIO); mt_set_gpio_dir(GPIO_COMBO_I2S_WS_PIN, GPIO_DIR_OUT); mt_set_gpio_out(GPIO_COMBO_I2S_WS_PIN, GPIO_OUT_ZERO); mt_set_gpio_mode(GPIO_COMBO_I2S_DAT_PIN, GPIO_COMBO_I2S_DAT_PIN_M_GPIO); mt_set_gpio_dir(GPIO_COMBO_I2S_DAT_PIN, GPIO_DIR_OUT); mt_set_gpio_out(GPIO_COMBO_I2S_DAT_PIN, GPIO_OUT_ZERO); WMT_DBG_FUNC("WMT-PLAT:<I2S IF>I2S deinit (out 0) \n"); break; default: WMT_WARN_FUNC("WMT-PLAT:<I2S IF>Warnning, invalid state(%d) on I2S Group\n", state); break; } #else WMT_ERR_FUNC( "[MT662x]<I2S IF>Error:FM digital mode set, but no I2S GPIOs defined\n"); #endif #else WMT_INFO_FUNC( "[MT662x]<I2S IF>warnning:FM digital mode is not set, no I2S GPIO settings should be modified by combo driver\n"); #endif #endif #else #if defined(FM_DIGITAL_INPUT) || defined(FM_DIGITAL_OUTPUT) #if defined (GPIO_COMBO_I2S_CK_PIN) switch(state) { case PIN_STA_INIT: case PIN_STA_MUX: mt_set_gpio_mode(GPIO_COMBO_I2S_CK_PIN, GPIO_COMBO_I2S_CK_PIN_M_I2S0_CK); mt_set_gpio_mode(GPIO_COMBO_I2S_WS_PIN, GPIO_COMBO_I2S_WS_PIN_M_I2S0_WS); mt_set_gpio_mode(GPIO_COMBO_I2S_DAT_PIN, GPIO_COMBO_I2S_DAT_PIN_M_I2S0_DAT); WMT_DBG_FUNC("WMT-PLAT:I2S init (I2S0 system) \n"); break; case PIN_STA_IN_L: case PIN_STA_DEINIT: mt_set_gpio_mode(GPIO_COMBO_I2S_CK_PIN, GPIO_COMBO_I2S_CK_PIN_M_GPIO); mt_set_gpio_dir(GPIO_COMBO_I2S_CK_PIN, GPIO_DIR_OUT); mt_set_gpio_out(GPIO_COMBO_I2S_CK_PIN, GPIO_OUT_ZERO); mt_set_gpio_mode(GPIO_COMBO_I2S_WS_PIN, GPIO_COMBO_I2S_WS_PIN_M_GPIO); mt_set_gpio_dir(GPIO_COMBO_I2S_WS_PIN, GPIO_DIR_OUT); mt_set_gpio_out(GPIO_COMBO_I2S_WS_PIN, GPIO_OUT_ZERO); mt_set_gpio_mode(GPIO_COMBO_I2S_DAT_PIN, GPIO_COMBO_I2S_DAT_PIN_M_GPIO); mt_set_gpio_dir(GPIO_COMBO_I2S_DAT_PIN, GPIO_DIR_OUT); mt_set_gpio_out(GPIO_COMBO_I2S_DAT_PIN, GPIO_OUT_ZERO); WMT_DBG_FUNC("WMT-PLAT:I2S deinit (out 0) \n"); break; default: WMT_WARN_FUNC("WMT-PLAT:Warnning, invalid state(%d) on I2S Group\n", state); break; } #else WMT_ERR_FUNC( "[MT662x]Error:FM digital mode set, but no I2S GPIOs defined\n"); #endif #else WMT_INFO_FUNC( "[MT662x]warnning:FM digital mode is not set, no I2S GPIO settings should be modified by combo driver\n"); #endif #endif return 0; }
MTK_WCN_BOOL mtk_wcn_wmt_assert_timeout(ENUM_WMTDRV_TYPE_T type, UINT32 reason, INT32 timeout) #endif { P_OSAL_OP pOp = NULL; MTK_WCN_BOOL bRet = MTK_WCN_BOOL_FALSE; P_OSAL_SIGNAL pSignal; pOp = wmt_lib_get_free_op(); if (!pOp) { WMT_DBG_FUNC("get_free_lxop fail\n"); return MTK_WCN_BOOL_FALSE; } wmt_lib_set_host_assert_info(type,reason,1); pSignal = &pOp ->signal; pOp ->op.opId = WMT_OPID_TRIGGER_STP_ASSERT; pSignal->timeoutValue = timeout; /*this test command should be run with usb cable connected, so no host awake is needed*/ /* wmt_lib_host_awake_get(); */ pOp->op.au4OpData[0] = 0; /*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(); WMT_INFO_FUNC("STP_ASSERT, opid (%d), par(%d, %d), ret(%d), result(%s)\n", \ pOp->op.opId, \ pOp->op.au4OpData[0], \ pOp->op.au4OpData[1], \ bRet, \ MTK_WCN_BOOL_FALSE == bRet ? "failed" : "succeed"\ ); /*If trigger stp assert succeed, just return; trigger WMT level assert if failed*/ if (MTK_WCN_BOOL_TRUE == bRet) return bRet; pOp = wmt_lib_get_free_op(); if (!pOp) { WMT_DBG_FUNC("get_free_lxop fail\n"); return MTK_WCN_BOOL_FALSE; } wmt_lib_set_host_assert_info(type, reason, 1); pSignal = &pOp->signal; pOp->op.opId = WMT_OPID_CMD_TEST; pSignal->timeoutValue = timeout; /*this test command should be run with usb cable connected, so no host awake is needed */ /* wmt_lib_host_awake_get(); */ pOp->op.au4OpData[0] = 0; /*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(); */ WMT_INFO_FUNC("CMD_TEST, opid (%d), par(%d, %d), ret(%d), result(%s)\n", pOp->op.opId, pOp->op.au4OpData[0], pOp->op.au4OpData[1], bRet, MTK_WCN_BOOL_FALSE == bRet ? "failed" : "succeed"); return bRet; }
INT32 wmt_plat_eirq_ctrl ( ENUM_PIN_ID id, ENUM_PIN_STATE state ) { INT32 iRet = 0; #if CFG_WMT_PS_SUPPORT // TODO: [ChangeFeature][GeorgeKuo]: use another function to handle this, as done in gpio_ctrls if ( (PIN_STA_INIT != state ) && (PIN_STA_DEINIT != state ) && (PIN_STA_EINT_EN != state ) && (PIN_STA_EINT_DIS != state ) ) { iRet = -1; WMT_WARN_FUNC("WMT-PLAT:invalid PIN_STATE(%d) in eirq_ctrl for PIN(%d), ret(%d) \n", state, id, iRet); return iRet; } iRet = -2; switch (id) { case PIN_BGF_EINT: if (PIN_STA_INIT == state) { /*request irq,low level triggered*/ iRet = request_irq(mtk_bgf_irq,irq_handler,0,"BT_wu_host",NULL); printk("WMT-PLAT:BGFInt (init) \n"); WMT_INFO_FUNC("WMT-PLAT:BGFInt (init) \n"); } else if (PIN_STA_EINT_EN == state) { /*enable irq*/ bgf_INT_balance = 1; enable_irq(mtk_bgf_irq); WMT_INFO_FUNC("WMT-PLAT:BGFInt (en) \n"); } else if (PIN_STA_EINT_DIS == state) { /*disable irq*/ if(bgf_INT_balance == 1){ bgf_INT_balance = 0; disable_irq_nosync(mtk_bgf_irq); } WMT_INFO_FUNC("WMT-PLAT:BGFInt (dis) \n"); } else { /* de-init: free irq*/ free_irq(mtk_bgf_irq,NULL); WMT_INFO_FUNC("WMT-PLAT:BGFInt (deinit) \n"); } iRet = 0; WMT_WARN_FUNC("WMT-PLAT:wmt_plat_eirq_ctrl PIN_BGF_EINT ret (%d)\n", iRet); break; case PIN_ALL_EINT: WMT_DBG_FUNC("WMT-PLAT:ALLInt (not used yet) \n"); iRet = 0; break; default: WMT_WARN_FUNC("WMT-PLAT:unsupported EIRQ(PIN_ID:%d) in eirq_ctrl, ret (%d)\n", id, iRet); iRet = -1; break; } WMT_WARN_FUNC("WMT-PLAT:wmt_plat_eirq_ctrlret (%d)\n", iRet); #endif return iRet; }
/* INT32 WMT_ioctl(struct inode *inode, struct file *filp, UINT32 cmd, unsigned long arg) */ long WMT_unlocked_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) { #define WMT_IOC_MAGIC 0xa0 #define WMT_IOCTL_SET_PATCH_NAME _IOW(WMT_IOC_MAGIC, 4, char*) #define WMT_IOCTL_SET_STP_MODE _IOW(WMT_IOC_MAGIC, 5, int) #define WMT_IOCTL_FUNC_ONOFF_CTRL _IOW(WMT_IOC_MAGIC, 6, int) #define WMT_IOCTL_LPBK_POWER_CTRL _IOW(WMT_IOC_MAGIC, 7, int) #define WMT_IOCTL_LPBK_TEST _IOWR(WMT_IOC_MAGIC, 8, char*) #define WMT_IOCTL_GET_CHIP_INFO _IOR(WMT_IOC_MAGIC, 12, int) #define WMT_IOCTL_SET_LAUNCHER_KILL _IOW(WMT_IOC_MAGIC, 13, int) #define WMT_IOCTL_SET_PATCH_NUM _IOW(WMT_IOC_MAGIC, 14, int) #define WMT_IOCTL_SET_PATCH_INFO _IOW(WMT_IOC_MAGIC, 15, char*) #define WMT_IOCTL_PORT_NAME _IOWR(WMT_IOC_MAGIC, 20, char*) #define WMT_IOCTL_WMT_CFG_NAME _IOWR(WMT_IOC_MAGIC, 21, char*) #define WMT_IOCTL_WMT_QUERY_CHIPID _IOR(WMT_IOC_MAGIC, 22, int) #define WMT_IOCTL_WMT_TELL_CHIPID _IOW(WMT_IOC_MAGIC, 23, int) #define WMT_IOCTL_WMT_COREDUMP_CTRL _IOW(WMT_IOC_MAGIC, 24, int) #define WMT_IOCTL_WMT_STP_ASSERT_CTRL _IOW(WMT_IOC_MAGIC, 27, int) INT32 iRet = 0; UINT8 pBuffer[NAME_MAX + 1]; WMT_DBG_FUNC("cmd (%u), arg (0x%lx)\n", cmd, arg); switch (cmd) { case WMT_IOCTL_SET_PATCH_NAME: /* patch location */ { if (copy_from_user(pBuffer, (void *)arg, NAME_MAX)) { iRet = -EFAULT; break; } pBuffer[NAME_MAX] = '\0'; wmt_lib_set_patch_name(pBuffer); } break; case WMT_IOCTL_SET_STP_MODE: /* stp/hif/fm mode */ /* set hif conf */ do { P_OSAL_OP pOp; MTK_WCN_BOOL bRet; P_OSAL_SIGNAL pSignal = NULL; P_WMT_HIF_CONF pHif = NULL; iRet = wmt_lib_set_hif(arg); if (0 != iRet) { WMT_INFO_FUNC("wmt_lib_set_hif fail (%lu)\n", arg); break; } pOp = wmt_lib_get_free_op(); if (!pOp) { WMT_INFO_FUNC("get_free_lxop fail\n"); break; } pSignal = &pOp->signal; pOp->op.opId = WMT_OPID_HIF_CONF; pHif = wmt_lib_get_hif(); osal_memcpy(&pOp->op.au4OpData[0], pHif, sizeof(WMT_HIF_CONF)); pOp->op.u4InfoBit = WMT_OP_HIF_BIT; pSignal->timeoutValue = 0; bRet = wmt_lib_put_act_op(pOp); WMT_DBG_FUNC("WMT_OPID_HIF_CONF result(%d)\n", bRet); iRet = (MTK_WCN_BOOL_FALSE == bRet) ? -EFAULT : 0; } while (0); break; case WMT_IOCTL_FUNC_ONOFF_CTRL: /* test turn on/off func */ do { MTK_WCN_BOOL bRet = MTK_WCN_BOOL_FALSE; if (arg & 0x80000000) { bRet = mtk_wcn_wmt_func_on(arg & 0xF); } else { bRet = mtk_wcn_wmt_func_off(arg & 0xF); } iRet = (MTK_WCN_BOOL_FALSE == bRet) ? -EFAULT : 0; } while (0); break; case WMT_IOCTL_LPBK_POWER_CTRL: /*switch Loopback function on/off arg: bit0 = 1:turn loopback function on bit0 = 0:turn loopback function off */ do { MTK_WCN_BOOL bRet = MTK_WCN_BOOL_FALSE; if (arg & 0x01) { bRet = mtk_wcn_wmt_func_on(WMTDRV_TYPE_LPBK); } else { bRet = mtk_wcn_wmt_func_off(WMTDRV_TYPE_LPBK); } iRet = (MTK_WCN_BOOL_FALSE == bRet) ? -EFAULT : 0; } while (0); break; case WMT_IOCTL_LPBK_TEST: do { P_OSAL_OP pOp; MTK_WCN_BOOL bRet; UINT32 u4Wait; /* UINT8 lpbk_buf[1024] = {0}; */ UINT32 effectiveLen = 0; P_OSAL_SIGNAL pSignal = NULL; if (copy_from_user(&effectiveLen, (void *)arg, sizeof(effectiveLen))) { iRet = -EFAULT; WMT_ERR_FUNC("copy_from_user failed at %d\n", __LINE__); break; } if (effectiveLen > sizeof(gLpbkBuf)) { iRet = -EFAULT; WMT_ERR_FUNC("length is too long\n"); break; } WMT_DBG_FUNC("len = %d\n", effectiveLen); pOp = wmt_lib_get_free_op(); if (!pOp) { WMT_WARN_FUNC("get_free_lxop fail\n"); iRet = -EFAULT; break; } u4Wait = 2000; if (copy_from_user (&gLpbkBuf[0], (void *)arg + sizeof(unsigned long), effectiveLen)) { WMT_ERR_FUNC("copy_from_user failed at %d\n", __LINE__); iRet = -EFAULT; break; } pSignal = &pOp->signal; pOp->op.opId = WMT_OPID_LPBK; pOp->op.au4OpData[0] = effectiveLen; /* packet length */ pOp->op.au4OpData[1] = (size_t) &gLpbkBuf[0]; memcpy(&gLpbkBufLog, &gLpbkBuf[((effectiveLen >= 4) ? effectiveLen - 4 : 0)], 4); pSignal->timeoutValue = MAX_EACH_WMT_CMD; 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 -1; } bRet = wmt_lib_put_act_op(pOp); ENABLE_PSM_MONITOR(); if (MTK_WCN_BOOL_FALSE == bRet) { WMT_WARN_FUNC("OPID(%d) type(%d) buf tail(0x%08x) fail\n", pOp->op.opId, pOp->op.au4OpData[0], gLpbkBufLog); iRet = -1; break; } else { WMT_INFO_FUNC("OPID(%d) length(%d) ok\n", pOp->op.opId, pOp->op.au4OpData[0]); iRet = pOp->op.au4OpData[0]; if (copy_to_user ((void *)arg + sizeof(unsigned long) + sizeof(UINT8[2048]), gLpbkBuf, iRet)) { iRet = -EFAULT; break; } } } while (0); break; #if 0 case 9: { #define LOG_BUF_SZ 300 UINT8 buf[LOG_BUF_SZ]; INT32 len = 0; INT32 remaining = 0; remaining = mtk_wcn_stp_btm_get_dmp(buf, &len); if (remaining == 0) { WMT_DBG_FUNC("waiting dmp\n"); wait_event_interruptible(dmp_wq, dmp_flag != 0); dmp_flag = 0; remaining = mtk_wcn_stp_btm_get_dmp(buf, &len); /* WMT_INFO_FUNC("len = %d ###%s#\n", len, buf); */ } else { WMT_LOUD_FUNC("no waiting dmp\n"); } if (unlikely((len + sizeof(INT32)) >= LOG_BUF_SZ)) { WMT_ERR_FUNC("len is larger buffer\n"); iRet = -EFAULT; goto fail_exit; } buf[sizeof(INT32) + len] = '\0'; if (copy_to_user((void *)arg, (PUINT8)&len, sizeof(INT32))) { iRet = -EFAULT; goto fail_exit; } if (copy_to_user((void *)arg + sizeof(INT32), buf, len)) { iRet = -EFAULT; goto fail_exit; } } break; case 10: { WMT_INFO_FUNC("Enable combo trace32 dump\n"); wmt_cdev_t32dmp_enable(); WMT_INFO_FUNC("Enable STP debugging mode\n"); mtk_wcn_stp_dbg_enable(); } break; case 11: { WMT_INFO_FUNC("Disable combo trace32 dump\n"); wmt_cdev_t32dmp_disable(); WMT_INFO_FUNC("Disable STP debugging mode\n"); mtk_wcn_stp_dbg_disable(); } break; #endif case 10: { wmt_lib_host_awake_get(); mtk_wcn_stp_coredump_start_ctrl(1); osal_strcpy(pBuffer, "MT662x f/w coredump start-"); if (copy_from_user (pBuffer + osal_strlen(pBuffer), (void *)arg, NAME_MAX - osal_strlen(pBuffer))) { /* osal_strcpy(pBuffer, "MT662x f/w assert core dump start"); */ WMT_ERR_FUNC("copy assert string failed\n"); } pBuffer[NAME_MAX] = '\0'; osal_dbg_assert_aee(pBuffer, pBuffer); } break; case 11: { osal_dbg_assert_aee("MT662x f/w coredump end", "MT662x firmware coredump ends"); wmt_lib_host_awake_put(); } break; case WMT_IOCTL_GET_CHIP_INFO: { if (0 == arg) { return wmt_lib_get_icinfo(WMTCHIN_CHIPID); } else if (1 == arg) { return wmt_lib_get_icinfo(WMTCHIN_HWVER); } else if (2 == arg) { return wmt_lib_get_icinfo(WMTCHIN_FWVER); } } break; case WMT_IOCTL_SET_LAUNCHER_KILL:{ if (1 == arg) { WMT_INFO_FUNC("launcher may be killed,block abnormal stp tx.\n"); wmt_lib_set_stp_wmt_last_close(1); } else { wmt_lib_set_stp_wmt_last_close(0); } } break; case WMT_IOCTL_SET_PATCH_NUM:{ pAtchNum = arg; WMT_INFO_FUNC(" get patch num from launcher = %d\n", pAtchNum); wmt_lib_set_patch_num(pAtchNum); if (pAtchNum > 0) pPatchInfo = kzalloc(sizeof(WMT_PATCH_INFO) *pAtchNum, GFP_ATOMIC); else WMT_ERR_FUNC("patch num == 0!\n"); if (!pPatchInfo) { WMT_ERR_FUNC("allocate memory fail!\n"); break; } } break; case WMT_IOCTL_SET_PATCH_INFO:{ WMT_PATCH_INFO wMtPatchInfo; P_WMT_PATCH_INFO pTemp = NULL; UINT32 dWloadSeq; static UINT32 counter = 0; if (!pPatchInfo) { WMT_ERR_FUNC("NULL patch info pointer\n"); break; } if (copy_from_user(&wMtPatchInfo, (void *)arg, sizeof(WMT_PATCH_INFO))) { WMT_ERR_FUNC("copy_from_user failed at %d\n", __LINE__); iRet = -EFAULT; break; } dWloadSeq = wMtPatchInfo.dowloadSeq; WMT_DBG_FUNC ("current download seq no is %d,patch name is %s,addres info is 0x%02x,0x%02x,0x%02x,0x%02x\n", dWloadSeq, wMtPatchInfo.patchName, wMtPatchInfo.addRess[0], wMtPatchInfo.addRess[1], wMtPatchInfo.addRess[2], wMtPatchInfo.addRess[3]); osal_memcpy(pPatchInfo + dWloadSeq - 1, &wMtPatchInfo, sizeof(WMT_PATCH_INFO)); pTemp = pPatchInfo + dWloadSeq - 1; if (++counter == pAtchNum) { wmt_lib_set_patch_info(pPatchInfo); counter = 0; } } break; case WMT_IOCTL_PORT_NAME:{ INT8 cUartName[NAME_MAX + 1]; if (copy_from_user(cUartName, (void *)arg, NAME_MAX)) { iRet = -EFAULT; break; } cUartName[NAME_MAX] = '\0'; wmt_lib_set_uart_name(cUartName); } break; case WMT_IOCTL_WMT_CFG_NAME: { INT8 cWmtCfgName[NAME_MAX + 1]; if (copy_from_user(cWmtCfgName, (void *)arg, NAME_MAX)) { iRet = -EFAULT; break; } cWmtCfgName[NAME_MAX] = '\0'; wmt_conf_set_cfg_file(cWmtCfgName); } break; case WMT_IOCTL_WMT_QUERY_CHIPID: { #if !(DELETE_HIF_SDIO_CHRDEV) iRet = mtk_wcn_hif_sdio_query_chipid(1); #else iRet = mtk_wcn_wmt_chipid_query(); #endif } break; case WMT_IOCTL_WMT_TELL_CHIPID: { #if !(DELETE_HIF_SDIO_CHRDEV) iRet = mtk_wcn_hif_sdio_tell_chipid(arg); #endif if (0x6628 == arg || 0x6630 == arg) { wmt_lib_merge_if_flag_ctrl(1); } else { wmt_lib_merge_if_flag_ctrl(0); } } break; case WMT_IOCTL_WMT_COREDUMP_CTRL: { if (0 == arg) { mtk_wcn_stp_coredump_flag_ctrl(0); } else { mtk_wcn_stp_coredump_flag_ctrl(1); } } break; case WMT_IOCTL_WMT_STP_ASSERT_CTRL: if (MTK_WCN_BOOL_TRUE == wmt_lib_btm_cb(BTM_TRIGGER_STP_ASSERT_OP)) { WMT_INFO_FUNC("trigger stp assert succeed\n"); iRet = 0; } else { WMT_INFO_FUNC("trigger stp assert failed\n"); iRet = -1; } break; default: iRet = -EINVAL; WMT_WARN_FUNC("unknown cmd (%d)\n", cmd); break; } return iRet; }
INT32 wmt_dev_tm_temp_query(VOID) { #define HISTORY_NUM 5 #define TEMP_THRESHOLD 65 #define REFRESH_TIME 300 /* sec */ static INT32 temp_table[HISTORY_NUM] = { 99 }; /* not query yet. */ static INT32 idx_temp_table; static struct timeval query_time, now_time; INT8 query_cond = 0; INT8 ctemp = 0; INT32 current_temp = 0; INT32 index = 0; MTK_WCN_BOOL bRet = MTK_WCN_BOOL_FALSE; /* Query condition 1: */ /* If we have the high temperature records on the past, we continue to query/monitor */ /* the real temperature until cooling */ for (index = 0; index < HISTORY_NUM; index++) { if (temp_table[index] >= TEMP_THRESHOLD) { query_cond = 1; WMT_INFO_FUNC ("high temperature (current temp = %d), we must keep querying temp temperature..\n", temp_table[index]); } } do_gettimeofday(&now_time); #if 1 /* Query condition 2: */ /* Moniter the hif_sdio activity to decide if we have the need to query temperature. */ if (!query_cond) { if (wmt_dev_tra_sdio_poll() == 0) { query_cond = 1; WMT_DBG_FUNC("sdio traffic , we must query temperature..\n"); } else { WMT_DBG_FUNC("sdio idle traffic ....\n"); } /* only WIFI tx power might make temperature varies largely */ #if 0 if (!query_cond) { last_access_time = wmt_dev_tra_uart_poll(); if (jiffies_to_msecs(last_access_time) < TIME_THRESHOLD_TO_TEMP_QUERY) { query_cond = 1; WMT_DBG_FUNC("uart busy traffic , we must query temperature..\n"); } else { WMT_DBG_FUNC ("uart still idle traffic , we don't query temp temperature..\n"); } } #endif } #endif /* Query condition 3: */ /* If the query time exceeds the a certain of period, refresh temp table. */ /* */ if (!query_cond) { if ((now_time.tv_sec < query_time.tv_sec) || /* time overflow, we refresh temp table again for simplicity! */ ((now_time.tv_sec > query_time.tv_sec) && (now_time.tv_sec - query_time.tv_sec) > REFRESH_TIME)) { query_cond = 1; WMT_INFO_FUNC ("It is long time (> %d sec) not to query, we must query temp temperature..\n", REFRESH_TIME); for (index = 0; index < HISTORY_NUM; index++) { temp_table[index] = 99; } } } if (query_cond) { /* update the temperature record */ bRet = mtk_wcn_wmt_therm_ctrl(WMTTHERM_ENABLE); if (bRet == MTK_WCN_BOOL_TRUE) { ctemp = mtk_wcn_wmt_therm_ctrl(WMTTHERM_READ); bRet = mtk_wcn_wmt_therm_ctrl(WMTTHERM_DISABLE); if(bRet == MTK_WCN_BOOL_TRUE) wmt_lib_notify_stp_sleep(); if (0 != (ctemp & 0x80)) { ctemp &= 0x7f; current_temp = ~((INT32)ctemp - 1); } else current_temp = ctemp; } else { current_temp = -1; if (MTK_WCN_BOOL_TRUE == wmt_lib_is_therm_ctrl_support()) WMT_WARN_FUNC("thermal function enable command failed, set current_temp = 0x%x \n", current_temp); } idx_temp_table = (idx_temp_table + 1) % HISTORY_NUM; temp_table[idx_temp_table] = current_temp; do_gettimeofday(&query_time); WMT_DBG_FUNC("[Thermal] current_temp = 0x%x \n", current_temp); } else { current_temp = temp_table[idx_temp_table]; idx_temp_table = (idx_temp_table + 1) % HISTORY_NUM; temp_table[idx_temp_table] = current_temp; } /* */ /* Dump information */ /* */ WMT_DBG_FUNC("[Thermal] idx_temp_table = %d\n", idx_temp_table); WMT_DBG_FUNC("[Thermal] now.time = %ld, query.time = %ld, REFRESH_TIME = %d\n", now_time.tv_sec, query_time.tv_sec, REFRESH_TIME); WMT_DBG_FUNC("[0] = %d, [1] = %d, [2] = %d, [3] = %d, [4] = %d\n----\n", temp_table[0], temp_table[1], temp_table[2], temp_table[3], temp_table[4]); return current_temp; }
INT32 wmt_plat_eirq_ctrl(ENUM_PIN_ID id, ENUM_PIN_STATE state) { INT32 iRet; unsigned int flags; /* TODO: [ChangeFeature][GeorgeKuo]: use another function to handle this, as done in gpio_ctrls */ if ((PIN_STA_INIT != state) && (PIN_STA_DEINIT != state) && (PIN_STA_EINT_EN != state) && (PIN_STA_EINT_DIS != state)) { iRet = -1; WMT_WARN_FUNC ("WMT-PLAT:invalid PIN_STATE(%d) in eirq_ctrl for PIN(%d), ret(%d) \n", state, id, iRet); return iRet; } iRet = -2; switch (id) { case PIN_BGF_EINT: if (PIN_STA_INIT == state) { /*request irq,low level triggered*/ iRet = request_irq(INT_6620, irq_handler, IRQF_TRIGGER_LOW | IRQF_DISABLED, "MTK6620_BT", NULL); g_balance_flag = 1; /* do not modify this value */ WMT_INFO_FUNC("WMT-PLAT:BGFInt (init) \n"); } else if (PIN_STA_EINT_EN == state) { /*enable irq*/ spin_lock_irqsave(&g_balance_lock, flags); if (g_balance_flag) { /*if enter this case, the bgf eint has been enabled,so skip it.*/ WMT_INFO_FUNC ("BGF_EINT has been enabled,g_balance_flag(%d)!\n", g_balance_flag); } else { /*do real irq enable implement is this case*/ enable_irq(INT_6620); g_balance_flag++; WMT_INFO_FUNC ("WMT-PLAT:BGFInt (en),g_balance_flag(%d)\n", g_balance_flag); } spin_unlock_irqrestore(&g_balance_lock, flags); } else if (PIN_STA_EINT_DIS == state) { /*disable irq*/ spin_lock_irqsave(&g_balance_lock, flags); if (!g_balance_flag) { /*if enter this case, the bgf eint has been disabled,so skip it.*/ WMT_INFO_FUNC ("BGF_EINT has been disabled,g_balance_flag(%d)!\n", g_balance_flag); } else { /*do real irq disable implement is this case*/ disable_irq_nosync(INT_6620); g_balance_flag--; WMT_INFO_FUNC ("WMT-PLAT:BGFInt (dis) g_balance_flag(%d)\n", g_balance_flag); } spin_unlock_irqrestore(&g_balance_lock, flags); } else { /* de-init: free irq*/ free_irq(INT_6620, NULL); WMT_INFO_FUNC("WMT-PLAT:BGFInt (deinit) \n"); } iRet = 0; break; case PIN_ALL_EINT: #if 0 if (PIN_STA_INIT == state) { WMT_DBG_FUNC ("WMT-PLAT:ALLInt (INIT but not used yet) \n"); } else if (PIN_STA_EINT_EN == state) { WMT_DBG_FUNC ("WMT-PLAT:ALLInt (EN but not used yet) \n"); } else if (PIN_STA_EINT_DIS == state) { WMT_DBG_FUNC ("WMT-PLAT:ALLInt (DIS but not used yet) \n"); } else { WMT_DBG_FUNC ("WMT-PLAT:ALLInt (DEINIT but not used yet) \n"); /* de-init: nothing to do in ALPS, such as un-registration... */ } #else WMT_DBG_FUNC("WMT-PLAT:ALLInt (not used yet) \n"); #endif iRet = 0; break; default: WMT_WARN_FUNC ("WMT-PLAT:unsupported EIRQ(PIN_ID:%d) in eirq_ctrl, ret (%d)\n", id, iRet); iRet = -1; break; } return iRet; }
//INT32 WMT_ioctl(struct inode *inode, struct file *filp, UINT32 cmd, unsigned long arg) long WMT_unlocked_ioctl ( struct file *filp, unsigned int cmd, unsigned long arg ) { INT32 iRet = 0; UCHAR pBuffer[NAME_MAX + 1]; WMT_DBG_FUNC("cmd (%u), arg (0x%lx)\n", cmd, arg); switch(cmd) { case 4: /* patch location */ { #if 0 WMT_DBG_FUNC("old patch file: %s \n", pWmtDevCtx->cPatchName); if (copy_from_user(pWmtDevCtx->cPatchName, (void *)arg, NAME_MAX)) { iRet = -EFAULT; break; } pWmtDevCtx->cPatchName[NAME_MAX] = '\0'; WMT_DBG_FUNC("new patch file name: %s \n", pWmtDevCtx->cPatchName); #endif UCHAR cPatchName[NAME_MAX + 1]; if (copy_from_user(cPatchName, (void *)arg, NAME_MAX)) { iRet = -EFAULT; break; } cPatchName[NAME_MAX] = '\0'; wmt_lib_set_patch_name(cPatchName); } break; case 5: /* stp/hif/fm mode */ /* set hif conf */ do { P_OSAL_OP pOp; MTK_WCN_BOOL bRet; P_OSAL_SIGNAL pSignal = NULL; P_WMT_HIF_CONF pHif = NULL; iRet = wmt_lib_set_hif(arg); if (0 != iRet) { WMT_INFO_FUNC("wmt_lib_set_hif fail\n"); break; } pOp = wmt_lib_get_free_op(); if (!pOp) { WMT_INFO_FUNC("get_free_lxop fail\n"); break; } pSignal = &pOp->signal; pOp->op.opId = WMT_OPID_HIF_CONF; pHif = wmt_lib_get_hif(); osal_memcpy(&pOp->op.au4OpData[0], pHif, sizeof(WMT_HIF_CONF)); pOp->op.u4InfoBit = WMT_OP_HIF_BIT; pSignal->timeoutValue = 0; bRet = wmt_lib_put_act_op(pOp); WMT_DBG_FUNC("WMT_OPID_HIF_CONF result(%d) \n", bRet); iRet = (MTK_WCN_BOOL_FALSE == bRet) ? -EFAULT : 0; } while (0); break; case 6: /* test turn on/off func */ do { MTK_WCN_BOOL bRet = MTK_WCN_BOOL_FALSE; if (arg & 0x80000000) { bRet = mtk_wcn_wmt_func_on(arg & 0xF); } else { bRet = mtk_wcn_wmt_func_off(arg & 0xF); } iRet = (MTK_WCN_BOOL_FALSE == bRet) ? -EFAULT : 0; } while (0); break; case 7: /*switch Loopback function on/off arg: bit0 = 1:turn loopback function on bit0 = 0:turn loopback function off */ do{ MTK_WCN_BOOL bRet = MTK_WCN_BOOL_FALSE; if (arg & 0x01) { bRet = mtk_wcn_wmt_func_on(WMTDRV_TYPE_LPBK); } else { bRet = mtk_wcn_wmt_func_off(WMTDRV_TYPE_LPBK); } iRet = (MTK_WCN_BOOL_FALSE == bRet) ? -EFAULT : 0; }while(0); break; case 8: do { P_OSAL_OP pOp; MTK_WCN_BOOL bRet; UINT32 u4Wait; //UINT8 lpbk_buf[1024] = {0}; UINT32 effectiveLen = 0; P_OSAL_SIGNAL pSignal = NULL; if (copy_from_user(&effectiveLen, (void *)arg, sizeof(effectiveLen))) { iRet = -EFAULT; WMT_ERR_FUNC("copy_from_user failed at %d\n", __LINE__); break; } if(effectiveLen > sizeof(gLpbkBuf)) { iRet = -EFAULT; WMT_ERR_FUNC("length is too long\n"); break; } WMT_DBG_FUNC("len = %d\n", effectiveLen); pOp = wmt_lib_get_free_op(); if (!pOp) { WMT_WARN_FUNC("get_free_lxop fail \n"); iRet = -EFAULT; break; } u4Wait = 2000; if (copy_from_user(&gLpbkBuf[0], (void *)arg + sizeof(unsigned long), effectiveLen)) { WMT_ERR_FUNC("copy_from_user failed at %d\n", __LINE__); iRet = -EFAULT; break; } pSignal = &pOp->signal; pOp->op.opId = WMT_OPID_LPBK; pOp->op.au4OpData[0] = effectiveLen; //packet length pOp->op.au4OpData[1] = (UINT32)&gLpbkBuf[0]; //packet buffer pointer memcpy(&gLpbkBufLog, &gLpbkBuf[((effectiveLen >=4) ? effectiveLen-4:0)], 4); pSignal->timeoutValue = MAX_EACH_WMT_CMD; WMT_INFO_FUNC("OPID(%d) type(%d) start\n", pOp->op.opId, pOp->op.au4OpData[0]); DISABLE_PSM_MONITOR(); bRet = wmt_lib_put_act_op(pOp); ENABLE_PSM_MONITOR(); if (MTK_WCN_BOOL_FALSE == bRet) { WMT_WARN_FUNC("OPID(%d) type(%d) buf tail(0x%08x) fail\n", pOp->op.opId, pOp->op.au4OpData[0], gLpbkBufLog); iRet = -1; break; } else { WMT_INFO_FUNC("OPID(%d) length(%d) ok\n", pOp->op.opId, pOp->op.au4OpData[0]); iRet = pOp->op.au4OpData[0] ; if (copy_to_user((void *)arg + sizeof(ULONG) + sizeof(UCHAR[2048]), gLpbkBuf, iRet)) { iRet = -EFAULT; break; } } }while(0); break; #if 0 case 9: { #define LOG_BUF_SZ 300 UCHAR buf[LOG_BUF_SZ]; INT32 len = 0; INT32 remaining = 0; remaining = mtk_wcn_stp_btm_get_dmp(buf, &len); if(remaining == 0){ WMT_DBG_FUNC("waiting dmp \n"); wait_event_interruptible(dmp_wq, dmp_flag != 0); dmp_flag = 0; remaining = mtk_wcn_stp_btm_get_dmp(buf, &len); //WMT_INFO_FUNC("len = %d ###%s#\n", len, buf); } else { WMT_LOUD_FUNC("no waiting dmp \n"); } if(unlikely((len+sizeof(INT32)) >= LOG_BUF_SZ)){ WMT_ERR_FUNC("len is larger buffer\n"); iRet = -EFAULT; goto fail_exit; } buf[sizeof(INT32)+len]='\0'; if (copy_to_user((void *)arg, (UCHAR *)&len, sizeof(INT32))){ iRet = -EFAULT; goto fail_exit; } if (copy_to_user((void *)arg + sizeof(INT32), buf, len)){ iRet = -EFAULT; goto fail_exit; } } break; case 10: { WMT_INFO_FUNC("Enable combo trace32 dump\n"); wmt_cdev_t32dmp_enable(); WMT_INFO_FUNC("Enable STP debugging mode\n"); mtk_wcn_stp_dbg_enable(); } break; case 11: { WMT_INFO_FUNC("Disable combo trace32 dump\n"); wmt_cdev_t32dmp_disable(); WMT_INFO_FUNC("Disable STP debugging mode\n"); mtk_wcn_stp_dbg_disable(); } break; #endif case 10: { wmt_lib_host_awake_get(); #if 0 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 = WMT_OPID_FUNC_ON; pOp->op.au4OpData[0] = WMTDRV_TYPE_COREDUMP; pSignal->timeoutValue= 0; 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*/ /*wake up chip first*/ DISABLE_PSM_MONITOR(); 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]); } #endif osal_strcpy(pBuffer, "MT662x f/w coredump start-"); if (copy_from_user(pBuffer + osal_strlen(pBuffer), (void *)arg, NAME_MAX)) { //osal_strcpy(pBuffer, "MT662x f/w assert core dump start"); WMT_ERR_FUNC("copy assert string failed\n"); } pBuffer[NAME_MAX] = '\0'; osal_dbg_assert_aee(pBuffer, pBuffer); } break; case 11: { osal_dbg_assert_aee("MT662x f/w coredump end", "MT662x firmware coredump ends"); wmt_lib_host_awake_put(); } break; case 12: { if (0 == arg) { return wmt_lib_get_icinfo(WMTCHIN_CHIPID); } else if (1 == arg) { return wmt_lib_get_icinfo(WMTCHIN_HWVER); } else if (2 == arg) { return wmt_lib_get_icinfo(WMTCHIN_FWVER); } } break; case 13: { if (1 == arg) { WMT_INFO_FUNC("launcher may be killed,block abnormal stp tx. \n"); wmt_lib_set_stp_wmt_last_close(1); } else { wmt_lib_set_stp_wmt_last_close(0); } } break; #ifdef MTK_MULTI_PATCH_SUPPORT case 14: { pAtchNum = arg; WMT_DBG_FUNC(" get patch num from launcher = %d\n",pAtchNum); wmt_lib_set_patch_num(pAtchNum); pPatchInfo = kzalloc(sizeof(WMT_PATCH_INFO)*pAtchNum,GFP_ATOMIC); if(!pPatchInfo) { WMT_ERR_FUNC("allocate memory fail!\n"); break; } } break; case 15: { WMT_PATCH_INFO wMtPatchInfo; P_WMT_PATCH_INFO pTemp = NULL; UINT32 dWloadSeq; static UINT32 counter = 0; if(!pPatchInfo) { WMT_ERR_FUNC("NULL patch info pointer\n"); break; } if (copy_from_user(&wMtPatchInfo, (void *)arg, sizeof(WMT_PATCH_INFO))) { WMT_ERR_FUNC("copy_from_user failed at %d\n", __LINE__); iRet = -EFAULT; break; } dWloadSeq = wMtPatchInfo.dowloadSeq; WMT_DBG_FUNC("current download seq no is %d,patch name is %s,addres info is 0x%02x,0x%02x,0x%02x,0x%02x\n",dWloadSeq,wMtPatchInfo.patchName,wMtPatchInfo.addRess[0],wMtPatchInfo.addRess[1],wMtPatchInfo.addRess[2],wMtPatchInfo.addRess[3]); osal_memcpy(pPatchInfo + dWloadSeq - 1,&wMtPatchInfo,sizeof(WMT_PATCH_INFO)); pTemp = pPatchInfo + dWloadSeq - 1; if(++counter == pAtchNum) { wmt_lib_set_patch_info(pPatchInfo); counter = 0; } } break; #endif default: iRet = -EINVAL; WMT_WARN_FUNC("unknown cmd (%d)\n", cmd); break; } return iRet; }
static INT32 wmt_conf_parse(P_DEV_WMT pWmtDev, const PINT8 pInBuf, UINT32 size) { PINT8 pch; PINT8 pBuf; PINT8 pLine; PINT8 pKey; PINT8 pVal; PINT8 pPos; INT32 ret = 0; INT32 i = 0; PINT8 pa = NULL; pBuf = osal_malloc(size); if (!pBuf) return -1; osal_memcpy(pBuf, pInBuf, size); pBuf[size] = '\0'; pch = pBuf; /* pch is to be updated by strsep(). Keep pBuf unchanged!! */ #if 0 { PINT8 buf_ptr = pBuf; INT32 k = 0; WMT_INFO_FUNC("%s len=%d", "wmcfg.content:", size); for (k = 0; k < size; k++) { /* if(k%16 == 0) WMT_INFO_FUNC("\n"); */ WMT_INFO_FUNC("%c", buf_ptr[k]); } WMT_INFO_FUNC("--end\n"); } #endif while ((pLine = osal_strsep(&pch, "\r\n")) != NULL) { /* pch is updated to the end of pLine by strsep() and updated to '\0' */ /*WMT_INFO_FUNC("strsep offset(%d), char(%d, '%c' )\n", pLine-pBuf, *pLine, *pLine); */ /* parse each line */ /* WMT_INFO_FUNC("==> Line = (%s)\n", pLine); */ if (!*pLine) continue; pVal = osal_strchr(pLine, '='); if (!pVal) { WMT_WARN_FUNC("mal-format cfg string(%s)\n", pLine); continue; } /* |<-pLine->|'='<-pVal->|'\n' ('\0')| */ *pVal = '\0'; /* replace '=' with '\0' to get key */ /* |<-pKey->|'\0'|<-pVal->|'\n' ('\0')| */ pKey = pLine; if ((pVal - pBuf) < size) pVal++; /*key handling */ pPos = pKey; /*skip space characeter */ while (((*pPos) == ' ') || ((*pPos) == '\t') || ((*pPos) == '\n')) { if ((pPos - pBuf) >= size) break; pPos++; } /*key head */ pKey = pPos; while (((*pPos) != ' ') && ((*pPos) != '\t') && ((*pPos) != '\0') && ((*pPos) != '\n')) { if ((pPos - pBuf) >= size) break; pPos++; } /*key tail */ (*pPos) = '\0'; /*value handling */ pPos = pVal; /*skip space characeter */ while (((*pPos) == ' ') || ((*pPos) == '\t') || ((*pPos) == '\n')) { if ((pPos - pBuf) >= size) break; pPos++; } /*value head */ pVal = pPos; while (((*pPos) != ' ') && ((*pPos) != '\t') && ((*pPos) != '\0') && ((*pPos) != '\n')) { if ((pPos - pBuf) >= size) break; pPos++; } /*value tail */ (*pPos) = '\0'; /* WMT_DBG_FUNC("parse (key: #%s#, value: #%s#)\n", pKey, pVal); */ ret = wmt_conf_parse_pair(pWmtDev, pKey, pVal); WMT_WARN_FUNC("parse (%s, %s, %d)\n", pKey, pVal, ret); if (ret) WMT_WARN_FUNC("parse fail (%s, %s, %d)\n", pKey, pVal, ret); } for (i = 0; i < NUM_WMTCFG_FIELDS; i++) { const struct parse_data *field = &wmtcfg_fields[i]; pa = field->writer(pWmtDev, field); if (pa) { WMT_DBG_FUNC("#%d(%s)=>%s\n", i, field->name, pa); osal_free(pa); } else { WMT_ERR_FUNC("failed to parse '%s'.\n", field->name); } } osal_free(pBuf); return 0; }
static INT32 wmt_dev_tm_temp_query(void) { #define HISTORY_NUM 5 #define TEMP_THRESHOLD 65 #define REFRESH_TIME 300 //sec static INT32 temp_table[HISTORY_NUM] = {99}; //not query yet. static INT32 idx_temp_table = 0; static struct timeval query_time, now_time; INT8 query_cond = 0; INT32 current_temp = 0; INT32 index = 0; //Query condition 1: // If we have the high temperature records on the past, we continue to query/monitor // the real temperature until cooling for(index = 0; index < HISTORY_NUM ; index++) { if(temp_table[index] >= TEMP_THRESHOLD) { query_cond = 1; WMT_INFO_FUNC("high temperature (current temp = %d), we must keep querying temp temperature..\n", temp_table[index]); } } do_gettimeofday(&now_time); // Query condition 2: // Moniter the hif_sdio activity to decide if we have the need to query temperature. if(!query_cond) { if( wmt_dev_tra_sdio_poll()==0) { query_cond = 1; WMT_INFO_FUNC("sdio traffic , we must query temperature..\n"); } else { WMT_DBG_FUNC("sdio idle traffic ....\n"); } //only WIFI tx power might make temperature varies largely #if 0 if(!query_cond) { last_access_time = wmt_dev_tra_uart_poll(); if( jiffies_to_msecs(last_access_time) < TIME_THRESHOLD_TO_TEMP_QUERY) { query_cond = 1; WMT_DBG_FUNC("uart busy traffic , we must query temperature..\n"); } else { WMT_DBG_FUNC("uart still idle traffic , we don't query temp temperature..\n"); } } #endif } // Query condition 3: // If the query time exceeds the a certain of period, refresh temp table. // if(!query_cond) { if( (now_time.tv_sec < query_time.tv_sec) || //time overflow, we refresh temp table again for simplicity! ((now_time.tv_sec > query_time.tv_sec) && (now_time.tv_sec - query_time.tv_sec) > REFRESH_TIME)) { query_cond = 1; WMT_INFO_FUNC("It is long time (> %d sec) not to query, we must query temp temperature..\n", REFRESH_TIME); for (index = 0; index < HISTORY_NUM ; index++) { temp_table[index] = 99; } } } if(query_cond) { // update the temperature record mtk_wcn_wmt_therm_ctrl(WMTTHERM_ENABLE); current_temp = mtk_wcn_wmt_therm_ctrl(WMTTHERM_READ); mtk_wcn_wmt_therm_ctrl(WMTTHERM_DISABLE); wmt_lib_notify_stp_sleep(); idx_temp_table = (idx_temp_table + 1) % HISTORY_NUM; temp_table[idx_temp_table] = current_temp; do_gettimeofday(&query_time); WMT_INFO_FUNC("[Thermal] current_temp = 0x%x \n", (current_temp & 0xFF)); } else { current_temp = temp_table[idx_temp_table]; idx_temp_table = (idx_temp_table + 1) % HISTORY_NUM; temp_table[idx_temp_table] = current_temp; } // // Dump information // WMT_DBG_FUNC("[Thermal] idx_temp_table = %d \n", idx_temp_table); WMT_DBG_FUNC("[Thermal] now.time = %d, query.time = %d, REFRESH_TIME = %d\n", now_time.tv_sec, query_time.tv_sec, REFRESH_TIME); WMT_DBG_FUNC("[0] = %d, [1] = %d, [2] = %d, [3] = %d, [4] = %d \n----\n", temp_table[0], temp_table[1], temp_table[2], temp_table[3], temp_table[4]); return current_temp; }
INT32 wmt_plat_i2s_ctrl(ENUM_PIN_STATE state) { // TODO: [NewFeature][GeorgeKuo]: GPIO_I2Sx is changed according to different project. // TODO: provide a translation table in board_custom.h for different ALPS project customization. UINT32 normalI2SFlag = 0; /*check if combo chip support merge if or not*/ if (0 != wmt_plat_merge_if_flag_get()) { #if (MTK_WCN_CMB_MERGE_INTERFACE_SUPPORT) //Hardware support Merge IF function #if defined(FM_DIGITAL_INPUT) || defined(FM_DIGITAL_OUTPUT) #if defined (GPIO_COMBO_I2S_CK_PIN) switch(state) { case PIN_STA_INIT: case PIN_STA_MUX: mt_set_gpio_mode(GPIO_COMBO_I2S_CK_PIN, GPIO_COMBO_I2S_CK_PIN_PINMUX_MODE); mt_set_gpio_mode(GPIO_COMBO_I2S_WS_PIN, GPIO_COMBO_I2S_WS_PIN_PINMUX_MODE); mt_set_gpio_mode(GPIO_COMBO_I2S_DAT_PIN, GPIO_COMBO_I2S_DAT_PIN_PINMUX_MODE); mt_set_gpio_mode(GPIO_PCM_DAIPCMOUT_PIN, GPIO_PCM_DAIPCMOUT_PIN_PINMUX_MODE); WMT_DBG_FUNC("WMT-PLAT:<Merge IF>I2S init (I2S0 system) \n"); break; case PIN_STA_IN_L: case PIN_STA_DEINIT: mt_set_gpio_mode(GPIO_COMBO_I2S_CK_PIN, GPIO_COMBO_I2S_CK_PIN_M_GPIO); mt_set_gpio_dir(GPIO_COMBO_I2S_CK_PIN, GPIO_DIR_OUT); mt_set_gpio_out(GPIO_COMBO_I2S_CK_PIN, GPIO_OUT_ZERO); mt_set_gpio_mode(GPIO_COMBO_I2S_WS_PIN, GPIO_COMBO_I2S_WS_PIN_M_GPIO); mt_set_gpio_dir(GPIO_COMBO_I2S_WS_PIN, GPIO_DIR_OUT); mt_set_gpio_out(GPIO_COMBO_I2S_WS_PIN, GPIO_OUT_ZERO); mt_set_gpio_mode(GPIO_COMBO_I2S_DAT_PIN, GPIO_COMBO_I2S_DAT_PIN_M_GPIO); mt_set_gpio_dir(GPIO_COMBO_I2S_DAT_PIN, GPIO_DIR_OUT); mt_set_gpio_out(GPIO_COMBO_I2S_DAT_PIN, GPIO_OUT_ZERO); WMT_DBG_FUNC("WMT-PLAT:<Merge IF>I2S deinit (out 0) \n"); break; default: WMT_WARN_FUNC("WMT-PLAT:<Merge IF>Warnning, invalid state(%d) on I2S Group\n", state); break; } #else WMT_ERR_FUNC( "[MT662x]<Merge IF>Error:FM digital mode set, but no I2S GPIOs defined\n"); #endif #else WMT_INFO_FUNC( "[MT662x]<Merge IF>warnning:FM digital mode is not set, no I2S GPIO settings should be modified by combo driver\n"); #endif #else //Hardware does support Merge IF function normalI2SFlag = 1; #endif } else { normalI2SFlag = 1; } if (0 != normalI2SFlag) { #if defined(FM_DIGITAL_INPUT) || defined(FM_DIGITAL_OUTPUT) #if defined (GPIO_COMBO_I2S_CK_PIN) switch(state) { case PIN_STA_INIT: case PIN_STA_MUX: mt_set_gpio_mode(GPIO_COMBO_I2S_CK_PIN, GPIO_COMBO_I2S_CK_PIN_I2SONLY_MODE); mt_set_gpio_mode(GPIO_COMBO_I2S_WS_PIN, GPIO_COMBO_I2S_WS_PIN_I2SONLY_MODE); mt_set_gpio_mode(GPIO_COMBO_I2S_DAT_PIN, GPIO_COMBO_I2S_DAT_PIN_I2SONLY_MODE); WMT_DBG_FUNC("WMT-PLAT:<I2S IF>I2S init (I2S0 system) \n"); break; case PIN_STA_IN_L: case PIN_STA_DEINIT: mt_set_gpio_mode(GPIO_COMBO_I2S_CK_PIN, GPIO_COMBO_I2S_CK_PIN_M_GPIO); mt_set_gpio_dir(GPIO_COMBO_I2S_CK_PIN, GPIO_DIR_OUT); mt_set_gpio_out(GPIO_COMBO_I2S_CK_PIN, GPIO_OUT_ZERO); mt_set_gpio_mode(GPIO_COMBO_I2S_WS_PIN, GPIO_COMBO_I2S_WS_PIN_M_GPIO); mt_set_gpio_dir(GPIO_COMBO_I2S_WS_PIN, GPIO_DIR_OUT); mt_set_gpio_out(GPIO_COMBO_I2S_WS_PIN, GPIO_OUT_ZERO); mt_set_gpio_mode(GPIO_COMBO_I2S_DAT_PIN, GPIO_COMBO_I2S_DAT_PIN_M_GPIO); mt_set_gpio_dir(GPIO_COMBO_I2S_DAT_PIN, GPIO_DIR_OUT); mt_set_gpio_out(GPIO_COMBO_I2S_DAT_PIN, GPIO_OUT_ZERO); WMT_DBG_FUNC("WMT-PLAT:<I2S IF>I2S deinit (out 0) \n"); break; default: WMT_WARN_FUNC("WMT-PLAT:<I2S IF>Warnning, invalid state(%d) on I2S Group\n", state); break; } #else WMT_ERR_FUNC( "[MT662x]<I2S IF>Error:FM digital mode set, but no I2S GPIOs defined\n"); #endif #else WMT_INFO_FUNC( "[MT662x]<I2S IF>warnning:FM digital mode is not set, no I2S GPIO settings should be modified by combo driver\n"); #endif } return 0; }
INT32 wmt_ctrl_rx(P_WMT_CTRL_DATA pWmtCtrlData/*UINT8 *pBuff, UINT32 buffLen, UINT32 *readSize*/) { P_DEV_WMT pDev = &gDevWmt; /* single instance */ INT32 readLen; LONG waitRet = -1; UINT8 *pBuff = (UINT8 *)pWmtCtrlData->au4CtrlData[0]; UINT32 buffLen = pWmtCtrlData->au4CtrlData[1]; UINT32 *readSize = (UINT32 *)pWmtCtrlData->au4CtrlData[2]; if (readSize) { *readSize = 0; } /* sanity check */ if (!buffLen ) { WMT_WARN_FUNC("buffLen = 0\n"); osal_assert(buffLen); return 0; } #if 0 if (!pDev) { WMT_WARN_FUNC("gpDevWmt = NULL\n"); osal_assert(pDev); return -1; } #endif if (!osal_test_bit(WMT_STAT_STP_OPEN, &pDev->state)) { WMT_WARN_FUNC("state(0x%lx) \n", pDev->state); osal_assert(osal_test_bit(WMT_STAT_STP_OPEN, &pDev->state)); return -2; } /* sanity ok, proceeding rx operation */ /* read_len = mtk_wcn_stp_receive_data(data, size, WMT_TASK_INDX); */ readLen = mtk_wcn_stp_receive_data(pBuff, buffLen, WMT_TASK_INDX); while (readLen == 0) { // got nothing, wait for STP's signal WMT_LOUD_FUNC("before wmt_dev_rx_timeout\n"); //iRet = wait_event_interruptible(pdev->rWmtRxWq, osal_test_bit(WMT_STAT_RX, &pdev->state)); //waitRet = wait_event_interruptible_timeout(pDev->rWmtRxWq, osal_test_bit(WMT_STAT_RX, &pdev->state), msecs_to_jiffies(WMT_LIB_RX_TIMEOUT)); pDev->rWmtRxWq.timeoutValue = WMT_LIB_RX_TIMEOUT; //waitRet = osal_wait_for_event_bit_timeout(&pDev->rWmtRxWq, &pDev->state, WMT_STAT_RX); waitRet = wmt_dev_rx_timeout(&pDev->rWmtRxWq); WMT_LOUD_FUNC("wmt_dev_rx_timeout returned\n"); if (0 == waitRet) { WMT_ERR_FUNC("wmt_dev_rx_timeout: timeout,jiffies(%lu),timeoutvalue(%d) \n", jiffies,pDev->rWmtRxWq.timeoutValue); return -1; } else if (waitRet < 0) { WMT_WARN_FUNC("wmt_dev_rx_timeout: interrupted by signal (%ld)\n", waitRet); return waitRet; } WMT_DBG_FUNC("wmt_dev_rx_timeout, iRet(%ld)\n", waitRet); /* read_len = mtk_wcn_stp_receive_data(data, size, WMT_TASK_INDX); */ readLen = mtk_wcn_stp_receive_data(pBuff, buffLen, WMT_TASK_INDX); if (0 == readLen) { WMT_WARN_FUNC("wmt_ctrl_rx be signaled, but no rx data(%ld)\n", waitRet); } WMT_DBG_FUNC("readLen(%d) \n", readLen); } if (readSize) { *readSize = readLen ; } return 0; }
INT32 wmt_plat_sdio_pin_ctrl ( ENUM_PIN_STATE state ) { #if 0 switch (state) { case PIN_STA_INIT: case PIN_STA_MUX: #if defined(CONFIG_MTK_WCN_CMB_SDIO_SLOT) #if (CONFIG_MTK_WCN_CMB_SDIO_SLOT == 1) // TODO: [FixMe][GeorgeKuo]: below are used for MT6573 only! Find a better way to do ALPS customization for different platform. //WMT_INFO_FUNC( "[mt662x] pull up sd1 bus(gpio62~68)\n"); mt_set_gpio_pull_enable(GPIO62, GPIO_PULL_ENABLE); mt_set_gpio_pull_select(GPIO62, GPIO_PULL_UP); mt_set_gpio_pull_enable(GPIO63, GPIO_PULL_ENABLE); mt_set_gpio_pull_select(GPIO63, GPIO_PULL_UP); mt_set_gpio_pull_enable(GPIO64, GPIO_PULL_ENABLE); mt_set_gpio_pull_select(GPIO64, GPIO_PULL_UP); mt_set_gpio_pull_enable(GPIO65, GPIO_PULL_ENABLE); mt_set_gpio_pull_select(GPIO65, GPIO_PULL_UP); mt_set_gpio_pull_enable(GPIO66, GPIO_PULL_ENABLE); mt_set_gpio_pull_select(GPIO66, GPIO_PULL_UP); mt_set_gpio_pull_enable(GPIO67, GPIO_PULL_ENABLE); mt_set_gpio_pull_select(GPIO67, GPIO_PULL_UP); mt_set_gpio_pull_enable(GPIO68, GPIO_PULL_ENABLE); mt_set_gpio_pull_select(GPIO68, GPIO_PULL_UP); WMT_DBG_FUNC("WMT-PLAT:SDIO init (pu) \n"); #elif (CONFIG_MTK_WCN_CMB_SDIO_SLOT == 2) #error "fix sdio2 gpio settings" #endif #else #error "CONFIG_MTK_WCN_CMB_SDIO_SLOT undefined!!!" #endif break; case PIN_STA_DEINIT: #if defined(CONFIG_MTK_WCN_CMB_SDIO_SLOT) #if (CONFIG_MTK_WCN_CMB_SDIO_SLOT == 1) // TODO: [FixMe][GeorgeKuo]: below are used for MT6573 only! Find a better way to do ALPS customization for different platform. //WMT_INFO_FUNC( "[mt662x] pull down sd1 bus(gpio62~68)\n"); mt_set_gpio_pull_select(GPIO62, GPIO_PULL_DOWN); mt_set_gpio_pull_enable(GPIO62, GPIO_PULL_ENABLE); mt_set_gpio_pull_select(GPIO63, GPIO_PULL_DOWN); mt_set_gpio_pull_enable(GPIO63, GPIO_PULL_ENABLE); mt_set_gpio_pull_select(GPIO64, GPIO_PULL_DOWN); mt_set_gpio_pull_enable(GPIO64, GPIO_PULL_ENABLE); mt_set_gpio_pull_select(GPIO65, GPIO_PULL_DOWN); mt_set_gpio_pull_enable(GPIO65, GPIO_PULL_ENABLE); mt_set_gpio_pull_select(GPIO66, GPIO_PULL_DOWN); mt_set_gpio_pull_enable(GPIO66, GPIO_PULL_ENABLE); mt_set_gpio_pull_select(GPIO67, GPIO_PULL_DOWN); mt_set_gpio_pull_enable(GPIO67, GPIO_PULL_ENABLE); mt_set_gpio_pull_select(GPIO68, GPIO_PULL_DOWN); mt_set_gpio_pull_enable(GPIO68, GPIO_PULL_ENABLE); WMT_DBG_FUNC("WMT-PLAT:SDIO deinit (pd) \n"); #elif (CONFIG_MTK_WCN_CMB_SDIO_SLOT == 2) #error "fix sdio2 gpio settings" #endif #else #error "CONFIG_MTK_WCN_CMB_SDIO_SLOT undefined!!!" #endif break; default: WMT_WARN_FUNC("WMT-PLAT:Warnning, invalid state(%d) on SDIO Group\n", state); break; } #endif return 0; }
UINT32 wmt_idc_msg_to_lte_handing_for_test(UINT8 *p_buf, UINT32 len) { UINT32 readlen = len; local_para_struct *p_lps = NULL; UINT8 *p_data = NULL; UINT8 opcode = 0; UINT16 msg_len = 0; UINT32 handle_len = 0; MTK_WCN_BOOL unknow_msgid = MTK_WCN_BOOL_FALSE; osal_memcpy(&gWmtIdcInfo.buffer[0], p_buf, len); if (readlen > 0) { WMT_DBG_FUNC("read data len from fw(%d)\n", readlen); p_data = &gWmtIdcInfo.buffer[0]; while (handle_len < readlen) { p_data += 2; /*omit direction & opcode 2 bytes */ osal_memcpy(&msg_len, p_data, 2); msg_len -= 1; /*flag byte */ WMT_DBG_FUNC("current raw data len(%d) from connsys firmware\n", msg_len); p_data += 2; /*length: 2 bytes */ /*how to handle flag(msg type) need to Scott comment */ /************************************************/ if (*p_data == WMT_IDC_RX_OPCODE_DEBUG_MONITOR) /*do not need transfer to LTE */ { p_data += 1; /*flag : 1 byte */ /*need to handle these debug message */ wmt_idc_dump_debug_msg("WIFI DEBUG MONITOR", p_data, msg_len); } else /*need to transfer to LTE */ { p_lps = (local_para_struct *) osal_malloc(osal_sizeof(local_para_struct) + osal_sizeof(UINT8) * msg_len); if (NULL == p_lps) { WMT_ERR_FUNC("allocate local_para_struct memory fail\n"); return -1; } p_lps->msg_len = msg_len + osal_sizeof(local_para_struct); opcode = *p_data; WMT_DBG_FUNC("current opcode(%d) to LTE\n", opcode); p_data += 1; /*flag : 1 byte */ osal_memcpy(p_lps->data, p_data, msg_len); gWmtIdcInfo.iit.local_para_ptr = p_lps; switch (opcode) { case WMT_IDC_RX_OPCODE_BTWF_DEF_PARA: gWmtIdcInfo.iit.msg_id = IPC_MSG_ID_EL1_WIFIBT_OPER_DEFAULT_PARAM_IND; break; case WMT_IDC_RX_OPCODE_BTWF_CHAN_RAN: gWmtIdcInfo.iit.msg_id = IPC_MSG_ID_EL1_WIFIBT_OPER_FREQ_IND; break; /* case WMT_IDC_RX_OPCODE_TDM_REQ: */ /* gWmtIdcInfo.iit.msg_id = IPC_MSG_ID_EL1_WIFIBT_OPER_FREQ_IND; */ /* break; */ default: unknow_msgid = MTK_WCN_BOOL_TRUE; WMT_ERR_FUNC("unknow opcode(%d) from connsys firmware\n", opcode); break; } if (MTK_WCN_BOOL_FALSE == unknow_msgid) { /*handling flag value in wmt cmd */ mtk_conn_md_bridge_send_msg(&gWmtIdcInfo.iit); } osal_free(p_lps); } p_data += msg_len; /*point to next package header */ handle_len += (msg_len + 5); } } else { WMT_ERR_FUNC("there is no coex data in stp buffer\n"); } osal_memset(&gWmtIdcInfo.buffer[0], 0, LTE_IDC_BUFFER_MAX_SIZE); return handle_len; }
INT32 wmt_plat_eirq_ctrl(ENUM_PIN_ID id, ENUM_PIN_STATE state) { INT32 iret; /* TODO: [ChangeFeature][GeorgeKuo]: use another function to handle this, as done in gpio_ctrls */ if ((PIN_STA_INIT != state) && (PIN_STA_DEINIT != state) && (PIN_STA_EINT_EN != state) && (PIN_STA_EINT_DIS != state)) { WMT_WARN_FUNC("WMT-PLAT:invalid PIN_STATE(%d) in eirq_ctrl for PIN(%d)\n", state, id); return -1; } iret = -2; switch (id) { case PIN_BGF_EINT: #ifdef GPIO_COMBO_BGF_EINT_PIN if (PIN_STA_INIT == state) { #ifdef GPIO_COMBO_BGF_EINT_PIN #if CONFIG_EINT_DEVICE_TREE struct device_node *node; UINT32 ints[2] = {0,0}; INT32 ret = -EINVAL; node = of_find_compatible_node(NULL, NULL, "mediatek, BGF-eint");/*BGF-eint name maybe wrong*/ if(node) { #if CUST_EINT_COMBO_BGF_DEBOUNCE_EN of_property_read_u32_array(node, "debounce", ints, ARRAY_SIZE(ints)); mt_gpio_set_debounce(ints[0], ints[1]); #endif bfg_irq = irq_of_parse_and_map(node, 0); ret = request_irq(bfg_irq, wmt_plat_bgf_eirq_cb, IRQF_TRIGGER_NONE,"BGF-eint", NULL); if(ret) printk(KERN_ERR "BGF EINT IRQ LINE NOT AVAILABLE!!\n"); else printk(KERN_INFO "BGF EINT request_irq sucess!!\n"); } else printk(KERN_ERR "[%s] can't find BGF eint compatible node\n",__func__); #else #if CUST_EINT_COMBO_BGF_DEBOUNCE_EN mt_eint_set_hw_debounce(CUST_EINT_COMBO_BGF_NUM, CUST_EINT_COMBO_BGF_DEBOUNCE_CN); #endif mt_eint_registration(CUST_EINT_COMBO_BGF_NUM, CUST_EINT_COMBO_BGF_TYPE, wmt_plat_bgf_eirq_cb, 0); mt_eint_mask(CUST_EINT_COMBO_BGF_NUM); /*2 */ #endif #endif } else if (PIN_STA_EINT_EN == state) { #if CONFIG_EINT_DEVICE_TREE enable_irq(bfg_irq); #else mt_eint_unmask(CUST_EINT_COMBO_BGF_NUM); #endif WMT_DBG_FUNC("WMT-PLAT:BGFInt (en)\n"); } else if (PIN_STA_EINT_DIS == state) { #if CONFIG_EINT_DEVICE_TREE disable_irq_nosync(bfg_irq); #else mt_eint_mask(CUST_EINT_COMBO_BGF_NUM); #endif WMT_DBG_FUNC("WMT-PLAT:BGFInt (dis)\n"); } else { #if CONFIG_EINT_DEVICE_TREE disable_irq_nosync(bfg_irq); #else mt_eint_mask(CUST_EINT_COMBO_BGF_NUM); #endif WMT_DBG_FUNC("WMT-PLAT:BGFInt (dis) \n"); /* de-init: nothing to do in ALPS, such as un-registration... */ } #else WMT_INFO_FUNC("WMT-PLAT:BGF EINT not defined\n"); #endif iret = 0; break; case PIN_ALL_EINT: #ifdef GPIO_COMBO_ALL_EINT_PIN if (PIN_STA_INIT == state) { #if 0 #if CUST_EINT_COMBO_ALL_DEBOUNCE_EN mt_eint_set_hw_debounce(CUST_EINT_COMBO_ALL_NUM, CUST_EINT_COMBO_ALL_DEBOUNCE_CN); #endif mt_eint_registration(CUST_EINT_COMBO_ALL_NUM, CUST_EINT_COMBO_ALL_TYPE, combo_bgf_eirq_handler, 0); #endif mt_eint_mask(CUST_EINT_COMBO_ALL_NUM); /*2 */ WMT_DBG_FUNC("WMT-PLAT:ALLInt (INIT but not used yet)\n"); } else if (PIN_STA_EINT_EN == state) { /*mt_eint_unmask(CUST_EINT_COMBO_ALL_NUM); */ WMT_DBG_FUNC("WMT-PLAT:ALLInt (EN but not used yet)\n"); } else if (PIN_STA_EINT_DIS == state) { mt_eint_mask(CUST_EINT_COMBO_ALL_NUM); WMT_DBG_FUNC("WMT-PLAT:ALLInt (DIS but not used yet)\n"); } else { mt_eint_mask(CUST_EINT_COMBO_ALL_NUM); WMT_DBG_FUNC("WMT-PLAT:ALLInt (DEINIT but not used yet)\n"); /* de-init: nothing to do in ALPS, such as un-registration... */ } #else WMT_INFO_FUNC("WMT-PLAT:ALL EINT not defined\n"); #endif iret = 0; break; default: WMT_WARN_FUNC("WMT-PLAT:unsupported EIRQ(PIN_ID:%d) in eirq_ctrl\n", id); iret = -1; break; } return iret; }