/* * sm5703-muic.c - SM5703 micro USB switch device driver * * Copyright (C) 2014 Samsung Electronics * Thomas Ryu * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * */ #include #include #include #include #include #include #include #include #include #if defined(CONFIG_MUIC_NOTIFIER) #include #endif /* CONFIG_MUIC_NOTIFIER */ #if defined (CONFIG_OF) #include #include #endif /* CONFIG_OF */ #include "muic-internal.h" #include "muic_debug.h" #include "muic_i2c.h" #include "muic_regmap.h" #define MAX_LOG 25 static u8 muic_log_cnt; static u8 muic_log[MAX_LOG][3]; void muic_reg_log(u8 reg, u8 value, u8 rw) { muic_log[muic_log_cnt][0]=reg; muic_log[muic_log_cnt][1]=value; muic_log[muic_log_cnt][2]=rw; muic_log_cnt++; if(muic_log_cnt >= MAX_LOG) muic_log_cnt = 0; } void muic_print_reg_log(void) { int i; u8 reg, value, rw; char mesg[256]=""; for( i = 0 ; i < MAX_LOG ; i++ ) { reg = muic_log[muic_log_cnt][0]; value = muic_log[muic_log_cnt][1]; rw = muic_log[muic_log_cnt][2]; muic_log_cnt++; if(muic_log_cnt >= MAX_LOG) muic_log_cnt = 0; sprintf(mesg+strlen(mesg),"%x(%x)%x ", reg, value, rw); } pr_info("%s:%s\n", __func__, mesg); } void muic_read_reg_dump(muic_data_t *pmuic, char *mesg) { struct regmap_ops *pops = pmuic->regmapdesc->regmapops; pops->get_formatted_dump(pmuic->regmapdesc, mesg); } void muic_print_reg_dump(muic_data_t *pmuic) { char mesg[256]=""; muic_read_reg_dump(pmuic, mesg); pr_info("%s:%s\n", __func__, mesg); } void muic_show_debug_info(struct work_struct *work) { muic_data_t *pmuic = container_of(work, muic_data_t, usb_work.work); mutex_lock(&pmuic->muic_mutex); muic_print_reg_log(); muic_print_reg_dump(pmuic); mutex_unlock(&pmuic->muic_mutex); INIT_DELAYED_WORK(&pmuic->usb_work, muic_show_debug_info); schedule_delayed_work(&pmuic->usb_work, msecs_to_jiffies(60000)); }