Files
Qiang YuandAbel Vesa 03e2d49246 clk: qcom: Add generic clkref_en support
Before XO refclk is distributed to PCIe/USB/eDP PHYs, it passes through
a QREF block. QREF is powered by dedicated LDO rails, and the clkref_en
register controls whether refclk is gated through to the PHY side.

These clkref controls are different from typical GCC branch clocks:
- only a single enable bit is present, without branch-style config bits
- regulators must be voted before enable and unvoted after disable

Model this as a dedicated clk_ref clock type with custom clk_ops instead
of reusing struct clk_branch semantics.

Also provide a common registration/probe API so the same clkref model
can be reused regardless of where clkref_en registers are placed, e.g.
TCSR on glymur and TLMM on SM8750.

Reviewed-by: Konrad Dybcio <konrad.dybcio@oss.qualcomm.com>
Signed-off-by: Qiang Yu <qiang.yu@oss.qualcomm.com>
2026-08-05 15:36:00 +03:00

68 lines
1.7 KiB
C

/* SPDX-License-Identifier: GPL-2.0 */
/*
* Copyright (c) 2026, Qualcomm Technologies, Inc. and/or its subsidiaries.
*/
#ifndef __LINUX_CLK_QCOM_H
#define __LINUX_CLK_QCOM_H
#include <linux/clk-provider.h>
#include <linux/errno.h>
#include <linux/kconfig.h>
#include <linux/regmap.h>
#include <linux/types.h>
struct device;
struct platform_device;
struct regulator_bulk_data;
/**
* struct qcom_clk_ref_desc - descriptor for a clkref_en gate clock
* @name: clock name exposed to the common clock framework
* @offset: clkref_en register offset from the block base
* @regulator_names: optional supply names enabled while preparing the clock
* @num_regulators: number of entries in @regulator_names
*/
struct qcom_clk_ref_desc {
const char *name;
u32 offset;
const char * const *regulator_names;
unsigned int num_regulators;
};
/**
* struct qcom_clk_ref - per-clock data for a clkref_en gate clock
* @hw: common clock framework hardware clock handle
* @regmap: register map backing the clkref_en register
* @desc: clock descriptor copied at registration time
* @regulators: optional bulk regulator handles for @desc.regulator_names
*/
struct qcom_clk_ref {
struct clk_hw hw;
struct regmap *regmap;
struct qcom_clk_ref_desc desc;
struct regulator_bulk_data *regulators;
};
#if IS_ENABLED(CONFIG_COMMON_CLK_QCOM)
int qcom_clk_ref_probe(struct platform_device *pdev,
const struct regmap_config *config,
const struct qcom_clk_ref_desc * const *descs,
size_t num_clk_refs);
#else
static inline int
qcom_clk_ref_probe(struct platform_device *pdev,
const struct regmap_config *config,
const struct qcom_clk_ref_desc * const *descs,
size_t num_clk_refs)
{
return -EOPNOTSUPP;
}
#endif
#endif