From: George Neacsu via B4 Relay <devnull+geocausa.gmail.com@kernel.org>
To: Sakari Ailus <sakari.ailus@linux.intel.com>
Cc: Mauro Carvalho Chehab <mchehab@kernel.org>,
Rob Herring <robh@kernel.org>,
Krzysztof Kozlowski <krzk+dt@kernel.org>,
Conor Dooley <conor+dt@kernel.org>,
Sergey Lebedev <lsa.uz@pm.me>,
German Pablo Lindo <germanpapulindez@gmail.com>,
Bryan O'Donoghue <bod@kernel.org>,
linux-media@vger.kernel.org, devicetree@vger.kernel.org,
linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org,
George Neacsu <geocausa@gmail.com>
Subject: [PATCH v2 2/2] media: i2c: ov13858: Add device tree support
Date: Sun, 18 Oct 2026 22:10:22 +0100 [thread overview]
Message-ID: <20261018-ov13858-x1e-v2-2-cd35434cfcfe@gmail.com> (raw)
In-Reply-To: <20261018-ov13858-x1e-v2-0-cd35434cfcfe@gmail.com>
From: George Neacsu <geocausa@gmail.com>
Add an OF match table for OV13858 and parse its firmware endpoint at
probe time. Require a four-lane D-PHY endpoint and both link frequencies
used by the existing sensor modes.
v4l2_fwnode_endpoint_alloc_parse() returns -EPROBE_DEFER if a software
node endpoint has not been instantiated yet, preserving bridge-created
endpoint probe ordering.
Tested-by: Sergey Lebedev <lsa.uz@pm.me> # Surface Pro 11 (Intel)
Assisted-by: Claude:claude-opus-5-5
Assisted-by: ChatGPT:gpt-5.6-sol
Signed-off-by: George Neacsu <geocausa@gmail.com>
---
drivers/media/i2c/ov13858.c | 54 +++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 54 insertions(+)
diff --git a/drivers/media/i2c/ov13858.c b/drivers/media/i2c/ov13858.c
index 5d7b3c335d..2957124404 100644
--- a/drivers/media/i2c/ov13858.c
+++ b/drivers/media/i2c/ov13858.c
@@ -1765,6 +1765,49 @@ static const struct dev_pm_ops ov13858_pm_ops = {
RUNTIME_PM_OPS(ov13858_power_off, ov13858_power_on, NULL)
};
+static int ov13858_check_hwcfg(struct device *dev)
+{
+ struct v4l2_fwnode_endpoint bus_cfg = {
+ .bus_type = V4L2_MBUS_CSI2_DPHY
+ };
+ unsigned long link_freq_bitmap;
+ struct fwnode_handle *ep;
+ int ret;
+
+ ep = fwnode_graph_get_next_endpoint(dev_fwnode(dev), NULL);
+ ret = v4l2_fwnode_endpoint_alloc_parse(ep, &bus_cfg);
+ fwnode_handle_put(ep);
+ if (ret)
+ return dev_err_probe(dev, ret, "parsing endpoint failed\n");
+
+ if (bus_cfg.bus.mipi_csi2.num_data_lanes != 4) {
+ ret = dev_err_probe(dev, -EINVAL,
+ "%u data lanes are not supported, only 4\n",
+ bus_cfg.bus.mipi_csi2.num_data_lanes);
+ goto out;
+ }
+
+ /* The modes use both link frequencies, so both have to be allowed. */
+ ret = v4l2_link_freq_to_bitmap(dev, bus_cfg.link_frequencies,
+ bus_cfg.nr_of_link_frequencies,
+ link_freq_menu_items,
+ ARRAY_SIZE(link_freq_menu_items),
+ &link_freq_bitmap);
+ if (ret)
+ goto out;
+
+ if (link_freq_bitmap != GENMASK(ARRAY_SIZE(link_freq_menu_items) - 1, 0))
+ ret = dev_err_probe(dev, -EINVAL,
+ "link frequencies %lld and %lld are both needed\n",
+ link_freq_menu_items[0],
+ link_freq_menu_items[1]);
+
+out:
+ v4l2_fwnode_endpoint_free(&bus_cfg);
+
+ return ret;
+}
+
static int ov13858_probe(struct i2c_client *client)
{
struct ov13858 *ov13858;
@@ -1777,6 +1820,10 @@ static int ov13858_probe(struct i2c_client *client)
ov13858->dev = &client->dev;
+ ret = ov13858_check_hwcfg(ov13858->dev);
+ if (ret)
+ return ret;
+
ov13858->clk = devm_v4l2_sensor_clk_get(ov13858->dev, NULL);
if (IS_ERR(ov13858->clk))
return dev_err_probe(ov13858->dev, PTR_ERR(ov13858->clk),
@@ -1897,10 +1944,17 @@ static const struct acpi_device_id ov13858_acpi_ids[] = {
MODULE_DEVICE_TABLE(acpi, ov13858_acpi_ids);
#endif
+static const struct of_device_id ov13858_of_match[] = {
+ { .compatible = "ovti,ov13858" },
+ { /* sentinel */ }
+};
+MODULE_DEVICE_TABLE(of, ov13858_of_match);
+
static struct i2c_driver ov13858_i2c_driver = {
.driver = {
.name = "ov13858",
.acpi_match_table = ACPI_PTR(ov13858_acpi_ids),
+ .of_match_table = ov13858_of_match,
.pm = pm_ptr(&ov13858_pm_ops),
},
.probe = ov13858_probe,
--
2.53.0
next prev parent reply other threads:[~2026-10-18 21:10 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-18 21:10 [PATCH v2 0/2] media: ov13858: device tree support for the Surface Pro 11 (Snapdragon) George Neacsu via B4 Relay
2026-10-18 21:10 ` [PATCH v2 1/2] dt-bindings: media: i2c: Add OmniVision OV13858 George Neacsu via B4 Relay
2026-10-19 6:03 ` Krzysztof Kozlowski
2026-10-19 6:13 ` George Neacsu
2026-10-18 21:10 ` George Neacsu via B4 Relay [this message]
2026-10-19 5:43 ` [PATCH v2 0/2] media: ov13858: device tree support for the Surface Pro 11 (Snapdragon) Sergey Lebedev
2026-10-19 6:01 ` George Neacsu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261018-ov13858-x1e-v2-2-cd35434cfcfe@gmail.com \
--to=devnull+geocausa.gmail.com@kernel.org \
--cc=bod@kernel.org \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=geocausa@gmail.com \
--cc=germanpapulindez@gmail.com \
--cc=krzk+dt@kernel.org \
--cc=linux-arm-msm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=lsa.uz@pm.me \
--cc=mchehab@kernel.org \
--cc=robh@kernel.org \
--cc=sakari.ailus@linux.intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®