Path: blob/master/arch/sh/kernel/cpu/sh4a/clock-sh7763.c
17495 views
/*1* arch/sh/kernel/cpu/sh4a/clock-sh7763.c2*3* SH7763 support for the clock framework4*5* Copyright (C) 2005 Paul Mundt6* Copyright (C) 2007 Yoshihiro Shimoda7*8* This file is subject to the terms and conditions of the GNU General Public9* License. See the file "COPYING" in the main directory of this archive10* for more details.11*/12#include <linux/init.h>13#include <linux/kernel.h>14#include <linux/io.h>15#include <linux/clkdev.h>16#include <asm/clock.h>17#include <asm/freq.h>18#include <asm/io.h>1920static int bfc_divisors[] = { 1, 1, 1, 8, 1, 1, 1, 1 };21static int p0fc_divisors[] = { 1, 1, 1, 8, 1, 1, 1, 1 };22static int cfc_divisors[] = { 1, 1, 4, 1, 1, 1, 1, 1 };2324static void master_clk_init(struct clk *clk)25{26clk->rate *= p0fc_divisors[(__raw_readl(FRQCR) >> 4) & 0x07];27}2829static struct clk_ops sh7763_master_clk_ops = {30.init = master_clk_init,31};3233static unsigned long module_clk_recalc(struct clk *clk)34{35int idx = ((__raw_readl(FRQCR) >> 4) & 0x07);36return clk->parent->rate / p0fc_divisors[idx];37}3839static struct clk_ops sh7763_module_clk_ops = {40.recalc = module_clk_recalc,41};4243static unsigned long bus_clk_recalc(struct clk *clk)44{45int idx = ((__raw_readl(FRQCR) >> 16) & 0x07);46return clk->parent->rate / bfc_divisors[idx];47}4849static struct clk_ops sh7763_bus_clk_ops = {50.recalc = bus_clk_recalc,51};5253static struct clk_ops sh7763_cpu_clk_ops = {54.recalc = followparent_recalc,55};5657static struct clk_ops *sh7763_clk_ops[] = {58&sh7763_master_clk_ops,59&sh7763_module_clk_ops,60&sh7763_bus_clk_ops,61&sh7763_cpu_clk_ops,62};6364void __init arch_init_clk_ops(struct clk_ops **ops, int idx)65{66if (idx < ARRAY_SIZE(sh7763_clk_ops))67*ops = sh7763_clk_ops[idx];68}6970static unsigned long shyway_clk_recalc(struct clk *clk)71{72int idx = ((__raw_readl(FRQCR) >> 20) & 0x07);73return clk->parent->rate / cfc_divisors[idx];74}7576static struct clk_ops sh7763_shyway_clk_ops = {77.recalc = shyway_clk_recalc,78};7980static struct clk sh7763_shyway_clk = {81.flags = CLK_ENABLE_ON_INIT,82.ops = &sh7763_shyway_clk_ops,83};8485/*86* Additional SH7763-specific on-chip clocks that aren't already part of the87* clock framework88*/89static struct clk *sh7763_onchip_clocks[] = {90&sh7763_shyway_clk,91};9293#define CLKDEV_CON_ID(_id, _clk) { .con_id = _id, .clk = _clk }9495static struct clk_lookup lookups[] = {96/* main clocks */97CLKDEV_CON_ID("shyway_clk", &sh7763_shyway_clk),98};99100int __init arch_clk_init(void)101{102struct clk *clk;103int i, ret = 0;104105cpg_clk_init();106107clk = clk_get(NULL, "master_clk");108for (i = 0; i < ARRAY_SIZE(sh7763_onchip_clocks); i++) {109struct clk *clkp = sh7763_onchip_clocks[i];110111clkp->parent = clk;112ret |= clk_register(clkp);113}114115clk_put(clk);116117clkdev_add_table(lookups, ARRAY_SIZE(lookups));118119return ret;120}121122123