Path: blob/master/arch/sh/kernel/cpu/sh3/clock-sh7709.c
17531 views
/*1* arch/sh/kernel/cpu/sh3/clock-sh7709.c2*3* SH7709 support for the clock framework4*5* Copyright (C) 2005 Andriy Skulysh6*7* Based on arch/sh/kernel/cpu/sh3/clock-sh7705.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 int stc_multipliers[] = { 1, 2, 4, 8, 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 sh7709_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 sh7709_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 & 0x0080) ?52((frqcr & 0x8000) >> 13) | ((frqcr & 0x0030) >> 4) : 1;5354return clk->parent->rate * stc_multipliers[idx];55}5657static struct clk_ops sh7709_bus_clk_ops = {58.recalc = bus_clk_recalc,59};6061static unsigned long cpu_clk_recalc(struct clk *clk)62{63int frqcr = __raw_readw(FRQCR);64int idx = ((frqcr & 0x4000) >> 12) | ((frqcr & 0x000c) >> 2);6566return clk->parent->rate / ifc_divisors[idx];67}6869static struct clk_ops sh7709_cpu_clk_ops = {70.recalc = cpu_clk_recalc,71};7273static struct clk_ops *sh7709_clk_ops[] = {74&sh7709_master_clk_ops,75&sh7709_module_clk_ops,76&sh7709_bus_clk_ops,77&sh7709_cpu_clk_ops,78};7980void __init arch_init_clk_ops(struct clk_ops **ops, int idx)81{82if (idx < ARRAY_SIZE(sh7709_clk_ops))83*ops = sh7709_clk_ops[idx];84}858687