Merge tag 'block-5.11-2021-01-10' of git://git.kernel.dk/linux-block
[linux/fpc-iii.git] / drivers / clk / davinci / pll-dm365.c
blob2d29712753a37641ddb9e8e311d4f44e05df42ef
1 // SPDX-License-Identifier: GPL-2.0
2 /*
3 * PLL clock descriptions for TI DM365
5 * Copyright (C) 2018 David Lechner <david@lechnology.com>
6 */
8 #include <linux/bitops.h>
9 #include <linux/clkdev.h>
10 #include <linux/clk/davinci.h>
11 #include <linux/init.h>
12 #include <linux/kernel.h>
13 #include <linux/types.h>
15 #include "pll.h"
17 #define OCSEL_OCSRC_ENABLE 0
19 static const struct davinci_pll_clk_info dm365_pll1_info = {
20 .name = "pll1",
21 .pllm_mask = GENMASK(9, 0),
22 .pllm_min = 1,
23 .pllm_max = 1023,
24 .flags = PLL_HAS_CLKMODE | PLL_HAS_PREDIV | PLL_HAS_POSTDIV |
25 PLL_POSTDIV_ALWAYS_ENABLED | PLL_PLLM_2X,
28 SYSCLK(1, pll1_sysclk1, pll1_pllen, 5, SYSCLK_ALWAYS_ENABLED);
29 SYSCLK(2, pll1_sysclk2, pll1_pllen, 5, SYSCLK_ALWAYS_ENABLED);
30 SYSCLK(3, pll1_sysclk3, pll1_pllen, 5, SYSCLK_ALWAYS_ENABLED);
31 SYSCLK(4, pll1_sysclk4, pll1_pllen, 5, SYSCLK_ALWAYS_ENABLED);
32 SYSCLK(5, pll1_sysclk5, pll1_pllen, 5, SYSCLK_ALWAYS_ENABLED);
33 SYSCLK(6, pll1_sysclk6, pll1_pllen, 5, SYSCLK_ALWAYS_ENABLED);
34 SYSCLK(7, pll1_sysclk7, pll1_pllen, 5, SYSCLK_ALWAYS_ENABLED);
35 SYSCLK(8, pll1_sysclk8, pll1_pllen, 5, SYSCLK_ALWAYS_ENABLED);
36 SYSCLK(9, pll1_sysclk9, pll1_pllen, 5, SYSCLK_ALWAYS_ENABLED);
39 * This is a bit of a hack to make OCSEL[OCSRC] on DM365 look like OCSEL[OCSRC]
40 * on DA850. On DM365, OCSEL[OCSRC] is just an enable/disable bit instead of a
41 * multiplexer. By modeling it as a single parent mux clock, the clock code will
42 * still do the right thing in this case.
44 static const char * const dm365_pll_obsclk_parent_names[] = {
45 "oscin",
48 static u32 dm365_pll_obsclk_table[] = {
49 OCSEL_OCSRC_ENABLE,
52 static const struct davinci_pll_obsclk_info dm365_pll1_obsclk_info = {
53 .name = "pll1_obsclk",
54 .parent_names = dm365_pll_obsclk_parent_names,
55 .num_parents = ARRAY_SIZE(dm365_pll_obsclk_parent_names),
56 .table = dm365_pll_obsclk_table,
57 .ocsrc_mask = BIT(4),
60 int dm365_pll1_init(struct device *dev, void __iomem *base, struct regmap *cfgchip)
62 struct clk *clk;
64 davinci_pll_clk_register(dev, &dm365_pll1_info, "ref_clk", base, cfgchip);
66 clk = davinci_pll_sysclk_register(dev, &pll1_sysclk1, base);
67 clk_register_clkdev(clk, "pll1_sysclk1", "dm365-psc");
69 clk = davinci_pll_sysclk_register(dev, &pll1_sysclk2, base);
70 clk_register_clkdev(clk, "pll1_sysclk2", "dm365-psc");
72 clk = davinci_pll_sysclk_register(dev, &pll1_sysclk3, base);
73 clk_register_clkdev(clk, "pll1_sysclk3", "dm365-psc");
75 clk = davinci_pll_sysclk_register(dev, &pll1_sysclk4, base);
76 clk_register_clkdev(clk, "pll1_sysclk4", "dm365-psc");
78 clk = davinci_pll_sysclk_register(dev, &pll1_sysclk5, base);
79 clk_register_clkdev(clk, "pll1_sysclk5", "dm365-psc");
81 davinci_pll_sysclk_register(dev, &pll1_sysclk6, base);
83 davinci_pll_sysclk_register(dev, &pll1_sysclk7, base);
85 clk = davinci_pll_sysclk_register(dev, &pll1_sysclk8, base);
86 clk_register_clkdev(clk, "pll1_sysclk8", "dm365-psc");
88 davinci_pll_sysclk_register(dev, &pll1_sysclk9, base);
90 clk = davinci_pll_auxclk_register(dev, "pll1_auxclk", base);
91 clk_register_clkdev(clk, "pll1_auxclk", "dm355-psc");
93 davinci_pll_sysclkbp_clk_register(dev, "pll1_sysclkbp", base);
95 davinci_pll_obsclk_register(dev, &dm365_pll1_obsclk_info, base);
97 return 0;
100 static const struct davinci_pll_clk_info dm365_pll2_info = {
101 .name = "pll2",
102 .pllm_mask = GENMASK(9, 0),
103 .pllm_min = 1,
104 .pllm_max = 1023,
105 .flags = PLL_HAS_PREDIV | PLL_HAS_POSTDIV | PLL_POSTDIV_ALWAYS_ENABLED |
106 PLL_PLLM_2X,
109 SYSCLK(1, pll2_sysclk1, pll2_pllen, 5, SYSCLK_ALWAYS_ENABLED);
110 SYSCLK(2, pll2_sysclk2, pll2_pllen, 5, SYSCLK_ALWAYS_ENABLED);
111 SYSCLK(3, pll2_sysclk3, pll2_pllen, 5, SYSCLK_ALWAYS_ENABLED);
112 SYSCLK(4, pll2_sysclk4, pll2_pllen, 5, SYSCLK_ALWAYS_ENABLED);
113 SYSCLK(5, pll2_sysclk5, pll2_pllen, 5, SYSCLK_ALWAYS_ENABLED);
115 static const struct davinci_pll_obsclk_info dm365_pll2_obsclk_info = {
116 .name = "pll2_obsclk",
117 .parent_names = dm365_pll_obsclk_parent_names,
118 .num_parents = ARRAY_SIZE(dm365_pll_obsclk_parent_names),
119 .table = dm365_pll_obsclk_table,
120 .ocsrc_mask = BIT(4),
123 int dm365_pll2_init(struct device *dev, void __iomem *base, struct regmap *cfgchip)
125 struct clk *clk;
127 davinci_pll_clk_register(dev, &dm365_pll2_info, "oscin", base, cfgchip);
129 davinci_pll_sysclk_register(dev, &pll2_sysclk1, base);
131 clk = davinci_pll_sysclk_register(dev, &pll2_sysclk2, base);
132 clk_register_clkdev(clk, "pll1_sysclk2", "dm365-psc");
134 davinci_pll_sysclk_register(dev, &pll2_sysclk3, base);
136 clk = davinci_pll_sysclk_register(dev, &pll2_sysclk4, base);
137 clk_register_clkdev(clk, "pll1_sysclk4", "dm365-psc");
139 davinci_pll_sysclk_register(dev, &pll2_sysclk5, base);
141 davinci_pll_auxclk_register(dev, "pll2_auxclk", base);
143 davinci_pll_obsclk_register(dev, &dm365_pll2_obsclk_info, base);
145 return 0;