Skip to content

Commit 5e77b4e

Browse files
Sivaprakash Murugesanbebarino
authored andcommitted
clk: qcom: Add ipq6018 apss clock controller
The CPU on Qualcomm ipq6018 devices are clocked primarily by a aplha PLL and xo which are connected to a mux and enable block. Add support for the mux and enable block which feeds the CPU on ipq6018 devices. Reviewed-by: Stephen Boyd <[email protected]> Signed-off-by: Sivaprakash Murugesan <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Stephen Boyd <[email protected]>
1 parent 49bcaef commit 5e77b4e

File tree

3 files changed

+118
-0
lines changed

3 files changed

+118
-0
lines changed

drivers/clk/qcom/Kconfig

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,17 @@ config IPQ_APSS_PLL
9797
Say Y if you want to support CPU frequency scaling on ipq based
9898
devices.
9999

100+
config IPQ_APSS_6018
101+
tristate "IPQ APSS Clock Controller"
102+
select IPQ_APSS_PLL
103+
depends on QCOM_APCS_IPC || COMPILE_TEST
104+
help
105+
Support for APSS clock controller on IPQ platforms. The
106+
APSS clock controller manages the Mux and enable block that feeds the
107+
CPUs.
108+
Say Y if you want to support CPU frequency scaling on
109+
ipq based devices.
110+
100111
config IPQ_GCC_4019
101112
tristate "IPQ4019 Global Clock Controller"
102113
help

drivers/clk/qcom/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ clk-qcom-$(CONFIG_QCOM_GDSC) += gdsc.o
2020
obj-$(CONFIG_APQ_GCC_8084) += gcc-apq8084.o
2121
obj-$(CONFIG_APQ_MMCC_8084) += mmcc-apq8084.o
2222
obj-$(CONFIG_IPQ_APSS_PLL) += apss-ipq-pll.o
23+
obj-$(CONFIG_IPQ_APSS_6018) += apss-ipq6018.o
2324
obj-$(CONFIG_IPQ_GCC_4019) += gcc-ipq4019.o
2425
obj-$(CONFIG_IPQ_GCC_6018) += gcc-ipq6018.o
2526
obj-$(CONFIG_IPQ_GCC_806X) += gcc-ipq806x.o

drivers/clk/qcom/apss-ipq6018.c

Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
// SPDX-License-Identifier: GPL-2.0
2+
/*
3+
* Copyright (c) 2018, The Linux Foundation. All rights reserved.
4+
*/
5+
6+
#include <linux/kernel.h>
7+
#include <linux/err.h>
8+
#include <linux/platform_device.h>
9+
#include <linux/clk-provider.h>
10+
#include <linux/regmap.h>
11+
#include <linux/module.h>
12+
13+
#include <dt-bindings/clock/qcom,apss-ipq.h>
14+
15+
#include "common.h"
16+
#include "clk-regmap.h"
17+
#include "clk-branch.h"
18+
#include "clk-alpha-pll.h"
19+
#include "clk-regmap-mux.h"
20+
21+
enum {
22+
P_XO,
23+
P_APSS_PLL_EARLY,
24+
};
25+
26+
static const struct clk_parent_data parents_apcs_alias0_clk_src[] = {
27+
{ .fw_name = "xo" },
28+
{ .fw_name = "pll" },
29+
};
30+
31+
static const struct parent_map parents_apcs_alias0_clk_src_map[] = {
32+
{ P_XO, 0 },
33+
{ P_APSS_PLL_EARLY, 5 },
34+
};
35+
36+
static struct clk_regmap_mux apcs_alias0_clk_src = {
37+
.reg = 0x0050,
38+
.width = 3,
39+
.shift = 7,
40+
.parent_map = parents_apcs_alias0_clk_src_map,
41+
.clkr.hw.init = &(struct clk_init_data){
42+
.name = "apcs_alias0_clk_src",
43+
.parent_data = parents_apcs_alias0_clk_src,
44+
.num_parents = 2,
45+
.ops = &clk_regmap_mux_closest_ops,
46+
.flags = CLK_SET_RATE_PARENT,
47+
},
48+
};
49+
50+
static struct clk_branch apcs_alias0_core_clk = {
51+
.halt_reg = 0x0058,
52+
.clkr = {
53+
.enable_reg = 0x0058,
54+
.enable_mask = BIT(0),
55+
.hw.init = &(struct clk_init_data){
56+
.name = "apcs_alias0_core_clk",
57+
.parent_hws = (const struct clk_hw *[]){
58+
&apcs_alias0_clk_src.clkr.hw },
59+
.num_parents = 1,
60+
.flags = CLK_SET_RATE_PARENT,
61+
.ops = &clk_branch2_ops,
62+
},
63+
},
64+
};
65+
66+
static const struct regmap_config apss_ipq6018_regmap_config = {
67+
.reg_bits = 32,
68+
.reg_stride = 4,
69+
.val_bits = 32,
70+
.max_register = 0x1000,
71+
.fast_io = true,
72+
};
73+
74+
static struct clk_regmap *apss_ipq6018_clks[] = {
75+
[APCS_ALIAS0_CLK_SRC] = &apcs_alias0_clk_src.clkr,
76+
[APCS_ALIAS0_CORE_CLK] = &apcs_alias0_core_clk.clkr,
77+
};
78+
79+
static const struct qcom_cc_desc apss_ipq6018_desc = {
80+
.config = &apss_ipq6018_regmap_config,
81+
.clks = apss_ipq6018_clks,
82+
.num_clks = ARRAY_SIZE(apss_ipq6018_clks),
83+
};
84+
85+
static int apss_ipq6018_probe(struct platform_device *pdev)
86+
{
87+
struct regmap *regmap;
88+
89+
regmap = dev_get_regmap(pdev->dev.parent, NULL);
90+
if (IS_ERR(regmap))
91+
return PTR_ERR(regmap);
92+
93+
return qcom_cc_really_probe(pdev, &apss_ipq6018_desc, regmap);
94+
}
95+
96+
static struct platform_driver apss_ipq6018_driver = {
97+
.probe = apss_ipq6018_probe,
98+
.driver = {
99+
.name = "qcom,apss-ipq6018-clk",
100+
},
101+
};
102+
103+
module_platform_driver(apss_ipq6018_driver);
104+
105+
MODULE_DESCRIPTION("QCOM APSS IPQ 6018 CLK Driver");
106+
MODULE_LICENSE("GPL v2");

0 commit comments

Comments
 (0)