Skip to content

Commit 2f1efa5

Browse files
Dmitry Shmidtjbrun3t
authored andcommitted
clk: meson: g12a: Add support for NNA CLK source clocks
This adds the Neural Network Accelerator source clocks hierarchy, it's 2 simple composite clocks to feed the AXI interface and the Core of the Neural Network Accelerator IP. This IP is only present on the Amlogic SM1 SoCs family. Signed-off-by: Dmitry Shmidt <[email protected]> Signed-off-by: Neil Armstrong <[email protected]> Signed-off-by: Jerome Brunet <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent df06230 commit 2f1efa5

File tree

2 files changed

+125
-1
lines changed

2 files changed

+125
-1
lines changed

drivers/clk/meson/g12a.c

Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3981,6 +3981,113 @@ static struct clk_regmap g12a_spicc1_sclk = {
39813981
},
39823982
};
39833983

3984+
/* Neural Network Accelerator source clock */
3985+
3986+
static const struct clk_parent_data nna_clk_parent_data[] = {
3987+
{ .fw_name = "xtal", },
3988+
{ .hw = &g12a_gp0_pll.hw, },
3989+
{ .hw = &g12a_hifi_pll.hw, },
3990+
{ .hw = &g12a_fclk_div2p5.hw, },
3991+
{ .hw = &g12a_fclk_div3.hw, },
3992+
{ .hw = &g12a_fclk_div4.hw, },
3993+
{ .hw = &g12a_fclk_div5.hw, },
3994+
{ .hw = &g12a_fclk_div7.hw },
3995+
};
3996+
3997+
static struct clk_regmap sm1_nna_axi_clk_sel = {
3998+
.data = &(struct clk_regmap_mux_data){
3999+
.offset = HHI_NNA_CLK_CNTL,
4000+
.mask = 7,
4001+
.shift = 9,
4002+
},
4003+
.hw.init = &(struct clk_init_data){
4004+
.name = "nna_axi_clk_sel",
4005+
.ops = &clk_regmap_mux_ops,
4006+
.parent_data = nna_clk_parent_data,
4007+
.num_parents = ARRAY_SIZE(nna_clk_parent_data),
4008+
},
4009+
};
4010+
4011+
static struct clk_regmap sm1_nna_axi_clk_div = {
4012+
.data = &(struct clk_regmap_div_data){
4013+
.offset = HHI_NNA_CLK_CNTL,
4014+
.shift = 0,
4015+
.width = 7,
4016+
},
4017+
.hw.init = &(struct clk_init_data){
4018+
.name = "nna_axi_clk_div",
4019+
.ops = &clk_regmap_divider_ops,
4020+
.parent_hws = (const struct clk_hw *[]) {
4021+
&sm1_nna_axi_clk_sel.hw
4022+
},
4023+
.num_parents = 1,
4024+
.flags = CLK_SET_RATE_PARENT,
4025+
},
4026+
};
4027+
4028+
static struct clk_regmap sm1_nna_axi_clk = {
4029+
.data = &(struct clk_regmap_gate_data){
4030+
.offset = HHI_NNA_CLK_CNTL,
4031+
.bit_idx = 8,
4032+
},
4033+
.hw.init = &(struct clk_init_data){
4034+
.name = "nna_axi_clk",
4035+
.ops = &clk_regmap_gate_ops,
4036+
.parent_hws = (const struct clk_hw *[]) {
4037+
&sm1_nna_axi_clk_div.hw
4038+
},
4039+
.num_parents = 1,
4040+
.flags = CLK_SET_RATE_PARENT,
4041+
},
4042+
};
4043+
4044+
static struct clk_regmap sm1_nna_core_clk_sel = {
4045+
.data = &(struct clk_regmap_mux_data){
4046+
.offset = HHI_NNA_CLK_CNTL,
4047+
.mask = 7,
4048+
.shift = 25,
4049+
},
4050+
.hw.init = &(struct clk_init_data){
4051+
.name = "nna_core_clk_sel",
4052+
.ops = &clk_regmap_mux_ops,
4053+
.parent_data = nna_clk_parent_data,
4054+
.num_parents = ARRAY_SIZE(nna_clk_parent_data),
4055+
},
4056+
};
4057+
4058+
static struct clk_regmap sm1_nna_core_clk_div = {
4059+
.data = &(struct clk_regmap_div_data){
4060+
.offset = HHI_NNA_CLK_CNTL,
4061+
.shift = 16,
4062+
.width = 7,
4063+
},
4064+
.hw.init = &(struct clk_init_data){
4065+
.name = "nna_core_clk_div",
4066+
.ops = &clk_regmap_divider_ops,
4067+
.parent_hws = (const struct clk_hw *[]) {
4068+
&sm1_nna_core_clk_sel.hw
4069+
},
4070+
.num_parents = 1,
4071+
.flags = CLK_SET_RATE_PARENT,
4072+
},
4073+
};
4074+
4075+
static struct clk_regmap sm1_nna_core_clk = {
4076+
.data = &(struct clk_regmap_gate_data){
4077+
.offset = HHI_NNA_CLK_CNTL,
4078+
.bit_idx = 24,
4079+
},
4080+
.hw.init = &(struct clk_init_data){
4081+
.name = "nna_core_clk",
4082+
.ops = &clk_regmap_gate_ops,
4083+
.parent_hws = (const struct clk_hw *[]) {
4084+
&sm1_nna_core_clk_div.hw
4085+
},
4086+
.num_parents = 1,
4087+
.flags = CLK_SET_RATE_PARENT,
4088+
},
4089+
};
4090+
39844091
#define MESON_GATE(_name, _reg, _bit) \
39854092
MESON_PCLK(_name, _reg, _bit, &g12a_clk81.hw)
39864093

@@ -4779,6 +4886,12 @@ static struct clk_hw_onecell_data sm1_hw_onecell_data = {
47794886
[CLKID_SPICC1_SCLK_SEL] = &g12a_spicc1_sclk_sel.hw,
47804887
[CLKID_SPICC1_SCLK_DIV] = &g12a_spicc1_sclk_div.hw,
47814888
[CLKID_SPICC1_SCLK] = &g12a_spicc1_sclk.hw,
4889+
[CLKID_NNA_AXI_CLK_SEL] = &sm1_nna_axi_clk_sel.hw,
4890+
[CLKID_NNA_AXI_CLK_DIV] = &sm1_nna_axi_clk_div.hw,
4891+
[CLKID_NNA_AXI_CLK] = &sm1_nna_axi_clk.hw,
4892+
[CLKID_NNA_CORE_CLK_SEL] = &sm1_nna_core_clk_sel.hw,
4893+
[CLKID_NNA_CORE_CLK_DIV] = &sm1_nna_core_clk_div.hw,
4894+
[CLKID_NNA_CORE_CLK] = &sm1_nna_core_clk.hw,
47824895
[NR_CLKS] = NULL,
47834896
},
47844897
.num = NR_CLKS,
@@ -5020,6 +5133,12 @@ static struct clk_regmap *const g12a_clk_regmaps[] = {
50205133
&g12a_spicc1_sclk_sel,
50215134
&g12a_spicc1_sclk_div,
50225135
&g12a_spicc1_sclk,
5136+
&sm1_nna_axi_clk_sel,
5137+
&sm1_nna_axi_clk_div,
5138+
&sm1_nna_axi_clk,
5139+
&sm1_nna_core_clk_sel,
5140+
&sm1_nna_core_clk_div,
5141+
&sm1_nna_core_clk,
50235142
};
50245143

50255144
static const struct reg_sequence g12a_init_regs[] = {

drivers/clk/meson/g12a.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@
7070
#define HHI_MALI_CLK_CNTL 0x1b0
7171
#define HHI_VPU_CLKC_CNTL 0x1b4
7272
#define HHI_VPU_CLK_CNTL 0x1bC
73+
#define HHI_NNA_CLK_CNTL 0x1C8
7374
#define HHI_HDMI_CLK_CNTL 0x1CC
7475
#define HHI_VDEC_CLK_CNTL 0x1E0
7576
#define HHI_VDEC2_CLK_CNTL 0x1E4
@@ -259,8 +260,12 @@
259260
#define CLKID_SPICC0_SCLK_DIV 257
260261
#define CLKID_SPICC1_SCLK_SEL 259
261262
#define CLKID_SPICC1_SCLK_DIV 260
263+
#define CLKID_NNA_AXI_CLK_SEL 262
264+
#define CLKID_NNA_AXI_CLK_DIV 263
265+
#define CLKID_NNA_CORE_CLK_SEL 265
266+
#define CLKID_NNA_CORE_CLK_DIV 266
262267

263-
#define NR_CLKS 262
268+
#define NR_CLKS 268
264269

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

0 commit comments

Comments
 (0)