blob: 5f8d9f42d0f376c24ae45560b85f9b41829ec863 [file] [log] [blame]
David Lechner650bba62018-03-15 21:52:22 -05001// SPDX-License-Identifier: GPL-2.0
2/*
3 * PLL clock descriptions for TI DM365
4 *
5 * Copyright (C) 2018 David Lechner <david@lechnology.com>
6 */
7
8#include <linux/bitops.h>
9#include <linux/clkdev.h>
10#include <linux/init.h>
11#include <linux/kernel.h>
12#include <linux/types.h>
13
14#include "pll.h"
15
16#define OCSEL_OCSRC_ENABLE 0
17
18static const struct davinci_pll_clk_info dm365_pll1_info = {
19 .name = "pll1",
20 .pllm_mask = GENMASK(9, 0),
21 .pllm_min = 1,
22 .pllm_max = 1023,
23 .flags = PLL_HAS_CLKMODE | PLL_HAS_PREDIV | PLL_HAS_POSTDIV |
24 PLL_POSTDIV_ALWAYS_ENABLED | PLL_PLLM_2X,
25};
26
27SYSCLK(1, pll1_sysclk1, pll1_pllen, 5, SYSCLK_ALWAYS_ENABLED);
28SYSCLK(2, pll1_sysclk2, pll1_pllen, 5, SYSCLK_ALWAYS_ENABLED);
29SYSCLK(3, pll1_sysclk3, pll1_pllen, 5, SYSCLK_ALWAYS_ENABLED);
30SYSCLK(4, pll1_sysclk4, pll1_pllen, 5, SYSCLK_ALWAYS_ENABLED);
31SYSCLK(5, pll1_sysclk5, pll1_pllen, 5, SYSCLK_ALWAYS_ENABLED);
32SYSCLK(6, pll1_sysclk6, pll1_pllen, 5, SYSCLK_ALWAYS_ENABLED);
33SYSCLK(7, pll1_sysclk7, pll1_pllen, 5, SYSCLK_ALWAYS_ENABLED);
34SYSCLK(8, pll1_sysclk8, pll1_pllen, 5, SYSCLK_ALWAYS_ENABLED);
35SYSCLK(9, pll1_sysclk9, pll1_pllen, 5, SYSCLK_ALWAYS_ENABLED);
36
37/*
38 * This is a bit of a hack to make OCSEL[OCSRC] on DM365 look like OCSEL[OCSRC]
39 * on DA850. On DM365, OCSEL[OCSRC] is just an enable/disable bit instead of a
40 * multiplexer. By modeling it as a single parent mux clock, the clock code will
41 * still do the right thing in this case.
42 */
43static const char * const dm365_pll_obsclk_parent_names[] = {
44 "oscin",
45};
46
47static u32 dm365_pll_obsclk_table[] = {
48 OCSEL_OCSRC_ENABLE,
49};
50
51static const struct davinci_pll_obsclk_info dm365_pll1_obsclk_info = {
52 .name = "pll1_obsclk",
53 .parent_names = dm365_pll_obsclk_parent_names,
54 .num_parents = ARRAY_SIZE(dm365_pll_obsclk_parent_names),
55 .table = dm365_pll_obsclk_table,
56 .ocsrc_mask = BIT(4),
57};
58
59int dm365_pll1_init(struct device *dev, void __iomem *base)
60{
61 struct clk *clk;
62
63 davinci_pll_clk_register(dev, &dm365_pll1_info, "ref_clk", base);
64
65 clk = davinci_pll_sysclk_register(dev, &pll1_sysclk1, base);
66 clk_register_clkdev(clk, "pll1_sysclk1", "dm365-psc");
67
68 clk = davinci_pll_sysclk_register(dev, &pll1_sysclk2, base);
69 clk_register_clkdev(clk, "pll1_sysclk2", "dm365-psc");
70
71 clk = davinci_pll_sysclk_register(dev, &pll1_sysclk3, base);
72 clk_register_clkdev(clk, "pll1_sysclk3", "dm365-psc");
73
74 clk = davinci_pll_sysclk_register(dev, &pll1_sysclk4, base);
75 clk_register_clkdev(clk, "pll1_sysclk4", "dm365-psc");
76
77 clk = davinci_pll_sysclk_register(dev, &pll1_sysclk5, base);
78 clk_register_clkdev(clk, "pll1_sysclk5", "dm365-psc");
79
80 davinci_pll_sysclk_register(dev, &pll1_sysclk6, base);
81
82 davinci_pll_sysclk_register(dev, &pll1_sysclk7, base);
83
84 clk = davinci_pll_sysclk_register(dev, &pll1_sysclk8, base);
85 clk_register_clkdev(clk, "pll1_sysclk8", "dm365-psc");
86
87 davinci_pll_sysclk_register(dev, &pll1_sysclk9, base);
88
89 clk = davinci_pll_auxclk_register(dev, "pll1_auxclk", base);
90 clk_register_clkdev(clk, "pll1_auxclk", "dm355-psc");
91
92 davinci_pll_sysclkbp_clk_register(dev, "pll1_sysclkbp", base);
93
94 davinci_pll_obsclk_register(dev, &dm365_pll1_obsclk_info, base);
95
96 return 0;
97}
98
99static const struct davinci_pll_clk_info dm365_pll2_info = {
100 .name = "pll2",
101 .pllm_mask = GENMASK(9, 0),
102 .pllm_min = 1,
103 .pllm_max = 1023,
104 .flags = PLL_HAS_PREDIV | PLL_HAS_POSTDIV | PLL_POSTDIV_ALWAYS_ENABLED |
105 PLL_PLLM_2X,
106};
107
108SYSCLK(1, pll2_sysclk1, pll2_pllen, 5, SYSCLK_ALWAYS_ENABLED);
109SYSCLK(2, pll2_sysclk2, pll2_pllen, 5, SYSCLK_ALWAYS_ENABLED);
110SYSCLK(3, pll2_sysclk3, pll2_pllen, 5, SYSCLK_ALWAYS_ENABLED);
111SYSCLK(4, pll2_sysclk4, pll2_pllen, 5, SYSCLK_ALWAYS_ENABLED);
112SYSCLK(5, pll2_sysclk5, pll2_pllen, 5, SYSCLK_ALWAYS_ENABLED);
113
114static const struct davinci_pll_obsclk_info dm365_pll2_obsclk_info = {
115 .name = "pll2_obsclk",
116 .parent_names = dm365_pll_obsclk_parent_names,
117 .num_parents = ARRAY_SIZE(dm365_pll_obsclk_parent_names),
118 .table = dm365_pll_obsclk_table,
119 .ocsrc_mask = BIT(4),
120};
121
122int dm365_pll2_init(struct device *dev, void __iomem *base)
123{
124 struct clk *clk;
125
126 davinci_pll_clk_register(dev, &dm365_pll2_info, "oscin", base);
127
128 davinci_pll_sysclk_register(dev, &pll2_sysclk1, base);
129
130 clk = davinci_pll_sysclk_register(dev, &pll2_sysclk2, base);
131 clk_register_clkdev(clk, "pll1_sysclk2", "dm365-psc");
132
133 davinci_pll_sysclk_register(dev, &pll2_sysclk3, base);
134
135 clk = davinci_pll_sysclk_register(dev, &pll2_sysclk4, base);
136 clk_register_clkdev(clk, "pll1_sysclk4", "dm365-psc");
137
138 davinci_pll_sysclk_register(dev, &pll2_sysclk5, base);
139
140 davinci_pll_auxclk_register(dev, "pll2_auxclk", base);
141
142 davinci_pll_obsclk_register(dev, &dm365_pll2_obsclk_info, base);
143
144 return 0;
145}