Path: blob/master/arch/sh/kernel/cpu/sh3/clock-sh7712.c
17495 views
/*1* arch/sh/kernel/cpu/sh3/clock-sh7712.c2*3* SH7712 support for the clock framework4*5* Copyright (C) 2007 Andrew Murray <[email protected]>6*7* Based on arch/sh/kernel/cpu/sh3/clock-sh3.c8* Copyright (C) 2005 Paul Mundt9*10* This file is subject to the terms and conditions of the GNU General Public11* License. See the file "COPYING" in the main directory of this archive12* for more details.13*/14#include <linux/init.h>15#include <linux/kernel.h>16#include <asm/clock.h>17#include <asm/freq.h>18#include <asm/io.h>1920static int multipliers[] = { 1, 2, 3 };21static int divisors[] = { 1, 2, 3, 4, 6 };2223static void master_clk_init(struct clk *clk)24{25int frqcr = __raw_readw(FRQCR);26int idx = (frqcr & 0x0300) >> 8;2728clk->rate *= multipliers[idx];29}3031static struct clk_ops sh7712_master_clk_ops = {32.init = master_clk_init,33};3435static unsigned long module_clk_recalc(struct clk *clk)36{37int frqcr = __raw_readw(FRQCR);38int idx = frqcr & 0x0007;3940return clk->parent->rate / divisors[idx];41}4243static struct clk_ops sh7712_module_clk_ops = {44.recalc = module_clk_recalc,45};4647static unsigned long cpu_clk_recalc(struct clk *clk)48{49int frqcr = __raw_readw(FRQCR);50int idx = (frqcr & 0x0030) >> 4;5152return clk->parent->rate / divisors[idx];53}5455static struct clk_ops sh7712_cpu_clk_ops = {56.recalc = cpu_clk_recalc,57};5859static struct clk_ops *sh7712_clk_ops[] = {60&sh7712_master_clk_ops,61&sh7712_module_clk_ops,62&sh7712_cpu_clk_ops,63};6465void __init arch_init_clk_ops(struct clk_ops **ops, int idx)66{67if (idx < ARRAY_SIZE(sh7712_clk_ops))68*ops = sh7712_clk_ops[idx];69}70717273