blob: 83342e4c7593f286562d5604d79cd3778ded7daf [file] [log] [blame]
Sachin Bhayareeeb88892018-01-02 16:36:01 +05301/* Copyright (c) 2012-2016, 2018, The Linux Foundation. All rights reserved.
2 *
3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License version 2 and
5 * only version 2 as published by the Free Software Foundation.
6 *
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
11 *
12 */
13
14#ifndef MDSS_DEBUG_H
15#define MDSS_DEBUG_H
16
17#include <stdarg.h>
18#include <linux/debugfs.h>
19#include <linux/list.h>
20#include <linux/mdss_io_util.h>
21
22#include "mdss.h"
23#include "mdss_mdp_trace.h"
24
25#define MISR_POLL_SLEEP 2000
26#define MISR_POLL_TIMEOUT 32000
27#define MISR_CRC_BATCH_CFG 0x101
28#define DATA_LIMITER (-1)
29#define XLOG_TOUT_DATA_LIMITER (NULL)
30#define XLOG_FUNC_ENTRY 0x1111
31#define XLOG_FUNC_EXIT 0x2222
32#define MDSS_REG_BLOCK_NAME_LEN (5)
33
34enum mdss_dbg_reg_dump_flag {
35 MDSS_DBG_DUMP_IN_LOG = BIT(0),
36 MDSS_DBG_DUMP_IN_MEM = BIT(1),
37};
38
39enum mdss_dbg_xlog_flag {
40 MDSS_XLOG_DEFAULT = BIT(0),
41 MDSS_XLOG_IOMMU = BIT(1),
42 MDSS_XLOG_DBG = BIT(6),
43 MDSS_XLOG_ALL = BIT(7)
44};
45
46#define TEST_MASK(id, tp) ((id << 4) | (tp << 1) | BIT(0))
47struct debug_bus {
48 u32 wr_addr;
49 u32 block_id;
50 u32 test_id;
51};
52
53struct vbif_debug_bus {
54 u32 disable_bus_addr;
55 u32 block_bus_addr;
56 u32 bit_offset;
57 u32 block_cnt;
58 u32 test_pnt_cnt;
59};
60
61#define MDSS_XLOG(...) mdss_xlog(__func__, __LINE__, MDSS_XLOG_DEFAULT, \
62 ##__VA_ARGS__, DATA_LIMITER)
63
64#define MDSS_XLOG_TOUT_HANDLER(...) \
65 mdss_xlog_tout_handler_default(false, __func__, ##__VA_ARGS__, \
66 XLOG_TOUT_DATA_LIMITER)
67
68#define MDSS_XLOG_TOUT_HANDLER_WQ(...) \
69 mdss_xlog_tout_handler_default(true, __func__, ##__VA_ARGS__, \
70 XLOG_TOUT_DATA_LIMITER)
71
72#define MDSS_XLOG_DBG(...) mdss_xlog(__func__, __LINE__, MDSS_XLOG_DBG, \
73 ##__VA_ARGS__, DATA_LIMITER)
74
75#define MDSS_XLOG_ALL(...) mdss_xlog(__func__, __LINE__, MDSS_XLOG_ALL, \
76 ##__VA_ARGS__, DATA_LIMITER)
77
78#define MDSS_XLOG_IOMMU(...) mdss_xlog(__func__, __LINE__, MDSS_XLOG_IOMMU, \
79 ##__VA_ARGS__, DATA_LIMITER)
80
Sachin Bhayare3d3767e2018-01-02 21:10:57 +053081#define ATRACE_END(name) trace_mdss_mark_write(current->tgid, name, 0)
82#define ATRACE_BEGIN(name) trace_mdss_mark_write(current->tgid, name, 1)
Sachin Bhayareeeb88892018-01-02 16:36:01 +053083#define ATRACE_FUNC() ATRACE_BEGIN(__func__)
84
85#define ATRACE_INT(name, value) \
86 trace_mdp_trace_counter(current->tgid, name, value)
87
88#if defined(CONFIG_DEBUG_FS) && defined(CONFIG_FB_MSM_MDSS)
89
90#define MDSS_DEBUG_BASE_MAX 10
91
92struct mdss_debug_base {
93 struct list_head head; /* head of this node */
94 struct list_head dump_list; /* head to the list with dump ranges */
95 struct mdss_debug_data *mdd;
96 char name[80];
97 void __iomem *base;
98 size_t off;
99 size_t cnt;
100 u8 cmd_data_type;
101 size_t max_offset;
102 char *buf;
103 size_t buf_len;
104 u32 *reg_dump; /* address for the mem dump if no ranges used */
105};
106
107struct mdss_debug_data {
108 struct dentry *root;
109 struct dentry *perf;
110 struct dentry *bordercolor;
111 struct dentry *postproc;
112 struct list_head base_list;
113};
114
115struct dump_offset {
116 u32 start;
117 u32 end;
118};
119
120struct range_dump_node {
121 struct list_head head; /* head of this node */
122 u32 *reg_dump; /* address for the mem dump */
123 char range_name[40]; /* name of this range */
124 struct dump_offset offset; /* range to dump */
125 uint32_t xin_id; /* client xin id */
126};
127
128#define DEFINE_MDSS_DEBUGFS_SEQ_FOPS(__prefix) \
129static int __prefix ## _open(struct inode *inode, struct file *file) \
130{ \
131 return single_open(file, __prefix ## _show, inode->i_private); \
132} \
133static const struct file_operations __prefix ## _fops = { \
134 .owner = THIS_MODULE, \
135 .open = __prefix ## _open, \
136 .release = single_release, \
137 .read = seq_read, \
138 .llseek = seq_lseek, \
139}
140
141int mdss_debugfs_init(struct mdss_data_type *mdata);
142int mdss_debugfs_remove(struct mdss_data_type *mdata);
143int mdss_debug_register_base(const char *name, void __iomem *base,
144 size_t max_offset, struct mdss_debug_base **dbg_blk);
145void mdss_debug_register_dump_range(struct platform_device *pdev,
146 struct mdss_debug_base *blk_base, const char *ranges_prop,
147 const char *name_prop, const char *xin_prop);
148int panel_debug_register_base(const char *name, void __iomem *base,
149 size_t max_offset);
150int mdss_misr_set(struct mdss_data_type *mdata,
151 struct mdp_misr *req,
152 struct mdss_mdp_ctl *ctl);
153int mdss_misr_get(struct mdss_data_type *mdata,
154 struct mdp_misr *resp,
155 struct mdss_mdp_ctl *ctl,
156 bool is_video_mode);
157void mdss_misr_disable(struct mdss_data_type *mdata,
158 struct mdp_misr *req,
159 struct mdss_mdp_ctl *ctl);
160void mdss_misr_crc_collect(struct mdss_data_type *mdata, int block_id,
161 bool is_video_mode);
162
163int mdss_create_xlog_debug(struct mdss_debug_data *mdd);
164#if defined(CONFIG_FB_MSM_MDSS_FRC_DEBUG)
165int mdss_create_frc_debug(struct mdss_debug_data *mdd);
166#else
167static inline int mdss_create_frc_debug(struct mdss_debug_data *mdd)
168 {return 0; }
169#endif
170void mdss_xlog(const char *name, int line, int flag, ...);
171void mdss_xlog_tout_handler_default(bool queue, const char *name, ...);
172u32 get_dump_range(struct dump_offset *range_node, size_t max_offset);
173void mdss_dump_reg(const char *dump_name, u32 reg_dump_flag, char *addr,
174 int len, u32 **dump_mem, bool from_isr);
175void mdss_mdp_debug_mid(u32 mid);
176#else
177struct mdss_debug_base;
178struct dump_offset;
179
180static inline int mdss_debugfs_init(struct mdss_data_type *mdata) { return 0; }
181static inline int mdss_debugfs_remove(struct mdss_data_type *mdata)
182{
183 return 0;
184}
185static inline int mdss_debug_register_base(const char *name, void __iomem *base,
186 size_t max_offset, struct mdss_debug_base **dbg_blk) { return 0; }
187static inline void mdss_debug_register_dump_range(struct platform_device *pdev,
188 struct mdss_debug_base *blk_base, const char *ranges_prop,
189 const char *name_prop, const char *xin_prop) { }
190static inline int panel_debug_register_base(const char *name,
191 void __iomem *base,
192 size_t max_offset)
193{ return 0; }
194static inline int mdss_misr_set(struct mdss_data_type *mdata,
195 struct mdp_misr *req,
196 struct mdss_mdp_ctl *ctl)
197{ return 0; }
198static inline int mdss_misr_get(struct mdss_data_type *mdata,
199 struct mdp_misr *resp,
200 struct mdss_mdp_ctl *ctl,
201 bool is_video_mode)
202{ return 0; }
203static inline void mdss_misr_disable(struct mdss_data_type *mdata,
204 struct mdp_misr *req,
205 struct mdss_mdp_ctl *ctl)
206{ return; }
207
208static inline void mdss_misr_crc_collect(struct mdss_data_type *mdata,
209 int block_id, bool is_video_mode) { }
210
211static inline int create_xlog_debug(struct mdss_data_type *mdata) { return 0; }
212static inline void mdss_xlog_dump(void) { }
213static inline void mdss_xlog(const char *name, int line, int flag, ...) { }
214
215static inline void mdss_dsi_debug_check_te(struct mdss_panel_data *pdata) { }
216static inline void mdss_xlog_tout_handler_default(bool queue,
217 const char *name, ...) { }
218u32 get_dump_range(struct dump_offset *range_node, size_t max_offset)
219 { return 0; }
220void mdss_dump_reg(const char *dump_name, u32 reg_dump_flag, char *addr,
221 int len, u32 **dump_mem, bool from_isr) { }
222void mdss_mdp_debug_mid(u32 mid) { }
223#endif
224
225int mdss_dump_misr_data(char **buf, u32 size);
226
227static inline int mdss_debug_register_io(const char *name,
228 struct dss_io_data *io_data, struct mdss_debug_base **dbg_blk)
229{
230 return mdss_debug_register_base(name, io_data->base, io_data->len,
231 dbg_blk);
232}
233
234#if defined(CONFIG_DEBUG_FS) && defined(CONFIG_FB_MSM_MDSS_FRC_DEBUG)
235void mdss_debug_frc_add_vsync_sample(struct mdss_mdp_ctl *ctl,
236 ktime_t vsync_time);
237void mdss_debug_frc_add_kickoff_sample_pre(struct mdss_mdp_ctl *ctl,
238 struct mdss_mdp_frc_info *frc_info, int remaining);
239void mdss_debug_frc_add_kickoff_sample_post(struct mdss_mdp_ctl *ctl,
240 struct mdss_mdp_frc_info *frc_info, int remaining);
241int mdss_debug_frc_frame_repeat_disabled(void);
242#else
243static inline void mdss_debug_frc_add_vsync_sample(
244 struct mdss_mdp_ctl *ctl, ktime_t vsync_time) {}
245static inline void mdss_debug_frc_add_kickoff_sample_pre(
246 struct mdss_mdp_ctl *ctl,
247 struct mdss_mdp_frc_info *frc_info,
248 int remaining) {}
249static inline void mdss_debug_frc_add_kickoff_sample_post(
250 struct mdss_mdp_ctl *ctl,
251 struct mdss_mdp_frc_info *frc_info,
252 int remaining) {}
253static inline int mdss_debug_frc_frame_repeat_disabled(void) {return false; }
254#endif
255
256#endif /* MDSS_DEBUG_H */