Path: blob/master/arch/sh/kernel/cpu/sh3/clock-sh7712.c
26495 views
// SPDX-License-Identifier: GPL-2.01/*2* arch/sh/kernel/cpu/sh3/clock-sh7712.c3*4* SH7712 support for the clock framework5*6* Copyright (C) 2007 Andrew Murray <[email protected]>7*8* Based on arch/sh/kernel/cpu/sh3/clock-sh3.c9* Copyright (C) 2005 Paul Mundt10*/11#include <linux/init.h>12#include <linux/kernel.h>13#include <asm/clock.h>14#include <asm/freq.h>15#include <asm/io.h>1617static int multipliers[] = { 1, 2, 3 };18static int divisors[] = { 1, 2, 3, 4, 6 };1920static void master_clk_init(struct clk *clk)21{22int frqcr = __raw_readw(FRQCR);23int idx = (frqcr & 0x0300) >> 8;2425clk->rate *= multipliers[idx];26}2728static struct sh_clk_ops sh7712_master_clk_ops = {29.init = master_clk_init,30};3132static unsigned long module_clk_recalc(struct clk *clk)33{34int frqcr = __raw_readw(FRQCR);35int idx = frqcr & 0x0007;3637return clk->parent->rate / divisors[idx];38}3940static struct sh_clk_ops sh7712_module_clk_ops = {41.recalc = module_clk_recalc,42};4344static unsigned long cpu_clk_recalc(struct clk *clk)45{46int frqcr = __raw_readw(FRQCR);47int idx = (frqcr & 0x0030) >> 4;4849return clk->parent->rate / divisors[idx];50}5152static struct sh_clk_ops sh7712_cpu_clk_ops = {53.recalc = cpu_clk_recalc,54};5556static struct sh_clk_ops *sh7712_clk_ops[] = {57&sh7712_master_clk_ops,58&sh7712_module_clk_ops,59&sh7712_cpu_clk_ops,60};6162void __init arch_init_clk_ops(struct sh_clk_ops **ops, int idx)63{64if (idx < ARRAY_SIZE(sh7712_clk_ops))65*ops = sh7712_clk_ops[idx];66}67686970