Path: blob/master/arch/sh/kernel/cpu/sh3/clock-sh7709.c
26495 views
// SPDX-License-Identifier: GPL-2.01/*2* arch/sh/kernel/cpu/sh3/clock-sh7709.c3*4* SH7709 support for the clock framework5*6* Copyright (C) 2005 Andriy Skulysh7*8* Based on arch/sh/kernel/cpu/sh3/clock-sh7705.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 stc_multipliers[] = { 1, 2, 4, 8, 3, 6, 1, 1 };18static int ifc_divisors[] = { 1, 2, 4, 1, 3, 1, 1, 1 };19static int pfc_divisors[] = { 1, 2, 4, 1, 3, 6, 1, 1 };2021static void master_clk_init(struct clk *clk)22{23int frqcr = __raw_readw(FRQCR);24int idx = ((frqcr & 0x2000) >> 11) | (frqcr & 0x0003);2526clk->rate *= pfc_divisors[idx];27}2829static struct sh_clk_ops sh7709_master_clk_ops = {30.init = master_clk_init,31};3233static unsigned long module_clk_recalc(struct clk *clk)34{35int frqcr = __raw_readw(FRQCR);36int idx = ((frqcr & 0x2000) >> 11) | (frqcr & 0x0003);3738return clk->parent->rate / pfc_divisors[idx];39}4041static struct sh_clk_ops sh7709_module_clk_ops = {42.recalc = module_clk_recalc,43};4445static unsigned long bus_clk_recalc(struct clk *clk)46{47int frqcr = __raw_readw(FRQCR);48int idx = (frqcr & 0x0080) ?49((frqcr & 0x8000) >> 13) | ((frqcr & 0x0030) >> 4) : 1;5051return clk->parent->rate * stc_multipliers[idx];52}5354static struct sh_clk_ops sh7709_bus_clk_ops = {55.recalc = bus_clk_recalc,56};5758static unsigned long cpu_clk_recalc(struct clk *clk)59{60int frqcr = __raw_readw(FRQCR);61int idx = ((frqcr & 0x4000) >> 12) | ((frqcr & 0x000c) >> 2);6263return clk->parent->rate / ifc_divisors[idx];64}6566static struct sh_clk_ops sh7709_cpu_clk_ops = {67.recalc = cpu_clk_recalc,68};6970static struct sh_clk_ops *sh7709_clk_ops[] = {71&sh7709_master_clk_ops,72&sh7709_module_clk_ops,73&sh7709_bus_clk_ops,74&sh7709_cpu_clk_ops,75};7677void __init arch_init_clk_ops(struct sh_clk_ops **ops, int idx)78{79if (idx < ARRAY_SIZE(sh7709_clk_ops))80*ops = sh7709_clk_ops[idx];81}828384