* [PATCH 0/2] rcar-csi2: Update how DT is traversed and parsed
@ 2020-09-14 21:50 Niklas Söderlund
2020-09-14 21:50 ` [PATCH 1/2] rcar-csi2: Switch to using fwnode instead of OF Niklas Söderlund
2020-09-14 21:50 ` [PATCH 2/2] rcar-csi2: Set bus type when parsing fwnode Niklas Söderlund
0 siblings, 2 replies; 7+ messages in thread
From: Niklas Söderlund @ 2020-09-14 21:50 UTC (permalink / raw)
To: linux-media; +Cc: linux-renesas-soc, Jacopo Mondi, Niklas Söderlund
Hi,
This series touches up how the R-Car CSI-2 driver traverse and parse DT
device nodes. Patch 1/2 switches to only use the fwnode interface and
2/2 specifies the bus type used for parsing.
This is done a preparation to later modify the rcar-vin driver in a
similar fashion to be able to drop the use of the
v4l2_async_notifier_parse_fwnode_endpoints_by_port() helper which I
understand is marked for deprecation. Therefore comments on the over all
solution of parsing DT here would be appreciated.
Niklas Söderlund (2):
rcar-csi2: Switch to using fwnode instead of OF
rcar-csi2: Set bus type when parsing fwnode
drivers/media/platform/rcar-vin/rcar-csi2.c | 18 ++++++++++--------
1 file changed, 10 insertions(+), 8 deletions(-)
--
2.28.0
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH 1/2] rcar-csi2: Switch to using fwnode instead of OF
2020-09-14 21:50 [PATCH 0/2] rcar-csi2: Update how DT is traversed and parsed Niklas Söderlund
@ 2020-09-14 21:50 ` Niklas Söderlund
2020-09-15 11:24 ` Jacopo Mondi
2020-09-14 21:50 ` [PATCH 2/2] rcar-csi2: Set bus type when parsing fwnode Niklas Söderlund
1 sibling, 1 reply; 7+ messages in thread
From: Niklas Söderlund @ 2020-09-14 21:50 UTC (permalink / raw)
To: linux-media; +Cc: linux-renesas-soc, Jacopo Mondi, Niklas Söderlund
Use the fwnode_graph_get_endpoint_by_id() interface instead of
of_graph_get_endpoint_by_regs() to fetch the fwnode. This saves
translating between a device_node and fwnode_handle.
Signed-off-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
---
drivers/media/platform/rcar-vin/rcar-csi2.c | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/drivers/media/platform/rcar-vin/rcar-csi2.c b/drivers/media/platform/rcar-vin/rcar-csi2.c
index 511cd4984777ad99..23e89ef2429d310a 100644
--- a/drivers/media/platform/rcar-vin/rcar-csi2.c
+++ b/drivers/media/platform/rcar-vin/rcar-csi2.c
@@ -873,31 +873,31 @@ static int rcsi2_parse_dt(struct rcar_csi2 *priv)
{
struct v4l2_async_subdev *asd;
struct fwnode_handle *fwnode;
- struct device_node *ep;
+ struct fwnode_handle *ep;
struct v4l2_fwnode_endpoint v4l2_ep = { .bus_type = 0 };
int ret;
- ep = of_graph_get_endpoint_by_regs(priv->dev->of_node, 0, 0);
+ ep = fwnode_graph_get_endpoint_by_id(dev_fwnode(priv->dev), 0, 0, 0);
if (!ep) {
dev_err(priv->dev, "Not connected to subdevice\n");
return -EINVAL;
}
- ret = v4l2_fwnode_endpoint_parse(of_fwnode_handle(ep), &v4l2_ep);
+ ret = v4l2_fwnode_endpoint_parse(ep, &v4l2_ep);
if (ret) {
dev_err(priv->dev, "Could not parse v4l2 endpoint\n");
- of_node_put(ep);
+ fwnode_handle_put(ep);
return -EINVAL;
}
ret = rcsi2_parse_v4l2(priv, &v4l2_ep);
if (ret) {
- of_node_put(ep);
+ fwnode_handle_put(ep);
return ret;
}
- fwnode = fwnode_graph_get_remote_endpoint(of_fwnode_handle(ep));
- of_node_put(ep);
+ fwnode = fwnode_graph_get_remote_endpoint(ep);
+ fwnode_handle_put(ep);
dev_dbg(priv->dev, "Found '%pOF'\n", to_of_node(fwnode));
--
2.28.0
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH 2/2] rcar-csi2: Set bus type when parsing fwnode
2020-09-14 21:50 [PATCH 0/2] rcar-csi2: Update how DT is traversed and parsed Niklas Söderlund
2020-09-14 21:50 ` [PATCH 1/2] rcar-csi2: Switch to using fwnode instead of OF Niklas Söderlund
@ 2020-09-14 21:50 ` Niklas Söderlund
2020-09-15 11:27 ` Jacopo Mondi
1 sibling, 1 reply; 7+ messages in thread
From: Niklas Söderlund @ 2020-09-14 21:50 UTC (permalink / raw)
To: linux-media; +Cc: linux-renesas-soc, Jacopo Mondi, Niklas Söderlund
The only supported bus for the R-Car CSI-2 driver is CSI-2 DPHY, specify
this before parsing the fwnode.
Signed-off-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
---
drivers/media/platform/rcar-vin/rcar-csi2.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/drivers/media/platform/rcar-vin/rcar-csi2.c b/drivers/media/platform/rcar-vin/rcar-csi2.c
index 23e89ef2429d310a..b2e58f51b94fccd7 100644
--- a/drivers/media/platform/rcar-vin/rcar-csi2.c
+++ b/drivers/media/platform/rcar-vin/rcar-csi2.c
@@ -874,7 +874,9 @@ static int rcsi2_parse_dt(struct rcar_csi2 *priv)
struct v4l2_async_subdev *asd;
struct fwnode_handle *fwnode;
struct fwnode_handle *ep;
- struct v4l2_fwnode_endpoint v4l2_ep = { .bus_type = 0 };
+ struct v4l2_fwnode_endpoint v4l2_ep = {
+ .bus_type = V4L2_MBUS_CSI2_DPHY
+ };
int ret;
ep = fwnode_graph_get_endpoint_by_id(dev_fwnode(priv->dev), 0, 0, 0);
--
2.28.0
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH 1/2] rcar-csi2: Switch to using fwnode instead of OF
2020-09-14 21:50 ` [PATCH 1/2] rcar-csi2: Switch to using fwnode instead of OF Niklas Söderlund
@ 2020-09-15 11:24 ` Jacopo Mondi
0 siblings, 0 replies; 7+ messages in thread
From: Jacopo Mondi @ 2020-09-15 11:24 UTC (permalink / raw)
To: Niklas Söderlund; +Cc: linux-media, linux-renesas-soc
Hi Niklas,
On Mon, Sep 14, 2020 at 11:50:10PM +0200, Niklas Söderlund wrote:
> Use the fwnode_graph_get_endpoint_by_id() interface instead of
> of_graph_get_endpoint_by_regs() to fetch the fwnode. This saves
> translating between a device_node and fwnode_handle.
>
> Signed-off-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
Looks good
Reviewed-by: Jacopo Mondi <jacopo+renesas@jmondi.org>
Thanks
j
> ---
> drivers/media/platform/rcar-vin/rcar-csi2.c | 14 +++++++-------
> 1 file changed, 7 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/media/platform/rcar-vin/rcar-csi2.c b/drivers/media/platform/rcar-vin/rcar-csi2.c
> index 511cd4984777ad99..23e89ef2429d310a 100644
> --- a/drivers/media/platform/rcar-vin/rcar-csi2.c
> +++ b/drivers/media/platform/rcar-vin/rcar-csi2.c
> @@ -873,31 +873,31 @@ static int rcsi2_parse_dt(struct rcar_csi2 *priv)
> {
> struct v4l2_async_subdev *asd;
> struct fwnode_handle *fwnode;
> - struct device_node *ep;
> + struct fwnode_handle *ep;
> struct v4l2_fwnode_endpoint v4l2_ep = { .bus_type = 0 };
> int ret;
>
> - ep = of_graph_get_endpoint_by_regs(priv->dev->of_node, 0, 0);
> + ep = fwnode_graph_get_endpoint_by_id(dev_fwnode(priv->dev), 0, 0, 0);
> if (!ep) {
> dev_err(priv->dev, "Not connected to subdevice\n");
> return -EINVAL;
> }
>
> - ret = v4l2_fwnode_endpoint_parse(of_fwnode_handle(ep), &v4l2_ep);
> + ret = v4l2_fwnode_endpoint_parse(ep, &v4l2_ep);
> if (ret) {
> dev_err(priv->dev, "Could not parse v4l2 endpoint\n");
> - of_node_put(ep);
> + fwnode_handle_put(ep);
> return -EINVAL;
> }
>
> ret = rcsi2_parse_v4l2(priv, &v4l2_ep);
> if (ret) {
> - of_node_put(ep);
> + fwnode_handle_put(ep);
> return ret;
> }
>
> - fwnode = fwnode_graph_get_remote_endpoint(of_fwnode_handle(ep));
> - of_node_put(ep);
> + fwnode = fwnode_graph_get_remote_endpoint(ep);
> + fwnode_handle_put(ep);
>
> dev_dbg(priv->dev, "Found '%pOF'\n", to_of_node(fwnode));
>
> --
> 2.28.0
>
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 2/2] rcar-csi2: Set bus type when parsing fwnode
2020-09-14 21:50 ` [PATCH 2/2] rcar-csi2: Set bus type when parsing fwnode Niklas Söderlund
@ 2020-09-15 11:27 ` Jacopo Mondi
2020-10-02 21:21 ` Sakari Ailus
0 siblings, 1 reply; 7+ messages in thread
From: Jacopo Mondi @ 2020-09-15 11:27 UTC (permalink / raw)
To: Niklas Söderlund; +Cc: linux-media, linux-renesas-soc
Hi Niklas,
On Mon, Sep 14, 2020 at 11:50:11PM +0200, Niklas Söderlund wrote:
> The only supported bus for the R-Car CSI-2 driver is CSI-2 DPHY, specify
> this before parsing the fwnode.
>
> Signed-off-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
> ---
> drivers/media/platform/rcar-vin/rcar-csi2.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/media/platform/rcar-vin/rcar-csi2.c b/drivers/media/platform/rcar-vin/rcar-csi2.c
> index 23e89ef2429d310a..b2e58f51b94fccd7 100644
> --- a/drivers/media/platform/rcar-vin/rcar-csi2.c
> +++ b/drivers/media/platform/rcar-vin/rcar-csi2.c
> @@ -874,7 +874,9 @@ static int rcsi2_parse_dt(struct rcar_csi2 *priv)
> struct v4l2_async_subdev *asd;
> struct fwnode_handle *fwnode;
> struct fwnode_handle *ep;
> - struct v4l2_fwnode_endpoint v4l2_ep = { .bus_type = 0 };
> + struct v4l2_fwnode_endpoint v4l2_ep = {
> + .bus_type = V4L2_MBUS_CSI2_DPHY
> + };
I would also take the occasion to make bus-type mandatory in
bindings as v4l2_fwnode_endpoint_parse() will fail only if it detect a
mismatch between bus_type and "bus-type".
For older DTS we won't detect mismatches, but that's not worse than
what we have today.
In case you update bindings I would update the error message in the
v4l2_fwnode_endpoint_parse() failure path to report the mismatch.
The patch itself is good
Reviewed-by: Jacopo Mondi <jacopo+renesas@jmondi.org>
Thanks
j
> int ret;
>
> ep = fwnode_graph_get_endpoint_by_id(dev_fwnode(priv->dev), 0, 0, 0);
> --
> 2.28.0
>
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 2/2] rcar-csi2: Set bus type when parsing fwnode
2020-09-15 11:27 ` Jacopo Mondi
@ 2020-10-02 21:21 ` Sakari Ailus
2020-10-05 8:19 ` Jacopo Mondi
0 siblings, 1 reply; 7+ messages in thread
From: Sakari Ailus @ 2020-10-02 21:21 UTC (permalink / raw)
To: Jacopo Mondi; +Cc: Niklas Söderlund, linux-media, linux-renesas-soc
Hi Jacopo,
On Tue, Sep 15, 2020 at 01:27:52PM +0200, Jacopo Mondi wrote:
> Hi Niklas,
>
> On Mon, Sep 14, 2020 at 11:50:11PM +0200, Niklas Söderlund wrote:
> > The only supported bus for the R-Car CSI-2 driver is CSI-2 DPHY, specify
> > this before parsing the fwnode.
> >
> > Signed-off-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
> > ---
> > drivers/media/platform/rcar-vin/rcar-csi2.c | 4 +++-
> > 1 file changed, 3 insertions(+), 1 deletion(-)
> >
> > diff --git a/drivers/media/platform/rcar-vin/rcar-csi2.c b/drivers/media/platform/rcar-vin/rcar-csi2.c
> > index 23e89ef2429d310a..b2e58f51b94fccd7 100644
> > --- a/drivers/media/platform/rcar-vin/rcar-csi2.c
> > +++ b/drivers/media/platform/rcar-vin/rcar-csi2.c
> > @@ -874,7 +874,9 @@ static int rcsi2_parse_dt(struct rcar_csi2 *priv)
> > struct v4l2_async_subdev *asd;
> > struct fwnode_handle *fwnode;
> > struct fwnode_handle *ep;
> > - struct v4l2_fwnode_endpoint v4l2_ep = { .bus_type = 0 };
> > + struct v4l2_fwnode_endpoint v4l2_ep = {
> > + .bus_type = V4L2_MBUS_CSI2_DPHY
> > + };
>
> I would also take the occasion to make bus-type mandatory in
> bindings as v4l2_fwnode_endpoint_parse() will fail only if it detect a
> mismatch between bus_type and "bus-type".
You don't really need bus-type property if the hardware supports a single
type. Then you can, as above, parse the endpoint with that type set by the
caller.
--
Sakari Ailus
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 2/2] rcar-csi2: Set bus type when parsing fwnode
2020-10-02 21:21 ` Sakari Ailus
@ 2020-10-05 8:19 ` Jacopo Mondi
0 siblings, 0 replies; 7+ messages in thread
From: Jacopo Mondi @ 2020-10-05 8:19 UTC (permalink / raw)
To: Sakari Ailus; +Cc: Niklas Söderlund, linux-media, linux-renesas-soc
Hi Sakari,
On Sat, Oct 03, 2020 at 12:21:03AM +0300, Sakari Ailus wrote:
> Hi Jacopo,
>
> On Tue, Sep 15, 2020 at 01:27:52PM +0200, Jacopo Mondi wrote:
> > Hi Niklas,
> >
> > On Mon, Sep 14, 2020 at 11:50:11PM +0200, Niklas Söderlund wrote:
> > > The only supported bus for the R-Car CSI-2 driver is CSI-2 DPHY, specify
> > > this before parsing the fwnode.
> > >
> > > Signed-off-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
> > > ---
> > > drivers/media/platform/rcar-vin/rcar-csi2.c | 4 +++-
> > > 1 file changed, 3 insertions(+), 1 deletion(-)
> > >
> > > diff --git a/drivers/media/platform/rcar-vin/rcar-csi2.c b/drivers/media/platform/rcar-vin/rcar-csi2.c
> > > index 23e89ef2429d310a..b2e58f51b94fccd7 100644
> > > --- a/drivers/media/platform/rcar-vin/rcar-csi2.c
> > > +++ b/drivers/media/platform/rcar-vin/rcar-csi2.c
> > > @@ -874,7 +874,9 @@ static int rcsi2_parse_dt(struct rcar_csi2 *priv)
> > > struct v4l2_async_subdev *asd;
> > > struct fwnode_handle *fwnode;
> > > struct fwnode_handle *ep;
> > > - struct v4l2_fwnode_endpoint v4l2_ep = { .bus_type = 0 };
> > > + struct v4l2_fwnode_endpoint v4l2_ep = {
> > > + .bus_type = V4L2_MBUS_CSI2_DPHY
> > > + };
> >
> > I would also take the occasion to make bus-type mandatory in
> > bindings as v4l2_fwnode_endpoint_parse() will fail only if it detect a
> > mismatch between bus_type and "bus-type".
>
> You don't really need bus-type property if the hardware supports a single
> type. Then you can, as above, parse the endpoint with that type set by the
> caller.
Ok, that's a bit confusing as if there's no bus-type property no
bus mismatch could ever be detected, not at run-time by the v4l2-fwnode
framework, nor by DTS validation. Of course, the chances that a DTS for a
device that only supports CSI-2 specifies (in example) parallel bus
properties are quite low, so I'm fine with the way things are.
>
> --
> Sakari Ailus
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2020-10-05 8:22 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-14 21:50 [PATCH 0/2] rcar-csi2: Update how DT is traversed and parsed Niklas Söderlund
2020-09-14 21:50 ` [PATCH 1/2] rcar-csi2: Switch to using fwnode instead of OF Niklas Söderlund
2020-09-15 11:24 ` Jacopo Mondi
2020-09-14 21:50 ` [PATCH 2/2] rcar-csi2: Set bus type when parsing fwnode Niklas Söderlund
2020-09-15 11:27 ` Jacopo Mondi
2020-10-02 21:21 ` Sakari Ailus
2020-10-05 8:19 ` Jacopo Mondi
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.