static ssize_t mtk_mdm_sw_write(struct file *file, const char __user *buf, size_t len, loff_t *data) { char desc[MAX_LEN] = {0}; char temp[MAX_LEN] = {0}; len = (len < (sizeof(desc) - 1)) ? len : (sizeof(desc) - 1); /* write data to the buffer */ if (copy_from_user(desc, buf, len)) { return -EFAULT; } if (sscanf(desc, "%s", temp) == 1) { if(strncmp(temp, "on", 2)==0 || strncmp(temp, "1", 1)==0){ mdm_sw = true; } else if (strncmp(temp, "off", 3)==0 || strncmp(temp, "0", 1)==0){ mdm_sw = false; } else { mtk_mdm_dprintk("[%s] bad argument:%s\n", __func__, temp); } if(mdm_sw) { mtk_mdm_enable(); } else { mtk_mdm_disable(); } return len; } else { mtk_mdm_dprintk("[%s] bad argument\n", __func__); } return -EINVAL; }
static ssize_t mtk_mdm_proc_mdinfoex_write(struct file *file, const char *buf, size_t len, loff_t *data) { char desc[MAX_LEN] = { 0 }; int opcode; int value; len = (len < (sizeof(desc) - 1)) ? len : (sizeof(desc) - 1); /* write data to the buffer */ if (copy_from_user(desc, buf, len)) { return -EFAULT; } if (sscanf(desc, "%d,%d", &opcode, &value) >= 2) { mtk_mdm_dprintk("[%s] %d,%d\n", __func__, opcode, value); /* fill mdinfoex */ if (opcode >= 0 && opcode < MAX_MDINFOEX_OPCODE) { mdinfoex[opcode] = value; } else { mtk_mdm_dprintk("[%s] invalid input %d,%d\n", __func__, opcode, value); } return len; } else { mtk_mdm_dprintk("[%s] invalid input %d,%d\n", __func__, opcode, value); } return -EINVAL; }
static int __init mtk_mdm_txpwr_init(void) { struct proc_dir_entry *entry = NULL; struct proc_dir_entry *mdtxpwr_dir = NULL; mtk_mdm_dprintk("[mtk_mdm_txpwr_init] \n"); mdtxpwr_dir = proc_mkdir("mtk_mdm_txpwr", NULL); if (!mdtxpwr_dir) { mtk_mdm_dprintk("[mtk_mdm_init]: mkdir /proc/mtk_mdm_txpwr failed\n"); } else { entry = create_proc_entry("txpwr_sw", S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP, mdtxpwr_dir); if (entry) { entry->read_proc = mtk_mdm_sw_read; entry->write_proc = mtk_mdm_sw_write; } entry = create_proc_entry("txpwr_value", S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP, mdtxpwr_dir); if (entry) { entry->read_proc = mtk_mdm_value_read; } entry = create_proc_entry("timeout", S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP, mdtxpwr_dir); if (entry) { entry->read_proc = mtk_mdm_proc_timeout_read; entry->write_proc = mtk_mdm_proc_timeout_write; } } // Add for thermal all on scenary //mtk_mdm_start_query(); return 0; }
static ssize_t mtk_mdm_proc_mdinfo_write(struct file *file, const char *buf, unsigned long len, void *data) { char desc[MAX_LEN] = {0}; int sim; int rat; int rf_temp; int tx_power; len = (len < (sizeof(desc) - 1)) ? len : (sizeof(desc) - 1); /* write data to the buffer */ if (copy_from_user(desc, buf, len)) { return -EFAULT; } if (sscanf(desc, "%d,%d,%d,%d", &sim, &rat, &rf_temp, &tx_power) >= 3) { mtk_mdm_dprintk("[%s] %d,%d,%d,%d\n", __func__, sim, rat, rf_temp, tx_power); rf_temp = (rf_temp >= 32767) ? -127 : rf_temp; // 32767 means invalid temp // fill into g_pinfo_list if (0 == sim) // MD1 { if (1 == rat) { g_pinfo_list[2].value = rf_temp*1000; } else if (2 == rat) { g_pinfo_list[4].value = rf_temp*1000; g_pinfo_list[0].value = tx_power; } } else if (1 == sim) // MD2 { if (1 == rat) { g_pinfo_list[3].value = rf_temp*1000; } else if (2 == rat) { g_pinfo_list[5].value = rf_temp*1000; g_pinfo_list[1].value = tx_power; } } return len; } else { mtk_mdm_dprintk("[%s] insufficient input %d,%d,%d,%d\n", __func__, sim, rat, rf_temp, tx_power); } return -EINVAL; }
int mtk_mdm_get_md_info(struct md_info** p_inf, int *size) { mtk_mdm_dprintk("mtk_mdm_get_md_info+\n"); *p_inf = g_pinfo_list; *size = sizeof(g_pinfo_list)/sizeof(g_pinfo_list[0]); mtk_mdm_dprintk("mtk_mdm_get_md_info-\n"); return 0; }
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 mtk_mdm_disable(void) { #if MTK_TS_PA_THPUT_VIA_CCCI == 1 del_timer(&txpwr_timer); #endif mtk_mdm_dprintk("DISABLE MDM_TxPower Function\n"); return 0; }
int mtk_mdm_stop_query(void) { mtk_mdm_dprintk("mtk_mdm_stop_query\n"); mdm_sw = false; mtk_mdm_disable(); return 0; }
static int mtk_mdm_proc_mdinfoex_read(struct seq_file *m, void *v) { int i = 0; for (; i < MAX_MDINFOEX_OPCODE; i++) seq_printf(m, "%03d %d\n", i, mdinfoex[i]); mtk_mdm_dprintk("[%s]\n", __func__); return 0; }
int mtk_mdm_start_query(void) { //#if defined(CONFIG_MTK_ENABLE_MD1) || defined(CONFIG_MTK_ENABLE_MD2) mtk_mdm_dprintk("mtk_mdm_start_query\n"); mdm_sw = true; mtk_mdm_enable(); //#endif return 0; }
static int mtk_mdm_proc_mdinfo_read(struct seq_file *m, void *v) { seq_printf(m, "md 1 T2g %d T3g %d tx %d\nmd 2 T2g %d T3g %d tx %d\n", g_pinfo_list[2].value, g_pinfo_list[4].value, g_pinfo_list[0].value, g_pinfo_list[3].value, g_pinfo_list[5].value, g_pinfo_list[1].value); mtk_mdm_dprintk("[%s] %d", __func__, signal_period); return 0; }
static int mtk_stats_txpwr(unsigned long data) { txpwr_timer.expires = jiffies + signal_period * HZ; send_get_md_all_msg(); add_timer(&txpwr_timer); mtk_mdm_dprintk("mtk_stats_txpwr\n"); return 0; }
static int mtk_mdm_proc_mdinfoex_threshold_read(struct seq_file *m, void *v) { int i = 0; for (; i < MAX_MDINFOEX_OPCODE; i++) { seq_printf(m, "%d,", mdinfoex_threshold[i]); } seq_puts(m, "\n"); mtk_mdm_dprintk("[%s]\n", __func__); return 0; }
static ssize_t mtk_mdm_proc_timeout_write(struct file *file, const char *buf, unsigned long len, void *data) { char desc[MAX_LEN] = {0}; int temp_value; len = (len < (sizeof(desc) - 1)) ? len : (sizeof(desc) - 1); /* write data to the buffer */ if (copy_from_user(desc, buf, len)) { return -EFAULT; } if (sscanf(desc, "%d", &temp_value) == 1) { signal_period = temp_value; mtk_mdm_dprintk("[%s] Set Timeout:%d\n", __func__, temp_value); return len; } else { mtk_mdm_dprintk("[%s] bad argument\n", __func__); } return -EINVAL; }
static int mtk_mdm_sw_read(char *buf, char **start, off_t off, int count, int *eof, void *data) { int len = 0; len += sprintf(buf, "%s\n", mdm_sw?"on":"off"); *start = buf + off; if (len > off) len -= off; else len = 0; mtk_mdm_dprintk("[%s] %s", __func__, mdm_sw?"on":"off"); return len < count ? len : count; }
static int mtk_mdm_proc_timeout_read(char *buf, char **start, off_t off, int count, int *eof, void *data) { int len = 0; len += sprintf(buf, "%d\n", signal_period); *start = buf + off; if (len > off) len -= off; else len = 0; mtk_mdm_dprintk("[%s] %d", __func__, signal_period); return len < count ? len : count; }
int mtk_mdm_set_mdinfoex_threshold(int opcode, int threshold) { mtk_mdm_dprintk("%s\n", __func__); #if defined(CONFIG_MTK_THERMAL_PA_VIA_ATCMD) if (opcode >= 0 && opcode < MAX_MDINFOEX_OPCODE) { mdinfoex_threshold[opcode] = threshold; return 0; } else { return -1; } #else return -1; #endif }
int mtk_mdm_get_mdinfoex(int opcode, int *value) { mtk_mdm_dprintk("%s\n", __func__); #if defined(CONFIG_MTK_THERMAL_PA_VIA_ATCMD) if (opcode >= 0 && opcode < MAX_MDINFOEX_OPCODE && value != NULL) { *value = mdinfoex[opcode]; return 0; } else { return -1; } #else return -1; #endif }
static int mtk_mdm_proc_mdinfo_read(char *buf, char **start, off_t off, int count, int *eof, void *data) { int len = 0; len += sprintf(buf, "md 1 T2g %d T3g %d tx %d\nmd 2 T2g %d T3g %d tx %d\n", g_pinfo_list[2].value, g_pinfo_list[4].value, g_pinfo_list[0].value, g_pinfo_list[3].value, g_pinfo_list[5].value, g_pinfo_list[1].value); *start = buf + off; if (len > off) len -= off; else len = 0; mtk_mdm_dprintk("[%s] %d", __func__, signal_period); return len < count ? len : count; }
static void __exit mtk_mdm_txpwr_exit(void) { mtk_mdm_dprintk("[mtk_mdm_txpwr_exit] \n"); }
static int __init mtk_mdm_txpwr_init(void) { struct proc_dir_entry *entry = NULL; struct proc_dir_entry *mdtxpwr_dir = NULL; mtk_mdm_dprintk("[%s]\n", __func__); mdtxpwr_dir = mtk_thermal_get_proc_drv_therm_dir_entry(); if (!mdtxpwr_dir) { mtk_mdm_dprintk("[%s]: mkdir /driver/thermal failed\n", __func__); } else { entry = proc_create("mdm_sw", S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP, mdtxpwr_dir, &mtk_mdm_sw_fops); entry = proc_create("mdm_value", S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP, mdtxpwr_dir, &mtk_mdm_value_fops); entry = proc_create("mdm_timeout", S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP, mdtxpwr_dir, &mtk_mdm_proc_timeout_fops); #if MTK_TS_PA_THPUT_VIA_ATCMD == 1 entry = proc_create("mdm_mdinfo", S_IRUGO | S_IWUSR | S_IWGRP, mdtxpwr_dir, &mtk_mdm_proc_mdinfo_fops); if (entry) { #if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 10, 0) proc_set_user(entry, 0, 1000); #else entry->gid = 1000; #endif } entry = proc_create("mdm_mdinfoex", S_IRUGO | S_IWUSR | S_IWGRP, mdtxpwr_dir, &mtk_mdm_proc_mdinfoex_fops); if (entry) { #if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 10, 0) proc_set_user(entry, 0, 1000); #else entry->gid = 1000; #endif } entry = proc_create("mdm_mdinfoex_thre", S_IRUGO, mdtxpwr_dir, &mtk_mdm_proc_mdinfoex_threshold_fops); if (entry) { #if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 10, 0) proc_set_user(entry, 0, 1000); #else entry->gid = 1000; #endif } #endif } /* Add for thermal all on scenary */ /* mtk_mdm_start_query(); */ return 0; }
static int mtk_mdm_proc_timeout_read(struct seq_file *m, void *v) { seq_printf(m, "%d\n", signal_period); mtk_mdm_dprintk("[%s] %d", __func__, signal_period); return 0; }
static int mtk_mdm_sw_read(struct seq_file *m, void *v) { seq_printf(m, "%s\n", mdm_sw ? "on" : "off"); mtk_mdm_dprintk("[%s] %s", __func__, mdm_sw?"on":"off"); return 0; }
static int mtk_mdm_disable(void) { del_timer(&txpwr_timer); mtk_mdm_dprintk("DISABLE MDM_TxPower Function\n"); return 0; }