Path: blob/master/arch/sh/kernel/cpu/sh2/clock-sh7619.c
17495 views
/*1* arch/sh/kernel/cpu/sh2/clock-sh7619.c2*3* SH7619 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 <linux/io.h>17#include <asm/clock.h>18#include <asm/freq.h>19#include <asm/processor.h>2021static const int pll1rate[] = {1,2};22static const int pfc_divisors[] = {1,2,0,4};23static unsigned int pll2_mult;2425static void master_clk_init(struct clk *clk)26{27clk->rate *= pll2_mult * pll1rate[(__raw_readw(FREQCR) >> 8) & 7];28}2930static struct clk_ops sh7619_master_clk_ops = {31.init = master_clk_init,32};3334static unsigned long module_clk_recalc(struct clk *clk)35{36int idx = (__raw_readw(FREQCR) & 0x0007);37return clk->parent->rate / pfc_divisors[idx];38}3940static struct clk_ops sh7619_module_clk_ops = {41.recalc = module_clk_recalc,42};4344static unsigned long bus_clk_recalc(struct clk *clk)45{46return clk->parent->rate / pll1rate[(__raw_readw(FREQCR) >> 8) & 7];47}4849static struct clk_ops sh7619_bus_clk_ops = {50.recalc = bus_clk_recalc,51};5253static struct clk_ops sh7619_cpu_clk_ops = {54.recalc = followparent_recalc,55};5657static struct clk_ops *sh7619_clk_ops[] = {58&sh7619_master_clk_ops,59&sh7619_module_clk_ops,60&sh7619_bus_clk_ops,61&sh7619_cpu_clk_ops,62};6364void __init arch_init_clk_ops(struct clk_ops **ops, int idx)65{66if (test_mode_pin(MODE_PIN2 | MODE_PIN0) ||67test_mode_pin(MODE_PIN2 | MODE_PIN1))68pll2_mult = 2;69else if (test_mode_pin(MODE_PIN0) || test_mode_pin(MODE_PIN1))70pll2_mult = 4;7172BUG_ON(!pll2_mult);7374if (idx < ARRAY_SIZE(sh7619_clk_ops))75*ops = sh7619_clk_ops[idx];76}777879