Commit 6a18865d authored by Niklas Söderlund's avatar Niklas Söderlund Committed by Mauro Carvalho Chehab

media: i2c: adv748x: store number of CSI-2 lanes described in device tree

The adv748x CSI-2 transmitters TXA and TXB can use different number of
lanes to transmit data. In order to be able to configure the device
correctly this information need to be parsed from device tree and stored
in each TX private data structure.

TXA supports 1, 2 and 4 lanes while TXB supports 1 lane.
Signed-off-by: default avatarNiklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
Reviewed-by: default avatarJacopo Mondi <jacopo+renesas@jmondi.org>
Reviewed-by: default avatarLaurent Pinchart <laurent.pinchart@ideasonboard.com>
Tested-by: default avatarJacopo Mondi <jacopo+renesas@jmondi.org>
Signed-off-by: default avatarHans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab+samsung@kernel.org>
parent 90917bc8
...@@ -23,6 +23,7 @@ ...@@ -23,6 +23,7 @@
#include <media/v4l2-ctrls.h> #include <media/v4l2-ctrls.h>
#include <media/v4l2-device.h> #include <media/v4l2-device.h>
#include <media/v4l2-dv-timings.h> #include <media/v4l2-dv-timings.h>
#include <media/v4l2-fwnode.h>
#include <media/v4l2-ioctl.h> #include <media/v4l2-ioctl.h>
#include "adv748x.h" #include "adv748x.h"
...@@ -521,12 +522,56 @@ void adv748x_subdev_init(struct v4l2_subdev *sd, struct adv748x_state *state, ...@@ -521,12 +522,56 @@ void adv748x_subdev_init(struct v4l2_subdev *sd, struct adv748x_state *state,
sd->entity.ops = &adv748x_media_ops; sd->entity.ops = &adv748x_media_ops;
} }
static int adv748x_parse_csi2_lanes(struct adv748x_state *state,
unsigned int port,
struct device_node *ep)
{
struct v4l2_fwnode_endpoint vep;
unsigned int num_lanes;
int ret;
if (port != ADV748X_PORT_TXA && port != ADV748X_PORT_TXB)
return 0;
vep.bus_type = V4L2_MBUS_CSI2_DPHY;
ret = v4l2_fwnode_endpoint_parse(of_fwnode_handle(ep), &vep);
if (ret)
return ret;
num_lanes = vep.bus.mipi_csi2.num_data_lanes;
if (vep.base.port == ADV748X_PORT_TXA) {
if (num_lanes != 1 && num_lanes != 2 && num_lanes != 4) {
adv_err(state, "TXA: Invalid number (%u) of lanes\n",
num_lanes);
return -EINVAL;
}
state->txa.num_lanes = num_lanes;
adv_dbg(state, "TXA: using %u lanes\n", state->txa.num_lanes);
}
if (vep.base.port == ADV748X_PORT_TXB) {
if (num_lanes != 1) {
adv_err(state, "TXB: Invalid number (%u) of lanes\n",
num_lanes);
return -EINVAL;
}
state->txb.num_lanes = num_lanes;
adv_dbg(state, "TXB: using %u lanes\n", state->txb.num_lanes);
}
return 0;
}
static int adv748x_parse_dt(struct adv748x_state *state) static int adv748x_parse_dt(struct adv748x_state *state)
{ {
struct device_node *ep_np = NULL; struct device_node *ep_np = NULL;
struct of_endpoint ep; struct of_endpoint ep;
bool out_found = false; bool out_found = false;
bool in_found = false; bool in_found = false;
int ret;
for_each_endpoint_of_node(state->dev->of_node, ep_np) { for_each_endpoint_of_node(state->dev->of_node, ep_np) {
of_graph_parse_endpoint(ep_np, &ep); of_graph_parse_endpoint(ep_np, &ep);
...@@ -557,6 +602,11 @@ static int adv748x_parse_dt(struct adv748x_state *state) ...@@ -557,6 +602,11 @@ static int adv748x_parse_dt(struct adv748x_state *state)
in_found = true; in_found = true;
else else
out_found = true; out_found = true;
/* Store number of CSI-2 lanes used for TXA and TXB. */
ret = adv748x_parse_csi2_lanes(state, ep.port, ep_np);
if (ret)
return ret;
} }
return in_found && out_found ? 0 : -ENODEV; return in_found && out_found ? 0 : -ENODEV;
......
...@@ -79,6 +79,7 @@ struct adv748x_csi2 { ...@@ -79,6 +79,7 @@ struct adv748x_csi2 {
struct v4l2_mbus_framefmt format; struct v4l2_mbus_framefmt format;
unsigned int page; unsigned int page;
unsigned int port; unsigned int port;
unsigned int num_lanes;
struct media_pad pads[ADV748X_CSI2_NR_PADS]; struct media_pad pads[ADV748X_CSI2_NR_PADS];
struct v4l2_ctrl_handler ctrl_hdl; struct v4l2_ctrl_handler ctrl_hdl;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment