static int mtk_mdm_enable(void) { #if MTK_TS_PA_THPUT_VIA_CCCI == 1 // Register the data send back function // MD will receive the data by cb //#ifdef CONFIG_MTK_ENABLE_MD1 if (get_modem_is_enabled(0)) { if(!(is_meta_mode() | is_advanced_meta_mode())){ register_ccci_sys_call_back(0, ID_REG_TXPOWER_CB, MDM_CB(0)); } register_ccci_sys_call_back(0, ID_REG_RFTEMP_CB, MDM_CB(2)); register_ccci_sys_call_back(0, ID_REG_RFTEMP_3G_CB, MDM_CB(4)); } //#endif //#ifdef CONFIG_MTK_ENABLE_MD2 if (get_modem_is_enabled(1)) { if(!(is_meta_mode() | is_advanced_meta_mode())){ register_ccci_sys_call_back(1, ID_REG_TXPOWER_CB, MDM_CB(1)); } register_ccci_sys_call_back(1, ID_REG_RFTEMP_CB, MDM_CB(3)); register_ccci_sys_call_back(1, ID_REG_RFTEMP_3G_CB, MDM_CB(5)); } //#endif init_timer(&txpwr_timer); txpwr_timer.function = (void *)&mtk_stats_txpwr; //txpwr_timer.data = (unsigned long) &wmt_stats_info; txpwr_timer.expires = jiffies + signal_period * HZ; add_timer(&txpwr_timer); #endif mtk_mdm_dprintk("ENABLE MDM_TxPower Function\n"); return 0; }
static int send_get_md_all_msg(void) { char mode[1]; if(!(is_meta_mode() | is_advanced_meta_mode())){ mode[0] = MTK_THERMAL_GET_TX_POWER; #ifdef MTK_ENABLE_MD1 exec_ccci_kern_func_by_md_id(0, ID_GET_TXPOWER, mode, 0); #endif #ifdef MTK_ENABLE_MD2 exec_ccci_kern_func_by_md_id(1, ID_GET_TXPOWER, mode, 0); #endif } mode[0] = MTK_THERMAL_GET_RF_TEMP_2G; #ifdef MTK_ENABLE_MD1 exec_ccci_kern_func_by_md_id(0, ID_GET_TXPOWER, mode, 0); #endif #ifdef MTK_ENABLE_MD2 exec_ccci_kern_func_by_md_id(1, ID_GET_TXPOWER, mode, 0); #endif mode[0] = MTK_THERMAL_GET_RF_TEMP_3G; #ifdef MTK_ENABLE_MD1 exec_ccci_kern_func_by_md_id(0, ID_GET_TXPOWER, mode, 0); #endif #ifdef MTK_ENABLE_MD2 exec_ccci_kern_func_by_md_id(1, ID_GET_TXPOWER, mode, 0); #endif return 0; }
/* * @brief Configure the modem runtime data structure. * @param * buffer [in] The buffer containing modem runtime data. * @return Size of the modem runtime data structure is returned always. */ KAL_INT32 eemcs_md_runtime_cfg(void *buffer) { struct file *filp = NULL; LOGGING_MODE mdlog_flag = MODE_IDLE; struct MODEM_RUNTIME_st *runtime = NULL; int ret = 0; KAL_ASSERT(buffer != NULL); runtime = (struct MODEM_RUNTIME_st *)buffer; memset(runtime, 0, sizeof(struct MODEM_RUNTIME_st)); runtime->Prefix = 0x46494343; //"CCIF" runtime->Postfix = 0x46494343; //"CCIF" runtime->BootChannel = CH_CTRL_RX; runtime->DriverVersion = 0x20110118; filp = filp_open(MDLOGGER_FILE_PATH, O_RDONLY, 0777); if (!IS_ERR(filp)) { ret = kernel_read(filp, 0, (char*)&mdlog_flag, sizeof(int)); if (ret != sizeof(int)) mdlog_flag = MODE_IDLE; } else { DBGLOG(BOOT, ERR, "open %s fail: %ld", MDLOGGER_FILE_PATH, PTR_ERR(filp)); filp = NULL; } if (filp != NULL) { filp_close(filp, NULL); } if (is_meta_mode() || is_advanced_meta_mode()) runtime->BootingStartID = ((char)mdlog_flag << 8 | META_BOOT_ID); else runtime->BootingStartID = ((char)mdlog_flag << 8 | NORMAL_BOOT_ID); DBGLOG(BOOT, INF, "send /data/extmdl/mdl_config =%d to modem!", mdlog_flag); return sizeof(struct MODEM_RUNTIME_st); }
static int send_get_md_all_msg(void) { char mode[1]; if (!(is_meta_mode() | is_advanced_meta_mode())) { mode[0] = MTK_THERMAL_GET_TX_POWER; /* #ifdef CONFIG_MTK_ENABLE_MD1 */ if (get_modem_is_enabled(0)) exec_ccci_kern_func_by_md_id(0, ID_GET_TXPOWER, mode, 0); /* #endif */ /* #ifdef CONFIG_MTK_ENABLE_MD2 */ if (get_modem_is_enabled(1)) exec_ccci_kern_func_by_md_id(1, ID_GET_TXPOWER, mode, 0); /* #endif */ } mode[0] = MTK_THERMAL_GET_RF_TEMP_2G; /* #ifdef CONFIG_MTK_ENABLE_MD1 */ if (get_modem_is_enabled(0)) exec_ccci_kern_func_by_md_id(0, ID_GET_TXPOWER, mode, 0); /* #endif */ /* #ifdef CONFIG_MTK_ENABLE_MD2 */ if (get_modem_is_enabled(1)) exec_ccci_kern_func_by_md_id(1, ID_GET_TXPOWER, mode, 0); /* #endif */ mode[0] = MTK_THERMAL_GET_RF_TEMP_3G; /* #ifdef CONFIG_MTK_ENABLE_MD1 */ if (get_modem_is_enabled(0)) exec_ccci_kern_func_by_md_id(0, ID_GET_TXPOWER, mode, 0); /* #endif */ /* #ifdef CONFIG_MTK_ENABLE_MD2 */ if (get_modem_is_enabled(1)) exec_ccci_kern_func_by_md_id(1, ID_GET_TXPOWER, mode, 0); /* #endif */ return 0; }
static void ccci_tty_read(unsigned long arg) { int part, size, accept, ret; unsigned read, write; tty_instance_t *tty_instance = (tty_instance_t *) arg; if (tty_instance->tty == NULL) { has_pending_read = 1; CCCI_MSG_INF("tty", "NULL tty @ read\n"); return; } else if ((tty_instance->tty->index == CCCI_TTY_MODEM) && (is_meta_mode()||is_advanced_meta_mode())) { // Do not allow writes to the modem when in Meta Mode. // Otherwise, the modem firmware will crash. CCCI_MSG_INF("tty", "Attempted read from modem while in meta mode\n"); return; } read = tty_instance->shared_mem->rx_control.read; write = tty_instance->shared_mem->rx_control.write; size = write - read; /*ALPS00241537: if there is no data in share memory, not copy and send message to MD*/ /*because total size is (length-1) which is handled in MD write API, size=0 only indicates memory is empty*/ if(size == 0) { //CCCI_MSG_INF("tty", "ttyC%d share memory is empty! \n", tty_instance->tty->index); return; } if (size < 0) { size += tty_instance->shared_mem->rx_control.length; } if(tty_debug_enable & (1UL << tty_instance->tty->index)) CCCI_MSG_INF("tty", "[before Read]:[RX] tty=%04d data_len=%04d write=%04d read=%04d \n", tty_instance->tty->index, size, write, read); if (read > write) { part = tty_instance->shared_mem->rx_control.length - read; memcpy(tty_instance->flip_string, &tty_instance->shared_mem->rx_buffer[read], part); accept = tty_insert_flip_string(tty_instance->tty, tty_instance->flip_string, part); if (accept < part) { size -= accept; read += accept; goto __ccci_read_ack; } else { size -= part; read = 0; } } memcpy(tty_instance->flip_string, &tty_instance->shared_mem->rx_buffer[read], size); accept = tty_insert_flip_string(tty_instance->tty, tty_instance->flip_string, size); if (accept < size) { size -= accept; read += accept; } else { size = 0; read += accept; } __ccci_read_ack: tty_instance->shared_mem->rx_control.read = read; ret = ccci_write_mailbox(tty_instance->uart_rx_ack, tty_instance->channel); if (ret != CCCI_SUCCESS) { CCCI_MSG_INF("tty", "ccci_write_mailbox for %d fail: %d\n", tty_instance->tty->index, ret); ccci_channel_status(tty_instance->uart_rx_ack); // axs: mask assert which will induce device reboot //ASSERT(0); // axs: mask assert which will induce device reboot } if(tty_debug_enable & (1UL << tty_instance->tty->index)) CCCI_MSG_INF("tty", "[after Read]:[RX] tty=%04d data_len=%04d write=%04d read=%4d\n", tty_instance->tty->index, accept, tty_instance->shared_mem->rx_control.write, tty_instance->shared_mem->rx_control.read); wake_lock_timeout(&tty_instance->wake_lock, HZ / 2); tty_flip_buffer_push(tty_instance->tty); }
static int set_md_runtime(void) { int i, addr, len; struct modem_runtime_t *runtime = (struct modem_runtime_t *)MD_RUNTIME_ADDR; volatile int *base = (int*)(MD_RUNTIME_ADDR+sizeof(struct modem_runtime_t)); struct file *filp = NULL; LOGGING_MODE mdlog_flag = MODE_IDLE; int ret = 0; do { base--; CCCI_WRITEL(base,0); } while (base > (int*)MD_RUNTIME_ADDR); CCCI_WRITEL(&runtime->Prefix, 0x46494343); // "CCIF" CCCI_WRITEL(&runtime->Postfix, 0x46494343); // "CCIF" CCCI_WRITEL(&runtime->BootChannel, CCCI_CONTROL_RX); #if 0 if (is_meta_mode()||is_advanced_meta_mode()) { CCCI_WRITEL(&runtime->BootingStartID ,META_BOOT_ID); } else { CCCI_WRITEL(&runtime->BootingStartID ,NORMAL_BOOT_ID); } #endif #ifdef AP_MD_EINT_SHARE_DATA CCCI_WRITEL(&runtime->DriverVersion, 0x00000929); CCCI_WRITEL(&runtime->SysShareMemBase ,ccci_sys_smem_base_phy); CCCI_WRITEL(&runtime->SysShareMemSize ,ccci_sys_smem_size); #endif platform_set_runtime_data(runtime); CCCI_WRITEL(&runtime->ExceShareMemBase ,ccci_exp_smem_base_phy); CCCI_WRITEL(&runtime->ExceShareMemSize ,ccci_exp_smem_size); ccci_mdlog_base_req((void *)&addr, &len); CCCI_WRITEL(&runtime->MdlogShareMemBase ,addr); CCCI_WRITEL(&runtime->MdlogShareMemSize , len); ccci_pcm_base_req((void *)&addr, &len); CCCI_WRITEL(&runtime->PcmShareMemBase ,addr); CCCI_WRITEL(&runtime->PcmShareMemSize ,len); ccci_pmic_base_req((void *)&addr, &len); CCCI_WRITEL(&runtime->PmicShareMemBase ,addr); CCCI_WRITEL(&runtime->PmicShareMemSize ,len); ccci_fs_base_req((void *)&addr, &len); CCCI_WRITEL(&runtime->FileShareMemBase ,addr); CCCI_WRITEL(&runtime->FileShareMemSize ,len); ccci_rpc_base_req((void *)&addr, &len); CCCI_WRITEL(&runtime->RpcShareMemBase, addr); CCCI_WRITEL(&runtime->RpcShareMemSize,len); ccci_ipc_base_req((void*)&addr,&len); CCCI_WRITEL(&runtime->IPCShareMemBase,addr); CCCI_WRITEL(&runtime->IPCShareMemSize,len); for (i = 0; i < CCCI_TTY_BUFF_NR; i++) { ccci_uart_base_req(i, (void *)&addr, &len); if (addr == 0 || len == 0) { break; } else { CCCI_WRITEL(&runtime->UartShareMemBase[i] ,addr); CCCI_WRITEL(&runtime->UartShareMemSize[i] ,len); } } CCCI_WRITEL(&runtime->UartPortNum ,i); //add a new attribute of mdlogger auto start info to notify md filp = filp_open(MDLOGGER_FILE_PATH, O_RDONLY, 0777); if (IS_ERR(filp)) { CCCI_MSG_INF("ctl", "open /data/mdl/mdl_config fail:%ld\n", PTR_ERR(filp)); filp=NULL; } else { ret = kernel_read(filp, 0, (char*)&mdlog_flag,sizeof(int)); if (ret != sizeof(int)) { CCCI_MSG_INF("ctl", "read /data/mdl/mdl_config fail:ret=%d!\n", ret); mdlog_flag = MODE_IDLE; } } if(filp != NULL) { //CCCI_MSG_INF("ctl", "close /data/mdl/mdl_config!\n"); //filp_close(filp, current->files); filp_close(filp, NULL); } if (is_meta_mode() || is_advanced_meta_mode()) CCCI_WRITEL(&runtime->BootingStartID, ((char)mdlog_flag <<8 | META_BOOT_ID)); else CCCI_WRITEL(&runtime->BootingStartID, ((char)mdlog_flag <<8 | NORMAL_BOOT_ID)); CCCI_MSG_INF("ctl", "send /data/mdl/mdl_config =%d to modem!\n", mdlog_flag); DUMP_CCCI_MD_DATA(); return 0; }