[PATCH 3/8] drm/tidss: Add support for DSS port properties

Aradhya Bhatia a-bhatia1 at ti.com
Tue Jul 19 08:08:40 UTC 2022


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 at 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



More information about the dri-devel mailing list