Skip to content

Commit 64ac82c

Browse files
Matt Redfearnscpcom
authored andcommitted
drm/bridge/synopsys: dsi: Allow VPG to be enabled via debugfs
The Synopsys MIPI DSI IP contains a video test pattern generator which is helpful in debugging video timing with connected displays. Add a debugfs directory containing files which allow the VPG to be enabled and disabled, and its orientation to be changed. Signed-off-by: Matt Redfearn <matt.redfearn@thinci.com> Tested-by: Yannick Fertré <yannick.fertre@st.com> Reviewed-by: Philippe Cornu <philippe.cornu@st.com> Signed-off-by: Andrzej Hajda <a.hajda@samsung.com> Link: https://patchwork.freedesktop.org/patch/msgid/20190430081646.23845-1-matt.redfearn@thinci.com
1 parent 8c49e81 commit 64ac82c

File tree

1 file changed

+47
-0
lines changed

1 file changed

+47
-0
lines changed

drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
#include <linux/clk.h>
1212
#include <linux/component.h>
13+
#include <linux/debugfs.h>
1314
#include <linux/iopoll.h>
1415
#include <linux/module.h>
1516
#include <linux/of_device.h>
@@ -86,6 +87,8 @@
8687
#define VID_MODE_TYPE_NON_BURST_SYNC_EVENTS 0x1
8788
#define VID_MODE_TYPE_BURST 0x2
8889
#define VID_MODE_TYPE_MASK 0x3
90+
#define VID_MODE_VPG_ENABLE BIT(16)
91+
#define VID_MODE_VPG_HORIZONTAL BIT(24)
8992

9093
#define DSI_VID_PKT_SIZE 0x3c
9194
#define VID_PKT_SIZE(p) ((p) & 0x3fff)
@@ -230,6 +233,13 @@ struct dw_mipi_dsi {
230233
u32 format;
231234
unsigned long mode_flags;
232235

236+
#ifdef CONFIG_DEBUG_FS
237+
struct dentry *debugfs;
238+
239+
bool vpg;
240+
bool vpg_horizontal;
241+
#endif /* CONFIG_DEBUG_FS */
242+
233243
struct dw_mipi_dsi *master; /* dual-dsi master ptr */
234244
struct dw_mipi_dsi *slave; /* dual-dsi slave ptr */
235245

@@ -515,6 +525,13 @@ static void dw_mipi_dsi_video_mode_config(struct dw_mipi_dsi *dsi)
515525
else
516526
val |= VID_MODE_TYPE_NON_BURST_SYNC_EVENTS;
517527

528+
#ifdef CONFIG_DEBUG_FS
529+
if (dsi->vpg) {
530+
val |= VID_MODE_VPG_ENABLE;
531+
val |= dsi->vpg_horizontal ? VID_MODE_VPG_HORIZONTAL : 0;
532+
}
533+
#endif /* CONFIG_DEBUG_FS */
534+
518535
dsi_write(dsi, DSI_VID_MODE_CFG, val);
519536
}
520537

@@ -938,6 +955,33 @@ static const struct drm_bridge_funcs dw_mipi_dsi_bridge_funcs = {
938955
.attach = dw_mipi_dsi_bridge_attach,
939956
};
940957

958+
#ifdef CONFIG_DEBUG_FS
959+
960+
static void dw_mipi_dsi_debugfs_init(struct dw_mipi_dsi *dsi)
961+
{
962+
dsi->debugfs = debugfs_create_dir(dev_name(dsi->dev), NULL);
963+
if (IS_ERR(dsi->debugfs)) {
964+
dev_err(dsi->dev, "failed to create debugfs root\n");
965+
return;
966+
}
967+
968+
debugfs_create_bool("vpg", 0660, dsi->debugfs, &dsi->vpg);
969+
debugfs_create_bool("vpg_horizontal", 0660, dsi->debugfs,
970+
&dsi->vpg_horizontal);
971+
}
972+
973+
static void dw_mipi_dsi_debugfs_remove(struct dw_mipi_dsi *dsi)
974+
{
975+
debugfs_remove_recursive(dsi->debugfs);
976+
}
977+
978+
#else
979+
980+
static void dw_mipi_dsi_debugfs_init(struct dw_mipi_dsi *dsi) { }
981+
static void dw_mipi_dsi_debugfs_remove(struct dw_mipi_dsi *dsi) { }
982+
983+
#endif /* CONFIG_DEBUG_FS */
984+
941985
static struct dw_mipi_dsi *
942986
__dw_mipi_dsi_probe(struct platform_device *pdev,
943987
const struct dw_mipi_dsi_plat_data *plat_data)
@@ -1009,13 +1053,15 @@ __dw_mipi_dsi_probe(struct platform_device *pdev,
10091053
clk_disable_unprepare(dsi->pclk);
10101054
}
10111055

1056+
dw_mipi_dsi_debugfs_init(dsi);
10121057
pm_runtime_enable(dev);
10131058

10141059
dsi->dsi_host.ops = &dw_mipi_dsi_host_ops;
10151060
dsi->dsi_host.dev = dev;
10161061
ret = mipi_dsi_host_register(&dsi->dsi_host);
10171062
if (ret) {
10181063
dev_err(dev, "Failed to register MIPI host: %d\n", ret);
1064+
dw_mipi_dsi_debugfs_remove(dsi);
10191065
return ERR_PTR(ret);
10201066
}
10211067

@@ -1031,6 +1077,7 @@ __dw_mipi_dsi_probe(struct platform_device *pdev,
10311077
static void __dw_mipi_dsi_remove(struct dw_mipi_dsi *dsi)
10321078
{
10331079
pm_runtime_disable(dsi->dev);
1080+
dw_mipi_dsi_debugfs_remove(dsi);
10341081
}
10351082

10361083
void dw_mipi_dsi_set_slave(struct dw_mipi_dsi *dsi, struct dw_mipi_dsi *slave)

0 commit comments

Comments
 (0)