drivers/clk/qcom/apcs-msm8996.c
Source file repositories/reference/linux-study-clean/drivers/clk/qcom/apcs-msm8996.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/clk/qcom/apcs-msm8996.c- Extension
.c- Size
- 2727 bytes
- Lines
- 90
- Domain
- Driver Families
- Bucket
- drivers/clk
- Inferred role
- Driver Families: exported/initcall integration point
- Status
- integration implementation candidate
Why This File Exists
Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/bits.hlinux/bitfield.hlinux/clk-provider.hlinux/delay.hlinux/module.hlinux/platform_device.hlinux/regmap.h
Detected Declarations
function Copyrightfunction qcom_apcs_msm8996_clk_initfunction qcom_apcs_msm8996_clk_exit
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0
/*
* Qualcomm APCS clock controller driver
*
* Copyright (c) 2022, Linaro Limited
* Author: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
*/
#include <linux/bits.h>
#include <linux/bitfield.h>
#include <linux/clk-provider.h>
#include <linux/delay.h>
#include <linux/module.h>
#include <linux/platform_device.h>
#include <linux/regmap.h>
#define APCS_AUX_OFFSET 0x50
#define APCS_AUX_DIV_MASK GENMASK(17, 16)
#define APCS_AUX_DIV_2 0x1
static int qcom_apcs_msm8996_clk_probe(struct platform_device *pdev)
{
struct device *dev = &pdev->dev;
struct device *parent = dev->parent;
struct regmap *regmap;
struct clk_hw *hw;
unsigned int val;
int ret = -ENODEV;
regmap = dev_get_regmap(parent, NULL);
if (!regmap) {
dev_err(dev, "failed to get regmap: %d\n", ret);
return ret;
}
regmap_read(regmap, APCS_AUX_OFFSET, &val);
regmap_update_bits(regmap, APCS_AUX_OFFSET, APCS_AUX_DIV_MASK,
FIELD_PREP(APCS_AUX_DIV_MASK, APCS_AUX_DIV_2));
/*
* This clock is used during CPU cluster setup while setting up CPU PLLs.
* Add hardware mandated delay to make sure that the sys_apcs_aux clock
* is stable (after setting the divider) before continuing
* bootstrapping to keep CPUs from ending up in a weird state.
*/
udelay(5);
/*
* As this clocks is a parent of the CPU cluster clocks and is actually
* used as a parent during CPU clocks setup, we want for it to register
* as early as possible, without letting fw_devlink to delay probing of
* either of the drivers.
*
* The sys_apcs_aux is a child (divider) of gpll0, but we register it
* as a fixed rate clock instead to ease bootstrapping procedure. By
* doing this we make sure that CPU cluster clocks are able to be setup
* early during the boot process (as it is recommended by Qualcomm).
*/
hw = devm_clk_hw_register_fixed_rate(dev, "sys_apcs_aux", NULL, 0, 300000000);
if (IS_ERR(hw))
return PTR_ERR(hw);
return devm_of_clk_add_hw_provider(dev, of_clk_hw_simple_get, hw);
}
static struct platform_driver qcom_apcs_msm8996_clk_driver = {
.probe = qcom_apcs_msm8996_clk_probe,
.driver = {
.name = "qcom-apcs-msm8996-clk",
},
};
/* Register early enough to fix the clock to be used for other cores */
static int __init qcom_apcs_msm8996_clk_init(void)
{
return platform_driver_register(&qcom_apcs_msm8996_clk_driver);
}
postcore_initcall(qcom_apcs_msm8996_clk_init);
static void __exit qcom_apcs_msm8996_clk_exit(void)
{
platform_driver_unregister(&qcom_apcs_msm8996_clk_driver);
}
module_exit(qcom_apcs_msm8996_clk_exit);
MODULE_AUTHOR("Dmitry Baryshkov <dmitry.baryshkov@linaro.org>");
MODULE_LICENSE("GPL");
MODULE_DESCRIPTION("Qualcomm MSM8996 APCS clock driver");
Annotation
- Immediate include surface: `linux/bits.h`, `linux/bitfield.h`, `linux/clk-provider.h`, `linux/delay.h`, `linux/module.h`, `linux/platform_device.h`, `linux/regmap.h`.
- Detected declarations: `function Copyright`, `function qcom_apcs_msm8996_clk_init`, `function qcom_apcs_msm8996_clk_exit`.
- Atlas domain: Driver Families / drivers/clk.
- Implementation status: integration implementation candidate.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.