Re: [PATCH v7 2/2] clk: qcom: Add LPASS VA CSR heartbeat pulse clock

From: Srinivas Kandagatla

Date: Tue Sep 08 2026 - 16:37:26 EST


On 8/31/26 7:33 AM, Sarath Ganapathiraju via B4 Relay wrote:
> From: Sarath Ganapathiraju <sarath.ganapathiraju@xxxxxxxxxxxxxxxx>
>
> The HeartBeat Pulse (also known as RateGen Pulse) synchronizes the
> start of the DMAs and Codec Interfaces for the audio usecases and can
> serve as a periodic wakeup source for the DSP.
>
> Add the LPASS VA CSR driver that models the rate generator as a clock
> provider so it is enabled and disabled automatically alongside the other
> clocks during runtime PM resume and suspend.
>
> Reviewed-by: Prasad Kumpatla <prasad.kumpatla@xxxxxxxxxxxxxxxx>
> Tested-by: Prasad Kumpatla <prasad.kumpatla@xxxxxxxxxxxxxxxx>
> Signed-off-by: Sarath Ganapathiraju <sarath.ganapathiraju@xxxxxxxxxxxxxxxx>
> ---
> drivers/clk/qcom/Kconfig | 14 ++++
> drivers/clk/qcom/Makefile | 1 +
> drivers/clk/qcom/lpass-va-csr.c | 148 ++++++++++++++++++++++++++++++++++++++++
> 3 files changed, 163 insertions(+)
>
> diff --git a/drivers/clk/qcom/Kconfig b/drivers/clk/qcom/Kconfig
> index e609a7819e07..502acd86efd6 100644
> --- a/drivers/clk/qcom/Kconfig
> +++ b/drivers/clk/qcom/Kconfig
> @@ -2105,6 +2105,20 @@ config CLK_GFM_LPASS_SM8250
> Support for the Glitch Free Mux (GFM) Low power audio
> subsystem (LPASS) clocks found on SM8250 SoCs.
>
> +config QCOM_CLK_LPASS_HEARTBEAT_PULSE
> + tristate "Qualcomm LPASS VA CSR heartbeat pulse clock provider"
> + depends on COMMON_CLK
> + depends on ARM64 || COMPILE_TEST
> + select REGMAP_MMIO
> + default m if ARCH_QCOM
> + help
> + Qualcomm LPASS VA CSR block contains the rate generator hardware
> + that produces the HeartBeat Pulse (also known as RateGen Pulse).
> + This driver models the rate generator as a clock provider so
> + that consumers can enable or disable it via the common clock
> + framework, and it can be used to synchronize the start of DMAs
> + and Codec Interfaces or as a periodic wakeup source for the DSP.
> +
> config SM_VIDEOCC_8450
> tristate "SM8450 Video Clock Controller"
> depends on ARM64 || COMPILE_TEST
> diff --git a/drivers/clk/qcom/Makefile b/drivers/clk/qcom/Makefile
> index b8590963736a..3f6a52cc7ec7 100644
> --- a/drivers/clk/qcom/Makefile
> +++ b/drivers/clk/qcom/Makefile
> @@ -28,6 +28,7 @@ obj-$(CONFIG_CLK_ELIZA_GPUCC) += gpucc-eliza.o
> obj-$(CONFIG_CLK_ELIZA_TCSRCC) += tcsrcc-eliza.o
> obj-$(CONFIG_CLK_ELIZA_VIDEOCC) += videocc-eliza.o
> obj-$(CONFIG_CLK_GFM_LPASS_SM8250) += lpass-gfm-sm8250.o
> +obj-$(CONFIG_QCOM_CLK_LPASS_HEARTBEAT_PULSE) += lpass-va-csr.o
> obj-$(CONFIG_CLK_GLYMUR_CAMCC) += camcc-glymur.o
> obj-$(CONFIG_CLK_GLYMUR_DISPCC) += dispcc-glymur.o
> obj-$(CONFIG_CLK_GLYMUR_EVACC) += evacc-glymur.o
> diff --git a/drivers/clk/qcom/lpass-va-csr.c b/drivers/clk/qcom/lpass-va-csr.c
> new file mode 100644
> index 000000000000..8438d000814e
> --- /dev/null
> +++ b/drivers/clk/qcom/lpass-va-csr.c
> @@ -0,0 +1,148 @@
> +// SPDX-License-Identifier: GPL-2.0-only
> +/*
> + * Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries.
> + */
> +
> +#include <linux/clk-provider.h>
> +#include <linux/device.h>
> +#include <linux/module.h>
> +#include <linux/of_clk.h>
> +#include <linux/platform_device.h>
> +#include <linux/pm_runtime.h>
> +#include <linux/regmap.h>
...
> +
> +#define to_lpass_va_csr(_hw) container_of(_hw, struct lpass_va_csr, hb_hw)
> +
> +static int heartbeat_pulse_prepare(struct clk_hw *hw)
> +{
> + struct lpass_va_csr *csr = to_lpass_va_csr(hw);
> + int ret;
> +
> + ret = regmap_write(csr->regmap, LPASS_RATE_GEN_COUNTER_0, csr->data->counter_0);
> + if (ret)
> + return ret;
> +
> + ret = regmap_write(csr->regmap, LPASS_RATE_GEN_DELAY, csr->data->delay);
> + if (ret)
> + return ret;
Does these two registers need to be written on every prepare?


if we need to program just once then we can just use clk_regmap_gate_ops
which will implement pretty much the same driver.

> +
> + return regmap_set_bits(csr->regmap, LPASS_RATE_GEN_CTRL, LPASS_RG_CTRL_EN);
> +}
> +
> +static void heartbeat_pulse_unprepare(struct clk_hw *hw)
> +{
> + struct lpass_va_csr *csr = to_lpass_va_csr(hw);
> +
> + regmap_clear_bits(csr->regmap, LPASS_RATE_GEN_CTRL, LPASS_RG_CTRL_EN);
> +}
> +
> +static int heartbeat_pulse_is_prepared(struct clk_hw *hw)
> +{
> + struct lpass_va_csr *csr = to_lpass_va_csr(hw);
> +
> + return regmap_test_bits(csr->regmap, LPASS_RATE_GEN_CTRL, LPASS_RG_CTRL_EN);
> +}
> +
> +static const struct clk_ops heartbeat_pulse_ops = {
> + .prepare = heartbeat_pulse_prepare,
> + .unprepare = heartbeat_pulse_unprepare,
> + .is_prepared = heartbeat_pulse_is_prepared,
> +};
> +
> +static int lpass_va_csr_probe(struct platform_device *pdev)
> +{
> + struct device *dev = &pdev->dev;
> + struct lpass_va_csr *csr;
> + struct clk_init_data init = {
> + .name = "lpass_heartbeat_pulse",
> + .ops = &heartbeat_pulse_ops,
> + };
> + void __iomem *base;
> + int ret;
> +
> + csr = devm_kzalloc(dev, sizeof(*csr), GFP_KERNEL);
> + if (!csr)
> + return -ENOMEM;
> +
> + csr->data = of_device_get_match_data(dev);
> + if (!csr->data)
This check will never fail as the device gets only probed if compatible
matches.

> + return dev_err_probe(dev, -EINVAL, "no variant data for compatible\n");
> +
> + base = devm_platform_ioremap_resource(pdev, 0);
> + if (IS_ERR(base))
> + return PTR_ERR(base);
> +