]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
drm/of: add helper to count data-lanes on a remote endpoint
authorDmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com>
Mon, 13 Apr 2026 14:05:29 +0000 (17:05 +0300)
committerDmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com>
Fri, 17 Apr 2026 23:10:37 +0000 (02:10 +0300)
If the DSI panel supports versatile lanes configuration, its driver
might require determining the number of DSI data lanes, which is usually
specified on the DSI host side of the OF graph. Add new helper as a
pair to drm_of_get_data_lanes_count_ep() that lets callers determine
number of data-lanes on the remote side of the OF graph.

Reviewed-by: Javier Martinez Canillas <javierm@redhat.com>
Link: https://patch.msgid.link/20260413-waveshare-dsi-touch-v3-6-3aeb53022c32@oss.qualcomm.com
Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com>
drivers/gpu/drm/drm_of.c
include/drm/drm_of.h

index 4f65ce729a473ec372bd76a60ac11a40ffb5df97..ef6b093169637ad210124a2ff75ce9865e21736f 100644 (file)
@@ -558,6 +558,40 @@ int drm_of_get_data_lanes_count_ep(const struct device_node *port,
 }
 EXPORT_SYMBOL_GPL(drm_of_get_data_lanes_count_ep);
 
+/**
+ * drm_of_get_data_lanes_count_remote - Get DSI/(e)DP data lane count by endpoint
+ * @port: DT port node of the DSI/(e)DP source or sink
+ * @port_reg: identifier (value of reg property) of the parent port node
+ * @reg: identifier (value of reg property) of the endpoint node
+ * @min: minimum supported number of data lanes
+ * @max: maximum supported number of data lanes
+ *
+ * Count DT "data-lanes" property elements in the remote endpoint and check for
+ * validity.  This variant uses endpoint specifier.
+ *
+ * Return:
+ * * min..max - positive integer count of "data-lanes" elements
+ * * -EINVAL - the "data-lanes" property is unsupported
+ * * -ENODEV - the "data-lanes" property is missing
+ */
+int drm_of_get_data_lanes_count_remote(const struct device_node *port,
+                                      int port_reg, int reg,
+                                      const unsigned int min,
+                                      const unsigned int max)
+{
+       struct device_node *endpoint, *remote;
+       int ret;
+
+       endpoint = of_graph_get_endpoint_by_regs(port, port_reg, reg);
+       remote = of_graph_get_remote_endpoint(endpoint);
+       of_node_put(endpoint);
+       ret = drm_of_get_data_lanes_count(remote, min, max);
+       of_node_put(remote);
+
+       return ret;
+}
+EXPORT_SYMBOL_GPL(drm_of_get_data_lanes_count_remote);
+
 #if IS_ENABLED(CONFIG_DRM_MIPI_DSI)
 
 /**
index f2f2bf82eff902bed3233c67273b1dbabfb4a996..7bcc0ccfe0f4be6cb161307793413f1f06974bb1 100644 (file)
@@ -62,6 +62,10 @@ int drm_of_get_data_lanes_count_ep(const struct device_node *port,
                                   int port_reg, int reg,
                                   const unsigned int min,
                                   const unsigned int max);
+int drm_of_get_data_lanes_count_remote(const struct device_node *port,
+                                      int port_reg, int reg,
+                                      const unsigned int min,
+                                      const unsigned int max);
 #else
 static inline uint32_t drm_of_crtc_port_mask(struct drm_device *dev,
                                          struct device_node *port)
@@ -140,6 +144,15 @@ drm_of_get_data_lanes_count_ep(const struct device_node *port,
 {
        return -EINVAL;
 }
+
+static inline int
+drm_of_get_data_lanes_count_remote(const struct device_node *port,
+                                  int port_reg, int reg,
+                                  const unsigned int min,
+                                  const unsigned int max)
+{
+       return -EINVAL;
+}
 #endif
 
 #if IS_ENABLED(CONFIG_OF) && IS_ENABLED(CONFIG_DRM_MIPI_DSI)