Path: blob/master/arch/sh/kernel/cpu/sh3/clock-sh7705.c
17498 views
/*1* arch/sh/kernel/cpu/sh3/clock-sh7705.c2*3* SH7705 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>2324/*25* SH7705 uses the same divisors as the generic SH-3 case, it's just the26* FRQCR layout that is a bit different..27*/28static int stc_multipliers[] = { 1, 2, 3, 4, 6, 1, 1, 1 };29static int ifc_divisors[] = { 1, 2, 3, 4, 1, 1, 1, 1 };30static int pfc_divisors[] = { 1, 2, 3, 4, 6, 1, 1, 1 };3132static void master_clk_init(struct clk *clk)33{34clk->rate *= pfc_divisors[__raw_readw(FRQCR) & 0x0003];35}3637static struct clk_ops sh7705_master_clk_ops = {38.init = master_clk_init,39};4041static unsigned long module_clk_recalc(struct clk *clk)42{43int idx = __raw_readw(FRQCR) & 0x0003;44return clk->parent->rate / pfc_divisors[idx];45}4647static struct clk_ops sh7705_module_clk_ops = {48.recalc = module_clk_recalc,49};5051static unsigned long bus_clk_recalc(struct clk *clk)52{53int idx = (__raw_readw(FRQCR) & 0x0300) >> 8;54return clk->parent->rate / stc_multipliers[idx];55}5657static struct clk_ops sh7705_bus_clk_ops = {58.recalc = bus_clk_recalc,59};6061static unsigned long cpu_clk_recalc(struct clk *clk)62{63int idx = (__raw_readw(FRQCR) & 0x0030) >> 4;64return clk->parent->rate / ifc_divisors[idx];65}6667static struct clk_ops sh7705_cpu_clk_ops = {68.recalc = cpu_clk_recalc,69};7071static struct clk_ops *sh7705_clk_ops[] = {72&sh7705_master_clk_ops,73&sh7705_module_clk_ops,74&sh7705_bus_clk_ops,75&sh7705_cpu_clk_ops,76};7778void __init arch_init_clk_ops(struct clk_ops **ops, int idx)79{80if (idx < ARRAY_SIZE(sh7705_clk_ops))81*ops = sh7705_clk_ops[idx];82}83848586