20 #include <linux/kernel.h>
24 #include <mach/common.h>
26 #define FRQCRA IOMEM(0xe6150000)
27 #define FRQCRB IOMEM(0xe6150004)
28 #define FRQCRD IOMEM(0xe61500e4)
29 #define VCLKCR1 IOMEM(0xe6150008)
30 #define VCLKCR2 IOMEM(0xe615000C)
31 #define VCLKCR3 IOMEM(0xe615001C)
32 #define ZBCKCR IOMEM(0xe6150010)
33 #define FLCKCR IOMEM(0xe6150014)
34 #define SD0CKCR IOMEM(0xe6150074)
35 #define SD1CKCR IOMEM(0xe6150078)
36 #define SD2CKCR IOMEM(0xe615007C)
37 #define FSIACKCR IOMEM(0xe6150018)
38 #define FSIBCKCR IOMEM(0xe6150090)
39 #define SUBCKCR IOMEM(0xe6150080)
40 #define SPUACKCR IOMEM(0xe6150084)
41 #define SPUVCKCR IOMEM(0xe6150094)
42 #define MSUCKCR IOMEM(0xe6150088)
43 #define HSICKCR IOMEM(0xe615008C)
44 #define MFCK1CR IOMEM(0xe6150098)
45 #define MFCK2CR IOMEM(0xe615009C)
46 #define DSITCKCR IOMEM(0xe6150060)
47 #define DSI0PCKCR IOMEM(0xe6150064)
48 #define DSI1PCKCR IOMEM(0xe6150068)
49 #define DSI0PHYCR 0xe615006C
50 #define DSI1PHYCR 0xe6150070
51 #define PLLECR IOMEM(0xe61500d0)
52 #define PLL0CR IOMEM(0xe61500d8)
53 #define PLL1CR IOMEM(0xe6150028)
54 #define PLL2CR IOMEM(0xe615002c)
55 #define PLL3CR IOMEM(0xe61500dc)
56 #define SMSTPCR0 IOMEM(0xe6150130)
57 #define SMSTPCR1 IOMEM(0xe6150134)
58 #define SMSTPCR2 IOMEM(0xe6150138)
59 #define SMSTPCR3 IOMEM(0xe615013c)
60 #define SMSTPCR4 IOMEM(0xe6150140)
61 #define SMSTPCR5 IOMEM(0xe6150144)
62 #define CKSCR IOMEM(0xe61500c0)
65 static struct clk r_clk = {
86 static unsigned long div2_recalc(
struct clk *
clk)
88 return clk->
parent->rate / 2;
92 .recalc = div2_recalc,
95 static unsigned long div7_recalc(
struct clk *
clk)
97 return clk->
parent->rate / 7;
101 .recalc = div7_recalc,
104 static unsigned long div13_recalc(
struct clk *
clk)
106 return clk->
parent->rate / 13;
110 .recalc = div13_recalc,
114 static struct clk extal1_div2_clk = {
115 .ops = &div2_clk_ops,
120 static struct clk extal2_div2_clk = {
121 .ops = &div2_clk_ops,
131 .ops = &main_clk_ops,
135 static struct clk main_div2_clk = {
136 .ops = &div2_clk_ops,
141 static unsigned long pll_recalc(
struct clk *
clk)
143 unsigned long mult = 1;
160 .recalc = pll_recalc,
163 static struct clk pll0_clk = {
171 static struct clk pll1_clk = {
179 static struct clk pll2_clk = {
187 static struct clk pll3_clk = {
196 static struct clk pll1_div2_clk = {
197 .ops = &div2_clk_ops,
201 static struct clk pll1_div7_clk = {
202 .ops = &div7_clk_ops,
206 static struct clk pll1_div13_clk = {
207 .ops = &div13_clk_ops,
237 static void div4_kick(
struct clk *clk)
247 static int divisors[] = { 2, 3, 4, 6, 8, 12, 16, 18,
256 .div_mult_table = &div4_div_mult_table,
263 #define DIV4(_reg, _bit, _mask, _flags) \
264 SH_CLK_DIV4(&pll1_clk, _reg, _bit, _mask, _flags)
288 static struct clk *vck_parent[8] = {
289 [0] = &pll1_div2_clk,
293 [4] = &main_div2_clk,
298 static struct clk *pll_parent[4] = {
299 [0] = &pll1_div2_clk,
301 [2] = &pll1_div13_clk,
304 static struct clk *hsi_parent[4] = {
305 [0] = &pll1_div2_clk,
307 [2] = &pll1_div7_clk,
310 static struct clk *pll_extal2_parent[] = {
311 [0] = &pll1_div2_clk,
317 static struct clk *dsi_parent[8] = {
318 [0] = &pll1_div2_clk,
325 static struct clk div6_clks[
DIV6_NR] = {
347 pll_extal2_parent,
ARRAY_SIZE(pll_extal2_parent), 6, 2),
349 pll_extal2_parent,
ARRAY_SIZE(pll_extal2_parent), 6, 2),
351 pll_extal2_parent,
ARRAY_SIZE(pll_extal2_parent), 6, 2),
369 static unsigned long dsiphy_recalc(
struct clk *clk)
376 if (!(value & 0x000B8000))
384 pr_err(
"DSIPHY has wrong value (%d)", value);
391 static long dsiphy_round_rate(
struct clk *clk,
unsigned long rate)
396 static void dsiphy_disable(
struct clk *clk)
401 value &= ~0x000B8000;
406 static int dsiphy_enable(
struct clk *clk)
412 multi = (value & 0x3f) + 1;
414 if ((multi < 12) || (multi > 33))
422 static int dsiphy_set_rate(
struct clk *clk,
unsigned long rate)
427 idx = rate / clk->
parent->rate;
428 if ((idx < 12) || (idx > 33))
434 value = (value & ~0x3f) + idx;
442 .recalc = dsiphy_recalc,
443 .round_rate = dsiphy_round_rate,
444 .set_rate = dsiphy_set_rate,
445 .enable = dsiphy_enable,
446 .disable = dsiphy_disable,
459 static struct clk dsi0phy_clk = {
460 .ops = &dsiphy_clk_ops,
462 .
mapping = &dsi0phy_clk_mapping,
465 static struct clk dsi1phy_clk = {
466 .ops = &dsiphy_clk_ops,
468 .
mapping = &dsi1phy_clk_mapping,
471 static struct clk *late_main_clks[] = {
486 #define MSTP(_parent, _reg, _bit, _flags) \
487 SH_CLK_MSTP32(_parent, _reg, _bit, _flags)
489 static struct clk mstp_clks[
MSTP_NR] = {
601 main_clk.
parent = &extal1_div2_clk;
607 main_clk.
parent = &extal2_div2_clk;
611 for (k = 0; !ret && (k <
ARRAY_SIZE(main_clks)); k++)
623 for (k = 0; !ret && (k <
ARRAY_SIZE(late_main_clks)); k++)
631 panic(
"failed to setup sh73a0 clocks\n");