WIP FPC-III support
[linux/fpc-iii.git] / drivers / clk / sifive / fu740-prci.c
blob764d1097aa51f91b838a49945aaaff84162abdb4
1 // SPDX-License-Identifier: GPL-2.0
2 /*
3 * Copyright (C) 2020 SiFive, Inc.
4 * Copyright (C) 2020 Zong Li
5 */
7 #include <linux/module.h>
9 #include <dt-bindings/clock/sifive-fu740-prci.h>
11 #include "fu540-prci.h"
12 #include "sifive-prci.h"
14 /* PRCI integration data for each WRPLL instance */
16 static struct __prci_wrpll_data __prci_corepll_data = {
17 .cfg0_offs = PRCI_COREPLLCFG0_OFFSET,
18 .cfg1_offs = PRCI_COREPLLCFG1_OFFSET,
19 .enable_bypass = sifive_prci_coreclksel_use_hfclk,
20 .disable_bypass = sifive_prci_coreclksel_use_final_corepll,
23 static struct __prci_wrpll_data __prci_ddrpll_data = {
24 .cfg0_offs = PRCI_DDRPLLCFG0_OFFSET,
25 .cfg1_offs = PRCI_DDRPLLCFG1_OFFSET,
28 static struct __prci_wrpll_data __prci_gemgxlpll_data = {
29 .cfg0_offs = PRCI_GEMGXLPLLCFG0_OFFSET,
30 .cfg1_offs = PRCI_GEMGXLPLLCFG1_OFFSET,
33 static struct __prci_wrpll_data __prci_dvfscorepll_data = {
34 .cfg0_offs = PRCI_DVFSCOREPLLCFG0_OFFSET,
35 .cfg1_offs = PRCI_DVFSCOREPLLCFG1_OFFSET,
36 .enable_bypass = sifive_prci_corepllsel_use_corepll,
37 .disable_bypass = sifive_prci_corepllsel_use_dvfscorepll,
40 static struct __prci_wrpll_data __prci_hfpclkpll_data = {
41 .cfg0_offs = PRCI_HFPCLKPLLCFG0_OFFSET,
42 .cfg1_offs = PRCI_HFPCLKPLLCFG1_OFFSET,
43 .enable_bypass = sifive_prci_hfpclkpllsel_use_hfclk,
44 .disable_bypass = sifive_prci_hfpclkpllsel_use_hfpclkpll,
47 static struct __prci_wrpll_data __prci_cltxpll_data = {
48 .cfg0_offs = PRCI_CLTXPLLCFG0_OFFSET,
49 .cfg1_offs = PRCI_CLTXPLLCFG1_OFFSET,
52 /* Linux clock framework integration */
54 static const struct clk_ops sifive_fu740_prci_wrpll_clk_ops = {
55 .set_rate = sifive_prci_wrpll_set_rate,
56 .round_rate = sifive_prci_wrpll_round_rate,
57 .recalc_rate = sifive_prci_wrpll_recalc_rate,
58 .enable = sifive_prci_clock_enable,
59 .disable = sifive_prci_clock_disable,
60 .is_enabled = sifive_clk_is_enabled,
63 static const struct clk_ops sifive_fu740_prci_wrpll_ro_clk_ops = {
64 .recalc_rate = sifive_prci_wrpll_recalc_rate,
67 static const struct clk_ops sifive_fu740_prci_tlclksel_clk_ops = {
68 .recalc_rate = sifive_prci_tlclksel_recalc_rate,
71 static const struct clk_ops sifive_fu740_prci_hfpclkplldiv_clk_ops = {
72 .recalc_rate = sifive_prci_hfpclkplldiv_recalc_rate,
75 /* List of clock controls provided by the PRCI */
76 struct __prci_clock __prci_init_clocks_fu740[] = {
77 [PRCI_CLK_COREPLL] = {
78 .name = "corepll",
79 .parent_name = "hfclk",
80 .ops = &sifive_fu740_prci_wrpll_clk_ops,
81 .pwd = &__prci_corepll_data,
83 [PRCI_CLK_DDRPLL] = {
84 .name = "ddrpll",
85 .parent_name = "hfclk",
86 .ops = &sifive_fu740_prci_wrpll_ro_clk_ops,
87 .pwd = &__prci_ddrpll_data,
89 [PRCI_CLK_GEMGXLPLL] = {
90 .name = "gemgxlpll",
91 .parent_name = "hfclk",
92 .ops = &sifive_fu740_prci_wrpll_clk_ops,
93 .pwd = &__prci_gemgxlpll_data,
95 [PRCI_CLK_DVFSCOREPLL] = {
96 .name = "dvfscorepll",
97 .parent_name = "hfclk",
98 .ops = &sifive_fu740_prci_wrpll_clk_ops,
99 .pwd = &__prci_dvfscorepll_data,
101 [PRCI_CLK_HFPCLKPLL] = {
102 .name = "hfpclkpll",
103 .parent_name = "hfclk",
104 .ops = &sifive_fu740_prci_wrpll_clk_ops,
105 .pwd = &__prci_hfpclkpll_data,
107 [PRCI_CLK_CLTXPLL] = {
108 .name = "cltxpll",
109 .parent_name = "hfclk",
110 .ops = &sifive_fu740_prci_wrpll_clk_ops,
111 .pwd = &__prci_cltxpll_data,
113 [PRCI_CLK_TLCLK] = {
114 .name = "tlclk",
115 .parent_name = "corepll",
116 .ops = &sifive_fu740_prci_tlclksel_clk_ops,
118 [PRCI_CLK_PCLK] = {
119 .name = "pclk",
120 .parent_name = "hfpclkpll",
121 .ops = &sifive_fu740_prci_hfpclkplldiv_clk_ops,