linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Aradhya Bhatia <a-bhatia1@ti.com>
To: Tomi Valkeinen <tomba@kernel.org>, Jyri Sarha <jyri.sarha@iki.fi>,
	Rob Herring <robh+dt@kernel.org>, David Airlie <airlied@linux.ie>,
	Daniel Vetter <daniel@ffwll.ch>,
	Krzysztof Kozlowski <krzysztof.kozlowski+dt@linaro.org>
Cc: Darren Etheridge <detheridge@ti.com>, Nishanth Menon <nm@ti.com>,
	Vignesh Raghavendra <vigneshr@ti.com>,
	Rahul T R <r-ravikumar@ti.com>, Krunal Bhargav <k-bhargav@ti.com>,
	Devarsh Thakkar <devarsht@ti.com>,
	DRI Development List <dri-devel@lists.freedesktop.org>,
	Devicetree List <devicetree@vger.kernel.org>,
	Linux Kernel List <linux-kernel@vger.kernel.org>
Subject: [PATCH 3/8] drm/tidss: Add support for DSS port properties
Date: Tue, 19 Jul 2022 13:38:40 +0530	[thread overview]
Message-ID: <20220719080845.22122-4-a-bhatia1@ti.com> (raw)
In-Reply-To: <20220719080845.22122-1-a-bhatia1@ti.com>

Add support to enable and read the dss port properties.

The "ti,oldi-mode" property indicates the tidss driver how many OLDI
TXes are enabled as well as which mode do they need to be connected in.

The "ti,rgb565_to_888" is a special property that forces the DSS to
output 16bit RGB565 data to a 24bit RGB888 bridge. This property can be
used when the bridge does not explicity support RGB565.

Signed-off-by: Aradhya Bhatia <a-bhatia1@ti.com>
---
 drivers/gpu/drm/tidss/tidss_dispc.c | 55 ++++++++++++++++++++++++++---
 drivers/gpu/drm/tidss/tidss_dispc.h |  8 +++++
 2 files changed, 59 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/tidss/tidss_dispc.c b/drivers/gpu/drm/tidss/tidss_dispc.c
index f084f0688a54..add725fa682b 100644
--- a/drivers/gpu/drm/tidss/tidss_dispc.c
+++ b/drivers/gpu/drm/tidss/tidss_dispc.c
@@ -348,6 +348,10 @@ struct dispc_device {
 
 	struct dss_vp_data vp_data[TIDSS_MAX_PORTS];
 
+	enum dss_oldi_modes oldi_mode;
+
+	bool rgb565_to_888;
+
 	u32 *fourccs;
 	u32 num_fourccs;
 
@@ -2718,6 +2722,42 @@ static void dispc_softreset(struct dispc_device *dispc)
 		dev_warn(dispc->dev, "failed to reset dispc\n");
 }
 
+static void dispc_get_port_properties(struct dispc_device *dispc)
+{
+	u32 i = 0;
+	struct device_node *dss_ports, *vport;
+
+	dss_ports = of_get_next_child(dispc->dev->of_node, NULL);
+
+	for_each_child_of_node(dss_ports, vport) {
+		if (dispc->feat->vp_bus_type[i] == DISPC_VP_OLDI) {
+			if (of_property_read_u32(vport, "ti,oldi-mode", &dispc->oldi_mode)) {
+				dev_dbg(dispc->dev, "%s: Using OLDI defaults on vp%d.\n",
+					__func__, i);
+				if (dispc->feat->subrev == DISPC_AM65X)
+					dispc->oldi_mode = OLDI_SINGLE_LINK_SINGLE_MODE_0;
+				else
+					dispc->oldi_mode = OLDI_MODE_OFF;
+			}
+
+			/*
+			 * DISPC_AM65X DSS has a singular OLDI TX. It can not work in
+			 * Dual/Duplicate Mode. Forcing defaults.
+			 */
+			if (dispc->feat->subrev == DISPC_AM65X &&
+			    dispc->oldi_mode > OLDI_SINGLE_LINK_SINGLE_MODE_0) {
+				dev_dbg(dispc->dev,
+					"%s: Using default OLDI mode %d. AM65X can not support mode %d.\n",
+					__func__, OLDI_SINGLE_LINK_SINGLE_MODE_0, dispc->oldi_mode);
+				dispc->oldi_mode = OLDI_SINGLE_LINK_SINGLE_MODE_0;
+			}
+		} else if (dispc->feat->vp_bus_type[i] == DISPC_VP_DPI) {
+			dispc->rgb565_to_888 = of_property_read_bool(vport, "ti,rgb565-to-888");
+		}
+		i++;
+	}
+}
+
 int dispc_init(struct tidss_device *tidss)
 {
 	struct device *dev = tidss->dev;
@@ -2812,10 +2852,17 @@ int dispc_init(struct tidss_device *tidss)
 		dispc->vp_data[i].gamma_table = gamma_table;
 	}
 
-	if (feat->subrev == DISPC_AM65X) {
-		r = dispc_init_am65x_oldi_io_ctrl(dev, dispc);
-		if (r)
-			return r;
+	if (feat->subrev == DISPC_AM65X || feat->subrev == DISPC_AM625) {
+		dispc_get_port_properties(dispc);
+		if (dispc->oldi_mode) {
+			r = dispc_init_am65x_oldi_io_ctrl(dev, dispc);
+			if (r)
+				return r;
+		}
+	} else {
+		/* K2G and J721E DSS do not support these properties */
+		dispc->oldi_mode = OLDI_MODE_OFF;
+		dispc->rgb565_to_888 = false;
 	}
 
 	dispc->fclk = devm_clk_get(dev, "fck");
diff --git a/drivers/gpu/drm/tidss/tidss_dispc.h b/drivers/gpu/drm/tidss/tidss_dispc.h
index a28005dafdc9..de8a95d3e3be 100644
--- a/drivers/gpu/drm/tidss/tidss_dispc.h
+++ b/drivers/gpu/drm/tidss/tidss_dispc.h
@@ -64,6 +64,14 @@ enum dispc_dss_subrevision {
 	DISPC_AM625,
 };
 
+enum dss_oldi_modes {
+	OLDI_MODE_OFF,				/* OLDI turned off / tied off in IP. */
+	OLDI_SINGLE_LINK_SINGLE_MODE_0,		/* Single Output over OLDI 0. */
+	OLDI_SINGLE_LINK_SINGLE_MODE_1,		/* Single Output over OLDI 1. */
+	OLDI_SINGLE_LINK_DUPLICATE_MODE,	/* Duplicate Output over OLDI 0 and 1. */
+	OLDI_DUAL_LINK,				/* Combined Output over OLDI 0 and 1. */
+};
+
 struct dispc_features {
 	int min_pclk_khz;
 	int max_pclk_khz[DISPC_VP_MAX_BUS_TYPE];
-- 
2.37.0


  parent reply	other threads:[~2022-07-19  8:09 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-07-19  8:08 sFrom b69208b75f7ae8e223c81783afb04fecd2f5faf8 Mon Sep 17 00:00:00 2001 Aradhya Bhatia
2022-07-19  8:08 ` [PATCH 1/8] dt-bindings: display: ti,am65x-dss: Add port properties for DSS Aradhya Bhatia
2022-07-20 23:28   ` Rob Herring
2022-07-22 16:16     ` Nishanth Menon
2022-07-28  6:28       ` Tomi Valkeinen
2022-07-25 11:26     ` Aradhya Bhatia
2022-07-25 22:14       ` Francesco Dolcini
2022-08-10 17:48       ` Rob Herring
2022-07-28 11:16   ` Tomi Valkeinen
2022-07-19  8:08 ` [PATCH 2/8] dt-bindings: display: ti,am65x-dss: Add IO CTRL property for AM625 OLDI Aradhya Bhatia
2022-07-20 23:32   ` Rob Herring
2022-07-25 11:34     ` Aradhya Bhatia
2022-07-19  8:08 ` Aradhya Bhatia [this message]
2022-07-28 12:07   ` [PATCH 3/8] drm/tidss: Add support for DSS port properties Tomi Valkeinen
2022-07-19  8:08 ` [PATCH 4/8] drm/tidss: Add support for Dual Link LVDS Bus Format Aradhya Bhatia
2022-07-28 11:03   ` Tomi Valkeinen
2022-07-28 11:45     ` Tomi Valkeinen
2022-08-09  5:58       ` Aradhya Bhatia
2022-08-09  6:28         ` Tomi Valkeinen
2022-08-09  9:06           ` Aradhya Bhatia
2022-08-09  9:51             ` Tomi Valkeinen
2022-08-09 13:34               ` Aradhya Bhatia
2022-08-01  3:32     ` Aradhya Bhatia
2022-07-19  8:08 ` [PATCH 5/8] drm/tidss: dt property to force 16bit VP output to a 24bit bridge Aradhya Bhatia
2022-07-19  8:08 ` [PATCH 6/8] drm/tidss: Add IO CTRL and Power support for OLDI TX in AM625 Aradhya Bhatia
2022-07-19  8:08 ` [PATCH 7/8] drm/tidss: Fix clock request value for OLDI videoports Aradhya Bhatia
2022-07-28 10:05   ` Tomi Valkeinen
2022-07-29  3:56     ` Aradhya Bhatia
2022-07-29  8:13       ` Tomi Valkeinen
2022-07-19  8:08 ` [PATCH 8/8] drm/tidss: Enable Dual and Duplicate Modes for OLDI Aradhya Bhatia
2022-07-27 13:22   ` Tomi Valkeinen
2022-07-28  6:46     ` Tomi Valkeinen
2022-07-28  8:49       ` Aradhya Bhatia
2022-07-28 11:29         ` Tomi Valkeinen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220719080845.22122-4-a-bhatia1@ti.com \
    --to=a-bhatia1@ti.com \
    --cc=airlied@linux.ie \
    --cc=daniel@ffwll.ch \
    --cc=detheridge@ti.com \
    --cc=devarsht@ti.com \
    --cc=devicetree@vger.kernel.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=jyri.sarha@iki.fi \
    --cc=k-bhargav@ti.com \
    --cc=krzysztof.kozlowski+dt@linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=nm@ti.com \
    --cc=r-ravikumar@ti.com \
    --cc=robh+dt@kernel.org \
    --cc=tomba@kernel.org \
    --cc=vigneshr@ti.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).