Path: blob/master/arch/sh/kernel/cpu/sh3/clock-sh7706.c
17531 views
/*1* arch/sh/kernel/cpu/sh3/clock-sh7706.c2*3* SH7706 support for the clock framework4*5* Copyright (C) 2006 Takashi YOSHII6*7* Based on arch/sh/kernel/cpu/sh3/clock-sh7709.c8* Copyright (C) 2005 Andriy Skulysh9*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 int stc_multipliers[] = { 1, 2, 4, 1, 3, 6, 1, 1 };21static int ifc_divisors[] = { 1, 2, 4, 1, 3, 1, 1, 1 };22static int pfc_divisors[] = { 1, 2, 4, 1, 3, 6, 1, 1 };2324static void master_clk_init(struct clk *clk)25{26int frqcr = __raw_readw(FRQCR);27int idx = ((frqcr & 0x2000) >> 11) | (frqcr & 0x0003);2829clk->rate *= pfc_divisors[idx];30}3132static struct clk_ops sh7706_master_clk_ops = {33.init = master_clk_init,34};3536static unsigned long module_clk_recalc(struct clk *clk)37{38int frqcr = __raw_readw(FRQCR);39int idx = ((frqcr & 0x2000) >> 11) | (frqcr & 0x0003);4041return clk->parent->rate / pfc_divisors[idx];42}4344static struct clk_ops sh7706_module_clk_ops = {45.recalc = module_clk_recalc,46};4748static unsigned long bus_clk_recalc(struct clk *clk)49{50int frqcr = __raw_readw(FRQCR);51int idx = ((frqcr & 0x8000) >> 13) | ((frqcr & 0x0030) >> 4);5253return clk->parent->rate / stc_multipliers[idx];54}5556static struct clk_ops sh7706_bus_clk_ops = {57.recalc = bus_clk_recalc,58};5960static unsigned long cpu_clk_recalc(struct clk *clk)61{62int frqcr = __raw_readw(FRQCR);63int idx = ((frqcr & 0x4000) >> 12) | ((frqcr & 0x000c) >> 2);6465return clk->parent->rate / ifc_divisors[idx];66}6768static struct clk_ops sh7706_cpu_clk_ops = {69.recalc = cpu_clk_recalc,70};7172static struct clk_ops *sh7706_clk_ops[] = {73&sh7706_master_clk_ops,74&sh7706_module_clk_ops,75&sh7706_bus_clk_ops,76&sh7706_cpu_clk_ops,77};7879void __init arch_init_clk_ops(struct clk_ops **ops, int idx)80{81if (idx < ARRAY_SIZE(sh7706_clk_ops))82*ops = sh7706_clk_ops[idx];83}848586