[PATCH] drm/bridge: ti-sn65dsi83: Add a sysfs entry for the pattern generator

Fabio Estevam festevam at gmail.com
Fri Jul 8 14:00:09 UTC 2022


From: Fabio Estevam <festevam at denx.de>

The sn65dsi83 chip has a test pattern generator capability.

Add a sysfs entry to allow enabling and disabling it in runtime.

This is helpful during the MIPI DSI/LVDS bringup.

To enable the test pattern generator:

echo 1 >  /sys/bus/i2c/devices/0-002c/pattern_generator

To disable the test pattern generator:

echo 0 >  /sys/bus/i2c/devices/0-002c/pattern_generator

Signed-off-by: Fabio Estevam <festevam at denx.de>
---
 drivers/gpu/drm/bridge/ti-sn65dsi83.c | 42 +++++++++++++++++++++++++++
 1 file changed, 42 insertions(+)

diff --git a/drivers/gpu/drm/bridge/ti-sn65dsi83.c b/drivers/gpu/drm/bridge/ti-sn65dsi83.c
index 14e7aa77e758..bb94b3fe9b17 100644
--- a/drivers/gpu/drm/bridge/ti-sn65dsi83.c
+++ b/drivers/gpu/drm/bridge/ti-sn65dsi83.c
@@ -731,6 +731,47 @@ static const struct of_device_id sn65dsi83_match_table[] = {
 };
 MODULE_DEVICE_TABLE(of, sn65dsi83_match_table);
 
+static ssize_t pattern_generator_store(struct device *dev,
+					struct device_attribute *attr,
+					const char *buf, size_t len)
+{
+	struct sn65dsi83 *ctx = dev_get_drvdata(dev);
+	bool arg;
+	int ret;
+
+	ret  = kstrtobool(buf, &arg);
+	if (ret < 0)
+		return ret;
+
+	ret = regmap_write(ctx->regmap, REG_VID_CHA_TEST_PATTERN, arg ? 0x10 : 0x00);
+	if (ret < 0)
+		return ret;
+
+	return len;
+}
+
+static ssize_t pattern_generator_show(struct device *dev,
+				       struct device_attribute *attr, char *buf)
+{
+	struct sn65dsi83 *ctx = dev_get_drvdata(dev);
+	int ret, test_pattern;
+
+	ret = regmap_read(ctx->regmap, REG_VID_CHA_TEST_PATTERN, &test_pattern);
+	if (ret < 0)
+		return ret;
+
+	return sprintf(buf, "%d\n", !!test_pattern);
+}
+
+static DEVICE_ATTR_RW(pattern_generator);
+
+static struct attribute *sn65dsi83_attrs[] = {
+	&dev_attr_pattern_generator.attr,
+	NULL,
+};
+
+ATTRIBUTE_GROUPS(sn65dsi83);
+
 static struct i2c_driver sn65dsi83_driver = {
 	.probe = sn65dsi83_probe,
 	.remove = sn65dsi83_remove,
@@ -738,6 +779,7 @@ static struct i2c_driver sn65dsi83_driver = {
 	.driver = {
 		.name = "sn65dsi83",
 		.of_match_table = sn65dsi83_match_table,
+		.dev_groups = sn65dsi83_groups,
 	},
 };
 module_i2c_driver(sn65dsi83_driver);
-- 
2.25.1



More information about the dri-devel mailing list