Commit 1effe5a3 authored by Matt Redfearn's avatar Matt Redfearn Committed by Andrzej Hajda

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: default avatarMatt Redfearn <matt.redfearn@thinci.com>
Tested-by: default avatarYannick Fertré <yannick.fertre@st.com>
Reviewed-by: default avatarPhilippe Cornu <philippe.cornu@st.com>
Signed-off-by: default avatarAndrzej Hajda <a.hajda@samsung.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20190430081646.23845-1-matt.redfearn@thinci.com
parent 0e343b08
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
#include <linux/clk.h> #include <linux/clk.h>
#include <linux/component.h> #include <linux/component.h>
#include <linux/debugfs.h>
#include <linux/iopoll.h> #include <linux/iopoll.h>
#include <linux/module.h> #include <linux/module.h>
#include <linux/of_device.h> #include <linux/of_device.h>
...@@ -89,6 +90,8 @@ ...@@ -89,6 +90,8 @@
#define VID_MODE_TYPE_NON_BURST_SYNC_EVENTS 0x1 #define VID_MODE_TYPE_NON_BURST_SYNC_EVENTS 0x1
#define VID_MODE_TYPE_BURST 0x2 #define VID_MODE_TYPE_BURST 0x2
#define VID_MODE_TYPE_MASK 0x3 #define VID_MODE_TYPE_MASK 0x3
#define VID_MODE_VPG_ENABLE BIT(16)
#define VID_MODE_VPG_HORIZONTAL BIT(24)
#define DSI_VID_PKT_SIZE 0x3c #define DSI_VID_PKT_SIZE 0x3c
#define VID_PKT_SIZE(p) ((p) & 0x3fff) #define VID_PKT_SIZE(p) ((p) & 0x3fff)
...@@ -233,6 +236,13 @@ struct dw_mipi_dsi { ...@@ -233,6 +236,13 @@ struct dw_mipi_dsi {
u32 format; u32 format;
unsigned long mode_flags; unsigned long mode_flags;
#ifdef CONFIG_DEBUG_FS
struct dentry *debugfs;
bool vpg;
bool vpg_horizontal;
#endif /* CONFIG_DEBUG_FS */
struct dw_mipi_dsi *master; /* dual-dsi master ptr */ struct dw_mipi_dsi *master; /* dual-dsi master ptr */
struct dw_mipi_dsi *slave; /* dual-dsi slave ptr */ struct dw_mipi_dsi *slave; /* dual-dsi slave ptr */
...@@ -518,6 +528,13 @@ static void dw_mipi_dsi_video_mode_config(struct dw_mipi_dsi *dsi) ...@@ -518,6 +528,13 @@ static void dw_mipi_dsi_video_mode_config(struct dw_mipi_dsi *dsi)
else else
val |= VID_MODE_TYPE_NON_BURST_SYNC_EVENTS; val |= VID_MODE_TYPE_NON_BURST_SYNC_EVENTS;
#ifdef CONFIG_DEBUG_FS
if (dsi->vpg) {
val |= VID_MODE_VPG_ENABLE;
val |= dsi->vpg_horizontal ? VID_MODE_VPG_HORIZONTAL : 0;
}
#endif /* CONFIG_DEBUG_FS */
dsi_write(dsi, DSI_VID_MODE_CFG, val); dsi_write(dsi, DSI_VID_MODE_CFG, val);
} }
...@@ -930,6 +947,33 @@ static const struct drm_bridge_funcs dw_mipi_dsi_bridge_funcs = { ...@@ -930,6 +947,33 @@ static const struct drm_bridge_funcs dw_mipi_dsi_bridge_funcs = {
.attach = dw_mipi_dsi_bridge_attach, .attach = dw_mipi_dsi_bridge_attach,
}; };
#ifdef CONFIG_DEBUG_FS
static void dw_mipi_dsi_debugfs_init(struct dw_mipi_dsi *dsi)
{
dsi->debugfs = debugfs_create_dir(dev_name(dsi->dev), NULL);
if (IS_ERR(dsi->debugfs)) {
dev_err(dsi->dev, "failed to create debugfs root\n");
return;
}
debugfs_create_bool("vpg", 0660, dsi->debugfs, &dsi->vpg);
debugfs_create_bool("vpg_horizontal", 0660, dsi->debugfs,
&dsi->vpg_horizontal);
}
static void dw_mipi_dsi_debugfs_remove(struct dw_mipi_dsi *dsi)
{
debugfs_remove_recursive(dsi->debugfs);
}
#else
static void dw_mipi_dsi_debugfs_init(struct dw_mipi_dsi *dsi) { }
static void dw_mipi_dsi_debugfs_remove(struct dw_mipi_dsi *dsi) { }
#endif /* CONFIG_DEBUG_FS */
static struct dw_mipi_dsi * static struct dw_mipi_dsi *
__dw_mipi_dsi_probe(struct platform_device *pdev, __dw_mipi_dsi_probe(struct platform_device *pdev,
const struct dw_mipi_dsi_plat_data *plat_data) const struct dw_mipi_dsi_plat_data *plat_data)
...@@ -1000,6 +1044,7 @@ __dw_mipi_dsi_probe(struct platform_device *pdev, ...@@ -1000,6 +1044,7 @@ __dw_mipi_dsi_probe(struct platform_device *pdev,
clk_disable_unprepare(dsi->pclk); clk_disable_unprepare(dsi->pclk);
} }
dw_mipi_dsi_debugfs_init(dsi);
pm_runtime_enable(dev); pm_runtime_enable(dev);
dsi->dsi_host.ops = &dw_mipi_dsi_host_ops; dsi->dsi_host.ops = &dw_mipi_dsi_host_ops;
...@@ -1007,6 +1052,7 @@ __dw_mipi_dsi_probe(struct platform_device *pdev, ...@@ -1007,6 +1052,7 @@ __dw_mipi_dsi_probe(struct platform_device *pdev,
ret = mipi_dsi_host_register(&dsi->dsi_host); ret = mipi_dsi_host_register(&dsi->dsi_host);
if (ret) { if (ret) {
dev_err(dev, "Failed to register MIPI host: %d\n", ret); dev_err(dev, "Failed to register MIPI host: %d\n", ret);
dw_mipi_dsi_debugfs_remove(dsi);
return ERR_PTR(ret); return ERR_PTR(ret);
} }
...@@ -1024,6 +1070,7 @@ static void __dw_mipi_dsi_remove(struct dw_mipi_dsi *dsi) ...@@ -1024,6 +1070,7 @@ static void __dw_mipi_dsi_remove(struct dw_mipi_dsi *dsi)
mipi_dsi_host_unregister(&dsi->dsi_host); mipi_dsi_host_unregister(&dsi->dsi_host);
pm_runtime_disable(dsi->dev); pm_runtime_disable(dsi->dev);
dw_mipi_dsi_debugfs_remove(dsi);
} }
void dw_mipi_dsi_set_slave(struct dw_mipi_dsi *dsi, struct dw_mipi_dsi *slave) void dw_mipi_dsi_set_slave(struct dw_mipi_dsi *dsi, struct dw_mipi_dsi *slave)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment