Path: blob/master/arch/sh/kernel/cpu/sh2a/clock-sh7201.c
26495 views
// SPDX-License-Identifier: GPL-2.01/*2* arch/sh/kernel/cpu/sh2a/clock-sh7201.c3*4* SH7201 support for the clock framework5*6* Copyright (C) 2008 Peter Griffin <[email protected]>7*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 = 10000000 * pll2_mult *26pll1rate[(__raw_readw(FREQCR) >> 8) & 0x0007];27}2829static struct sh_clk_ops sh7201_master_clk_ops = {30.init = master_clk_init,31};3233static unsigned long module_clk_recalc(struct clk *clk)34{35int idx = (__raw_readw(FREQCR) & 0x0007);36return clk->parent->rate / pfc_divisors[idx];37}3839static struct sh_clk_ops sh7201_module_clk_ops = {40.recalc = module_clk_recalc,41};4243static unsigned long bus_clk_recalc(struct clk *clk)44{45int idx = (__raw_readw(FREQCR) & 0x0007);46return clk->parent->rate / pfc_divisors[idx];47}4849static struct sh_clk_ops sh7201_bus_clk_ops = {50.recalc = bus_clk_recalc,51};5253static unsigned long cpu_clk_recalc(struct clk *clk)54{55int idx = ((__raw_readw(FREQCR) >> 4) & 0x0007);56return clk->parent->rate / ifc_divisors[idx];57}5859static struct sh_clk_ops sh7201_cpu_clk_ops = {60.recalc = cpu_clk_recalc,61};6263static struct sh_clk_ops *sh7201_clk_ops[] = {64&sh7201_master_clk_ops,65&sh7201_module_clk_ops,66&sh7201_bus_clk_ops,67&sh7201_cpu_clk_ops,68};6970void __init arch_init_clk_ops(struct sh_clk_ops **ops, int idx)71{72if (test_mode_pin(MODE_PIN1 | MODE_PIN0))73pll2_mult = 1;74else if (test_mode_pin(MODE_PIN1))75pll2_mult = 2;76else77pll2_mult = 4;7879if (idx < ARRAY_SIZE(sh7201_clk_ops))80*ops = sh7201_clk_ops[idx];81}828384