Path: blob/master/arch/sh/kernel/cpu/sh2a/clock-sh7201.c
17498 views
/*1* arch/sh/kernel/cpu/sh2a/clock-sh7201.c2*3* SH7201 support for the clock framework4*5* Copyright (C) 2008 Peter Griffin <[email protected]>6*7* Based on clock-sh4.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 const int pll1rate[]={1,2,3,4,6,8};21static const int pfc_divisors[]={1,2,3,4,6,8,12};22#define ifc_divisors pfc_divisors2324static unsigned int pll2_mult;2526static void master_clk_init(struct clk *clk)27{28clk->rate = 10000000 * pll2_mult *29pll1rate[(__raw_readw(FREQCR) >> 8) & 0x0007];30}3132static struct clk_ops sh7201_master_clk_ops = {33.init = master_clk_init,34};3536static unsigned long module_clk_recalc(struct clk *clk)37{38int idx = (__raw_readw(FREQCR) & 0x0007);39return clk->parent->rate / pfc_divisors[idx];40}4142static struct clk_ops sh7201_module_clk_ops = {43.recalc = module_clk_recalc,44};4546static unsigned long bus_clk_recalc(struct clk *clk)47{48int idx = (__raw_readw(FREQCR) & 0x0007);49return clk->parent->rate / pfc_divisors[idx];50}5152static struct clk_ops sh7201_bus_clk_ops = {53.recalc = bus_clk_recalc,54};5556static unsigned long cpu_clk_recalc(struct clk *clk)57{58int idx = ((__raw_readw(FREQCR) >> 4) & 0x0007);59return clk->parent->rate / ifc_divisors[idx];60}6162static struct clk_ops sh7201_cpu_clk_ops = {63.recalc = cpu_clk_recalc,64};6566static struct clk_ops *sh7201_clk_ops[] = {67&sh7201_master_clk_ops,68&sh7201_module_clk_ops,69&sh7201_bus_clk_ops,70&sh7201_cpu_clk_ops,71};7273void __init arch_init_clk_ops(struct clk_ops **ops, int idx)74{75if (test_mode_pin(MODE_PIN1 | MODE_PIN0))76pll2_mult = 1;77else if (test_mode_pin(MODE_PIN1))78pll2_mult = 2;79else80pll2_mult = 4;8182if (idx < ARRAY_SIZE(sh7201_clk_ops))83*ops = sh7201_clk_ops[idx];84}858687