[PATCH v2 8/8] fbdev: omapfb: use of_graph_get_remote_port()

2024-03-31 Thread Kuninori Morimoto
We already have of_graph_get_remote_port(), Let's use it.

Signed-off-by: Kuninori Morimoto 
---
 drivers/video/fbdev/omap2/omapfb/dss/dss-of.c | 15 +--
 1 file changed, 1 insertion(+), 14 deletions(-)

diff --git a/drivers/video/fbdev/omap2/omapfb/dss/dss-of.c 
b/drivers/video/fbdev/omap2/omapfb/dss/dss-of.c
index 14965a3fd05b..4040e247e026 100644
--- a/drivers/video/fbdev/omap2/omapfb/dss/dss-of.c
+++ b/drivers/video/fbdev/omap2/omapfb/dss/dss-of.c
@@ -117,19 +117,6 @@ u32 dss_of_port_get_port_number(struct device_node *port)
return reg;
 }
 
-static struct device_node *omapdss_of_get_remote_port(const struct device_node 
*node)
-{
-   struct device_node *np;
-
-   np = of_graph_get_remote_endpoint(node);
-   if (!np)
-   return NULL;
-
-   np = of_get_next_parent(np);
-
-   return np;
-}
-
 struct omap_dss_device *
 omapdss_of_find_source_for_first_ep(struct device_node *node)
 {
@@ -141,7 +128,7 @@ omapdss_of_find_source_for_first_ep(struct device_node 
*node)
if (!ep)
return ERR_PTR(-EINVAL);
 
-   src_port = omapdss_of_get_remote_port(ep);
+   src_port = of_graph_get_remote_port(ep);
if (!src_port) {
of_node_put(ep);
return ERR_PTR(-EINVAL);
-- 
2.25.1



[PATCH v2 7/8] video: fbdev: use for_each_endpoint_of_node()

2024-03-31 Thread Kuninori Morimoto
We already have for_each_endpoint_of_node(), don't use
of_graph_get_next_endpoint() directly. Replace it.

Signed-off-by: Kuninori Morimoto 
---
 drivers/video/fbdev/omap2/omapfb/dss/omapdss-boot-init.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/video/fbdev/omap2/omapfb/dss/omapdss-boot-init.c 
b/drivers/video/fbdev/omap2/omapfb/dss/omapdss-boot-init.c
index 09f719af0d0c..d80720c84323 100644
--- a/drivers/video/fbdev/omap2/omapfb/dss/omapdss-boot-init.c
+++ b/drivers/video/fbdev/omap2/omapfb/dss/omapdss-boot-init.c
@@ -149,8 +149,7 @@ static void __init omapdss_walk_device(struct device_node 
*node, bool root)
 
of_node_put(n);
 
-   n = NULL;
-   while ((n = of_graph_get_next_endpoint(node, n)) != NULL) {
+   for_each_endpoint_of_node(node, n) {
struct device_node *pn;
 
pn = of_graph_get_remote_port_parent(n);
-- 
2.25.1



[PATCH v2 6/8] staging: media: atmel: use for_each_endpoint_of_node()

2024-03-31 Thread Kuninori Morimoto
We already have for_each_endpoint_of_node(), don't use
of_graph_get_next_endpoint() directly. Replace it.

Signed-off-by: Kuninori Morimoto 
---
 drivers/staging/media/deprecated/atmel/atmel-sama5d2-isc.c | 6 +-
 drivers/staging/media/deprecated/atmel/atmel-sama7g5-isc.c | 6 +-
 2 files changed, 2 insertions(+), 10 deletions(-)

diff --git a/drivers/staging/media/deprecated/atmel/atmel-sama5d2-isc.c 
b/drivers/staging/media/deprecated/atmel/atmel-sama5d2-isc.c
index 31b2b48085c5..cbfbec0c6cb5 100644
--- a/drivers/staging/media/deprecated/atmel/atmel-sama5d2-isc.c
+++ b/drivers/staging/media/deprecated/atmel/atmel-sama5d2-isc.c
@@ -340,13 +340,9 @@ static int isc_parse_dt(struct device *dev, struct 
isc_device *isc)
 
INIT_LIST_HEAD(>subdev_entities);
 
-   while (1) {
+   for_each_endpoint_of_node(np, epn) {
struct v4l2_fwnode_endpoint v4l2_epn = { .bus_type = 0 };
 
-   epn = of_graph_get_next_endpoint(np, epn);
-   if (!epn)
-   return 0;
-
ret = v4l2_fwnode_endpoint_parse(of_fwnode_handle(epn),
 _epn);
if (ret) {
diff --git a/drivers/staging/media/deprecated/atmel/atmel-sama7g5-isc.c 
b/drivers/staging/media/deprecated/atmel/atmel-sama7g5-isc.c
index 020034f631f5..7c477b1d3c48 100644
--- a/drivers/staging/media/deprecated/atmel/atmel-sama7g5-isc.c
+++ b/drivers/staging/media/deprecated/atmel/atmel-sama7g5-isc.c
@@ -326,13 +326,9 @@ static int xisc_parse_dt(struct device *dev, struct 
isc_device *isc)
 
mipi_mode = of_property_read_bool(np, "microchip,mipi-mode");
 
-   while (1) {
+   for_each_endpoint_of_node(np, epn) {
struct v4l2_fwnode_endpoint v4l2_epn = { .bus_type = 0 };
 
-   epn = of_graph_get_next_endpoint(np, epn);
-   if (!epn)
-   return 0;
-
ret = v4l2_fwnode_endpoint_parse(of_fwnode_handle(epn),
 _epn);
if (ret) {
-- 
2.25.1



[PATCH v2 5/8] media: platform: xilinx: use for_each_endpoint_of_node()

2024-03-31 Thread Kuninori Morimoto
We already have for_each_endpoint_of_node(), don't use
of_graph_get_next_endpoint() directly. Replace it.

Signed-off-by: Kuninori Morimoto 
---
 drivers/media/platform/xilinx/xilinx-vipp.c | 7 +--
 1 file changed, 1 insertion(+), 6 deletions(-)

diff --git a/drivers/media/platform/xilinx/xilinx-vipp.c 
b/drivers/media/platform/xilinx/xilinx-vipp.c
index 996684a73038..38818b82a575 100644
--- a/drivers/media/platform/xilinx/xilinx-vipp.c
+++ b/drivers/media/platform/xilinx/xilinx-vipp.c
@@ -205,12 +205,7 @@ static int xvip_graph_build_dma(struct 
xvip_composite_device *xdev)
 
dev_dbg(xdev->dev, "creating links for DMA engines\n");
 
-   while (1) {
-   /* Get the next endpoint and parse its link. */
-   ep = of_graph_get_next_endpoint(node, ep);
-   if (ep == NULL)
-   break;
-
+   for_each_endpoint_of_node(node, ep) {
dev_dbg(xdev->dev, "processing endpoint %pOF\n", ep);
 
ret = v4l2_fwnode_parse_link(of_fwnode_handle(ep), );
-- 
2.25.1



[PATCH v2 4/8] media: platform: ti: use for_each_endpoint_of_node()

2024-03-31 Thread Kuninori Morimoto
We already have for_each_endpoint_of_node(), don't use
of_graph_get_next_endpoint() directly. Replace it.

Signed-off-by: Kuninori Morimoto 
---
 drivers/media/platform/ti/am437x/am437x-vpfe.c   | 12 +---
 drivers/media/platform/ti/davinci/vpif_capture.c | 12 ++--
 2 files changed, 11 insertions(+), 13 deletions(-)

diff --git a/drivers/media/platform/ti/am437x/am437x-vpfe.c 
b/drivers/media/platform/ti/am437x/am437x-vpfe.c
index 77e12457d149..009ff68a2b43 100644
--- a/drivers/media/platform/ti/am437x/am437x-vpfe.c
+++ b/drivers/media/platform/ti/am437x/am437x-vpfe.c
@@ -2287,7 +2287,7 @@ static const struct v4l2_async_notifier_operations 
vpfe_async_ops = {
 static struct vpfe_config *
 vpfe_get_pdata(struct vpfe_device *vpfe)
 {
-   struct device_node *endpoint = NULL;
+   struct device_node *endpoint;
struct device *dev = vpfe->pdev;
struct vpfe_subdev_info *sdinfo;
struct vpfe_config *pdata;
@@ -2306,14 +2306,11 @@ vpfe_get_pdata(struct vpfe_device *vpfe)
if (!pdata)
return NULL;
 
-   for (i = 0; ; i++) {
+   i = 0;
+   for_each_endpoint_of_node(dev->of_node, endpoint) {
struct v4l2_fwnode_endpoint bus_cfg = { .bus_type = 0 };
struct device_node *rem;
 
-   endpoint = of_graph_get_next_endpoint(dev->of_node, endpoint);
-   if (!endpoint)
-   break;
-
sdinfo = >sub_devs[i];
sdinfo->grp_id = 0;
 
@@ -2371,9 +2368,10 @@ vpfe_get_pdata(struct vpfe_device *vpfe)
of_node_put(rem);
if (IS_ERR(pdata->asd[i]))
goto cleanup;
+
+   i++;
}
 
-   of_node_put(endpoint);
return pdata;
 
 cleanup:
diff --git a/drivers/media/platform/ti/davinci/vpif_capture.c 
b/drivers/media/platform/ti/davinci/vpif_capture.c
index c31a5566fc5a..3db4e82c8a80 100644
--- a/drivers/media/platform/ti/davinci/vpif_capture.c
+++ b/drivers/media/platform/ti/davinci/vpif_capture.c
@@ -1517,16 +1517,12 @@ vpif_capture_get_pdata(struct platform_device *pdev,
if (!pdata->subdev_info)
return NULL;
 
-   for (i = 0; i < VPIF_CAPTURE_NUM_CHANNELS; i++) {
+   i = 0;
+   for_each_endpoint_of_node(pdev->dev.of_node, endpoint) {
struct v4l2_fwnode_endpoint bus_cfg = { .bus_type = 0 };
unsigned int flags;
int err;
 
-   endpoint = of_graph_get_next_endpoint(pdev->dev.of_node,
- endpoint);
-   if (!endpoint)
-   break;
-
rem = of_graph_get_remote_port_parent(endpoint);
if (!rem) {
dev_dbg(>dev, "Remote device at %pOF not found\n",
@@ -1577,6 +1573,10 @@ vpif_capture_get_pdata(struct platform_device *pdev,
goto err_cleanup;
 
of_node_put(rem);
+
+   i++;
+   if (i >= VPIF_CAPTURE_NUM_CHANNELS)
+   break;
}
 
 done:
-- 
2.25.1



[PATCH v2 3/8] media: platform: microchip: use for_each_endpoint_of_node()

2024-03-31 Thread Kuninori Morimoto
We already have for_each_endpoint_of_node(), don't use
of_graph_get_next_endpoint() directly. Replace it.

Signed-off-by: Kuninori Morimoto 
---
 .../microchip/microchip-sama5d2-isc.c | 19 +++
 .../microchip/microchip-sama7g5-isc.c | 19 +++
 2 files changed, 14 insertions(+), 24 deletions(-)

diff --git a/drivers/media/platform/microchip/microchip-sama5d2-isc.c 
b/drivers/media/platform/microchip/microchip-sama5d2-isc.c
index 5ac149cf3647..d9298771f509 100644
--- a/drivers/media/platform/microchip/microchip-sama5d2-isc.c
+++ b/drivers/media/platform/microchip/microchip-sama5d2-isc.c
@@ -356,30 +356,26 @@ static int isc_parse_dt(struct device *dev, struct 
isc_device *isc)
struct device_node *epn = NULL;
struct isc_subdev_entity *subdev_entity;
unsigned int flags;
-   int ret;
 
INIT_LIST_HEAD(>subdev_entities);
 
-   while (1) {
+   for_each_endpoint_of_node(np, epn) {
struct v4l2_fwnode_endpoint v4l2_epn = { .bus_type = 0 };
-
-   epn = of_graph_get_next_endpoint(np, epn);
-   if (!epn)
-   return 0;
+   int ret;
 
ret = v4l2_fwnode_endpoint_parse(of_fwnode_handle(epn),
 _epn);
if (ret) {
-   ret = -EINVAL;
+   of_node_put(epn);
dev_err(dev, "Could not parse the endpoint\n");
-   break;
+   return -EINVAL;
}
 
subdev_entity = devm_kzalloc(dev, sizeof(*subdev_entity),
 GFP_KERNEL);
if (!subdev_entity) {
-   ret = -ENOMEM;
-   break;
+   of_node_put(epn);
+   return -ENOMEM;
}
subdev_entity->epn = epn;
 
@@ -400,9 +396,8 @@ static int isc_parse_dt(struct device *dev, struct 
isc_device *isc)
 
list_add_tail(_entity->list, >subdev_entities);
}
-   of_node_put(epn);
 
-   return ret;
+   return 0;
 }
 
 static int microchip_isc_probe(struct platform_device *pdev)
diff --git a/drivers/media/platform/microchip/microchip-sama7g5-isc.c 
b/drivers/media/platform/microchip/microchip-sama7g5-isc.c
index 73445f33d26b..36204fee10aa 100644
--- a/drivers/media/platform/microchip/microchip-sama7g5-isc.c
+++ b/drivers/media/platform/microchip/microchip-sama7g5-isc.c
@@ -339,33 +339,29 @@ static int xisc_parse_dt(struct device *dev, struct 
isc_device *isc)
struct device_node *epn = NULL;
struct isc_subdev_entity *subdev_entity;
unsigned int flags;
-   int ret;
bool mipi_mode;
 
INIT_LIST_HEAD(>subdev_entities);
 
mipi_mode = of_property_read_bool(np, "microchip,mipi-mode");
 
-   while (1) {
+   for_each_endpoint_of_node(np, epn) {
struct v4l2_fwnode_endpoint v4l2_epn = { .bus_type = 0 };
-
-   epn = of_graph_get_next_endpoint(np, epn);
-   if (!epn)
-   return 0;
+   int ret;
 
ret = v4l2_fwnode_endpoint_parse(of_fwnode_handle(epn),
 _epn);
if (ret) {
-   ret = -EINVAL;
+   of_node_put(epn);
dev_err(dev, "Could not parse the endpoint\n");
-   break;
+   return -EINVAL;
}
 
subdev_entity = devm_kzalloc(dev, sizeof(*subdev_entity),
 GFP_KERNEL);
if (!subdev_entity) {
-   ret = -ENOMEM;
-   break;
+   of_node_put(epn);
+   return -ENOMEM;
}
subdev_entity->epn = epn;
 
@@ -389,9 +385,8 @@ static int xisc_parse_dt(struct device *dev, struct 
isc_device *isc)
 
list_add_tail(_entity->list, >subdev_entities);
}
-   of_node_put(epn);
 
-   return ret;
+   return 0;
 }
 
 static int microchip_xisc_probe(struct platform_device *pdev)
-- 
2.25.1



[PATCH v2 2/8] hwtracing: use for_each_endpoint_of_node()

2024-03-31 Thread Kuninori Morimoto
We already have for_each_endpoint_of_node(), don't use
of_graph_get_next_endpoint() directly. Replace it.

Signed-off-by: Kuninori Morimoto 
Reviewed-by: Suzuki K Poulose 
---
 drivers/hwtracing/coresight/coresight-platform.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/hwtracing/coresight/coresight-platform.c 
b/drivers/hwtracing/coresight/coresight-platform.c
index 9d550f5697fa..e9683e613d52 100644
--- a/drivers/hwtracing/coresight/coresight-platform.c
+++ b/drivers/hwtracing/coresight/coresight-platform.c
@@ -275,7 +275,7 @@ static int of_get_coresight_platform_data(struct device 
*dev,
 */
if (!parent) {
/*
-* Avoid warnings in of_graph_get_next_endpoint()
+* Avoid warnings in for_each_endpoint_of_node()
 * if the device doesn't have any graph connections
 */
if (!of_graph_is_present(node))
@@ -286,7 +286,7 @@ static int of_get_coresight_platform_data(struct device 
*dev,
}
 
/* Iterate through each output port to discover topology */
-   while ((ep = of_graph_get_next_endpoint(parent, ep))) {
+   for_each_endpoint_of_node(parent, ep) {
/*
 * Legacy binding mixes input/output ports under the
 * same parent. So, skip the input ports if we are dealing
-- 
2.25.1



[PATCH v2 1/8] gpu: drm: use for_each_endpoint_of_node()

2024-03-31 Thread Kuninori Morimoto
We already have for_each_endpoint_of_node(), don't use
of_graph_get_next_endpoint() directly. Replace it.

Signed-off-by: Kuninori Morimoto 
---
 drivers/gpu/drm/omapdrm/dss/base.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/dss/base.c 
b/drivers/gpu/drm/omapdrm/dss/base.c
index 050ca7eafac5..5f8002f6bb7a 100644
--- a/drivers/gpu/drm/omapdrm/dss/base.c
+++ b/drivers/gpu/drm/omapdrm/dss/base.c
@@ -242,8 +242,7 @@ static void omapdss_walk_device(struct device *dev, struct 
device_node *node,
 
of_node_put(n);
 
-   n = NULL;
-   while ((n = of_graph_get_next_endpoint(node, n)) != NULL) {
+   for_each_endpoint_of_node(node, n) {
struct device_node *pn = of_graph_get_remote_port_parent(n);
 
if (!pn)
-- 
2.25.1



[PATCH v2 0/8] use for_each_endpoint_of_node()

2024-03-31 Thread Kuninori Morimoto


Hi Rob, Helge

We already have for_each_endpoint_of_node(), but some drivers are
not using it. This patch-set replace it.

This patch-set is related to "OF" (= Rob), but many driveres are for
"MultiMedia" (= Helge). I'm not sure who handle these.

[o] done
[*] this patch-set

[o] tidyup of_graph_get_endpoint_count()
[o] replace endpoint func - use endpoint_by_regs()
[*] replace endpoint func - use for_each()
[ ] rename endpoint func to device_endpoint
[ ] add new port function
[ ] add new endpont function
[ ] remove of_graph_get_next_device_endpoint()

v1 -> v2
- fixup TI patch

Link: https://lore.kernel.org/r/8734sf6mgn.wl-kuninori.morimoto...@renesas.com

Kuninori Morimoto (8):
  gpu: drm: use for_each_endpoint_of_node()
  hwtracing: use for_each_endpoint_of_node()
  media: platform: microchip: use for_each_endpoint_of_node()
  media: platform: ti: use for_each_endpoint_of_node()
  media: platform: xilinx: use for_each_endpoint_of_node()
  staging: media: atmel: use for_each_endpoint_of_node()
  video: fbdev: use for_each_endpoint_of_node()
  fbdev: omapfb: use of_graph_get_remote_port()

 drivers/gpu/drm/omapdrm/dss/base.c|  3 +--
 .../hwtracing/coresight/coresight-platform.c  |  4 ++--
 .../microchip/microchip-sama5d2-isc.c | 19 +++
 .../microchip/microchip-sama7g5-isc.c | 19 +++
 .../media/platform/ti/am437x/am437x-vpfe.c| 12 +---
 .../media/platform/ti/davinci/vpif_capture.c  | 12 ++--
 drivers/media/platform/xilinx/xilinx-vipp.c   |  7 +--
 .../deprecated/atmel/atmel-sama5d2-isc.c  |  6 +-
 .../deprecated/atmel/atmel-sama7g5-isc.c  |  6 +-
 drivers/video/fbdev/omap2/omapfb/dss/dss-of.c | 15 +--
 .../omap2/omapfb/dss/omapdss-boot-init.c  |  3 +--
 11 files changed, 33 insertions(+), 73 deletions(-)

-- 
2.25.1



Re: [PATCH 4/8] media: platform: ti: use for_each_endpoint_of_node()

2024-03-25 Thread Kuninori Morimoto


Hi Dan

> > We already have for_each_endpoint_of_node(), don't use
> > of_graph_get_next_endpoint() directly. Replace it.
> > 
> > Signed-off-by: Kuninori Morimoto 
> > ---
(snip)
> > -   for (i = 0; ; i++) {
> > +   for_each_endpoint_of_node(dev->of_node, endpoint) {
> > struct v4l2_fwnode_endpoint bus_cfg = { .bus_type = 0 };
> > struct device_node *rem;
> >  
> > -   endpoint = of_graph_get_next_endpoint(dev->of_node, endpoint);
> > -   if (!endpoint)
> > -   break;
> > -
> > sdinfo = >sub_devs[i];
>   ^
> "i" is uninitialized now.
> 
> Also in the initializer it has "struct device_node *endpoint = NULL;"
> which is unnecessary now.  And at the end it has:
> 
>   of_node_put(endpoint);
>   return pdata;
> 
> Since endpoint is NULL this was always a pointless no-op but now it's
> more obvious, so lets delete that.

Thank you for pointing it.
I will wait other feedback, and post v2 patch in next week.

Best regards
---
Renesas Electronics
Ph.D. Kuninori Morimoto


[PATCH 8/8] fbdev: omapfb: use of_graph_get_remote_port()

2024-03-24 Thread Kuninori Morimoto
We already have of_graph_get_remote_port(), Let's use it.

Signed-off-by: Kuninori Morimoto 
---
 drivers/video/fbdev/omap2/omapfb/dss/dss-of.c | 15 +--
 1 file changed, 1 insertion(+), 14 deletions(-)

diff --git a/drivers/video/fbdev/omap2/omapfb/dss/dss-of.c 
b/drivers/video/fbdev/omap2/omapfb/dss/dss-of.c
index 14965a3fd05b..4040e247e026 100644
--- a/drivers/video/fbdev/omap2/omapfb/dss/dss-of.c
+++ b/drivers/video/fbdev/omap2/omapfb/dss/dss-of.c
@@ -117,19 +117,6 @@ u32 dss_of_port_get_port_number(struct device_node *port)
return reg;
 }
 
-static struct device_node *omapdss_of_get_remote_port(const struct device_node 
*node)
-{
-   struct device_node *np;
-
-   np = of_graph_get_remote_endpoint(node);
-   if (!np)
-   return NULL;
-
-   np = of_get_next_parent(np);
-
-   return np;
-}
-
 struct omap_dss_device *
 omapdss_of_find_source_for_first_ep(struct device_node *node)
 {
@@ -141,7 +128,7 @@ omapdss_of_find_source_for_first_ep(struct device_node 
*node)
if (!ep)
return ERR_PTR(-EINVAL);
 
-   src_port = omapdss_of_get_remote_port(ep);
+   src_port = of_graph_get_remote_port(ep);
if (!src_port) {
of_node_put(ep);
return ERR_PTR(-EINVAL);
-- 
2.25.1



[PATCH 7/8] video: fbdev: use for_each_endpoint_of_node()

2024-03-24 Thread Kuninori Morimoto
We already have for_each_endpoint_of_node(), don't use
of_graph_get_next_endpoint() directly. Replace it.

Signed-off-by: Kuninori Morimoto 
---
 drivers/video/fbdev/omap2/omapfb/dss/omapdss-boot-init.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/video/fbdev/omap2/omapfb/dss/omapdss-boot-init.c 
b/drivers/video/fbdev/omap2/omapfb/dss/omapdss-boot-init.c
index 09f719af0d0c..d80720c84323 100644
--- a/drivers/video/fbdev/omap2/omapfb/dss/omapdss-boot-init.c
+++ b/drivers/video/fbdev/omap2/omapfb/dss/omapdss-boot-init.c
@@ -149,8 +149,7 @@ static void __init omapdss_walk_device(struct device_node 
*node, bool root)
 
of_node_put(n);
 
-   n = NULL;
-   while ((n = of_graph_get_next_endpoint(node, n)) != NULL) {
+   for_each_endpoint_of_node(node, n) {
struct device_node *pn;
 
pn = of_graph_get_remote_port_parent(n);
-- 
2.25.1



[PATCH 6/8] staging: media: atmel: use for_each_endpoint_of_node()

2024-03-24 Thread Kuninori Morimoto
We already have for_each_endpoint_of_node(), don't use
of_graph_get_next_endpoint() directly. Replace it.

Signed-off-by: Kuninori Morimoto 
---
 drivers/staging/media/deprecated/atmel/atmel-sama5d2-isc.c | 6 +-
 drivers/staging/media/deprecated/atmel/atmel-sama7g5-isc.c | 6 +-
 2 files changed, 2 insertions(+), 10 deletions(-)

diff --git a/drivers/staging/media/deprecated/atmel/atmel-sama5d2-isc.c 
b/drivers/staging/media/deprecated/atmel/atmel-sama5d2-isc.c
index 31b2b48085c5..cbfbec0c6cb5 100644
--- a/drivers/staging/media/deprecated/atmel/atmel-sama5d2-isc.c
+++ b/drivers/staging/media/deprecated/atmel/atmel-sama5d2-isc.c
@@ -340,13 +340,9 @@ static int isc_parse_dt(struct device *dev, struct 
isc_device *isc)
 
INIT_LIST_HEAD(>subdev_entities);
 
-   while (1) {
+   for_each_endpoint_of_node(np, epn) {
struct v4l2_fwnode_endpoint v4l2_epn = { .bus_type = 0 };
 
-   epn = of_graph_get_next_endpoint(np, epn);
-   if (!epn)
-   return 0;
-
ret = v4l2_fwnode_endpoint_parse(of_fwnode_handle(epn),
 _epn);
if (ret) {
diff --git a/drivers/staging/media/deprecated/atmel/atmel-sama7g5-isc.c 
b/drivers/staging/media/deprecated/atmel/atmel-sama7g5-isc.c
index 020034f631f5..7c477b1d3c48 100644
--- a/drivers/staging/media/deprecated/atmel/atmel-sama7g5-isc.c
+++ b/drivers/staging/media/deprecated/atmel/atmel-sama7g5-isc.c
@@ -326,13 +326,9 @@ static int xisc_parse_dt(struct device *dev, struct 
isc_device *isc)
 
mipi_mode = of_property_read_bool(np, "microchip,mipi-mode");
 
-   while (1) {
+   for_each_endpoint_of_node(np, epn) {
struct v4l2_fwnode_endpoint v4l2_epn = { .bus_type = 0 };
 
-   epn = of_graph_get_next_endpoint(np, epn);
-   if (!epn)
-   return 0;
-
ret = v4l2_fwnode_endpoint_parse(of_fwnode_handle(epn),
 _epn);
if (ret) {
-- 
2.25.1



[PATCH 5/8] media: platform: xilinx: use for_each_endpoint_of_node()

2024-03-24 Thread Kuninori Morimoto
We already have for_each_endpoint_of_node(), don't use
of_graph_get_next_endpoint() directly. Replace it.

Signed-off-by: Kuninori Morimoto 
---
 drivers/media/platform/xilinx/xilinx-vipp.c | 7 +--
 1 file changed, 1 insertion(+), 6 deletions(-)

diff --git a/drivers/media/platform/xilinx/xilinx-vipp.c 
b/drivers/media/platform/xilinx/xilinx-vipp.c
index 996684a73038..38818b82a575 100644
--- a/drivers/media/platform/xilinx/xilinx-vipp.c
+++ b/drivers/media/platform/xilinx/xilinx-vipp.c
@@ -205,12 +205,7 @@ static int xvip_graph_build_dma(struct 
xvip_composite_device *xdev)
 
dev_dbg(xdev->dev, "creating links for DMA engines\n");
 
-   while (1) {
-   /* Get the next endpoint and parse its link. */
-   ep = of_graph_get_next_endpoint(node, ep);
-   if (ep == NULL)
-   break;
-
+   for_each_endpoint_of_node(node, ep) {
dev_dbg(xdev->dev, "processing endpoint %pOF\n", ep);
 
ret = v4l2_fwnode_parse_link(of_fwnode_handle(ep), );
-- 
2.25.1



[PATCH 3/8] media: platform: microchip: use for_each_endpoint_of_node()

2024-03-24 Thread Kuninori Morimoto
We already have for_each_endpoint_of_node(), don't use
of_graph_get_next_endpoint() directly. Replace it.

Signed-off-by: Kuninori Morimoto 
---
 .../microchip/microchip-sama5d2-isc.c | 19 +++
 .../microchip/microchip-sama7g5-isc.c | 19 +++
 2 files changed, 14 insertions(+), 24 deletions(-)

diff --git a/drivers/media/platform/microchip/microchip-sama5d2-isc.c 
b/drivers/media/platform/microchip/microchip-sama5d2-isc.c
index 5ac149cf3647..d9298771f509 100644
--- a/drivers/media/platform/microchip/microchip-sama5d2-isc.c
+++ b/drivers/media/platform/microchip/microchip-sama5d2-isc.c
@@ -356,30 +356,26 @@ static int isc_parse_dt(struct device *dev, struct 
isc_device *isc)
struct device_node *epn = NULL;
struct isc_subdev_entity *subdev_entity;
unsigned int flags;
-   int ret;
 
INIT_LIST_HEAD(>subdev_entities);
 
-   while (1) {
+   for_each_endpoint_of_node(np, epn) {
struct v4l2_fwnode_endpoint v4l2_epn = { .bus_type = 0 };
-
-   epn = of_graph_get_next_endpoint(np, epn);
-   if (!epn)
-   return 0;
+   int ret;
 
ret = v4l2_fwnode_endpoint_parse(of_fwnode_handle(epn),
 _epn);
if (ret) {
-   ret = -EINVAL;
+   of_node_put(epn);
dev_err(dev, "Could not parse the endpoint\n");
-   break;
+   return -EINVAL;
}
 
subdev_entity = devm_kzalloc(dev, sizeof(*subdev_entity),
 GFP_KERNEL);
if (!subdev_entity) {
-   ret = -ENOMEM;
-   break;
+   of_node_put(epn);
+   return -ENOMEM;
}
subdev_entity->epn = epn;
 
@@ -400,9 +396,8 @@ static int isc_parse_dt(struct device *dev, struct 
isc_device *isc)
 
list_add_tail(_entity->list, >subdev_entities);
}
-   of_node_put(epn);
 
-   return ret;
+   return 0;
 }
 
 static int microchip_isc_probe(struct platform_device *pdev)
diff --git a/drivers/media/platform/microchip/microchip-sama7g5-isc.c 
b/drivers/media/platform/microchip/microchip-sama7g5-isc.c
index 73445f33d26b..36204fee10aa 100644
--- a/drivers/media/platform/microchip/microchip-sama7g5-isc.c
+++ b/drivers/media/platform/microchip/microchip-sama7g5-isc.c
@@ -339,33 +339,29 @@ static int xisc_parse_dt(struct device *dev, struct 
isc_device *isc)
struct device_node *epn = NULL;
struct isc_subdev_entity *subdev_entity;
unsigned int flags;
-   int ret;
bool mipi_mode;
 
INIT_LIST_HEAD(>subdev_entities);
 
mipi_mode = of_property_read_bool(np, "microchip,mipi-mode");
 
-   while (1) {
+   for_each_endpoint_of_node(np, epn) {
struct v4l2_fwnode_endpoint v4l2_epn = { .bus_type = 0 };
-
-   epn = of_graph_get_next_endpoint(np, epn);
-   if (!epn)
-   return 0;
+   int ret;
 
ret = v4l2_fwnode_endpoint_parse(of_fwnode_handle(epn),
 _epn);
if (ret) {
-   ret = -EINVAL;
+   of_node_put(epn);
dev_err(dev, "Could not parse the endpoint\n");
-   break;
+   return -EINVAL;
}
 
subdev_entity = devm_kzalloc(dev, sizeof(*subdev_entity),
 GFP_KERNEL);
if (!subdev_entity) {
-   ret = -ENOMEM;
-   break;
+   of_node_put(epn);
+   return -ENOMEM;
}
subdev_entity->epn = epn;
 
@@ -389,9 +385,8 @@ static int xisc_parse_dt(struct device *dev, struct 
isc_device *isc)
 
list_add_tail(_entity->list, >subdev_entities);
}
-   of_node_put(epn);
 
-   return ret;
+   return 0;
 }
 
 static int microchip_xisc_probe(struct platform_device *pdev)
-- 
2.25.1



[PATCH 4/8] media: platform: ti: use for_each_endpoint_of_node()

2024-03-24 Thread Kuninori Morimoto
We already have for_each_endpoint_of_node(), don't use
of_graph_get_next_endpoint() directly. Replace it.

Signed-off-by: Kuninori Morimoto 
---
 drivers/media/platform/ti/am437x/am437x-vpfe.c   |  8 +++-
 drivers/media/platform/ti/davinci/vpif_capture.c | 11 +--
 2 files changed, 8 insertions(+), 11 deletions(-)

diff --git a/drivers/media/platform/ti/am437x/am437x-vpfe.c 
b/drivers/media/platform/ti/am437x/am437x-vpfe.c
index 77e12457d149..4f185a0d42b3 100644
--- a/drivers/media/platform/ti/am437x/am437x-vpfe.c
+++ b/drivers/media/platform/ti/am437x/am437x-vpfe.c
@@ -2306,14 +2306,10 @@ vpfe_get_pdata(struct vpfe_device *vpfe)
if (!pdata)
return NULL;
 
-   for (i = 0; ; i++) {
+   for_each_endpoint_of_node(dev->of_node, endpoint) {
struct v4l2_fwnode_endpoint bus_cfg = { .bus_type = 0 };
struct device_node *rem;
 
-   endpoint = of_graph_get_next_endpoint(dev->of_node, endpoint);
-   if (!endpoint)
-   break;
-
sdinfo = >sub_devs[i];
sdinfo->grp_id = 0;
 
@@ -2371,6 +2367,8 @@ vpfe_get_pdata(struct vpfe_device *vpfe)
of_node_put(rem);
if (IS_ERR(pdata->asd[i]))
goto cleanup;
+
+   i++;
}
 
of_node_put(endpoint);
diff --git a/drivers/media/platform/ti/davinci/vpif_capture.c 
b/drivers/media/platform/ti/davinci/vpif_capture.c
index c31a5566fc5a..8b7077a265e6 100644
--- a/drivers/media/platform/ti/davinci/vpif_capture.c
+++ b/drivers/media/platform/ti/davinci/vpif_capture.c
@@ -1517,16 +1517,11 @@ vpif_capture_get_pdata(struct platform_device *pdev,
if (!pdata->subdev_info)
return NULL;
 
-   for (i = 0; i < VPIF_CAPTURE_NUM_CHANNELS; i++) {
+   for_each_endpoint_of_node(pdev->dev.of_node, endpoint) {
struct v4l2_fwnode_endpoint bus_cfg = { .bus_type = 0 };
unsigned int flags;
int err;
 
-   endpoint = of_graph_get_next_endpoint(pdev->dev.of_node,
- endpoint);
-   if (!endpoint)
-   break;
-
rem = of_graph_get_remote_port_parent(endpoint);
if (!rem) {
dev_dbg(>dev, "Remote device at %pOF not found\n",
@@ -1577,6 +1572,10 @@ vpif_capture_get_pdata(struct platform_device *pdev,
goto err_cleanup;
 
of_node_put(rem);
+
+   i++;
+   if (i >= VPIF_CAPTURE_NUM_CHANNELS)
+   break;
}
 
 done:
-- 
2.25.1



[PATCH 2/8] hwtracing: use for_each_endpoint_of_node()

2024-03-24 Thread Kuninori Morimoto
We already have for_each_endpoint_of_node(), don't use
of_graph_get_next_endpoint() directly. Replace it.

Signed-off-by: Kuninori Morimoto 
Reviewed-by: Suzuki K Poulose 
---
 drivers/hwtracing/coresight/coresight-platform.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/hwtracing/coresight/coresight-platform.c 
b/drivers/hwtracing/coresight/coresight-platform.c
index 9d550f5697fa..e9683e613d52 100644
--- a/drivers/hwtracing/coresight/coresight-platform.c
+++ b/drivers/hwtracing/coresight/coresight-platform.c
@@ -275,7 +275,7 @@ static int of_get_coresight_platform_data(struct device 
*dev,
 */
if (!parent) {
/*
-* Avoid warnings in of_graph_get_next_endpoint()
+* Avoid warnings in for_each_endpoint_of_node()
 * if the device doesn't have any graph connections
 */
if (!of_graph_is_present(node))
@@ -286,7 +286,7 @@ static int of_get_coresight_platform_data(struct device 
*dev,
}
 
/* Iterate through each output port to discover topology */
-   while ((ep = of_graph_get_next_endpoint(parent, ep))) {
+   for_each_endpoint_of_node(parent, ep) {
/*
 * Legacy binding mixes input/output ports under the
 * same parent. So, skip the input ports if we are dealing
-- 
2.25.1



[PATCH 1/8] gpu: drm: use for_each_endpoint_of_node()

2024-03-24 Thread Kuninori Morimoto
We already have for_each_endpoint_of_node(), don't use
of_graph_get_next_endpoint() directly. Replace it.

Signed-off-by: Kuninori Morimoto 
---
 drivers/gpu/drm/omapdrm/dss/base.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/dss/base.c 
b/drivers/gpu/drm/omapdrm/dss/base.c
index 050ca7eafac5..5f8002f6bb7a 100644
--- a/drivers/gpu/drm/omapdrm/dss/base.c
+++ b/drivers/gpu/drm/omapdrm/dss/base.c
@@ -242,8 +242,7 @@ static void omapdss_walk_device(struct device *dev, struct 
device_node *node,
 
of_node_put(n);
 
-   n = NULL;
-   while ((n = of_graph_get_next_endpoint(node, n)) != NULL) {
+   for_each_endpoint_of_node(node, n) {
struct device_node *pn = of_graph_get_remote_port_parent(n);
 
if (!pn)
-- 
2.25.1



[PATCH 0/8] use for_each_endpoint_of_node()

2024-03-24 Thread Kuninori Morimoto


Hi Rob, Helge

We already have for_each_endpoint_of_node(), but some drivers are
not using it. This patch-set replace it.

This patch-set is related to "OF" (= Rob), but many driveres are for
"MultiMedia" (= Helge). I'm not sure who can handle it.

[o] done
[x] under reviewing
[*] this patch-set

[o] tidyup of_graph_get_endpoint_count()
[x] replace endpoint func - use endpoint_by_regs()
[*] replace endpoint func - use for_each()
[ ] rename endpoint func to device_endpoint
[ ] add new port function
[ ] add new endpont function
[ ] remove of_graph_get_next_device_endpoint()

Kuninori Morimoto (8):
  gpu: drm: use for_each_endpoint_of_node()
  hwtracing: use for_each_endpoint_of_node()
  media: platform: microchip: use for_each_endpoint_of_node()
  media: platform: ti: use for_each_endpoint_of_node()
  media: platform: xilinx: use for_each_endpoint_of_node()
  staging: media: atmel: use for_each_endpoint_of_node()
  video: fbdev: use for_each_endpoint_of_node()
  fbdev: omapfb: use of_graph_get_remote_port()

 drivers/gpu/drm/omapdrm/dss/base.c|  3 +--
 .../hwtracing/coresight/coresight-platform.c  |  4 ++--
 .../microchip/microchip-sama5d2-isc.c | 19 +++
 .../microchip/microchip-sama7g5-isc.c | 19 +++
 .../media/platform/ti/am437x/am437x-vpfe.c|  8 +++-
 .../media/platform/ti/davinci/vpif_capture.c  | 11 +--
 drivers/media/platform/xilinx/xilinx-vipp.c   |  7 +--
 .../deprecated/atmel/atmel-sama5d2-isc.c  |  6 +-
 .../deprecated/atmel/atmel-sama7g5-isc.c  |  6 +-
 drivers/video/fbdev/omap2/omapfb/dss/dss-of.c | 15 +--
 .../omap2/omapfb/dss/omapdss-boot-init.c  |  3 +--
 11 files changed, 30 insertions(+), 71 deletions(-)

-- 
2.25.1



[PATCH 2/2] video: fbdev: replace of_graph_get_next_endpoint()

2024-03-24 Thread Kuninori Morimoto
>From DT point of view, in general, drivers should be asking for a
specific port number because their function is fixed in the binding.

of_graph_get_next_endpoint() doesn't match to this concept.

Simply replace

- of_graph_get_next_endpoint(xxx, NULL);
+ of_graph_get_endpoint_by_regs(xxx, 0, -1);

Link: https://lore.kernel.org/r/20240202174941.ga310089-r...@kernel.org
Signed-off-by: Kuninori Morimoto 
Reviewed-by: Laurent Pinchart 
---
 drivers/video/fbdev/omap2/omapfb/dss/dsi.c|  3 ++-
 drivers/video/fbdev/omap2/omapfb/dss/dss-of.c | 20 +--
 drivers/video/fbdev/omap2/omapfb/dss/hdmi4.c  |  3 ++-
 drivers/video/fbdev/omap2/omapfb/dss/hdmi5.c  |  3 ++-
 drivers/video/fbdev/omap2/omapfb/dss/venc.c   |  3 ++-
 drivers/video/fbdev/pxafb.c   |  2 +-
 include/video/omapfb_dss.h|  3 ---
 7 files changed, 10 insertions(+), 27 deletions(-)

diff --git a/drivers/video/fbdev/omap2/omapfb/dss/dsi.c 
b/drivers/video/fbdev/omap2/omapfb/dss/dsi.c
index b7eb17a16ec4..1f13bcf73da5 100644
--- a/drivers/video/fbdev/omap2/omapfb/dss/dsi.c
+++ b/drivers/video/fbdev/omap2/omapfb/dss/dsi.c
@@ -28,6 +28,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 
@@ -5079,7 +5080,7 @@ static int dsi_probe_of(struct platform_device *pdev)
struct device_node *ep;
struct omap_dsi_pin_config pin_cfg;
 
-   ep = omapdss_of_get_first_endpoint(node);
+   ep = of_graph_get_endpoint_by_regs(node, 0, -1);
if (!ep)
return 0;
 
diff --git a/drivers/video/fbdev/omap2/omapfb/dss/dss-of.c 
b/drivers/video/fbdev/omap2/omapfb/dss/dss-of.c
index 0282d4eef139..14965a3fd05b 100644
--- a/drivers/video/fbdev/omap2/omapfb/dss/dss-of.c
+++ b/drivers/video/fbdev/omap2/omapfb/dss/dss-of.c
@@ -130,24 +130,6 @@ static struct device_node 
*omapdss_of_get_remote_port(const struct device_node *
return np;
 }
 
-struct device_node *
-omapdss_of_get_first_endpoint(const struct device_node *parent)
-{
-   struct device_node *port, *ep;
-
-   port = omapdss_of_get_next_port(parent, NULL);
-
-   if (!port)
-   return NULL;
-
-   ep = omapdss_of_get_next_endpoint(port, NULL);
-
-   of_node_put(port);
-
-   return ep;
-}
-EXPORT_SYMBOL_GPL(omapdss_of_get_first_endpoint);
-
 struct omap_dss_device *
 omapdss_of_find_source_for_first_ep(struct device_node *node)
 {
@@ -155,7 +137,7 @@ omapdss_of_find_source_for_first_ep(struct device_node 
*node)
struct device_node *src_port;
struct omap_dss_device *src;
 
-   ep = omapdss_of_get_first_endpoint(node);
+   ep = of_graph_get_endpoint_by_regs(node, 0, -1);
if (!ep)
return ERR_PTR(-EINVAL);
 
diff --git a/drivers/video/fbdev/omap2/omapfb/dss/hdmi4.c 
b/drivers/video/fbdev/omap2/omapfb/dss/hdmi4.c
index f05b4e35a842..8f407ec134dc 100644
--- a/drivers/video/fbdev/omap2/omapfb/dss/hdmi4.c
+++ b/drivers/video/fbdev/omap2/omapfb/dss/hdmi4.c
@@ -20,6 +20,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -529,7 +530,7 @@ static int hdmi_probe_of(struct platform_device *pdev)
struct device_node *ep;
int r;
 
-   ep = omapdss_of_get_first_endpoint(node);
+   ep = of_graph_get_endpoint_by_regs(node, 0, -1);
if (!ep)
return 0;
 
diff --git a/drivers/video/fbdev/omap2/omapfb/dss/hdmi5.c 
b/drivers/video/fbdev/omap2/omapfb/dss/hdmi5.c
index 03292945b1d4..4ad219f522b9 100644
--- a/drivers/video/fbdev/omap2/omapfb/dss/hdmi5.c
+++ b/drivers/video/fbdev/omap2/omapfb/dss/hdmi5.c
@@ -25,6 +25,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -561,7 +562,7 @@ static int hdmi_probe_of(struct platform_device *pdev)
struct device_node *ep;
int r;
 
-   ep = omapdss_of_get_first_endpoint(node);
+   ep = of_graph_get_endpoint_by_regs(node, 0, -1);
if (!ep)
return 0;
 
diff --git a/drivers/video/fbdev/omap2/omapfb/dss/venc.c 
b/drivers/video/fbdev/omap2/omapfb/dss/venc.c
index c9d40e28a06f..0bd80d3b8f1b 100644
--- a/drivers/video/fbdev/omap2/omapfb/dss/venc.c
+++ b/drivers/video/fbdev/omap2/omapfb/dss/venc.c
@@ -24,6 +24,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 
 #include 
@@ -764,7 +765,7 @@ static int venc_probe_of(struct platform_device *pdev)
u32 channels;
int r;
 
-   ep = omapdss_of_get_first_endpoint(node);
+   ep = of_graph_get_endpoint_by_regs(node, 0, -1);
if (!ep)
return 0;
 
diff --git a/drivers/video/fbdev/pxafb.c b/drivers/video/fbdev/pxafb.c
index fa943612c4e2..2ef56fa28aff 100644
--- a/drivers/video/fbdev/pxafb.c
+++ b/drivers/video/fbdev/pxafb.c
@@ -2171,7 +2171,7 @@ static int of_get_pxafb_mode_info(struct device *dev,
u32 bus_width;
int ret, i;
 
-   np = of_graph_get_next_endpoint(dev->of_node, NULL);
+   np = of_graph_get_endpoint_by_regs(dev-&g

[PATCH 1/2] gpu: drm: replace of_graph_get_next_endpoint()

2024-03-24 Thread Kuninori Morimoto
>From DT point of view, in general, drivers should be asking for a
specific port number because their function is fixed in the binding.

of_graph_get_next_endpoint() doesn't match to this concept.

Simply replace

- of_graph_get_next_endpoint(xxx, NULL);
+ of_graph_get_endpoint_by_regs(xxx, 0, -1);

Link: https://lore.kernel.org/r/20240202174941.ga310089-r...@kernel.org
Signed-off-by: Kuninori Morimoto 
Reviewed-by: Laurent Pinchart 
---
 drivers/gpu/drm/drm_of.c  | 4 +++-
 drivers/gpu/drm/panel/panel-raspberrypi-touchscreen.c | 2 +-
 drivers/gpu/drm/tiny/arcpgu.c | 2 +-
 3 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/drm_of.c b/drivers/gpu/drm/drm_of.c
index 177b600895d3..b6b2cade69ae 100644
--- a/drivers/gpu/drm/drm_of.c
+++ b/drivers/gpu/drm/drm_of.c
@@ -504,6 +504,8 @@ EXPORT_SYMBOL_GPL(drm_of_get_data_lanes_count_ep);
  * Gets parent DSI bus for a DSI device controlled through a bus other
  * than MIPI-DCS (SPI, I2C, etc.) using the Device Tree.
  *
+ * This function assumes that the device's port@0 is the DSI input.
+ *
  * Returns pointer to mipi_dsi_host if successful, -EINVAL if the
  * request is unsupported, -EPROBE_DEFER if the DSI host is found but
  * not available, or -ENODEV otherwise.
@@ -516,7 +518,7 @@ struct mipi_dsi_host *drm_of_get_dsi_bus(struct device *dev)
/*
 * Get first endpoint child from device.
 */
-   endpoint = of_graph_get_next_endpoint(dev->of_node, NULL);
+   endpoint = of_graph_get_endpoint_by_regs(dev->of_node, 0, -1);
if (!endpoint)
return ERR_PTR(-ENODEV);
 
diff --git a/drivers/gpu/drm/panel/panel-raspberrypi-touchscreen.c 
b/drivers/gpu/drm/panel/panel-raspberrypi-touchscreen.c
index 4618c892cdd6..e10e469aa7a6 100644
--- a/drivers/gpu/drm/panel/panel-raspberrypi-touchscreen.c
+++ b/drivers/gpu/drm/panel/panel-raspberrypi-touchscreen.c
@@ -400,7 +400,7 @@ static int rpi_touchscreen_probe(struct i2c_client *i2c)
rpi_touchscreen_i2c_write(ts, REG_POWERON, 0);
 
/* Look up the DSI host.  It needs to probe before we do. */
-   endpoint = of_graph_get_next_endpoint(dev->of_node, NULL);
+   endpoint = of_graph_get_endpoint_by_regs(dev->of_node, 0, -1);
if (!endpoint)
return -ENODEV;
 
diff --git a/drivers/gpu/drm/tiny/arcpgu.c b/drivers/gpu/drm/tiny/arcpgu.c
index 4f8f3172379e..8c29b719ea62 100644
--- a/drivers/gpu/drm/tiny/arcpgu.c
+++ b/drivers/gpu/drm/tiny/arcpgu.c
@@ -288,7 +288,7 @@ static int arcpgu_load(struct arcpgu_drm_private *arcpgu)
 * There is only one output port inside each device. It is linked with
 * encoder endpoint.
 */
-   endpoint_node = of_graph_get_next_endpoint(pdev->dev.of_node, NULL);
+   endpoint_node = of_graph_get_endpoint_by_regs(pdev->dev.of_node, 0, -1);
if (endpoint_node) {
encoder_node = of_graph_get_remote_port_parent(endpoint_node);
of_node_put(endpoint_node);
-- 
2.25.1



[PATCH 0/2] of: replace of_graph_get_next_endpoint()

2024-03-24 Thread Kuninori Morimoto


Hi Rob, Helge

This is resend of remain of replace of_graph_get_next_endpoint()
(In previous patch-set, media maintainer accepted some of them).
This patches are for GPU/Video, I'm not sure who should handle it.
GPU/Video maintainer as Video, or Rom as OF ?

We should get rid of or minimize of_graph_get_next_endpoint() in
its current form. In general, drivers should be asking for a specific 
port number because their function is fixed in the binding.

https://lore.kernel.org/r/20240131184347.ga1906672-r...@kernel.org

This patch-set replace of_graph_get_next_endpoint() by
of_graph_get_endpoint_by_regs(). There are still next_endpoint()
after this patch-set, but it will be replaced by
for_each_endpoint_of_node() in next patch-set (A)

[*] this patch-set
[o] done

[o] tidyup of_graph_get_endpoint_count()
[*] replace endpoint func - use endpoint_by_regs()
(A) [ ] replace endpoint func - use for_each()
[ ] rename endpoint func to device_endpoint
[ ] add new port function
[ ] add new endpont function
[ ] remove of_graph_get_next_device_endpoint()

v1 -> v2
- add Reviewed-by from Launrent
- use by_regs(xx, -1, -1) for some devices
- add extra explain for drm_of_get_dsi_bus()
- add FIXME and Link on adv7604.c
- based on latest of branch

Kuninori Morimoto (2):
  gpu: drm: replace of_graph_get_next_endpoint()
  video: fbdev: replace of_graph_get_next_endpoint()

 drivers/gpu/drm/drm_of.c  |  4 +++-
 .../drm/panel/panel-raspberrypi-touchscreen.c |  2 +-
 drivers/gpu/drm/tiny/arcpgu.c |  2 +-
 drivers/video/fbdev/omap2/omapfb/dss/dsi.c|  3 ++-
 drivers/video/fbdev/omap2/omapfb/dss/dss-of.c | 20 +--
 drivers/video/fbdev/omap2/omapfb/dss/hdmi4.c  |  3 ++-
 drivers/video/fbdev/omap2/omapfb/dss/hdmi5.c  |  3 ++-
 drivers/video/fbdev/omap2/omapfb/dss/venc.c   |  3 ++-
 drivers/video/fbdev/pxafb.c   |  2 +-
 include/video/omapfb_dss.h|  3 ---
 10 files changed, 15 insertions(+), 30 deletions(-)

-- 
2.25.1



[PATCH v2 4/4] video: fbdev: replace of_graph_get_next_endpoint()

2024-03-03 Thread Kuninori Morimoto
>From DT point of view, in general, drivers should be asking for a
specific port number because their function is fixed in the binding.

of_graph_get_next_endpoint() doesn't match to this concept.

Simply replace

- of_graph_get_next_endpoint(xxx, NULL);
+ of_graph_get_endpoint_by_regs(xxx, 0, -1);

Link: https://lore.kernel.org/r/20240202174941.ga310089-r...@kernel.org
Signed-off-by: Kuninori Morimoto 
Reviewed-by: Laurent Pinchart 
---
 drivers/video/fbdev/omap2/omapfb/dss/dsi.c|  3 ++-
 drivers/video/fbdev/omap2/omapfb/dss/dss-of.c | 20 +--
 drivers/video/fbdev/omap2/omapfb/dss/hdmi4.c  |  3 ++-
 drivers/video/fbdev/omap2/omapfb/dss/hdmi5.c  |  3 ++-
 drivers/video/fbdev/omap2/omapfb/dss/venc.c   |  3 ++-
 drivers/video/fbdev/pxafb.c   |  2 +-
 include/video/omapfb_dss.h|  3 ---
 7 files changed, 10 insertions(+), 27 deletions(-)

diff --git a/drivers/video/fbdev/omap2/omapfb/dss/dsi.c 
b/drivers/video/fbdev/omap2/omapfb/dss/dsi.c
index b7eb17a16ec4..1f13bcf73da5 100644
--- a/drivers/video/fbdev/omap2/omapfb/dss/dsi.c
+++ b/drivers/video/fbdev/omap2/omapfb/dss/dsi.c
@@ -28,6 +28,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 
@@ -5079,7 +5080,7 @@ static int dsi_probe_of(struct platform_device *pdev)
struct device_node *ep;
struct omap_dsi_pin_config pin_cfg;
 
-   ep = omapdss_of_get_first_endpoint(node);
+   ep = of_graph_get_endpoint_by_regs(node, 0, -1);
if (!ep)
return 0;
 
diff --git a/drivers/video/fbdev/omap2/omapfb/dss/dss-of.c 
b/drivers/video/fbdev/omap2/omapfb/dss/dss-of.c
index 0282d4eef139..14965a3fd05b 100644
--- a/drivers/video/fbdev/omap2/omapfb/dss/dss-of.c
+++ b/drivers/video/fbdev/omap2/omapfb/dss/dss-of.c
@@ -130,24 +130,6 @@ static struct device_node 
*omapdss_of_get_remote_port(const struct device_node *
return np;
 }
 
-struct device_node *
-omapdss_of_get_first_endpoint(const struct device_node *parent)
-{
-   struct device_node *port, *ep;
-
-   port = omapdss_of_get_next_port(parent, NULL);
-
-   if (!port)
-   return NULL;
-
-   ep = omapdss_of_get_next_endpoint(port, NULL);
-
-   of_node_put(port);
-
-   return ep;
-}
-EXPORT_SYMBOL_GPL(omapdss_of_get_first_endpoint);
-
 struct omap_dss_device *
 omapdss_of_find_source_for_first_ep(struct device_node *node)
 {
@@ -155,7 +137,7 @@ omapdss_of_find_source_for_first_ep(struct device_node 
*node)
struct device_node *src_port;
struct omap_dss_device *src;
 
-   ep = omapdss_of_get_first_endpoint(node);
+   ep = of_graph_get_endpoint_by_regs(node, 0, -1);
if (!ep)
return ERR_PTR(-EINVAL);
 
diff --git a/drivers/video/fbdev/omap2/omapfb/dss/hdmi4.c 
b/drivers/video/fbdev/omap2/omapfb/dss/hdmi4.c
index f05b4e35a842..8f407ec134dc 100644
--- a/drivers/video/fbdev/omap2/omapfb/dss/hdmi4.c
+++ b/drivers/video/fbdev/omap2/omapfb/dss/hdmi4.c
@@ -20,6 +20,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -529,7 +530,7 @@ static int hdmi_probe_of(struct platform_device *pdev)
struct device_node *ep;
int r;
 
-   ep = omapdss_of_get_first_endpoint(node);
+   ep = of_graph_get_endpoint_by_regs(node, 0, -1);
if (!ep)
return 0;
 
diff --git a/drivers/video/fbdev/omap2/omapfb/dss/hdmi5.c 
b/drivers/video/fbdev/omap2/omapfb/dss/hdmi5.c
index 03292945b1d4..4ad219f522b9 100644
--- a/drivers/video/fbdev/omap2/omapfb/dss/hdmi5.c
+++ b/drivers/video/fbdev/omap2/omapfb/dss/hdmi5.c
@@ -25,6 +25,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -561,7 +562,7 @@ static int hdmi_probe_of(struct platform_device *pdev)
struct device_node *ep;
int r;
 
-   ep = omapdss_of_get_first_endpoint(node);
+   ep = of_graph_get_endpoint_by_regs(node, 0, -1);
if (!ep)
return 0;
 
diff --git a/drivers/video/fbdev/omap2/omapfb/dss/venc.c 
b/drivers/video/fbdev/omap2/omapfb/dss/venc.c
index c9d40e28a06f..0bd80d3b8f1b 100644
--- a/drivers/video/fbdev/omap2/omapfb/dss/venc.c
+++ b/drivers/video/fbdev/omap2/omapfb/dss/venc.c
@@ -24,6 +24,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 
 #include 
@@ -764,7 +765,7 @@ static int venc_probe_of(struct platform_device *pdev)
u32 channels;
int r;
 
-   ep = omapdss_of_get_first_endpoint(node);
+   ep = of_graph_get_endpoint_by_regs(node, 0, -1);
if (!ep)
return 0;
 
diff --git a/drivers/video/fbdev/pxafb.c b/drivers/video/fbdev/pxafb.c
index fa943612c4e2..2ef56fa28aff 100644
--- a/drivers/video/fbdev/pxafb.c
+++ b/drivers/video/fbdev/pxafb.c
@@ -2171,7 +2171,7 @@ static int of_get_pxafb_mode_info(struct device *dev,
u32 bus_width;
int ret, i;
 
-   np = of_graph_get_next_endpoint(dev->of_node, NULL);
+   np = of_graph_get_endpoint_by_regs(dev-&g

[PATCH v2 3/4] media: platform: replace of_graph_get_next_endpoint()

2024-03-03 Thread Kuninori Morimoto
>From DT point of view, in general, drivers should be asking for a
specific port number because their function is fixed in the binding.

of_graph_get_next_endpoint() doesn't match to this concept.

Simply replace

- of_graph_get_next_endpoint(xxx, NULL);
+ of_graph_get_endpoint_by_regs(xxx, 0, -1);

Link: https://lore.kernel.org/r/20240202174941.ga310089-r...@kernel.org
Signed-off-by: Kuninori Morimoto 
---
 drivers/media/platform/atmel/atmel-isi.c  | 4 ++--
 drivers/media/platform/intel/pxa_camera.c | 2 +-
 drivers/media/platform/samsung/exynos4-is/fimc-is.c   | 2 +-
 drivers/media/platform/samsung/exynos4-is/mipi-csis.c | 3 ++-
 drivers/media/platform/st/stm32/stm32-dcmi.c  | 4 ++--
 drivers/media/platform/ti/davinci/vpif.c  | 3 +--
 6 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/drivers/media/platform/atmel/atmel-isi.c 
b/drivers/media/platform/atmel/atmel-isi.c
index f8450a8ccda6..c1108df72dd5 100644
--- a/drivers/media/platform/atmel/atmel-isi.c
+++ b/drivers/media/platform/atmel/atmel-isi.c
@@ -834,7 +834,7 @@ static int atmel_isi_parse_dt(struct atmel_isi *isi,
isi->pdata.full_mode = 1;
isi->pdata.frate = ISI_CFG1_FRATE_CAPTURE_ALL;
 
-   np = of_graph_get_next_endpoint(np, NULL);
+   np = of_graph_get_endpoint_by_regs(np, 0, -1);
if (!np) {
dev_err(>dev, "Could not find the endpoint\n");
return -EINVAL;
@@ -1158,7 +1158,7 @@ static int isi_graph_init(struct atmel_isi *isi)
struct device_node *ep;
int ret;
 
-   ep = of_graph_get_next_endpoint(isi->dev->of_node, NULL);
+   ep = of_graph_get_endpoint_by_regs(isi->dev->of_node, 0, -1);
if (!ep)
return -EINVAL;
 
diff --git a/drivers/media/platform/intel/pxa_camera.c 
b/drivers/media/platform/intel/pxa_camera.c
index 59b89e421dc2..d904952bf00e 100644
--- a/drivers/media/platform/intel/pxa_camera.c
+++ b/drivers/media/platform/intel/pxa_camera.c
@@ -2207,7 +2207,7 @@ static int pxa_camera_pdata_from_dt(struct device *dev,
pcdev->mclk = mclk_rate;
}
 
-   np = of_graph_get_next_endpoint(np, NULL);
+   np = of_graph_get_endpoint_by_regs(np, 0, -1);
if (!np) {
dev_err(dev, "could not find endpoint\n");
return -EINVAL;
diff --git a/drivers/media/platform/samsung/exynos4-is/fimc-is.c 
b/drivers/media/platform/samsung/exynos4-is/fimc-is.c
index a08c87ef6e2d..39aab667910d 100644
--- a/drivers/media/platform/samsung/exynos4-is/fimc-is.c
+++ b/drivers/media/platform/samsung/exynos4-is/fimc-is.c
@@ -175,7 +175,7 @@ static int fimc_is_parse_sensor_config(struct fimc_is *is, 
unsigned int index,
return -EINVAL;
}
 
-   ep = of_graph_get_next_endpoint(node, NULL);
+   ep = of_graph_get_endpoint_by_regs(node, 0, -1);
if (!ep)
return -ENXIO;
 
diff --git a/drivers/media/platform/samsung/exynos4-is/mipi-csis.c 
b/drivers/media/platform/samsung/exynos4-is/mipi-csis.c
index aae8a8b2c0f4..4b9b20ba3504 100644
--- a/drivers/media/platform/samsung/exynos4-is/mipi-csis.c
+++ b/drivers/media/platform/samsung/exynos4-is/mipi-csis.c
@@ -727,7 +727,8 @@ static int s5pcsis_parse_dt(struct platform_device *pdev,
 >max_num_lanes))
return -EINVAL;
 
-   node = of_graph_get_next_endpoint(node, NULL);
+   /* from port@3 or port@4 */
+   node = of_graph_get_endpoint_by_regs(node, -1, -1);
if (!node) {
dev_err(>dev, "No port node at %pOF\n",
pdev->dev.of_node);
diff --git a/drivers/media/platform/st/stm32/stm32-dcmi.c 
b/drivers/media/platform/st/stm32/stm32-dcmi.c
index c4610e305546..ff3331af9406 100644
--- a/drivers/media/platform/st/stm32/stm32-dcmi.c
+++ b/drivers/media/platform/st/stm32/stm32-dcmi.c
@@ -1855,7 +1855,7 @@ static int dcmi_graph_init(struct stm32_dcmi *dcmi)
struct device_node *ep;
int ret;
 
-   ep = of_graph_get_next_endpoint(dcmi->dev->of_node, NULL);
+   ep = of_graph_get_endpoint_by_regs(dcmi->dev->of_node, 0, -1);
if (!ep) {
dev_err(dcmi->dev, "Failed to get next endpoint\n");
return -EINVAL;
@@ -1907,7 +1907,7 @@ static int dcmi_probe(struct platform_device *pdev)
 "Could not get reset control\n");
 
/* Get bus characteristics from devicetree */
-   np = of_graph_get_next_endpoint(np, NULL);
+   np = of_graph_get_endpoint_by_regs(np, 0, -1);
if (!np) {
dev_err(>dev, "Could not find the endpoint\n");
return -ENODEV;
diff --git a/drivers/media/platform/ti/davinci/vpif.c 
b/drivers/media/platform/ti/davinci/vpif.c
index 63cdfed37bc9..f4e1fa76bf37 100644
--- a/drivers/media/p

[PATCH v2 2/4] media: i2c: replace of_graph_get_next_endpoint()

2024-03-03 Thread Kuninori Morimoto
>From DT point of view, in general, drivers should be asking for a
specific port number because their function is fixed in the binding.

of_graph_get_next_endpoint() doesn't match to this concept.

Simply replace

- of_graph_get_next_endpoint(xxx, NULL);
+ of_graph_get_endpoint_by_regs(xxx, 0, -1);

Link: https://lore.kernel.org/r/20240202174941.ga310089-r...@kernel.org
Link: https://lore.kernel.org/r/9d1e99b0-892d-4a72-a9b3-886b8ed09...@xs4all.nl
Signed-off-by: Kuninori Morimoto 
---
 drivers/media/i2c/adv7343.c  | 2 +-
 drivers/media/i2c/adv7604.c  | 4 ++--
 drivers/media/i2c/mt9p031.c  | 2 +-
 drivers/media/i2c/mt9v032.c  | 2 +-
 drivers/media/i2c/ov2659.c   | 2 +-
 drivers/media/i2c/ov5645.c   | 2 +-
 drivers/media/i2c/ov5647.c   | 2 +-
 drivers/media/i2c/s5c73m3/s5c73m3-core.c | 2 +-
 drivers/media/i2c/s5k5baf.c  | 2 +-
 drivers/media/i2c/tc358743.c | 2 +-
 drivers/media/i2c/tda1997x.c | 2 +-
 drivers/media/i2c/tvp514x.c  | 2 +-
 drivers/media/i2c/tvp7002.c  | 2 +-
 13 files changed, 14 insertions(+), 14 deletions(-)

diff --git a/drivers/media/i2c/adv7343.c b/drivers/media/i2c/adv7343.c
index ff21cd4744d3..4fbe4e18570e 100644
--- a/drivers/media/i2c/adv7343.c
+++ b/drivers/media/i2c/adv7343.c
@@ -403,7 +403,7 @@ adv7343_get_pdata(struct i2c_client *client)
if (!IS_ENABLED(CONFIG_OF) || !client->dev.of_node)
return client->dev.platform_data;
 
-   np = of_graph_get_next_endpoint(client->dev.of_node, NULL);
+   np = of_graph_get_endpoint_by_regs(client->dev.of_node, 0, -1);
if (!np)
return NULL;
 
diff --git a/drivers/media/i2c/adv7604.c b/drivers/media/i2c/adv7604.c
index 810fa8826f30..319db3e847c4 100644
--- a/drivers/media/i2c/adv7604.c
+++ b/drivers/media/i2c/adv7604.c
@@ -3204,8 +3204,8 @@ static int adv76xx_parse_dt(struct adv76xx_state *state)
 
np = state->i2c_clients[ADV76XX_PAGE_IO]->dev.of_node;
 
-   /* Parse the endpoint. */
-   endpoint = of_graph_get_next_endpoint(np, NULL);
+   /* FIXME: Parse the endpoint. */
+   endpoint = of_graph_get_endpoint_by_regs(np, -1, -1);
if (!endpoint)
return -EINVAL;
 
diff --git a/drivers/media/i2c/mt9p031.c b/drivers/media/i2c/mt9p031.c
index 596200d0248c..f4b481212356 100644
--- a/drivers/media/i2c/mt9p031.c
+++ b/drivers/media/i2c/mt9p031.c
@@ -1078,7 +1078,7 @@ mt9p031_get_pdata(struct i2c_client *client)
if (!IS_ENABLED(CONFIG_OF) || !client->dev.of_node)
return client->dev.platform_data;
 
-   np = of_graph_get_next_endpoint(client->dev.of_node, NULL);
+   np = of_graph_get_endpoint_by_regs(client->dev.of_node, 0, -1);
if (!np)
return NULL;
 
diff --git a/drivers/media/i2c/mt9v032.c b/drivers/media/i2c/mt9v032.c
index 3ca76eeae7ff..e9f5c6647f97 100644
--- a/drivers/media/i2c/mt9v032.c
+++ b/drivers/media/i2c/mt9v032.c
@@ -1006,7 +1006,7 @@ mt9v032_get_pdata(struct i2c_client *client)
if (!IS_ENABLED(CONFIG_OF) || !client->dev.of_node)
return client->dev.platform_data;
 
-   np = of_graph_get_next_endpoint(client->dev.of_node, NULL);
+   np = of_graph_get_endpoint_by_regs(client->dev.of_node, 0, -1);
if (!np)
return NULL;
 
diff --git a/drivers/media/i2c/ov2659.c b/drivers/media/i2c/ov2659.c
index 1d0ef72a6403..d1653d7431d0 100644
--- a/drivers/media/i2c/ov2659.c
+++ b/drivers/media/i2c/ov2659.c
@@ -1388,7 +1388,7 @@ ov2659_get_pdata(struct i2c_client *client)
if (!IS_ENABLED(CONFIG_OF) || !client->dev.of_node)
return client->dev.platform_data;
 
-   endpoint = of_graph_get_next_endpoint(client->dev.of_node, NULL);
+   endpoint = of_graph_get_endpoint_by_regs(client->dev.of_node, 0, -1);
if (!endpoint)
return NULL;
 
diff --git a/drivers/media/i2c/ov5645.c b/drivers/media/i2c/ov5645.c
index a26ac11c989d..9daf06ffedf4 100644
--- a/drivers/media/i2c/ov5645.c
+++ b/drivers/media/i2c/ov5645.c
@@ -1056,7 +1056,7 @@ static int ov5645_probe(struct i2c_client *client)
ov5645->i2c_client = client;
ov5645->dev = dev;
 
-   endpoint = of_graph_get_next_endpoint(dev->of_node, NULL);
+   endpoint = of_graph_get_endpoint_by_regs(dev->of_node, 0, -1);
if (!endpoint) {
dev_err(dev, "endpoint node not found\n");
return -EINVAL;
diff --git a/drivers/media/i2c/ov5647.c b/drivers/media/i2c/ov5647.c
index 96c0fd4ff5ab..7e1ecdf2485f 100644
--- a/drivers/media/i2c/ov5647.c
+++ b/drivers/media/i2c/ov5647.c
@@ -1363,7 +1363,7 @@ static int ov5647_parse_dt(struct ov5647 *sensor, struct 
device_node *np)
struct device_node *ep;
int ret;
 
-   ep = of_graph_get_next_endpoint(np

[PATCH v2 1/4] gpu: drm: replace of_graph_get_next_endpoint()

2024-03-03 Thread Kuninori Morimoto
>From DT point of view, in general, drivers should be asking for a
specific port number because their function is fixed in the binding.

of_graph_get_next_endpoint() doesn't match to this concept.

Simply replace

- of_graph_get_next_endpoint(xxx, NULL);
+ of_graph_get_endpoint_by_regs(xxx, 0, -1);

Link: https://lore.kernel.org/r/20240202174941.ga310089-r...@kernel.org
Signed-off-by: Kuninori Morimoto 
Reviewed-by: Laurent Pinchart 
---
 drivers/gpu/drm/drm_of.c  | 4 +++-
 drivers/gpu/drm/panel/panel-raspberrypi-touchscreen.c | 2 +-
 drivers/gpu/drm/tiny/arcpgu.c | 2 +-
 3 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/drm_of.c b/drivers/gpu/drm/drm_of.c
index 177b600895d3..b6b2cade69ae 100644
--- a/drivers/gpu/drm/drm_of.c
+++ b/drivers/gpu/drm/drm_of.c
@@ -504,6 +504,8 @@ EXPORT_SYMBOL_GPL(drm_of_get_data_lanes_count_ep);
  * Gets parent DSI bus for a DSI device controlled through a bus other
  * than MIPI-DCS (SPI, I2C, etc.) using the Device Tree.
  *
+ * This function assumes that the device's port@0 is the DSI input.
+ *
  * Returns pointer to mipi_dsi_host if successful, -EINVAL if the
  * request is unsupported, -EPROBE_DEFER if the DSI host is found but
  * not available, or -ENODEV otherwise.
@@ -516,7 +518,7 @@ struct mipi_dsi_host *drm_of_get_dsi_bus(struct device *dev)
/*
 * Get first endpoint child from device.
 */
-   endpoint = of_graph_get_next_endpoint(dev->of_node, NULL);
+   endpoint = of_graph_get_endpoint_by_regs(dev->of_node, 0, -1);
if (!endpoint)
return ERR_PTR(-ENODEV);
 
diff --git a/drivers/gpu/drm/panel/panel-raspberrypi-touchscreen.c 
b/drivers/gpu/drm/panel/panel-raspberrypi-touchscreen.c
index 4618c892cdd6..e10e469aa7a6 100644
--- a/drivers/gpu/drm/panel/panel-raspberrypi-touchscreen.c
+++ b/drivers/gpu/drm/panel/panel-raspberrypi-touchscreen.c
@@ -400,7 +400,7 @@ static int rpi_touchscreen_probe(struct i2c_client *i2c)
rpi_touchscreen_i2c_write(ts, REG_POWERON, 0);
 
/* Look up the DSI host.  It needs to probe before we do. */
-   endpoint = of_graph_get_next_endpoint(dev->of_node, NULL);
+   endpoint = of_graph_get_endpoint_by_regs(dev->of_node, 0, -1);
if (!endpoint)
return -ENODEV;
 
diff --git a/drivers/gpu/drm/tiny/arcpgu.c b/drivers/gpu/drm/tiny/arcpgu.c
index 4f8f3172379e..8c29b719ea62 100644
--- a/drivers/gpu/drm/tiny/arcpgu.c
+++ b/drivers/gpu/drm/tiny/arcpgu.c
@@ -288,7 +288,7 @@ static int arcpgu_load(struct arcpgu_drm_private *arcpgu)
 * There is only one output port inside each device. It is linked with
 * encoder endpoint.
 */
-   endpoint_node = of_graph_get_next_endpoint(pdev->dev.of_node, NULL);
+   endpoint_node = of_graph_get_endpoint_by_regs(pdev->dev.of_node, 0, -1);
if (endpoint_node) {
encoder_node = of_graph_get_remote_port_parent(endpoint_node);
of_node_put(endpoint_node);
-- 
2.25.1



[PATCH v2 resend 0/4] of: replace of_graph_get_next_endpoint()

2024-03-03 Thread Kuninori Morimoto


Hi Rob

This is resend v2 of replace of_graph_get_next_endpoint()

We should get rid of or minimize of_graph_get_next_endpoint() in
its current form. In general, drivers should be asking for a specific 
port number because their function is fixed in the binding.

https://lore.kernel.org/r/20240131184347.ga1906672-r...@kernel.org

This patch-set replace of_graph_get_next_endpoint() by
of_graph_get_endpoint_by_regs(). There are still next_endpoint()
after this patch-set, but it will be replaced by
for_each_endpoint_of_node() in next patch-set (A)

[*] this patch-set
[o] done

[o] tidyup of_graph_get_endpoint_count()
[*] replace endpoint func - use endpoint_by_regs()
(A) [ ] replace endpoint func - use for_each()
[ ] rename endpoint func to device_endpoint
[ ] add new port function
[ ] add new endpont function
[ ] remove of_graph_get_next_device_endpoint()

v1 -> v2
- add Reviewed-by from Launrent
- use by_regs(xx, -1, -1) for some devices
- add extra explain for drm_of_get_dsi_bus()
- add FIXME and Link on adv7604.c
- based on latest of branch

Kuninori Morimoto (4):
  gpu: drm: replace of_graph_get_next_endpoint()
  media: i2c: replace of_graph_get_next_endpoint()
  media: platform: replace of_graph_get_next_endpoint()
  video: fbdev: replace of_graph_get_next_endpoint()

 drivers/gpu/drm/drm_of.c  |  4 +++-
 .../drm/panel/panel-raspberrypi-touchscreen.c |  2 +-
 drivers/gpu/drm/tiny/arcpgu.c |  2 +-
 drivers/media/i2c/adv7343.c   |  2 +-
 drivers/media/i2c/adv7604.c   |  4 ++--
 drivers/media/i2c/mt9p031.c   |  2 +-
 drivers/media/i2c/mt9v032.c   |  2 +-
 drivers/media/i2c/ov2659.c|  2 +-
 drivers/media/i2c/ov5645.c|  2 +-
 drivers/media/i2c/ov5647.c|  2 +-
 drivers/media/i2c/s5c73m3/s5c73m3-core.c  |  2 +-
 drivers/media/i2c/s5k5baf.c   |  2 +-
 drivers/media/i2c/tc358743.c  |  2 +-
 drivers/media/i2c/tda1997x.c  |  2 +-
 drivers/media/i2c/tvp514x.c   |  2 +-
 drivers/media/i2c/tvp7002.c   |  2 +-
 drivers/media/platform/atmel/atmel-isi.c  |  4 ++--
 drivers/media/platform/intel/pxa_camera.c |  2 +-
 .../platform/samsung/exynos4-is/fimc-is.c |  2 +-
 .../platform/samsung/exynos4-is/mipi-csis.c   |  3 ++-
 drivers/media/platform/st/stm32/stm32-dcmi.c  |  4 ++--
 drivers/media/platform/ti/davinci/vpif.c  |  3 +--
 drivers/video/fbdev/omap2/omapfb/dss/dsi.c|  3 ++-
 drivers/video/fbdev/omap2/omapfb/dss/dss-of.c | 20 +--
 drivers/video/fbdev/omap2/omapfb/dss/hdmi4.c  |  3 ++-
 drivers/video/fbdev/omap2/omapfb/dss/hdmi5.c  |  3 ++-
 drivers/video/fbdev/omap2/omapfb/dss/venc.c   |  3 ++-
 drivers/video/fbdev/pxafb.c   |  2 +-
 include/video/omapfb_dss.h|  3 ---
 29 files changed, 38 insertions(+), 53 deletions(-)


Re: [PATCH v2 resend 0/4] of: replace of_graph_get_next_endpoint()

2024-02-26 Thread Kuninori Morimoto


Hi Rob

> This is resend v2 of replace of_graph_get_next_endpoint()
> 
> We should get rid of or minimize of_graph_get_next_endpoint() in
> its current form. In general, drivers should be asking for a specific 
> port number because their function is fixed in the binding.
> 
>   https://lore.kernel.org/r/20240131184347.ga1906672-r...@kernel.org
> 
> This patch-set replace of_graph_get_next_endpoint() by
> of_graph_get_endpoint_by_regs(). There are still next_endpoint()
> after this patch-set, but it will be replaced by
> for_each_endpoint_of_node() in next patch-set (A)
> 
> [*] this patch-set
> [o] done
> 
>   [o] tidyup of_graph_get_endpoint_count()
>   [*] replace endpoint func - use endpoint_by_regs()
> (A)   [ ] replace endpoint func - use for_each()
>   [ ] rename endpoint func to device_endpoint
>   [ ] add new port function
>   [ ] add new endpont function
>   [ ] remove of_graph_get_next_device_endpoint()
> 
> v1 -> v2
>   - add Reviewed-by from Launrent
>   - use by_regs(xx, -1, -1) for some devices
>   - add extra explain for drm_of_get_dsi_bus()
>   - add FIXME and Link on adv7604.c
>   - based on latest of branch
> 
> Kuninori Morimoto (4):
>   gpu: drm: replace of_graph_get_next_endpoint()
>   media: i2c: replace of_graph_get_next_endpoint()
>   media: platform: replace of_graph_get_next_endpoint()
>   video: fbdev: replace of_graph_get_next_endpoint()

I wonder who should handle this patch-set ??
I'm posting these as part of "of patch-set" (= to Rob)
but does these should be handled by each driver maintainer ?
(I believe all maintainers are listed on To)

Thank you for your help !!

Best regards
---
Renesas Electronics
Ph.D. Kuninori Morimoto


[PATCH v2 resend 4/4] video: fbdev: replace of_graph_get_next_endpoint()

2024-02-19 Thread Kuninori Morimoto
>From DT point of view, in general, drivers should be asking for a
specific port number because their function is fixed in the binding.

of_graph_get_next_endpoint() doesn't match to this concept.

Simply replace

- of_graph_get_next_endpoint(xxx, NULL);
+ of_graph_get_endpoint_by_regs(xxx, 0, -1);

Link: https://lore.kernel.org/r/20240202174941.ga310089-r...@kernel.org
Signed-off-by: Kuninori Morimoto 
Reviewed-by: Laurent Pinchart 
---
 drivers/video/fbdev/omap2/omapfb/dss/dsi.c|  3 ++-
 drivers/video/fbdev/omap2/omapfb/dss/dss-of.c | 20 +--
 drivers/video/fbdev/omap2/omapfb/dss/hdmi4.c  |  3 ++-
 drivers/video/fbdev/omap2/omapfb/dss/hdmi5.c  |  3 ++-
 drivers/video/fbdev/omap2/omapfb/dss/venc.c   |  3 ++-
 drivers/video/fbdev/pxafb.c   |  2 +-
 include/video/omapfb_dss.h|  3 ---
 7 files changed, 10 insertions(+), 27 deletions(-)

diff --git a/drivers/video/fbdev/omap2/omapfb/dss/dsi.c 
b/drivers/video/fbdev/omap2/omapfb/dss/dsi.c
index b7eb17a16ec4..1f13bcf73da5 100644
--- a/drivers/video/fbdev/omap2/omapfb/dss/dsi.c
+++ b/drivers/video/fbdev/omap2/omapfb/dss/dsi.c
@@ -28,6 +28,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 
@@ -5079,7 +5080,7 @@ static int dsi_probe_of(struct platform_device *pdev)
struct device_node *ep;
struct omap_dsi_pin_config pin_cfg;
 
-   ep = omapdss_of_get_first_endpoint(node);
+   ep = of_graph_get_endpoint_by_regs(node, 0, -1);
if (!ep)
return 0;
 
diff --git a/drivers/video/fbdev/omap2/omapfb/dss/dss-of.c 
b/drivers/video/fbdev/omap2/omapfb/dss/dss-of.c
index 0282d4eef139..14965a3fd05b 100644
--- a/drivers/video/fbdev/omap2/omapfb/dss/dss-of.c
+++ b/drivers/video/fbdev/omap2/omapfb/dss/dss-of.c
@@ -130,24 +130,6 @@ static struct device_node 
*omapdss_of_get_remote_port(const struct device_node *
return np;
 }
 
-struct device_node *
-omapdss_of_get_first_endpoint(const struct device_node *parent)
-{
-   struct device_node *port, *ep;
-
-   port = omapdss_of_get_next_port(parent, NULL);
-
-   if (!port)
-   return NULL;
-
-   ep = omapdss_of_get_next_endpoint(port, NULL);
-
-   of_node_put(port);
-
-   return ep;
-}
-EXPORT_SYMBOL_GPL(omapdss_of_get_first_endpoint);
-
 struct omap_dss_device *
 omapdss_of_find_source_for_first_ep(struct device_node *node)
 {
@@ -155,7 +137,7 @@ omapdss_of_find_source_for_first_ep(struct device_node 
*node)
struct device_node *src_port;
struct omap_dss_device *src;
 
-   ep = omapdss_of_get_first_endpoint(node);
+   ep = of_graph_get_endpoint_by_regs(node, 0, -1);
if (!ep)
return ERR_PTR(-EINVAL);
 
diff --git a/drivers/video/fbdev/omap2/omapfb/dss/hdmi4.c 
b/drivers/video/fbdev/omap2/omapfb/dss/hdmi4.c
index f05b4e35a842..8f407ec134dc 100644
--- a/drivers/video/fbdev/omap2/omapfb/dss/hdmi4.c
+++ b/drivers/video/fbdev/omap2/omapfb/dss/hdmi4.c
@@ -20,6 +20,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -529,7 +530,7 @@ static int hdmi_probe_of(struct platform_device *pdev)
struct device_node *ep;
int r;
 
-   ep = omapdss_of_get_first_endpoint(node);
+   ep = of_graph_get_endpoint_by_regs(node, 0, -1);
if (!ep)
return 0;
 
diff --git a/drivers/video/fbdev/omap2/omapfb/dss/hdmi5.c 
b/drivers/video/fbdev/omap2/omapfb/dss/hdmi5.c
index 03292945b1d4..4ad219f522b9 100644
--- a/drivers/video/fbdev/omap2/omapfb/dss/hdmi5.c
+++ b/drivers/video/fbdev/omap2/omapfb/dss/hdmi5.c
@@ -25,6 +25,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -561,7 +562,7 @@ static int hdmi_probe_of(struct platform_device *pdev)
struct device_node *ep;
int r;
 
-   ep = omapdss_of_get_first_endpoint(node);
+   ep = of_graph_get_endpoint_by_regs(node, 0, -1);
if (!ep)
return 0;
 
diff --git a/drivers/video/fbdev/omap2/omapfb/dss/venc.c 
b/drivers/video/fbdev/omap2/omapfb/dss/venc.c
index c9d40e28a06f..0bd80d3b8f1b 100644
--- a/drivers/video/fbdev/omap2/omapfb/dss/venc.c
+++ b/drivers/video/fbdev/omap2/omapfb/dss/venc.c
@@ -24,6 +24,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 
 #include 
@@ -764,7 +765,7 @@ static int venc_probe_of(struct platform_device *pdev)
u32 channels;
int r;
 
-   ep = omapdss_of_get_first_endpoint(node);
+   ep = of_graph_get_endpoint_by_regs(node, 0, -1);
if (!ep)
return 0;
 
diff --git a/drivers/video/fbdev/pxafb.c b/drivers/video/fbdev/pxafb.c
index fa943612c4e2..2ef56fa28aff 100644
--- a/drivers/video/fbdev/pxafb.c
+++ b/drivers/video/fbdev/pxafb.c
@@ -2171,7 +2171,7 @@ static int of_get_pxafb_mode_info(struct device *dev,
u32 bus_width;
int ret, i;
 
-   np = of_graph_get_next_endpoint(dev->of_node, NULL);
+   np = of_graph_get_endpoint_by_regs(dev-&g

[PATCH v2 resend 3/4] media: platform: replace of_graph_get_next_endpoint()

2024-02-19 Thread Kuninori Morimoto
>From DT point of view, in general, drivers should be asking for a
specific port number because their function is fixed in the binding.

of_graph_get_next_endpoint() doesn't match to this concept.

Simply replace

- of_graph_get_next_endpoint(xxx, NULL);
+ of_graph_get_endpoint_by_regs(xxx, 0, -1);

Link: https://lore.kernel.org/r/20240202174941.ga310089-r...@kernel.org
Signed-off-by: Kuninori Morimoto 
---
 drivers/media/platform/atmel/atmel-isi.c  | 4 ++--
 drivers/media/platform/intel/pxa_camera.c | 2 +-
 drivers/media/platform/samsung/exynos4-is/fimc-is.c   | 2 +-
 drivers/media/platform/samsung/exynos4-is/mipi-csis.c | 3 ++-
 drivers/media/platform/st/stm32/stm32-dcmi.c  | 4 ++--
 drivers/media/platform/ti/davinci/vpif.c  | 3 +--
 6 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/drivers/media/platform/atmel/atmel-isi.c 
b/drivers/media/platform/atmel/atmel-isi.c
index f8450a8ccda6..c1108df72dd5 100644
--- a/drivers/media/platform/atmel/atmel-isi.c
+++ b/drivers/media/platform/atmel/atmel-isi.c
@@ -834,7 +834,7 @@ static int atmel_isi_parse_dt(struct atmel_isi *isi,
isi->pdata.full_mode = 1;
isi->pdata.frate = ISI_CFG1_FRATE_CAPTURE_ALL;
 
-   np = of_graph_get_next_endpoint(np, NULL);
+   np = of_graph_get_endpoint_by_regs(np, 0, -1);
if (!np) {
dev_err(>dev, "Could not find the endpoint\n");
return -EINVAL;
@@ -1158,7 +1158,7 @@ static int isi_graph_init(struct atmel_isi *isi)
struct device_node *ep;
int ret;
 
-   ep = of_graph_get_next_endpoint(isi->dev->of_node, NULL);
+   ep = of_graph_get_endpoint_by_regs(isi->dev->of_node, 0, -1);
if (!ep)
return -EINVAL;
 
diff --git a/drivers/media/platform/intel/pxa_camera.c 
b/drivers/media/platform/intel/pxa_camera.c
index 59b89e421dc2..d904952bf00e 100644
--- a/drivers/media/platform/intel/pxa_camera.c
+++ b/drivers/media/platform/intel/pxa_camera.c
@@ -2207,7 +2207,7 @@ static int pxa_camera_pdata_from_dt(struct device *dev,
pcdev->mclk = mclk_rate;
}
 
-   np = of_graph_get_next_endpoint(np, NULL);
+   np = of_graph_get_endpoint_by_regs(np, 0, -1);
if (!np) {
dev_err(dev, "could not find endpoint\n");
return -EINVAL;
diff --git a/drivers/media/platform/samsung/exynos4-is/fimc-is.c 
b/drivers/media/platform/samsung/exynos4-is/fimc-is.c
index a08c87ef6e2d..39aab667910d 100644
--- a/drivers/media/platform/samsung/exynos4-is/fimc-is.c
+++ b/drivers/media/platform/samsung/exynos4-is/fimc-is.c
@@ -175,7 +175,7 @@ static int fimc_is_parse_sensor_config(struct fimc_is *is, 
unsigned int index,
return -EINVAL;
}
 
-   ep = of_graph_get_next_endpoint(node, NULL);
+   ep = of_graph_get_endpoint_by_regs(node, 0, -1);
if (!ep)
return -ENXIO;
 
diff --git a/drivers/media/platform/samsung/exynos4-is/mipi-csis.c 
b/drivers/media/platform/samsung/exynos4-is/mipi-csis.c
index aae8a8b2c0f4..4b9b20ba3504 100644
--- a/drivers/media/platform/samsung/exynos4-is/mipi-csis.c
+++ b/drivers/media/platform/samsung/exynos4-is/mipi-csis.c
@@ -727,7 +727,8 @@ static int s5pcsis_parse_dt(struct platform_device *pdev,
 >max_num_lanes))
return -EINVAL;
 
-   node = of_graph_get_next_endpoint(node, NULL);
+   /* from port@3 or port@4 */
+   node = of_graph_get_endpoint_by_regs(node, -1, -1);
if (!node) {
dev_err(>dev, "No port node at %pOF\n",
pdev->dev.of_node);
diff --git a/drivers/media/platform/st/stm32/stm32-dcmi.c 
b/drivers/media/platform/st/stm32/stm32-dcmi.c
index c4610e305546..ff3331af9406 100644
--- a/drivers/media/platform/st/stm32/stm32-dcmi.c
+++ b/drivers/media/platform/st/stm32/stm32-dcmi.c
@@ -1855,7 +1855,7 @@ static int dcmi_graph_init(struct stm32_dcmi *dcmi)
struct device_node *ep;
int ret;
 
-   ep = of_graph_get_next_endpoint(dcmi->dev->of_node, NULL);
+   ep = of_graph_get_endpoint_by_regs(dcmi->dev->of_node, 0, -1);
if (!ep) {
dev_err(dcmi->dev, "Failed to get next endpoint\n");
return -EINVAL;
@@ -1907,7 +1907,7 @@ static int dcmi_probe(struct platform_device *pdev)
 "Could not get reset control\n");
 
/* Get bus characteristics from devicetree */
-   np = of_graph_get_next_endpoint(np, NULL);
+   np = of_graph_get_endpoint_by_regs(np, 0, -1);
if (!np) {
dev_err(>dev, "Could not find the endpoint\n");
return -ENODEV;
diff --git a/drivers/media/platform/ti/davinci/vpif.c 
b/drivers/media/platform/ti/davinci/vpif.c
index 63cdfed37bc9..f4e1fa76bf37 100644
--- a/drivers/media/p

[PATCH v2 resend 2/4] media: i2c: replace of_graph_get_next_endpoint()

2024-02-19 Thread Kuninori Morimoto
>From DT point of view, in general, drivers should be asking for a
specific port number because their function is fixed in the binding.

of_graph_get_next_endpoint() doesn't match to this concept.

Simply replace

- of_graph_get_next_endpoint(xxx, NULL);
+ of_graph_get_endpoint_by_regs(xxx, 0, -1);

Link: https://lore.kernel.org/r/20240202174941.ga310089-r...@kernel.org
Link: https://lore.kernel.org/r/9d1e99b0-892d-4a72-a9b3-886b8ed09...@xs4all.nl
Signed-off-by: Kuninori Morimoto 
---
 drivers/media/i2c/adv7343.c  | 2 +-
 drivers/media/i2c/adv7604.c  | 4 ++--
 drivers/media/i2c/mt9p031.c  | 2 +-
 drivers/media/i2c/mt9v032.c  | 2 +-
 drivers/media/i2c/ov2659.c   | 2 +-
 drivers/media/i2c/ov5645.c   | 2 +-
 drivers/media/i2c/ov5647.c   | 2 +-
 drivers/media/i2c/s5c73m3/s5c73m3-core.c | 2 +-
 drivers/media/i2c/s5k5baf.c  | 2 +-
 drivers/media/i2c/tc358743.c | 2 +-
 drivers/media/i2c/tda1997x.c | 2 +-
 drivers/media/i2c/tvp514x.c  | 2 +-
 drivers/media/i2c/tvp7002.c  | 2 +-
 13 files changed, 14 insertions(+), 14 deletions(-)

diff --git a/drivers/media/i2c/adv7343.c b/drivers/media/i2c/adv7343.c
index ff21cd4744d3..4fbe4e18570e 100644
--- a/drivers/media/i2c/adv7343.c
+++ b/drivers/media/i2c/adv7343.c
@@ -403,7 +403,7 @@ adv7343_get_pdata(struct i2c_client *client)
if (!IS_ENABLED(CONFIG_OF) || !client->dev.of_node)
return client->dev.platform_data;
 
-   np = of_graph_get_next_endpoint(client->dev.of_node, NULL);
+   np = of_graph_get_endpoint_by_regs(client->dev.of_node, 0, -1);
if (!np)
return NULL;
 
diff --git a/drivers/media/i2c/adv7604.c b/drivers/media/i2c/adv7604.c
index 810fa8826f30..319db3e847c4 100644
--- a/drivers/media/i2c/adv7604.c
+++ b/drivers/media/i2c/adv7604.c
@@ -3204,8 +3204,8 @@ static int adv76xx_parse_dt(struct adv76xx_state *state)
 
np = state->i2c_clients[ADV76XX_PAGE_IO]->dev.of_node;
 
-   /* Parse the endpoint. */
-   endpoint = of_graph_get_next_endpoint(np, NULL);
+   /* FIXME: Parse the endpoint. */
+   endpoint = of_graph_get_endpoint_by_regs(np, -1, -1);
if (!endpoint)
return -EINVAL;
 
diff --git a/drivers/media/i2c/mt9p031.c b/drivers/media/i2c/mt9p031.c
index 596200d0248c..f4b481212356 100644
--- a/drivers/media/i2c/mt9p031.c
+++ b/drivers/media/i2c/mt9p031.c
@@ -1078,7 +1078,7 @@ mt9p031_get_pdata(struct i2c_client *client)
if (!IS_ENABLED(CONFIG_OF) || !client->dev.of_node)
return client->dev.platform_data;
 
-   np = of_graph_get_next_endpoint(client->dev.of_node, NULL);
+   np = of_graph_get_endpoint_by_regs(client->dev.of_node, 0, -1);
if (!np)
return NULL;
 
diff --git a/drivers/media/i2c/mt9v032.c b/drivers/media/i2c/mt9v032.c
index 3ca76eeae7ff..e9f5c6647f97 100644
--- a/drivers/media/i2c/mt9v032.c
+++ b/drivers/media/i2c/mt9v032.c
@@ -1006,7 +1006,7 @@ mt9v032_get_pdata(struct i2c_client *client)
if (!IS_ENABLED(CONFIG_OF) || !client->dev.of_node)
return client->dev.platform_data;
 
-   np = of_graph_get_next_endpoint(client->dev.of_node, NULL);
+   np = of_graph_get_endpoint_by_regs(client->dev.of_node, 0, -1);
if (!np)
return NULL;
 
diff --git a/drivers/media/i2c/ov2659.c b/drivers/media/i2c/ov2659.c
index 1d0ef72a6403..d1653d7431d0 100644
--- a/drivers/media/i2c/ov2659.c
+++ b/drivers/media/i2c/ov2659.c
@@ -1388,7 +1388,7 @@ ov2659_get_pdata(struct i2c_client *client)
if (!IS_ENABLED(CONFIG_OF) || !client->dev.of_node)
return client->dev.platform_data;
 
-   endpoint = of_graph_get_next_endpoint(client->dev.of_node, NULL);
+   endpoint = of_graph_get_endpoint_by_regs(client->dev.of_node, 0, -1);
if (!endpoint)
return NULL;
 
diff --git a/drivers/media/i2c/ov5645.c b/drivers/media/i2c/ov5645.c
index a26ac11c989d..9daf06ffedf4 100644
--- a/drivers/media/i2c/ov5645.c
+++ b/drivers/media/i2c/ov5645.c
@@ -1056,7 +1056,7 @@ static int ov5645_probe(struct i2c_client *client)
ov5645->i2c_client = client;
ov5645->dev = dev;
 
-   endpoint = of_graph_get_next_endpoint(dev->of_node, NULL);
+   endpoint = of_graph_get_endpoint_by_regs(dev->of_node, 0, -1);
if (!endpoint) {
dev_err(dev, "endpoint node not found\n");
return -EINVAL;
diff --git a/drivers/media/i2c/ov5647.c b/drivers/media/i2c/ov5647.c
index 96c0fd4ff5ab..7e1ecdf2485f 100644
--- a/drivers/media/i2c/ov5647.c
+++ b/drivers/media/i2c/ov5647.c
@@ -1363,7 +1363,7 @@ static int ov5647_parse_dt(struct ov5647 *sensor, struct 
device_node *np)
struct device_node *ep;
int ret;
 
-   ep = of_graph_get_next_endpoint(np

[PATCH v2 resend 1/4] gpu: drm: replace of_graph_get_next_endpoint()

2024-02-19 Thread Kuninori Morimoto
>From DT point of view, in general, drivers should be asking for a
specific port number because their function is fixed in the binding.

of_graph_get_next_endpoint() doesn't match to this concept.

Simply replace

- of_graph_get_next_endpoint(xxx, NULL);
+ of_graph_get_endpoint_by_regs(xxx, 0, -1);

Link: https://lore.kernel.org/r/20240202174941.ga310089-r...@kernel.org
Signed-off-by: Kuninori Morimoto 
Reviewed-by: Laurent Pinchart 
---
 drivers/gpu/drm/drm_of.c  | 4 +++-
 drivers/gpu/drm/panel/panel-raspberrypi-touchscreen.c | 2 +-
 drivers/gpu/drm/tiny/arcpgu.c | 2 +-
 3 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/drm_of.c b/drivers/gpu/drm/drm_of.c
index 177b600895d3..b6b2cade69ae 100644
--- a/drivers/gpu/drm/drm_of.c
+++ b/drivers/gpu/drm/drm_of.c
@@ -504,6 +504,8 @@ EXPORT_SYMBOL_GPL(drm_of_get_data_lanes_count_ep);
  * Gets parent DSI bus for a DSI device controlled through a bus other
  * than MIPI-DCS (SPI, I2C, etc.) using the Device Tree.
  *
+ * This function assumes that the device's port@0 is the DSI input.
+ *
  * Returns pointer to mipi_dsi_host if successful, -EINVAL if the
  * request is unsupported, -EPROBE_DEFER if the DSI host is found but
  * not available, or -ENODEV otherwise.
@@ -516,7 +518,7 @@ struct mipi_dsi_host *drm_of_get_dsi_bus(struct device *dev)
/*
 * Get first endpoint child from device.
 */
-   endpoint = of_graph_get_next_endpoint(dev->of_node, NULL);
+   endpoint = of_graph_get_endpoint_by_regs(dev->of_node, 0, -1);
if (!endpoint)
return ERR_PTR(-ENODEV);
 
diff --git a/drivers/gpu/drm/panel/panel-raspberrypi-touchscreen.c 
b/drivers/gpu/drm/panel/panel-raspberrypi-touchscreen.c
index 4618c892cdd6..e10e469aa7a6 100644
--- a/drivers/gpu/drm/panel/panel-raspberrypi-touchscreen.c
+++ b/drivers/gpu/drm/panel/panel-raspberrypi-touchscreen.c
@@ -400,7 +400,7 @@ static int rpi_touchscreen_probe(struct i2c_client *i2c)
rpi_touchscreen_i2c_write(ts, REG_POWERON, 0);
 
/* Look up the DSI host.  It needs to probe before we do. */
-   endpoint = of_graph_get_next_endpoint(dev->of_node, NULL);
+   endpoint = of_graph_get_endpoint_by_regs(dev->of_node, 0, -1);
if (!endpoint)
return -ENODEV;
 
diff --git a/drivers/gpu/drm/tiny/arcpgu.c b/drivers/gpu/drm/tiny/arcpgu.c
index 4f8f3172379e..8c29b719ea62 100644
--- a/drivers/gpu/drm/tiny/arcpgu.c
+++ b/drivers/gpu/drm/tiny/arcpgu.c
@@ -288,7 +288,7 @@ static int arcpgu_load(struct arcpgu_drm_private *arcpgu)
 * There is only one output port inside each device. It is linked with
 * encoder endpoint.
 */
-   endpoint_node = of_graph_get_next_endpoint(pdev->dev.of_node, NULL);
+   endpoint_node = of_graph_get_endpoint_by_regs(pdev->dev.of_node, 0, -1);
if (endpoint_node) {
encoder_node = of_graph_get_remote_port_parent(endpoint_node);
of_node_put(endpoint_node);
-- 
2.25.1



[PATCH v2 resend 0/4] of: replace of_graph_get_next_endpoint()

2024-02-19 Thread Kuninori Morimoto


Hi Rob

This is resend v2 of replace of_graph_get_next_endpoint()

We should get rid of or minimize of_graph_get_next_endpoint() in
its current form. In general, drivers should be asking for a specific 
port number because their function is fixed in the binding.

https://lore.kernel.org/r/20240131184347.ga1906672-r...@kernel.org

This patch-set replace of_graph_get_next_endpoint() by
of_graph_get_endpoint_by_regs(). There are still next_endpoint()
after this patch-set, but it will be replaced by
for_each_endpoint_of_node() in next patch-set (A)

[*] this patch-set
[o] done

[o] tidyup of_graph_get_endpoint_count()
[*] replace endpoint func - use endpoint_by_regs()
(A) [ ] replace endpoint func - use for_each()
[ ] rename endpoint func to device_endpoint
[ ] add new port function
[ ] add new endpont function
[ ] remove of_graph_get_next_device_endpoint()

v1 -> v2
- add Reviewed-by from Launrent
- use by_regs(xx, -1, -1) for some devices
- add extra explain for drm_of_get_dsi_bus()
- add FIXME and Link on adv7604.c
- based on latest of branch

Kuninori Morimoto (4):
  gpu: drm: replace of_graph_get_next_endpoint()
  media: i2c: replace of_graph_get_next_endpoint()
  media: platform: replace of_graph_get_next_endpoint()
  video: fbdev: replace of_graph_get_next_endpoint()

 drivers/gpu/drm/drm_of.c  |  4 +++-
 .../drm/panel/panel-raspberrypi-touchscreen.c |  2 +-
 drivers/gpu/drm/tiny/arcpgu.c |  2 +-
 drivers/media/i2c/adv7343.c   |  2 +-
 drivers/media/i2c/adv7604.c   |  4 ++--
 drivers/media/i2c/mt9p031.c   |  2 +-
 drivers/media/i2c/mt9v032.c   |  2 +-
 drivers/media/i2c/ov2659.c|  2 +-
 drivers/media/i2c/ov5645.c|  2 +-
 drivers/media/i2c/ov5647.c|  2 +-
 drivers/media/i2c/s5c73m3/s5c73m3-core.c  |  2 +-
 drivers/media/i2c/s5k5baf.c   |  2 +-
 drivers/media/i2c/tc358743.c  |  2 +-
 drivers/media/i2c/tda1997x.c  |  2 +-
 drivers/media/i2c/tvp514x.c   |  2 +-
 drivers/media/i2c/tvp7002.c   |  2 +-
 drivers/media/platform/atmel/atmel-isi.c  |  4 ++--
 drivers/media/platform/intel/pxa_camera.c |  2 +-
 .../platform/samsung/exynos4-is/fimc-is.c |  2 +-
 .../platform/samsung/exynos4-is/mipi-csis.c   |  3 ++-
 drivers/media/platform/st/stm32/stm32-dcmi.c  |  4 ++--
 drivers/media/platform/ti/davinci/vpif.c  |  3 +--
 drivers/video/fbdev/omap2/omapfb/dss/dsi.c|  3 ++-
 drivers/video/fbdev/omap2/omapfb/dss/dss-of.c | 20 +--
 drivers/video/fbdev/omap2/omapfb/dss/hdmi4.c  |  3 ++-
 drivers/video/fbdev/omap2/omapfb/dss/hdmi5.c  |  3 ++-
 drivers/video/fbdev/omap2/omapfb/dss/venc.c   |  3 ++-
 drivers/video/fbdev/pxafb.c   |  2 +-
 include/video/omapfb_dss.h|  3 ---
 29 files changed, 38 insertions(+), 53 deletions(-)

-- 
2.25.1



[PATCH v2 4/4] video: fbdev: replace of_graph_get_next_endpoint()

2024-02-06 Thread Kuninori Morimoto
>From DT point of view, in general, drivers should be asking for a
specific port number because their function is fixed in the binding.

of_graph_get_next_endpoint() doesn't match to this concept.

Simply replace

- of_graph_get_next_endpoint(xxx, NULL);
+ of_graph_get_endpoint_by_regs(xxx, 0, -1);

Link: https://lore.kernel.org/r/20240202174941.ga310089-r...@kernel.org
Signed-off-by: Kuninori Morimoto 
Reviewed-by: Laurent Pinchart 
---
 drivers/video/fbdev/omap2/omapfb/dss/dsi.c|  3 ++-
 drivers/video/fbdev/omap2/omapfb/dss/dss-of.c | 20 +--
 drivers/video/fbdev/omap2/omapfb/dss/hdmi4.c  |  3 ++-
 drivers/video/fbdev/omap2/omapfb/dss/hdmi5.c  |  3 ++-
 drivers/video/fbdev/omap2/omapfb/dss/venc.c   |  3 ++-
 drivers/video/fbdev/pxafb.c   |  2 +-
 include/video/omapfb_dss.h|  3 ---
 7 files changed, 10 insertions(+), 27 deletions(-)

diff --git a/drivers/video/fbdev/omap2/omapfb/dss/dsi.c 
b/drivers/video/fbdev/omap2/omapfb/dss/dsi.c
index b7eb17a16ec4..1f13bcf73da5 100644
--- a/drivers/video/fbdev/omap2/omapfb/dss/dsi.c
+++ b/drivers/video/fbdev/omap2/omapfb/dss/dsi.c
@@ -28,6 +28,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 
@@ -5079,7 +5080,7 @@ static int dsi_probe_of(struct platform_device *pdev)
struct device_node *ep;
struct omap_dsi_pin_config pin_cfg;
 
-   ep = omapdss_of_get_first_endpoint(node);
+   ep = of_graph_get_endpoint_by_regs(node, 0, -1);
if (!ep)
return 0;
 
diff --git a/drivers/video/fbdev/omap2/omapfb/dss/dss-of.c 
b/drivers/video/fbdev/omap2/omapfb/dss/dss-of.c
index 0282d4eef139..14965a3fd05b 100644
--- a/drivers/video/fbdev/omap2/omapfb/dss/dss-of.c
+++ b/drivers/video/fbdev/omap2/omapfb/dss/dss-of.c
@@ -130,24 +130,6 @@ static struct device_node 
*omapdss_of_get_remote_port(const struct device_node *
return np;
 }
 
-struct device_node *
-omapdss_of_get_first_endpoint(const struct device_node *parent)
-{
-   struct device_node *port, *ep;
-
-   port = omapdss_of_get_next_port(parent, NULL);
-
-   if (!port)
-   return NULL;
-
-   ep = omapdss_of_get_next_endpoint(port, NULL);
-
-   of_node_put(port);
-
-   return ep;
-}
-EXPORT_SYMBOL_GPL(omapdss_of_get_first_endpoint);
-
 struct omap_dss_device *
 omapdss_of_find_source_for_first_ep(struct device_node *node)
 {
@@ -155,7 +137,7 @@ omapdss_of_find_source_for_first_ep(struct device_node 
*node)
struct device_node *src_port;
struct omap_dss_device *src;
 
-   ep = omapdss_of_get_first_endpoint(node);
+   ep = of_graph_get_endpoint_by_regs(node, 0, -1);
if (!ep)
return ERR_PTR(-EINVAL);
 
diff --git a/drivers/video/fbdev/omap2/omapfb/dss/hdmi4.c 
b/drivers/video/fbdev/omap2/omapfb/dss/hdmi4.c
index f05b4e35a842..8f407ec134dc 100644
--- a/drivers/video/fbdev/omap2/omapfb/dss/hdmi4.c
+++ b/drivers/video/fbdev/omap2/omapfb/dss/hdmi4.c
@@ -20,6 +20,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -529,7 +530,7 @@ static int hdmi_probe_of(struct platform_device *pdev)
struct device_node *ep;
int r;
 
-   ep = omapdss_of_get_first_endpoint(node);
+   ep = of_graph_get_endpoint_by_regs(node, 0, -1);
if (!ep)
return 0;
 
diff --git a/drivers/video/fbdev/omap2/omapfb/dss/hdmi5.c 
b/drivers/video/fbdev/omap2/omapfb/dss/hdmi5.c
index 03292945b1d4..4ad219f522b9 100644
--- a/drivers/video/fbdev/omap2/omapfb/dss/hdmi5.c
+++ b/drivers/video/fbdev/omap2/omapfb/dss/hdmi5.c
@@ -25,6 +25,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -561,7 +562,7 @@ static int hdmi_probe_of(struct platform_device *pdev)
struct device_node *ep;
int r;
 
-   ep = omapdss_of_get_first_endpoint(node);
+   ep = of_graph_get_endpoint_by_regs(node, 0, -1);
if (!ep)
return 0;
 
diff --git a/drivers/video/fbdev/omap2/omapfb/dss/venc.c 
b/drivers/video/fbdev/omap2/omapfb/dss/venc.c
index c9d40e28a06f..0bd80d3b8f1b 100644
--- a/drivers/video/fbdev/omap2/omapfb/dss/venc.c
+++ b/drivers/video/fbdev/omap2/omapfb/dss/venc.c
@@ -24,6 +24,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 
 #include 
@@ -764,7 +765,7 @@ static int venc_probe_of(struct platform_device *pdev)
u32 channels;
int r;
 
-   ep = omapdss_of_get_first_endpoint(node);
+   ep = of_graph_get_endpoint_by_regs(node, 0, -1);
if (!ep)
return 0;
 
diff --git a/drivers/video/fbdev/pxafb.c b/drivers/video/fbdev/pxafb.c
index fa943612c4e2..2ef56fa28aff 100644
--- a/drivers/video/fbdev/pxafb.c
+++ b/drivers/video/fbdev/pxafb.c
@@ -2171,7 +2171,7 @@ static int of_get_pxafb_mode_info(struct device *dev,
u32 bus_width;
int ret, i;
 
-   np = of_graph_get_next_endpoint(dev->of_node, NULL);
+   np = of_graph_get_endpoint_by_regs(dev-&g

[PATCH v2 3/4] media: platform: replace of_graph_get_next_endpoint()

2024-02-06 Thread Kuninori Morimoto
>From DT point of view, in general, drivers should be asking for a
specific port number because their function is fixed in the binding.

of_graph_get_next_endpoint() doesn't match to this concept.

Simply replace

- of_graph_get_next_endpoint(xxx, NULL);
+ of_graph_get_endpoint_by_regs(xxx, 0, -1);

Link: https://lore.kernel.org/r/20240202174941.ga310089-r...@kernel.org
Signed-off-by: Kuninori Morimoto 
---
 drivers/media/platform/atmel/atmel-isi.c  | 4 ++--
 drivers/media/platform/intel/pxa_camera.c | 2 +-
 drivers/media/platform/samsung/exynos4-is/fimc-is.c   | 2 +-
 drivers/media/platform/samsung/exynos4-is/mipi-csis.c | 3 ++-
 drivers/media/platform/st/stm32/stm32-dcmi.c  | 4 ++--
 drivers/media/platform/ti/davinci/vpif.c  | 3 +--
 6 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/drivers/media/platform/atmel/atmel-isi.c 
b/drivers/media/platform/atmel/atmel-isi.c
index f8450a8ccda6..c1108df72dd5 100644
--- a/drivers/media/platform/atmel/atmel-isi.c
+++ b/drivers/media/platform/atmel/atmel-isi.c
@@ -834,7 +834,7 @@ static int atmel_isi_parse_dt(struct atmel_isi *isi,
isi->pdata.full_mode = 1;
isi->pdata.frate = ISI_CFG1_FRATE_CAPTURE_ALL;
 
-   np = of_graph_get_next_endpoint(np, NULL);
+   np = of_graph_get_endpoint_by_regs(np, 0, -1);
if (!np) {
dev_err(>dev, "Could not find the endpoint\n");
return -EINVAL;
@@ -1158,7 +1158,7 @@ static int isi_graph_init(struct atmel_isi *isi)
struct device_node *ep;
int ret;
 
-   ep = of_graph_get_next_endpoint(isi->dev->of_node, NULL);
+   ep = of_graph_get_endpoint_by_regs(isi->dev->of_node, 0, -1);
if (!ep)
return -EINVAL;
 
diff --git a/drivers/media/platform/intel/pxa_camera.c 
b/drivers/media/platform/intel/pxa_camera.c
index 59b89e421dc2..d904952bf00e 100644
--- a/drivers/media/platform/intel/pxa_camera.c
+++ b/drivers/media/platform/intel/pxa_camera.c
@@ -2207,7 +2207,7 @@ static int pxa_camera_pdata_from_dt(struct device *dev,
pcdev->mclk = mclk_rate;
}
 
-   np = of_graph_get_next_endpoint(np, NULL);
+   np = of_graph_get_endpoint_by_regs(np, 0, -1);
if (!np) {
dev_err(dev, "could not find endpoint\n");
return -EINVAL;
diff --git a/drivers/media/platform/samsung/exynos4-is/fimc-is.c 
b/drivers/media/platform/samsung/exynos4-is/fimc-is.c
index a08c87ef6e2d..39aab667910d 100644
--- a/drivers/media/platform/samsung/exynos4-is/fimc-is.c
+++ b/drivers/media/platform/samsung/exynos4-is/fimc-is.c
@@ -175,7 +175,7 @@ static int fimc_is_parse_sensor_config(struct fimc_is *is, 
unsigned int index,
return -EINVAL;
}
 
-   ep = of_graph_get_next_endpoint(node, NULL);
+   ep = of_graph_get_endpoint_by_regs(node, 0, -1);
if (!ep)
return -ENXIO;
 
diff --git a/drivers/media/platform/samsung/exynos4-is/mipi-csis.c 
b/drivers/media/platform/samsung/exynos4-is/mipi-csis.c
index aae8a8b2c0f4..4b9b20ba3504 100644
--- a/drivers/media/platform/samsung/exynos4-is/mipi-csis.c
+++ b/drivers/media/platform/samsung/exynos4-is/mipi-csis.c
@@ -727,7 +727,8 @@ static int s5pcsis_parse_dt(struct platform_device *pdev,
 >max_num_lanes))
return -EINVAL;
 
-   node = of_graph_get_next_endpoint(node, NULL);
+   /* from port@3 or port@4 */
+   node = of_graph_get_endpoint_by_regs(node, -1, -1);
if (!node) {
dev_err(>dev, "No port node at %pOF\n",
pdev->dev.of_node);
diff --git a/drivers/media/platform/st/stm32/stm32-dcmi.c 
b/drivers/media/platform/st/stm32/stm32-dcmi.c
index c4610e305546..ff3331af9406 100644
--- a/drivers/media/platform/st/stm32/stm32-dcmi.c
+++ b/drivers/media/platform/st/stm32/stm32-dcmi.c
@@ -1855,7 +1855,7 @@ static int dcmi_graph_init(struct stm32_dcmi *dcmi)
struct device_node *ep;
int ret;
 
-   ep = of_graph_get_next_endpoint(dcmi->dev->of_node, NULL);
+   ep = of_graph_get_endpoint_by_regs(dcmi->dev->of_node, 0, -1);
if (!ep) {
dev_err(dcmi->dev, "Failed to get next endpoint\n");
return -EINVAL;
@@ -1907,7 +1907,7 @@ static int dcmi_probe(struct platform_device *pdev)
 "Could not get reset control\n");
 
/* Get bus characteristics from devicetree */
-   np = of_graph_get_next_endpoint(np, NULL);
+   np = of_graph_get_endpoint_by_regs(np, 0, -1);
if (!np) {
dev_err(>dev, "Could not find the endpoint\n");
return -ENODEV;
diff --git a/drivers/media/platform/ti/davinci/vpif.c 
b/drivers/media/platform/ti/davinci/vpif.c
index 63cdfed37bc9..f4e1fa76bf37 100644
--- a/drivers/media/p

[PATCH v2 2/4] media: i2c: replace of_graph_get_next_endpoint()

2024-02-06 Thread Kuninori Morimoto
>From DT point of view, in general, drivers should be asking for a
specific port number because their function is fixed in the binding.

of_graph_get_next_endpoint() doesn't match to this concept.

Simply replace

- of_graph_get_next_endpoint(xxx, NULL);
+ of_graph_get_endpoint_by_regs(xxx, 0, -1);

Link: https://lore.kernel.org/r/20240202174941.ga310089-r...@kernel.org
Link: https://lore.kernel.org/r/9d1e99b0-892d-4a72-a9b3-886b8ed09...@xs4all.nl
Signed-off-by: Kuninori Morimoto 
---
 drivers/media/i2c/adv7343.c  | 2 +-
 drivers/media/i2c/adv7604.c  | 4 ++--
 drivers/media/i2c/mt9p031.c  | 2 +-
 drivers/media/i2c/mt9v032.c  | 2 +-
 drivers/media/i2c/ov2659.c   | 2 +-
 drivers/media/i2c/ov5645.c   | 2 +-
 drivers/media/i2c/ov5647.c   | 2 +-
 drivers/media/i2c/s5c73m3/s5c73m3-core.c | 2 +-
 drivers/media/i2c/s5k5baf.c  | 2 +-
 drivers/media/i2c/tc358743.c | 2 +-
 drivers/media/i2c/tda1997x.c | 2 +-
 drivers/media/i2c/tvp514x.c  | 2 +-
 drivers/media/i2c/tvp7002.c  | 2 +-
 13 files changed, 14 insertions(+), 14 deletions(-)

diff --git a/drivers/media/i2c/adv7343.c b/drivers/media/i2c/adv7343.c
index ff21cd4744d3..4fbe4e18570e 100644
--- a/drivers/media/i2c/adv7343.c
+++ b/drivers/media/i2c/adv7343.c
@@ -403,7 +403,7 @@ adv7343_get_pdata(struct i2c_client *client)
if (!IS_ENABLED(CONFIG_OF) || !client->dev.of_node)
return client->dev.platform_data;
 
-   np = of_graph_get_next_endpoint(client->dev.of_node, NULL);
+   np = of_graph_get_endpoint_by_regs(client->dev.of_node, 0, -1);
if (!np)
return NULL;
 
diff --git a/drivers/media/i2c/adv7604.c b/drivers/media/i2c/adv7604.c
index 810fa8826f30..319db3e847c4 100644
--- a/drivers/media/i2c/adv7604.c
+++ b/drivers/media/i2c/adv7604.c
@@ -3204,8 +3204,8 @@ static int adv76xx_parse_dt(struct adv76xx_state *state)
 
np = state->i2c_clients[ADV76XX_PAGE_IO]->dev.of_node;
 
-   /* Parse the endpoint. */
-   endpoint = of_graph_get_next_endpoint(np, NULL);
+   /* FIXME: Parse the endpoint. */
+   endpoint = of_graph_get_endpoint_by_regs(np, -1, -1);
if (!endpoint)
return -EINVAL;
 
diff --git a/drivers/media/i2c/mt9p031.c b/drivers/media/i2c/mt9p031.c
index 596200d0248c..f4b481212356 100644
--- a/drivers/media/i2c/mt9p031.c
+++ b/drivers/media/i2c/mt9p031.c
@@ -1078,7 +1078,7 @@ mt9p031_get_pdata(struct i2c_client *client)
if (!IS_ENABLED(CONFIG_OF) || !client->dev.of_node)
return client->dev.platform_data;
 
-   np = of_graph_get_next_endpoint(client->dev.of_node, NULL);
+   np = of_graph_get_endpoint_by_regs(client->dev.of_node, 0, -1);
if (!np)
return NULL;
 
diff --git a/drivers/media/i2c/mt9v032.c b/drivers/media/i2c/mt9v032.c
index 3ca76eeae7ff..e9f5c6647f97 100644
--- a/drivers/media/i2c/mt9v032.c
+++ b/drivers/media/i2c/mt9v032.c
@@ -1006,7 +1006,7 @@ mt9v032_get_pdata(struct i2c_client *client)
if (!IS_ENABLED(CONFIG_OF) || !client->dev.of_node)
return client->dev.platform_data;
 
-   np = of_graph_get_next_endpoint(client->dev.of_node, NULL);
+   np = of_graph_get_endpoint_by_regs(client->dev.of_node, 0, -1);
if (!np)
return NULL;
 
diff --git a/drivers/media/i2c/ov2659.c b/drivers/media/i2c/ov2659.c
index 1d0ef72a6403..d1653d7431d0 100644
--- a/drivers/media/i2c/ov2659.c
+++ b/drivers/media/i2c/ov2659.c
@@ -1388,7 +1388,7 @@ ov2659_get_pdata(struct i2c_client *client)
if (!IS_ENABLED(CONFIG_OF) || !client->dev.of_node)
return client->dev.platform_data;
 
-   endpoint = of_graph_get_next_endpoint(client->dev.of_node, NULL);
+   endpoint = of_graph_get_endpoint_by_regs(client->dev.of_node, 0, -1);
if (!endpoint)
return NULL;
 
diff --git a/drivers/media/i2c/ov5645.c b/drivers/media/i2c/ov5645.c
index a26ac11c989d..9daf06ffedf4 100644
--- a/drivers/media/i2c/ov5645.c
+++ b/drivers/media/i2c/ov5645.c
@@ -1056,7 +1056,7 @@ static int ov5645_probe(struct i2c_client *client)
ov5645->i2c_client = client;
ov5645->dev = dev;
 
-   endpoint = of_graph_get_next_endpoint(dev->of_node, NULL);
+   endpoint = of_graph_get_endpoint_by_regs(dev->of_node, 0, -1);
if (!endpoint) {
dev_err(dev, "endpoint node not found\n");
return -EINVAL;
diff --git a/drivers/media/i2c/ov5647.c b/drivers/media/i2c/ov5647.c
index 96c0fd4ff5ab..7e1ecdf2485f 100644
--- a/drivers/media/i2c/ov5647.c
+++ b/drivers/media/i2c/ov5647.c
@@ -1363,7 +1363,7 @@ static int ov5647_parse_dt(struct ov5647 *sensor, struct 
device_node *np)
struct device_node *ep;
int ret;
 
-   ep = of_graph_get_next_endpoint(np

[PATCH v2 1/4] gpu: drm: replace of_graph_get_next_endpoint()

2024-02-06 Thread Kuninori Morimoto
>From DT point of view, in general, drivers should be asking for a
specific port number because their function is fixed in the binding.

of_graph_get_next_endpoint() doesn't match to this concept.

Simply replace

- of_graph_get_next_endpoint(xxx, NULL);
+ of_graph_get_endpoint_by_regs(xxx, 0, -1);

Link: https://lore.kernel.org/r/20240202174941.ga310089-r...@kernel.org
Signed-off-by: Kuninori Morimoto 
Reviewed-by: Laurent Pinchart 
---
 drivers/gpu/drm/drm_of.c  | 4 +++-
 drivers/gpu/drm/panel/panel-raspberrypi-touchscreen.c | 2 +-
 drivers/gpu/drm/tiny/arcpgu.c | 2 +-
 3 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/drm_of.c b/drivers/gpu/drm/drm_of.c
index 177b600895d3..b6b2cade69ae 100644
--- a/drivers/gpu/drm/drm_of.c
+++ b/drivers/gpu/drm/drm_of.c
@@ -504,6 +504,8 @@ EXPORT_SYMBOL_GPL(drm_of_get_data_lanes_count_ep);
  * Gets parent DSI bus for a DSI device controlled through a bus other
  * than MIPI-DCS (SPI, I2C, etc.) using the Device Tree.
  *
+ * This function assumes that the device's port@0 is the DSI input.
+ *
  * Returns pointer to mipi_dsi_host if successful, -EINVAL if the
  * request is unsupported, -EPROBE_DEFER if the DSI host is found but
  * not available, or -ENODEV otherwise.
@@ -516,7 +518,7 @@ struct mipi_dsi_host *drm_of_get_dsi_bus(struct device *dev)
/*
 * Get first endpoint child from device.
 */
-   endpoint = of_graph_get_next_endpoint(dev->of_node, NULL);
+   endpoint = of_graph_get_endpoint_by_regs(dev->of_node, 0, -1);
if (!endpoint)
return ERR_PTR(-ENODEV);
 
diff --git a/drivers/gpu/drm/panel/panel-raspberrypi-touchscreen.c 
b/drivers/gpu/drm/panel/panel-raspberrypi-touchscreen.c
index 4618c892cdd6..e10e469aa7a6 100644
--- a/drivers/gpu/drm/panel/panel-raspberrypi-touchscreen.c
+++ b/drivers/gpu/drm/panel/panel-raspberrypi-touchscreen.c
@@ -400,7 +400,7 @@ static int rpi_touchscreen_probe(struct i2c_client *i2c)
rpi_touchscreen_i2c_write(ts, REG_POWERON, 0);
 
/* Look up the DSI host.  It needs to probe before we do. */
-   endpoint = of_graph_get_next_endpoint(dev->of_node, NULL);
+   endpoint = of_graph_get_endpoint_by_regs(dev->of_node, 0, -1);
if (!endpoint)
return -ENODEV;
 
diff --git a/drivers/gpu/drm/tiny/arcpgu.c b/drivers/gpu/drm/tiny/arcpgu.c
index 4f8f3172379e..8c29b719ea62 100644
--- a/drivers/gpu/drm/tiny/arcpgu.c
+++ b/drivers/gpu/drm/tiny/arcpgu.c
@@ -288,7 +288,7 @@ static int arcpgu_load(struct arcpgu_drm_private *arcpgu)
 * There is only one output port inside each device. It is linked with
 * encoder endpoint.
 */
-   endpoint_node = of_graph_get_next_endpoint(pdev->dev.of_node, NULL);
+   endpoint_node = of_graph_get_endpoint_by_regs(pdev->dev.of_node, 0, -1);
if (endpoint_node) {
encoder_node = of_graph_get_remote_port_parent(endpoint_node);
of_node_put(endpoint_node);
-- 
2.25.1



[PATCH v2 0/4] of: replace of_graph_get_next_endpoint()

2024-02-06 Thread Kuninori Morimoto


Hi Rob

This is v2 of replace of_graph_get_next_endpoint()

We should get rid of or minimize of_graph_get_next_endpoint() in
its current form. In general, drivers should be asking for a specific 
port number because their function is fixed in the binding.

https://lore.kernel.org/r/20240131184347.ga1906672-r...@kernel.org

This patch-set replace of_graph_get_next_endpoint() by
of_graph_get_endpoint_by_regs(). There are still next_endpoint()
after this patch-set, but it will be replaced by
for_each_endpoint_of_node() in next patch-set (A)

[*] this patch-set
[o] done

[o] tidyup of_graph_get_endpoint_count()
[*] replace endpoint func - use endpoint_by_regs()
(A) [ ] replace endpoint func - use for_each()
[ ] rename endpoint func to device_endpoint
[ ] add new port function
[ ] add new endpont function
[ ] remove of_graph_get_next_device_endpoint()

v1 -> v2
- add Reviewed-by from Launrent
- use by_regs(xx, -1, -1) for some devices
- add extra explain for drm_of_get_dsi_bus()
- add FIXME and Link on adv7604.c
- based on latest of branch

Kuninori Morimoto (4):
  gpu: drm: replace of_graph_get_next_endpoint()
  media: i2c: replace of_graph_get_next_endpoint()
  media: platform: replace of_graph_get_next_endpoint()
  video: fbdev: replace of_graph_get_next_endpoint()

 drivers/gpu/drm/drm_of.c  |  4 +++-
 .../drm/panel/panel-raspberrypi-touchscreen.c |  2 +-
 drivers/gpu/drm/tiny/arcpgu.c |  2 +-
 drivers/media/i2c/adv7343.c   |  2 +-
 drivers/media/i2c/adv7604.c   |  4 ++--
 drivers/media/i2c/mt9p031.c   |  2 +-
 drivers/media/i2c/mt9v032.c   |  2 +-
 drivers/media/i2c/ov2659.c|  2 +-
 drivers/media/i2c/ov5645.c|  2 +-
 drivers/media/i2c/ov5647.c|  2 +-
 drivers/media/i2c/s5c73m3/s5c73m3-core.c  |  2 +-
 drivers/media/i2c/s5k5baf.c   |  2 +-
 drivers/media/i2c/tc358743.c  |  2 +-
 drivers/media/i2c/tda1997x.c  |  2 +-
 drivers/media/i2c/tvp514x.c   |  2 +-
 drivers/media/i2c/tvp7002.c   |  2 +-
 drivers/media/platform/atmel/atmel-isi.c  |  4 ++--
 drivers/media/platform/intel/pxa_camera.c |  2 +-
 .../platform/samsung/exynos4-is/fimc-is.c |  2 +-
 .../platform/samsung/exynos4-is/mipi-csis.c   |  3 ++-
 drivers/media/platform/st/stm32/stm32-dcmi.c  |  4 ++--
 drivers/media/platform/ti/davinci/vpif.c  |  3 +--
 drivers/video/fbdev/omap2/omapfb/dss/dsi.c|  3 ++-
 drivers/video/fbdev/omap2/omapfb/dss/dss-of.c | 20 +--
 drivers/video/fbdev/omap2/omapfb/dss/hdmi4.c  |  3 ++-
 drivers/video/fbdev/omap2/omapfb/dss/hdmi5.c  |  3 ++-
 drivers/video/fbdev/omap2/omapfb/dss/venc.c   |  3 ++-
 drivers/video/fbdev/pxafb.c   |  2 +-
 include/video/omapfb_dss.h|  3 ---
 29 files changed, 38 insertions(+), 53 deletions(-)

-- 
2.25.1



Re: [PATCH 2/4] media: i2c: replace of_graph_get_next_endpoint()

2024-02-06 Thread Kuninori Morimoto


Hi Laurent, Hans

> >> From DT point of view, in general, drivers should be asking for a
> >> specific port number because their function is fixed in the binding.
> >>
> >> of_graph_get_next_endpoint() doesn't match to this concept.
> >>
> >> Simply replace
> >>
> >>- of_graph_get_next_endpoint(xxx, NULL);
> >>+ of_graph_get_endpoint_by_regs(xxx, 0, -1);
(snip)
> >>/* Parse the endpoint. */
> >> -  endpoint = of_graph_get_next_endpoint(np, NULL);
> >> +  endpoint = of_graph_get_endpoint_by_regs(np, 0, -1);
> > 
> > I think this should be port 1 for the adv7611 and port2 for the adv7612.
> > The adv7610 may need to use port 1 too, but the bindings likely need to
> > be updated.
> > 
> > Hans, Krzysztof, any opinion ?
> 
> It looks like it. But I suspect the code never worked. The endpoint parsing
> is only needed if a specific mbus type is used (i.e., not 'UNKNOWN'), and
> I don't think that is used in the device trees in the kernel. So everything
> silently falls back to UNKNOWN and some default bus config that 'just works' 
> (tm).
> 
> I'm pretty sure this code is wrong, but nobody ever noticed. Changing it
> to the new code just makes it bug-compatible :-)

Nice ;)
So, let's add /* FIXME */ here in v2

Thank you for your help !!

Best regards
---
Renesas Electronics
Ph.D. Kuninori Morimoto


Re: [PATCH 4/4] video: fbdev: replace of_graph_get_next_endpoint()

2024-02-06 Thread Kuninori Morimoto


Hi Laurent

Thank you for the review

> > From DT point of view, in general, drivers should be asking for a
> > specific port number because their function is fixed in the binding.
> > 
> > of_graph_get_next_endpoint() doesn't match to this concept.
> > 
> > Simply replace
> > 
> > - of_graph_get_next_endpoint(xxx, NULL);
> > + of_graph_get_endpoint_by_regs(xxx, 0, -1);
(snip)
> > --- a/drivers/video/fbdev/amba-clcd.c
> > +++ b/drivers/video/fbdev/amba-clcd.c
> 
> This driver has been deleted in v6.8-rc1.

Thank you for pointing it.
I will rebase to latest of branch in v2


Thank you for your help !!

Best regards
---
Renesas Electronics
Ph.D. Kuninori Morimoto


Re: [PATCH 3/4] media: platform: replace of_graph_get_next_endpoint()

2024-02-06 Thread Kuninori Morimoto


Hi Laurent

Thank you for your review

> > diff --git a/drivers/media/platform/samsung/exynos4-is/mipi-csis.c 
> > b/drivers/media/platform/samsung/exynos4-is/mipi-csis.c
> > index 686ca8753ba2..3f8bea2e3934 100644
> > --- a/drivers/media/platform/samsung/exynos4-is/mipi-csis.c
> > +++ b/drivers/media/platform/samsung/exynos4-is/mipi-csis.c
> > @@ -728,7 +728,7 @@ static int s5pcsis_parse_dt(struct platform_device 
> > *pdev,
> >  >max_num_lanes))
> > return -EINVAL;
> >  
> > -   node = of_graph_get_next_endpoint(node, NULL);
> > +   node = of_graph_get_endpoint_by_regs(node, 0, -1);
> 
> This is not correct, see
> Documentation/devicetree/bindings/media/samsung,exynos4210-csis.yaml.

Hmm... Then, It can be like this ?

+ node = of_graph_get_endpoint_by_regs(node, -1, -1);




Thank you for your help !!

Best regards
---
Renesas Electronics
Ph.D. Kuninori Morimoto


Re: [PATCH v3 05/24] media: i2c: switch to use of_graph_get_next_device_endpoint()

2024-02-06 Thread Kuninori Morimoto


Hi Rob, again

> > This is assuming there's just 1 port and 1 endpoint, but let's be 
> > specific as the bindings are (first endpoint on port 0):
> > 
> > of_graph_get_endpoint_by_regs(client->dev.of_node, 0, -1);
> > 
> > Note we could ask for endpoint 0 here, but the bindings generally allow 
> > for more than 1.
> > 
> > I imagine most of the other cases here are the same.

I'm bit confused here.
You mentioned that -1 is wrong in previous mail.

Most cases are in the form of of_graph_get_next_endpoint(dev, NULL) 
which is equivalent to of_graph_get_endpoint_by_regs(dev, 0, 0). 
Technically, -1 instead of 0 is equivalent, but I'd argue is sloppy and 
wrong.

But you mentioned -1 here, So, I will use it on next patch-set.


Thank you for your help !!

Best regards
---
Renesas Electronics
Ph.D. Kuninori Morimoto


[PATCH 4/4] video: fbdev: replace of_graph_get_next_endpoint()

2024-02-05 Thread Kuninori Morimoto
>From DT point of view, in general, drivers should be asking for a
specific port number because their function is fixed in the binding.

of_graph_get_next_endpoint() doesn't match to this concept.

Simply replace

- of_graph_get_next_endpoint(xxx, NULL);
+ of_graph_get_endpoint_by_regs(xxx, 0, -1);

Link: https://lore.kernel.org/r/20240202174941.ga310089-r...@kernel.org
Signed-off-by: Kuninori Morimoto 
---
 drivers/video/fbdev/amba-clcd.c   |  2 +-
 drivers/video/fbdev/omap2/omapfb/dss/dsi.c|  3 ++-
 drivers/video/fbdev/omap2/omapfb/dss/dss-of.c | 20 +--
 drivers/video/fbdev/omap2/omapfb/dss/hdmi4.c  |  3 ++-
 drivers/video/fbdev/omap2/omapfb/dss/hdmi5.c  |  3 ++-
 drivers/video/fbdev/omap2/omapfb/dss/venc.c   |  3 ++-
 drivers/video/fbdev/pxafb.c   |  2 +-
 include/video/omapfb_dss.h|  3 ---
 8 files changed, 11 insertions(+), 28 deletions(-)

diff --git a/drivers/video/fbdev/amba-clcd.c b/drivers/video/fbdev/amba-clcd.c
index 0399db369e70..2371b204cfd2 100644
--- a/drivers/video/fbdev/amba-clcd.c
+++ b/drivers/video/fbdev/amba-clcd.c
@@ -691,7 +691,7 @@ static int clcdfb_of_init_display(struct clcd_fb *fb)
/*
 * Fetch the panel endpoint.
 */
-   endpoint = of_graph_get_next_endpoint(fb->dev->dev.of_node, NULL);
+   endpoint = of_graph_get_endpoint_by_regs(fb->dev->dev.of_node, 0, -1);
if (!endpoint)
return -ENODEV;
 
diff --git a/drivers/video/fbdev/omap2/omapfb/dss/dsi.c 
b/drivers/video/fbdev/omap2/omapfb/dss/dsi.c
index b7eb17a16ec4..1f13bcf73da5 100644
--- a/drivers/video/fbdev/omap2/omapfb/dss/dsi.c
+++ b/drivers/video/fbdev/omap2/omapfb/dss/dsi.c
@@ -28,6 +28,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 
@@ -5079,7 +5080,7 @@ static int dsi_probe_of(struct platform_device *pdev)
struct device_node *ep;
struct omap_dsi_pin_config pin_cfg;
 
-   ep = omapdss_of_get_first_endpoint(node);
+   ep = of_graph_get_endpoint_by_regs(node, 0, -1);
if (!ep)
return 0;
 
diff --git a/drivers/video/fbdev/omap2/omapfb/dss/dss-of.c 
b/drivers/video/fbdev/omap2/omapfb/dss/dss-of.c
index 0282d4eef139..14965a3fd05b 100644
--- a/drivers/video/fbdev/omap2/omapfb/dss/dss-of.c
+++ b/drivers/video/fbdev/omap2/omapfb/dss/dss-of.c
@@ -130,24 +130,6 @@ static struct device_node 
*omapdss_of_get_remote_port(const struct device_node *
return np;
 }
 
-struct device_node *
-omapdss_of_get_first_endpoint(const struct device_node *parent)
-{
-   struct device_node *port, *ep;
-
-   port = omapdss_of_get_next_port(parent, NULL);
-
-   if (!port)
-   return NULL;
-
-   ep = omapdss_of_get_next_endpoint(port, NULL);
-
-   of_node_put(port);
-
-   return ep;
-}
-EXPORT_SYMBOL_GPL(omapdss_of_get_first_endpoint);
-
 struct omap_dss_device *
 omapdss_of_find_source_for_first_ep(struct device_node *node)
 {
@@ -155,7 +137,7 @@ omapdss_of_find_source_for_first_ep(struct device_node 
*node)
struct device_node *src_port;
struct omap_dss_device *src;
 
-   ep = omapdss_of_get_first_endpoint(node);
+   ep = of_graph_get_endpoint_by_regs(node, 0, -1);
if (!ep)
return ERR_PTR(-EINVAL);
 
diff --git a/drivers/video/fbdev/omap2/omapfb/dss/hdmi4.c 
b/drivers/video/fbdev/omap2/omapfb/dss/hdmi4.c
index f05b4e35a842..8f407ec134dc 100644
--- a/drivers/video/fbdev/omap2/omapfb/dss/hdmi4.c
+++ b/drivers/video/fbdev/omap2/omapfb/dss/hdmi4.c
@@ -20,6 +20,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -529,7 +530,7 @@ static int hdmi_probe_of(struct platform_device *pdev)
struct device_node *ep;
int r;
 
-   ep = omapdss_of_get_first_endpoint(node);
+   ep = of_graph_get_endpoint_by_regs(node, 0, -1);
if (!ep)
return 0;
 
diff --git a/drivers/video/fbdev/omap2/omapfb/dss/hdmi5.c 
b/drivers/video/fbdev/omap2/omapfb/dss/hdmi5.c
index 03292945b1d4..4ad219f522b9 100644
--- a/drivers/video/fbdev/omap2/omapfb/dss/hdmi5.c
+++ b/drivers/video/fbdev/omap2/omapfb/dss/hdmi5.c
@@ -25,6 +25,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -561,7 +562,7 @@ static int hdmi_probe_of(struct platform_device *pdev)
struct device_node *ep;
int r;
 
-   ep = omapdss_of_get_first_endpoint(node);
+   ep = of_graph_get_endpoint_by_regs(node, 0, -1);
if (!ep)
return 0;
 
diff --git a/drivers/video/fbdev/omap2/omapfb/dss/venc.c 
b/drivers/video/fbdev/omap2/omapfb/dss/venc.c
index c9d40e28a06f..0bd80d3b8f1b 100644
--- a/drivers/video/fbdev/omap2/omapfb/dss/venc.c
+++ b/drivers/video/fbdev/omap2/omapfb/dss/venc.c
@@ -24,6 +24,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 
 #include 
@@ -764,7 +765,7 @@ static int venc_probe_of(struct platform_device *pdev)
u32 channels

[PATCH 3/4] media: platform: replace of_graph_get_next_endpoint()

2024-02-05 Thread Kuninori Morimoto
>From DT point of view, in general, drivers should be asking for a
specific port number because their function is fixed in the binding.

of_graph_get_next_endpoint() doesn't match to this concept.

Simply replace

- of_graph_get_next_endpoint(xxx, NULL);
+ of_graph_get_endpoint_by_regs(xxx, 0, -1);

Link: https://lore.kernel.org/r/20240202174941.ga310089-r...@kernel.org
Signed-off-by: Kuninori Morimoto 
---
 drivers/media/platform/atmel/atmel-isi.c  | 4 ++--
 drivers/media/platform/intel/pxa_camera.c | 2 +-
 drivers/media/platform/samsung/exynos4-is/fimc-is.c   | 2 +-
 drivers/media/platform/samsung/exynos4-is/mipi-csis.c | 2 +-
 drivers/media/platform/st/stm32/stm32-dcmi.c  | 4 ++--
 drivers/media/platform/ti/davinci/vpif.c  | 3 +--
 6 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/drivers/media/platform/atmel/atmel-isi.c 
b/drivers/media/platform/atmel/atmel-isi.c
index 4046212d48b4..f615aee85968 100644
--- a/drivers/media/platform/atmel/atmel-isi.c
+++ b/drivers/media/platform/atmel/atmel-isi.c
@@ -831,7 +831,7 @@ static int atmel_isi_parse_dt(struct atmel_isi *isi,
isi->pdata.full_mode = 1;
isi->pdata.frate = ISI_CFG1_FRATE_CAPTURE_ALL;
 
-   np = of_graph_get_next_endpoint(np, NULL);
+   np = of_graph_get_endpoint_by_regs(np, 0, -1);
if (!np) {
dev_err(>dev, "Could not find the endpoint\n");
return -EINVAL;
@@ -1155,7 +1155,7 @@ static int isi_graph_init(struct atmel_isi *isi)
struct device_node *ep;
int ret;
 
-   ep = of_graph_get_next_endpoint(isi->dev->of_node, NULL);
+   ep = of_graph_get_endpoint_by_regs(isi->dev->of_node, 0, -1);
if (!ep)
return -EINVAL;
 
diff --git a/drivers/media/platform/intel/pxa_camera.c 
b/drivers/media/platform/intel/pxa_camera.c
index 59b89e421dc2..d904952bf00e 100644
--- a/drivers/media/platform/intel/pxa_camera.c
+++ b/drivers/media/platform/intel/pxa_camera.c
@@ -2207,7 +2207,7 @@ static int pxa_camera_pdata_from_dt(struct device *dev,
pcdev->mclk = mclk_rate;
}
 
-   np = of_graph_get_next_endpoint(np, NULL);
+   np = of_graph_get_endpoint_by_regs(np, 0, -1);
if (!np) {
dev_err(dev, "could not find endpoint\n");
return -EINVAL;
diff --git a/drivers/media/platform/samsung/exynos4-is/fimc-is.c 
b/drivers/media/platform/samsung/exynos4-is/fimc-is.c
index a08c87ef6e2d..39aab667910d 100644
--- a/drivers/media/platform/samsung/exynos4-is/fimc-is.c
+++ b/drivers/media/platform/samsung/exynos4-is/fimc-is.c
@@ -175,7 +175,7 @@ static int fimc_is_parse_sensor_config(struct fimc_is *is, 
unsigned int index,
return -EINVAL;
}
 
-   ep = of_graph_get_next_endpoint(node, NULL);
+   ep = of_graph_get_endpoint_by_regs(node, 0, -1);
if (!ep)
return -ENXIO;
 
diff --git a/drivers/media/platform/samsung/exynos4-is/mipi-csis.c 
b/drivers/media/platform/samsung/exynos4-is/mipi-csis.c
index 686ca8753ba2..3f8bea2e3934 100644
--- a/drivers/media/platform/samsung/exynos4-is/mipi-csis.c
+++ b/drivers/media/platform/samsung/exynos4-is/mipi-csis.c
@@ -728,7 +728,7 @@ static int s5pcsis_parse_dt(struct platform_device *pdev,
 >max_num_lanes))
return -EINVAL;
 
-   node = of_graph_get_next_endpoint(node, NULL);
+   node = of_graph_get_endpoint_by_regs(node, 0, -1);
if (!node) {
dev_err(>dev, "No port node at %pOF\n",
pdev->dev.of_node);
diff --git a/drivers/media/platform/st/stm32/stm32-dcmi.c 
b/drivers/media/platform/st/stm32/stm32-dcmi.c
index 8cb4fdcae137..4c00aae013af 100644
--- a/drivers/media/platform/st/stm32/stm32-dcmi.c
+++ b/drivers/media/platform/st/stm32/stm32-dcmi.c
@@ -1856,7 +1856,7 @@ static int dcmi_graph_init(struct stm32_dcmi *dcmi)
struct device_node *ep;
int ret;
 
-   ep = of_graph_get_next_endpoint(dcmi->dev->of_node, NULL);
+   ep = of_graph_get_endpoint_by_regs(dcmi->dev->of_node, 0, -1);
if (!ep) {
dev_err(dcmi->dev, "Failed to get next endpoint\n");
return -EINVAL;
@@ -1915,7 +1915,7 @@ static int dcmi_probe(struct platform_device *pdev)
 "Could not get reset control\n");
 
/* Get bus characteristics from devicetree */
-   np = of_graph_get_next_endpoint(np, NULL);
+   np = of_graph_get_endpoint_by_regs(np, 0, -1);
if (!np) {
dev_err(>dev, "Could not find the endpoint\n");
return -ENODEV;
diff --git a/drivers/media/platform/ti/davinci/vpif.c 
b/drivers/media/platform/ti/davinci/vpif.c
index 63cdfed37bc9..f4e1fa76bf37 100644
--- a/drivers/media/platform/ti/davinci/vpif.c
+++

[PATCH 2/4] media: i2c: replace of_graph_get_next_endpoint()

2024-02-05 Thread Kuninori Morimoto
>From DT point of view, in general, drivers should be asking for a
specific port number because their function is fixed in the binding.

of_graph_get_next_endpoint() doesn't match to this concept.

Simply replace

- of_graph_get_next_endpoint(xxx, NULL);
+ of_graph_get_endpoint_by_regs(xxx, 0, -1);

Link: https://lore.kernel.org/r/20240202174941.ga310089-r...@kernel.org
Signed-off-by: Kuninori Morimoto 
---
 drivers/media/i2c/adv7343.c  | 2 +-
 drivers/media/i2c/adv7604.c  | 2 +-
 drivers/media/i2c/mt9p031.c  | 2 +-
 drivers/media/i2c/mt9v032.c  | 2 +-
 drivers/media/i2c/ov2659.c   | 2 +-
 drivers/media/i2c/ov5645.c   | 2 +-
 drivers/media/i2c/ov5647.c   | 2 +-
 drivers/media/i2c/s5c73m3/s5c73m3-core.c | 2 +-
 drivers/media/i2c/s5k5baf.c  | 2 +-
 drivers/media/i2c/tc358743.c | 2 +-
 drivers/media/i2c/tda1997x.c | 2 +-
 drivers/media/i2c/tvp514x.c  | 2 +-
 drivers/media/i2c/tvp7002.c  | 2 +-
 13 files changed, 13 insertions(+), 13 deletions(-)

diff --git a/drivers/media/i2c/adv7343.c b/drivers/media/i2c/adv7343.c
index ff21cd4744d3..4fbe4e18570e 100644
--- a/drivers/media/i2c/adv7343.c
+++ b/drivers/media/i2c/adv7343.c
@@ -403,7 +403,7 @@ adv7343_get_pdata(struct i2c_client *client)
if (!IS_ENABLED(CONFIG_OF) || !client->dev.of_node)
return client->dev.platform_data;
 
-   np = of_graph_get_next_endpoint(client->dev.of_node, NULL);
+   np = of_graph_get_endpoint_by_regs(client->dev.of_node, 0, -1);
if (!np)
return NULL;
 
diff --git a/drivers/media/i2c/adv7604.c b/drivers/media/i2c/adv7604.c
index b202a85fbeaa..dcfdbb975473 100644
--- a/drivers/media/i2c/adv7604.c
+++ b/drivers/media/i2c/adv7604.c
@@ -3205,7 +3205,7 @@ static int adv76xx_parse_dt(struct adv76xx_state *state)
np = state->i2c_clients[ADV76XX_PAGE_IO]->dev.of_node;
 
/* Parse the endpoint. */
-   endpoint = of_graph_get_next_endpoint(np, NULL);
+   endpoint = of_graph_get_endpoint_by_regs(np, 0, -1);
if (!endpoint)
return -EINVAL;
 
diff --git a/drivers/media/i2c/mt9p031.c b/drivers/media/i2c/mt9p031.c
index 348f1e1098fb..c57a0d436421 100644
--- a/drivers/media/i2c/mt9p031.c
+++ b/drivers/media/i2c/mt9p031.c
@@ -1080,7 +1080,7 @@ mt9p031_get_pdata(struct i2c_client *client)
if (!IS_ENABLED(CONFIG_OF) || !client->dev.of_node)
return client->dev.platform_data;
 
-   np = of_graph_get_next_endpoint(client->dev.of_node, NULL);
+   np = of_graph_get_endpoint_by_regs(client->dev.of_node, 0, -1);
if (!np)
return NULL;
 
diff --git a/drivers/media/i2c/mt9v032.c b/drivers/media/i2c/mt9v032.c
index 1c6f6cea1204..14d277680fa2 100644
--- a/drivers/media/i2c/mt9v032.c
+++ b/drivers/media/i2c/mt9v032.c
@@ -1008,7 +1008,7 @@ mt9v032_get_pdata(struct i2c_client *client)
if (!IS_ENABLED(CONFIG_OF) || !client->dev.of_node)
return client->dev.platform_data;
 
-   np = of_graph_get_next_endpoint(client->dev.of_node, NULL);
+   np = of_graph_get_endpoint_by_regs(client->dev.of_node, 0, -1);
if (!np)
return NULL;
 
diff --git a/drivers/media/i2c/ov2659.c b/drivers/media/i2c/ov2659.c
index 2c3dbe164eb6..edea62a02320 100644
--- a/drivers/media/i2c/ov2659.c
+++ b/drivers/media/i2c/ov2659.c
@@ -1388,7 +1388,7 @@ ov2659_get_pdata(struct i2c_client *client)
if (!IS_ENABLED(CONFIG_OF) || !client->dev.of_node)
return client->dev.platform_data;
 
-   endpoint = of_graph_get_next_endpoint(client->dev.of_node, NULL);
+   endpoint = of_graph_get_endpoint_by_regs(client->dev.of_node, 0, -1);
if (!endpoint)
return NULL;
 
diff --git a/drivers/media/i2c/ov5645.c b/drivers/media/i2c/ov5645.c
index a70db7e601a4..31d214bd4a83 100644
--- a/drivers/media/i2c/ov5645.c
+++ b/drivers/media/i2c/ov5645.c
@@ -1053,7 +1053,7 @@ static int ov5645_probe(struct i2c_client *client)
ov5645->i2c_client = client;
ov5645->dev = dev;
 
-   endpoint = of_graph_get_next_endpoint(dev->of_node, NULL);
+   endpoint = of_graph_get_endpoint_by_regs(dev->of_node, 0, -1);
if (!endpoint) {
dev_err(dev, "endpoint node not found\n");
return -EINVAL;
diff --git a/drivers/media/i2c/ov5647.c b/drivers/media/i2c/ov5647.c
index dcfe3129c63a..beab2813c672 100644
--- a/drivers/media/i2c/ov5647.c
+++ b/drivers/media/i2c/ov5647.c
@@ -1363,7 +1363,7 @@ static int ov5647_parse_dt(struct ov5647 *sensor, struct 
device_node *np)
struct device_node *ep;
int ret;
 
-   ep = of_graph_get_next_endpoint(np, NULL);
+   ep = of_graph_get_endpoint_by_regs(np, 0, -1);
if (!ep)
return -EINVAL;
 
diff --git a/drivers/med

[PATCH 1/4] gpu: drm: replace of_graph_get_next_endpoint()

2024-02-05 Thread Kuninori Morimoto
>From DT point of view, in general, drivers should be asking for a
specific port number because their function is fixed in the binding.

of_graph_get_next_endpoint() doesn't match to this concept.

Simply replace

- of_graph_get_next_endpoint(xxx, NULL);
+ of_graph_get_endpoint_by_regs(xxx, 0, -1);

Link: https://lore.kernel.org/r/20240202174941.ga310089-r...@kernel.org
Signed-off-by: Kuninori Morimoto 
---
 drivers/gpu/drm/drm_of.c  | 2 +-
 drivers/gpu/drm/panel/panel-raspberrypi-touchscreen.c | 2 +-
 drivers/gpu/drm/tiny/arcpgu.c | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/drm_of.c b/drivers/gpu/drm/drm_of.c
index 177b600895d3..c2eae9296012 100644
--- a/drivers/gpu/drm/drm_of.c
+++ b/drivers/gpu/drm/drm_of.c
@@ -516,7 +516,7 @@ struct mipi_dsi_host *drm_of_get_dsi_bus(struct device *dev)
/*
 * Get first endpoint child from device.
 */
-   endpoint = of_graph_get_next_endpoint(dev->of_node, NULL);
+   endpoint = of_graph_get_endpoint_by_regs(dev->of_node, 0, -1);
if (!endpoint)
return ERR_PTR(-ENODEV);
 
diff --git a/drivers/gpu/drm/panel/panel-raspberrypi-touchscreen.c 
b/drivers/gpu/drm/panel/panel-raspberrypi-touchscreen.c
index 4618c892cdd6..e10e469aa7a6 100644
--- a/drivers/gpu/drm/panel/panel-raspberrypi-touchscreen.c
+++ b/drivers/gpu/drm/panel/panel-raspberrypi-touchscreen.c
@@ -400,7 +400,7 @@ static int rpi_touchscreen_probe(struct i2c_client *i2c)
rpi_touchscreen_i2c_write(ts, REG_POWERON, 0);
 
/* Look up the DSI host.  It needs to probe before we do. */
-   endpoint = of_graph_get_next_endpoint(dev->of_node, NULL);
+   endpoint = of_graph_get_endpoint_by_regs(dev->of_node, 0, -1);
if (!endpoint)
return -ENODEV;
 
diff --git a/drivers/gpu/drm/tiny/arcpgu.c b/drivers/gpu/drm/tiny/arcpgu.c
index e5b10e41554a..04d0053b9315 100644
--- a/drivers/gpu/drm/tiny/arcpgu.c
+++ b/drivers/gpu/drm/tiny/arcpgu.c
@@ -288,7 +288,7 @@ static int arcpgu_load(struct arcpgu_drm_private *arcpgu)
 * There is only one output port inside each device. It is linked with
 * encoder endpoint.
 */
-   endpoint_node = of_graph_get_next_endpoint(pdev->dev.of_node, NULL);
+   endpoint_node = of_graph_get_endpoint_by_regs(pdev->dev.of_node, 0, -1);
if (endpoint_node) {
encoder_node = of_graph_get_remote_port_parent(endpoint_node);
of_node_put(endpoint_node);
-- 
2.25.1



[PATCH 0/4] of: replace of_graph_get_next_endpoint()

2024-02-05 Thread Kuninori Morimoto


Hi Rob

We should get rid of or minimize of_graph_get_next_endpoint() in
its current form. In general, drivers should be asking for a specific 
port number because their function is fixed in the binding.

https://lore.kernel.org/r/20240131184347.ga1906672-r...@kernel.org

This patch-set replace of_graph_get_next_endpoint() by
of_graph_get_endpoint_by_regs(). There are still next_endpoint()
after this patch-set, but it will be replaced by
for_each_endpoint_of_node() in next patch-set (A)

[*] this patch-set
[o] done

[o] tidyup of_graph_get_endpoint_count()
[*] replace endpoint func - use endpoint_by_regs()
(A) [ ] replace endpoint func - use for_each()
[ ] rename endpoint func to device_endpoint
[ ] add new port function
[ ] add new endpont function
[ ] remove of_graph_get_next_device_endpoint()

Kuninori Morimoto (4):
  gpu: drm: replace of_graph_get_next_endpoint()
  media: i2c: replace of_graph_get_next_endpoint()
  media: platform: replace of_graph_get_next_endpoint()
  video: fbdev: replace of_graph_get_next_endpoint()

 drivers/gpu/drm/drm_of.c  |  2 +-
 .../drm/panel/panel-raspberrypi-touchscreen.c |  2 +-
 drivers/gpu/drm/tiny/arcpgu.c |  2 +-
 drivers/media/i2c/adv7343.c   |  2 +-
 drivers/media/i2c/adv7604.c   |  2 +-
 drivers/media/i2c/mt9p031.c   |  2 +-
 drivers/media/i2c/mt9v032.c   |  2 +-
 drivers/media/i2c/ov2659.c|  2 +-
 drivers/media/i2c/ov5645.c|  2 +-
 drivers/media/i2c/ov5647.c|  2 +-
 drivers/media/i2c/s5c73m3/s5c73m3-core.c  |  2 +-
 drivers/media/i2c/s5k5baf.c   |  2 +-
 drivers/media/i2c/tc358743.c  |  2 +-
 drivers/media/i2c/tda1997x.c  |  2 +-
 drivers/media/i2c/tvp514x.c   |  2 +-
 drivers/media/i2c/tvp7002.c   |  2 +-
 drivers/media/platform/atmel/atmel-isi.c  |  4 ++--
 drivers/media/platform/intel/pxa_camera.c |  2 +-
 .../platform/samsung/exynos4-is/fimc-is.c |  2 +-
 .../platform/samsung/exynos4-is/mipi-csis.c   |  2 +-
 drivers/media/platform/st/stm32/stm32-dcmi.c  |  4 ++--
 drivers/media/platform/ti/davinci/vpif.c  |  3 +--
 drivers/video/fbdev/amba-clcd.c   |  2 +-
 drivers/video/fbdev/omap2/omapfb/dss/dsi.c|  3 ++-
 drivers/video/fbdev/omap2/omapfb/dss/dss-of.c | 20 +--
 drivers/video/fbdev/omap2/omapfb/dss/hdmi4.c  |  3 ++-
 drivers/video/fbdev/omap2/omapfb/dss/hdmi5.c  |  3 ++-
 drivers/video/fbdev/omap2/omapfb/dss/venc.c   |  3 ++-
 drivers/video/fbdev/pxafb.c   |  2 +-
 include/video/omapfb_dss.h|  3 ---
 30 files changed, 35 insertions(+), 53 deletions(-)

-- 
2.25.1



Re: [PATCH v3 05/24] media: i2c: switch to use of_graph_get_next_device_endpoint()

2024-02-05 Thread Kuninori Morimoto
Hi Rob

> I've read the threads already and think you should skip the rename. Just 
> put 'port' in the name of the new one.

OK

> That and taking a port number param should be enough distinction.

I think we want to use "port" directly instead of "port number"
on new function.

Thank you for your help !!

Best regards
---
Renesas Electronics
Ph.D. Kuninori Morimoto


Re: [PATCH v3 05/24] media: i2c: switch to use of_graph_get_next_device_endpoint()

2024-02-05 Thread Kuninori Morimoto


Hi Rob

> This is assuming there's just 1 port and 1 endpoint, but let's be 
> specific as the bindings are (first endpoint on port 0):
> 
> of_graph_get_endpoint_by_regs(client->dev.of_node, 0, -1);
> 
> Note we could ask for endpoint 0 here, but the bindings generally allow 
> for more than 1.
> 
> I imagine most of the other cases here are the same.

I will do it on new patch-set

> > -   for_each_endpoint_of_node(state->dev->of_node, ep_np) {
> > +   for_each_device_endpoint_of_node(state->dev->of_node, ep_np) {
> 
> I would skip the rename.

It is needed to avoid confuse, because new function will add
another endpoint loop.

see
https://lore.kernel.org/r/20240131100701.754a95ee@booty


Thank you for your help !!

Best regards
---
Renesas Electronics
Ph.D. Kuninori Morimoto


Re: [PATCH v3 14/24] of: property: add of_graph_get_next_endpoint()

2024-02-01 Thread Kuninori Morimoto


Hi Luca

Thank you for your review

> > To handle endpoint more intuitive, create of_graph_get_next_endpoint()
> > 
> > of_graph_get_next_endpoint(port1, NULL); // A1
> > of_graph_get_next_endpoint(port1, A1);   // A2
> > of_graph_get_next_endpoint(port1, A2);   // NULL
> 
> The idea looks good. My only concern is about reusing the
> of_graph_get_next_endpoint() name after having removed the old, different
> function having the same name. This can be confusing in the first
> place to who is used to the old function, and also to anybody rebasing
> their patches on top of a new kernel to find their code behaving
> differently.
> 
> Also, as now we'd have two similar variants of this function, it would
> be good if each of them were having a name that clearly identifies in
> which way they differ from the other.
> 
> So a better name for this function would probably be
> of_graph_get_next_port_endpoint() I guess, to clearly differentiate from
> of_graph_get_next_device_endpoint().

Yes, Indeed, Thank you for pointing it !
I will update it on v4


Thank you for your help !!

Best regards
---
Renesas Electronics
Ph.D. Kuninori Morimoto


Re: [PATCH v3 02/24] of: property: use unsigned int return on of_graph_get_endpoint_count()

2024-02-01 Thread Kuninori Morimoto


Hi Dmitry

Thank you for your review

> > The return type and the variable of of_graph_get_endpoint_count()
> > should be unsigned. Tidyup it.
> 
> 'the variable'?
> 
> I'd have added a few words telling that return type can be unsigned
> because there is no error reporting for this function.

I see. v4 will be

Because of of_graph_get_endpoint_count() doesn't report error,
just return count of endpoint, the return type of it should be
unsigned. Tidyup it.

Thank you for your help !!

Best regards
---
Renesas Electronics
Ph.D. Kuninori Morimoto


[PATCH v3 24/24] fbdev: omapfb: use of_graph_get_next_device_endpoint()

2024-01-31 Thread Kuninori Morimoto
omapdss_of_get_first_endpoint() is same as
of_graph_get_next_device_endpoint(xxx, NULL). Replcase it.

Signed-off-by: Kuninori Morimoto 
---
 drivers/video/fbdev/omap2/omapfb/dss/dsi.c|  3 ++-
 drivers/video/fbdev/omap2/omapfb/dss/dss-of.c | 20 +--
 drivers/video/fbdev/omap2/omapfb/dss/hdmi4.c  |  3 ++-
 drivers/video/fbdev/omap2/omapfb/dss/hdmi5.c  |  3 ++-
 drivers/video/fbdev/omap2/omapfb/dss/venc.c   |  3 ++-
 include/video/omapfb_dss.h|  3 ---
 6 files changed, 9 insertions(+), 26 deletions(-)

diff --git a/drivers/video/fbdev/omap2/omapfb/dss/dsi.c 
b/drivers/video/fbdev/omap2/omapfb/dss/dsi.c
index b7eb17a16ec4..4d503aa824d3 100644
--- a/drivers/video/fbdev/omap2/omapfb/dss/dsi.c
+++ b/drivers/video/fbdev/omap2/omapfb/dss/dsi.c
@@ -28,6 +28,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 
@@ -5079,7 +5080,7 @@ static int dsi_probe_of(struct platform_device *pdev)
struct device_node *ep;
struct omap_dsi_pin_config pin_cfg;
 
-   ep = omapdss_of_get_first_endpoint(node);
+   ep = of_graph_get_next_device_endpoint(node, NULL);
if (!ep)
return 0;
 
diff --git a/drivers/video/fbdev/omap2/omapfb/dss/dss-of.c 
b/drivers/video/fbdev/omap2/omapfb/dss/dss-of.c
index 2ba2554055fc..130bbe4813be 100644
--- a/drivers/video/fbdev/omap2/omapfb/dss/dss-of.c
+++ b/drivers/video/fbdev/omap2/omapfb/dss/dss-of.c
@@ -51,24 +51,6 @@ u32 dss_of_port_get_port_number(struct device_node *port)
return reg;
 }
 
-struct device_node *
-omapdss_of_get_first_endpoint(const struct device_node *parent)
-{
-   struct device_node *port, *ep;
-
-   port = of_graph_get_next_port(parent, NULL);
-
-   if (!port)
-   return NULL;
-
-   ep = of_graph_get_next_endpoint(port, NULL);
-
-   of_node_put(port);
-
-   return ep;
-}
-EXPORT_SYMBOL_GPL(omapdss_of_get_first_endpoint);
-
 struct omap_dss_device *
 omapdss_of_find_source_for_first_ep(struct device_node *node)
 {
@@ -76,7 +58,7 @@ omapdss_of_find_source_for_first_ep(struct device_node *node)
struct device_node *src_port;
struct omap_dss_device *src;
 
-   ep = omapdss_of_get_first_endpoint(node);
+   ep = of_graph_get_next_device_endpoint(node, NULL);
if (!ep)
return ERR_PTR(-EINVAL);
 
diff --git a/drivers/video/fbdev/omap2/omapfb/dss/hdmi4.c 
b/drivers/video/fbdev/omap2/omapfb/dss/hdmi4.c
index f05b4e35a842..3a7d612c8feb 100644
--- a/drivers/video/fbdev/omap2/omapfb/dss/hdmi4.c
+++ b/drivers/video/fbdev/omap2/omapfb/dss/hdmi4.c
@@ -20,6 +20,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -529,7 +530,7 @@ static int hdmi_probe_of(struct platform_device *pdev)
struct device_node *ep;
int r;
 
-   ep = omapdss_of_get_first_endpoint(node);
+   ep = of_graph_get_next_device_endpoint(node, NULL);
if (!ep)
return 0;
 
diff --git a/drivers/video/fbdev/omap2/omapfb/dss/hdmi5.c 
b/drivers/video/fbdev/omap2/omapfb/dss/hdmi5.c
index 03292945b1d4..db01ac3ea387 100644
--- a/drivers/video/fbdev/omap2/omapfb/dss/hdmi5.c
+++ b/drivers/video/fbdev/omap2/omapfb/dss/hdmi5.c
@@ -25,6 +25,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -561,7 +562,7 @@ static int hdmi_probe_of(struct platform_device *pdev)
struct device_node *ep;
int r;
 
-   ep = omapdss_of_get_first_endpoint(node);
+   ep = of_graph_get_next_device_endpoint(node, NULL);
if (!ep)
return 0;
 
diff --git a/drivers/video/fbdev/omap2/omapfb/dss/venc.c 
b/drivers/video/fbdev/omap2/omapfb/dss/venc.c
index c9d40e28a06f..4dcc3f2a2aec 100644
--- a/drivers/video/fbdev/omap2/omapfb/dss/venc.c
+++ b/drivers/video/fbdev/omap2/omapfb/dss/venc.c
@@ -24,6 +24,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 
 #include 
@@ -764,7 +765,7 @@ static int venc_probe_of(struct platform_device *pdev)
u32 channels;
int r;
 
-   ep = omapdss_of_get_first_endpoint(node);
+   ep = of_graph_get_next_device_endpoint(node, NULL);
if (!ep)
return 0;
 
diff --git a/include/video/omapfb_dss.h b/include/video/omapfb_dss.h
index fc106aaa75bf..d133190e3143 100644
--- a/include/video/omapfb_dss.h
+++ b/include/video/omapfb_dss.h
@@ -811,9 +811,6 @@ static inline bool omapdss_device_is_enabled(struct 
omap_dss_device *dssdev)
return dssdev->state == OMAP_DSS_DISPLAY_ACTIVE;
 }
 
-struct device_node *
-omapdss_of_get_first_endpoint(const struct device_node *parent);
-
 struct omap_dss_device *
 omapdss_of_find_source_for_first_ep(struct device_node *node);
 #else
-- 
2.25.1



[PATCH v3 02/24] of: property: use unsigned int return on of_graph_get_endpoint_count()

2024-01-31 Thread Kuninori Morimoto
The return type and the variable of of_graph_get_endpoint_count()
should be unsigned. Tidyup it.

Signed-off-by: Kuninori Morimoto 
---
 drivers/of/property.c| 2 +-
 include/linux/of_graph.h | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/of/property.c b/drivers/of/property.c
index 4e879faa1710..25d73409aeee 100644
--- a/drivers/of/property.c
+++ b/drivers/of/property.c
@@ -817,7 +817,7 @@ EXPORT_SYMBOL(of_graph_get_remote_port);
  *
  * Return: count of endpoint of this device node
  */
-int of_graph_get_endpoint_count(const struct device_node *np)
+unsigned int of_graph_get_endpoint_count(const struct device_node *np)
 {
struct device_node *endpoint;
int num = 0;
diff --git a/include/linux/of_graph.h b/include/linux/of_graph.h
index 4d7756087b6b..a4bea62bfa29 100644
--- a/include/linux/of_graph.h
+++ b/include/linux/of_graph.h
@@ -41,7 +41,7 @@ struct of_endpoint {
 bool of_graph_is_present(const struct device_node *node);
 int of_graph_parse_endpoint(const struct device_node *node,
struct of_endpoint *endpoint);
-int of_graph_get_endpoint_count(const struct device_node *np);
+unsigned int of_graph_get_endpoint_count(const struct device_node *np);
 struct device_node *of_graph_get_port_by_id(struct device_node *node, u32 id);
 struct device_node *of_graph_get_next_endpoint(const struct device_node 
*parent,
struct device_node *previous);
@@ -68,7 +68,7 @@ static inline int of_graph_parse_endpoint(const struct 
device_node *node,
return -ENOSYS;
 }
 
-static inline int of_graph_get_endpoint_count(const struct device_node *np)
+static inline unsigned int of_graph_get_endpoint_count(const struct 
device_node *np)
 {
return 0;
 }
-- 
2.25.1



[PATCH v3 03/24] of: property: rename of_graph_get_next_endpoint() to of_graph_get_next_device_endpoint()

2024-01-31 Thread Kuninori Morimoto
Current of_graph_get_next_endpoint() will get next endpoint.

ports {
port@0 {
endpoint@0 {...};
(A) endpoint@1 {...};
};
port@1 {
(B) endpoint {...};
};
...
};

If it reached to end of port (A), it will get next endpoint from next
port (B). This behavior is not intuitive to user. User assume it return
NULL after (A) from this function name.

This function gets "endpoint" from "device" one after another instead
of "port". So let's rename related functions as

of_graph_get_next_endpoint()  -> of_graph_get_next_device_endpoint()
of_graph_get_endpoint_count() -> of_graph_get_device_endpoint_count()
for_each_endpoint_of_node()   -> for_each_device_endpoint_of_node()

Signed-off-by: Kuninori Morimoto 
---
 .clang-format|  2 +-
 drivers/of/property.c| 24 +---
 include/linux/of_graph.h | 23 ++-
 3 files changed, 28 insertions(+), 21 deletions(-)

diff --git a/.clang-format b/.clang-format
index 0bbb1991defe..e8ca6d577073 100644
--- a/.clang-format
+++ b/.clang-format
@@ -231,6 +231,7 @@ ForEachMacros:
   - 'for_each_dedup_cand'
   - 'for_each_dev_addr'
   - 'for_each_dev_scope'
+  - 'for_each_device_endpoint_of_node'
   - 'for_each_dma_cap_mask'
   - 'for_each_dpcm_be'
   - 'for_each_dpcm_be_rollback'
@@ -243,7 +244,6 @@ ForEachMacros:
   - 'for_each_element'
   - 'for_each_element_extid'
   - 'for_each_element_id'
-  - 'for_each_endpoint_of_node'
   - 'for_each_event'
   - 'for_each_event_tps'
   - 'for_each_evictable_lru'
diff --git a/drivers/of/property.c b/drivers/of/property.c
index 25d73409aeee..007729d66972 100644
--- a/drivers/of/property.c
+++ b/drivers/of/property.c
@@ -632,15 +632,17 @@ struct device_node *of_graph_get_port_by_id(struct 
device_node *parent, u32 id)
 EXPORT_SYMBOL(of_graph_get_port_by_id);
 
 /**
- * of_graph_get_next_endpoint() - get next endpoint node
+ * of_graph_get_next_device_endpoint() - get next endpoint node. If it reached 
to end of the port,
+ * it gets next endpoint from next port.
+ *
  * @parent: pointer to the parent device node
  * @prev: previous endpoint node, or NULL to get first
  *
  * Return: An 'endpoint' node pointer with refcount incremented. Refcount
  * of the passed @prev node is decremented.
  */
-struct device_node *of_graph_get_next_endpoint(const struct device_node 
*parent,
-   struct device_node *prev)
+struct device_node *of_graph_get_next_device_endpoint(const struct device_node 
*parent,
+ struct device_node *prev)
 {
struct device_node *endpoint;
struct device_node *port;
@@ -696,7 +698,7 @@ struct device_node *of_graph_get_next_endpoint(const struct 
device_node *parent,
} while (!of_node_name_eq(port, "port"));
}
 }
-EXPORT_SYMBOL(of_graph_get_next_endpoint);
+EXPORT_SYMBOL(of_graph_get_next_device_endpoint);
 
 /**
  * of_graph_get_endpoint_by_regs() - get endpoint node of specific identifiers
@@ -714,7 +716,7 @@ struct device_node *of_graph_get_endpoint_by_regs(
struct of_endpoint endpoint;
struct device_node *node = NULL;
 
-   for_each_endpoint_of_node(parent, node) {
+   for_each_device_endpoint_of_node(parent, node) {
of_graph_parse_endpoint(node, );
if (((port_reg == -1) || (endpoint.port == port_reg)) &&
((reg == -1) || (endpoint.id == reg)))
@@ -812,22 +814,22 @@ struct device_node *of_graph_get_remote_port(const struct 
device_node *node)
 EXPORT_SYMBOL(of_graph_get_remote_port);
 
 /**
- * of_graph_get_endpoint_count() - get count of endpoint
+ * of_graph_get_device_endpoint_count() - get count of endpoint
  * @np: pointer to the parent device node
  *
  * Return: count of endpoint of this device node
  */
-unsigned int of_graph_get_endpoint_count(const struct device_node *np)
+unsigned int of_graph_get_device_endpoint_count(const struct device_node *np)
 {
struct device_node *endpoint;
int num = 0;
 
-   for_each_endpoint_of_node(np, endpoint)
+   for_each_device_endpoint_of_node(np, endpoint)
num++;
 
return num;
 }
-EXPORT_SYMBOL(of_graph_get_endpoint_count);
+EXPORT_SYMBOL(of_graph_get_device_endpoint_count);
 
 /**
  * of_graph_get_remote_node() - get remote parent device_node for given 
port/endpoint
@@ -1017,8 +1019,8 @@ static struct fwnode_handle *
 of_fwnode_graph_get_next_endpoint(const struct fwnode_handle *fwnode,
  struct fwnode_handle *prev)
 {
-   return of_fwnode_handle(of_graph_get_next_endpoint(to_of_node(fwnode),
-  to_of_node(prev)));
+   return 
of_fwnode_h

[PATCH v3 14/24] of: property: add of_graph_get_next_endpoint()

2024-01-31 Thread Kuninori Morimoto
We already have of_graph_get_next_device_endpoint(), but it is not
intuitive to use.

(X) node {
(Y) ports {
port@0 { endpoint { remote-endpoint = ...; };};
(A1)port@1 { endpoint { remote-endpoint = ...; };
(A2) endpoint { remote-endpoint = ...; };};
(B) port@2 { endpoint { remote-endpoint = ...; };};
};
};

For example, if I want to handle port@1's 2 endpoints (= A1, A2),
I want to use like below

A1 = of_graph_get_next_device_endpoint(port1, NULL);
A2 = of_graph_get_next_device_endpoint(port1, A1);

But 1st one will be error, because of_graph_get_next_device_endpoint()
requested "parent" means "node" (X) or "ports" (Y), not "port".
Below are OK

/* These will be node/ports/port@0/endpoint */
of_graph_get_next_device_endpoint(node,  NULL);
of_graph_get_next_device_endpoint(ports, NULL);

In other words, we can't handle A1/A2 directly via
of_graph_get_next_device_endpoint() so far.

There is another non intuitive behavior on
of_graph_get_next_device_endpoint(). In case of if I could get A1 pointer
for some way, and if I want to handle port@1 things, I would like use
it like below

/*
 * "ep" is now A1, and handle port1 things here,
 * but we don't know how many endpoints port1 has.
 *
 * Because "ep" is non NULL, we can use port1
 * as of_graph_get_next_device_endpoint(port1, xxx)
 */
do {
/* do something for port1 specific things here */
} while (ep = of_graph_get_next_device_endpoint(port1, ep))

But it also not worked as I expected.
I expect it will be A1 -> A2 -> NULL,
but  it will be A1 -> A2 -> B,because
of_graph_get_next_device_endpoint() will fetch endpoint beyond the port.

It is not useful on generic driver like Generic Sound Card.
It uses of_get_next_child() instead for now, but it is not intuitive,
and not check node name (= "endpoint").

To handle endpoint more intuitive, create of_graph_get_next_endpoint()

of_graph_get_next_endpoint(port1, NULL); // A1
of_graph_get_next_endpoint(port1, A1);   // A2
of_graph_get_next_endpoint(port1, A2);   // NULL

Signed-off-by: Kuninori Morimoto 
---
 drivers/of/property.c| 24 +++-
 include/linux/of_graph.h |  9 +
 2 files changed, 32 insertions(+), 1 deletion(-)

diff --git a/drivers/of/property.c b/drivers/of/property.c
index 083f92513f5e..ff37fd5194c1 100644
--- a/drivers/of/property.c
+++ b/drivers/of/property.c
@@ -669,6 +669,28 @@ struct device_node *of_graph_get_next_port(const struct 
device_node *parent,
 }
 EXPORT_SYMBOL(of_graph_get_next_port);
 
+/**
+ * of_graph_get_next_endpoint() - get next endpoint node. If it reached to end 
of the port,
+ * it will return NULL.
+ * @port: pointer to the target port node
+ * @endpoint: current endpoint node, or NULL to get first
+ *
+ * Return: An 'endpoint' node pointer with refcount incremented. Refcount
+ * of the passed @prev node is decremented.
+ */
+struct device_node *of_graph_get_next_endpoint(const struct device_node *port,
+  struct device_node *endpoint)
+{
+   do {
+   endpoint = of_get_next_child(port, endpoint);
+   if (!endpoint)
+   break;
+   } while (!of_node_name_eq(endpoint, "endpoint"));
+
+   return endpoint;
+}
+EXPORT_SYMBOL(of_graph_get_next_endpoint);
+
 /**
  * of_graph_get_next_device_endpoint() - get next endpoint node. If it reached 
to end of the port,
  * it gets next endpoint from next port.
@@ -712,7 +734,7 @@ struct device_node *of_graph_get_next_device_endpoint(const 
struct device_node *
 * getting the next child. If the previous endpoint is NULL this
 * will return the first child.
 */
-   endpoint = of_get_next_child(port, prev);
+   endpoint = of_graph_get_next_endpoint(port, prev);
if (endpoint) {
of_node_put(port);
return endpoint;
diff --git a/include/linux/of_graph.h b/include/linux/of_graph.h
index 48f7701feab1..ee4b219594f1 100644
--- a/include/linux/of_graph.h
+++ b/include/linux/of_graph.h
@@ -57,6 +57,8 @@ unsigned int of_graph_get_port_count(const struct device_node 
*np);
 struct device_node *of_graph_get_port_by_id(struct device_node *node, u32 id);
 struct device_node *of_graph_get_next_device_endpoint(const struct device_node 
*parent,
  struct device_node 
*previous);
+struct device_node *of_graph_get_next_endpoint(const struct device_node *port,
+  struct device_node *prev);
 struct device_node *of_graph_get_n

[PATCH v3 01/24] of: property: add missing kerneldoc for of_graph_get_endpoint_count()

2024-01-31 Thread Kuninori Morimoto
of_graph_get_endpoint_count() doesn't have kerneldoc. Add it.

Signed-off-by: Kuninori Morimoto 
---
 drivers/of/property.c | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/drivers/of/property.c b/drivers/of/property.c
index afdaefbd03f6..4e879faa1710 100644
--- a/drivers/of/property.c
+++ b/drivers/of/property.c
@@ -811,6 +811,12 @@ struct device_node *of_graph_get_remote_port(const struct 
device_node *node)
 }
 EXPORT_SYMBOL(of_graph_get_remote_port);
 
+/**
+ * of_graph_get_endpoint_count() - get count of endpoint
+ * @np: pointer to the parent device node
+ *
+ * Return: count of endpoint of this device node
+ */
 int of_graph_get_endpoint_count(const struct device_node *np)
 {
struct device_node *endpoint;
-- 
2.25.1



[PATCH v3 22/24] fbdev: omapfb: use of_graph_get_next_port()

2024-01-31 Thread Kuninori Morimoto
Now we can use of_graph_get_next_port() for port parsing.
Use it on omapfb.

Signed-off-by: Kuninori Morimoto 
---
 drivers/video/fbdev/omap2/omapfb/dss/dss-of.c | 48 +--
 drivers/video/fbdev/omap2/omapfb/dss/dss.c|  9 ++--
 include/video/omapfb_dss.h|  4 --
 3 files changed, 6 insertions(+), 55 deletions(-)

diff --git a/drivers/video/fbdev/omap2/omapfb/dss/dss-of.c 
b/drivers/video/fbdev/omap2/omapfb/dss/dss-of.c
index fe6c72d03216..321ae18f2747 100644
--- a/drivers/video/fbdev/omap2/omapfb/dss/dss-of.c
+++ b/drivers/video/fbdev/omap2/omapfb/dss/dss-of.c
@@ -15,52 +15,6 @@
 
 #include "dss.h"
 
-struct device_node *
-omapdss_of_get_next_port(const struct device_node *parent,
-struct device_node *prev)
-{
-   struct device_node *port = NULL;
-
-   if (!parent)
-   return NULL;
-
-   if (!prev) {
-   struct device_node *ports;
-   /*
-* It's the first call, we have to find a port subnode
-* within this node or within an optional 'ports' node.
-*/
-   ports = of_get_child_by_name(parent, "ports");
-   if (ports)
-   parent = ports;
-
-   port = of_get_child_by_name(parent, "port");
-
-   /* release the 'ports' node */
-   of_node_put(ports);
-   } else {
-   struct device_node *ports;
-
-   ports = of_get_parent(prev);
-   if (!ports)
-   return NULL;
-
-   do {
-   port = of_get_next_child(ports, prev);
-   if (!port) {
-   of_node_put(ports);
-   return NULL;
-   }
-   prev = port;
-   } while (!of_node_name_eq(port, "port"));
-
-   of_node_put(ports);
-   }
-
-   return port;
-}
-EXPORT_SYMBOL_GPL(omapdss_of_get_next_port);
-
 struct device_node *
 omapdss_of_get_next_endpoint(const struct device_node *parent,
 struct device_node *prev)
@@ -122,7 +76,7 @@ omapdss_of_get_first_endpoint(const struct device_node 
*parent)
 {
struct device_node *port, *ep;
 
-   port = omapdss_of_get_next_port(parent, NULL);
+   port = of_graph_get_next_port(parent, NULL);
 
if (!port)
return NULL;
diff --git a/drivers/video/fbdev/omap2/omapfb/dss/dss.c 
b/drivers/video/fbdev/omap2/omapfb/dss/dss.c
index d814e4baa4b3..5cab317011ee 100644
--- a/drivers/video/fbdev/omap2/omapfb/dss/dss.c
+++ b/drivers/video/fbdev/omap2/omapfb/dss/dss.c
@@ -26,6 +26,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -922,7 +923,7 @@ static int dss_init_ports(struct platform_device *pdev)
if (parent == NULL)
return 0;
 
-   port = omapdss_of_get_next_port(parent, NULL);
+   port = of_graph_get_next_port(parent, NULL);
if (!port)
return 0;
 
@@ -953,7 +954,7 @@ static int dss_init_ports(struct platform_device *pdev)
break;
}
} while (!ret &&
-(port = omapdss_of_get_next_port(parent, port)) != NULL);
+(port = of_graph_get_next_port(parent, port)) != NULL);
 
if (ret)
dss_uninit_ports(pdev);
@@ -969,7 +970,7 @@ static void dss_uninit_ports(struct platform_device *pdev)
if (parent == NULL)
return;
 
-   port = omapdss_of_get_next_port(parent, NULL);
+   port = of_graph_get_next_port(parent, NULL);
if (!port)
return;
 
@@ -1000,7 +1001,7 @@ static void dss_uninit_ports(struct platform_device *pdev)
default:
break;
}
-   } while ((port = omapdss_of_get_next_port(parent, port)) != NULL);
+   } while ((port = of_graph_get_next_port(parent, port)) != NULL);
 }
 
 static int dss_video_pll_probe(struct platform_device *pdev)
diff --git a/include/video/omapfb_dss.h b/include/video/omapfb_dss.h
index e8eaac2cb7b8..426d12881132 100644
--- a/include/video/omapfb_dss.h
+++ b/include/video/omapfb_dss.h
@@ -811,10 +811,6 @@ static inline bool omapdss_device_is_enabled(struct 
omap_dss_device *dssdev)
return dssdev->state == OMAP_DSS_DISPLAY_ACTIVE;
 }
 
-struct device_node *
-omapdss_of_get_next_port(const struct device_node *parent,
-struct device_node *prev);
-
 struct device_node *
 omapdss_of_get_next_endpoint(const struct device_node *parent,
 struct device_node *prev);
-- 
2.25.1



[PATCH v3 11/24] of: remove of_graph_get_next_endpoint() define

2024-01-31 Thread Kuninori Morimoto
All driver are using new of_graph_get_next_device_endpoint(),
remove of_graph_get_next_endpoint() macro.

Signed-off-by: Kuninori Morimoto 
---
 include/linux/of_graph.h | 5 -
 1 file changed, 5 deletions(-)

diff --git a/include/linux/of_graph.h b/include/linux/of_graph.h
index 80b7a579e96a..f59ce2ea55eb 100644
--- a/include/linux/of_graph.h
+++ b/include/linux/of_graph.h
@@ -26,11 +26,6 @@ struct of_endpoint {
const struct device_node *local_node;
 };
 
-/* REMOVE ME */
-#define of_graph_get_next_endpoint(parent, previous) 
of_graph_get_next_device_endpoint(parent, previous)
-#define for_each_endpoint_of_node(parent, child) 
for_each_device_endpoint_of_node(parent, child)
-#define of_graph_get_endpoint_count(np) of_graph_get_device_endpoint_count(np)
-
 /**
  * for_each_device_endpoint_of_node - iterate over every endpoint in a device 
node
  * @parent: parent device node containing ports and endpoints
-- 
2.25.1



[PATCH v3 19/24] ASoC: audio-graph-card2: use of_graph_get_next_endpoint()

2024-01-31 Thread Kuninori Morimoto
We can now use of_graph_get_next_endpoint(), let's use it.

Signed-off-by: Kuninori Morimoto 
---
 sound/soc/generic/audio-graph-card2.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/sound/soc/generic/audio-graph-card2.c 
b/sound/soc/generic/audio-graph-card2.c
index b2bd5b70a712..70f34e920423 100644
--- a/sound/soc/generic/audio-graph-card2.c
+++ b/sound/soc/generic/audio-graph-card2.c
@@ -555,7 +555,7 @@ static int graph_parse_node_multi_nm(struct 
snd_soc_dai_link *dai_link,
if (*nm_idx > nm_max)
break;
 
-   mcpu_ep_n = of_get_next_child(mcpu_port, mcpu_ep_n);
+   mcpu_ep_n = of_graph_get_next_endpoint(mcpu_port, mcpu_ep_n);
if (!mcpu_ep_n) {
ret = 0;
break;
-- 
2.25.1



[PATCH v3 17/24] ASoC: audio-graph-card: use of_graph_get_next_endpoint()

2024-01-31 Thread Kuninori Morimoto
We can now use of_graph_get_next_endpoint(), let's use it.

Signed-off-by: Kuninori Morimoto 
---
 sound/soc/generic/audio-graph-card.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/sound/soc/generic/audio-graph-card.c 
b/sound/soc/generic/audio-graph-card.c
index 83e3ba773fbd..864f014a497c 100644
--- a/sound/soc/generic/audio-graph-card.c
+++ b/sound/soc/generic/audio-graph-card.c
@@ -344,7 +344,7 @@ static int __graph_for_each_link(struct simple_util_priv 
*priv,
 
/* loop for all CPU endpoint */
while (1) {
-   cpu_ep = of_get_next_child(cpu_port, cpu_ep);
+   cpu_ep = of_graph_get_next_endpoint(cpu_port, cpu_ep);
if (!cpu_ep)
break;
 
-- 
2.25.1



[PATCH v3 20/24] ASoC: test-component: use for_each_port_of_node()

2024-01-31 Thread Kuninori Morimoto
Current test-component.c is using for_each_endpoint_of_node() for parsing,
but it should use "port" base loop instead of "endpoint", because
properties are "port" base instead of "endpoint".

Signed-off-by: Kuninori Morimoto 
---
 sound/soc/generic/test-component.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/sound/soc/generic/test-component.c 
b/sound/soc/generic/test-component.c
index 0ebacbcddee3..a7bcd668e1f7 100644
--- a/sound/soc/generic/test-component.c
+++ b/sound/soc/generic/test-component.c
@@ -600,7 +600,7 @@ static int test_driver_probe(struct platform_device *pdev)
}
 
i = 0;
-   for_each_device_endpoint_of_node(node, ep) {
+   for_each_port_of_node(node, ep) {
snprintf(dname[i].name, TEST_NAME_LEN, "%s.%d", node->name, i);
ddriv[i].name = dname[i].name;
 
-- 
2.25.1



[PATCH v3 04/24] video: fbdev: switch to use of_graph_get_next_device_endpoint()

2024-01-31 Thread Kuninori Morimoto
of_graph_get_next_endpoint() is now renamed to
of_graph_get_next_device_endpoint(). Switch to it.

Signed-off-by: Kuninori Morimoto 
---
 drivers/video/fbdev/amba-clcd.c  | 2 +-
 drivers/video/fbdev/omap2/omapfb/dss/omapdss-boot-init.c | 2 +-
 drivers/video/fbdev/pxafb.c  | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/video/fbdev/amba-clcd.c b/drivers/video/fbdev/amba-clcd.c
index 0399db369e70..7778c4a6b294 100644
--- a/drivers/video/fbdev/amba-clcd.c
+++ b/drivers/video/fbdev/amba-clcd.c
@@ -691,7 +691,7 @@ static int clcdfb_of_init_display(struct clcd_fb *fb)
/*
 * Fetch the panel endpoint.
 */
-   endpoint = of_graph_get_next_endpoint(fb->dev->dev.of_node, NULL);
+   endpoint = of_graph_get_next_device_endpoint(fb->dev->dev.of_node, 
NULL);
if (!endpoint)
return -ENODEV;
 
diff --git a/drivers/video/fbdev/omap2/omapfb/dss/omapdss-boot-init.c 
b/drivers/video/fbdev/omap2/omapfb/dss/omapdss-boot-init.c
index 09f719af0d0c..a5da79214061 100644
--- a/drivers/video/fbdev/omap2/omapfb/dss/omapdss-boot-init.c
+++ b/drivers/video/fbdev/omap2/omapfb/dss/omapdss-boot-init.c
@@ -150,7 +150,7 @@ static void __init omapdss_walk_device(struct device_node 
*node, bool root)
of_node_put(n);
 
n = NULL;
-   while ((n = of_graph_get_next_endpoint(node, n)) != NULL) {
+   while ((n = of_graph_get_next_device_endpoint(node, n)) != NULL) {
struct device_node *pn;
 
pn = of_graph_get_remote_port_parent(n);
diff --git a/drivers/video/fbdev/pxafb.c b/drivers/video/fbdev/pxafb.c
index fa943612c4e2..0acdde8b2f45 100644
--- a/drivers/video/fbdev/pxafb.c
+++ b/drivers/video/fbdev/pxafb.c
@@ -2171,7 +2171,7 @@ static int of_get_pxafb_mode_info(struct device *dev,
u32 bus_width;
int ret, i;
 
-   np = of_graph_get_next_endpoint(dev->of_node, NULL);
+   np = of_graph_get_next_device_endpoint(dev->of_node, NULL);
if (!np) {
dev_err(dev, "could not find endpoint\n");
return -EINVAL;
-- 
2.25.1



[PATCH v3 18/24] ASoC: audio-graph-card2: use of_graph_get_next_port()

2024-01-31 Thread Kuninori Morimoto
Now we can use of_graph_get_next_port() for port parsing.
Use it on audio-graph-card2 driver.

Signed-off-by: Kuninori Morimoto 
---
 sound/soc/generic/audio-graph-card2.c | 29 ---
 1 file changed, 8 insertions(+), 21 deletions(-)

diff --git a/sound/soc/generic/audio-graph-card2.c 
b/sound/soc/generic/audio-graph-card2.c
index c3763719a69f..b2bd5b70a712 100644
--- a/sound/soc/generic/audio-graph-card2.c
+++ b/sound/soc/generic/audio-graph-card2.c
@@ -339,12 +339,7 @@ static struct device_node *graph_get_next_multi_ep(struct 
device_node **port)
 *  port@1 { rep1 };
 * };
 */
-   do {
-   *port = of_get_next_child(ports, *port);
-   if (!*port)
-   break;
-   } while (!of_node_name_eq(*port, "port"));
-
+   *port = of_graph_get_next_port(ports, *port);
if (*port) {
ep  = port_to_endpoint(*port);
rep = of_graph_get_remote_endpoint(ep);
@@ -539,7 +534,8 @@ static int graph_parse_node_multi_nm(struct 
snd_soc_dai_link *dai_link,
 */
struct device_node *mcpu_ep = port_to_endpoint(mcpu_port);
struct device_node *mcpu_ep_n   = mcpu_ep;
-   struct device_node *mcpu_port_top   = 
of_get_next_child(of_get_parent(mcpu_port), NULL);
+   struct device_node *mcpu_ports  = of_get_parent(mcpu_port);
+   struct device_node *mcpu_port_top   = 
of_graph_get_next_port(mcpu_ports, NULL);
struct device_node *mcpu_ep_top = 
port_to_endpoint(mcpu_port_top);
struct device_node *mcodec_ep_top   = 
of_graph_get_remote_endpoint(mcpu_ep_top);
struct device_node *mcodec_port_top = of_get_parent(mcodec_ep_top);
@@ -572,12 +568,12 @@ static int graph_parse_node_multi_nm(struct 
snd_soc_dai_link *dai_link,
goto mcpu_err;
 
codec_idx = 0;
-   mcodec_port_i = of_get_next_child(mcodec_ports, NULL);
+   mcodec_port_i = of_graph_get_next_port(mcodec_ports, NULL);
while (1) {
if (codec_idx > dai_link->num_codecs)
goto mcodec_err;
 
-   mcodec_port_i = of_get_next_child(mcodec_ports, 
mcodec_port_i);
+   mcodec_port_i = of_graph_get_next_port(mcodec_ports, 
mcodec_port_i);
 
if (!mcodec_port_i)
goto mcodec_err;
@@ -967,7 +963,7 @@ int audio_graph2_link_c2c(struct simple_util_priv *priv,
of_node_get(lnk);
port0 = lnk;
ports = of_get_parent(port0);
-   port1 = of_get_next_child(ports, lnk);
+   port1 = of_graph_get_next_port(ports, port0);
 
/*
 * Card2 can use original Codec2Codec settings if DT has.
@@ -1099,21 +1095,12 @@ static int graph_counter(struct device_node *lnk)
 */
if (graph_lnk_is_multi(lnk)) {
struct device_node *ports = of_get_parent(lnk);
-   struct device_node *port = NULL;
-   int cnt = 0;
 
/*
 * CPU/Codec = N:M case has many endpoints.
 * We can't use of_graph_get_device_endpoint_count() here
 */
-   while(1) {
-   port = of_get_next_child(ports, port);
-   if (!port)
-   break;
-   cnt++;
-   }
-
-   return cnt - 1;
+   return of_graph_get_port_count(ports) - 1;
}
/*
 * Single CPU / Codec
@@ -1197,7 +1184,7 @@ static int graph_count_c2c(struct simple_util_priv *priv,
 {
struct device_node *ports = of_get_parent(lnk);
struct device_node *port0 = lnk;
-   struct device_node *port1 = of_get_next_child(ports, lnk);
+   struct device_node *port1 = of_graph_get_next_port(ports, port0);
struct device_node *ep0 = port_to_endpoint(port0);
struct device_node *ep1 = port_to_endpoint(port1);
struct device_node *codec0 = of_graph_get_remote_port(ep0);
-- 
2.25.1



[PATCH v3 12/24] of: property: add port base loop

2024-01-31 Thread Kuninori Morimoto
We have endpoint base functions
- of_graph_get_next_device_endpoint()
- of_graph_get_device_endpoint_count()
- for_each_device_endpoint_of_node()

Here, for_each_device_endpoint_of_node() loop finds each endpoints

ports {
port@0 {
(1) endpoint {...};
};
port@1 {
(2) endpoint {...};
};
...
};

In above case, for_each_device_endpoint_of_node() loop finds endpoint
as (1) -> (2) -> ...

Basically, user/driver knows which port is used for what, but not in
all cases. For example on flexible/generic driver case, how many ports
are used is not fixed.

For example Sound Generic Card driver which is used from many venders
can't know how many ports are used. Because the driver is very
flexible/generic, it is impossible to know how many ports are used,
it depends on each vender SoC and/or its used board.

And more, the port can have multi endpoints. For example Generic Sound
Card case, it supports many type of connection between CPU / Codec, and
some of them uses multi endpoint in one port.
Then, Generic Sound Card want to handle each connection via "port"
instead of "endpoint".
But, it is very difficult to handle each "port" by
for_each_device_endpoint_of_node(). Getting "port" by
using of_get_parent() from "endpoint" doesn't work. see below.

ports {
port@0 {
(1) endpoint@0 {...};
(2) endpoint@1 {...};
};
port@1 {
(3) endpoint {...};
};
...
    };

Add "port" base functions.

Signed-off-by: Kuninori Morimoto 
---
 drivers/of/property.c| 56 
 include/linux/of_graph.h | 26 +++
 2 files changed, 82 insertions(+)

diff --git a/drivers/of/property.c b/drivers/of/property.c
index 007729d66972..cba07d2af62b 100644
--- a/drivers/of/property.c
+++ b/drivers/of/property.c
@@ -631,6 +631,44 @@ struct device_node *of_graph_get_port_by_id(struct 
device_node *parent, u32 id)
 }
 EXPORT_SYMBOL(of_graph_get_port_by_id);
 
+/**
+ * of_graph_get_next_port() - get next port node.
+ * @parent: pointer to the parent device node
+ * @port: current port node, or NULL to get first
+ *
+ * Return: A 'port' node pointer with refcount incremented. Refcount
+ * of the passed @prev node is decremented.
+ */
+struct device_node *of_graph_get_next_port(const struct device_node *parent,
+  struct device_node *port)
+{
+   if (!parent)
+   return NULL;
+
+   if (!port) {
+   struct device_node *node;
+   struct device_node *port;
+
+   node = of_get_child_by_name(parent, "ports");
+   if (node)
+   parent = node;
+
+   port = of_get_child_by_name(parent, "port");
+   of_node_put(node);
+
+   return port;
+   }
+
+   do {
+   port = of_get_next_child(parent, port);
+   if (!port)
+   break;
+   } while (!of_node_name_eq(port, "port"));
+
+   return port;
+}
+EXPORT_SYMBOL(of_graph_get_next_port);
+
 /**
  * of_graph_get_next_device_endpoint() - get next endpoint node. If it reached 
to end of the port,
  * it gets next endpoint from next port.
@@ -831,6 +869,24 @@ unsigned int of_graph_get_device_endpoint_count(const 
struct device_node *np)
 }
 EXPORT_SYMBOL(of_graph_get_device_endpoint_count);
 
+/**
+ * of_graph_get_port_count() - get count of port
+ * @np: pointer to the parent device node
+ *
+ * Return: count of port of this device node
+ */
+unsigned int of_graph_get_port_count(const struct device_node *np)
+{
+   struct device_node *port;
+   int num = 0;
+
+   for_each_port_of_node(np, port)
+   num++;
+
+   return num;
+}
+EXPORT_SYMBOL(of_graph_get_port_count);
+
 /**
  * of_graph_get_remote_node() - get remote parent device_node for given 
port/endpoint
  * @node: pointer to parent device_node containing graph port/endpoint
diff --git a/include/linux/of_graph.h b/include/linux/of_graph.h
index f59ce2ea55eb..48f7701feab1 100644
--- a/include/linux/of_graph.h
+++ b/include/linux/of_graph.h
@@ -37,14 +37,28 @@ struct of_endpoint {
for (child = of_graph_get_next_device_endpoint(parent, NULL); child != 
NULL; \
 child = of_graph_get_next_device_endpoint(parent, child))
 
+/**
+ * for_each_port_of_node - iterate over every port in a device node
+ * @parent: parent device node containing ports/port
+ * @child: loop variable pointing to the current port node
+ *
+ * When breaking out of the loop, of_node_put(child) has to be called manually.
+ */
+#define for_each_port_of_node(parent, child)   

[PATCH v3 06/24] media: platform: switch to use of_graph_get_next_device_endpoint()

2024-01-31 Thread Kuninori Morimoto
of_graph_get_next_endpoint() is now renamed to
of_graph_get_next_device_endpoint(). Switch to it.

Signed-off-by: Kuninori Morimoto 
---
 drivers/media/platform/atmel/atmel-isi.c | 4 ++--
 drivers/media/platform/intel/pxa_camera.c| 2 +-
 drivers/media/platform/microchip/microchip-sama5d2-isc.c | 2 +-
 drivers/media/platform/microchip/microchip-sama7g5-isc.c | 2 +-
 drivers/media/platform/qcom/camss/camss.c| 2 +-
 drivers/media/platform/renesas/renesas-ceu.c | 2 +-
 drivers/media/platform/samsung/exynos4-is/fimc-is.c  | 2 +-
 drivers/media/platform/samsung/exynos4-is/mipi-csis.c| 2 +-
 drivers/media/platform/st/stm32/stm32-dcmi.c | 4 ++--
 drivers/media/platform/ti/am437x/am437x-vpfe.c   | 2 +-
 drivers/media/platform/ti/davinci/vpif.c | 3 +--
 drivers/media/platform/ti/davinci/vpif_capture.c | 3 +--
 drivers/media/platform/video-mux.c   | 2 +-
 drivers/media/platform/xilinx/xilinx-vipp.c  | 2 +-
 14 files changed, 16 insertions(+), 18 deletions(-)

diff --git a/drivers/media/platform/atmel/atmel-isi.c 
b/drivers/media/platform/atmel/atmel-isi.c
index 4046212d48b4..4317750d05ad 100644
--- a/drivers/media/platform/atmel/atmel-isi.c
+++ b/drivers/media/platform/atmel/atmel-isi.c
@@ -831,7 +831,7 @@ static int atmel_isi_parse_dt(struct atmel_isi *isi,
isi->pdata.full_mode = 1;
isi->pdata.frate = ISI_CFG1_FRATE_CAPTURE_ALL;
 
-   np = of_graph_get_next_endpoint(np, NULL);
+   np = of_graph_get_next_device_endpoint(np, NULL);
if (!np) {
dev_err(>dev, "Could not find the endpoint\n");
return -EINVAL;
@@ -1155,7 +1155,7 @@ static int isi_graph_init(struct atmel_isi *isi)
struct device_node *ep;
int ret;
 
-   ep = of_graph_get_next_endpoint(isi->dev->of_node, NULL);
+   ep = of_graph_get_next_device_endpoint(isi->dev->of_node, NULL);
if (!ep)
return -EINVAL;
 
diff --git a/drivers/media/platform/intel/pxa_camera.c 
b/drivers/media/platform/intel/pxa_camera.c
index 59b89e421dc2..f2175c03502b 100644
--- a/drivers/media/platform/intel/pxa_camera.c
+++ b/drivers/media/platform/intel/pxa_camera.c
@@ -2207,7 +2207,7 @@ static int pxa_camera_pdata_from_dt(struct device *dev,
pcdev->mclk = mclk_rate;
}
 
-   np = of_graph_get_next_endpoint(np, NULL);
+   np = of_graph_get_next_device_endpoint(np, NULL);
if (!np) {
dev_err(dev, "could not find endpoint\n");
return -EINVAL;
diff --git a/drivers/media/platform/microchip/microchip-sama5d2-isc.c 
b/drivers/media/platform/microchip/microchip-sama5d2-isc.c
index 5ac149cf3647..201049c047b0 100644
--- a/drivers/media/platform/microchip/microchip-sama5d2-isc.c
+++ b/drivers/media/platform/microchip/microchip-sama5d2-isc.c
@@ -363,7 +363,7 @@ static int isc_parse_dt(struct device *dev, struct 
isc_device *isc)
while (1) {
struct v4l2_fwnode_endpoint v4l2_epn = { .bus_type = 0 };
 
-   epn = of_graph_get_next_endpoint(np, epn);
+   epn = of_graph_get_next_device_endpoint(np, epn);
if (!epn)
return 0;
 
diff --git a/drivers/media/platform/microchip/microchip-sama7g5-isc.c 
b/drivers/media/platform/microchip/microchip-sama7g5-isc.c
index 73445f33d26b..b617a9bcd398 100644
--- a/drivers/media/platform/microchip/microchip-sama7g5-isc.c
+++ b/drivers/media/platform/microchip/microchip-sama7g5-isc.c
@@ -349,7 +349,7 @@ static int xisc_parse_dt(struct device *dev, struct 
isc_device *isc)
while (1) {
struct v4l2_fwnode_endpoint v4l2_epn = { .bus_type = 0 };
 
-   epn = of_graph_get_next_endpoint(np, epn);
+   epn = of_graph_get_next_device_endpoint(np, epn);
if (!epn)
return 0;
 
diff --git a/drivers/media/platform/qcom/camss/camss.c 
b/drivers/media/platform/qcom/camss/camss.c
index 8e78dd8d5961..cbb6f88cfe4a 100644
--- a/drivers/media/platform/qcom/camss/camss.c
+++ b/drivers/media/platform/qcom/camss/camss.c
@@ -1136,7 +1136,7 @@ static int camss_of_parse_ports(struct camss *camss)
struct device_node *remote = NULL;
int ret, num_subdevs = 0;
 
-   for_each_endpoint_of_node(dev->of_node, node) {
+   for_each_device_endpoint_of_node(dev->of_node, node) {
struct camss_async_subdev *csd;
 
if (!of_device_is_available(node))
diff --git a/drivers/media/platform/renesas/renesas-ceu.c 
b/drivers/media/platform/renesas/renesas-ceu.c
index 2562b30acfb9..929d17de4ac9 100644
--- a/drivers/media/platform/renesas/renesas-ceu.c
+++ b/drivers/media/platform/renesas/renesas-ceu.c
@@ -1526,7 +1526,7 @@ static int ceu_parse_dt(struct ceu_device *ceudev)
int num_ep;
int ret;
 
-   num_ep

[PATCH v3 13/24] of: property: use of_graph_get_next_port() on of_graph_get_next_endpoint()

2024-01-31 Thread Kuninori Morimoto
We have of_graph_get_next_port(), use it on of_graph_get_next_endpoint().

Signed-off-by: Kuninori Morimoto 
Reviewed-by: Tomi Valkeinen 
---
 drivers/of/property.c | 18 --
 1 file changed, 4 insertions(+), 14 deletions(-)

diff --git a/drivers/of/property.c b/drivers/of/property.c
index cba07d2af62b..083f92513f5e 100644
--- a/drivers/of/property.c
+++ b/drivers/of/property.c
@@ -694,15 +694,7 @@ struct device_node 
*of_graph_get_next_device_endpoint(const struct device_node *
 * parent port node.
 */
if (!prev) {
-   struct device_node *node;
-
-   node = of_get_child_by_name(parent, "ports");
-   if (node)
-   parent = node;
-
-   port = of_get_child_by_name(parent, "port");
-   of_node_put(node);
-
+   port = of_graph_get_next_port(parent, NULL);
if (!port) {
pr_err("graph: no port node found in %pOF\n", parent);
return NULL;
@@ -729,11 +721,9 @@ struct device_node 
*of_graph_get_next_device_endpoint(const struct device_node *
/* No more endpoints under this port, try the next one. */
prev = NULL;
 
-   do {
-   port = of_get_next_child(parent, port);
-   if (!port)
-   return NULL;
-   } while (!of_node_name_eq(port, "port"));
+   port = of_graph_get_next_port(parent, port);
+   if (!port)
+   return NULL;
}
 }
 EXPORT_SYMBOL(of_graph_get_next_device_endpoint);
-- 
2.25.1



[PATCH v3 15/24] drm: omapdrm: use of_graph_get_next_endpoint()

2024-01-31 Thread Kuninori Morimoto
We can now use of_graph_get_next_endpoint(), let's use it.

Signed-off-by: Kuninori Morimoto 
---
 drivers/gpu/drm/omapdrm/dss/dpi.c | 2 +-
 drivers/gpu/drm/omapdrm/dss/sdi.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/dss/dpi.c 
b/drivers/gpu/drm/omapdrm/dss/dpi.c
index 030f997eccd0..74d240aa35a6 100644
--- a/drivers/gpu/drm/omapdrm/dss/dpi.c
+++ b/drivers/gpu/drm/omapdrm/dss/dpi.c
@@ -709,7 +709,7 @@ int dpi_init_port(struct dss_device *dss, struct 
platform_device *pdev,
if (!dpi)
return -ENOMEM;
 
-   ep = of_get_next_child(port, NULL);
+   ep = of_graph_get_next_endpoint(port, NULL);
if (!ep)
return 0;
 
diff --git a/drivers/gpu/drm/omapdrm/dss/sdi.c 
b/drivers/gpu/drm/omapdrm/dss/sdi.c
index 91eaae3b9481..6155e99e64f6 100644
--- a/drivers/gpu/drm/omapdrm/dss/sdi.c
+++ b/drivers/gpu/drm/omapdrm/dss/sdi.c
@@ -346,7 +346,7 @@ int sdi_init_port(struct dss_device *dss, struct 
platform_device *pdev,
if (!sdi)
return -ENOMEM;
 
-   ep = of_get_next_child(port, NULL);
+   ep = of_graph_get_next_endpoint(port, NULL);
if (!ep) {
r = 0;
goto err_free;
-- 
2.25.1



[PATCH v3 10/24] ASoC: switch to use of_graph_get_next_device_endpoint()

2024-01-31 Thread Kuninori Morimoto
of_graph_get_next_endpoint() is now renamed to
of_graph_get_next_device_endpoint(). Switch to it.

Signed-off-by: Kuninori Morimoto 
---
 sound/soc/codecs/ak4613.c | 2 +-
 sound/soc/generic/audio-graph-card2.c | 2 +-
 sound/soc/generic/simple-card-utils.c | 6 +++---
 sound/soc/generic/test-component.c| 4 ++--
 sound/soc/sh/rcar/core.c  | 4 ++--
 5 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/sound/soc/codecs/ak4613.c b/sound/soc/codecs/ak4613.c
index 73fb35560e51..1e1d9c7abdc7 100644
--- a/sound/soc/codecs/ak4613.c
+++ b/sound/soc/codecs/ak4613.c
@@ -870,7 +870,7 @@ static void ak4613_parse_of(struct ak4613_priv *priv,
 * TDM support is assuming it is probed via Audio-Graph-Card style here.
 * Default is SDTIx1 if it was probed via Simple-Audio-Card for now.
 */
-   sdti_num = of_graph_get_endpoint_count(np);
+   sdti_num = of_graph_get_device_endpoint_count(np);
if ((sdti_num >= SDTx_MAX) || (sdti_num < 1))
sdti_num = 1;
 
diff --git a/sound/soc/generic/audio-graph-card2.c 
b/sound/soc/generic/audio-graph-card2.c
index 62606e20be9a..c3763719a69f 100644
--- a/sound/soc/generic/audio-graph-card2.c
+++ b/sound/soc/generic/audio-graph-card2.c
@@ -1104,7 +1104,7 @@ static int graph_counter(struct device_node *lnk)
 
/*
 * CPU/Codec = N:M case has many endpoints.
-* We can't use of_graph_get_endpoint_count() here
+* We can't use of_graph_get_device_endpoint_count() here
 */
while(1) {
port = of_get_next_child(ports, port);
diff --git a/sound/soc/generic/simple-card-utils.c 
b/sound/soc/generic/simple-card-utils.c
index 81077d16d22f..2c89b711b1ea 100644
--- a/sound/soc/generic/simple-card-utils.c
+++ b/sound/soc/generic/simple-card-utils.c
@@ -1049,7 +1049,7 @@ static int graph_get_dai_id(struct device_node *ep)
 */
i = 0;
id = -1;
-   for_each_endpoint_of_node(node, endpoint) {
+   for_each_device_endpoint_of_node(node, endpoint) {
if (endpoint == ep)
id = i;
i++;
@@ -1093,7 +1093,7 @@ int graph_util_parse_dai(struct device *dev, struct 
device_node *ep,
/* Get dai->name */
args.np = node;
args.args[0]= graph_get_dai_id(ep);
-   args.args_count = (of_graph_get_endpoint_count(node) > 1);
+   args.args_count = (of_graph_get_device_endpoint_count(node) > 1);
 
/*
 * FIXME
@@ -1122,7 +1122,7 @@ int graph_util_parse_dai(struct device *dev, struct 
device_node *ep,
 
 parse_dai_end:
if (is_single_link)
-   *is_single_link = of_graph_get_endpoint_count(node) == 1;
+   *is_single_link = of_graph_get_device_endpoint_count(node) == 1;
 
return 0;
 }
diff --git a/sound/soc/generic/test-component.c 
b/sound/soc/generic/test-component.c
index e4967540a2e1..0ebacbcddee3 100644
--- a/sound/soc/generic/test-component.c
+++ b/sound/soc/generic/test-component.c
@@ -538,7 +538,7 @@ static int test_driver_probe(struct platform_device *pdev)
struct test_priv *priv;
int num, ret, i;
 
-   num = of_graph_get_endpoint_count(node);
+   num = of_graph_get_device_endpoint_count(node);
if (!num) {
dev_err(dev, "no port exits\n");
return -EINVAL;
@@ -600,7 +600,7 @@ static int test_driver_probe(struct platform_device *pdev)
}
 
i = 0;
-   for_each_endpoint_of_node(node, ep) {
+   for_each_device_endpoint_of_node(node, ep) {
snprintf(dname[i].name, TEST_NAME_LEN, "%s.%d", node->name, i);
ddriv[i].name = dname[i].name;
 
diff --git a/sound/soc/sh/rcar/core.c b/sound/soc/sh/rcar/core.c
index 0b1aa23c1189..d0581232063a 100644
--- a/sound/soc/sh/rcar/core.c
+++ b/sound/soc/sh/rcar/core.c
@@ -1298,7 +1298,7 @@ static int rsnd_dai_of_node(struct rsnd_priv *priv, int 
*is_graph)
if (!of_node_name_eq(ports, "ports") &&
!of_node_name_eq(ports, "port"))
continue;
-   priv->component_dais[i] = of_graph_get_endpoint_count(ports);
+   priv->component_dais[i] = 
of_graph_get_device_endpoint_count(ports);
nr += priv->component_dais[i];
i++;
if (i >= RSND_MAX_COMPONENT) {
@@ -1510,7 +1510,7 @@ static int rsnd_dai_probe(struct rsnd_priv *priv)
if (!of_node_name_eq(ports, "ports") &&
!of_node_name_eq(ports, "port"))
continue;
-   for_each_endpoint_of_node(ports, dai_np) {
+   for_each_device_endpoint_of_node(ports, dai_np) {
__rsnd_dai_probe(pri

[PATCH v3 21/24] fbdev: omapfb: use of_graph_get_remote_port()

2024-01-31 Thread Kuninori Morimoto
We already have of_graph_get_remote_port(), Let's use it.

Signed-off-by: Kuninori Morimoto 
---
 drivers/video/fbdev/omap2/omapfb/dss/dss-of.c | 15 +--
 1 file changed, 1 insertion(+), 14 deletions(-)

diff --git a/drivers/video/fbdev/omap2/omapfb/dss/dss-of.c 
b/drivers/video/fbdev/omap2/omapfb/dss/dss-of.c
index 0282d4eef139..fe6c72d03216 100644
--- a/drivers/video/fbdev/omap2/omapfb/dss/dss-of.c
+++ b/drivers/video/fbdev/omap2/omapfb/dss/dss-of.c
@@ -117,19 +117,6 @@ u32 dss_of_port_get_port_number(struct device_node *port)
return reg;
 }
 
-static struct device_node *omapdss_of_get_remote_port(const struct device_node 
*node)
-{
-   struct device_node *np;
-
-   np = of_graph_get_remote_endpoint(node);
-   if (!np)
-   return NULL;
-
-   np = of_get_next_parent(np);
-
-   return np;
-}
-
 struct device_node *
 omapdss_of_get_first_endpoint(const struct device_node *parent)
 {
@@ -159,7 +146,7 @@ omapdss_of_find_source_for_first_ep(struct device_node 
*node)
if (!ep)
return ERR_PTR(-EINVAL);
 
-   src_port = omapdss_of_get_remote_port(ep);
+   src_port = of_graph_get_remote_port(ep);
if (!src_port) {
of_node_put(ep);
return ERR_PTR(-EINVAL);
-- 
2.25.1



[PATCH v3 07/24] gpu: drm: switch to use of_graph_get_next_device_endpoint()

2024-01-31 Thread Kuninori Morimoto
of_graph_get_next_endpoint() is now renamed to
of_graph_get_next_device_endpoint(). Switch to it.

Signed-off-by: Kuninori Morimoto 
---
 drivers/gpu/drm/armada/armada_drv.c   | 2 +-
 drivers/gpu/drm/bridge/tc358767.c | 2 +-
 drivers/gpu/drm/drm_of.c  | 6 +++---
 drivers/gpu/drm/meson/meson_drv.c | 4 ++--
 drivers/gpu/drm/msm/msm_drv.c | 2 +-
 drivers/gpu/drm/mxsfb/lcdif_drv.c | 2 +-
 drivers/gpu/drm/omapdrm/dss/base.c| 2 +-
 drivers/gpu/drm/panel/panel-raspberrypi-touchscreen.c | 2 +-
 drivers/gpu/drm/pl111/pl111_drv.c | 2 +-
 drivers/gpu/drm/renesas/rcar-du/rcar_du_kms.c | 2 +-
 drivers/gpu/drm/stm/ltdc.c| 4 ++--
 drivers/gpu/drm/tiny/arcpgu.c | 2 +-
 12 files changed, 16 insertions(+), 16 deletions(-)

diff --git a/drivers/gpu/drm/armada/armada_drv.c 
b/drivers/gpu/drm/armada/armada_drv.c
index fa1c67598706..575c61c6711f 100644
--- a/drivers/gpu/drm/armada/armada_drv.c
+++ b/drivers/gpu/drm/armada/armada_drv.c
@@ -175,7 +175,7 @@ static void armada_add_endpoints(struct device *dev,
 {
struct device_node *ep, *remote;
 
-   for_each_endpoint_of_node(dev_node, ep) {
+   for_each_device_endpoint_of_node(dev_node, ep) {
remote = of_graph_get_remote_port_parent(ep);
if (remote && of_device_is_available(remote))
drm_of_component_match_add(dev, match, 
component_compare_of,
diff --git a/drivers/gpu/drm/bridge/tc358767.c 
b/drivers/gpu/drm/bridge/tc358767.c
index ef2e373606ba..845d60943c52 100644
--- a/drivers/gpu/drm/bridge/tc358767.c
+++ b/drivers/gpu/drm/bridge/tc358767.c
@@ -2190,7 +2190,7 @@ static int tc_probe_bridge_endpoint(struct tc_data *tc)
 * DSI -> port@0 -> port@1 -> DPI :: [port@2 is not connected]
 */
 
-   for_each_endpoint_of_node(dev->of_node, node) {
+   for_each_device_endpoint_of_node(dev->of_node, node) {
of_graph_parse_endpoint(node, );
if (endpoint.port > 2) {
of_node_put(node);
diff --git a/drivers/gpu/drm/drm_of.c b/drivers/gpu/drm/drm_of.c
index 177b600895d3..b322cc922aa1 100644
--- a/drivers/gpu/drm/drm_of.c
+++ b/drivers/gpu/drm/drm_of.c
@@ -63,7 +63,7 @@ uint32_t drm_of_find_possible_crtcs(struct drm_device *dev,
struct device_node *remote_port, *ep;
uint32_t possible_crtcs = 0;
 
-   for_each_endpoint_of_node(port, ep) {
+   for_each_device_endpoint_of_node(port, ep) {
remote_port = of_graph_get_remote_port(ep);
if (!remote_port) {
of_node_put(ep);
@@ -203,7 +203,7 @@ int drm_of_encoder_active_endpoint(struct device_node *node,
if (!node || !crtc)
return -EINVAL;
 
-   for_each_endpoint_of_node(node, ep) {
+   for_each_device_endpoint_of_node(node, ep) {
port = of_graph_get_remote_port(ep);
of_node_put(port);
if (port == crtc->port) {
@@ -516,7 +516,7 @@ struct mipi_dsi_host *drm_of_get_dsi_bus(struct device *dev)
/*
 * Get first endpoint child from device.
 */
-   endpoint = of_graph_get_next_endpoint(dev->of_node, NULL);
+   endpoint = of_graph_get_next_device_endpoint(dev->of_node, NULL);
if (!endpoint)
return ERR_PTR(-ENODEV);
 
diff --git a/drivers/gpu/drm/meson/meson_drv.c 
b/drivers/gpu/drm/meson/meson_drv.c
index cb674966e9ac..338a7b90d1c3 100644
--- a/drivers/gpu/drm/meson/meson_drv.c
+++ b/drivers/gpu/drm/meson/meson_drv.c
@@ -113,7 +113,7 @@ static bool meson_vpu_has_available_connectors(struct 
device *dev)
struct device_node *ep, *remote;
 
/* Parses each endpoint and check if remote exists */
-   for_each_endpoint_of_node(dev->of_node, ep) {
+   for_each_device_endpoint_of_node(dev->of_node, ep) {
/* If the endpoint node exists, consider it enabled */
remote = of_graph_get_remote_port(ep);
if (remote) {
@@ -481,7 +481,7 @@ static int meson_drv_probe(struct platform_device *pdev)
struct device_node *ep, *remote;
int count = 0;
 
-   for_each_endpoint_of_node(np, ep) {
+   for_each_device_endpoint_of_node(np, ep) {
remote = of_graph_get_remote_port_parent(ep);
if (!remote || !of_device_is_available(remote)) {
of_node_put(remote);
diff --git a/drivers/gpu/drm/msm/msm_drv.c b/drivers/gpu/drm/msm/msm_drv.c
index 3f217b578293..43e3f22c5520 100644
--- a/drivers/gpu/drm/msm/msm_drv.c
+++ b/drivers/gpu/drm/msm/msm_drv.c
@@ -840,7 +840,7 @@ static int add_components_mdp(struct device *master_dev,
struct device_node *np = master_dev->of_node;
struct device_node *ep_node;
 
-

[PATCH v3 05/24] media: i2c: switch to use of_graph_get_next_device_endpoint()

2024-01-31 Thread Kuninori Morimoto
of_graph_get_next_endpoint() is now renamed to
of_graph_get_next_device_endpoint(). Switch to it.

Signed-off-by: Kuninori Morimoto 
---
 drivers/media/i2c/adv7343.c  | 2 +-
 drivers/media/i2c/adv748x/adv748x-core.c | 2 +-
 drivers/media/i2c/adv7604.c  | 2 +-
 drivers/media/i2c/isl7998x.c | 2 +-
 drivers/media/i2c/max9286.c  | 2 +-
 drivers/media/i2c/mt9p031.c  | 2 +-
 drivers/media/i2c/mt9v032.c  | 2 +-
 drivers/media/i2c/ov2659.c   | 2 +-
 drivers/media/i2c/ov5645.c   | 2 +-
 drivers/media/i2c/ov5647.c   | 2 +-
 drivers/media/i2c/s5c73m3/s5c73m3-core.c | 2 +-
 drivers/media/i2c/s5k5baf.c  | 2 +-
 drivers/media/i2c/tc358743.c | 2 +-
 drivers/media/i2c/tda1997x.c | 2 +-
 drivers/media/i2c/tvp514x.c  | 2 +-
 drivers/media/i2c/tvp5150.c  | 4 ++--
 drivers/media/i2c/tvp7002.c  | 2 +-
 17 files changed, 18 insertions(+), 18 deletions(-)

diff --git a/drivers/media/i2c/adv7343.c b/drivers/media/i2c/adv7343.c
index ff21cd4744d3..7e4eb2f8bf0d 100644
--- a/drivers/media/i2c/adv7343.c
+++ b/drivers/media/i2c/adv7343.c
@@ -403,7 +403,7 @@ adv7343_get_pdata(struct i2c_client *client)
if (!IS_ENABLED(CONFIG_OF) || !client->dev.of_node)
return client->dev.platform_data;
 
-   np = of_graph_get_next_endpoint(client->dev.of_node, NULL);
+   np = of_graph_get_next_device_endpoint(client->dev.of_node, NULL);
if (!np)
return NULL;
 
diff --git a/drivers/media/i2c/adv748x/adv748x-core.c 
b/drivers/media/i2c/adv748x/adv748x-core.c
index 3eb6d5e8f082..4e9e4cef8954 100644
--- a/drivers/media/i2c/adv748x/adv748x-core.c
+++ b/drivers/media/i2c/adv748x/adv748x-core.c
@@ -657,7 +657,7 @@ static int adv748x_parse_dt(struct adv748x_state *state)
bool in_found = false;
int ret;
 
-   for_each_endpoint_of_node(state->dev->of_node, ep_np) {
+   for_each_device_endpoint_of_node(state->dev->of_node, ep_np) {
of_graph_parse_endpoint(ep_np, );
adv_info(state, "Endpoint %pOF on port %d", ep.local_node,
 ep.port);
diff --git a/drivers/media/i2c/adv7604.c b/drivers/media/i2c/adv7604.c
index b202a85fbeaa..5b98a688b5de 100644
--- a/drivers/media/i2c/adv7604.c
+++ b/drivers/media/i2c/adv7604.c
@@ -3205,7 +3205,7 @@ static int adv76xx_parse_dt(struct adv76xx_state *state)
np = state->i2c_clients[ADV76XX_PAGE_IO]->dev.of_node;
 
/* Parse the endpoint. */
-   endpoint = of_graph_get_next_endpoint(np, NULL);
+   endpoint = of_graph_get_next_device_endpoint(np, NULL);
if (!endpoint)
return -EINVAL;
 
diff --git a/drivers/media/i2c/isl7998x.c b/drivers/media/i2c/isl7998x.c
index 73460688c356..1ef26dd8290c 100644
--- a/drivers/media/i2c/isl7998x.c
+++ b/drivers/media/i2c/isl7998x.c
@@ -580,7 +580,7 @@ static int isl7998x_get_nr_inputs(struct device_node 
*of_node)
unsigned int inputs = 0;
unsigned int i;
 
-   if (of_graph_get_endpoint_count(of_node) > ISL7998X_NUM_PADS)
+   if (of_graph_get_device_endpoint_count(of_node) > ISL7998X_NUM_PADS)
return -EINVAL;
 
/*
diff --git a/drivers/media/i2c/max9286.c b/drivers/media/i2c/max9286.c
index fc1cf196ef01..7d0725285a24 100644
--- a/drivers/media/i2c/max9286.c
+++ b/drivers/media/i2c/max9286.c
@@ -1452,7 +1452,7 @@ static int max9286_parse_dt(struct max9286_priv *priv)
of_node_put(i2c_mux);
 
/* Parse the endpoints */
-   for_each_endpoint_of_node(dev->of_node, node) {
+   for_each_device_endpoint_of_node(dev->of_node, node) {
struct max9286_source *source;
struct of_endpoint ep;
 
diff --git a/drivers/media/i2c/mt9p031.c b/drivers/media/i2c/mt9p031.c
index 348f1e1098fb..4832968ca50b 100644
--- a/drivers/media/i2c/mt9p031.c
+++ b/drivers/media/i2c/mt9p031.c
@@ -1080,7 +1080,7 @@ mt9p031_get_pdata(struct i2c_client *client)
if (!IS_ENABLED(CONFIG_OF) || !client->dev.of_node)
return client->dev.platform_data;
 
-   np = of_graph_get_next_endpoint(client->dev.of_node, NULL);
+   np = of_graph_get_next_device_endpoint(client->dev.of_node, NULL);
if (!np)
return NULL;
 
diff --git a/drivers/media/i2c/mt9v032.c b/drivers/media/i2c/mt9v032.c
index 1c6f6cea1204..236a671857a1 100644
--- a/drivers/media/i2c/mt9v032.c
+++ b/drivers/media/i2c/mt9v032.c
@@ -1008,7 +1008,7 @@ mt9v032_get_pdata(struct i2c_client *client)
if (!IS_ENABLED(CONFIG_OF) || !client->dev.of_node)
return client->dev.platform_data;
 
-   np = of_graph_get_next_endpoint(client->dev.of_node, NULL);
+   np = of_graph_get_next_device_endpoint(client->dev.of_node, NULL);
if (!np)
return NULL;
 
diff --git 

[PATCH v3 09/24] staging: switch to use of_graph_get_next_device_endpoint()

2024-01-31 Thread Kuninori Morimoto
of_graph_get_next_endpoint() is now renamed to
of_graph_get_next_device_endpoint(). Switch to it.

Signed-off-by: Kuninori Morimoto 
---
 drivers/staging/media/deprecated/atmel/atmel-sama5d2-isc.c | 2 +-
 drivers/staging/media/deprecated/atmel/atmel-sama7g5-isc.c | 2 +-
 drivers/staging/media/tegra-video/csi.c| 2 +-
 drivers/staging/media/tegra-video/vi.c | 2 +-
 drivers/staging/media/tegra-video/vip.c| 2 +-
 5 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/staging/media/deprecated/atmel/atmel-sama5d2-isc.c 
b/drivers/staging/media/deprecated/atmel/atmel-sama5d2-isc.c
index 31b2b48085c5..bed11223e4be 100644
--- a/drivers/staging/media/deprecated/atmel/atmel-sama5d2-isc.c
+++ b/drivers/staging/media/deprecated/atmel/atmel-sama5d2-isc.c
@@ -343,7 +343,7 @@ static int isc_parse_dt(struct device *dev, struct 
isc_device *isc)
while (1) {
struct v4l2_fwnode_endpoint v4l2_epn = { .bus_type = 0 };
 
-   epn = of_graph_get_next_endpoint(np, epn);
+   epn = of_graph_get_next_device_endpoint(np, epn);
if (!epn)
return 0;
 
diff --git a/drivers/staging/media/deprecated/atmel/atmel-sama7g5-isc.c 
b/drivers/staging/media/deprecated/atmel/atmel-sama7g5-isc.c
index 020034f631f5..e0dcec334ae2 100644
--- a/drivers/staging/media/deprecated/atmel/atmel-sama7g5-isc.c
+++ b/drivers/staging/media/deprecated/atmel/atmel-sama7g5-isc.c
@@ -329,7 +329,7 @@ static int xisc_parse_dt(struct device *dev, struct 
isc_device *isc)
while (1) {
struct v4l2_fwnode_endpoint v4l2_epn = { .bus_type = 0 };
 
-   epn = of_graph_get_next_endpoint(np, epn);
+   epn = of_graph_get_next_device_endpoint(np, epn);
if (!epn)
return 0;
 
diff --git a/drivers/staging/media/tegra-video/csi.c 
b/drivers/staging/media/tegra-video/csi.c
index 9aa72863c213..2135dca9725e 100644
--- a/drivers/staging/media/tegra-video/csi.c
+++ b/drivers/staging/media/tegra-video/csi.c
@@ -571,7 +571,7 @@ static int tegra_csi_channels_alloc(struct tegra_csi *csi)
goto err_node_put;
}
 
-   num_pads = of_graph_get_endpoint_count(channel);
+   num_pads = of_graph_get_device_endpoint_count(channel);
if (num_pads == TEGRA_CSI_PADS_NUM) {
ret = tegra_csi_channel_alloc(csi, channel, portno,
  lanes, num_pads);
diff --git a/drivers/staging/media/tegra-video/vi.c 
b/drivers/staging/media/tegra-video/vi.c
index 94171e62dee9..de63721495ef 100644
--- a/drivers/staging/media/tegra-video/vi.c
+++ b/drivers/staging/media/tegra-video/vi.c
@@ -1704,7 +1704,7 @@ static int tegra_vi_graph_parse_one(struct 
tegra_vi_channel *chan,
dev_dbg(vi->dev, "parsing node %pOF\n", to_of_node(fwnode));
 
/* parse all the remote entities and put them into the list */
-   for_each_endpoint_of_node(to_of_node(fwnode), node) {
+   for_each_device_endpoint_of_node(to_of_node(fwnode), node) {
ep = of_fwnode_handle(node);
remote = fwnode_graph_get_remote_port_parent(ep);
if (!remote) {
diff --git a/drivers/staging/media/tegra-video/vip.c 
b/drivers/staging/media/tegra-video/vip.c
index e95cc7bb190e..78b3cdf7ee29 100644
--- a/drivers/staging/media/tegra-video/vip.c
+++ b/drivers/staging/media/tegra-video/vip.c
@@ -137,7 +137,7 @@ static int tegra_vip_channel_of_parse(struct tegra_vip *vip)
goto err_node_put;
}
 
-   num_pads = of_graph_get_endpoint_count(np);
+   num_pads = of_graph_get_device_endpoint_count(np);
if (num_pads != TEGRA_VIP_PADS_NUM) {
err = -EINVAL;
dev_err_probe(dev, err, "%pOF: need 2 pads, got %d\n", np, 
num_pads);
-- 
2.25.1



[PATCH v3 23/24] fbdev: omapfb: use of_graph_get_next_endpoint()

2024-01-31 Thread Kuninori Morimoto
We can now use of_graph_get_next_endpoint(), let's use it.

Signed-off-by: Kuninori Morimoto 
---
 drivers/video/fbdev/omap2/omapfb/dss/dpi.c|  3 ++-
 drivers/video/fbdev/omap2/omapfb/dss/dss-of.c | 22 +--
 drivers/video/fbdev/omap2/omapfb/dss/sdi.c|  3 ++-
 include/video/omapfb_dss.h|  4 
 4 files changed, 5 insertions(+), 27 deletions(-)

diff --git a/drivers/video/fbdev/omap2/omapfb/dss/dpi.c 
b/drivers/video/fbdev/omap2/omapfb/dss/dpi.c
index 7c1b7d89389a..d018ee755cf4 100644
--- a/drivers/video/fbdev/omap2/omapfb/dss/dpi.c
+++ b/drivers/video/fbdev/omap2/omapfb/dss/dpi.c
@@ -20,6 +20,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 
@@ -845,7 +846,7 @@ int dpi_init_port(struct platform_device *pdev, struct 
device_node *port)
if (!dpi)
return -ENOMEM;
 
-   ep = omapdss_of_get_next_endpoint(port, NULL);
+   ep = of_graph_get_next_endpoint(port, NULL);
if (!ep)
return 0;
 
diff --git a/drivers/video/fbdev/omap2/omapfb/dss/dss-of.c 
b/drivers/video/fbdev/omap2/omapfb/dss/dss-of.c
index 321ae18f2747..2ba2554055fc 100644
--- a/drivers/video/fbdev/omap2/omapfb/dss/dss-of.c
+++ b/drivers/video/fbdev/omap2/omapfb/dss/dss-of.c
@@ -15,26 +15,6 @@
 
 #include "dss.h"
 
-struct device_node *
-omapdss_of_get_next_endpoint(const struct device_node *parent,
-struct device_node *prev)
-{
-   struct device_node *ep = NULL;
-
-   if (!parent)
-   return NULL;
-
-   do {
-   ep = of_get_next_child(parent, prev);
-   if (!ep)
-   return NULL;
-   prev = ep;
-   } while (!of_node_name_eq(ep, "endpoint"));
-
-   return ep;
-}
-EXPORT_SYMBOL_GPL(omapdss_of_get_next_endpoint);
-
 struct device_node *dss_of_port_get_parent_device(struct device_node *port)
 {
struct device_node *np;
@@ -81,7 +61,7 @@ omapdss_of_get_first_endpoint(const struct device_node 
*parent)
if (!port)
return NULL;
 
-   ep = omapdss_of_get_next_endpoint(port, NULL);
+   ep = of_graph_get_next_endpoint(port, NULL);
 
of_node_put(port);
 
diff --git a/drivers/video/fbdev/omap2/omapfb/dss/sdi.c 
b/drivers/video/fbdev/omap2/omapfb/dss/sdi.c
index d527931b2b16..e92d84c9474c 100644
--- a/drivers/video/fbdev/omap2/omapfb/dss/sdi.c
+++ b/drivers/video/fbdev/omap2/omapfb/dss/sdi.c
@@ -16,6 +16,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 
 #include 
@@ -405,7 +406,7 @@ int sdi_init_port(struct platform_device *pdev, struct 
device_node *port)
u32 datapairs;
int r;
 
-   ep = omapdss_of_get_next_endpoint(port, NULL);
+   ep = of_graph_get_next_endpoint(port, NULL);
if (!ep)
return 0;
 
diff --git a/include/video/omapfb_dss.h b/include/video/omapfb_dss.h
index 426d12881132..fc106aaa75bf 100644
--- a/include/video/omapfb_dss.h
+++ b/include/video/omapfb_dss.h
@@ -811,10 +811,6 @@ static inline bool omapdss_device_is_enabled(struct 
omap_dss_device *dssdev)
return dssdev->state == OMAP_DSS_DISPLAY_ACTIVE;
 }
 
-struct device_node *
-omapdss_of_get_next_endpoint(const struct device_node *parent,
-struct device_node *prev);
-
 struct device_node *
 omapdss_of_get_first_endpoint(const struct device_node *parent);
 
-- 
2.25.1



[PATCH v3 00/24] of: property: add port base loop

2024-01-31 Thread Kuninori Morimoto


Hi Rob

This is v3 of port base loop patch-set

We have "endpoint" base functions
- of_graph_get_next_endpoint()
- of_graph_get_endpoint_count()
- for_each_endpoint_of_node()

But to handling "port" base things, it is not useful. We want to have
"port" base functions, too. This patch-set adds it.

Because current existing drivers couldn't use "port" base functions,
it were implemented in a different way. This patch-set doesn't try
to full-replace to avoid unknown bug, try easy / quick replace only
for now, but easy to know how "port" base functions are needed.

Because I can't test the driver which I can't use, non-ASoC drivers
needs Tested-by, Acked-by.

This patch-set renames existing "endpoint" to *_device_*
because it is rather than focusing to device's endpoint instead of
port's endpoint.

- of_graph_get_next_endpoint()
+ of_graph_get_next_device_endpoint()

- of_graph_get_endpoint_count()
+ of_graph_get_device_endpoint_count()

- for_each_endpoint_of_node()
+ for_each_device_endpoint_of_node()


[PATCH 01/24] - [PATCH 02/24] : tidyup existing endpoint function kerneldoc
[PATCH 03/24] - [PATCH 11/24] : replace existing function to *_device_*
[PATCH 12/24] - [PATCH 24/24] : add new function and use it

v2 -> v3
- tidyup existing endpoint function kerneldoc
- replace exising function to *_device_*

v1 -> v2
- tidyup function explain
- add missing header on each files

https://lore.kernel.org/r/87jzo0uda2.wl-kuninori.morimoto...@renesas.com
https://lore.kernel.org/r/87fryhklhb.wl-kuninori.morimoto...@renesas.com


Kuninori Morimoto (24):
   1) of: property: add missing kerneldoc for of_graph_get_endpoint_count()
   2) of: property: use unsigned int return on of_graph_get_endpoint_count()
   3) of: property: rename of_graph_get_next_endpoint() to 
of_graph_get_next_device_endpoint()
   4) video: fbdev: switch to use of_graph_get_next_device_endpoint()
   5) media: i2c: switch to use of_graph_get_next_device_endpoint()
   6) media: platform: switch to use of_graph_get_next_device_endpoint()
   7) gpu: drm: switch to use of_graph_get_next_device_endpoint()
   8) hwtracing: switch to use of_graph_get_next_device_endpoint()
   9) staging: switch to use of_graph_get_next_device_endpoint()
  10) ASoC: switch to use of_graph_get_next_device_endpoint()
  11) of: remove of_graph_get_next_endpoint() define
  12) of: property: add port base loop
  13) of: property: use of_graph_get_next_port() on of_graph_get_next_endpoint()
  14) of: property: add of_graph_get_next_endpoint()
  15) drm: omapdrm: use of_graph_get_next_endpoint()
  16) media: xilinx-tpg: use of_graph_get_next_endpoint()
  17) ASoC: audio-graph-card: use of_graph_get_next_endpoint()
  18) ASoC: audio-graph-card2: use of_graph_get_next_port()
  19) ASoC: audio-graph-card2: use of_graph_get_next_endpoint()
  20) ASoC: test-component: use for_each_port_of_node()
  21) fbdev: omapfb: use of_graph_get_remote_port()
  22) fbdev: omapfb: use of_graph_get_next_port()
  23) fbdev: omapfb: use of_graph_get_next_endpoint()
  24) fbdev: omapfb: use of_graph_get_next_device_endpoint()

 .clang-format |   2 +-
 drivers/gpu/drm/armada/armada_drv.c   |   2 +-
 drivers/gpu/drm/bridge/tc358767.c |   2 +-
 drivers/gpu/drm/drm_of.c  |   6 +-
 drivers/gpu/drm/meson/meson_drv.c |   4 +-
 drivers/gpu/drm/msm/msm_drv.c |   2 +-
 drivers/gpu/drm/mxsfb/lcdif_drv.c |   2 +-
 drivers/gpu/drm/omapdrm/dss/base.c|   2 +-
 drivers/gpu/drm/omapdrm/dss/dpi.c |   2 +-
 drivers/gpu/drm/omapdrm/dss/sdi.c |   2 +-
 .../drm/panel/panel-raspberrypi-touchscreen.c |   2 +-
 drivers/gpu/drm/pl111/pl111_drv.c |   2 +-
 drivers/gpu/drm/renesas/rcar-du/rcar_du_kms.c |   2 +-
 drivers/gpu/drm/stm/ltdc.c|   4 +-
 drivers/gpu/drm/tiny/arcpgu.c |   2 +-
 .../hwtracing/coresight/coresight-platform.c  |   4 +-
 drivers/media/i2c/adv7343.c   |   2 +-
 drivers/media/i2c/adv748x/adv748x-core.c  |   2 +-
 drivers/media/i2c/adv7604.c   |   2 +-
 drivers/media/i2c/isl7998x.c  |   2 +-
 drivers/media/i2c/max9286.c   |   2 +-
 drivers/media/i2c/mt9p031.c   |   2 +-
 drivers/media/i2c/mt9v032.c   |   2 +-
 drivers/media/i2c/ov2659.c|   2 +-
 drivers/media/i2c/ov5645.c|   2 +-
 drivers/media/i2c/ov5647.c|   2 +-
 drivers/media/i2c/s5c73m3/s5c73m3-core.c  |   2 +-
 drivers/media/i2c/s5k5baf.c   |   2 +-
 drivers/media/i2c/tc358743.c  |   2 +-
 drivers/media/i2c/tda1997x.c  |   2 +-
 drivers/media/i2c/tvp514x.c   |   2 +-
 dri

[PATCH v3 16/24] media: xilinx-tpg: use of_graph_get_next_endpoint()

2024-01-31 Thread Kuninori Morimoto
We can now use of_graph_get_next_endpoint(), let's use it.

Signed-off-by: Kuninori Morimoto 
---
 drivers/media/platform/xilinx/xilinx-tpg.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/media/platform/xilinx/xilinx-tpg.c 
b/drivers/media/platform/xilinx/xilinx-tpg.c
index 80353ca44402..53c4e1ddf867 100644
--- a/drivers/media/platform/xilinx/xilinx-tpg.c
+++ b/drivers/media/platform/xilinx/xilinx-tpg.c
@@ -13,6 +13,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 
@@ -745,7 +746,7 @@ static int xtpg_parse_of(struct xtpg_device *xtpg)
}
 
if (nports == 0) {
-   endpoint = of_get_next_child(port, NULL);
+   endpoint = of_graph_get_next_endpoint(port, NULL);
if (endpoint)
has_endpoint = true;
of_node_put(endpoint);
-- 
2.25.1



[PATCH v3 08/24] hwtracing: switch to use of_graph_get_next_device_endpoint()

2024-01-31 Thread Kuninori Morimoto
of_graph_get_next_endpoint() is now renamed to
of_graph_get_next_device_endpoint(). Switch to it.

Signed-off-by: Kuninori Morimoto 
---
 drivers/hwtracing/coresight/coresight-platform.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/hwtracing/coresight/coresight-platform.c 
b/drivers/hwtracing/coresight/coresight-platform.c
index 9d550f5697fa..944b2e66c04e 100644
--- a/drivers/hwtracing/coresight/coresight-platform.c
+++ b/drivers/hwtracing/coresight/coresight-platform.c
@@ -275,7 +275,7 @@ static int of_get_coresight_platform_data(struct device 
*dev,
 */
if (!parent) {
/*
-* Avoid warnings in of_graph_get_next_endpoint()
+* Avoid warnings in of_graph_get_next_device_endpoint()
 * if the device doesn't have any graph connections
 */
if (!of_graph_is_present(node))
@@ -286,7 +286,7 @@ static int of_get_coresight_platform_data(struct device 
*dev,
}
 
/* Iterate through each output port to discover topology */
-   while ((ep = of_graph_get_next_endpoint(parent, ep))) {
+   while ((ep = of_graph_get_next_device_endpoint(parent, ep))) {
/*
 * Legacy binding mixes input/output ports under the
 * same parent. So, skip the input ports if we are dealing
-- 
2.25.1



Re: [PATCH 05/22] sound: remove sh-specific sounds/soc/sh drivers

2023-01-17 Thread Kuninori Morimoto


Hi Christoph
> 
> Now that arch/sh is removed these drivers are dead code.
> 
> Signed-off-by: Christoph Hellwig 
> ---
(snip)
>  sound/soc/sh/fsi.c |   9 -
(snip)
>  config SND_SOC_SH4_FSI
>   tristate "SH4 FSI support"
>   depends on COMMON_CLK

You can remove sound/soc/sh/fsi.c
It is for SH SoC.

Thank you for your help !!

Best regards
---
Kuninori Morimoto


Re: [PATCH v2 05/10] arm64: dts: renesas: r8a77961: Add FCP device nodes

2020-09-10 Thread Kuninori Morimoto


Hi Geert

> > From: Kuninori Morimoto 
> >
> > This patch adds FCP device nodes for R-Car M3-W+ (r8a77961) SoC.
> > This patch was tested on R-Car M3-W+ Salvator-XS board.
> >
> > Signed-off-by: Kuninori Morimoto 
(snip)
> Missing "iommus = <_vc0 16>;"
(snip)
> Missing "iommus = <_vi0 5>;"

As I mentioned at [07/10] reply,
I dropped the features which I'm not sure how to confirm/test
from initial support.
I hope expert people will update it.

Thank you for your help !!

Best regards
---
Kuninori Morimoto
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [PATCH v2 07/10] arm64: dts: renesas: r8a77961: Add DU device nodes

2020-09-10 Thread Kuninori Morimoto


Hi Geert

> > From: Kuninori Morimoto 
> >
> > This patch adds DU device nodes for R-Car M3-W+ (r8a77961) SoC.
> > This patch was tested on R-Car M3-W+ Salvator-XS board.
> >
> > Signed-off-by: Kuninori Morimoto 
> > ---
(snip)
> > du: display@feb0 {
> > +   compatible = "renesas,du-r8a77961";
> > reg = <0 0xfeb0 0 0x7>;
> > -   /* placeholder */
> > +   interrupts = ,
> > +,
> > +;
> > +   clocks = < CPG_MOD 724>, < CPG_MOD 723>,
> > +< CPG_MOD 722>;
> > +   clock-names = "du.0", "du.1", "du.2";
> > +   resets = < 724>, < 722>;
> > +   reset-names = "du.0", "du.2";
> > +
> > +   renesas,vsps = < 0>, < 0>, < 0>;
> > +   status = "disabled";
> 
> Do you want support for CMMs?

I'm not sure how it works.
Thus I dropped such features from initial support.

I hope Laurent or Kieran will support it
when he received physical board.
Some comment for iommu.

Thank you for your help !!

Best regards
---
Kuninori Morimoto
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [PATCH v2 02/10] dt-bindings: display: renesas: dw-hdmi: tidyup example compatible.

2020-09-09 Thread Kuninori Morimoto


Hi Laurent,

> > Author: Kuninori Morimoto 
> > Date:   Tue Sep 8 09:34:11 2020 +0900
> > 
> > dt-bindings: display: renesas: dw-hdmi: Tidyup example compatible
> > 
> > The DT example erronously uses the "renesas,r8a7795-dw-hdmi", when the
> > correct value is "renesas,r8a7795-hdmi". It is furthermore missing the
> > generic "renesas,rcar-gen3-hdmi" compatible string. Fix it.
> > 
> > Signed-off-by: Kuninori Morimoto 
> > Reviewed-by: Laurent Pinchart 
> > 
> > Reviewed-by: Kieran Bingham 
> > [Add "renesas,rcar-gen3-hdmi" and rework commit message]
> > Signed-off-by: Laurent Pinchart 
> > 

I will send Acked-by: to my (?) patch :)

Acked-by: Kuninori Morimoto 

Thank you for your help !!

Best regards
---
Kuninori Morimoto
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [PATCH v2 10/10] arm64: dts: renesas: r8a77961-salvator-xs: add HDMI Sound support

2020-09-08 Thread Kuninori Morimoto


Hi Laurent

> > > > From: Kuninori Morimoto 
> > > > 
> > > > This patch enables HDMI Sound on R-Car M3-W+ Salvator-XS board.
> > > > 
> > > > This reverts commit b997613fad58a03588f0f64a3d86db6c5bd76dd2.
> > > 
> > > Which tree can this commit be found in ?
> > 
> > Grr, I forgot to remove it from git-log.
> > will fix in v3
> 
> No worries :-)
> 
> I've applied patch 01 to 04 to my tree and plan to send a pull request
> later today. Could you just let me know if you're fine with the small
> modification to the commit message proposed in 04/10 ?

Yes, no objection about it.
Thank you for your help !!

Best regards
---
Kuninori Morimoto
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [PATCH v2 10/10] arm64: dts: renesas: r8a77961-salvator-xs: add HDMI Sound support

2020-09-08 Thread Kuninori Morimoto


Hi Laurent

Thank you for your review

> > From: Kuninori Morimoto 
> > 
> > This patch enables HDMI Sound on R-Car M3-W+ Salvator-XS board.
> > 
> > This reverts commit b997613fad58a03588f0f64a3d86db6c5bd76dd2.
> 
> Which tree can this commit be found in ?

Grr, I forgot to remove it from git-log.
will fix in v3

Thank you for your help !!

Best regards
---
Kuninori Morimoto
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH v2 08/10] arm64: dts: renesas: r8a77961: Add HDMI device nodes

2020-09-07 Thread Kuninori Morimoto


From: Kuninori Morimoto 

This patch adds HDMI device nodes for R-Car M3-W+ (r8a77961) SoC.
This patch was tested on R-Car M3-W+ Salvator-XS board.

Signed-off-by: Kuninori Morimoto 
---
 arch/arm64/boot/dts/renesas/r8a77961.dtsi | 12 +++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/arch/arm64/boot/dts/renesas/r8a77961.dtsi 
b/arch/arm64/boot/dts/renesas/r8a77961.dtsi
index c7fabd9e875b..7f21491f6436 100644
--- a/arch/arm64/boot/dts/renesas/r8a77961.dtsi
+++ b/arch/arm64/boot/dts/renesas/r8a77961.dtsi
@@ -2145,14 +2145,23 @@ port@1 {
};
 
hdmi0: hdmi@fead {
+   compatible = "renesas,r8a77961-hdmi", 
"renesas,rcar-gen3-hdmi";
reg = <0 0xfead 0 0x1>;
-   /* placeholder */
+   interrupts = ;
+   clocks = < CPG_MOD 729>, < CPG_CORE 
R8A77961_CLK_HDMI>;
+   clock-names = "iahb", "isfr";
+   power-domains = < R8A77961_PD_ALWAYS_ON>;
+   resets = < 729>;
+   status = "disabled";
 
ports {
#address-cells = <1>;
#size-cells = <0>;
port@0 {
reg = <0>;
+   dw_hdmi0_in: endpoint {
+   remote-endpoint = 
<_out_hdmi0>;
+   };
};
port@1 {
reg = <1>;
@@ -2191,6 +2200,7 @@ du_out_rgb: endpoint {
port@1 {
reg = <1>;
du_out_hdmi0: endpoint {
+   remote-endpoint = 
<_hdmi0_in>;
};
};
port@2 {
-- 
2.25.1

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH v2 10/10] arm64: dts: renesas: r8a77961-salvator-xs: add HDMI Sound support

2020-09-07 Thread Kuninori Morimoto
From: Kuninori Morimoto 

This patch enables HDMI Sound on R-Car M3-W+ Salvator-XS board.

This reverts commit b997613fad58a03588f0f64a3d86db6c5bd76dd2.

Signed-off-by: Kuninori Morimoto 
---
 .../boot/dts/renesas/r8a77961-salvator-xs.dts | 29 +++
 1 file changed, 29 insertions(+)

diff --git a/arch/arm64/boot/dts/renesas/r8a77961-salvator-xs.dts 
b/arch/arm64/boot/dts/renesas/r8a77961-salvator-xs.dts
index ca21a702db54..1e7603365106 100644
--- a/arch/arm64/boot/dts/renesas/r8a77961-salvator-xs.dts
+++ b/arch/arm64/boot/dts/renesas/r8a77961-salvator-xs.dts
@@ -51,9 +51,38 @@ rcar_dw_hdmi0_out: endpoint {
remote-endpoint = <_con>;
};
};
+   port@2 {
+   reg = <2>;
+   dw_hdmi0_snd_in: endpoint {
+   remote-endpoint = <_endpoint1>;
+   };
+   };
};
 };
 
 _con {
remote-endpoint = <_dw_hdmi0_out>;
 };
+
+_sound {
+   ports {
+   /* rsnd_port0 is on salvator-common */
+   rsnd_port1: port@1 {
+   reg = <1>;
+   rsnd_endpoint1: endpoint {
+   remote-endpoint = <_hdmi0_snd_in>;
+
+   dai-format = "i2s";
+   bitclock-master = <_endpoint1>;
+   frame-master = <_endpoint1>;
+
+   playback = <>;
+   };
+   };
+   };
+};
+
+_card {
+   dais = <_port0 /* ak4613 */
+   _port1>;   /* HDMI0  */
+};
-- 
2.25.1

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH v2 09/10] arm64: dts: renesas: r8a77961-salvator-xs: add HDMI Display support

2020-09-07 Thread Kuninori Morimoto
From: Kuninori Morimoto 

This patch enables HDMI Display on R-Car M3-W+ Salvator-XS board.

Signed-off-by: Kuninori Morimoto 
---
 .../boot/dts/renesas/r8a77961-salvator-xs.dts | 28 +++
 1 file changed, 28 insertions(+)

diff --git a/arch/arm64/boot/dts/renesas/r8a77961-salvator-xs.dts 
b/arch/arm64/boot/dts/renesas/r8a77961-salvator-xs.dts
index 2ffc7e31dd58..ca21a702db54 100644
--- a/arch/arm64/boot/dts/renesas/r8a77961-salvator-xs.dts
+++ b/arch/arm64/boot/dts/renesas/r8a77961-salvator-xs.dts
@@ -29,3 +29,31 @@ memory@6 {
reg = <0x6 0x 0x1 0x>;
};
 };
+
+ {
+   clocks = < CPG_MOD 724>,
+< CPG_MOD 723>,
+< CPG_MOD 722>,
+< 1>,
+<_clk>,
+< 2>;
+   clock-names = "du.0", "du.1", "du.2",
+ "dclkin.0", "dclkin.1", "dclkin.2";
+};
+
+ {
+   status = "okay";
+
+   ports {
+   port@1 {
+   reg = <1>;
+   rcar_dw_hdmi0_out: endpoint {
+   remote-endpoint = <_con>;
+   };
+   };
+   };
+};
+
+_con {
+   remote-endpoint = <_dw_hdmi0_out>;
+};
-- 
2.25.1

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH v2 07/10] arm64: dts: renesas: r8a77961: Add DU device nodes

2020-09-07 Thread Kuninori Morimoto


From: Kuninori Morimoto 

This patch adds DU device nodes for R-Car M3-W+ (r8a77961) SoC.
This patch was tested on R-Car M3-W+ Salvator-XS board.

Signed-off-by: Kuninori Morimoto 
---
 arch/arm64/boot/dts/renesas/r8a77961.dtsi | 13 -
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/arch/arm64/boot/dts/renesas/r8a77961.dtsi 
b/arch/arm64/boot/dts/renesas/r8a77961.dtsi
index 423808b6cd58..c7fabd9e875b 100644
--- a/arch/arm64/boot/dts/renesas/r8a77961.dtsi
+++ b/arch/arm64/boot/dts/renesas/r8a77961.dtsi
@@ -2165,8 +2165,19 @@ port@2 {
};
 
du: display@feb0 {
+   compatible = "renesas,du-r8a77961";
reg = <0 0xfeb0 0 0x7>;
-   /* placeholder */
+   interrupts = ,
+,
+;
+   clocks = < CPG_MOD 724>, < CPG_MOD 723>,
+< CPG_MOD 722>;
+   clock-names = "du.0", "du.1", "du.2";
+   resets = < 724>, < 722>;
+   reset-names = "du.0", "du.2";
+
+   renesas,vsps = < 0>, < 0>, < 0>;
+   status = "disabled";
 
ports {
#address-cells = <1>;
-- 
2.25.1

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH v2 06/10] arm64: dts: renesas: r8a77961: Add VSP device nodes

2020-09-07 Thread Kuninori Morimoto


From: Kuninori Morimoto 

This patch adds VSP device nodes for R-Car M3-W+ (r8a77961) SoC.
This patch was tested on R-Car M3-W+ Salvator-XS board.

Signed-off-by: Kuninori Morimoto 
---
 arch/arm64/boot/dts/renesas/r8a77961.dtsi | 55 +++
 1 file changed, 55 insertions(+)

diff --git a/arch/arm64/boot/dts/renesas/r8a77961.dtsi 
b/arch/arm64/boot/dts/renesas/r8a77961.dtsi
index fe0db11b9cb9..423808b6cd58 100644
--- a/arch/arm64/boot/dts/renesas/r8a77961.dtsi
+++ b/arch/arm64/boot/dts/renesas/r8a77961.dtsi
@@ -2012,6 +2012,17 @@ fcpf0: fcp@fe95 {
resets = < 615>;
};
 
+   vspb: vsp@fe96 {
+   compatible = "renesas,vsp2";
+   reg = <0 0xfe96 0 0x8000>;
+   interrupts = ;
+   clocks = < CPG_MOD 626>;
+   power-domains = < R8A77961_PD_A3VC>;
+   resets = < 626>;
+
+   renesas,fcp = <>;
+   };
+
fcpvb0: fcp@fe96f000 {
compatible = "renesas,fcpv";
reg = <0 0xfe96f000 0 0x200>;
@@ -2020,6 +2031,17 @@ fcpvb0: fcp@fe96f000 {
resets = < 607>;
};
 
+   vspi0: vsp@fe9a {
+   compatible = "renesas,vsp2";
+   reg = <0 0xfe9a 0 0x8000>;
+   interrupts = ;
+   clocks = < CPG_MOD 631>;
+   power-domains = < R8A77961_PD_A3VC>;
+   resets = < 631>;
+
+   renesas,fcp = <>;
+   };
+
fcpvi0: fcp@fe9af000 {
compatible = "renesas,fcpv";
reg = <0 0xfe9af000 0 0x200>;
@@ -2029,6 +2051,17 @@ fcpvi0: fcp@fe9af000 {
iommus = <_vc0 19>;
};
 
+   vspd0: vsp@fea2 {
+   compatible = "renesas,vsp2";
+   reg = <0 0xfea2 0 0x5000>;
+   interrupts = ;
+   clocks = < CPG_MOD 623>;
+   power-domains = < R8A77961_PD_ALWAYS_ON>;
+   resets = < 623>;
+
+   renesas,fcp = <>;
+   };
+
fcpvd0: fcp@fea27000 {
compatible = "renesas,fcpv";
reg = <0 0xfea27000 0 0x200>;
@@ -2038,6 +2071,17 @@ fcpvd0: fcp@fea27000 {
iommus = <_vi0 8>;
};
 
+   vspd1: vsp@fea28000 {
+   compatible = "renesas,vsp2";
+   reg = <0 0xfea28000 0 0x5000>;
+   interrupts = ;
+   clocks = < CPG_MOD 622>;
+   power-domains = < R8A77961_PD_ALWAYS_ON>;
+   resets = < 622>;
+
+   renesas,fcp = <>;
+   };
+
fcpvd1: fcp@fea2f000 {
compatible = "renesas,fcpv";
reg = <0 0xfea2f000 0 0x200>;
@@ -2047,6 +2091,17 @@ fcpvd1: fcp@fea2f000 {
iommus = <_vi0 9>;
};
 
+   vspd2: vsp@fea3 {
+   compatible = "renesas,vsp2";
+   reg = <0 0xfea3 0 0x5000>;
+   interrupts = ;
+   clocks = < CPG_MOD 621>;
+   power-domains = < R8A77961_PD_ALWAYS_ON>;
+   resets = < 621>;
+
+   renesas,fcp = <>;
+   };
+
fcpvd2: fcp@fea37000 {
compatible = "renesas,fcpv";
reg = <0 0xfea37000 0 0x200>;
-- 
2.25.1

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH v2 01/10] dt-bindings: display: renesas: du: Document the r8a77961 bindings

2020-09-07 Thread Kuninori Morimoto
From: Kuninori Morimoto 

Document the R-Car M3-W+ (R8A77961) SoC in the R-Car DU bindings.

Signed-off-by: Kuninori Morimoto 
---
 Documentation/devicetree/bindings/display/renesas,du.txt | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/Documentation/devicetree/bindings/display/renesas,du.txt 
b/Documentation/devicetree/bindings/display/renesas,du.txt
index 51cd4d162770..317c9dd2d57c 100644
--- a/Documentation/devicetree/bindings/display/renesas,du.txt
+++ b/Documentation/devicetree/bindings/display/renesas,du.txt
@@ -18,6 +18,7 @@ Required Properties:
 - "renesas,du-r8a7794" for R8A7794 (R-Car E2) compatible DU
 - "renesas,du-r8a7795" for R8A7795 (R-Car H3) compatible DU
 - "renesas,du-r8a7796" for R8A7796 (R-Car M3-W) compatible DU
+- "renesas,du-r8a77961" for R8A77961 (R-Car M3-W+) compatible DU
 - "renesas,du-r8a77965" for R8A77965 (R-Car M3-N) compatible DU
 - "renesas,du-r8a77970" for R8A77970 (R-Car V3M) compatible DU
 - "renesas,du-r8a77980" for R8A77980 (R-Car V3H) compatible DU
@@ -83,6 +84,7 @@ corresponding to each DU output.
  R8A7794 (R-Car E2) DPAD 0 DPAD 1 -  -
  R8A7795 (R-Car H3) DPAD 0 HDMI 0 HDMI 1 LVDS 0
  R8A7796 (R-Car M3-W)   DPAD 0 HDMI 0 LVDS 0 -
+ R8A77961 (R-Car M3-W+) DPAD 0 HDMI 0 LVDS 0 -
  R8A77965 (R-Car M3-N)  DPAD 0 HDMI 0 LVDS 0 -
  R8A77970 (R-Car V3M)   DPAD 0 LVDS 0 -  -
  R8A77980 (R-Car V3H)   DPAD 0 LVDS 0 -  -
-- 
2.25.1

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH v2 03/10] dt-bindings: display: renesas: dw-hdmi: Add R8A77961 support

2020-09-07 Thread Kuninori Morimoto
From: Kuninori Morimoto 

This patch adds R-Car M3-W+ (R8A77961) SoC bindings.

Signed-off-by: Kuninori Morimoto 
Reviewed-by: Geert Uytterhoeven 
---
 .../devicetree/bindings/display/bridge/renesas,dw-hdmi.txt   | 1 +
 1 file changed, 1 insertion(+)

diff --git 
a/Documentation/devicetree/bindings/display/bridge/renesas,dw-hdmi.txt 
b/Documentation/devicetree/bindings/display/bridge/renesas,dw-hdmi.txt
index e6526ab485d0..2086f4514911 100644
--- a/Documentation/devicetree/bindings/display/bridge/renesas,dw-hdmi.txt
+++ b/Documentation/devicetree/bindings/display/bridge/renesas,dw-hdmi.txt
@@ -16,6 +16,7 @@ Required properties:
   - "renesas,r8a774b1-hdmi" for R8A774B1 (RZ/G2N) compatible HDMI TX
   - "renesas,r8a7795-hdmi" for R8A7795 (R-Car H3) compatible HDMI TX
   - "renesas,r8a7796-hdmi" for R8A7796 (R-Car M3-W) compatible HDMI TX
+  - "renesas,r8a77961-hdmi" for R8A77961 (R-Car M3-W+) compatible HDMI TX
   - "renesas,r8a77965-hdmi" for R8A77965 (R-Car M3-N) compatible HDMI TX
   - "renesas,rcar-gen3-hdmi" for the generic R-Car Gen3 and RZ/G2 compatible
 HDMI TX
-- 
2.25.1

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH v2 02/10] dt-bindings: display: renesas: dw-hdmi: tidyup example compatible.

2020-09-07 Thread Kuninori Morimoto
From: Kuninori Morimoto 

required is "renesas,r8a7795-hdmi", instead of "renesas,r8a7795-dw-hdmi"

Signed-off-by: Kuninori Morimoto 
---
 .../devicetree/bindings/display/bridge/renesas,dw-hdmi.txt  | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git 
a/Documentation/devicetree/bindings/display/bridge/renesas,dw-hdmi.txt 
b/Documentation/devicetree/bindings/display/bridge/renesas,dw-hdmi.txt
index 819f3e31013c..e6526ab485d0 100644
--- a/Documentation/devicetree/bindings/display/bridge/renesas,dw-hdmi.txt
+++ b/Documentation/devicetree/bindings/display/bridge/renesas,dw-hdmi.txt
@@ -42,7 +42,7 @@ Optional properties:
 Example:
 
hdmi0: hdmi@fead {
-   compatible = "renesas,r8a7795-dw-hdmi";
+   compatible = "renesas,r8a7795-hdmi";
reg = <0 0xfead 0 0x1>;
interrupts = <0 389 IRQ_TYPE_LEVEL_HIGH>;
clocks = < CPG_CORE R8A7795_CLK_S0D4>, < CPG_MOD 729>;
-- 
2.25.1

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH v2 04/10] drm: rcar-du: Add r8a77961 support

2020-09-07 Thread Kuninori Morimoto


From: Kuninori Morimoto 

This patch adds R-Car M3-W+ (R8A77961) support which has
compatible to R-Car M3-W (R8A77960).

Signed-off-by: Kuninori Morimoto 
---
 drivers/gpu/drm/rcar-du/rcar_du_drv.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/gpu/drm/rcar-du/rcar_du_drv.c 
b/drivers/gpu/drm/rcar-du/rcar_du_drv.c
index f53b0ec71085..64533cbdbef0 100644
--- a/drivers/gpu/drm/rcar-du/rcar_du_drv.c
+++ b/drivers/gpu/drm/rcar-du/rcar_du_drv.c
@@ -458,6 +458,7 @@ static const struct of_device_id rcar_du_of_table[] = {
{ .compatible = "renesas,du-r8a7794", .data = _du_r8a7794_info },
{ .compatible = "renesas,du-r8a7795", .data = _du_r8a7795_info },
{ .compatible = "renesas,du-r8a7796", .data = _du_r8a7796_info },
+   { .compatible = "renesas,du-r8a77961", .data = _du_r8a7796_info },
{ .compatible = "renesas,du-r8a77965", .data = _du_r8a77965_info },
{ .compatible = "renesas,du-r8a77970", .data = _du_r8a77970_info },
{ .compatible = "renesas,du-r8a77980", .data = _du_r8a77970_info },
-- 
2.25.1

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH v2 05/10] arm64: dts: renesas: r8a77961: Add FCP device nodes

2020-09-07 Thread Kuninori Morimoto


From: Kuninori Morimoto 

This patch adds FCP device nodes for R-Car M3-W+ (r8a77961) SoC.
This patch was tested on R-Car M3-W+ Salvator-XS board.

Signed-off-by: Kuninori Morimoto 
---
 arch/arm64/boot/dts/renesas/r8a77961.dtsi | 52 +++
 1 file changed, 52 insertions(+)

diff --git a/arch/arm64/boot/dts/renesas/r8a77961.dtsi 
b/arch/arm64/boot/dts/renesas/r8a77961.dtsi
index 0abfea0b27be..fe0db11b9cb9 100644
--- a/arch/arm64/boot/dts/renesas/r8a77961.dtsi
+++ b/arch/arm64/boot/dts/renesas/r8a77961.dtsi
@@ -2004,6 +2004,58 @@ pciec1: pcie@ee80 {
status = "disabled";
};
 
+   fcpf0: fcp@fe95 {
+   compatible = "renesas,fcpf";
+   reg = <0 0xfe95 0 0x200>;
+   clocks = < CPG_MOD 615>;
+   power-domains = < R8A77961_PD_A3VC>;
+   resets = < 615>;
+   };
+
+   fcpvb0: fcp@fe96f000 {
+   compatible = "renesas,fcpv";
+   reg = <0 0xfe96f000 0 0x200>;
+   clocks = < CPG_MOD 607>;
+   power-domains = < R8A77961_PD_A3VC>;
+   resets = < 607>;
+   };
+
+   fcpvi0: fcp@fe9af000 {
+   compatible = "renesas,fcpv";
+   reg = <0 0xfe9af000 0 0x200>;
+   clocks = < CPG_MOD 611>;
+   power-domains = < R8A77961_PD_A3VC>;
+   resets = < 611>;
+   iommus = <_vc0 19>;
+   };
+
+   fcpvd0: fcp@fea27000 {
+   compatible = "renesas,fcpv";
+   reg = <0 0xfea27000 0 0x200>;
+   clocks = < CPG_MOD 603>;
+   power-domains = < R8A77961_PD_ALWAYS_ON>;
+   resets = < 603>;
+   iommus = <_vi0 8>;
+   };
+
+   fcpvd1: fcp@fea2f000 {
+   compatible = "renesas,fcpv";
+   reg = <0 0xfea2f000 0 0x200>;
+   clocks = < CPG_MOD 602>;
+   power-domains = < R8A77961_PD_ALWAYS_ON>;
+   resets = < 602>;
+   iommus = <_vi0 9>;
+   };
+
+   fcpvd2: fcp@fea37000 {
+   compatible = "renesas,fcpv";
+   reg = <0 0xfea37000 0 0x200>;
+   clocks = < CPG_MOD 601>;
+   power-domains = < R8A77961_PD_ALWAYS_ON>;
+   resets = < 601>;
+   iommus = <_vi0 10>;
+   };
+
csi20: csi2@fea8 {
reg = <0 0xfea8 0 0x1>;
/* placeholder */
-- 
2.25.1

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH v2 00/10] arm64: renesas: enable HDMI Display/Sound on R-Car M3-W+ Salvator-XS

2020-09-07 Thread Kuninori Morimoto


Hi Geert, Laurent

These are v2 of HDMI Display/Sound support for R8A77961.
These are tested on R-Car M3-W+ Salvator-XS board.

v1 -> v2
- "is test" to "was tested" at git-log
- add M3-W+ port entry to DU table (= [01/10])
- add dw-hdmi tidyup new patch (= [02/10])
- add Geert's Reviewed-by  (= [03/10])
- address sorting for VSP node     (= [06/10])

Kuninori Morimoto (10):
  dt-bindings: display: renesas: du: Document the r8a77961 bindings
  dt-bindings: display: renesas: dw-hdmi: tidyup example compatible.
  dt-bindings: display: renesas: dw-hdmi: Add R8A77961 support
  drm: rcar-du: Add r8a77961 support
  arm64: dts: renesas: r8a77961: Add FCP device nodes
  arm64: dts: renesas: r8a77961: Add VSP device nodes
  arm64: dts: renesas: r8a77961: Add DU device nodes
  arm64: dts: renesas: r8a77961: Add HDMI device nodes
  arm64: dts: renesas: r8a77961-salvator-xs: add HDMI Display support
  arm64: dts: renesas: r8a77961-salvator-xs: add HDMI Sound support

 .../display/bridge/renesas,dw-hdmi.txt|   3 +-
 .../bindings/display/renesas,du.txt   |   2 +
 .../boot/dts/renesas/r8a77961-salvator-xs.dts |  57 
 arch/arm64/boot/dts/renesas/r8a77961.dtsi | 132 +-
 drivers/gpu/drm/rcar-du/rcar_du_drv.c |   1 +
 5 files changed, 192 insertions(+), 3 deletions(-)

-- 
2.25.1

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [PATCH 5/9] arm64: dts: renesas: r8a77961: Add VSP device nodes

2020-09-07 Thread Kuninori Morimoto


Hi Kieran

> > From: Kuninori Morimoto 
> > 
> > This patch adds VSP device nodes for R-Car M3-W+ (r8a77961) SoC.
> > This patch is test on R-Car M3-W+ Salvator-XS board.
> > 
> > Signed-off-by: Kuninori Morimoto 
> > ---
(snip)
> Do we keep the items grouped by the first occurrence? or sort the nodes
> based on address?
(snip)
> Is there a set policy?

The order is same as r8a77960.dtsi, not my policy.
Will sort in v2


Thank you for your help !!

Best regards
---
Kuninori Morimoto
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [PATCH 1/9] dt-bindings: display: renesas: du: Document the r8a77961 bindings

2020-09-07 Thread Kuninori Morimoto


Hi Geert

> > --- a/Documentation/devicetree/bindings/display/renesas,du.txt
> > +++ b/Documentation/devicetree/bindings/display/renesas,du.txt
> > @@ -18,6 +18,7 @@ Required Properties:
> >  - "renesas,du-r8a7794" for R8A7794 (R-Car E2) compatible DU
> >  - "renesas,du-r8a7795" for R8A7795 (R-Car H3) compatible DU
> >  - "renesas,du-r8a7796" for R8A7796 (R-Car M3-W) compatible DU
> > +- "renesas,du-r8a77961" for R8A77961 (R-Car M3-W+) compatible DU
> >  - "renesas,du-r8a77965" for R8A77965 (R-Car M3-N) compatible DU
> >  - "renesas,du-r8a77970" for R8A77970 (R-Car V3M) compatible DU
> >  - "renesas,du-r8a77980" for R8A77980 (R-Car V3H) compatible DU
> 
> Looks good to me, but please also add an entry to the table below
> describing the port mappings.

Oops indeed.
Thank you for pointing it, I didn't noticed about it.
Will do in v2


Thank you for your help !!

Best regards
---
Kuninori Morimoto
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH 8/9] arm64: dts: renesas: r8a77961-salvator-xs: add HDMI Display support

2020-09-06 Thread Kuninori Morimoto
From: Kuninori Morimoto 

This patch enables HDMI Display on R-Car M3-W+ Salvator-XS board.
This patch is test on R-Car M3-W+ Salvator-XS board.

Signed-off-by: Kuninori Morimoto 
---
 .../boot/dts/renesas/r8a77961-salvator-xs.dts | 28 +++
 1 file changed, 28 insertions(+)

diff --git a/arch/arm64/boot/dts/renesas/r8a77961-salvator-xs.dts 
b/arch/arm64/boot/dts/renesas/r8a77961-salvator-xs.dts
index 2ffc7e31dd58..ca21a702db54 100644
--- a/arch/arm64/boot/dts/renesas/r8a77961-salvator-xs.dts
+++ b/arch/arm64/boot/dts/renesas/r8a77961-salvator-xs.dts
@@ -29,3 +29,31 @@ memory@6 {
reg = <0x6 0x 0x1 0x>;
};
 };
+
+ {
+   clocks = < CPG_MOD 724>,
+< CPG_MOD 723>,
+< CPG_MOD 722>,
+< 1>,
+<_clk>,
+< 2>;
+   clock-names = "du.0", "du.1", "du.2",
+ "dclkin.0", "dclkin.1", "dclkin.2";
+};
+
+ {
+   status = "okay";
+
+   ports {
+   port@1 {
+   reg = <1>;
+   rcar_dw_hdmi0_out: endpoint {
+   remote-endpoint = <_con>;
+   };
+   };
+   };
+};
+
+_con {
+   remote-endpoint = <_dw_hdmi0_out>;
+};
-- 
2.25.1

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH 7/9] arm64: dts: renesas: r8a77961: Add HDMI device nodes

2020-09-06 Thread Kuninori Morimoto


From: Kuninori Morimoto 

This patch adds HDMI device nodes for R-Car M3-W+ (r8a77961) SoC.
This patch is test on R-Car M3-W+ Salvator-XS board.

Signed-off-by: Kuninori Morimoto 
---
 arch/arm64/boot/dts/renesas/r8a77961.dtsi | 12 +++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/arch/arm64/boot/dts/renesas/r8a77961.dtsi 
b/arch/arm64/boot/dts/renesas/r8a77961.dtsi
index dcd92f5abad6..5050cf8e7625 100644
--- a/arch/arm64/boot/dts/renesas/r8a77961.dtsi
+++ b/arch/arm64/boot/dts/renesas/r8a77961.dtsi
@@ -2145,14 +2145,23 @@ port@1 {
};
 
hdmi0: hdmi@fead {
+   compatible = "renesas,r8a77961-hdmi", 
"renesas,rcar-gen3-hdmi";
reg = <0 0xfead 0 0x1>;
-   /* placeholder */
+   interrupts = ;
+   clocks = < CPG_MOD 729>, < CPG_CORE 
R8A77961_CLK_HDMI>;
+   clock-names = "iahb", "isfr";
+   power-domains = < R8A77961_PD_ALWAYS_ON>;
+   resets = < 729>;
+   status = "disabled";
 
ports {
#address-cells = <1>;
#size-cells = <0>;
port@0 {
reg = <0>;
+   dw_hdmi0_in: endpoint {
+   remote-endpoint = 
<_out_hdmi0>;
+   };
};
port@1 {
reg = <1>;
@@ -2191,6 +2200,7 @@ du_out_rgb: endpoint {
port@1 {
reg = <1>;
du_out_hdmi0: endpoint {
+   remote-endpoint = 
<_hdmi0_in>;
};
};
port@2 {
-- 
2.25.1

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH 9/9] arm64: dts: renesas: r8a77961-salvator-xs: add HDMI Sound support

2020-09-06 Thread Kuninori Morimoto
From: Kuninori Morimoto 

This patch enables HDMI Sound on R-Car M3-W+ Salvator-XS board.
This patch is test on R-Car M3-W+ Salvator-XS board.

This reverts commit b997613fad58a03588f0f64a3d86db6c5bd76dd2.

Signed-off-by: Kuninori Morimoto 
---
 .../boot/dts/renesas/r8a77961-salvator-xs.dts | 29 +++
 1 file changed, 29 insertions(+)

diff --git a/arch/arm64/boot/dts/renesas/r8a77961-salvator-xs.dts 
b/arch/arm64/boot/dts/renesas/r8a77961-salvator-xs.dts
index ca21a702db54..1e7603365106 100644
--- a/arch/arm64/boot/dts/renesas/r8a77961-salvator-xs.dts
+++ b/arch/arm64/boot/dts/renesas/r8a77961-salvator-xs.dts
@@ -51,9 +51,38 @@ rcar_dw_hdmi0_out: endpoint {
remote-endpoint = <_con>;
};
};
+   port@2 {
+   reg = <2>;
+   dw_hdmi0_snd_in: endpoint {
+   remote-endpoint = <_endpoint1>;
+   };
+   };
};
 };
 
 _con {
remote-endpoint = <_dw_hdmi0_out>;
 };
+
+_sound {
+   ports {
+   /* rsnd_port0 is on salvator-common */
+   rsnd_port1: port@1 {
+   reg = <1>;
+   rsnd_endpoint1: endpoint {
+   remote-endpoint = <_hdmi0_snd_in>;
+
+   dai-format = "i2s";
+   bitclock-master = <_endpoint1>;
+   frame-master = <_endpoint1>;
+
+   playback = <>;
+   };
+   };
+   };
+};
+
+_card {
+   dais = <_port0 /* ak4613 */
+   _port1>;   /* HDMI0  */
+};
-- 
2.25.1

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH 6/9] arm64: dts: renesas: r8a77961: Add DU device nodes

2020-09-06 Thread Kuninori Morimoto


From: Kuninori Morimoto 

This patch adds DU device nodes for R-Car M3-W+ (r8a77961) SoC.
This patch is test on R-Car M3-W+ Salvator-XS board.

Signed-off-by: Kuninori Morimoto 
---
 arch/arm64/boot/dts/renesas/r8a77961.dtsi | 13 -
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/arch/arm64/boot/dts/renesas/r8a77961.dtsi 
b/arch/arm64/boot/dts/renesas/r8a77961.dtsi
index c2a6918ed5e6..dcd92f5abad6 100644
--- a/arch/arm64/boot/dts/renesas/r8a77961.dtsi
+++ b/arch/arm64/boot/dts/renesas/r8a77961.dtsi
@@ -2165,8 +2165,19 @@ port@2 {
};
 
du: display@feb0 {
+   compatible = "renesas,du-r8a77961";
reg = <0 0xfeb0 0 0x7>;
-   /* placeholder */
+   interrupts = ,
+,
+;
+   clocks = < CPG_MOD 724>, < CPG_MOD 723>,
+< CPG_MOD 722>;
+   clock-names = "du.0", "du.1", "du.2";
+   resets = < 724>, < 722>;
+   reset-names = "du.0", "du.2";
+
+   renesas,vsps = < 0>, < 0>, < 0>;
+   status = "disabled";
 
ports {
#address-cells = <1>;
-- 
2.25.1

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH 5/9] arm64: dts: renesas: r8a77961: Add VSP device nodes

2020-09-06 Thread Kuninori Morimoto


From: Kuninori Morimoto 

This patch adds VSP device nodes for R-Car M3-W+ (r8a77961) SoC.
This patch is test on R-Car M3-W+ Salvator-XS board.

Signed-off-by: Kuninori Morimoto 
---
 arch/arm64/boot/dts/renesas/r8a77961.dtsi | 55 +++
 1 file changed, 55 insertions(+)

diff --git a/arch/arm64/boot/dts/renesas/r8a77961.dtsi 
b/arch/arm64/boot/dts/renesas/r8a77961.dtsi
index fe0db11b9cb9..c2a6918ed5e6 100644
--- a/arch/arm64/boot/dts/renesas/r8a77961.dtsi
+++ b/arch/arm64/boot/dts/renesas/r8a77961.dtsi
@@ -2056,6 +2056,61 @@ fcpvd2: fcp@fea37000 {
iommus = <_vi0 10>;
};
 
+   vspb: vsp@fe96 {
+   compatible = "renesas,vsp2";
+   reg = <0 0xfe96 0 0x8000>;
+   interrupts = ;
+   clocks = < CPG_MOD 626>;
+   power-domains = < R8A77961_PD_A3VC>;
+   resets = < 626>;
+
+   renesas,fcp = <>;
+   };
+
+   vspd0: vsp@fea2 {
+   compatible = "renesas,vsp2";
+   reg = <0 0xfea2 0 0x5000>;
+   interrupts = ;
+   clocks = < CPG_MOD 623>;
+   power-domains = < R8A77961_PD_ALWAYS_ON>;
+   resets = < 623>;
+
+   renesas,fcp = <>;
+   };
+
+   vspd1: vsp@fea28000 {
+   compatible = "renesas,vsp2";
+   reg = <0 0xfea28000 0 0x5000>;
+   interrupts = ;
+   clocks = < CPG_MOD 622>;
+   power-domains = < R8A77961_PD_ALWAYS_ON>;
+   resets = < 622>;
+
+   renesas,fcp = <>;
+   };
+
+   vspd2: vsp@fea3 {
+   compatible = "renesas,vsp2";
+   reg = <0 0xfea3 0 0x5000>;
+   interrupts = ;
+   clocks = < CPG_MOD 621>;
+   power-domains = < R8A77961_PD_ALWAYS_ON>;
+   resets = < 621>;
+
+   renesas,fcp = <>;
+   };
+
+   vspi0: vsp@fe9a {
+   compatible = "renesas,vsp2";
+   reg = <0 0xfe9a 0 0x8000>;
+   interrupts = ;
+   clocks = < CPG_MOD 631>;
+   power-domains = < R8A77961_PD_A3VC>;
+   resets = < 631>;
+
+   renesas,fcp = <>;
+   };
+
csi20: csi2@fea8 {
reg = <0 0xfea8 0 0x1>;
/* placeholder */
-- 
2.25.1

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


  1   2   >