1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
|
/*
* sm5703-muic.c - SM5703 micro USB switch device driver
*
* Copyright (C) 2014 Samsung Electronics
* Thomas Ryu <smilesr.ryu@samsung.com>
*
* 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 <linux/gpio.h>
#include <linux/i2c.h>
#include <linux/interrupt.h>
#include <linux/slab.h>
#include <linux/platform_device.h>
#include <linux/module.h>
#include <linux/delay.h>
#include <linux/host_notify.h>
#include <linux/muic/muic.h>
#if defined(CONFIG_MUIC_NOTIFIER)
#include <linux/muic/muic_notifier.h>
#endif /* CONFIG_MUIC_NOTIFIER */
#if defined (CONFIG_OF)
#include <linux/of_device.h>
#include <linux/of_gpio.h>
#endif /* CONFIG_OF */
#include "muic-internal.h"
#include "muic_debug.h"
#include "muic_i2c.h"
#include "muic_regmap.h"
#define MAX_LOG 25
extern bool muic_is_online(void);
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;
if (!muic_is_online()) {
pr_err("%s: muic is offline\n", __func__);
return;
}
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);
schedule_delayed_work(&pmuic->usb_work, msecs_to_jiffies(60000));
}
|