Path: blob/master/arch/sh/kernel/cpu/sh2a/clock-sh7206.c
17495 views
/*1* arch/sh/kernel/cpu/sh2a/clock-sh7206.c2*3* SH7206 support for the clock framework4*5* Copyright (C) 2006 Yoshinori Sato6*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 *= pll2_mult * pll1rate[(__raw_readw(FREQCR) >> 8) & 0x0007];29}3031static struct clk_ops sh7206_master_clk_ops = {32.init = master_clk_init,33};3435static unsigned long module_clk_recalc(struct clk *clk)36{37int idx = (__raw_readw(FREQCR) & 0x0007);38return clk->parent->rate / pfc_divisors[idx];39}4041static struct clk_ops sh7206_module_clk_ops = {42.recalc = module_clk_recalc,43};4445static unsigned long bus_clk_recalc(struct clk *clk)46{47return clk->parent->rate / pll1rate[(__raw_readw(FREQCR) >> 8) & 0x0007];48}4950static struct clk_ops sh7206_bus_clk_ops = {51.recalc = bus_clk_recalc,52};5354static unsigned long cpu_clk_recalc(struct clk *clk)55{56int idx = (__raw_readw(FREQCR) & 0x0007);57return clk->parent->rate / ifc_divisors[idx];58}5960static struct clk_ops sh7206_cpu_clk_ops = {61.recalc = cpu_clk_recalc,62};6364static struct clk_ops *sh7206_clk_ops[] = {65&sh7206_master_clk_ops,66&sh7206_module_clk_ops,67&sh7206_bus_clk_ops,68&sh7206_cpu_clk_ops,69};7071void __init arch_init_clk_ops(struct clk_ops **ops, int idx)72{73if (test_mode_pin(MODE_PIN2 | MODE_PIN1 | MODE_PIN0))74pll2_mult = 1;75else if (test_mode_pin(MODE_PIN2 | MODE_PIN1))76pll2_mult = 2;77else if (test_mode_pin(MODE_PIN1))78pll2_mult = 4;7980if (idx < ARRAY_SIZE(sh7206_clk_ops))81*ops = sh7206_clk_ops[idx];82}838485