From: Georgi Djakov <djakov@kernel.org>
To: Atanas Filipov <atanas.filipov@oss.qualcomm.com>,
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>
Subject: Re: [PATCH v2 04/10] media: qcom: cam-icc: add the Titan camera NoC driver
Date: Fri, 4 Dec 2026 14:25:27 +0200 [thread overview]
Message-ID: <bf1acd88-83bf-4c33-aa81-d38ac66285b8@kernel.org> (raw)
In-Reply-To: <20261204075339.4077387-5-atanas.filipov@oss.qualcomm.com>
Hi Atanas,
On 12/4/26 9:53 AM, Atanas Filipov wrote:
> 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 | 670 ++++++++++++++++++
> .../platform/qcom/cam-icc/qcom-cam-icc-core.h | 127 ++++
> include/media/qcom-cam-icc.h | 26 +
> 7 files changed, 843 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
>
This is an interconnect provider with bindings under bindings/interconnect/, but
you put it in drivers/media/platform/qcom/, why? Maybe you should move it to
drivers/interconnect/qcom/
> 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
[..]
> +++ b/drivers/media/platform/qcom/cam-icc/qcom-cam-icc-core.c
> @@ -0,0 +1,670 @@
> +// 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
Why is this 3GB/s floor? Why not use kBps_to_icc() or MBps_to_icc() etc?
> +#define QCOM_CAM_ICC_BUS_WIDTH 32
> +#define QCOM_CAM_ICC_MARGIN_PCT 20
Please explain this 20% margin? Is it an arbitrary number?
> +#define QCOM_CAM_ICC_CFG_KBPS 76800
> +#define QCOM_CAM_ICC_AHB_RATE 80000000
> +/* Set minimum bandwidth required to keep data path functional */
> +#define QCOM_CAM_ICC_HF_MIN_KBPS 1
What actually needs the MM NoC up while the camera NoC is resumed - maybe the
QoS writes? The "SF" path gets no such vote?
> +
> +#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;
> + int irq;
> + u32 irq_mask;
> + struct clk_bulk_data *clks;
> + int num_clks;
> + struct clk *axi_clk;
> + struct clk *ahb_clk;
> + struct icc_provider provider;
> + struct icc_onecell_data *icc_data;
> + u64 axi_rate;
> + unsigned long ahb_rate;
> + 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;
> + }
Please explain this aggregation policy. With one or two equal clients behind an
internal node, the un-halved port value wins. Looks like halving only matters from
three clients up. Is that the intended behavior?
> +
> + *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, max(node->avg_bw, node->peak_bw));
> + }
> +
> + 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 = min_t(u64, rate, ULONG_MAX);
> + struct dev_pm_opp *opp;
> + int ret;
> +
> + if (!rate) {
> + ret = clk_set_min_rate(camnoc->axi_clk, 0);
> + if (ret)
> + return ret;
> +
> + ret = clk_set_rate(camnoc->axi_clk, 0);
> + 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;
> +}
Have you tried to run this with a real client and PROVE_LOCKING enabled?
> +
> +static int qcom_cam_icc_update(struct qcom_cam_icc *camnoc)
> +{
> + struct icc_node *ahb = camnoc->icc_data->nodes[camnoc->data->ahb_id];
> + unsigned long ahb_rate;
> + u64 rate;
> + int ret;
> +
> + rate = qcom_cam_icc_axi_rate(camnoc);
> + ahb_rate = (ahb && (ahb->avg_bw || ahb->peak_bw)) ? QCOM_CAM_ICC_AHB_RATE : 0;
> + if (rate == camnoc->axi_rate && ahb_rate == camnoc->ahb_rate)
> + 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 (ahb_rate != camnoc->ahb_rate) {
> + ret = clk_set_min_rate(camnoc->ahb_clk, ahb_rate);
> + if (ret)
> + return ret;
> +
> + ret = clk_set_rate(camnoc->ahb_clk, ahb_rate);
> + if (ret)
> + return ret;
This will leave the AXI rate applied and cached if the AHB step fails?
> +
> + camnoc->ahb_rate = ahb_rate;
> + }
> +
> + dev_dbg(camnoc->dev, "axi %llu Hz, cpas_ahb %lu Hz\n", rate, ahb_rate);
> +
> + 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 struct icc_node_data *qcom_cam_icc_xlate(const struct of_phandle_args *spec, void *data)
> +{
> + struct icc_node_data *ndata;
> + struct icc_node *node;
> +
> + node = of_icc_xlate_onecell(spec, data);
> + if (IS_ERR(node))
> + return ERR_CAST(node);
> +
> + ndata = kzalloc_obj(*ndata);
> + if (!ndata)
> + return ERR_PTR(-ENOMEM);
> +
> + ndata->node = node;
> + ndata->tag = spec->args[1];
> +
> + return ndata;
> +}
Looks like a copy of the existing qcom_icc_xlate_extended()
> +
> +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;
> + 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_extended = qcom_cam_icc_xlate;
Why not use qcom_icc_xlate_extended() ?
> + 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];
> +
> + if (desc->link_path)
> + ret = qcom_cam_icc_icc_link_path(camnoc, icc_data->nodes[desc->id],
> + desc->link_path);
> + else
> + ret = icc_link_nodes(icc_data->nodes[desc->id],
> + &icc_data->nodes[desc->link]);
> + 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);
> +
We dereference data->sbm unconditionally while err_logger is optional. Maybe make it
consistent?
> + 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->err_logger) {
> + writel(1, camnoc->base + data->err_logger->base + QCOM_CAM_ICC_ERL_ERRCLR);
> + writel(QCOM_CAM_ICC_ERL_MAINCTL_STALL_EN | QCOM_CAM_ICC_ERL_MAINCTL_FAULT_EN,
> + camnoc->base + data->err_logger->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->err_logger->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;
> + 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;
> + }
> +
> + if (data->err_logger && (pending & data->err_logger->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);
> + }
> +
> + writel(data->sbm->clear_val, camnoc->base + data->sbm->clear_reg);
> +
> + 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->err_logger)
> + camnoc->irq_mask |= data->err_logger->sbm_mask;
> +
> + irq = platform_get_irq(pdev, 0);
> + if (irq < 0)
> + return irq;
> +
> + camnoc->irq = 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);
> + icc_set_bw(camnoc->cfg_path, 0, 0);
> +
> + return 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, QCOM_CAM_ICC_CFG_KBPS);
> + if (ret)
> + return ret;
> +
> + ret = icc_set_bw(camnoc->hf_path, 0, QCOM_CAM_ICC_HF_MIN_KBPS);
> + 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 int qcom_cam_icc_suspend(struct device *dev)
> +{
> + struct qcom_cam_icc *camnoc = dev_get_drvdata(dev);
> + int ret;
> +
> + disable_irq(camnoc->irq);
> +
> + ret = pm_runtime_force_suspend(dev);
> + if (ret)
> + enable_irq(camnoc->irq);
> +
> + return ret;
> +}
> +
> +static int qcom_cam_icc_resume(struct device *dev)
> +{
> + struct qcom_cam_icc *camnoc = dev_get_drvdata(dev);
> + int ret;
> +
> + ret = pm_runtime_force_resume(dev);
> + if (ret)
> + return ret;
> +
> + enable_irq(camnoc->irq);
> +
> + return 0;
> +}
> +
> +static const struct dev_pm_ops qcom_cam_icc_pm_ops = {
> + SYSTEM_SLEEP_PM_OPS(qcom_cam_icc_suspend, qcom_cam_icc_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),
> +};
> +
> +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);
> + unsigned long freq = dev_pm_opp_get_freq(opp);
> + int ret;
> +
> + ret = clk_set_min_rate(camnoc->axi_clk, freq);
> + if (ret)
> + return ret;
> +
> + return clk_set_rate(camnoc->axi_clk, freq);
> +}
> +
> +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. @client must get
> + * its camera NoC interconnect path before this call.
> + *
> + * Return: 0 on success, -ENODEV if @client has no camera NoC path,
> + * -EPROBE_DEFER if the camera NoC device is not created 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;
> +
> + 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);
This is exported, but i see no user?
> +
> +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);
Should we check for NULL here?
> +
> + 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_clk = devm_clk_get(dev, camnoc->data->rate_clk);
> + if (IS_ERR(camnoc->axi_clk))
> + return dev_err_probe(dev, PTR_ERR(camnoc->axi_clk), "no %s clock\n",
> + camnoc->data->rate_clk);
> +
> + camnoc->ahb_clk = devm_clk_get(dev, "cpas_ahb");
> + if (IS_ERR(camnoc->ahb_clk))
> + return dev_err_probe(dev, PTR_ERR(camnoc->ahb_clk), "no cpas_ahb 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 = qcom_cam_icc_irq_request(pdev, camnoc);
> + if (ret)
> + return dev_err_probe(dev, ret, "failed to request the interrupt\n");
> +
> + ret = devm_pm_runtime_enable(dev);
> + if (ret)
> + return ret;
> +
> + 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..eee7eb9c4c2d
> --- /dev/null
> +++ b/drivers/media/platform/qcom/cam-icc/qcom-cam-icc-core.h
> @@ -0,0 +1,127 @@
> +/* SPDX-License-Identifier: GPL-2.0-only */
> +/*
> + * Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries.
> + */
> +
> +#ifndef __QCOM_CAM_ICC_CORE_H__
> +#define __QCOM_CAM_ICC_CORE_H__
> +
> +#include <linux/types.h>
> +
> +struct dev_pm_domain_attach_data;
> +
> +#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
I don't see where all these are used? Please remove what is unused.
> +
> +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 link;
> + enum qcom_cam_icc_merge merge;
> + bool rate_node;
> + const char *link_path;
> +};
> +
> +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;
> + 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 *err_logger;
> +};
> +
> +#define CAMNOC_PORT(_id, _name, _link) \
> + { \
> + .name = _name, \
> + .id = _id, \
> + .link = _link, \
> + .merge = QCOM_CAM_ICC_MERGE_SUM, \
> + .rate_node = true, \
> + }
> +
> +#define CAMNOC_INTERNAL(_id, _name, _link, _merge) \
> + { \
> + .name = _name, \
> + .id = _id, \
> + .link = _link, \
> + .merge = _merge, \
> + .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)
I would expect that with a tristate and an IS_ENABLED() stub, a built-in client
against a modular provider will fail to link. Is this a possible scenario?
> +
> +int qcom_cam_icc_link(struct device *client);
> +
> +#else
> +
> +static inline int qcom_cam_icc_link(struct device *client)
> +{
> + return -ENODEV;
> +}
> +
> +#endif
> +
> +#endif
Thanks,
Georgi
next prev parent reply other threads:[~2026-12-04 12:25 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-04 7:53 [PATCH v2 00/10] Add the Qualcomm Titan camera NoC interconnect provider Atanas Filipov
2026-12-04 7:53 ` [PATCH v2 01/10] dt-bindings: interconnect: add the Qualcomm SM8250 Titan camera NoC Atanas Filipov
2026-12-04 8:01 ` sashiko-bot
2026-12-04 7:53 ` [PATCH v2 02/10] dt-bindings: interconnect: add the Qualcomm SC7280 " Atanas Filipov
2026-12-04 8:04 ` sashiko-bot
2026-12-04 11:10 ` Bryan O'Donoghue
2026-12-04 7:53 ` [PATCH v2 03/10] dt-bindings: interconnect: add the Qualcomm SA8775P " Atanas Filipov
2026-12-04 8:04 ` sashiko-bot
2026-12-04 11:14 ` Bryan O'Donoghue
2026-12-04 7:53 ` [PATCH v2 04/10] media: qcom: cam-icc: add the Titan camera NoC driver Atanas Filipov
2026-12-04 8:27 ` sashiko-bot
2026-12-04 11:33 ` Bryan O'Donoghue
2026-12-04 12:25 ` Georgi Djakov [this message]
2026-12-04 7:53 ` [PATCH v2 05/10] media: qcom: cam-icc: add the SM8250 data Atanas Filipov
2026-12-04 8:16 ` sashiko-bot
2026-12-04 7:53 ` [PATCH v2 06/10] media: qcom: cam-icc: add the SC7280 data Atanas Filipov
2026-12-04 7:53 ` [PATCH v2 07/10] media: qcom: cam-icc: add the SA8775P data Atanas Filipov
2026-12-04 8:19 ` sashiko-bot
2026-12-04 7:53 ` [PATCH v2 08/10] arm64: dts: qcom: sm8250: add the Titan camera NoC node Atanas Filipov
2026-12-04 8:25 ` sashiko-bot
2026-12-04 7:53 ` [PATCH v2 09/10] arm64: dts: qcom: sc7280: " Atanas Filipov
2026-12-04 8:30 ` sashiko-bot
2026-12-04 7:53 ` [PATCH v2 10/10] arm64: dts: qcom: sa8775p: " Atanas Filipov
2026-12-04 8:35 ` sashiko-bot
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=bf1acd88-83bf-4c33-aa81-d38ac66285b8@kernel.org \
--to=djakov@kernel.org \
--cc=abelvesa@kernel.org \
--cc=andersson@kernel.org \
--cc=atanas.filipov@oss.qualcomm.com \
--cc=bod@kernel.org \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.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