Path: blob/master/arch/sh/kernel/cpu/sh4/clock-sh4.c
37217 views
/*1* arch/sh/kernel/cpu/sh4/clock-sh4.c2*3* Generic SH-4 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 ifc_divisors[] = { 1, 2, 3, 4, 6, 8, 1, 1 };25#define bfc_divisors ifc_divisors /* Same */26static int pfc_divisors[] = { 2, 3, 4, 6, 8, 2, 2, 2 };2728static void master_clk_init(struct clk *clk)29{30clk->rate *= pfc_divisors[__raw_readw(FRQCR) & 0x0007];31}3233static struct clk_ops sh4_master_clk_ops = {34.init = master_clk_init,35};3637static unsigned long module_clk_recalc(struct clk *clk)38{39int idx = (__raw_readw(FRQCR) & 0x0007);40return clk->parent->rate / pfc_divisors[idx];41}4243static struct clk_ops sh4_module_clk_ops = {44.recalc = module_clk_recalc,45};4647static unsigned long bus_clk_recalc(struct clk *clk)48{49int idx = (__raw_readw(FRQCR) >> 3) & 0x0007;50return clk->parent->rate / bfc_divisors[idx];51}5253static struct clk_ops sh4_bus_clk_ops = {54.recalc = bus_clk_recalc,55};5657static unsigned long cpu_clk_recalc(struct clk *clk)58{59int idx = (__raw_readw(FRQCR) >> 6) & 0x0007;60return clk->parent->rate / ifc_divisors[idx];61}6263static struct clk_ops sh4_cpu_clk_ops = {64.recalc = cpu_clk_recalc,65};6667static struct clk_ops *sh4_clk_ops[] = {68&sh4_master_clk_ops,69&sh4_module_clk_ops,70&sh4_bus_clk_ops,71&sh4_cpu_clk_ops,72};7374void __init arch_init_clk_ops(struct clk_ops **ops, int idx)75{76if (idx < ARRAY_SIZE(sh4_clk_ops))77*ops = sh4_clk_ops[idx];78}79808182