Path: blob/master/arch/sh/kernel/cpu/sh3/clock-sh7710.c
17531 views
/*1* arch/sh/kernel/cpu/sh3/clock-sh7710.c2*3* SH7710 support for the clock framework4*5* Copyright (C) 2005 Paul Mundt6*7* FRQCR parsing hacked out of arch/sh/kernel/time.c8*9* Copyright (C) 1999 Tetsuya Okada & Niibe Yutaka10* Copyright (C) 2000 Philipp Rumpf <[email protected]>11* Copyright (C) 2002, 2003, 2004 Paul Mundt12* Copyright (C) 2002 M. R. Brown <[email protected]>13*14* This file is subject to the terms and conditions of the GNU General Public15* License. See the file "COPYING" in the main directory of this archive16* for more details.17*/18#include <linux/init.h>19#include <linux/kernel.h>20#include <asm/clock.h>21#include <asm/freq.h>22#include <asm/io.h>2324static int md_table[] = { 1, 2, 3, 4, 6, 8, 12 };2526static void master_clk_init(struct clk *clk)27{28clk->rate *= md_table[__raw_readw(FRQCR) & 0x0007];29}3031static struct clk_ops sh7710_master_clk_ops = {32.init = master_clk_init,33};3435static unsigned long module_clk_recalc(struct clk *clk)36{37int idx = (__raw_readw(FRQCR) & 0x0007);38return clk->parent->rate / md_table[idx];39}4041static struct clk_ops sh7710_module_clk_ops = {42.recalc = module_clk_recalc,43};4445static unsigned long bus_clk_recalc(struct clk *clk)46{47int idx = (__raw_readw(FRQCR) & 0x0700) >> 8;48return clk->parent->rate / md_table[idx];49}5051static struct clk_ops sh7710_bus_clk_ops = {52.recalc = bus_clk_recalc,53};5455static unsigned long cpu_clk_recalc(struct clk *clk)56{57int idx = (__raw_readw(FRQCR) & 0x0070) >> 4;58return clk->parent->rate / md_table[idx];59}6061static struct clk_ops sh7710_cpu_clk_ops = {62.recalc = cpu_clk_recalc,63};6465static struct clk_ops *sh7710_clk_ops[] = {66&sh7710_master_clk_ops,67&sh7710_module_clk_ops,68&sh7710_bus_clk_ops,69&sh7710_cpu_clk_ops,70};7172void __init arch_init_clk_ops(struct clk_ops **ops, int idx)73{74if (idx < ARRAY_SIZE(sh7710_clk_ops))75*ops = sh7710_clk_ops[idx];76}77787980