1141518d2SEric Anholt /*
2141518d2SEric Anholt  *  Copyright © 2017 Broadcom
3141518d2SEric Anholt  *
4141518d2SEric Anholt  * This program is free software; you can redistribute it and/or modify
5141518d2SEric Anholt  * it under the terms of the GNU General Public License version 2 as
6141518d2SEric Anholt  * published by the Free Software Foundation.
7141518d2SEric Anholt  */
8141518d2SEric Anholt 
9141518d2SEric Anholt #include <linux/amba/clcd-regs.h>
10141518d2SEric Anholt #include <linux/seq_file.h>
11141518d2SEric Anholt #include <drm/drm_debugfs.h>
12141518d2SEric Anholt #include <drm/drmP.h>
13141518d2SEric Anholt #include "pl111_drm.h"
14141518d2SEric Anholt 
15141518d2SEric Anholt #define REGDEF(reg) { reg, #reg }
16141518d2SEric Anholt static const struct {
17141518d2SEric Anholt 	u32 reg;
18141518d2SEric Anholt 	const char *name;
19141518d2SEric Anholt } pl111_reg_defs[] = {
20141518d2SEric Anholt 	REGDEF(CLCD_TIM0),
21141518d2SEric Anholt 	REGDEF(CLCD_TIM1),
22141518d2SEric Anholt 	REGDEF(CLCD_TIM2),
23141518d2SEric Anholt 	REGDEF(CLCD_TIM3),
24141518d2SEric Anholt 	REGDEF(CLCD_UBAS),
25141518d2SEric Anholt 	REGDEF(CLCD_PL111_CNTL),
26141518d2SEric Anholt 	REGDEF(CLCD_PL111_IENB),
27141518d2SEric Anholt };
28141518d2SEric Anholt 
29141518d2SEric Anholt int pl111_debugfs_regs(struct seq_file *m, void *unused)
30141518d2SEric Anholt {
31141518d2SEric Anholt 	struct drm_info_node *node = (struct drm_info_node *)m->private;
32141518d2SEric Anholt 	struct drm_device *dev = node->minor->dev;
33141518d2SEric Anholt 	struct pl111_drm_dev_private *priv = dev->dev_private;
34141518d2SEric Anholt 	int i;
35141518d2SEric Anholt 
36141518d2SEric Anholt 	for (i = 0; i < ARRAY_SIZE(pl111_reg_defs); i++) {
37141518d2SEric Anholt 		seq_printf(m, "%s (0x%04x): 0x%08x\n",
38141518d2SEric Anholt 			   pl111_reg_defs[i].name, pl111_reg_defs[i].reg,
39141518d2SEric Anholt 			   readl(priv->regs + pl111_reg_defs[i].reg));
40141518d2SEric Anholt 	}
41141518d2SEric Anholt 
42141518d2SEric Anholt 	return 0;
43141518d2SEric Anholt }
44141518d2SEric Anholt 
45141518d2SEric Anholt static const struct drm_info_list pl111_debugfs_list[] = {
46141518d2SEric Anholt 	{"regs", pl111_debugfs_regs, 0},
47141518d2SEric Anholt };
48141518d2SEric Anholt 
49141518d2SEric Anholt int
50141518d2SEric Anholt pl111_debugfs_init(struct drm_minor *minor)
51141518d2SEric Anholt {
52141518d2SEric Anholt 	return drm_debugfs_create_files(pl111_debugfs_list,
53141518d2SEric Anholt 					ARRAY_SIZE(pl111_debugfs_list),
54141518d2SEric Anholt 					minor->debugfs_root, minor);
55141518d2SEric Anholt }
56