Path: blob/master/arch/sh/kernel/cpu/sh2a/clock-sh7206.c
26495 views
// SPDX-License-Identifier: GPL-2.01/*2* arch/sh/kernel/cpu/sh2a/clock-sh7206.c3*4* SH7206 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 <asm/clock.h>14#include <asm/freq.h>15#include <asm/io.h>1617static const int pll1rate[]={1,2,3,4,6,8};18static const int pfc_divisors[]={1,2,3,4,6,8,12};19#define ifc_divisors pfc_divisors2021static unsigned int pll2_mult;2223static void master_clk_init(struct clk *clk)24{25clk->rate *= pll2_mult * pll1rate[(__raw_readw(FREQCR) >> 8) & 0x0007];26}2728static struct sh_clk_ops sh7206_master_clk_ops = {29.init = master_clk_init,30};3132static unsigned long module_clk_recalc(struct clk *clk)33{34int idx = (__raw_readw(FREQCR) & 0x0007);35return clk->parent->rate / pfc_divisors[idx];36}3738static struct sh_clk_ops sh7206_module_clk_ops = {39.recalc = module_clk_recalc,40};4142static unsigned long bus_clk_recalc(struct clk *clk)43{44return clk->parent->rate / pll1rate[(__raw_readw(FREQCR) >> 8) & 0x0007];45}4647static struct sh_clk_ops sh7206_bus_clk_ops = {48.recalc = bus_clk_recalc,49};5051static unsigned long cpu_clk_recalc(struct clk *clk)52{53int idx = (__raw_readw(FREQCR) & 0x0007);54return clk->parent->rate / ifc_divisors[idx];55}5657static struct sh_clk_ops sh7206_cpu_clk_ops = {58.recalc = cpu_clk_recalc,59};6061static struct sh_clk_ops *sh7206_clk_ops[] = {62&sh7206_master_clk_ops,63&sh7206_module_clk_ops,64&sh7206_bus_clk_ops,65&sh7206_cpu_clk_ops,66};6768void __init arch_init_clk_ops(struct sh_clk_ops **ops, int idx)69{70if (test_mode_pin(MODE_PIN2 | MODE_PIN1 | MODE_PIN0))71pll2_mult = 1;72else if (test_mode_pin(MODE_PIN2 | MODE_PIN1))73pll2_mult = 2;74else if (test_mode_pin(MODE_PIN1))75pll2_mult = 4;7677if (idx < ARRAY_SIZE(sh7206_clk_ops))78*ops = sh7206_clk_ops[idx];79}808182