Path: blob/master/arch/sh/kernel/cpu/sh3/clock-sh3.c
17392 views
/*1* arch/sh/kernel/cpu/sh3/clock-sh3.c2*3* Generic SH-3 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 stc_multipliers[] = { 1, 2, 3, 4, 6, 1, 1, 1 };25static int ifc_divisors[] = { 1, 2, 3, 4, 1, 1, 1, 1 };26static int pfc_divisors[] = { 1, 2, 3, 4, 6, 1, 1, 1 };2728static void master_clk_init(struct clk *clk)29{30int frqcr = __raw_readw(FRQCR);31int idx = ((frqcr & 0x2000) >> 11) | (frqcr & 0x0003);3233clk->rate *= pfc_divisors[idx];34}3536static struct clk_ops sh3_master_clk_ops = {37.init = master_clk_init,38};3940static unsigned long module_clk_recalc(struct clk *clk)41{42int frqcr = __raw_readw(FRQCR);43int idx = ((frqcr & 0x2000) >> 11) | (frqcr & 0x0003);4445return clk->parent->rate / pfc_divisors[idx];46}4748static struct clk_ops sh3_module_clk_ops = {49.recalc = module_clk_recalc,50};5152static unsigned long bus_clk_recalc(struct clk *clk)53{54int frqcr = __raw_readw(FRQCR);55int idx = ((frqcr & 0x8000) >> 13) | ((frqcr & 0x0030) >> 4);5657return clk->parent->rate / stc_multipliers[idx];58}5960static struct clk_ops sh3_bus_clk_ops = {61.recalc = bus_clk_recalc,62};6364static unsigned long cpu_clk_recalc(struct clk *clk)65{66int frqcr = __raw_readw(FRQCR);67int idx = ((frqcr & 0x4000) >> 12) | ((frqcr & 0x000c) >> 2);6869return clk->parent->rate / ifc_divisors[idx];70}7172static struct clk_ops sh3_cpu_clk_ops = {73.recalc = cpu_clk_recalc,74};7576static struct clk_ops *sh3_clk_ops[] = {77&sh3_master_clk_ops,78&sh3_module_clk_ops,79&sh3_bus_clk_ops,80&sh3_cpu_clk_ops,81};8283void __init arch_init_clk_ops(struct clk_ops **ops, int idx)84{85if (idx < ARRAY_SIZE(sh3_clk_ops))86*ops = sh3_clk_ops[idx];87}88899091