1 // SPDX-License-Identifier: GPL-2.0-only
2 /*
3 * Copyright © 2017 Broadcom
4 */
5
6 #include <linux/amba/clcd-regs.h>
7 #include <linux/seq_file.h>
8
9 #include <drm/drm_debugfs.h>
10 #include <drm/drm_file.h>
11
12 #include "pl111_drm.h"
13
14 #define REGDEF(reg) { reg, #reg }
15 static const struct {
16 u32 reg;
17 const char *name;
18 } pl111_reg_defs[] = {
19 REGDEF(CLCD_TIM0),
20 REGDEF(CLCD_TIM1),
21 REGDEF(CLCD_TIM2),
22 REGDEF(CLCD_TIM3),
23 REGDEF(CLCD_UBAS),
24 REGDEF(CLCD_LBAS),
25 REGDEF(CLCD_PL111_CNTL),
26 REGDEF(CLCD_PL111_IENB),
27 REGDEF(CLCD_PL111_RIS),
28 REGDEF(CLCD_PL111_MIS),
29 REGDEF(CLCD_PL111_ICR),
30 REGDEF(CLCD_PL111_UCUR),
31 REGDEF(CLCD_PL111_LCUR),
32 };
33
pl111_debugfs_regs(struct seq_file * m,void * unused)34 int pl111_debugfs_regs(struct seq_file *m, void *unused)
35 {
36 struct drm_info_node *node = (struct drm_info_node *)m->private;
37 struct drm_device *dev = node->minor->dev;
38 struct pl111_drm_dev_private *priv = dev->dev_private;
39 int i;
40
41 for (i = 0; i < ARRAY_SIZE(pl111_reg_defs); i++) {
42 seq_printf(m, "%s (0x%04x): 0x%08x\n",
43 pl111_reg_defs[i].name, pl111_reg_defs[i].reg,
44 readl(priv->regs + pl111_reg_defs[i].reg));
45 }
46
47 return 0;
48 }
49
50 static const struct drm_info_list pl111_debugfs_list[] = {
51 {"regs", pl111_debugfs_regs, 0},
52 };
53
54 int
pl111_debugfs_init(struct drm_minor * minor)55 pl111_debugfs_init(struct drm_minor *minor)
56 {
57 return drm_debugfs_create_files(pl111_debugfs_list,
58 ARRAY_SIZE(pl111_debugfs_list),
59 minor->debugfs_root, minor);
60 }
61