1 // SPDX-License-Identifier: GPL-2.0
3 * PLL clock descriptions for TI DA850/OMAP-L138/AM18XX
5 * Copyright (C) 2018 David Lechner <david@lechnology.com>
8 #include <linux/bitops.h>
9 #include <linux/clk-provider.h>
10 #include <linux/clk/davinci.h>
11 #include <linux/clkdev.h>
12 #include <linux/device.h>
13 #include <linux/init.h>
15 #include <linux/kernel.h>
16 #include <linux/mfd/da8xx-cfgchip.h>
17 #include <linux/mfd/syscon.h>
18 #include <linux/of_address.h>
20 #include <linux/types.h>
24 #define OCSEL_OCSRC_OSCIN 0x14
25 #define OCSEL_OCSRC_PLL0_SYSCLK(n) (0x16 + (n))
26 #define OCSEL_OCSRC_PLL1_OBSCLK 0x1e
27 #define OCSEL_OCSRC_PLL1_SYSCLK(n) (0x16 + (n))
29 static const struct davinci_pll_clk_info da850_pll0_info
= {
31 .unlock_reg
= CFGCHIP(0),
32 .unlock_mask
= CFGCHIP0_PLL_MASTER_LOCK
,
33 .pllm_mask
= GENMASK(4, 0),
36 .pllout_min_rate
= 300000000,
37 .pllout_max_rate
= 600000000,
38 .flags
= PLL_HAS_CLKMODE
| PLL_HAS_PREDIV
| PLL_HAS_POSTDIV
|
43 * NB: Technically, the clocks flagged as SYSCLK_FIXED_DIV are "fixed ratio",
44 * meaning that we could change the divider as long as we keep the correct
45 * ratio between all of the clocks, but we don't support that because there is
46 * currently not a need for it.
49 SYSCLK(1, pll0_sysclk1
, pll0_pllen
, 5, SYSCLK_FIXED_DIV
);
50 SYSCLK(2, pll0_sysclk2
, pll0_pllen
, 5, SYSCLK_FIXED_DIV
);
51 SYSCLK(3, pll0_sysclk3
, pll0_pllen
, 5, 0);
52 SYSCLK(4, pll0_sysclk4
, pll0_pllen
, 5, SYSCLK_FIXED_DIV
);
53 SYSCLK(5, pll0_sysclk5
, pll0_pllen
, 5, 0);
54 SYSCLK(6, pll0_sysclk6
, pll0_pllen
, 5, SYSCLK_ARM_RATE
| SYSCLK_FIXED_DIV
);
55 SYSCLK(7, pll0_sysclk7
, pll0_pllen
, 5, 0);
57 static const char * const da850_pll0_obsclk_parent_names
[] = {
69 static u32 da850_pll0_obsclk_table
[] = {
71 OCSEL_OCSRC_PLL0_SYSCLK(1),
72 OCSEL_OCSRC_PLL0_SYSCLK(2),
73 OCSEL_OCSRC_PLL0_SYSCLK(3),
74 OCSEL_OCSRC_PLL0_SYSCLK(4),
75 OCSEL_OCSRC_PLL0_SYSCLK(5),
76 OCSEL_OCSRC_PLL0_SYSCLK(6),
77 OCSEL_OCSRC_PLL0_SYSCLK(7),
78 OCSEL_OCSRC_PLL1_OBSCLK
,
81 static const struct davinci_pll_obsclk_info da850_pll0_obsclk_info
= {
82 .name
= "pll0_obsclk",
83 .parent_names
= da850_pll0_obsclk_parent_names
,
84 .num_parents
= ARRAY_SIZE(da850_pll0_obsclk_parent_names
),
85 .table
= da850_pll0_obsclk_table
,
86 .ocsrc_mask
= GENMASK(4, 0),
89 int da850_pll0_init(struct device
*dev
, void __iomem
*base
, struct regmap
*cfgchip
)
93 davinci_pll_clk_register(dev
, &da850_pll0_info
, "ref_clk", base
, cfgchip
);
95 clk
= davinci_pll_sysclk_register(dev
, &pll0_sysclk1
, base
);
96 clk_register_clkdev(clk
, "pll0_sysclk1", "da850-psc0");
98 clk
= davinci_pll_sysclk_register(dev
, &pll0_sysclk2
, base
);
99 clk_register_clkdev(clk
, "pll0_sysclk2", "da850-psc0");
100 clk_register_clkdev(clk
, "pll0_sysclk2", "da850-psc1");
101 clk_register_clkdev(clk
, "pll0_sysclk2", "da850-async3-clksrc");
103 clk
= davinci_pll_sysclk_register(dev
, &pll0_sysclk3
, base
);
104 clk_register_clkdev(clk
, "pll0_sysclk3", "da850-async1-clksrc");
106 clk
= davinci_pll_sysclk_register(dev
, &pll0_sysclk4
, base
);
107 clk_register_clkdev(clk
, "pll0_sysclk4", "da850-psc0");
108 clk_register_clkdev(clk
, "pll0_sysclk4", "da850-psc1");
110 davinci_pll_sysclk_register(dev
, &pll0_sysclk5
, base
);
112 clk
= davinci_pll_sysclk_register(dev
, &pll0_sysclk6
, base
);
113 clk_register_clkdev(clk
, "pll0_sysclk6", "da850-psc0");
115 davinci_pll_sysclk_register(dev
, &pll0_sysclk7
, base
);
117 davinci_pll_auxclk_register(dev
, "pll0_auxclk", base
);
119 clk
= clk_register_fixed_factor(dev
, "async2", "pll0_auxclk",
120 CLK_IS_CRITICAL
, 1, 1);
122 clk_register_clkdev(clk
, NULL
, "i2c_davinci.1");
123 clk_register_clkdev(clk
, "timer0", NULL
);
124 clk_register_clkdev(clk
, NULL
, "davinci-wdt");
126 davinci_pll_obsclk_register(dev
, &da850_pll0_obsclk_info
, base
);
131 static const struct davinci_pll_sysclk_info
*da850_pll0_sysclk_info
[] = {
142 void of_da850_pll0_init(struct device_node
*node
)
145 struct regmap
*cfgchip
;
147 base
= of_iomap(node
, 0);
149 pr_err("%s: ioremap failed\n", __func__
);
153 cfgchip
= syscon_regmap_lookup_by_compatible("ti,da830-cfgchip");
155 of_davinci_pll_init(NULL
, node
, &da850_pll0_info
,
156 &da850_pll0_obsclk_info
,
157 da850_pll0_sysclk_info
, 7, base
, cfgchip
);
160 static const struct davinci_pll_clk_info da850_pll1_info
= {
162 .unlock_reg
= CFGCHIP(3),
163 .unlock_mask
= CFGCHIP3_PLL1_MASTER_LOCK
,
164 .pllm_mask
= GENMASK(4, 0),
167 .pllout_min_rate
= 300000000,
168 .pllout_max_rate
= 600000000,
169 .flags
= PLL_HAS_POSTDIV
,
172 SYSCLK(1, pll1_sysclk1
, pll1_pllen
, 5, SYSCLK_ALWAYS_ENABLED
);
173 SYSCLK(2, pll1_sysclk2
, pll1_pllen
, 5, 0);
174 SYSCLK(3, pll1_sysclk3
, pll1_pllen
, 5, 0);
176 static const char * const da850_pll1_obsclk_parent_names
[] = {
183 static u32 da850_pll1_obsclk_table
[] = {
185 OCSEL_OCSRC_PLL1_SYSCLK(1),
186 OCSEL_OCSRC_PLL1_SYSCLK(2),
187 OCSEL_OCSRC_PLL1_SYSCLK(3),
190 static const struct davinci_pll_obsclk_info da850_pll1_obsclk_info
= {
191 .name
= "pll1_obsclk",
192 .parent_names
= da850_pll1_obsclk_parent_names
,
193 .num_parents
= ARRAY_SIZE(da850_pll1_obsclk_parent_names
),
194 .table
= da850_pll1_obsclk_table
,
195 .ocsrc_mask
= GENMASK(4, 0),
198 int da850_pll1_init(struct device
*dev
, void __iomem
*base
, struct regmap
*cfgchip
)
202 davinci_pll_clk_register(dev
, &da850_pll1_info
, "oscin", base
, cfgchip
);
204 davinci_pll_sysclk_register(dev
, &pll1_sysclk1
, base
);
206 clk
= davinci_pll_sysclk_register(dev
, &pll1_sysclk2
, base
);
207 clk_register_clkdev(clk
, "pll1_sysclk2", "da850-async3-clksrc");
209 davinci_pll_sysclk_register(dev
, &pll1_sysclk3
, base
);
211 davinci_pll_obsclk_register(dev
, &da850_pll1_obsclk_info
, base
);
216 static const struct davinci_pll_sysclk_info
*da850_pll1_sysclk_info
[] = {
223 int of_da850_pll1_init(struct device
*dev
, void __iomem
*base
, struct regmap
*cfgchip
)
225 return of_davinci_pll_init(dev
, dev
->of_node
, &da850_pll1_info
,
226 &da850_pll1_obsclk_info
,
227 da850_pll1_sysclk_info
, 3, base
, cfgchip
);