Path: blob/master/arch/sh/kernel/cpu/sh3/clock-sh7705.c
26495 views
// SPDX-License-Identifier: GPL-2.01/*2* arch/sh/kernel/cpu/sh3/clock-sh7705.c3*4* SH7705 support for the clock framework5*6* Copyright (C) 2005 Paul Mundt7*8* FRQCR parsing hacked out of arch/sh/kernel/time.c9*10* Copyright (C) 1999 Tetsuya Okada & Niibe Yutaka11* Copyright (C) 2000 Philipp Rumpf <[email protected]>12* Copyright (C) 2002, 2003, 2004 Paul Mundt13* Copyright (C) 2002 M. R. Brown <[email protected]>14*/15#include <linux/init.h>16#include <linux/kernel.h>17#include <asm/clock.h>18#include <asm/freq.h>19#include <asm/io.h>2021/*22* SH7705 uses the same divisors as the generic SH-3 case, it's just the23* FRQCR layout that is a bit different..24*/25static int stc_multipliers[] = { 1, 2, 3, 4, 6, 1, 1, 1 };26static int ifc_divisors[] = { 1, 2, 3, 4, 1, 1, 1, 1 };27static int pfc_divisors[] = { 1, 2, 3, 4, 6, 1, 1, 1 };2829static void master_clk_init(struct clk *clk)30{31clk->rate *= pfc_divisors[__raw_readw(FRQCR) & 0x0003];32}3334static struct sh_clk_ops sh7705_master_clk_ops = {35.init = master_clk_init,36};3738static unsigned long module_clk_recalc(struct clk *clk)39{40int idx = __raw_readw(FRQCR) & 0x0003;41return clk->parent->rate / pfc_divisors[idx];42}4344static struct sh_clk_ops sh7705_module_clk_ops = {45.recalc = module_clk_recalc,46};4748static unsigned long bus_clk_recalc(struct clk *clk)49{50int idx = (__raw_readw(FRQCR) & 0x0300) >> 8;51return clk->parent->rate / stc_multipliers[idx];52}5354static struct sh_clk_ops sh7705_bus_clk_ops = {55.recalc = bus_clk_recalc,56};5758static unsigned long cpu_clk_recalc(struct clk *clk)59{60int idx = (__raw_readw(FRQCR) & 0x0030) >> 4;61return clk->parent->rate / ifc_divisors[idx];62}6364static struct sh_clk_ops sh7705_cpu_clk_ops = {65.recalc = cpu_clk_recalc,66};6768static struct sh_clk_ops *sh7705_clk_ops[] = {69&sh7705_master_clk_ops,70&sh7705_module_clk_ops,71&sh7705_bus_clk_ops,72&sh7705_cpu_clk_ops,73};7475void __init arch_init_clk_ops(struct sh_clk_ops **ops, int idx)76{77if (idx < ARRAY_SIZE(sh7705_clk_ops))78*ops = sh7705_clk_ops[idx];79}80818283