static int _cl_bcct_read(struct seq_file *m, void *v) { /** * The format to print out: * kernel_log <0 or 1> * <mtk-cl-bcct<ID>> <bcc limit> * .. */ mtk_cooler_bcct_dprintk("_cl_bcct_read invoked.\n"); { int i = 0; seq_printf(m, "klog %d\n", cl_bcct_klog_on); seq_printf(m, "curr_limit %d\n", cl_bcct_cur_limit); for (; i < MAX_NUM_INSTANCE_MTK_COOLER_BCCT; i++) { int limit; unsigned int curr_state; MTK_CL_BCCT_GET_LIMIT(limit, cl_bcct_state[i]); MTK_CL_BCCT_GET_CURR_STATE(curr_state, cl_bcct_state[i]); seq_printf(m, "mtk-cl-bcct%02d %d mA, state %d\n", i, limit, curr_state); } } return 0; }
static int _mtk_cl_bcct_proc_read(char *buf, char **start, off_t off, int count, int *eof, void *data) { int len = 0; char *p = buf; mtk_cooler_bcct_dprintk("[_mtk_cl_bcct_proc_read] invoked.\n"); /** * The format to print out: * kernel_log <0 or 1> * <mtk-cl-bcct<ID>> <bcc limit> * .. */ if (NULL == data) { mtk_cooler_bcct_dprintk("[_mtk_cl_bcct_proc_read] null data\n"); } else { int i = 0; p += sprintf(p, "klog %d\n", cl_bcct_klog_on); p += sprintf(p, "curr_limit %d\n", cl_bcct_cur_limit); for (; i < MAX_NUM_INSTANCE_MTK_COOLER_BCCT; i++) { int limit; unsigned int curr_state; MTK_CL_BCCT_GET_LIMIT(limit, cl_bcct_state[i]); MTK_CL_BCCT_GET_CURR_STATE(curr_state, cl_bcct_state[i]); p += sprintf(p, "mtk-cl-bcct%02d %d mA, state %d\n", i, limit, curr_state); } } *start = buf + off; len = p - buf; if (len > off) len -= off; else len = 0; return len < count ? len : count; }
static void mtk_cl_bcct_set_bcct_limit(void) { // TODO: optimize int i = 0; int min_limit = 65535; for (; i < MAX_NUM_INSTANCE_MTK_COOLER_BCCT; i++) { unsigned long curr_state; MTK_CL_BCCT_GET_CURR_STATE(curr_state, cl_bcct_state[i]); if (1 == curr_state) { int limit; MTK_CL_BCCT_GET_LIMIT(limit, cl_bcct_state[i]); if ((min_limit > limit) && (limit > 0)) min_limit = limit; } } if (min_limit != cl_bcct_cur_limit) { cl_bcct_cur_limit = min_limit; #if 1 if (65535 <= cl_bcct_cur_limit) { set_bat_charging_current_limit(-1); mtk_cooler_bcct_dprintk_always("mtk_cl_bcct_set_bcct_limit() limit=-1\n"); } else { set_bat_charging_current_limit(cl_bcct_cur_limit); mtk_cooler_bcct_dprintk_always("mtk_cl_bcct_set_bcct_limit() limit=%d\n", cl_bcct_cur_limit); } mtk_cooler_bcct_dprintk_always("mtk_cl_bcct_set_bcct_limit() real limit=%d\n", get_bat_charging_current_level()); #endif } }