From: Atanas Filipov <atanas.filipov@oss.qualcomm.com>
To: djakov@kernel.org, bod@kernel.org, linux-pm@vger.kernel.org,
linux-media@vger.kernel.org
Cc: mchehab@kernel.org, andersson@kernel.org, konradybcio@kernel.org,
abelvesa@kernel.org, robh@kernel.org, krzk+dt@kernel.org,
conor+dt@kernel.org, loic.poulain@oss.qualcomm.com,
linux-arm-msm@vger.kernel.org, devicetree@vger.kernel.org,
linux-kernel@vger.kernel.org,
Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com>,
Prashant Shrotriya <pshrotri@qti.qualcomm.com>,
Vikram Sharma <vikram.sharma@oss.qualcomm.com>,
Gjorgji Rosikopulos <gjorgji.rosikopulos@oss.qualcomm.com>,
Atanas Filipov <atanas.filipov@oss.qualcomm.com>
Subject: [PATCH 04/10] media: qcom: cam-icc: add the Titan camera NoC driver
Date: Mon, 30 Nov 2026 12:49:49 +0200 [thread overview]
Message-ID: <20261130104955.1288089-5-atanas.filipov@oss.qualcomm.com> (raw)
In-Reply-To: <20261130104955.1288089-1-atanas.filipov@oss.qualcomm.com>
Add an interconnect provider for the Titan camera NoC. CAMSS blocks
vote bandwidth on their camera NoC port to DDR and on the camera AHB
path. The driver sets the camera NoC AXI and AHB clock rates from the
aggregated votes, and the rail level through an OPP table.
On every runtime resume the driver writes the static QoS settings and
enables the camera NoC error interrupt.
Signed-off-by: Atanas Filipov <atanas.filipov@oss.qualcomm.com>
---
drivers/media/platform/qcom/Kconfig | 1 +
drivers/media/platform/qcom/Makefile | 1 +
drivers/media/platform/qcom/cam-icc/Kconfig | 14 +
drivers/media/platform/qcom/cam-icc/Makefile | 4 +
.../platform/qcom/cam-icc/qcom-cam-icc-core.c | 635 ++++++++++++++++++
.../platform/qcom/cam-icc/qcom-cam-icc-core.h | 142 ++++
include/media/qcom-cam-icc.h | 26 +
7 files changed, 823 insertions(+)
create mode 100644 drivers/media/platform/qcom/cam-icc/Kconfig
create mode 100644 drivers/media/platform/qcom/cam-icc/Makefile
create mode 100644 drivers/media/platform/qcom/cam-icc/qcom-cam-icc-core.c
create mode 100644 drivers/media/platform/qcom/cam-icc/qcom-cam-icc-core.h
create mode 100644 include/media/qcom-cam-icc.h
diff --git a/drivers/media/platform/qcom/Kconfig b/drivers/media/platform/qcom/Kconfig
index 4f4d3a68e6e5..95ea812c4996 100644
--- a/drivers/media/platform/qcom/Kconfig
+++ b/drivers/media/platform/qcom/Kconfig
@@ -4,4 +4,5 @@ comment "Qualcomm media platform drivers"
source "drivers/media/platform/qcom/camss/Kconfig"
source "drivers/media/platform/qcom/iris/Kconfig"
+source "drivers/media/platform/qcom/cam-icc/Kconfig"
source "drivers/media/platform/qcom/venus/Kconfig"
diff --git a/drivers/media/platform/qcom/Makefile b/drivers/media/platform/qcom/Makefile
index ea2221a202c0..f5b95ba6dd98 100644
--- a/drivers/media/platform/qcom/Makefile
+++ b/drivers/media/platform/qcom/Makefile
@@ -1,4 +1,5 @@
# SPDX-License-Identifier: GPL-2.0-only
obj-y += camss/
obj-y += iris/
+obj-y += cam-icc/
obj-y += venus/
diff --git a/drivers/media/platform/qcom/cam-icc/Kconfig b/drivers/media/platform/qcom/cam-icc/Kconfig
new file mode 100644
index 000000000000..8fae973ce1b0
--- /dev/null
+++ b/drivers/media/platform/qcom/cam-icc/Kconfig
@@ -0,0 +1,14 @@
+# SPDX-License-Identifier: GPL-2.0-only
+config QCOM_CAM_ICC
+ tristate "Qualcomm Titan camera NoC core driver"
+ depends on ARCH_QCOM || COMPILE_TEST
+ depends on COMMON_CLK && PM
+ depends on INTERCONNECT
+ select PM_OPP
+ default ARCH_QCOM
+ help
+ Core driver for the camera NoC of Qualcomm SoCs. It manages the
+ camera NoC resources shared by the camera drivers (CAMSS).
+
+ To compile this driver as a module, choose M here: the module
+ will be called qcom-cam-icc.
diff --git a/drivers/media/platform/qcom/cam-icc/Makefile b/drivers/media/platform/qcom/cam-icc/Makefile
new file mode 100644
index 000000000000..4d1cbf60fea0
--- /dev/null
+++ b/drivers/media/platform/qcom/cam-icc/Makefile
@@ -0,0 +1,4 @@
+# SPDX-License-Identifier: GPL-2.0-only
+qcom-cam-icc-y := qcom-cam-icc-core.o
+
+obj-$(CONFIG_QCOM_CAM_ICC) += qcom-cam-icc.o
diff --git a/drivers/media/platform/qcom/cam-icc/qcom-cam-icc-core.c b/drivers/media/platform/qcom/cam-icc/qcom-cam-icc-core.c
new file mode 100644
index 000000000000..beb0ee0cad7a
--- /dev/null
+++ b/drivers/media/platform/qcom/cam-icc/qcom-cam-icc-core.c
@@ -0,0 +1,635 @@
+// SPDX-License-Identifier: GPL-2.0-only
+/*
+ * Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries.
+ */
+
+#include <linux/bitfield.h>
+#include <linux/bits.h>
+#include <linux/clk.h>
+#include <linux/device.h>
+#include <linux/err.h>
+#include <linux/interconnect-provider.h>
+#include <linux/interconnect.h>
+#include <linux/interrupt.h>
+#include <linux/io.h>
+#include <linux/math64.h>
+#include <linux/minmax.h>
+#include <linux/module.h>
+#include <linux/of.h>
+#include <linux/of_platform.h>
+#include <linux/platform_device.h>
+#include <linux/pm_domain.h>
+#include <linux/pm_opp.h>
+#include <linux/pm_runtime.h>
+#include <linux/property.h>
+#include <linux/slab.h>
+
+#include <media/qcom-cam-icc.h>
+
+#include "qcom-cam-icc-core.h"
+
+#define QCOM_CAM_ICC_MIN_BW_KBPS 3000000
+#define QCOM_CAM_ICC_BUS_WIDTH 32
+#define QCOM_CAM_ICC_MARGIN_PCT 20
+
+#define QCOM_CAM_ICC_ERL_MAINCTL 0x08
+#define QCOM_CAM_ICC_ERL_MAINCTL_STALL_EN BIT(0)
+#define QCOM_CAM_ICC_ERL_MAINCTL_FAULT_EN BIT(1)
+#define QCOM_CAM_ICC_ERL_ERRCLR 0x18
+#define QCOM_CAM_ICC_ERL_ERRLOG0 0x20
+#define QCOM_CAM_ICC_ERL_ERRLOG0_CODE GENMASK(10, 8)
+#define QCOM_CAM_ICC_ERL_ERRLOG1 0x28
+
+struct qcom_cam_icc {
+ struct device *dev;
+ const struct qcom_cam_icc_data *data;
+ void __iomem *base;
+ u32 irq_mask;
+ struct clk_bulk_data *clks;
+ int num_clks;
+ struct clk *axi_src;
+ struct clk *ahb_src;
+ struct icc_provider provider;
+ struct icc_onecell_data *icc_data;
+ u64 axi_rate;
+ const struct qcom_cam_icc_ahb_level *ahb_level;
+ struct dev_pm_domain_list *pd_list;
+ struct dev_pm_domain_list *rail_pd_list;
+ struct icc_path *cfg_path;
+ struct icc_path *hf_path;
+};
+
+static int qcom_cam_icc_icc_aggregate(struct icc_node *node, u32 tag, u32 avg_bw,
+ u32 peak_bw, u32 *agg_avg, u32 *agg_peak)
+{
+ const struct qcom_cam_icc_node *desc = node->data;
+
+ if (desc->merge == QCOM_CAM_ICC_MERGE_SUM_INTERLEAVE) {
+ avg_bw /= 2;
+ peak_bw /= 2;
+ }
+
+ *agg_avg += avg_bw;
+ *agg_peak = max(*agg_peak, peak_bw);
+
+ return 0;
+}
+
+static u64 qcom_cam_icc_axi_rate(struct qcom_cam_icc *camnoc)
+{
+ const struct qcom_cam_icc_data *data = camnoc->data;
+ u64 bw = 0;
+ size_t i;
+
+ for (i = 0; i < data->num_nodes; i++) {
+ const struct qcom_cam_icc_node *desc = &data->nodes[i];
+ struct icc_node *node = camnoc->icc_data->nodes[desc->id];
+
+ if (!desc->rate_node || !node)
+ continue;
+
+ bw = max_t(u64, bw, (u64)max(node->avg_bw, node->peak_bw) * desc->width_factor);
+ }
+
+ if (!bw)
+ return 0;
+
+ bw += div_u64(bw * QCOM_CAM_ICC_MARGIN_PCT, 100);
+ bw = max_t(u64, bw, QCOM_CAM_ICC_MIN_BW_KBPS);
+
+ return div_u64(bw * 1000, QCOM_CAM_ICC_BUS_WIDTH);
+}
+
+static int qcom_cam_icc_set_axi_rate(struct qcom_cam_icc *camnoc, u64 rate)
+{
+ unsigned long freq = rate;
+ struct dev_pm_opp *opp;
+ int ret;
+
+ if (!rate) {
+ ret = clk_set_rate_range(camnoc->axi_src, 0, ULONG_MAX);
+ if (ret)
+ return ret;
+
+ return dev_pm_opp_set_opp(camnoc->dev, NULL);
+ }
+
+ opp = dev_pm_opp_find_freq_ceil(camnoc->dev, &freq);
+ if (IS_ERR(opp))
+ opp = dev_pm_opp_find_freq_floor(camnoc->dev, &freq);
+ if (IS_ERR(opp))
+ return PTR_ERR(opp);
+
+ ret = dev_pm_opp_set_opp(camnoc->dev, opp);
+ dev_pm_opp_put(opp);
+
+ return ret;
+}
+
+static const struct qcom_cam_icc_ahb_level *
+qcom_cam_icc_ahb_level(struct qcom_cam_icc *camnoc, u32 peak)
+{
+ const struct qcom_cam_icc_data *data = camnoc->data;
+ size_t i;
+
+ if (!peak || !data->num_ahb_levels)
+ return NULL;
+
+ for (i = 0; i < data->num_ahb_levels; i++) {
+ if (data->ahb_levels[i].cfg_kbps >= peak)
+ return &data->ahb_levels[i];
+ }
+
+ return &data->ahb_levels[data->num_ahb_levels - 1];
+}
+
+static int qcom_cam_icc_update(struct qcom_cam_icc *camnoc)
+{
+ struct icc_node *ahb = camnoc->icc_data->nodes[camnoc->data->ahb_id];
+ const struct qcom_cam_icc_ahb_level *level;
+ unsigned long ahb_rate;
+ u64 rate;
+ int ret;
+
+ rate = qcom_cam_icc_axi_rate(camnoc);
+ level = qcom_cam_icc_ahb_level(camnoc, ahb ? ahb->peak_bw : 0);
+ if (rate == camnoc->axi_rate && level == camnoc->ahb_level)
+ return 0;
+
+ if (rate != camnoc->axi_rate) {
+ ret = qcom_cam_icc_set_axi_rate(camnoc, rate);
+ if (ret)
+ return ret;
+
+ camnoc->axi_rate = rate;
+ }
+
+ if (level != camnoc->ahb_level) {
+ ahb_rate = level ? level->slow_ahb_rate : 0;
+ ret = clk_set_rate_range(camnoc->ahb_src, ahb_rate, ULONG_MAX);
+ if (ret)
+ return ret;
+
+ camnoc->ahb_level = level;
+ }
+
+ dev_dbg(camnoc->dev, "request: camnoc axi %llu Hz, cfg %u kBps, slow ahb %lu Hz\n",
+ rate, level ? level->cfg_kbps : 0, level ? level->slow_ahb_rate : 0);
+
+ return 0;
+}
+
+static int qcom_cam_icc_icc_set(struct icc_node *src, struct icc_node *dst)
+{
+ struct qcom_cam_icc *camnoc = container_of(src->provider, struct qcom_cam_icc, provider);
+
+ return qcom_cam_icc_update(camnoc);
+}
+
+static int qcom_cam_icc_icc_get_bw(struct icc_node *node, u32 *avg, u32 *peak)
+{
+ *avg = 0;
+ *peak = 0;
+
+ return 0;
+}
+
+static int qcom_cam_icc_icc_link_path(struct qcom_cam_icc *camnoc,
+ struct icc_node *node, const char *path)
+{
+ struct device_node *np = camnoc->dev->of_node;
+ struct icc_node_data *link_data;
+ struct of_phandle_args args;
+ struct icc_node *link;
+ int idx, ret;
+
+ idx = of_property_match_string(np, "interconnect-names", path);
+ if (idx < 0)
+ return idx;
+
+ ret = of_parse_phandle_with_args(np, "interconnects", "#interconnect-cells", idx * 2,
+ &args);
+ if (ret)
+ return ret;
+
+ link_data = of_icc_get_from_provider(&args);
+ of_node_put(args.np);
+ if (IS_ERR(link_data))
+ return PTR_ERR(link_data);
+
+ link = link_data->node;
+ kfree(link_data);
+
+ return icc_link_nodes(node, &link);
+}
+
+static int qcom_cam_icc_icc_init(struct qcom_cam_icc *camnoc)
+{
+ const struct qcom_cam_icc_data *data = camnoc->data;
+ struct icc_provider *provider = &camnoc->provider;
+ struct icc_onecell_data *icc_data;
+ size_t i, j;
+ int ret;
+
+ icc_data = devm_kzalloc(camnoc->dev, struct_size(icc_data, nodes, data->num_ids),
+ GFP_KERNEL);
+ if (!icc_data)
+ return -ENOMEM;
+
+ icc_data->num_nodes = data->num_ids;
+ camnoc->icc_data = icc_data;
+
+ provider->dev = camnoc->dev;
+ provider->set = qcom_cam_icc_icc_set;
+ provider->aggregate = qcom_cam_icc_icc_aggregate;
+ provider->get_bw = qcom_cam_icc_icc_get_bw;
+ provider->xlate = of_icc_xlate_onecell;
+ provider->data = icc_data;
+ icc_provider_init(provider);
+
+ for (i = 0; i < data->num_nodes; i++) {
+ const struct qcom_cam_icc_node *desc = &data->nodes[i];
+ struct icc_node *node;
+
+ node = icc_node_create_dyn();
+ if (IS_ERR(node)) {
+ ret = PTR_ERR(node);
+ goto err_remove_nodes;
+ }
+
+ ret = icc_node_set_name(node, provider, desc->name);
+ if (ret) {
+ icc_node_destroy(node->id);
+ goto err_remove_nodes;
+ }
+
+ node->data = (void *)desc;
+ icc_data->nodes[desc->id] = node;
+ icc_node_add(node, provider);
+ }
+
+ for (i = 0; i < data->num_nodes; i++) {
+ const struct qcom_cam_icc_node *desc = &data->nodes[i];
+
+ for (j = 0; j < desc->num_links; j++) {
+ ret = icc_link_nodes(icc_data->nodes[desc->id],
+ &icc_data->nodes[desc->links[j]]);
+ if (ret)
+ goto err_remove_nodes;
+ }
+
+ if (desc->link_path) {
+ ret = qcom_cam_icc_icc_link_path(camnoc, icc_data->nodes[desc->id],
+ desc->link_path);
+ if (ret)
+ goto err_remove_nodes;
+ }
+ }
+
+ ret = icc_provider_register(provider);
+ if (ret)
+ goto err_remove_nodes;
+
+ return 0;
+
+err_remove_nodes:
+ icc_nodes_remove(provider);
+
+ return ret;
+}
+
+static void qcom_cam_icc_qos_init(struct qcom_cam_icc *camnoc)
+{
+ const struct qcom_cam_icc_data *data = camnoc->data;
+ size_t i;
+
+ for (i = 0; i < data->num_qos; i++)
+ writel(data->qos[i].value, camnoc->base + data->qos[i].offset);
+}
+
+static void qcom_cam_icc_irq_init(struct qcom_cam_icc *camnoc)
+{
+ const struct qcom_cam_icc_data *data = camnoc->data;
+ size_t i;
+
+ writel(data->sbm->clear_val, camnoc->base + data->sbm->clear_reg);
+
+ for (i = 0; i < data->num_irq_errs; i++) {
+ const struct qcom_cam_icc_irq_err *err = &data->irq_errs[i];
+
+ writel(1, camnoc->base + err->base + err->clear_off);
+ writel(err->enable_val, camnoc->base + err->base + err->enable_off);
+ }
+
+ if (data->erl) {
+ writel(1, camnoc->base + data->erl->base + QCOM_CAM_ICC_ERL_ERRCLR);
+ writel(QCOM_CAM_ICC_ERL_MAINCTL_STALL_EN | QCOM_CAM_ICC_ERL_MAINCTL_FAULT_EN,
+ camnoc->base + data->erl->base + QCOM_CAM_ICC_ERL_MAINCTL);
+ }
+
+ writel(camnoc->irq_mask, camnoc->base + data->sbm->enable_reg);
+}
+
+static void qcom_cam_icc_erl_handle(struct qcom_cam_icc *camnoc)
+{
+ void __iomem *erl = camnoc->base + camnoc->data->erl->base;
+ u32 log0 = readl(erl + QCOM_CAM_ICC_ERL_ERRLOG0);
+
+ dev_err_ratelimited(camnoc->dev, "slave error, code %lu, errlog0 %#x, errlog1 %#x\n",
+ FIELD_GET(QCOM_CAM_ICC_ERL_ERRLOG0_CODE, log0), log0,
+ readl(erl + QCOM_CAM_ICC_ERL_ERRLOG1));
+ writel(1, erl + QCOM_CAM_ICC_ERL_ERRCLR);
+}
+
+static irqreturn_t qcom_cam_icc_irq(int irq, void *dev_id)
+{
+ struct qcom_cam_icc *camnoc = dev_id;
+ const struct qcom_cam_icc_data *data = camnoc->data;
+ u32 status, pending, enable;
+ size_t i;
+
+ if (pm_runtime_get_if_active(camnoc->dev) <= 0)
+ return IRQ_NONE;
+
+ status = readl(camnoc->base + data->sbm->status_reg);
+ pending = status & camnoc->irq_mask;
+ if (!pending) {
+ pm_runtime_put(camnoc->dev);
+ return IRQ_NONE;
+ }
+
+ enable = readl(camnoc->base + data->sbm->enable_reg);
+ writel(enable & ~pending, camnoc->base + data->sbm->enable_reg);
+ writel(data->sbm->clear_val, camnoc->base + data->sbm->clear_reg);
+
+ if (data->erl && (pending & data->erl->sbm_mask))
+ qcom_cam_icc_erl_handle(camnoc);
+
+ for (i = 0; i < data->num_irq_errs; i++) {
+ const struct qcom_cam_icc_irq_err *err = &data->irq_errs[i];
+
+ if (!(pending & err->sbm_mask))
+ continue;
+
+ dev_err_ratelimited(camnoc->dev, "%s error, status %#x\n", err->name,
+ readl(camnoc->base + err->base + err->status_off));
+ writel(1, camnoc->base + err->base + err->clear_off);
+ }
+
+ pm_runtime_put(camnoc->dev);
+
+ return IRQ_HANDLED;
+}
+
+static int qcom_cam_icc_irq_request(struct platform_device *pdev, struct qcom_cam_icc *camnoc)
+{
+ const struct qcom_cam_icc_data *data = camnoc->data;
+ size_t i;
+ int irq;
+
+ for (i = 0; i < data->num_irq_errs; i++)
+ camnoc->irq_mask |= data->irq_errs[i].sbm_mask;
+
+ if (data->erl)
+ camnoc->irq_mask |= data->erl->sbm_mask;
+
+ irq = platform_get_irq(pdev, 0);
+ if (irq < 0)
+ return irq;
+
+ return devm_request_threaded_irq(camnoc->dev, irq, NULL, qcom_cam_icc_irq, IRQF_ONESHOT,
+ dev_name(camnoc->dev), camnoc);
+}
+
+static int qcom_cam_icc_runtime_suspend(struct device *dev)
+{
+ struct qcom_cam_icc *camnoc = dev_get_drvdata(dev);
+
+ clk_bulk_disable_unprepare(camnoc->num_clks, camnoc->clks);
+ icc_set_bw(camnoc->hf_path, 0, 0);
+
+ return icc_set_bw(camnoc->cfg_path, 0, 0);
+}
+
+static int qcom_cam_icc_runtime_resume(struct device *dev)
+{
+ struct qcom_cam_icc *camnoc = dev_get_drvdata(dev);
+ int ret;
+
+ ret = icc_set_bw(camnoc->cfg_path, 0, camnoc->data->ahb_levels[0].cfg_kbps);
+ if (ret)
+ return ret;
+
+ ret = icc_set_bw(camnoc->hf_path, 0, 1);
+ if (ret)
+ goto err_cfg;
+
+ ret = clk_bulk_prepare_enable(camnoc->num_clks, camnoc->clks);
+ if (ret)
+ goto err_cfg;
+
+ qcom_cam_icc_qos_init(camnoc);
+ qcom_cam_icc_irq_init(camnoc);
+
+ return 0;
+
+err_cfg:
+ icc_set_bw(camnoc->hf_path, 0, 0);
+ icc_set_bw(camnoc->cfg_path, 0, 0);
+
+ return ret;
+}
+
+static const struct dev_pm_ops qcom_cam_icc_pm_ops = {
+ SYSTEM_SLEEP_PM_OPS(pm_runtime_force_suspend, pm_runtime_force_resume)
+ RUNTIME_PM_OPS(qcom_cam_icc_runtime_suspend, qcom_cam_icc_runtime_resume, NULL)
+};
+
+static const char * const qcom_cam_icc_pd_names[] = { "top" };
+
+static const struct dev_pm_domain_attach_data qcom_cam_icc_pd_data = {
+ .pd_names = qcom_cam_icc_pd_names,
+ .num_pd_names = ARRAY_SIZE(qcom_cam_icc_pd_names),
+ .pd_flags = PD_FLAG_DEV_LINK_ON,
+};
+
+static int qcom_cam_icc_pd_init(struct qcom_cam_icc *camnoc)
+{
+ int ret;
+
+ ret = devm_pm_domain_attach_list(camnoc->dev, &qcom_cam_icc_pd_data, &camnoc->pd_list);
+ if (ret < 0)
+ return ret;
+
+ ret = devm_pm_domain_attach_list(camnoc->dev, camnoc->data->rail_pd_data,
+ &camnoc->rail_pd_list);
+ if (ret < 0)
+ return ret;
+
+ return 0;
+}
+
+static int qcom_cam_icc_config_clks(struct device *dev, struct opp_table *opp_table,
+ struct dev_pm_opp *opp, void *data, bool scaling_down)
+{
+ struct qcom_cam_icc *camnoc = dev_get_drvdata(dev);
+
+ return clk_set_rate_range(camnoc->axi_src, dev_pm_opp_get_freq(opp), ULONG_MAX);
+}
+
+static int qcom_cam_icc_opp_init(struct qcom_cam_icc *camnoc)
+{
+ struct dev_pm_opp_config config = {
+ .clk_names = (const char *[]){ camnoc->data->rate_clk, NULL },
+ .config_clks = qcom_cam_icc_config_clks,
+ };
+ int ret;
+
+ ret = devm_pm_opp_set_config(camnoc->dev, &config);
+ if (ret)
+ return ret;
+
+ return devm_pm_opp_of_add_table(camnoc->dev);
+}
+
+static const struct of_device_id qcom_cam_icc_of_match[] = {
+ { }
+};
+MODULE_DEVICE_TABLE(of, qcom_cam_icc_of_match);
+
+/**
+ * qcom_cam_icc_link() - link a camera NoC client to the camera NoC
+ * @client: client device with a camera NoC path in its "interconnects"
+ *
+ * Add a runtime PM device link from @client to the camera NoC, so that a
+ * runtime resume of @client resumes the camera NoC first.
+ *
+ * Return: 0 on success, -ENODEV if @client has no camera NoC path,
+ * -EPROBE_DEFER if the camera NoC driver is not bound yet, or another
+ * negative error code.
+ */
+int qcom_cam_icc_link(struct device *client)
+{
+ struct platform_device *pdev;
+ struct of_phandle_args args;
+ struct device_link *link;
+ int i;
+
+ for (i = 0; ; i++) {
+ if (of_parse_phandle_with_args(client->of_node, "interconnects",
+ "#interconnect-cells", i, &args))
+ return -ENODEV;
+
+ if (of_match_node(qcom_cam_icc_of_match, args.np))
+ break;
+
+ of_node_put(args.np);
+ }
+
+ pdev = of_find_device_by_node(args.np);
+ of_node_put(args.np);
+ if (!pdev)
+ return -EPROBE_DEFER;
+
+ if (!platform_get_drvdata(pdev)) {
+ put_device(&pdev->dev);
+ return -EPROBE_DEFER;
+ }
+
+ link = device_link_add(client, &pdev->dev,
+ DL_FLAG_PM_RUNTIME | DL_FLAG_AUTOREMOVE_CONSUMER);
+ put_device(&pdev->dev);
+
+ return link ? 0 : -EINVAL;
+}
+EXPORT_SYMBOL_GPL(qcom_cam_icc_link);
+
+static int qcom_cam_icc_probe(struct platform_device *pdev)
+{
+ struct device *dev = &pdev->dev;
+ struct qcom_cam_icc *camnoc;
+ int ret;
+
+ camnoc = devm_kzalloc(dev, sizeof(*camnoc), GFP_KERNEL);
+ if (!camnoc)
+ return -ENOMEM;
+
+ camnoc->dev = dev;
+ camnoc->data = device_get_match_data(dev);
+ if (!camnoc->data)
+ return -EINVAL;
+
+ camnoc->base = devm_platform_ioremap_resource(pdev, 0);
+ if (IS_ERR(camnoc->base))
+ return PTR_ERR(camnoc->base);
+
+ camnoc->num_clks = devm_clk_bulk_get_all(dev, &camnoc->clks);
+ if (camnoc->num_clks < 0)
+ return dev_err_probe(dev, camnoc->num_clks, "failed to get clocks\n");
+
+ camnoc->axi_src = devm_clk_get(dev, camnoc->data->rate_clk);
+ if (IS_ERR(camnoc->axi_src))
+ return dev_err_probe(dev, PTR_ERR(camnoc->axi_src), "no %s clock\n",
+ camnoc->data->rate_clk);
+
+ camnoc->ahb_src = devm_clk_get(dev, "slow_ahb_src");
+ if (IS_ERR(camnoc->ahb_src))
+ return dev_err_probe(dev, PTR_ERR(camnoc->ahb_src), "no slow_ahb_src clock\n");
+
+ camnoc->cfg_path = devm_of_icc_get(dev, "cfg");
+ if (IS_ERR(camnoc->cfg_path))
+ return dev_err_probe(dev, PTR_ERR(camnoc->cfg_path),
+ "failed to get the cfg path\n");
+
+ camnoc->hf_path = devm_of_icc_get(dev, "hf");
+ if (IS_ERR(camnoc->hf_path))
+ return dev_err_probe(dev, PTR_ERR(camnoc->hf_path),
+ "failed to get the hf path\n");
+
+ platform_set_drvdata(pdev, camnoc);
+
+ ret = qcom_cam_icc_pd_init(camnoc);
+ if (ret)
+ return dev_err_probe(dev, ret, "failed to attach the power domains\n");
+
+ ret = qcom_cam_icc_opp_init(camnoc);
+ if (ret)
+ return dev_err_probe(dev, ret, "failed to add the OPP table\n");
+
+ ret = devm_pm_runtime_enable(dev);
+ if (ret)
+ return ret;
+
+ ret = qcom_cam_icc_irq_request(pdev, camnoc);
+ if (ret)
+ return dev_err_probe(dev, ret, "failed to request the interrupt\n");
+
+ ret = qcom_cam_icc_icc_init(camnoc);
+ if (ret)
+ return dev_err_probe(dev, ret, "failed to register the interconnect provider\n");
+
+ return 0;
+}
+
+static void qcom_cam_icc_remove(struct platform_device *pdev)
+{
+ struct qcom_cam_icc *camnoc = platform_get_drvdata(pdev);
+
+ icc_provider_deregister(&camnoc->provider);
+ icc_nodes_remove(&camnoc->provider);
+}
+
+static struct platform_driver qcom_cam_icc_driver = {
+ .probe = qcom_cam_icc_probe,
+ .remove = qcom_cam_icc_remove,
+ .driver = {
+ .name = "qcom-cam-icc",
+ .of_match_table = qcom_cam_icc_of_match,
+ .pm = pm_ptr(&qcom_cam_icc_pm_ops),
+ .sync_state = icc_sync_state,
+ },
+};
+module_platform_driver(qcom_cam_icc_driver);
+
+MODULE_DESCRIPTION("Qualcomm Titan camera NoC core driver");
+MODULE_LICENSE("GPL");
diff --git a/drivers/media/platform/qcom/cam-icc/qcom-cam-icc-core.h b/drivers/media/platform/qcom/cam-icc/qcom-cam-icc-core.h
new file mode 100644
index 000000000000..0de2aff3fe95
--- /dev/null
+++ b/drivers/media/platform/qcom/cam-icc/qcom-cam-icc-core.h
@@ -0,0 +1,142 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+/*
+ * Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries.
+ */
+
+#ifndef __QCOM_CAM_ICC_H__
+#define __QCOM_CAM_ICC_H__
+
+#include <linux/types.h>
+
+struct dev_pm_domain_attach_data;
+
+#define QCOM_CAM_ICC_MAX_LINKS 1
+
+#define QCOM_CAM_ICC_PRIORITYLUT_LOW 0x30
+#define QCOM_CAM_ICC_PRIORITYLUT_HIGH 0x34
+#define QCOM_CAM_ICC_URGENCY_LOW 0x38
+#define QCOM_CAM_ICC_DANGERLUT_LOW 0x40
+#define QCOM_CAM_ICC_SAFELUT_LOW 0x48
+#define QCOM_CAM_ICC_MAINCTL_LOW 0x08
+#define QCOM_CAM_ICC_SHAPING_LOW 0x20
+#define QCOM_CAM_ICC_SHAPING_HIGH 0x24
+#define QCOM_CAM_ICC_DECERRSTATUS_LOW 0x110
+#define QCOM_CAM_ICC_DECERRCLR_LOW 0x118
+#define QCOM_CAM_ICC_DECERREN_LOW 0x120
+#define QCOM_CAM_ICC_ENCCTL_LOW 0x188
+#define QCOM_CAM_ICC_ENCERRSTATUS_LOW 0x190
+#define QCOM_CAM_ICC_ENCERRCLR_LOW 0x198
+#define QCOM_CAM_ICC_ENCERREN_LOW 0x1a0
+
+enum qcom_cam_icc_merge {
+ QCOM_CAM_ICC_MERGE_SUM,
+ QCOM_CAM_ICC_MERGE_SUM_INTERLEAVE,
+};
+
+struct qcom_cam_icc_node {
+ const char *name;
+ u16 id;
+ u16 num_links;
+ u16 links[QCOM_CAM_ICC_MAX_LINKS];
+ enum qcom_cam_icc_merge merge;
+ u8 width_factor;
+ bool rate_node;
+ const char *link_path;
+};
+
+struct qcom_cam_icc_ahb_level {
+ u32 cfg_kbps;
+ unsigned long slow_ahb_rate;
+};
+
+struct qcom_cam_icc_qos {
+ u32 offset;
+ u32 value;
+};
+
+struct qcom_cam_icc_sbm {
+ u32 enable_reg;
+ u32 status_reg;
+ u32 clear_reg;
+ u32 clear_val;
+};
+
+struct qcom_cam_icc_irq_err {
+ const char *name;
+ u32 sbm_mask;
+ u32 base;
+ u32 enable_off;
+ u32 enable_val;
+ u32 status_off;
+ u32 clear_off;
+};
+
+struct qcom_cam_icc_erl {
+ u32 base;
+ u32 sbm_mask;
+};
+
+struct qcom_cam_icc_data {
+ const char *rate_clk;
+ const struct qcom_cam_icc_node *nodes;
+ size_t num_nodes;
+ size_t num_ids;
+ const struct qcom_cam_icc_ahb_level *ahb_levels;
+ size_t num_ahb_levels;
+ u16 ahb_id;
+ const struct dev_pm_domain_attach_data *rail_pd_data;
+ const struct qcom_cam_icc_qos *qos;
+ size_t num_qos;
+ const struct qcom_cam_icc_sbm *sbm;
+ const struct qcom_cam_icc_irq_err *irq_errs;
+ size_t num_irq_errs;
+ const struct qcom_cam_icc_erl *erl;
+};
+
+#define CAMNOC_PORT(_id, _name, _link) \
+ { \
+ .name = _name, \
+ .id = _id, \
+ .num_links = 1, \
+ .links = { _link }, \
+ .merge = QCOM_CAM_ICC_MERGE_SUM, \
+ .width_factor = 1, \
+ .rate_node = true, \
+ }
+
+#define CAMNOC_INTERNAL(_id, _name, _link, _merge) \
+ { \
+ .name = _name, \
+ .id = _id, \
+ .num_links = 1, \
+ .links = { _link }, \
+ .merge = _merge, \
+ .width_factor = 1, \
+ .rate_node = true, \
+ }
+
+#define CAMNOC_LINK_SLAVE(_id, _name, _link_path) \
+ { \
+ .name = _name, \
+ .id = _id, \
+ .link_path = _link_path, \
+ }
+
+#define CAMNOC_QOS(_base, _reg, _value) \
+ { \
+ .offset = (_base) + QCOM_CAM_ICC_##_reg, \
+ .value = _value, \
+ }
+
+#define CAMNOC_IRQ_ERR(_name, _mask, _base, _type, _enable_val) \
+ { \
+ .name = _name, \
+ .sbm_mask = _mask, \
+ .base = _base, \
+ .enable_off = QCOM_CAM_ICC_##_type##ERREN_LOW, \
+ .enable_val = _enable_val, \
+ .status_off = QCOM_CAM_ICC_##_type##ERRSTATUS_LOW, \
+ .clear_off = QCOM_CAM_ICC_##_type##ERRCLR_LOW, \
+ }
+
+#endif
diff --git a/include/media/qcom-cam-icc.h b/include/media/qcom-cam-icc.h
new file mode 100644
index 000000000000..68c230687377
--- /dev/null
+++ b/include/media/qcom-cam-icc.h
@@ -0,0 +1,26 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+/*
+ * Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries.
+ */
+
+#ifndef __MEDIA_QCOM_CAM_ICC_H__
+#define __MEDIA_QCOM_CAM_ICC_H__
+
+#include <linux/errno.h>
+
+struct device;
+
+#if IS_ENABLED(CONFIG_QCOM_CAM_ICC)
+
+int qcom_cam_icc_link(struct device *client);
+
+#else
+
+static inline int qcom_cam_icc_link(struct device *client)
+{
+ return -ENODEV;
+}
+
+#endif
+
+#endif
--
2.25.1
next prev parent reply other threads:[~2026-11-30 10:50 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-30 10:49 [PATCH 00/10] Add the Qualcomm Titan camera NoC interconnect provider Atanas Filipov
2026-11-30 10:49 ` [PATCH 01/10] dt-bindings: interconnect: add the Qualcomm SM8250 Titan camera NoC Atanas Filipov
2026-11-30 10:49 ` [PATCH 02/10] dt-bindings: interconnect: add the Qualcomm SC7280 " Atanas Filipov
2026-11-30 10:49 ` [PATCH 03/10] dt-bindings: interconnect: add the Qualcomm SA8775P " Atanas Filipov
2026-11-30 10:49 ` Atanas Filipov [this message]
2026-11-30 12:16 ` [PATCH 04/10] media: qcom: cam-icc: add the Titan camera NoC driver Bryan O'Donoghue
2026-11-30 12:59 ` Atanas Filipov
2026-11-30 13:22 ` Gjorgji Rosikopulos (Consultant)
2026-11-30 15:22 ` Bryan O'Donoghue
2026-11-30 10:49 ` [PATCH 05/10] media: qcom: cam-icc: add the SM8250 data Atanas Filipov
2026-11-30 10:49 ` [PATCH 06/10] media: qcom: cam-icc: add the SC7280 data Atanas Filipov
2026-11-30 10:49 ` [PATCH 07/10] media: qcom: cam-icc: add the SA8775P data Atanas Filipov
2026-11-30 10:49 ` [PATCH 08/10] arm64: dts: qcom: sm8250: add the Titan camera NoC node Atanas Filipov
2026-11-30 10:49 ` [PATCH 09/10] arm64: dts: qcom: sc7280: " Atanas Filipov
2026-11-30 10:49 ` [PATCH 10/10] arm64: dts: qcom: sa8775p: " Atanas Filipov
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=20261130104955.1288089-5-atanas.filipov@oss.qualcomm.com \
--to=atanas.filipov@oss.qualcomm.com \
--cc=abelvesa@kernel.org \
--cc=andersson@kernel.org \
--cc=bod@kernel.org \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=djakov@kernel.org \
--cc=dmitry.baryshkov@oss.qualcomm.com \
--cc=gjorgji.rosikopulos@oss.qualcomm.com \
--cc=konradybcio@kernel.org \
--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=linux-pm@vger.kernel.org \
--cc=loic.poulain@oss.qualcomm.com \
--cc=mchehab@kernel.org \
--cc=pshrotri@qti.qualcomm.com \
--cc=robh@kernel.org \
--cc=vikram.sharma@oss.qualcomm.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®