Path: blob/master/arch/sh/kernel/cpu/sh2a/clock-sh7203.c
26495 views
// SPDX-License-Identifier: GPL-2.01/*2* arch/sh/kernel/cpu/sh2a/clock-sh7203.c3*4* SH7203 support for the clock framework5*6* Copyright (C) 2007 Kieran Bingham (MPC-Data Ltd)7*8* Based on clock-sh7263.c9* Copyright (C) 2006 Yoshinori Sato10*11* Based on clock-sh4.c12* Copyright (C) 2005 Paul Mundt13*/14#include <linux/init.h>15#include <linux/kernel.h>16#include <asm/clock.h>17#include <asm/freq.h>18#include <asm/io.h>1920static const int pll1rate[]={8,12,16,0};21static const int pfc_divisors[]={1,2,3,4,6,8,12};22#define ifc_divisors pfc_divisors2324static unsigned int pll2_mult;2526static void master_clk_init(struct clk *clk)27{28clk->rate *= pll1rate[(__raw_readw(FREQCR) >> 8) & 0x0003] * pll2_mult;29}3031static struct sh_clk_ops sh7203_master_clk_ops = {32.init = master_clk_init,33};3435static unsigned long module_clk_recalc(struct clk *clk)36{37int idx = (__raw_readw(FREQCR) & 0x0007);38return clk->parent->rate / pfc_divisors[idx];39}4041static struct sh_clk_ops sh7203_module_clk_ops = {42.recalc = module_clk_recalc,43};4445static unsigned long bus_clk_recalc(struct clk *clk)46{47int idx = (__raw_readw(FREQCR) & 0x0007);48return clk->parent->rate / pfc_divisors[idx-2];49}5051static struct sh_clk_ops sh7203_bus_clk_ops = {52.recalc = bus_clk_recalc,53};5455static struct sh_clk_ops sh7203_cpu_clk_ops = {56.recalc = followparent_recalc,57};5859static struct sh_clk_ops *sh7203_clk_ops[] = {60&sh7203_master_clk_ops,61&sh7203_module_clk_ops,62&sh7203_bus_clk_ops,63&sh7203_cpu_clk_ops,64};6566void __init arch_init_clk_ops(struct sh_clk_ops **ops, int idx)67{68if (test_mode_pin(MODE_PIN1))69pll2_mult = 4;70else if (test_mode_pin(MODE_PIN0))71pll2_mult = 2;72else73pll2_mult = 1;7475if (idx < ARRAY_SIZE(sh7203_clk_ops))76*ops = sh7203_clk_ops[idx];77}787980