Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dts: ov5647 Fix link frequency and media: i2c: ov5647: Add checks for link frequency #6431

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions arch/arm/boot/dts/overlays/ov5647.dtsi
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@ cam_node: ov5647@36 {
data-lanes = <1 2>;
clock-noncontinuous;
link-frequencies =
/bits/ 64 <297000000>;
/bits/ 64 <218500000 208333000>;
};
};
};

25 changes: 22 additions & 3 deletions drivers/media/i2c/ov5647.c
Original file line number Diff line number Diff line change
Expand Up @@ -1352,13 +1352,15 @@ static int ov5647_init_controls(struct ov5647 *sensor, struct device *dev)
return sensor->ctrls.error;
}

static int ov5647_parse_dt(struct ov5647 *sensor, struct device_node *np)
static int ov5647_parse_dt(struct device *dev,
struct ov5647 *sensor,
struct device_node *np)
{
struct v4l2_fwnode_endpoint bus_cfg = {
.bus_type = V4L2_MBUS_CSI2_DPHY,
};
struct device_node *ep;
int ret;
int ret = -EINVAL;

ep = of_graph_get_next_endpoint(np, NULL);
if (!ep)
Expand All @@ -1371,6 +1373,23 @@ static int ov5647_parse_dt(struct ov5647 *sensor, struct device_node *np)
sensor->clock_ncont = bus_cfg.bus.mipi_csi2.flags &
V4L2_MBUS_CSI2_NONCONTINUOUS_CLOCK;

if (!bus_cfg.nr_of_link_frequencies) {
dev_err(dev, "link-frequency property not found in DT\n");
goto out;
}

if (bus_cfg.nr_of_link_frequencies != ARRAY_SIZE(ov5647_link_freqs)) {
dev_err(dev, "Link frequency missing in dtree\n");
goto out;
}

for (int i = 0; i < ARRAY_SIZE(ov5647_link_freqs); i++) {
if (bus_cfg.link_frequencies[i] != ov5647_link_freqs[i]) {
dev_err(dev, "no supported link frequency found\n");
goto out;
}
}

out:
of_node_put(ep);

Expand All @@ -1391,7 +1410,7 @@ static int ov5647_probe(struct i2c_client *client)
return -ENOMEM;

if (IS_ENABLED(CONFIG_OF) && np) {
ret = ov5647_parse_dt(sensor, np);
ret = ov5647_parse_dt(dev, sensor, np);
if (ret) {
dev_err(dev, "DT parsing error: %d\n", ret);
return ret;
Expand Down