Skip to content

Commit 0277263

Browse files
lumagandersson
authored andcommitted
clk: qcom: add the driver for the MSM8996 APCS clocks
Add a simple driver handling the APCS clocks on MSM8996. For now it supports just a single aux clock, linking GPLL0 to CPU and CBF clocks. Note, there is little sense in registering sys_apcs_aux as a child of gpll0. The PLL is always-on. And listing the gpll0 as a property of the apcs would delay its probing until the GCC has been probed (while we would like for the apcs to be probed as early as possible). Signed-off-by: Dmitry Baryshkov <[email protected]> Reviewed-by: Konrad Dybcio <[email protected]> [bjorn: Fixed spelling of register, per Stephen's feedback] Signed-off-by: Bjorn Andersson <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent d4cb3e7 commit 0277263

File tree

2 files changed

+89
-1
lines changed

2 files changed

+89
-1
lines changed

drivers/clk/qcom/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ obj-$(CONFIG_MSM_MMCC_8998) += mmcc-msm8998.o
5252
obj-$(CONFIG_QCOM_A53PLL) += a53-pll.o
5353
obj-$(CONFIG_QCOM_A7PLL) += a7-pll.o
5454
obj-$(CONFIG_QCOM_CLK_APCS_MSM8916) += apcs-msm8916.o
55-
obj-$(CONFIG_QCOM_CLK_APCC_MSM8996) += clk-cpu-8996.o
55+
obj-$(CONFIG_QCOM_CLK_APCC_MSM8996) += apcs-msm8996.o clk-cpu-8996.o
5656
obj-$(CONFIG_QCOM_CLK_APCS_SDX55) += apcs-sdx55.o
5757
obj-$(CONFIG_QCOM_CLK_RPM) += clk-rpm.o
5858
obj-$(CONFIG_QCOM_CLK_RPMH) += clk-rpmh.o

drivers/clk/qcom/apcs-msm8996.c

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
// SPDX-License-Identifier: GPL-2.0
2+
/*
3+
* Qualcomm APCS clock controller driver
4+
*
5+
* Copyright (c) 2022, Linaro Limited
6+
* Author: Dmitry Baryshkov <[email protected]>
7+
*/
8+
9+
#include <linux/bits.h>
10+
#include <linux/clk-provider.h>
11+
#include <linux/delay.h>
12+
#include <linux/module.h>
13+
#include <linux/platform_device.h>
14+
#include <linux/regmap.h>
15+
16+
#define APCS_AUX_OFFSET 0x50
17+
18+
#define APCS_AUX_DIV_MASK GENMASK(17, 16)
19+
#define APCS_AUX_DIV_2 0x1
20+
21+
static int qcom_apcs_msm8996_clk_probe(struct platform_device *pdev)
22+
{
23+
struct device *dev = &pdev->dev;
24+
struct device *parent = dev->parent;
25+
struct regmap *regmap;
26+
struct clk_hw *hw;
27+
unsigned int val;
28+
int ret = -ENODEV;
29+
30+
regmap = dev_get_regmap(parent, NULL);
31+
if (!regmap) {
32+
dev_err(dev, "failed to get regmap: %d\n", ret);
33+
return ret;
34+
}
35+
36+
regmap_read(regmap, APCS_AUX_OFFSET, &val);
37+
regmap_update_bits(regmap, APCS_AUX_OFFSET, APCS_AUX_DIV_MASK,
38+
FIELD_PREP(APCS_AUX_DIV_MASK, APCS_AUX_DIV_2));
39+
40+
/*
41+
* This clock is used during CPU cluster setup while setting up CPU PLLs.
42+
* Add hardware mandated delay to make sure that the sys_apcs_aux clock
43+
* is stable (after setting the divider) before continuing
44+
* bootstrapping to keep CPUs from ending up in a weird state.
45+
*/
46+
udelay(5);
47+
48+
/*
49+
* As this clocks is a parent of the CPU cluster clocks and is actually
50+
* used as a parent during CPU clocks setup, we want for it to register
51+
* as early as possible, without letting fw_devlink to delay probing of
52+
* either of the drivers.
53+
*
54+
* The sys_apcs_aux is a child (divider) of gpll0, but we register it
55+
* as a fixed rate clock instead to ease bootstrapping procedure. By
56+
* doing this we make sure that CPU cluster clocks are able to be setup
57+
* early during the boot process (as it is recommended by Qualcomm).
58+
*/
59+
hw = devm_clk_hw_register_fixed_rate(dev, "sys_apcs_aux", NULL, 0, 300000000);
60+
if (IS_ERR(hw))
61+
return PTR_ERR(hw);
62+
63+
return devm_of_clk_add_hw_provider(dev, of_clk_hw_simple_get, hw);
64+
}
65+
66+
static struct platform_driver qcom_apcs_msm8996_clk_driver = {
67+
.probe = qcom_apcs_msm8996_clk_probe,
68+
.driver = {
69+
.name = "qcom-apcs-msm8996-clk",
70+
},
71+
};
72+
73+
/* Register early enough to fix the clock to be used for other cores */
74+
static int __init qcom_apcs_msm8996_clk_init(void)
75+
{
76+
return platform_driver_register(&qcom_apcs_msm8996_clk_driver);
77+
}
78+
postcore_initcall(qcom_apcs_msm8996_clk_init);
79+
80+
static void __exit qcom_apcs_msm8996_clk_exit(void)
81+
{
82+
platform_driver_unregister(&qcom_apcs_msm8996_clk_driver);
83+
}
84+
module_exit(qcom_apcs_msm8996_clk_exit);
85+
86+
MODULE_AUTHOR("Dmitry Baryshkov <[email protected]>");
87+
MODULE_LICENSE("GPL");
88+
MODULE_DESCRIPTION("Qualcomm MSM8996 APCS clock driver");

0 commit comments

Comments
 (0)