20 #include <linux/kernel.h>
24 #include <mach/common.h>
27 #define FRQCRA IOMEM(0xe6150000)
28 #define FRQCRB IOMEM(0xe6150004)
29 #define FRQCRC IOMEM(0xe61500e0)
30 #define FRQCRD IOMEM(0xe61500e4)
31 #define VCLKCR1 IOMEM(0xe6150008)
32 #define VCLKCR2 IOMEM(0xe615000c)
33 #define VCLKCR3 IOMEM(0xe615001c)
34 #define FMSICKCR IOMEM(0xe6150010)
35 #define FMSOCKCR IOMEM(0xe6150014)
36 #define FSIACKCR IOMEM(0xe6150018)
37 #define FSIBCKCR IOMEM(0xe6150090)
38 #define SUBCKCR IOMEM(0xe6150080)
39 #define SPUCKCR IOMEM(0xe6150084)
40 #define VOUCKCR IOMEM(0xe6150088)
41 #define HDMICKCR IOMEM(0xe6150094)
42 #define DSITCKCR IOMEM(0xe6150060)
43 #define DSI0PCKCR IOMEM(0xe6150064)
44 #define DSI1PCKCR IOMEM(0xe6150098)
45 #define PLLC01CR IOMEM(0xe6150028)
46 #define PLLC2CR IOMEM(0xe615002c)
47 #define RMSTPCR0 IOMEM(0xe6150110)
48 #define RMSTPCR1 IOMEM(0xe6150114)
49 #define RMSTPCR2 IOMEM(0xe6150118)
50 #define RMSTPCR3 IOMEM(0xe615011c)
51 #define RMSTPCR4 IOMEM(0xe6150120)
52 #define SMSTPCR0 IOMEM(0xe6150130)
53 #define SMSTPCR1 IOMEM(0xe6150134)
54 #define SMSTPCR2 IOMEM(0xe6150138)
55 #define SMSTPCR3 IOMEM(0xe615013c)
56 #define SMSTPCR4 IOMEM(0xe6150140)
58 #define FSIDIVA 0xFE1F8000
59 #define FSIDIVB 0xFE1F8008
66 static struct clk r_clk = {
87 static unsigned long div2_recalc(
struct clk *
clk)
89 return clk->
parent->rate / 2;
93 .recalc = div2_recalc,
103 static struct clk extal1_div2_clk = {
104 .ops = &div2_clk_ops,
109 static struct clk extal2_div2_clk = {
110 .ops = &div2_clk_ops,
115 static struct clk extal2_div4_clk = {
116 .ops = &div2_clk_ops,
117 .parent = &extal2_div2_clk,
121 static unsigned long pllc01_recalc(
struct clk *
clk)
123 unsigned long mult = 1;
132 .recalc = pllc01_recalc,
135 static struct clk pllc0_clk = {
136 .ops = &pllc01_clk_ops,
138 .parent = &extal1_div2_clk,
142 static struct clk pllc1_clk = {
143 .ops = &pllc01_clk_ops,
145 .parent = &extal1_div2_clk,
150 static struct clk pllc1_div2_clk = {
151 .ops = &div2_clk_ops,
152 .parent = &pllc1_clk,
158 static struct clk *pllc2_parent[] = {
159 [0] = &extal1_div2_clk,
160 [1] = &extal2_div2_clk,
167 static void pllc2_table_rebuild(
struct clk *clk)
172 for (i = 0; i <
ARRAY_SIZE(pllc2_freq_table) - 2; i++) {
173 pllc2_freq_table[
i].frequency = clk->
parent->rate * (i + 20) * 2;
174 pllc2_freq_table[
i].index =
i;
178 pllc2_freq_table[
i].frequency = clk->
parent->rate;
179 pllc2_freq_table[
i].index =
i;
182 pllc2_freq_table[
i].index =
i;
185 static unsigned long pllc2_recalc(
struct clk *clk)
187 unsigned long mult = 1;
189 pllc2_table_rebuild(clk);
201 static long pllc2_round_rate(
struct clk *clk,
unsigned long rate)
206 static int pllc2_enable(
struct clk *clk)
212 for (i = 0; i < 100; i++)
214 clk->
rate = pllc2_recalc(clk);
218 pr_err(
"%s(): timeout!\n", __func__);
223 static void pllc2_disable(
struct clk *clk)
228 static int pllc2_set_rate(
struct clk *clk,
unsigned long rate)
237 if (rate == clk->
parent->rate)
249 static int pllc2_set_parent(
struct clk *clk,
struct clk *parent)
274 pllc2_table_rebuild(clk);
280 .recalc = pllc2_recalc,
281 .round_rate = pllc2_round_rate,
282 .set_rate = pllc2_set_rate,
283 .enable = pllc2_enable,
284 .disable = pllc2_disable,
285 .set_parent = pllc2_set_parent,
289 .ops = &pllc2_clk_ops,
290 .parent = &extal1_div2_clk,
293 .parent_table = pllc2_parent,
321 static void div4_kick(
struct clk *clk)
331 static int divisors[] = { 2, 3, 4, 6, 8, 12, 16, 18,
332 24, 32, 36, 48, 0, 72, 96, 0 };
340 .div_mult_table = &div4_div_mult_table,
349 #define DIV4(_reg, _bit, _mask, _flags) \
350 SH_CLK_DIV4(&pllc1_clk, _reg, _bit, _mask, _flags)
375 static struct clk div6_clks[
DIV6_NR] = {
392 static struct clk *hdmi_parent[] = {
393 [0] = &pllc1_div2_clk,
399 static struct clk *fsiackcr_parent[] = {
400 [0] = &pllc1_div2_clk,
406 static struct clk *fsibckcr_parent[] = {
407 [0] = &pllc1_div2_clk,
417 fsiackcr_parent,
ARRAY_SIZE(fsiackcr_parent), 6, 2),
419 fsibckcr_parent,
ARRAY_SIZE(fsibckcr_parent), 6, 2),
423 static unsigned long fsidiv_recalc(
struct clk *clk)
436 static long fsidiv_round_rate(
struct clk *clk,
unsigned long rate)
441 static void fsidiv_disable(
struct clk *clk)
446 static int fsidiv_enable(
struct clk *clk)
459 static int fsidiv_set_rate(
struct clk *clk,
unsigned long rate)
472 .recalc = fsidiv_recalc,
473 .round_rate = fsidiv_round_rate,
474 .set_rate = fsidiv_set_rate,
475 .enable = fsidiv_enable,
476 .disable = fsidiv_disable,
485 .ops = &fsidiv_clk_ops,
486 .parent = &div6_reparent_clks[
DIV6_FSIA],
487 .
mapping = &fsidiva_clk_mapping,
496 .ops = &fsidiv_clk_ops,
497 .parent = &div6_reparent_clks[
DIV6_FSIB],
498 .
mapping = &fsidivb_clk_mapping,
501 static struct clk *late_main_clks[] = {
519 #define MSTP(_parent, _reg, _bit, _flags) \
520 SH_CLK_MSTP32(_parent, _reg, _bit, _flags)
522 static struct clk mstp_clks[
MSTP_NR] = {
694 for (k = 0; !ret && (k <
ARRAY_SIZE(main_clks)); k++)
709 for (k = 0; !ret && (k <
ARRAY_SIZE(late_main_clks)); k++)
717 panic(
"failed to setup sh7372 clocks\n");