Skip to content

Commit ecd2bac

Browse files
Sivaprakash Murugesanbebarino
authored andcommitted
clk: qcom: Add ipq apss pll driver
The CPUs on Qualcomm ipq based devices are clocked by an alpha PLL. Add support for the apss pll found on ipq based devices which can support CPU frequencies above 1Ghz. Signed-off-by: Sivaprakash Murugesan <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Stephen Boyd <[email protected]>
1 parent 2afc6ec commit ecd2bac

File tree

3 files changed

+104
-0
lines changed

3 files changed

+104
-0
lines changed

drivers/clk/qcom/Kconfig

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,14 @@ config APQ_MMCC_8084
8989
Say Y if you want to support multimedia devices such as display,
9090
graphics, video encode/decode, camera, etc.
9191

92+
config IPQ_APSS_PLL
93+
tristate "IPQ APSS PLL"
94+
help
95+
Support for APSS PLL on ipq devices. The APSS PLL is the main
96+
clock that feeds the CPUs on ipq based devices.
97+
Say Y if you want to support CPU frequency scaling on ipq based
98+
devices.
99+
92100
config IPQ_GCC_4019
93101
tristate "IPQ4019 Global Clock Controller"
94102
help

drivers/clk/qcom/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ clk-qcom-$(CONFIG_QCOM_GDSC) += gdsc.o
1919
# Keep alphabetically sorted by config
2020
obj-$(CONFIG_APQ_GCC_8084) += gcc-apq8084.o
2121
obj-$(CONFIG_APQ_MMCC_8084) += mmcc-apq8084.o
22+
obj-$(CONFIG_IPQ_APSS_PLL) += apss-ipq-pll.o
2223
obj-$(CONFIG_IPQ_GCC_4019) += gcc-ipq4019.o
2324
obj-$(CONFIG_IPQ_GCC_6018) += gcc-ipq6018.o
2425
obj-$(CONFIG_IPQ_GCC_806X) += gcc-ipq806x.o

drivers/clk/qcom/apss-ipq-pll.c

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
// SPDX-License-Identifier: GPL-2.0
2+
// Copyright (c) 2018, The Linux Foundation. All rights reserved.
3+
#include <linux/clk-provider.h>
4+
#include <linux/module.h>
5+
#include <linux/platform_device.h>
6+
#include <linux/regmap.h>
7+
8+
#include "clk-alpha-pll.h"
9+
10+
static const u8 ipq_pll_offsets[] = {
11+
[PLL_OFF_L_VAL] = 0x08,
12+
[PLL_OFF_ALPHA_VAL] = 0x10,
13+
[PLL_OFF_USER_CTL] = 0x18,
14+
[PLL_OFF_CONFIG_CTL] = 0x20,
15+
[PLL_OFF_CONFIG_CTL_U] = 0x24,
16+
[PLL_OFF_STATUS] = 0x28,
17+
[PLL_OFF_TEST_CTL] = 0x30,
18+
[PLL_OFF_TEST_CTL_U] = 0x34,
19+
};
20+
21+
static struct clk_alpha_pll ipq_pll = {
22+
.offset = 0x0,
23+
.regs = ipq_pll_offsets,
24+
.flags = SUPPORTS_DYNAMIC_UPDATE,
25+
.clkr = {
26+
.enable_reg = 0x0,
27+
.enable_mask = BIT(0),
28+
.hw.init = &(struct clk_init_data){
29+
.name = "a53pll",
30+
.parent_data = &(const struct clk_parent_data) {
31+
.fw_name = "xo",
32+
},
33+
.num_parents = 1,
34+
.ops = &clk_alpha_pll_huayra_ops,
35+
},
36+
},
37+
};
38+
39+
static const struct alpha_pll_config ipq_pll_config = {
40+
.l = 0x37,
41+
.config_ctl_val = 0x04141200,
42+
.config_ctl_hi_val = 0x0,
43+
.early_output_mask = BIT(3),
44+
.main_output_mask = BIT(0),
45+
};
46+
47+
static const struct regmap_config ipq_pll_regmap_config = {
48+
.reg_bits = 32,
49+
.reg_stride = 4,
50+
.val_bits = 32,
51+
.max_register = 0x40,
52+
.fast_io = true,
53+
};
54+
55+
static int apss_ipq_pll_probe(struct platform_device *pdev)
56+
{
57+
struct device *dev = &pdev->dev;
58+
struct regmap *regmap;
59+
void __iomem *base;
60+
int ret;
61+
62+
base = devm_platform_ioremap_resource(pdev, 0);
63+
if (IS_ERR(base))
64+
return PTR_ERR(base);
65+
66+
regmap = devm_regmap_init_mmio(dev, base, &ipq_pll_regmap_config);
67+
if (IS_ERR(regmap))
68+
return PTR_ERR(regmap);
69+
70+
clk_alpha_pll_configure(&ipq_pll, regmap, &ipq_pll_config);
71+
72+
ret = devm_clk_register_regmap(dev, &ipq_pll.clkr);
73+
if (ret)
74+
return ret;
75+
76+
return devm_of_clk_add_hw_provider(dev, of_clk_hw_simple_get,
77+
&ipq_pll.clkr.hw);
78+
}
79+
80+
static const struct of_device_id apss_ipq_pll_match_table[] = {
81+
{ .compatible = "qcom,ipq6018-a53pll" },
82+
{ }
83+
};
84+
85+
static struct platform_driver apss_ipq_pll_driver = {
86+
.probe = apss_ipq_pll_probe,
87+
.driver = {
88+
.name = "qcom-ipq-apss-pll",
89+
.of_match_table = apss_ipq_pll_match_table,
90+
},
91+
};
92+
module_platform_driver(apss_ipq_pll_driver);
93+
94+
MODULE_DESCRIPTION("Qualcomm technology Inc APSS ALPHA PLL Driver");
95+
MODULE_LICENSE("GPL v2");

0 commit comments

Comments
 (0)