Path: blob/master/arch/sh/kernel/cpu/sh4a/clock-sh7770.c
26498 views
// SPDX-License-Identifier: GPL-2.01/*2* arch/sh/kernel/cpu/sh4a/clock-sh7770.c3*4* SH7770 support for the clock framework5*6* Copyright (C) 2005 Paul Mundt7*/8#include <linux/init.h>9#include <linux/kernel.h>10#include <asm/clock.h>11#include <asm/freq.h>12#include <asm/io.h>1314static int ifc_divisors[] = { 1, 1, 1, 1, 1, 1, 1, 1 };15static int bfc_divisors[] = { 1, 1, 1, 1, 1, 8,12, 1 };16static int pfc_divisors[] = { 1, 8, 1,10,12,16, 1, 1 };1718static void master_clk_init(struct clk *clk)19{20clk->rate *= pfc_divisors[(__raw_readl(FRQCR) >> 28) & 0x000f];21}2223static struct sh_clk_ops sh7770_master_clk_ops = {24.init = master_clk_init,25};2627static unsigned long module_clk_recalc(struct clk *clk)28{29int idx = ((__raw_readl(FRQCR) >> 28) & 0x000f);30return clk->parent->rate / pfc_divisors[idx];31}3233static struct sh_clk_ops sh7770_module_clk_ops = {34.recalc = module_clk_recalc,35};3637static unsigned long bus_clk_recalc(struct clk *clk)38{39int idx = (__raw_readl(FRQCR) & 0x000f);40return clk->parent->rate / bfc_divisors[idx];41}4243static struct sh_clk_ops sh7770_bus_clk_ops = {44.recalc = bus_clk_recalc,45};4647static unsigned long cpu_clk_recalc(struct clk *clk)48{49int idx = ((__raw_readl(FRQCR) >> 24) & 0x000f);50return clk->parent->rate / ifc_divisors[idx];51}5253static struct sh_clk_ops sh7770_cpu_clk_ops = {54.recalc = cpu_clk_recalc,55};5657static struct sh_clk_ops *sh7770_clk_ops[] = {58&sh7770_master_clk_ops,59&sh7770_module_clk_ops,60&sh7770_bus_clk_ops,61&sh7770_cpu_clk_ops,62};6364void __init arch_init_clk_ops(struct sh_clk_ops **ops, int idx)65{66if (idx < ARRAY_SIZE(sh7770_clk_ops))67*ops = sh7770_clk_ops[idx];68}69707172