diff options
author | Joel Stanley <joel@jms.id.au> | 2018-04-19 07:20:01 +0300 |
---|---|---|
committer | Joel Stanley <joel@jms.id.au> | 2018-04-20 09:40:23 +0300 |
commit | 84532683d1b8b2c570a9e60c511c96271a9f3b56 (patch) | |
tree | 1691c3c4b3561ab1abb5866e24c1ecc358e971c1 | |
parent | dff934c53f7f36636751b162a88ee3b0dc05c1bf (diff) | |
download | linux-84532683d1b8b2c570a9e60c511c96271a9f3b56.tar.xz |
drm: aspeed: Debugfs interface for GFX registers
This exposes the GFX registers in debugfs for debugging. The idea is
borrowed from the Broadcom driver.
OpenBMC-Staging-Count: 1
Signed-off-by: Joel Stanley <joel@jms.id.au>
-rw-r--r-- | drivers/gpu/drm/aspeed/Makefile | 1 | ||||
-rw-r--r-- | drivers/gpu/drm/aspeed/aspeed_gfx.h | 1 | ||||
-rw-r--r-- | drivers/gpu/drm/aspeed/aspeed_gfx_debugfs.c | 77 | ||||
-rw-r--r-- | drivers/gpu/drm/aspeed/aspeed_gfx_drv.c | 4 |
4 files changed, 83 insertions, 0 deletions
diff --git a/drivers/gpu/drm/aspeed/Makefile b/drivers/gpu/drm/aspeed/Makefile index 6e194cd790d8..b01dd5800672 100644 --- a/drivers/gpu/drm/aspeed/Makefile +++ b/drivers/gpu/drm/aspeed/Makefile @@ -1,3 +1,4 @@ aspeed_gfx-y := aspeed_gfx_drv.o aspeed_gfx_crtc.o aspeed_gfx_out.o +aspeed_gfx-$(CONFIG_DEBUG_FS) += aspeed_gfx_debugfs.o obj-$(CONFIG_DRM_ASPEED_GFX) += aspeed_gfx.o diff --git a/drivers/gpu/drm/aspeed/aspeed_gfx.h b/drivers/gpu/drm/aspeed/aspeed_gfx.h index fb56e425bd48..c46afb3398cb 100644 --- a/drivers/gpu/drm/aspeed/aspeed_gfx.h +++ b/drivers/gpu/drm/aspeed/aspeed_gfx.h @@ -17,6 +17,7 @@ struct aspeed_gfx { int aspeed_gfx_create_pipe(struct drm_device *drm); int aspeed_gfx_create_output(struct drm_device *drm); +int aspeed_gfx_debugfs_init(struct drm_minor *minor); #define CRT_CTRL1 0x60 /* CRT Control I */ #define CRT_CTRL2 0x64 /* CRT Control II */ diff --git a/drivers/gpu/drm/aspeed/aspeed_gfx_debugfs.c b/drivers/gpu/drm/aspeed/aspeed_gfx_debugfs.c new file mode 100644 index 000000000000..ac47c27d8e74 --- /dev/null +++ b/drivers/gpu/drm/aspeed/aspeed_gfx_debugfs.c @@ -0,0 +1,77 @@ +// SPDX-License-Identifier: GPL-2.0 +// Copyright © 2017 Broadcom +// Copyright 2018 IBM Corp + +#include <linux/seq_file.h> +#include <drm/drm_debugfs.h> + +#include "aspeed_gfx.h" + +#define REGDEF(reg) { reg, #reg } +static const struct { + u32 reg; + const char *name; +} aspeed_gfx_reg_defs[] = { + REGDEF(CRT_CTRL1), + REGDEF(CRT_CTRL2), + REGDEF(CRT_STATUS), + REGDEF(CRT_MISC), + REGDEF(CRT_HORIZ0), + REGDEF(CRT_HORIZ1), + REGDEF(CRT_VERT0), + REGDEF(CRT_VERT1), + REGDEF(CRT_ADDR), + REGDEF(CRT_OFFSET), + REGDEF(CRT_THROD), + REGDEF(CRT_XSCALE), + REGDEF(CRT_CURSOR0), + REGDEF(CRT_CURSOR1), + REGDEF(CRT_CURSOR2), + REGDEF(CRT_9C), + REGDEF(CRT_OSD_H), + REGDEF(CRT_OSD_V), + REGDEF(CRT_OSD_ADDR), + REGDEF(CRT_OSD_DISP), + REGDEF(CRT_OSD_THRESH), + REGDEF(CRT_B4), + REGDEF(CRT_STS_V), + REGDEF(CRT_SCRATCH), + REGDEF(CRT_BB0_ADDR), + REGDEF(CRT_BB1_ADDR), + REGDEF(CRT_BB_COUNT), + REGDEF(OSD_COLOR1), + REGDEF(OSD_COLOR2), + REGDEF(OSD_COLOR3), + REGDEF(OSD_COLOR4), + REGDEF(OSD_COLOR5), + REGDEF(OSD_COLOR6), + REGDEF(OSD_COLOR7), + REGDEF(OSD_COLOR8), +}; + +int aspeed_gfx_debugfs_regs(struct seq_file *m, void *unused) +{ + struct drm_info_node *node = (struct drm_info_node *)m->private; + struct drm_device *dev = node->minor->dev; + struct aspeed_gfx *priv = dev->dev_private; + int i; + + for (i = 0; i < ARRAY_SIZE(aspeed_gfx_reg_defs); i++) { + seq_printf(m, "%15s (0x%02x): 0x%08x\n", + aspeed_gfx_reg_defs[i].name, aspeed_gfx_reg_defs[i].reg, + readl(priv->base + aspeed_gfx_reg_defs[i].reg)); + } + + return 0; +} + +static const struct drm_info_list aspeed_gfx_debugfs_list[] = { + {"regs", aspeed_gfx_debugfs_regs, 0}, +}; + +int aspeed_gfx_debugfs_init(struct drm_minor *minor) +{ + return drm_debugfs_create_files(aspeed_gfx_debugfs_list, + ARRAY_SIZE(aspeed_gfx_debugfs_list), + minor->debugfs_root, minor); +} diff --git a/drivers/gpu/drm/aspeed/aspeed_gfx_drv.c b/drivers/gpu/drm/aspeed/aspeed_gfx_drv.c index e53d84b97d54..e2db7ddcb53c 100644 --- a/drivers/gpu/drm/aspeed/aspeed_gfx_drv.c +++ b/drivers/gpu/drm/aspeed/aspeed_gfx_drv.c @@ -200,6 +200,10 @@ static struct drm_driver aspeed_gfx_driver = { .date = "20180319", .major = 1, .minor = 0, + +#if defined(CONFIG_DEBUG_FS) + .debugfs_init = aspeed_gfx_debugfs_init, +#endif }; static const struct of_device_id aspeed_gfx_match[] = { |