spi-topcliff-pch: add recovery processing in case wait-event timeout
[zen-stable.git] / arch / sh / kernel / cpu / sh4a / clock-sh7763.c
blob2d4c7fd79c025515adcca670a0d5bbccc6ab04f1
1 /*
2 * arch/sh/kernel/cpu/sh4a/clock-sh7763.c
4 * SH7763 support for the clock framework
6 * Copyright (C) 2005 Paul Mundt
7 * Copyright (C) 2007 Yoshihiro Shimoda
9 * This file is subject to the terms and conditions of the GNU General Public
10 * License. See the file "COPYING" in the main directory of this archive
11 * for more details.
13 #include <linux/init.h>
14 #include <linux/kernel.h>
15 #include <linux/io.h>
16 #include <linux/clkdev.h>
17 #include <asm/clock.h>
18 #include <asm/freq.h>
19 #include <asm/io.h>
21 static int bfc_divisors[] = { 1, 1, 1, 8, 1, 1, 1, 1 };
22 static int p0fc_divisors[] = { 1, 1, 1, 8, 1, 1, 1, 1 };
23 static int cfc_divisors[] = { 1, 1, 4, 1, 1, 1, 1, 1 };
25 static void master_clk_init(struct clk *clk)
27 clk->rate *= p0fc_divisors[(__raw_readl(FRQCR) >> 4) & 0x07];
30 static struct clk_ops sh7763_master_clk_ops = {
31 .init = master_clk_init,
34 static unsigned long module_clk_recalc(struct clk *clk)
36 int idx = ((__raw_readl(FRQCR) >> 4) & 0x07);
37 return clk->parent->rate / p0fc_divisors[idx];
40 static struct clk_ops sh7763_module_clk_ops = {
41 .recalc = module_clk_recalc,
44 static unsigned long bus_clk_recalc(struct clk *clk)
46 int idx = ((__raw_readl(FRQCR) >> 16) & 0x07);
47 return clk->parent->rate / bfc_divisors[idx];
50 static struct clk_ops sh7763_bus_clk_ops = {
51 .recalc = bus_clk_recalc,
54 static struct clk_ops sh7763_cpu_clk_ops = {
55 .recalc = followparent_recalc,
58 static struct clk_ops *sh7763_clk_ops[] = {
59 &sh7763_master_clk_ops,
60 &sh7763_module_clk_ops,
61 &sh7763_bus_clk_ops,
62 &sh7763_cpu_clk_ops,
65 void __init arch_init_clk_ops(struct clk_ops **ops, int idx)
67 if (idx < ARRAY_SIZE(sh7763_clk_ops))
68 *ops = sh7763_clk_ops[idx];
71 static unsigned long shyway_clk_recalc(struct clk *clk)
73 int idx = ((__raw_readl(FRQCR) >> 20) & 0x07);
74 return clk->parent->rate / cfc_divisors[idx];
77 static struct clk_ops sh7763_shyway_clk_ops = {
78 .recalc = shyway_clk_recalc,
81 static struct clk sh7763_shyway_clk = {
82 .flags = CLK_ENABLE_ON_INIT,
83 .ops = &sh7763_shyway_clk_ops,
87 * Additional SH7763-specific on-chip clocks that aren't already part of the
88 * clock framework
90 static struct clk *sh7763_onchip_clocks[] = {
91 &sh7763_shyway_clk,
94 static struct clk_lookup lookups[] = {
95 /* main clocks */
96 CLKDEV_CON_ID("shyway_clk", &sh7763_shyway_clk),
99 int __init arch_clk_init(void)
101 struct clk *clk;
102 int i, ret = 0;
104 cpg_clk_init();
106 clk = clk_get(NULL, "master_clk");
107 for (i = 0; i < ARRAY_SIZE(sh7763_onchip_clocks); i++) {
108 struct clk *clkp = sh7763_onchip_clocks[i];
110 clkp->parent = clk;
111 ret |= clk_register(clkp);
114 clk_put(clk);
116 clkdev_add_table(lookups, ARRAY_SIZE(lookups));
118 return ret;