Path: blob/master/arch/sh/kernel/cpu/sh2/clock-sh7619.c
26495 views
// SPDX-License-Identifier: GPL-2.01/*2* arch/sh/kernel/cpu/sh2/clock-sh7619.c3*4* SH7619 support for the clock framework5*6* Copyright (C) 2006 Yoshinori Sato7*8* Based on clock-sh4.c9* Copyright (C) 2005 Paul Mundt10*/11#include <linux/init.h>12#include <linux/kernel.h>13#include <linux/io.h>14#include <asm/clock.h>15#include <asm/freq.h>16#include <asm/processor.h>1718static const int pll1rate[] = {1,2};19static const int pfc_divisors[] = {1,2,0,4};20static unsigned int pll2_mult;2122static void master_clk_init(struct clk *clk)23{24clk->rate *= pll2_mult * pll1rate[(__raw_readw(FREQCR) >> 8) & 7];25}2627static struct sh_clk_ops sh7619_master_clk_ops = {28.init = master_clk_init,29};3031static unsigned long module_clk_recalc(struct clk *clk)32{33int idx = (__raw_readw(FREQCR) & 0x0007);34return clk->parent->rate / pfc_divisors[idx];35}3637static struct sh_clk_ops sh7619_module_clk_ops = {38.recalc = module_clk_recalc,39};4041static unsigned long bus_clk_recalc(struct clk *clk)42{43return clk->parent->rate / pll1rate[(__raw_readw(FREQCR) >> 8) & 7];44}4546static struct sh_clk_ops sh7619_bus_clk_ops = {47.recalc = bus_clk_recalc,48};4950static struct sh_clk_ops sh7619_cpu_clk_ops = {51.recalc = followparent_recalc,52};5354static struct sh_clk_ops *sh7619_clk_ops[] = {55&sh7619_master_clk_ops,56&sh7619_module_clk_ops,57&sh7619_bus_clk_ops,58&sh7619_cpu_clk_ops,59};6061void __init arch_init_clk_ops(struct sh_clk_ops **ops, int idx)62{63if (test_mode_pin(MODE_PIN2 | MODE_PIN0) ||64test_mode_pin(MODE_PIN2 | MODE_PIN1))65pll2_mult = 2;66else if (test_mode_pin(MODE_PIN0) || test_mode_pin(MODE_PIN1))67pll2_mult = 4;6869BUG_ON(!pll2_mult);7071if (idx < ARRAY_SIZE(sh7619_clk_ops))72*ops = sh7619_clk_ops[idx];73}747576