diff --git a/arch/arm/boot/dts/overlays/ov5647.dtsi b/arch/arm/boot/dts/overlays/ov5647.dtsi index 6455a191a394bf..b60a5e794b18a4 100644 --- a/arch/arm/boot/dts/overlays/ov5647.dtsi +++ b/arch/arm/boot/dts/overlays/ov5647.dtsi @@ -18,8 +18,7 @@ cam_node: ov5647@36 { data-lanes = <1 2>; clock-noncontinuous; link-frequencies = - /bits/ 64 <297000000>; + /bits/ 64 <218500000 208333000>; }; }; }; - diff --git a/drivers/media/i2c/ov5647.c b/drivers/media/i2c/ov5647.c index f474d22dbded94..4d90604eca8dc2 100644 --- a/drivers/media/i2c/ov5647.c +++ b/drivers/media/i2c/ov5647.c @@ -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) @@ -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); @@ -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;