Path: blob/master/arch/sh/kernel/cpu/sh5/clock-sh5.c
17466 views
/*1* arch/sh/kernel/cpu/sh5/clock-sh5.c2*3* SH-5 support for the clock framework4*5* Copyright (C) 2008 Paul Mundt6*7* This file is subject to the terms and conditions of the GNU General Public8* License. See the file "COPYING" in the main directory of this archive9* for more details.10*/11#include <linux/init.h>12#include <linux/kernel.h>13#include <asm/clock.h>14#include <asm/io.h>1516static int ifc_table[] = { 2, 4, 6, 8, 10, 12, 16, 24 };1718/* Clock, Power and Reset Controller */19#define CPRC_BLOCK_OFF 0x0101000020#define CPRC_BASE (PHYS_PERIPHERAL_BLOCK + CPRC_BLOCK_OFF)2122static unsigned long cprc_base;2324static void master_clk_init(struct clk *clk)25{26int idx = (__raw_readl(cprc_base + 0x00) >> 6) & 0x0007;27clk->rate *= ifc_table[idx];28}2930static struct clk_ops sh5_master_clk_ops = {31.init = master_clk_init,32};3334static unsigned long module_clk_recalc(struct clk *clk)35{36int idx = (__raw_readw(cprc_base) >> 12) & 0x0007;37return clk->parent->rate / ifc_table[idx];38}3940static struct clk_ops sh5_module_clk_ops = {41.recalc = module_clk_recalc,42};4344static unsigned long bus_clk_recalc(struct clk *clk)45{46int idx = (__raw_readw(cprc_base) >> 3) & 0x0007;47return clk->parent->rate / ifc_table[idx];48}4950static struct clk_ops sh5_bus_clk_ops = {51.recalc = bus_clk_recalc,52};5354static unsigned long cpu_clk_recalc(struct clk *clk)55{56int idx = (__raw_readw(cprc_base) & 0x0007);57return clk->parent->rate / ifc_table[idx];58}5960static struct clk_ops sh5_cpu_clk_ops = {61.recalc = cpu_clk_recalc,62};6364static struct clk_ops *sh5_clk_ops[] = {65&sh5_master_clk_ops,66&sh5_module_clk_ops,67&sh5_bus_clk_ops,68&sh5_cpu_clk_ops,69};7071void __init arch_init_clk_ops(struct clk_ops **ops, int idx)72{73cprc_base = (unsigned long)ioremap_nocache(CPRC_BASE, 1024);74BUG_ON(!cprc_base);7576if (idx < ARRAY_SIZE(sh5_clk_ops))77*ops = sh5_clk_ops[idx];78}798081