Path: blob/master/arch/sh/kernel/cpu/sh2a/clock-sh7203.c
17495 views
/*1* arch/sh/kernel/cpu/sh2a/clock-sh7203.c2*3* SH7203 support for the clock framework4*5* Copyright (C) 2007 Kieran Bingham (MPC-Data Ltd)6*7* Based on clock-sh7263.c8* Copyright (C) 2006 Yoshinori Sato9*10* Based on clock-sh4.c11* Copyright (C) 2005 Paul Mundt12*13* This file is subject to the terms and conditions of the GNU General Public14* License. See the file "COPYING" in the main directory of this archive15* for more details.16*/17#include <linux/init.h>18#include <linux/kernel.h>19#include <asm/clock.h>20#include <asm/freq.h>21#include <asm/io.h>2223static const int pll1rate[]={8,12,16,0};24static const int pfc_divisors[]={1,2,3,4,6,8,12};25#define ifc_divisors pfc_divisors2627static unsigned int pll2_mult;2829static void master_clk_init(struct clk *clk)30{31clk->rate *= pll1rate[(__raw_readw(FREQCR) >> 8) & 0x0003] * pll2_mult;32}3334static struct clk_ops sh7203_master_clk_ops = {35.init = master_clk_init,36};3738static unsigned long module_clk_recalc(struct clk *clk)39{40int idx = (__raw_readw(FREQCR) & 0x0007);41return clk->parent->rate / pfc_divisors[idx];42}4344static struct clk_ops sh7203_module_clk_ops = {45.recalc = module_clk_recalc,46};4748static unsigned long bus_clk_recalc(struct clk *clk)49{50int idx = (__raw_readw(FREQCR) & 0x0007);51return clk->parent->rate / pfc_divisors[idx-2];52}5354static struct clk_ops sh7203_bus_clk_ops = {55.recalc = bus_clk_recalc,56};5758static struct clk_ops sh7203_cpu_clk_ops = {59.recalc = followparent_recalc,60};6162static struct clk_ops *sh7203_clk_ops[] = {63&sh7203_master_clk_ops,64&sh7203_module_clk_ops,65&sh7203_bus_clk_ops,66&sh7203_cpu_clk_ops,67};6869void __init arch_init_clk_ops(struct clk_ops **ops, int idx)70{71if (test_mode_pin(MODE_PIN1))72pll2_mult = 4;73else if (test_mode_pin(MODE_PIN0))74pll2_mult = 2;75else76pll2_mult = 1;7778if (idx < ARRAY_SIZE(sh7203_clk_ops))79*ops = sh7203_clk_ops[idx];80}818283