21 #include <linux/kernel.h>
25 #include <mach/common.h>
44 #define FRQCRA IOMEM(0xe6150000)
45 #define FRQCRB IOMEM(0xe6150004)
46 #define VCLKCR1 IOMEM(0xE6150008)
47 #define VCLKCR2 IOMEM(0xE615000c)
48 #define FRQCRC IOMEM(0xe61500e0)
49 #define FSIACKCR IOMEM(0xe6150018)
50 #define PLLC01CR IOMEM(0xe6150028)
52 #define SUBCKCR IOMEM(0xe6150080)
53 #define USBCKCR IOMEM(0xe615008c)
55 #define MSTPSR0 IOMEM(0xe6150030)
56 #define MSTPSR1 IOMEM(0xe6150038)
57 #define MSTPSR2 IOMEM(0xe6150040)
58 #define MSTPSR3 IOMEM(0xe6150048)
59 #define MSTPSR4 IOMEM(0xe615004c)
60 #define FSIBCKCR IOMEM(0xe6150090)
61 #define HDMICKCR IOMEM(0xe6150094)
62 #define SMSTPCR0 IOMEM(0xe6150130)
63 #define SMSTPCR1 IOMEM(0xe6150134)
64 #define SMSTPCR2 IOMEM(0xe6150138)
65 #define SMSTPCR3 IOMEM(0xe615013c)
66 #define SMSTPCR4 IOMEM(0xe6150140)
69 static struct clk extalr_clk = {
77 static struct clk extal1_clk = {
85 static struct clk extal2_clk = {
93 static struct clk dv_clk = {
97 static unsigned long div_recalc(
struct clk *
clk)
103 .recalc = div_recalc,
107 static struct clk extal1_div2_clk = {
114 static struct clk extal1_div1024_clk = {
116 .priv = (
void *)1024,
121 static struct clk extal1_div2048_clk = {
123 .priv = (
void *)1024,
124 .
parent = &extal1_div2_clk,
128 static struct clk extal2_div2_clk = {
134 static struct sh_clk_ops followparent_clk_ops = {
139 static struct clk system_clk = {
140 .ops = &followparent_clk_ops,
143 static struct clk system_div2_clk = {
150 static struct clk r_clk = {
151 .ops = &followparent_clk_ops,
155 static unsigned long pllc01_recalc(
struct clk *clk)
157 unsigned long mult = 1;
166 .recalc = pllc01_recalc,
169 static struct clk pllc0_clk = {
170 .ops = &pllc01_clk_ops,
172 .parent = &system_clk,
176 static struct clk pllc1_clk = {
177 .ops = &pllc01_clk_ops,
179 .parent = &system_div2_clk,
184 static struct clk pllc1_div2_clk = {
191 static struct clk *usb24s_parents[] = {
196 static int usb24s_enable(
struct clk *clk)
203 static void usb24s_disable(
struct clk *clk)
208 static int usb24s_set_parent(
struct clk *clk,
struct clk *
parent)
238 .enable = usb24s_enable,
239 .disable = usb24s_disable,
240 .set_parent = usb24s_set_parent,
243 static struct clk usb24s_clk = {
244 .ops = &usb24s_clk_ops,
245 .parent_table = usb24s_parents,
247 .parent = &system_clk,
250 static unsigned long usb24_recalc(
struct clk *clk)
252 return clk->
parent->rate /
256 static int usb24_set_rate(
struct clk *clk,
unsigned long rate)
263 val |= (rate > (clk->
parent->rate / 4) * 3) << 6;
270 .recalc = usb24_recalc,
271 .set_rate = usb24_set_rate,
274 static struct clk usb24_clk = {
275 .ops = &usb24_clk_ops,
276 .parent = &usb24s_clk,
280 static struct clk fsiack_clk = {
283 static struct clk fsibck_clk = {
307 static void div4_kick(
struct clk *clk)
317 static int divisors[] = { 2, 3, 4, 6, 8, 12, 16, 18,
318 24, 32, 36, 48, 0, 72, 96, 0 };
326 .div_mult_table = &div4_div_mult_table,
338 static struct clk *hdmi_parent[] = {
339 [0] = &pllc1_div2_clk,
344 static struct clk *vclk_parents[8] = {
345 [0] = &pllc1_div2_clk,
348 [4] = &extal1_div2_clk,
352 static struct clk *fsia_parents[] = {
353 [0] = &pllc1_div2_clk,
357 static struct clk *fsib_parents[] = {
358 [0] = &pllc1_div2_clk,
366 vclk_parents,
ARRAY_SIZE(vclk_parents), 12, 3),
368 vclk_parents,
ARRAY_SIZE(vclk_parents), 12, 3),
370 fsia_parents,
ARRAY_SIZE(fsia_parents), 6, 2),
372 fsib_parents,
ARRAY_SIZE(fsib_parents), 6, 2),
376 static unsigned long hdmi12_recalc(
struct clk *clk)
384 return clk->
parent->rate / (1 << val);
387 static int hdmi12_set_rate(
struct clk *clk,
unsigned long rate)
392 for (i = 0; i < 3; i++)
393 if (rate == clk->
parent->rate / (1 << i))
401 mask = ~(0x3 <<
shift);
402 val = (val &
mask) | i << shift;
409 .recalc = hdmi12_recalc,
410 .set_rate = hdmi12_set_rate,
413 static struct clk hdmi1_clk = {
414 .ops = &hdmi12_clk_ops,
416 .parent = &div6_reparent_clks[
DIV6_HDMI],
419 static struct clk hdmi2_clk = {
420 .ops = &hdmi12_clk_ops,
422 .parent = &div6_reparent_clks[DIV6_HDMI],
425 static struct clk *late_main_clks[] = {
456 static struct clk div6_clks[
DIV6_NR] = {
478 static struct clk mstp_clks[
MSTP_NR] = {
595 CLKDEV_ICK_ID(
"ick",
"sh-mobile-hdmi", &div6_reparent_clks[DIV6_HDMI]),
607 system_clk.
parent = &extal1_div2_clk;
609 system_clk.
parent = &extal1_clk;
612 switch (md_ck & (
MD_CK2 | MD_CK1)) {
614 r_clk.
parent = &extal1_div2048_clk;
617 r_clk.
parent = &extal1_div1024_clk;
621 r_clk.
parent = &extalr_clk;
625 for (k = 0; !ret && (k <
ARRAY_SIZE(main_clks)); k++)
641 for (k = 0; !ret && (k <
ARRAY_SIZE(late_main_clks)); k++)
649 panic(
"failed to setup r8a7740 clocks\n");