2 * arch/sh/kernel/cpu/sh4/clock-shx3.c
4 * SH-X3 support for the clock framework
6 * Copyright (C) 2006-2007 Renesas Technology Corp.
7 * Copyright (C) 2006-2007 Renesas Solutions Corp.
8 * Copyright (C) 2006-2007 Paul Mundt
10 * This file is subject to the terms and conditions of the GNU General Public
11 * License. See the file "COPYING" in the main directory of this archive
14 #include <linux/init.h>
15 #include <linux/kernel.h>
16 #include <asm/clock.h>
20 static int ifc_divisors
[] = { 1, 2, 4 ,6 };
21 static int bfc_divisors
[] = { 1, 1, 1, 1, 1, 12, 16, 18, 24, 32, 36, 48 };
22 static int pfc_divisors
[] = { 1, 1, 1, 1, 1, 1, 1, 18, 24, 32, 36, 48 };
23 static int cfc_divisors
[] = { 1, 1, 4, 6 };
26 #define IFC_MSK 0x0003
27 #define BFC_MSK 0x000f
28 #define PFC_MSK 0x000f
29 #define CFC_MSK 0x0003
34 static void master_clk_init(struct clk
*clk
)
36 clk
->rate
*= pfc_divisors
[(ctrl_inl(FRQCR
) >> PFC_POS
) & PFC_MSK
];
39 static struct clk_ops shx3_master_clk_ops
= {
40 .init
= master_clk_init
,
43 static unsigned long module_clk_recalc(struct clk
*clk
)
45 int idx
= ((ctrl_inl(FRQCR
) >> PFC_POS
) & PFC_MSK
);
46 return clk
->parent
->rate
/ pfc_divisors
[idx
];
49 static struct clk_ops shx3_module_clk_ops
= {
50 .recalc
= module_clk_recalc
,
53 static unsigned long bus_clk_recalc(struct clk
*clk
)
55 int idx
= ((ctrl_inl(FRQCR
) >> BFC_POS
) & BFC_MSK
);
56 return clk
->parent
->rate
/ bfc_divisors
[idx
];
59 static struct clk_ops shx3_bus_clk_ops
= {
60 .recalc
= bus_clk_recalc
,
63 static unsigned long cpu_clk_recalc(struct clk
*clk
)
65 int idx
= ((ctrl_inl(FRQCR
) >> IFC_POS
) & IFC_MSK
);
66 return clk
->parent
->rate
/ ifc_divisors
[idx
];
69 static struct clk_ops shx3_cpu_clk_ops
= {
70 .recalc
= cpu_clk_recalc
,
73 static struct clk_ops
*shx3_clk_ops
[] = {
80 void __init
arch_init_clk_ops(struct clk_ops
**ops
, int idx
)
82 if (idx
< ARRAY_SIZE(shx3_clk_ops
))
83 *ops
= shx3_clk_ops
[idx
];
86 static unsigned long shyway_clk_recalc(struct clk
*clk
)
88 int idx
= ((ctrl_inl(FRQCR
) >> CFC_POS
) & CFC_MSK
);
89 return clk
->parent
->rate
/ cfc_divisors
[idx
];
92 static struct clk_ops shx3_shyway_clk_ops
= {
93 .recalc
= shyway_clk_recalc
,
96 static struct clk shx3_shyway_clk
= {
98 .flags
= CLK_ENABLE_ON_INIT
,
99 .ops
= &shx3_shyway_clk_ops
,
103 * Additional SHx3-specific on-chip clocks that aren't already part of the
106 static struct clk
*shx3_onchip_clocks
[] = {
110 int __init
arch_clk_init(void)
117 clk
= clk_get(NULL
, "master_clk");
118 for (i
= 0; i
< ARRAY_SIZE(shx3_onchip_clocks
); i
++) {
119 struct clk
*clkp
= shx3_onchip_clocks
[i
];
122 ret
|= clk_register(clkp
);