Skip to content

Commit a18c8e0

Browse files
superna9999jbrun3t
authored andcommitted
clk: meson: g12a: add support for the SPICC SCLK Source clocks
This adds the clocks used for the Amlogic G12A and compatible SoCs SPICC controller to provide a more complete range of frequencies instead of the SPICC internal divider over Xtal. Signed-off-by: Neil Armstrong <[email protected]> Signed-off-by: Jerome Brunet <[email protected]>
1 parent 51a0c29 commit a18c8e0

File tree

2 files changed

+134
-1
lines changed

2 files changed

+134
-1
lines changed

drivers/clk/meson/g12a.c

Lines changed: 129 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3862,6 +3862,111 @@ static struct clk_regmap g12a_ts = {
38623862
},
38633863
};
38643864

3865+
/* SPICC SCLK source clock */
3866+
3867+
static const struct clk_parent_data spicc_sclk_parent_data[] = {
3868+
{ .fw_name = "xtal", },
3869+
{ .hw = &g12a_clk81.hw },
3870+
{ .hw = &g12a_fclk_div4.hw },
3871+
{ .hw = &g12a_fclk_div3.hw },
3872+
{ .hw = &g12a_fclk_div5.hw },
3873+
{ .hw = &g12a_fclk_div7.hw },
3874+
};
3875+
3876+
static struct clk_regmap g12a_spicc0_sclk_sel = {
3877+
.data = &(struct clk_regmap_mux_data){
3878+
.offset = HHI_SPICC_CLK_CNTL,
3879+
.mask = 7,
3880+
.shift = 7,
3881+
},
3882+
.hw.init = &(struct clk_init_data){
3883+
.name = "spicc0_sclk_sel",
3884+
.ops = &clk_regmap_mux_ops,
3885+
.parent_data = spicc_sclk_parent_data,
3886+
.num_parents = ARRAY_SIZE(spicc_sclk_parent_data),
3887+
},
3888+
};
3889+
3890+
static struct clk_regmap g12a_spicc0_sclk_div = {
3891+
.data = &(struct clk_regmap_div_data){
3892+
.offset = HHI_SPICC_CLK_CNTL,
3893+
.shift = 0,
3894+
.width = 6,
3895+
},
3896+
.hw.init = &(struct clk_init_data){
3897+
.name = "spicc0_sclk_div",
3898+
.ops = &clk_regmap_divider_ops,
3899+
.parent_hws = (const struct clk_hw *[]) {
3900+
&g12a_spicc0_sclk_sel.hw
3901+
},
3902+
.num_parents = 1,
3903+
.flags = CLK_SET_RATE_PARENT,
3904+
},
3905+
};
3906+
3907+
static struct clk_regmap g12a_spicc0_sclk = {
3908+
.data = &(struct clk_regmap_gate_data){
3909+
.offset = HHI_SPICC_CLK_CNTL,
3910+
.bit_idx = 6,
3911+
},
3912+
.hw.init = &(struct clk_init_data){
3913+
.name = "spicc0_sclk",
3914+
.ops = &clk_regmap_gate_ops,
3915+
.parent_hws = (const struct clk_hw *[]) {
3916+
&g12a_spicc0_sclk_div.hw
3917+
},
3918+
.num_parents = 1,
3919+
.flags = CLK_SET_RATE_PARENT,
3920+
},
3921+
};
3922+
3923+
static struct clk_regmap g12a_spicc1_sclk_sel = {
3924+
.data = &(struct clk_regmap_mux_data){
3925+
.offset = HHI_SPICC_CLK_CNTL,
3926+
.mask = 7,
3927+
.shift = 23,
3928+
},
3929+
.hw.init = &(struct clk_init_data){
3930+
.name = "spicc1_sclk_sel",
3931+
.ops = &clk_regmap_mux_ops,
3932+
.parent_data = spicc_sclk_parent_data,
3933+
.num_parents = ARRAY_SIZE(spicc_sclk_parent_data),
3934+
},
3935+
};
3936+
3937+
static struct clk_regmap g12a_spicc1_sclk_div = {
3938+
.data = &(struct clk_regmap_div_data){
3939+
.offset = HHI_SPICC_CLK_CNTL,
3940+
.shift = 16,
3941+
.width = 6,
3942+
},
3943+
.hw.init = &(struct clk_init_data){
3944+
.name = "spicc1_sclk_div",
3945+
.ops = &clk_regmap_divider_ops,
3946+
.parent_hws = (const struct clk_hw *[]) {
3947+
&g12a_spicc1_sclk_sel.hw
3948+
},
3949+
.num_parents = 1,
3950+
.flags = CLK_SET_RATE_PARENT,
3951+
},
3952+
};
3953+
3954+
static struct clk_regmap g12a_spicc1_sclk = {
3955+
.data = &(struct clk_regmap_gate_data){
3956+
.offset = HHI_SPICC_CLK_CNTL,
3957+
.bit_idx = 22,
3958+
},
3959+
.hw.init = &(struct clk_init_data){
3960+
.name = "spicc1_sclk",
3961+
.ops = &clk_regmap_gate_ops,
3962+
.parent_hws = (const struct clk_hw *[]) {
3963+
&g12a_spicc1_sclk_div.hw
3964+
},
3965+
.num_parents = 1,
3966+
.flags = CLK_SET_RATE_PARENT,
3967+
},
3968+
};
3969+
38653970
#define MESON_GATE(_name, _reg, _bit) \
38663971
MESON_PCLK(_name, _reg, _bit, &g12a_clk81.hw)
38673972

@@ -4159,6 +4264,12 @@ static struct clk_hw_onecell_data g12a_hw_onecell_data = {
41594264
[CLKID_VDEC_HEVCF] = &g12a_vdec_hevcf.hw,
41604265
[CLKID_TS_DIV] = &g12a_ts_div.hw,
41614266
[CLKID_TS] = &g12a_ts.hw,
4267+
[CLKID_SPICC0_SCLK_SEL] = &g12a_spicc0_sclk_sel.hw,
4268+
[CLKID_SPICC0_SCLK_DIV] = &g12a_spicc0_sclk_div.hw,
4269+
[CLKID_SPICC0_SCLK] = &g12a_spicc0_sclk.hw,
4270+
[CLKID_SPICC1_SCLK_SEL] = &g12a_spicc1_sclk_sel.hw,
4271+
[CLKID_SPICC1_SCLK_DIV] = &g12a_spicc1_sclk_div.hw,
4272+
[CLKID_SPICC1_SCLK] = &g12a_spicc1_sclk.hw,
41624273
[NR_CLKS] = NULL,
41634274
},
41644275
.num = NR_CLKS,
@@ -4408,6 +4519,12 @@ static struct clk_hw_onecell_data g12b_hw_onecell_data = {
44084519
[CLKID_CPUB_CLK_AXI] = &g12b_cpub_clk_axi.hw,
44094520
[CLKID_CPUB_CLK_TRACE_SEL] = &g12b_cpub_clk_trace_sel.hw,
44104521
[CLKID_CPUB_CLK_TRACE] = &g12b_cpub_clk_trace.hw,
4522+
[CLKID_SPICC0_SCLK_SEL] = &g12a_spicc0_sclk_sel.hw,
4523+
[CLKID_SPICC0_SCLK_DIV] = &g12a_spicc0_sclk_div.hw,
4524+
[CLKID_SPICC0_SCLK] = &g12a_spicc0_sclk.hw,
4525+
[CLKID_SPICC1_SCLK_SEL] = &g12a_spicc1_sclk_sel.hw,
4526+
[CLKID_SPICC1_SCLK_DIV] = &g12a_spicc1_sclk_div.hw,
4527+
[CLKID_SPICC1_SCLK] = &g12a_spicc1_sclk.hw,
44114528
[NR_CLKS] = NULL,
44124529
},
44134530
.num = NR_CLKS,
@@ -4642,6 +4759,12 @@ static struct clk_hw_onecell_data sm1_hw_onecell_data = {
46424759
[CLKID_CPU1_CLK] = &sm1_cpu1_clk.hw,
46434760
[CLKID_CPU2_CLK] = &sm1_cpu2_clk.hw,
46444761
[CLKID_CPU3_CLK] = &sm1_cpu3_clk.hw,
4762+
[CLKID_SPICC0_SCLK_SEL] = &g12a_spicc0_sclk_sel.hw,
4763+
[CLKID_SPICC0_SCLK_DIV] = &g12a_spicc0_sclk_div.hw,
4764+
[CLKID_SPICC0_SCLK] = &g12a_spicc0_sclk.hw,
4765+
[CLKID_SPICC1_SCLK_SEL] = &g12a_spicc1_sclk_sel.hw,
4766+
[CLKID_SPICC1_SCLK_DIV] = &g12a_spicc1_sclk_div.hw,
4767+
[CLKID_SPICC1_SCLK] = &g12a_spicc1_sclk.hw,
46454768
[NR_CLKS] = NULL,
46464769
},
46474770
.num = NR_CLKS,
@@ -4877,6 +5000,12 @@ static struct clk_regmap *const g12a_clk_regmaps[] = {
48775000
&sm1_cpu1_clk,
48785001
&sm1_cpu2_clk,
48795002
&sm1_cpu3_clk,
5003+
&g12a_spicc0_sclk_sel,
5004+
&g12a_spicc0_sclk_div,
5005+
&g12a_spicc0_sclk,
5006+
&g12a_spicc1_sclk_sel,
5007+
&g12a_spicc1_sclk_div,
5008+
&g12a_spicc1_sclk,
48805009
};
48815010

48825011
static const struct reg_sequence g12a_init_regs[] = {

drivers/clk/meson/g12a.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -255,8 +255,12 @@
255255
#define CLKID_DSU_CLK_DYN1 249
256256
#define CLKID_DSU_CLK_DYN 250
257257
#define CLKID_DSU_CLK_FINAL 251
258+
#define CLKID_SPICC0_SCLK_SEL 256
259+
#define CLKID_SPICC0_SCLK_DIV 257
260+
#define CLKID_SPICC1_SCLK_SEL 259
261+
#define CLKID_SPICC1_SCLK_DIV 260
258262

259-
#define NR_CLKS 256
263+
#define NR_CLKS 262
260264

261265
/* include the CLKIDs that have been made part of the DT binding */
262266
#include <dt-bindings/clock/g12a-clkc.h>

0 commit comments

Comments
 (0)