Skip to contentSkip to conversation

Add ti948 and ti949 display bridge drivers

PATCH In review Michael Drake 2 participants 22 messages Jun 11, 2019 – Jul 12, 2019

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

cover Add ti948 and ti949 display bridge drivers

This patch series adds support for the ti948 and ti949 display bridge devices. They are both regmap i2c device drivers.

The ti949 converts HDMI video signals to FPD-Link III. The ti948 converts FPD-Link III video signals to OpenLDI.

The drivers support PM suspend/resume, and rely on device tree / ACPI nodes to set up any device dependency chain. (ACPI requiring the special DT namespace link device ID, PRP0001.) The unified device properties API is used to get board-specific config from device tree / ACPI.

Cc Patrick Glaser <[email protected]>
Cc Nate Case <[email protected]>

Michael Drake (11):
dt-bindings: display/bridge: Add bindings for ti948
ti948: i2c device driver for TI DS90UB948-Q1
dt-bindings: display/bridge: Add config property for ti948
ti948: Add support for configuration via device properties
ti948: Add alive check function using schedule_delayed_work()
ti948: Reconfigure in the alive check when device returns
ti948: Add sysfs node for alive attribute
dt-bindings: display/bridge: Add bindings for ti949
ti949: i2c device driver for TI DS90UB949-Q1
dt-bindings: display/bridge: Add config property for ti949
ti949: Add support for configuration via device properties

 .../bindings/display/bridge/ti,ds90ub948.txt  |  45 ++
 .../bindings/display/bridge/ti,ds90ub949.txt  |  37 +
 drivers/gpu/drm/bridge/Kconfig                |  16 +
 drivers/gpu/drm/bridge/Makefile               |   2 +
 drivers/gpu/drm/bridge/ti948.c                | 689 ++++++++++++++++++
 drivers/gpu/drm/bridge/ti949.c                | 631 ++++++++++++++++
 6 files changed, 1420 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/display/bridge/ti,ds90ub948.txt
 create mode 100644 Documentation/devicetree/bindings/display/bridge/ti,ds90ub949.txt
 create mode 100644 drivers/gpu/drm/bridge/ti948.c
 create mode 100644 drivers/gpu/drm/bridge/ti949.c
Signature · 1 line
2.20.1
#1 lore raw

PATCH 1/11 dt-bindings: display/bridge: Add bindings for ti948

Adds device tree bindings for:

TI DS90UB948-Q1 2K FPD-Link III to OpenLDI Deserializer

The device has the compatible string "ti,ds90ub948", and and allows an arrray of strings to be provided as regulator names to enable for operation of the device.

Cc Patrick Glaser <[email protected]>
Cc Nate Case <[email protected]>
---
 .../bindings/display/bridge/ti,ds90ub948.txt  | 24 +++++++++++++++++++
 1 file changed, 24 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/display/bridge/ti,ds90ub948.txt
Documentation/devicetree/bindings/display/bridge/ti,ds90ub948.txt new file +24 -0
new file mode 100644
index 000000000000..f9e86cb22900
@@ -0,0 +1,24 @@
+TI DS90UB948-Q1 2K FPD-Link III to OpenLDI Deserializer
+=======================================================
+
+This is the binding for Texas Instruments DS90UB948-Q1 bridge deserializer.
+
+This device supports I2C only.
+
+Required properties:
+
+- compatible: "ti,ds90ub948"
+
+Optional properties:
+
+- regulators: List of regulator name strings to enable for operation of device.
+
+Example
+-------
+
+ti948: ds90ub948@0 {
+	compatible = "ti,ds90ub948";
+
+	regulators: "vcc",
+	            "vcc_disp";
+};
Signature · 1 line
2.20.1
#4 lore raw

PATCH 2/11 ti948: i2c device driver for TI DS90UB948-Q1

In reply to Michael Drake

This is a regmap i2c device driver for:

TI DS90UB948-Q1 2K FPD-Link III to OpenLDI Deserializer

It supports instantiation via device tree / ACPI table.

A list of regulators to enable for use of the device (e.g. GPIOs for turning on power) may be provided as device tree properties. These are enabled on probe and PM resume. They are disabled on remove and PM suspend.

Datasheet: http://www.ti.com/lit/ds/symlink/ds90ub948-q1.pdf

Cc Patrick Glaser <[email protected]>
Cc Nate Case <[email protected]>
---
 drivers/gpu/drm/bridge/Kconfig  |   8 +
 drivers/gpu/drm/bridge/Makefile |   1 +
 drivers/gpu/drm/bridge/ti948.c  | 509 ++++++++++++++++++++++++++++++++
 3 files changed, 518 insertions(+)
 create mode 100644 drivers/gpu/drm/bridge/ti948.c
drivers/gpu/drm/bridge/Kconfig +8 -0
index ee777469293a..149692dc8d48 100644
@@ -81,6 +81,14 @@ config DRM_PARADE_PS8622
 	---help---
 	  Parade eDP-LVDS bridge chip driver.
 
+config DRM_TI948
+	tristate "TI DS90UB948-Q1 FPD-Link III to OpenLDI Deserializer"
+	select DRM_KMS_HELPER
+	select REGMAP_I2C
+	help
+	  This is a driver for the TI DS90UB948-Q1 device.
+	  It converts video signals from FPD-Link III to OpenLDI.
+
 config DRM_SIL_SII8620
 	tristate "Silicon Image SII8620 HDMI/MHL bridge"
 	depends on OF
drivers/gpu/drm/bridge/Makefile +1 -0
index 4934fcf5a6f8..3fb37bbe10e1 100644
@@ -6,6 +6,7 @@ obj-$(CONFIG_DRM_LVDS_ENCODER) += lvds-encoder.o
 obj-$(CONFIG_DRM_MEGACHIPS_STDPXXXX_GE_B850V3_FW) += megachips-stdpxxxx-ge-b850v3-fw.o
 obj-$(CONFIG_DRM_NXP_PTN3460) += nxp-ptn3460.o
 obj-$(CONFIG_DRM_PARADE_PS8622) += parade-ps8622.o
+obj-$(CONFIG_DRM_TI948) += ti948.o
 obj-$(CONFIG_DRM_SIL_SII8620) += sil-sii8620.o
 obj-$(CONFIG_DRM_SII902X) += sii902x.o
 obj-$(CONFIG_DRM_SII9234) += sii9234.o
drivers/gpu/drm/bridge/ti948.c new file +509 -0

509 lines not on this page · raw message

Signature · 1 line
2.20.1
#5 lore raw

PATCH 3/11 dt-bindings: display/bridge: Add config property for ti948

In reply to Michael Drake

The config property can be used to provide an array of register addresses and values to be written to configure the device for the board.

Cc Patrick Glaser <[email protected]>
Cc Nate Case <[email protected]>
---
 .../bindings/display/bridge/ti,ds90ub948.txt  | 21 +++++++++++++++++++
 1 file changed, 21 insertions(+)
Documentation/devicetree/bindings/display/bridge/ti,ds90ub948.txt +21 -0
index f9e86cb22900..1e7033b0f3b7 100644
@@ -12,6 +12,8 @@ Required properties:
 Optional properties:
 
 - regulators: List of regulator name strings to enable for operation of device.
+- config: List of <register address>,<value> pairs to be set to configure
+  device on powerup.  The register addresses and values are 8bit.
 
 Example
 -------
@@ -21,4 +23,23 @@ ti948: ds90ub948@0 {
 
 	regulators: "vcc",
 	            "vcc_disp";
+	config:
+	        /* set error count to max */
+	        <0x41>, <0x1f>,
+	        /* sets output mode, no change noticed */
+	        <0x49>, <0xe0>,
+	        /* speed up I2C, 0xE is around 480KHz */
+	        <0x26>, <0x0e>,
+	        /* speed up I2C, 0xE is around 480KHz */
+	        <0x27>, <0x0e>,
+	        /* sets GPIO0 as an input */
+	        <0x1D>, <0x13>,
+	        /* set GPIO2 high, backlight PWM (set to 0x50 for normal use) */
+	        <0x1E>, <0x50>,
+	        /* sets GPIO3 as an output with remote control for touch XRES */
+	        <0x1F>, <0x05>,
+	        /* set GPIO5 high, backlight enable on new display */
+	        <0x20>, <0x09>,
+	        /* set GPIO7 and GPIO8 high to enable touch power and prox sense */
+	        <0x21>, <0x91>;
 };
Signature · 1 line
2.20.1
#8 lore raw

PATCH 4/11 ti948: Add support for configuration via device properties

In reply to Michael Drake

This allows the device to be configured for the board in device tree, or in ACPI tables. The device node properties can provide an array of register addresses and values to be written to configure the device for the board.

The config is written to the device on probe and on PM resume.

Cc Patrick Glaser <[email protected]>
Cc Nate Case <[email protected]>
---
 drivers/gpu/drm/bridge/ti948.c | 106 ++++++++++++++++++++++++++++++++-
 1 file changed, 105 insertions(+), 1 deletion(-)
drivers/gpu/drm/bridge/ti948.c +105 -1
index c22252036bbe..9cb37215f049 100644
@@ -19,6 +19,7 @@
 #include <linux/module.h>
 #include <linux/regmap.h>
 #include <linux/delay.h>
+#include <linux/slab.h>
 #include <linux/i2c.h>
 
 /* Number of times to try checking for device on bringup. */
@@ -122,6 +123,8 @@ struct ti948_reg_val {
  * struct ti948_ctx - ti948 driver context
  * @i2c:         Handle for the device's i2c client.
  * @regmap:      Handle for the device's regmap.
+ * @config:      Array of register values loaded from device properties.
+ * @config_len:  Number of entries in config.
  * @reg_names:   Array of regulator names, or NULL.
  * @regs:        Array of regulators, or NULL.
  * @reg_count:   Number of entries in reg_names and regs arrays.
@@ -129,6 +132,8 @@ struct ti948_reg_val {
 struct ti948_ctx {
 	struct i2c_client *i2c;
 	struct regmap *regmap;
+	struct ti948_reg_val *config;
+	size_t config_len;
 	const char **reg_names;
 	struct regulator **regs;
 	size_t reg_count;
@@ -212,6 +217,42 @@ static const struct regmap_config ti948_regmap_config = {
 	.writeable_reg = ti948_writeable_reg,
 };
 
+static int ti948_write_sequence(
+		struct ti948_ctx *ti948,
+		const struct ti948_reg_val *sequence,
+		u32 entries)
+{
+	int i;
+
+	for (i = 0; i < entries; i++) {
+		const struct ti948_reg_val *r = sequence + i;
+		int ret = regmap_write(ti948->regmap, r->addr, r->value);
+
+		if (ret < 0)
+			return ret;
+	}
+
+	return 0;
+}
+
+static int ti948_write_config_seq(struct ti948_ctx *ti948)
+{
+	int ret;
+
+	if (ti948->config == NULL) {
+		dev_info(&ti948->i2c->dev, "No config for ti948 device\n");
+		return 0;
+	}
+
+	ret = ti948_write_sequence(ti948, ti948->config, ti948->config_len);
+	if (ret < 0)
+		return ret;
+
+	dev_info(&ti948->i2c->dev, "Successfully configured ti948\n");
+
+	return ret;
+}
+
 static inline u8 ti948_device_address(struct ti948_ctx *ti948)
 {
 	return ti948->i2c->addr;
@@ -345,7 +386,7 @@ static int ti948_pm_resume(struct device *dev)
 	if (ret != 0)
 		return ret;
 
-	return 0;
+	return ti948_write_config_seq(ti948);
 }
 
 static int ti948_pm_suspend(struct device *dev)
@@ -434,6 +475,65 @@ static int ti948_get_regulators(struct ti948_ctx *ti948)
 	return 0;
 }
 
+static int ti948_get_config(struct ti948_ctx *ti948)
+{
+	int i;
+	int ret;
+	u8 *config;
+	size_t config_len;
+
+	ret = device_property_read_u8_array(&ti948->i2c->dev,
+			"config", NULL, 0);
+	if (ret == -EINVAL ||
+	    ret == -ENODATA ||
+	    ret == 0) {
+		/* "config" property was either:
+		 *   - unset
+		 *   - valueless
+		 *   - set to empty list
+		 * Not an error; continue without config.
+		 */
+		dev_info(&ti948->i2c->dev, "No config defined for device.\n");
+		return 0;
+
+	} else if (ret < 0) {
+		return ret;
+	} else if (ret & 0x1) {
+		dev_err(&ti948->i2c->dev,
+			"Device property 'config' needs even entry count.\n");
+		return -EINVAL;
+	}
+
+	config_len = ret;
+
+	config = kmalloc_array(config_len, sizeof(*config), GFP_KERNEL);
+	if (!config)
+		return -ENOMEM;
+
+	ret = device_property_read_u8_array(&ti948->i2c->dev, "config",
+			config, config_len);
+	if (ret < 0) {
+		kfree(config);
+		return ret;
+	}
+
+	ti948->config = devm_kmalloc_array(&ti948->i2c->dev,
+			config_len / 2, sizeof(*ti948->config), GFP_KERNEL);
+	if (!ti948->config) {
+		kfree(config);
+		return -ENOMEM;
+	}
+
+	ti948->config_len = config_len / 2;
+	for (i = 0; i < config_len; i += 2) {
+		ti948->config[i / 2].addr = config[i];
+		ti948->config[i / 2].value = config[i + 1];
+	}
+	kfree(config);
+
+	return 0;
+}
+
 static int ti948_probe(struct i2c_client *client,
 		const struct i2c_device_id *id)
 {
@@ -456,6 +556,10 @@ static int ti948_probe(struct i2c_client *client,
 	if (ret != 0)
 		return ret;
 
+	ret = ti948_get_config(ti948);
+	if (ret != 0)
+		return ret;
+
 	i2c_set_clientdata(client, ti948);
 
 	ret = ti948_pm_resume(&client->dev);
Signature · 1 line
2.20.1
#9 lore raw

PATCH 5/11 ti948: Add alive check function using schedule_delayed_work()

In reply to Michael Drake

This simply runs the function once every 5 seconds, while the device is supposed to be active. The alive check function is currently simply a stub, that logs it has been called, and re-inserts itself into the work queue.

Cc Patrick Glaser <[email protected]>
Cc Nate Case <[email protected]>
---
 drivers/gpu/drm/bridge/ti948.c | 37 +++++++++++++++++++++++++++++++++-
 1 file changed, 36 insertions(+), 1 deletion(-)
drivers/gpu/drm/bridge/ti948.c +36 -1
index 9cb37215f049..86daa3701b91 100644
@@ -16,6 +16,7 @@
 
 #include <linux/regulator/consumer.h>
 #include <linux/of_device.h>
+#include <linux/workqueue.h>
 #include <linux/module.h>
 #include <linux/regmap.h>
 #include <linux/delay.h>
@@ -25,6 +26,9 @@
 /* Number of times to try checking for device on bringup. */
 #define TI948_DEVICE_ID_TRIES 10
 
+/* Alive check every 5 seconds. */
+#define TI948_ALIVE_CHECK_DELAY (5 * HZ)
+
 /**
  * enum ti948_reg - TI948 registers.
  *
@@ -374,9 +378,27 @@ static inline struct ti948_ctx *ti948_ctx_from_dev(struct device *dev)
 	return i2c_get_clientdata(client);
 }
 
+static inline struct ti948_ctx *delayed_work_to_ti948_ctx(
+		struct delayed_work *dwork)
+{
+	return container_of(dwork, struct ti948_ctx, alive_check);
+}
+
+static void ti948_alive_check(struct work_struct *work)
+{
+	struct delayed_work *dwork = to_delayed_work(work);
+	struct ti948_ctx *ti948 = delayed_work_to_ti948_ctx(dwork);
+
+	dev_info(&ti948->i2c->dev, "%s Alive check!\n", __func__);
+
+	/* Reschedule ourself for the next check. */
+	schedule_delayed_work(&ti948->alive_check, TI948_ALIVE_CHECK_DELAY);
+}
+
 static int ti948_pm_resume(struct device *dev)
 {
 	struct ti948_ctx *ti948 = ti948_ctx_from_dev(dev);
+	bool scheduled;
 	int ret;
 
 	if (ti948 == NULL)
@@ -386,7 +408,18 @@ static int ti948_pm_resume(struct device *dev)
 	if (ret != 0)
 		return ret;
 
-	return ti948_write_config_seq(ti948);
+	ret = ti948_write_config_seq(ti948);
+	if (ret != 0)
+		return ret;
+
+	INIT_DELAYED_WORK(&ti948->alive_check, ti948_alive_check);
+
+	scheduled = schedule_delayed_work(
+			&ti948->alive_check, TI948_ALIVE_CHECK_DELAY);
+	if (!scheduled)
+		dev_warn(&ti948->i2c->dev, "Alive check already scheduled\n");
+
+	return 0;
 }
 
 static int ti948_pm_suspend(struct device *dev)
@@ -396,6 +429,8 @@ static int ti948_pm_suspend(struct device *dev)
 	if (ti948 == NULL)
 		return 0;
 
+	cancel_delayed_work_sync(&ti948->alive_check);
+
 	return ti948_power_off(ti948);
 }
 
Signature · 1 line
2.20.1
#10 lore raw

PATCH 6/11 ti948: Reconfigure in the alive check when device returns

In reply to Michael Drake

If the alive check detects a transition to the alive state, the device configuration is rewritten.

Cc Patrick Glaser <[email protected]>
Cc Nate Case <[email protected]>
---
 drivers/gpu/drm/bridge/ti948.c | 19 ++++++++++++++++++-
 1 file changed, 18 insertions(+), 1 deletion(-)
drivers/gpu/drm/bridge/ti948.c +18 -1
index 86daa3701b91..b5c766711c4b 100644
@@ -132,6 +132,8 @@ struct ti948_reg_val {
  * @reg_names:   Array of regulator names, or NULL.
  * @regs:        Array of regulators, or NULL.
  * @reg_count:   Number of entries in reg_names and regs arrays.
+ * @alive_check: Context for the alive checking work item.
+ * @alive:       Whether the device is alive or not (alive_check).
  */
 struct ti948_ctx {
 	struct i2c_client *i2c;
@@ -141,6 +143,8 @@ struct ti948_ctx {
 	const char **reg_names;
 	struct regulator **regs;
 	size_t reg_count;
+	struct delayed_work alive_check;
+	bool alive;
 };
 
 static bool ti948_readable_reg(struct device *dev, unsigned int reg)
@@ -346,6 +350,8 @@ static int ti948_power_on(struct ti948_ctx *ti948)
 	if (ret != 0)
 		return ret;
 
+	ti948->alive = true;
+
 	msleep(500);
 
 	return 0;
@@ -356,6 +362,8 @@ static int ti948_power_off(struct ti948_ctx *ti948)
 	int i;
 	int ret;
 
+	ti948->alive = false;
+
 	for (i = ti948->reg_count; i > 0; i--) {
 		dev_info(&ti948->i2c->dev, "Disabling %s regulator\n",
 				ti948->reg_names[i - 1]);
@@ -388,8 +396,17 @@ static void ti948_alive_check(struct work_struct *work)
 {
 	struct delayed_work *dwork = to_delayed_work(work);
 	struct ti948_ctx *ti948 = delayed_work_to_ti948_ctx(dwork);
+	int ret = ti948_device_check(ti948);
 
-	dev_info(&ti948->i2c->dev, "%s Alive check!\n", __func__);
+	if (ti948->alive == false && ret == 0) {
+		dev_info(&ti948->i2c->dev, "Device has come back to life!\n");
+		ti948_write_config_seq(ti948);
+		ti948->alive = true;
+
+	} else if (ti948->alive == true && ret != 0) {
+		dev_info(&ti948->i2c->dev, "Device has stopped responding\n");
+		ti948->alive = false;
+	}
 
 	/* Reschedule ourself for the next check. */
 	schedule_delayed_work(&ti948->alive_check, TI948_ALIVE_CHECK_DELAY);
Signature · 1 line
2.20.1
#13 lore raw

PATCH 7/11 ti948: Add sysfs node for alive attribute

In reply to Michael Drake

This may be used by userspace to determine the state of the device.

Cc Patrick Glaser <[email protected]>
Cc Nate Case <[email protected]>
---
 drivers/gpu/drm/bridge/ti948.c | 28 ++++++++++++++++++++++++++--
 1 file changed, 26 insertions(+), 2 deletions(-)
drivers/gpu/drm/bridge/ti948.c +26 -2
index b5c766711c4b..b624eaeabb43 100644
@@ -412,6 +412,16 @@ static void ti948_alive_check(struct work_struct *work)
 	schedule_delayed_work(&ti948->alive_check, TI948_ALIVE_CHECK_DELAY);
 }
 
+static ssize_t alive_show(struct device *dev,
+		struct device_attribute *attr, char *buf)
+{
+	struct ti948_ctx *ti948 = ti948_ctx_from_dev(dev);
+
+	return scnprintf(buf, PAGE_SIZE, "%u\n", (unsigned int)ti948->alive);
+}
+
+static DEVICE_ATTR_RO(alive);
+
 static int ti948_pm_resume(struct device *dev)
 {
 	struct ti948_ctx *ti948 = ti948_ctx_from_dev(dev);
@@ -614,17 +624,31 @@ static int ti948_probe(struct i2c_client *client,
 
 	i2c_set_clientdata(client, ti948);
 
+	ret = device_create_file(&client->dev, &dev_attr_alive);
+	if (ret) {
+		dev_err(&client->dev, "Could not create alive attr\n");
+		return ret;
+	}
+
 	ret = ti948_pm_resume(&client->dev);
-	if (ret != 0)
-		return -EPROBE_DEFER;
+	if (ret != 0) {
+		ret = -EPROBE_DEFER;
+		goto error;
+	}
 
 	dev_info(&ti948->i2c->dev, "End probe (addr: %x)\n", ti948->i2c->addr);
 
 	return 0;
+
+error:
+	device_remove_file(&client->dev, &dev_attr_alive);
+	return ret;
 }
 
 static int ti948_remove(struct i2c_client *client)
 {
+	device_remove_file(&client->dev, &dev_attr_alive);
+
 	return ti948_pm_suspend(&client->dev);
 }
 
Signature · 1 line
2.20.1
#16 lore raw

PATCH 8/11 dt-bindings: display/bridge: Add bindings for ti949

In reply to Michael Drake

Adds device tree bindings for:

TI DS90UB949-Q1 1080p HDMI to FPD-Link III bridge serializer

It supports instantiation via device tree / ACPI table.

The device has the compatible string "ti,ds90ub949", and and allows an arrray of strings to be provided as regulator names to enable for operation of the device.

Cc Patrick Glaser <[email protected]>
Cc Nate Case <[email protected]>
---
 .../bindings/display/bridge/ti,ds90ub949.txt  | 24 +++++++++++++++++++
 1 file changed, 24 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/display/bridge/ti,ds90ub949.txt
Documentation/devicetree/bindings/display/bridge/ti,ds90ub949.txt new file +24 -0
new file mode 100644
index 000000000000..3ba3897d5e81
@@ -0,0 +1,24 @@
+TI DS90UB949-Q1 1080p HDMI to FPD-Link III bridge serializer
+============================================================
+
+This is the binding for Texas Instruments DS90UB949-Q1 bridge serializer.
+
+This device supports I2C only.
+
+Required properties:
+
+- compatible: "ti,ds90ub949"
+
+Optional properties:
+
+- regulators: List of regulator name strings to enable for operation of device.
+
+Example
+-------
+
+ti949: ds90ub949@0 {
+	compatible = "ti,ds90ub949";
+
+	regulators: "vcc",
+	            "vcc_hdmi";
+};
Signature · 1 line
2.20.1
#19 lore raw

PATCH 9/11 ti949: i2c device driver for TI DS90UB949-Q1

In reply to Michael Drake

This is a regmap i2c device driver for:

TI DS90UB949-Q1 1080p HDMI to FPD-Link III bridge serializer

It supports instantiation via device tree / ACPI table.

A list of regulators to enable for use of the device (e.g. GPIOs for turning on power) may be provided as device tree properties. These are enabled on probe and PM resume. They are disabled on remove and PM suspend.

Datasheet: http://www.ti.com/lit/ds/symlink/ds90ub949-q1.pdf

Cc Patrick Glaser <[email protected]>
Cc Nate Case <[email protected]>
---
 drivers/gpu/drm/bridge/Kconfig  |   8 +
 drivers/gpu/drm/bridge/Makefile |   1 +
 drivers/gpu/drm/bridge/ti949.c  | 511 ++++++++++++++++++++++++++++++++
 3 files changed, 520 insertions(+)
 create mode 100644 drivers/gpu/drm/bridge/ti949.c
drivers/gpu/drm/bridge/Kconfig +8 -0
index 149692dc8d48..fbc0eddda8f0 100644
@@ -89,6 +89,14 @@ config DRM_TI948
 	  This is a driver for the TI DS90UB948-Q1 device.
 	  It converts video signals from FPD-Link III to OpenLDI.
 
+config DRM_TI949
+	tristate "TI DS90UB949-Q1 1080p HDMI to FPD-Link III bridge serializer"
+	select DRM_KMS_HELPER
+	select REGMAP_I2C
+	help
+	  This is a driver for the TI DS90UB949-Q1 device.
+	  It converts video signals from HDMI to FPD-Link III.
+
 config DRM_SIL_SII8620
 	tristate "Silicon Image SII8620 HDMI/MHL bridge"
 	depends on OF
drivers/gpu/drm/bridge/Makefile +1 -0
index 3fb37bbe10e1..1788b5efe234 100644
@@ -7,6 +7,7 @@ obj-$(CONFIG_DRM_MEGACHIPS_STDPXXXX_GE_B850V3_FW) += megachips-stdpxxxx-ge-b850v
 obj-$(CONFIG_DRM_NXP_PTN3460) += nxp-ptn3460.o
 obj-$(CONFIG_DRM_PARADE_PS8622) += parade-ps8622.o
 obj-$(CONFIG_DRM_TI948) += ti948.o
+obj-$(CONFIG_DRM_TI949) += ti949.o
 obj-$(CONFIG_DRM_SIL_SII8620) += sil-sii8620.o
 obj-$(CONFIG_DRM_SII902X) += sii902x.o
 obj-$(CONFIG_DRM_SII9234) += sii9234.o
drivers/gpu/drm/bridge/ti949.c new file +511 -0

511 lines not on this page · raw message

Signature · 1 line
2.20.1
#20 lore raw

PATCH 10/11 dt-bindings: display/bridge: Add config property for ti949

In reply to Michael Drake

The config property can be used to provide an array of register addresses and values to be written to configure the device for the board.

Cc Patrick Glaser <[email protected]>
Cc Nate Case <[email protected]>
---
 .../bindings/display/bridge/ti,ds90ub949.txt        | 13 +++++++++++++
 1 file changed, 13 insertions(+)
Documentation/devicetree/bindings/display/bridge/ti,ds90ub949.txt +13 -0
index 3ba3897d5e81..b1e38d732f17 100644
@@ -12,6 +12,8 @@ Required properties:
 Optional properties:
 
 - regulators: List of regulator name strings to enable for operation of device.
+- config: List of <register address>,<value> pairs to be set to configure
+  device on powerup.  The register addresses and values are 8bit.
 
 Example
 -------
@@ -21,4 +23,15 @@ ti949: ds90ub949@0 {
 
 	regulators: "vcc",
 	            "vcc_hdmi";
+	config:
+	        /* GPIO0 is an output with remote value */
+	        <0x0D>, <0x25>,
+	        /* GPIO3 is an input for XRES */
+	        <0x0F>, <0x03>,
+	        /* GPIO2 is an input for backlight PWM */
+	        <0x0E>, <0x30>,
+	        /* Enables forward channel I2C pass through */
+	        <0x17>, <0x9e>,
+	        /* Enables PORT1 registers I2C access */
+	        <0x1E>, <0x04>;
 };
Signature · 1 line
2.20.1
#21 lore raw

PATCH 11/11 ti949: Add support for configuration via device properties

In reply to Michael Drake

This allows the device to be configured for the board in device tree, or in ACPI tables. The device node properties can provide an array of register addresses and values to be written to configure the device for the board.

The config is written to the device on probe and on PM resume.

Cc Patrick Glaser <[email protected]>
Cc Nate Case <[email protected]>
---
 drivers/gpu/drm/bridge/ti949.c | 120 +++++++++++++++++++++++++++++++++
 1 file changed, 120 insertions(+)
drivers/gpu/drm/bridge/ti949.c +120 -0
index 04618ca5f25e..57dcecd10ace 100644
@@ -19,6 +19,7 @@
 #include <linux/module.h>
 #include <linux/regmap.h>
 #include <linux/delay.h>
+#include <linux/slab.h>
 #include <linux/i2c.h>
 
 /* Number of times to try checking for device on bringup. */
@@ -127,10 +128,22 @@ enum ti949_reg {
 	TI949_REG_TX_ID_5                               = 0xF5,
 };
 
+/**
+ * struct ti949_reg_val - ti949 register value
+ * @addr:     The address of the register
+ * @value:    The initial value of the register
+ */
+struct ti949_reg_val {
+	u8 addr;
+	u8 value;
+};
+
 /**
  * struct ti949_ctx - ti949 driver context
  * @i2c:         Handle for the device's i2c client.
  * @regmap:      Handle for the device's regmap.
+ * @config:      Array of register values loaded from device properties.
+ * @config_len:  Number of entries in config.
  * @reg_names:   Array of regulator names, or NULL.
  * @regs:        Array of regulators, or NULL.
  * @reg_count:   Number of entries in reg_names and regs arrays.
@@ -138,6 +151,8 @@ enum ti949_reg {
 struct ti949_ctx {
 	struct i2c_client *i2c;
 	struct regmap *regmap;
+	struct ti949_reg_val *config;
+	size_t config_len;
 	const char **reg_names;
 	struct regulator **regs;
 	size_t reg_count;
@@ -214,6 +229,42 @@ static const struct regmap_config ti949_regmap_config = {
 	.writeable_reg = ti949_writeable_reg,
 };
 
+static int ti949_write_sequence(
+		struct ti949_ctx *ti949,
+		const struct ti949_reg_val *sequence,
+		u32 entries)
+{
+	int i;
+
+	for (i = 0; i < entries; i++) {
+		const struct ti949_reg_val *r = sequence + i;
+		int ret = regmap_write(ti949->regmap, r->addr, r->value);
+
+		if (ret < 0)
+			return ret;
+	}
+
+	return 0;
+}
+
+static int ti949_write_config_seq(struct ti949_ctx *ti949)
+{
+	int ret;
+
+	if (ti949->config == NULL) {
+		dev_info(&ti949->i2c->dev, "No config for ti949 device\n");
+		return 0;
+	}
+
+	ret = ti949_write_sequence(ti949, ti949->config, ti949->config_len);
+	if (ret < 0)
+		return ret;
+
+	dev_info(&ti949->i2c->dev, "Successfully configured ti949\n");
+
+	return ret;
+}
+
 static inline u8 ti949_device_address(struct ti949_ctx *ti949)
 {
 	return ti949->i2c->addr;
@@ -347,6 +398,12 @@ static int ti949_pm_resume(struct device *dev)
 	if (ret != 0)
 		return ret;
 
+	ret = ti949_write_config_seq(ti949);
+	if (ret != 0)
+		return ret;
+
+	/* Extend 200ms after ti949 init for display HW tolerance. */
+	msleep(200);
 	return 0;
 }
 
@@ -436,6 +493,65 @@ static int ti949_get_regulators(struct ti949_ctx *ti949)
 	return 0;
 }
 
+static int ti949_get_config(struct ti949_ctx *ti949)
+{
+	int i;
+	int ret;
+	u8 *config;
+	size_t config_len;
+
+	ret = device_property_read_u8_array(&ti949->i2c->dev,
+			"config", NULL, 0);
+	if (ret == -EINVAL ||
+	    ret == -ENODATA ||
+	    ret == 0) {
+		/* "config" property was either:
+		 *   - unset
+		 *   - valueless
+		 *   - set to empty list
+		 * Not an error; continue without config.
+		 */
+		dev_info(&ti949->i2c->dev, "No config defined for device.\n");
+		return 0;
+
+	} else if (ret < 0) {
+		return ret;
+	} else if (ret & 0x1) {
+		dev_err(&ti949->i2c->dev,
+			"Device property 'config' needs even entry count.\n");
+		return -EINVAL;
+	}
+
+	config_len = ret;
+
+	config = kmalloc_array(config_len, sizeof(*config), GFP_KERNEL);
+	if (!config)
+		return -ENOMEM;
+
+	ret = device_property_read_u8_array(&ti949->i2c->dev, "config",
+			config, config_len);
+	if (ret < 0) {
+		kfree(config);
+		return ret;
+	}
+
+	ti949->config = devm_kmalloc_array(&ti949->i2c->dev,
+			config_len / 2, sizeof(*ti949->config), GFP_KERNEL);
+	if (!ti949->config) {
+		kfree(config);
+		return -ENOMEM;
+	}
+
+	ti949->config_len = config_len / 2;
+	for (i = 0; i < config_len; i += 2) {
+		ti949->config[i / 2].addr = config[i];
+		ti949->config[i / 2].value = config[i + 1];
+	}
+	kfree(config);
+
+	return 0;
+}
+
 static int ti949_probe(struct i2c_client *client,
 		const struct i2c_device_id *id)
 {
@@ -458,6 +574,10 @@ static int ti949_probe(struct i2c_client *client,
 	if (ret != 0)
 		return ret;
 
+	ret = ti949_get_config(ti949);
+	if (ret != 0)
+		return ret;
+
 	i2c_set_clientdata(client, ti949);
 
 	ret = ti949_pm_resume(&client->dev);
Signature · 1 line
2.20.1
#2 lore raw

Re: [PATCH v1 01/11] dt-bindings: display/bridge: Add bindings for ti948

In reply to Michael Drake

Hi Michael,

Thank you for the patch.

Quoted 6 lines · Michael Drake

Adds device tree bindings for:

TI DS90UB948-Q1 2K FPD-Link III to OpenLDI Deserializer

The device has the compatible string "ti,ds90ub948", and and allows an arrray of strings to be provided as regulator

s/arrray/array/

Quoted 16 lines

names to enable for operation of the device.

Cc Patrick Glaser <[email protected]>
Cc Nate Case <[email protected]>
---
 .../bindings/display/bridge/ti,ds90ub948.txt  | 24 +++++++++++++++++++
 1 file changed, 24 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/display/bridge/ti,ds90ub948.txt
Documentation/devicetree/bindings/display/bridge/ti,ds90ub948.txt new file +0 -0
new file mode 100644
index 000000000000..f9e86cb22900

Documentation/devicetree/bindings/display/bridge/ti,ds90ub948.txt line 6

Quoted 6 lines
Documentation/devicetree/bindings/display/bridge/ti,ds90ub948.txt new file +6 -0
@@ -0,0 +1,24 @@
+TI DS90UB948-Q1 2K FPD-Link III to OpenLDI Deserializer
+=======================================================
+
+This is the binding for Texas Instruments DS90UB948-Q1 bridge deserializer.
+
+This device supports I2C only.

Then the DT node should be a child of its I2C controller, and have a reg property.

Documentation/devicetree/bindings/display/bridge/ti,ds90ub948.txt line 14

Quoted 8 lines
Documentation/devicetree/bindings/display/bridge/ti,ds90ub948.txt new file +8 -0
+
+Required properties:
+
+- compatible: "ti,ds90ub948"
+
+Optional properties:
+
+- regulators: List of regulator name strings to enable for operation of device.

There's a standard binding for regulators, using *-supply properties. Please use them.

You should also use the OF graph DT bindings to model the data connections.

Quoted 10 lines
Documentation/devicetree/bindings/display/bridge/ti,ds90ub948.txt new file +10 -0
+
+Example
+-------
+
+ti948: ds90ub948@0 {
+	compatible = "ti,ds90ub948";
+
+	regulators: "vcc",
+	            "vcc_disp";
+};
Signature · 3 lines
Regards,

Laurent Pinchart
#6 lore raw

Re: [PATCH v1 03/11] dt-bindings: display/bridge: Add config property for ti948

In reply to Michael Drake

Hi Michael,

Thank you for the patch.

Quoted 3 lines · Michael Drake

The config property can be used to provide an array of register addresses and values to be written to configure the device for the board.

Please don't. DT describes the hardware (or more accurately the system), it's not meant to store arbitrary configuration data. All the registers specified below should instead be set by the driver based on a combination of hardware description and information obtained at runtime.

Quoted 44 lines
Cc Patrick Glaser <[email protected]>
Cc Nate Case <[email protected]>
---
 .../bindings/display/bridge/ti,ds90ub948.txt  | 21 +++++++++++++++++++
 1 file changed, 21 insertions(+)
Documentation/devicetree/bindings/display/bridge/ti,ds90ub948.txt +21 -0
index f9e86cb22900..1e7033b0f3b7 100644
@@ -12,6 +12,8 @@ Required properties:
 Optional properties:
 
 - regulators: List of regulator name strings to enable for operation of device.
+- config: List of <register address>,<value> pairs to be set to configure
+  device on powerup.  The register addresses and values are 8bit.
 
 Example
 -------
@@ -21,4 +23,23 @@ ti948: ds90ub948@0 {
 
 	regulators: "vcc",
 	            "vcc_disp";
+	config:
+	        /* set error count to max */
+	        <0x41>, <0x1f>,
+	        /* sets output mode, no change noticed */
+	        <0x49>, <0xe0>,
+	        /* speed up I2C, 0xE is around 480KHz */
+	        <0x26>, <0x0e>,
+	        /* speed up I2C, 0xE is around 480KHz */
+	        <0x27>, <0x0e>,
+	        /* sets GPIO0 as an input */
+	        <0x1D>, <0x13>,
+	        /* set GPIO2 high, backlight PWM (set to 0x50 for normal use) */
+	        <0x1E>, <0x50>,
+	        /* sets GPIO3 as an output with remote control for touch XRES */
+	        <0x1F>, <0x05>,
+	        /* set GPIO5 high, backlight enable on new display */
+	        <0x20>, <0x09>,
+	        /* set GPIO7 and GPIO8 high to enable touch power and prox sense */
+	        <0x21>, <0x91>;
 };
Signature · 3 lines
Regards,

Laurent Pinchart
#11 lore raw

Re: [PATCH v1 06/11] ti948: Reconfigure in the alive check when device returns

In reply to Michael Drake

Hi Michael,

Thank you for the patch.

Quoted 2 lines · Michael Drake

If the alive check detects a transition to the alive state, the device configuration is rewritten.

This seems like a big hack. You will have at the very least to explain why this is needed, and why you can't configure the device in response to drm_bridge operation calls.

Quoted 66 lines
Cc Patrick Glaser <[email protected]>
Cc Nate Case <[email protected]>
---
 drivers/gpu/drm/bridge/ti948.c | 19 ++++++++++++++++++-
 1 file changed, 18 insertions(+), 1 deletion(-)
drivers/gpu/drm/bridge/ti948.c +18 -1
index 86daa3701b91..b5c766711c4b 100644
@@ -132,6 +132,8 @@ struct ti948_reg_val {
  * @reg_names:   Array of regulator names, or NULL.
  * @regs:        Array of regulators, or NULL.
  * @reg_count:   Number of entries in reg_names and regs arrays.
+ * @alive_check: Context for the alive checking work item.
+ * @alive:       Whether the device is alive or not (alive_check).
  */
 struct ti948_ctx {
 	struct i2c_client *i2c;
@@ -141,6 +143,8 @@ struct ti948_ctx {
 	const char **reg_names;
 	struct regulator **regs;
 	size_t reg_count;
+	struct delayed_work alive_check;
+	bool alive;
 };
 
 static bool ti948_readable_reg(struct device *dev, unsigned int reg)
@@ -346,6 +350,8 @@ static int ti948_power_on(struct ti948_ctx *ti948)
 	if (ret != 0)
 		return ret;
 
+	ti948->alive = true;
+
 	msleep(500);
 
 	return 0;
@@ -356,6 +362,8 @@ static int ti948_power_off(struct ti948_ctx *ti948)
 	int i;
 	int ret;
 
+	ti948->alive = false;
+
 	for (i = ti948->reg_count; i > 0; i--) {
 		dev_info(&ti948->i2c->dev, "Disabling %s regulator\n",
 				ti948->reg_names[i - 1]);
@@ -388,8 +396,17 @@ static void ti948_alive_check(struct work_struct *work)
 {
 	struct delayed_work *dwork = to_delayed_work(work);
 	struct ti948_ctx *ti948 = delayed_work_to_ti948_ctx(dwork);
+	int ret = ti948_device_check(ti948);
 
-	dev_info(&ti948->i2c->dev, "%s Alive check!\n", __func__);
+	if (ti948->alive == false && ret == 0) {
+		dev_info(&ti948->i2c->dev, "Device has come back to life!\n");
+		ti948_write_config_seq(ti948);
+		ti948->alive = true;
+
+	} else if (ti948->alive == true && ret != 0) {
+		dev_info(&ti948->i2c->dev, "Device has stopped responding\n");
+		ti948->alive = false;
+	}
 
 	/* Reschedule ourself for the next check. */
 	schedule_delayed_work(&ti948->alive_check, TI948_ALIVE_CHECK_DELAY);
Signature · 3 lines
Regards,

Laurent Pinchart
#14 lore raw

Re: [PATCH v1 07/11] ti948: Add sysfs node for alive attribute

In reply to Michael Drake

Hi Michael,

Thank you for the patch.

Quoted 2 lines · Michael Drake

This may be used by userspace to determine the state of the device.

Why is this needed ? Userspace shouldn't even be aware that this device exists.

Quoted 62 lines
Cc Patrick Glaser <[email protected]>
Cc Nate Case <[email protected]>
---
 drivers/gpu/drm/bridge/ti948.c | 28 ++++++++++++++++++++++++++--
 1 file changed, 26 insertions(+), 2 deletions(-)
drivers/gpu/drm/bridge/ti948.c +26 -2
index b5c766711c4b..b624eaeabb43 100644
@@ -412,6 +412,16 @@ static void ti948_alive_check(struct work_struct *work)
 	schedule_delayed_work(&ti948->alive_check, TI948_ALIVE_CHECK_DELAY);
 }
 
+static ssize_t alive_show(struct device *dev,
+		struct device_attribute *attr, char *buf)
+{
+	struct ti948_ctx *ti948 = ti948_ctx_from_dev(dev);
+
+	return scnprintf(buf, PAGE_SIZE, "%u\n", (unsigned int)ti948->alive);
+}
+
+static DEVICE_ATTR_RO(alive);
+
 static int ti948_pm_resume(struct device *dev)
 {
 	struct ti948_ctx *ti948 = ti948_ctx_from_dev(dev);
@@ -614,17 +624,31 @@ static int ti948_probe(struct i2c_client *client,
 
 	i2c_set_clientdata(client, ti948);
 
+	ret = device_create_file(&client->dev, &dev_attr_alive);
+	if (ret) {
+		dev_err(&client->dev, "Could not create alive attr\n");
+		return ret;
+	}
+
 	ret = ti948_pm_resume(&client->dev);
-	if (ret != 0)
-		return -EPROBE_DEFER;
+	if (ret != 0) {
+		ret = -EPROBE_DEFER;
+		goto error;
+	}
 
 	dev_info(&ti948->i2c->dev, "End probe (addr: %x)\n", ti948->i2c->addr);
 
 	return 0;
+
+error:
+	device_remove_file(&client->dev, &dev_attr_alive);
+	return ret;
 }
 
 static int ti948_remove(struct i2c_client *client)
 {
+	device_remove_file(&client->dev, &dev_attr_alive);
+
 	return ti948_pm_suspend(&client->dev);
 }
 
Signature · 7 lines
Regards,

Laurent Pinchart
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#17 lore raw

Re: [PATCH v1 08/11] dt-bindings: display/bridge: Add bindings for ti949

In reply to Michael Drake

Hi Michael,

Thank you for the patch.

Quoted 9 lines · Michael Drake

Adds device tree bindings for:

TI DS90UB949-Q1 1080p HDMI to FPD-Link III bridge serializer

It supports instantiation via device tree / ACPI table.

The device has the compatible string "ti,ds90ub949", and and allows an arrray of strings to be provided as regulator names to enable for operation of the device.

All the comments I made regarding the ds90ub948 DT bindings apply here too. Same for the comments related to the driver, they apply to the subsequent patches in this series.

Quoted 38 lines
Cc Patrick Glaser <[email protected]>
Cc Nate Case <[email protected]>
---
 .../bindings/display/bridge/ti,ds90ub949.txt  | 24 +++++++++++++++++++
 1 file changed, 24 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/display/bridge/ti,ds90ub949.txt
Documentation/devicetree/bindings/display/bridge/ti,ds90ub949.txt new file +24 -0
new file mode 100644
index 000000000000..3ba3897d5e81
@@ -0,0 +1,24 @@
+TI DS90UB949-Q1 1080p HDMI to FPD-Link III bridge serializer
+============================================================
+
+This is the binding for Texas Instruments DS90UB949-Q1 bridge serializer.
+
+This device supports I2C only.
+
+Required properties:
+
+- compatible: "ti,ds90ub949"
+
+Optional properties:
+
+- regulators: List of regulator name strings to enable for operation of device.
+
+Example
+-------
+
+ti949: ds90ub949@0 {
+	compatible = "ti,ds90ub949";
+
+	regulators: "vcc",
+	            "vcc_hdmi";
+};
Signature · 3 lines
Regards,

Laurent Pinchart
#3 lore raw

Re: [PATCH v1 01/11] dt-bindings: display/bridge: Add bindings for ti948

In reply to Laurent Pinchart

Hi Laurent,

Quoted 3 lines · Laurent Pinchart

Hi Michael,

Thank you for the patch.

My pleasure, and thank you for the feedback! I'm sorry it's taken me a while to respond to it.

Quoted 9 lines · Michael Drake
Quoted 6 lines

Adds device tree bindings for:

TI DS90UB948-Q1 2K FPD-Link III to OpenLDI Deserializer

The device has the compatible string "ti,ds90ub948", and and allows an arrray of strings to be provided as regulator

s/arrray/array/

Thanks. Fixed for the next version.

Quoted 10 lines
Quoted 10 lines

names to enable for operation of the device.

Cc Patrick Glaser <[email protected]>
Cc Nate Case <[email protected]>
---
 .../bindings/display/bridge/ti,ds90ub948.txt  | 24 +++++++++++++++++++
 1 file changed, 24 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/display/bridge/ti,ds90ub948.txt
Quoted 15 lines

Documentation/devicetree/bindings/display/bridge/ti,ds90ub948.txt line 6

Quoted 12 lines
Documentation/devicetree/bindings/display/bridge/ti,ds90ub948.txt new file +6 -0
new file mode 100644
index 000000000000..f9e86cb22900
@@ -0,0 +1,24 @@
+TI DS90UB948-Q1 2K FPD-Link III to OpenLDI Deserializer
+=======================================================
+
+This is the binding for Texas Instruments DS90UB948-Q1 bridge deserializer.
+
+This device supports I2C only.

Then the DT node should be a child of its I2C controller, and have a reg property.

OK, thank you. I'm not actually using DT, I'm using ACPI tables.

For DT, would this cause the device to get bound to the driver on startup?

I tried adding a reg property with the value set to the device's I2C address with device tree compatible properties, coupled with the DT "compatible" string property, but that was insufficient to bind the device to the driver. At the moment, I'm using the ACPI mechanism for achieving this.

So all I've done for this is add the "reg" property to the device tree ti,ds90ub948.txt documentation file, in the Example section.

Is this what you were expecting?

For the other point, that the DT node should be a child of its I2C controller, I've made the devices descendants of the I2C controller in ACPI, but one of them is not a direct child.

The ti949 is a child of its I2C controller node, but the ti948 is a child of the ti949 node in the ACPI table. I did this to ensure that linux was aware of the dependency of the devices, so that they would be brought up in the correct order and suspended and resumed in the correct order.

Quoted 11 lines

Documentation/devicetree/bindings/display/bridge/ti,ds90ub948.txt line 14

Quoted 8 lines
Documentation/devicetree/bindings/display/bridge/ti,ds90ub948.txt new file +8 -0
+
+Required properties:
+
+- compatible: "ti,ds90ub948"
+
+Optional properties:
+
+- regulators: List of regulator name strings to enable for operation of device.

There's a standard binding for regulators, using *-supply properties. Please use them.

Thank you! I've switched to using that, and it is less code. :)

Quoted 2 lines

You should also use the OF graph DT bindings to model the data connections.

I'm not clear on the implications of this from the driver code. Does it need any code changes to the driver to support these endpoints? How are they used?

If it's just a documentation thing, I can easily do it, but otherwise, I can't test Device Tree because we're using ACPI.

Quoted 11 lines
Quoted 10 lines
Documentation/devicetree/bindings/display/bridge/ti,ds90ub948.txt new file +10 -0
+
+Example
+-------
+
+ti948: ds90ub948@0 {
+	compatible = "ti,ds90ub948";
+
+	regulators: "vcc",
+	            "vcc_disp";
+};
Signature · 1 line
Michael Drake                 https://www.codethink.co.uk/
#7 lore raw

Re: [PATCH v1 03/11] dt-bindings: display/bridge: Add config property for ti948

In reply to Laurent Pinchart

Hi Laurent,

Quoted 3 lines · Laurent Pinchart

Hi Michael,

Thank you for the patch.

My pleasure, and thank you for the feedback!

Quoted 9 lines · Michael Drake
Quoted 3 lines

The config property can be used to provide an array of register addresses and values to be written to configure the device for the board.

Please don't. DT describes the hardware (or more accurately the system), it's not meant to store arbitrary configuration data. All the registers specified below should instead be set by the driver based on a combination of hardware description and information obtained at runtime.

OK, understood. I'll work on this. For some of them explicit firmware properties would be appropriate.

I'll go through it to ascertain what can be determined at runtime.

Quoted 45 lines
Quoted 44 lines
Cc Patrick Glaser <[email protected]>
Cc Nate Case <[email protected]>
---
 .../bindings/display/bridge/ti,ds90ub948.txt  | 21 +++++++++++++++++++
 1 file changed, 21 insertions(+)
Documentation/devicetree/bindings/display/bridge/ti,ds90ub948.txt +21 -0
index f9e86cb22900..1e7033b0f3b7 100644
@@ -12,6 +12,8 @@ Required properties:
 Optional properties:
 
 - regulators: List of regulator name strings to enable for operation of device.
+- config: List of <register address>,<value> pairs to be set to configure
+  device on powerup.  The register addresses and values are 8bit.
 
 Example
 -------
@@ -21,4 +23,23 @@ ti948: ds90ub948@0 {
 
 	regulators: "vcc",
 	            "vcc_disp";
+	config:
+	        /* set error count to max */
+	        <0x41>, <0x1f>,
+	        /* sets output mode, no change noticed */
+	        <0x49>, <0xe0>,
+	        /* speed up I2C, 0xE is around 480KHz */
+	        <0x26>, <0x0e>,
+	        /* speed up I2C, 0xE is around 480KHz */
+	        <0x27>, <0x0e>,
+	        /* sets GPIO0 as an input */
+	        <0x1D>, <0x13>,
+	        /* set GPIO2 high, backlight PWM (set to 0x50 for normal use) */
+	        <0x1E>, <0x50>,
+	        /* sets GPIO3 as an output with remote control for touch XRES */
+	        <0x1F>, <0x05>,
+	        /* set GPIO5 high, backlight enable on new display */
+	        <0x20>, <0x09>,
+	        /* set GPIO7 and GPIO8 high to enable touch power and prox sense */
+	        <0x21>, <0x91>;
 };
Signature · 1 line
Michael Drake                 https://www.codethink.co.uk/
#12 lore raw

Re: [PATCH v1 06/11] ti948: Reconfigure in the alive check when device returns

In reply to Laurent Pinchart

Hi Laurent,

Quoted 3 lines · Laurent Pinchart

Hi Michael,

Thank you for the patch.

My pleasure, and thank you for the feedback!

Quoted 7 lines · Michael Drake
Quoted 2 lines

If the alive check detects a transition to the alive state, the device configuration is rewritten.

This seems like a big hack. You will have at the very least to explain why this is needed, and why you can't configure the device in response to drm_bridge operation calls.

The ti948 device is situated inside the housing of the LCD panel. The ti949 is a normal i2c device on the system i2c bus. In order for the ti948 to appear on the system's i2c bus, the ti949 must be powered up and configured.

The panel is connected to the system via the FPD-Link III. If a connector for the wire to the display is unplugged and re-inserted, then the ti948 will drop out and come back.

Application note AN-2173, "I2C Communication Over FPD-LinkIII with Bidirectional Control Channel" describes this:

http://www.ti.com/lit/an/snla131a/snla131a.pdf

Perhaps I need to expand the commit message to explain this?

Alternatively is there a more standard way of dealing with remotely connected i2c devices?

Quoted 67 lines
Quoted 66 lines
Cc Patrick Glaser <[email protected]>
Cc Nate Case <[email protected]>
---
 drivers/gpu/drm/bridge/ti948.c | 19 ++++++++++++++++++-
 1 file changed, 18 insertions(+), 1 deletion(-)
drivers/gpu/drm/bridge/ti948.c +18 -1
index 86daa3701b91..b5c766711c4b 100644
@@ -132,6 +132,8 @@ struct ti948_reg_val {
  * @reg_names:   Array of regulator names, or NULL.
  * @regs:        Array of regulators, or NULL.
  * @reg_count:   Number of entries in reg_names and regs arrays.
+ * @alive_check: Context for the alive checking work item.
+ * @alive:       Whether the device is alive or not (alive_check).
  */
 struct ti948_ctx {
 	struct i2c_client *i2c;
@@ -141,6 +143,8 @@ struct ti948_ctx {
 	const char **reg_names;
 	struct regulator **regs;
 	size_t reg_count;
+	struct delayed_work alive_check;
+	bool alive;
 };
 
 static bool ti948_readable_reg(struct device *dev, unsigned int reg)
@@ -346,6 +350,8 @@ static int ti948_power_on(struct ti948_ctx *ti948)
 	if (ret != 0)
 		return ret;
 
+	ti948->alive = true;
+
 	msleep(500);
 
 	return 0;
@@ -356,6 +362,8 @@ static int ti948_power_off(struct ti948_ctx *ti948)
 	int i;
 	int ret;
 
+	ti948->alive = false;
+
 	for (i = ti948->reg_count; i > 0; i--) {
 		dev_info(&ti948->i2c->dev, "Disabling %s regulator\n",
 				ti948->reg_names[i - 1]);
@@ -388,8 +396,17 @@ static void ti948_alive_check(struct work_struct *work)
 {
 	struct delayed_work *dwork = to_delayed_work(work);
 	struct ti948_ctx *ti948 = delayed_work_to_ti948_ctx(dwork);
+	int ret = ti948_device_check(ti948);
 
-	dev_info(&ti948->i2c->dev, "%s Alive check!\n", __func__);
+	if (ti948->alive == false && ret == 0) {
+		dev_info(&ti948->i2c->dev, "Device has come back to life!\n");
+		ti948_write_config_seq(ti948);
+		ti948->alive = true;
+
+	} else if (ti948->alive == true && ret != 0) {
+		dev_info(&ti948->i2c->dev, "Device has stopped responding\n");
+		ti948->alive = false;
+	}
 
 	/* Reschedule ourself for the next check. */
 	schedule_delayed_work(&ti948->alive_check, TI948_ALIVE_CHECK_DELAY);
Signature · 1 line
Michael Drake                 https://www.codethink.co.uk/
#15 lore raw

Re: [PATCH v1 07/11] ti948: Add sysfs node for alive attribute

In reply to Laurent Pinchart

Hi Laurent,

Quoted 3 lines · Laurent Pinchart

Hi Michael,

Thank you for the patch.

My pleasure, and thank you for the feedback!

Quoted 6 lines · Michael Drake
Quoted 2 lines

This may be used by userspace to determine the state of the device.

Why is this needed ? Userspace shouldn't even be aware that this device exists.

The display (containing the ti948) could be unplugged. (See my response to the feedback on the previous commit in the series.)

If you can suggest a better or more standard way of doing this I would be very happy to learn of it.

Quoted 63 lines
Quoted 62 lines
Cc Patrick Glaser <[email protected]>
Cc Nate Case <[email protected]>
---
 drivers/gpu/drm/bridge/ti948.c | 28 ++++++++++++++++++++++++++--
 1 file changed, 26 insertions(+), 2 deletions(-)
drivers/gpu/drm/bridge/ti948.c +26 -2
index b5c766711c4b..b624eaeabb43 100644
@@ -412,6 +412,16 @@ static void ti948_alive_check(struct work_struct *work)
 	schedule_delayed_work(&ti948->alive_check, TI948_ALIVE_CHECK_DELAY);
 }
 
+static ssize_t alive_show(struct device *dev,
+		struct device_attribute *attr, char *buf)
+{
+	struct ti948_ctx *ti948 = ti948_ctx_from_dev(dev);
+
+	return scnprintf(buf, PAGE_SIZE, "%u\n", (unsigned int)ti948->alive);
+}
+
+static DEVICE_ATTR_RO(alive);
+
 static int ti948_pm_resume(struct device *dev)
 {
 	struct ti948_ctx *ti948 = ti948_ctx_from_dev(dev);
@@ -614,17 +624,31 @@ static int ti948_probe(struct i2c_client *client,
 
 	i2c_set_clientdata(client, ti948);
 
+	ret = device_create_file(&client->dev, &dev_attr_alive);
+	if (ret) {
+		dev_err(&client->dev, "Could not create alive attr\n");
+		return ret;
+	}
+
 	ret = ti948_pm_resume(&client->dev);
-	if (ret != 0)
-		return -EPROBE_DEFER;
+	if (ret != 0) {
+		ret = -EPROBE_DEFER;
+		goto error;
+	}
 
 	dev_info(&ti948->i2c->dev, "End probe (addr: %x)\n", ti948->i2c->addr);
 
 	return 0;
+
+error:
+	device_remove_file(&client->dev, &dev_attr_alive);
+	return ret;
 }
 
 static int ti948_remove(struct i2c_client *client)
 {
+	device_remove_file(&client->dev, &dev_attr_alive);
+
 	return ti948_pm_suspend(&client->dev);
 }
 
Signature · 1 line
Michael Drake                 https://www.codethink.co.uk/
#18 lore raw

Re: [PATCH v1 08/11] dt-bindings: display/bridge: Add bindings for ti949

In reply to Laurent Pinchart

Hi Laurent,

Quoted 3 lines · Laurent Pinchart

Hi Michael,

Thank you for the patch.

My pleasure, and thank you for the feedback!

Quoted 7 lines · Michael Drake
Quoted 6 lines

Adds device tree bindings for:

TI DS90UB949-Q1 1080p HDMI to FPD-Link III bridge serializer

It supports instantiation via device tree / ACPI table.

Quoted 7 lines
Quoted 3 lines

The device has the compatible string "ti,ds90ub949", and and allows an arrray of strings to be provided as regulator names to enable for operation of the device.

All the comments I made regarding the ds90ub948 DT bindings apply here too. Same for the comments related to the driver, they apply to the subsequent patches in this series.

OK, understood.

Thank you very much for the review.

Quoted 39 lines
Quoted 38 lines
Cc Patrick Glaser <[email protected]>
Cc Nate Case <[email protected]>
---
 .../bindings/display/bridge/ti,ds90ub949.txt  | 24 +++++++++++++++++++
 1 file changed, 24 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/display/bridge/ti,ds90ub949.txt
Documentation/devicetree/bindings/display/bridge/ti,ds90ub949.txt new file +24 -0
new file mode 100644
index 000000000000..3ba3897d5e81
@@ -0,0 +1,24 @@
+TI DS90UB949-Q1 1080p HDMI to FPD-Link III bridge serializer
+============================================================
+
+This is the binding for Texas Instruments DS90UB949-Q1 bridge serializer.
+
+This device supports I2C only.
+
+Required properties:
+
+- compatible: "ti,ds90ub949"
+
+Optional properties:
+
+- regulators: List of regulator name strings to enable for operation of device.
+
+Example
+-------
+
+ti949: ds90ub949@0 {
+	compatible = "ti,ds90ub949";
+
+	regulators: "vcc",
+	            "vcc_hdmi";
+};
Signature · 1 line
Michael Drake                 https://www.codethink.co.uk/