xref: /linux/drivers/gpu/drm/pl111/pl111_debugfs.c (revision e9f0878c4b2004ac19581274c1ae4c61ae3ca70e)
1 /*
2  *  Copyright © 2017 Broadcom
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License version 2 as
6  * published by the Free Software Foundation.
7  */
8 
9 #include <linux/amba/clcd-regs.h>
10 #include <linux/seq_file.h>
11 #include <drm/drm_debugfs.h>
12 #include <drm/drmP.h>
13 #include "pl111_drm.h"
14 
15 #define REGDEF(reg) { reg, #reg }
16 static const struct {
17 	u32 reg;
18 	const char *name;
19 } pl111_reg_defs[] = {
20 	REGDEF(CLCD_TIM0),
21 	REGDEF(CLCD_TIM1),
22 	REGDEF(CLCD_TIM2),
23 	REGDEF(CLCD_TIM3),
24 	REGDEF(CLCD_UBAS),
25 	REGDEF(CLCD_LBAS),
26 	REGDEF(CLCD_PL111_CNTL),
27 	REGDEF(CLCD_PL111_IENB),
28 	REGDEF(CLCD_PL111_RIS),
29 	REGDEF(CLCD_PL111_MIS),
30 	REGDEF(CLCD_PL111_ICR),
31 	REGDEF(CLCD_PL111_UCUR),
32 	REGDEF(CLCD_PL111_LCUR),
33 };
34 
35 int pl111_debugfs_regs(struct seq_file *m, void *unused)
36 {
37 	struct drm_info_node *node = (struct drm_info_node *)m->private;
38 	struct drm_device *dev = node->minor->dev;
39 	struct pl111_drm_dev_private *priv = dev->dev_private;
40 	int i;
41 
42 	for (i = 0; i < ARRAY_SIZE(pl111_reg_defs); i++) {
43 		seq_printf(m, "%s (0x%04x): 0x%08x\n",
44 			   pl111_reg_defs[i].name, pl111_reg_defs[i].reg,
45 			   readl(priv->regs + pl111_reg_defs[i].reg));
46 	}
47 
48 	return 0;
49 }
50 
51 static const struct drm_info_list pl111_debugfs_list[] = {
52 	{"regs", pl111_debugfs_regs, 0},
53 };
54 
55 int
56 pl111_debugfs_init(struct drm_minor *minor)
57 {
58 	return drm_debugfs_create_files(pl111_debugfs_list,
59 					ARRAY_SIZE(pl111_debugfs_list),
60 					minor->debugfs_root, minor);
61 }
62