Skip to content

Commit 5e91693

Browse files
zongboxbebarino
authored andcommitted
clk: sifive: Move all stuff into SoCs header files from C files
Improve PRCI driver to reduce the complexity, we remove the SoCs C files by putting all stuff in each SoCs header files, and include these SoCs-specific header files in core of PRCI. It can also avoid the W=1 kernel build warnings about variable defined but not used [-Wunused-const-variable=], like commit 487dc7b ("clk: sifive: fu540-prci: Declare static const variable 'prci_clk_fu540' where it's used") does. Signed-off-by: Zong Li <[email protected]> Suggested-by: Lee Jones <[email protected]> Reviewed-by: Lee Jones <[email protected]> Acked-by: Palmer Dabbelt <[email protected]> Link: https://lore.kernel.org/r/a3c7ec5c46c1d8be455d1c347db4855bb56cec53.1646388139.git.zong.li@sifive.com Signed-off-by: Stephen Boyd <[email protected]>
1 parent 24a4a29 commit 5e91693

File tree

6 files changed

+214
-235
lines changed

6 files changed

+214
-235
lines changed

drivers/clk/sifive/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
# SPDX-License-Identifier: GPL-2.0-only
2-
obj-$(CONFIG_CLK_SIFIVE_PRCI) += sifive-prci.o fu540-prci.o fu740-prci.o
2+
obj-$(CONFIG_CLK_SIFIVE_PRCI) += sifive-prci.o

drivers/clk/sifive/fu540-prci.c

Lines changed: 0 additions & 88 deletions
This file was deleted.

drivers/clk/sifive/fu540-prci.h

Lines changed: 87 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,99 @@
11
/* SPDX-License-Identifier: GPL-2.0 */
22
/*
3-
* Copyright (C) 2020 SiFive, Inc.
4-
* Zong Li
3+
* Copyright (C) 2018-2021 SiFive, Inc.
4+
* Copyright (C) 2018-2019 Wesley Terpstra
5+
* Copyright (C) 2018-2019 Paul Walmsley
6+
* Copyright (C) 2020-2021 Zong Li
7+
*
8+
* The FU540 PRCI implements clock and reset control for the SiFive
9+
* FU540-C000 chip. This driver assumes that it has sole control
10+
* over all PRCI resources.
11+
*
12+
* This driver is based on the PRCI driver written by Wesley Terpstra:
13+
* https://github.com/riscv/riscv-linux/commit/999529edf517ed75b56659d456d221b2ee56bb60
14+
*
15+
* References:
16+
* - SiFive FU540-C000 manual v1p0, Chapter 7 "Clocking and Reset"
517
*/
618

719
#ifndef __SIFIVE_CLK_FU540_PRCI_H
820
#define __SIFIVE_CLK_FU540_PRCI_H
921

22+
23+
#include <linux/module.h>
24+
25+
#include <dt-bindings/clock/sifive-fu540-prci.h>
26+
1027
#include "sifive-prci.h"
1128

12-
#define NUM_CLOCK_FU540 4
29+
/* PRCI integration data for each WRPLL instance */
30+
31+
static struct __prci_wrpll_data sifive_fu540_prci_corepll_data = {
32+
.cfg0_offs = PRCI_COREPLLCFG0_OFFSET,
33+
.cfg1_offs = PRCI_COREPLLCFG1_OFFSET,
34+
.enable_bypass = sifive_prci_coreclksel_use_hfclk,
35+
.disable_bypass = sifive_prci_coreclksel_use_corepll,
36+
};
37+
38+
static struct __prci_wrpll_data sifive_fu540_prci_ddrpll_data = {
39+
.cfg0_offs = PRCI_DDRPLLCFG0_OFFSET,
40+
.cfg1_offs = PRCI_DDRPLLCFG1_OFFSET,
41+
};
42+
43+
static struct __prci_wrpll_data sifive_fu540_prci_gemgxlpll_data = {
44+
.cfg0_offs = PRCI_GEMGXLPLLCFG0_OFFSET,
45+
.cfg1_offs = PRCI_GEMGXLPLLCFG1_OFFSET,
46+
};
47+
48+
/* Linux clock framework integration */
49+
50+
static const struct clk_ops sifive_fu540_prci_wrpll_clk_ops = {
51+
.set_rate = sifive_prci_wrpll_set_rate,
52+
.round_rate = sifive_prci_wrpll_round_rate,
53+
.recalc_rate = sifive_prci_wrpll_recalc_rate,
54+
.enable = sifive_prci_clock_enable,
55+
.disable = sifive_prci_clock_disable,
56+
.is_enabled = sifive_clk_is_enabled,
57+
};
58+
59+
static const struct clk_ops sifive_fu540_prci_wrpll_ro_clk_ops = {
60+
.recalc_rate = sifive_prci_wrpll_recalc_rate,
61+
};
62+
63+
static const struct clk_ops sifive_fu540_prci_tlclksel_clk_ops = {
64+
.recalc_rate = sifive_prci_tlclksel_recalc_rate,
65+
};
66+
67+
/* List of clock controls provided by the PRCI */
68+
static struct __prci_clock __prci_init_clocks_fu540[] = {
69+
[FU540_PRCI_CLK_COREPLL] = {
70+
.name = "corepll",
71+
.parent_name = "hfclk",
72+
.ops = &sifive_fu540_prci_wrpll_clk_ops,
73+
.pwd = &sifive_fu540_prci_corepll_data,
74+
},
75+
[FU540_PRCI_CLK_DDRPLL] = {
76+
.name = "ddrpll",
77+
.parent_name = "hfclk",
78+
.ops = &sifive_fu540_prci_wrpll_ro_clk_ops,
79+
.pwd = &sifive_fu540_prci_ddrpll_data,
80+
},
81+
[FU540_PRCI_CLK_GEMGXLPLL] = {
82+
.name = "gemgxlpll",
83+
.parent_name = "hfclk",
84+
.ops = &sifive_fu540_prci_wrpll_clk_ops,
85+
.pwd = &sifive_fu540_prci_gemgxlpll_data,
86+
},
87+
[FU540_PRCI_CLK_TLCLK] = {
88+
.name = "tlclk",
89+
.parent_name = "corepll",
90+
.ops = &sifive_fu540_prci_tlclksel_clk_ops,
91+
},
92+
};
1393

14-
extern struct __prci_clock __prci_init_clocks_fu540[NUM_CLOCK_FU540];
94+
static const struct prci_clk_desc prci_clk_fu540 = {
95+
.clks = __prci_init_clocks_fu540,
96+
.num_clks = ARRAY_SIZE(__prci_init_clocks_fu540),
97+
};
1598

1699
#endif /* __SIFIVE_CLK_FU540_PRCI_H */

drivers/clk/sifive/fu740-prci.c

Lines changed: 0 additions & 133 deletions
This file was deleted.

0 commit comments

Comments
 (0)