Path: blob/master/arch/sh/kernel/cpu/sh4a/clock-shx3.c
17495 views
/*1* arch/sh/kernel/cpu/sh4/clock-shx3.c2*3* SH-X3 support for the clock framework4*5* Copyright (C) 2006-2007 Renesas Technology Corp.6* Copyright (C) 2006-2007 Renesas Solutions Corp.7* Copyright (C) 2006-2010 Paul Mundt8*9* This file is subject to the terms and conditions of the GNU General Public10* License. See the file "COPYING" in the main directory of this archive11* for more details.12*/13#include <linux/init.h>14#include <linux/kernel.h>15#include <linux/io.h>16#include <linux/clkdev.h>17#include <asm/clock.h>18#include <asm/freq.h>1920/*21* Default rate for the root input clock, reset this with clk_set_rate()22* from the platform code.23*/24static struct clk extal_clk = {25.rate = 16666666,26};2728static unsigned long pll_recalc(struct clk *clk)29{30/* PLL1 has a fixed x72 multiplier. */31return clk->parent->rate * 72;32}3334static struct clk_ops pll_clk_ops = {35.recalc = pll_recalc,36};3738static struct clk pll_clk = {39.ops = &pll_clk_ops,40.parent = &extal_clk,41.flags = CLK_ENABLE_ON_INIT,42};4344static struct clk *clks[] = {45&extal_clk,46&pll_clk,47};4849static unsigned int div2[] = { 1, 2, 4, 6, 8, 12, 16, 18,5024, 32, 36, 48 };5152static struct clk_div_mult_table div4_div_mult_table = {53.divisors = div2,54.nr_divisors = ARRAY_SIZE(div2),55};5657static struct clk_div4_table div4_table = {58.div_mult_table = &div4_div_mult_table,59};6061enum { DIV4_I, DIV4_SH, DIV4_B, DIV4_DDR, DIV4_SHA, DIV4_P, DIV4_NR };6263#define DIV4(_bit, _mask, _flags) \64SH_CLK_DIV4(&pll_clk, FRQMR1, _bit, _mask, _flags)6566struct clk div4_clks[DIV4_NR] = {67[DIV4_P] = DIV4(0, 0x0f80, 0),68[DIV4_SHA] = DIV4(4, 0x0ff0, 0),69[DIV4_DDR] = DIV4(12, 0x000c, CLK_ENABLE_ON_INIT),70[DIV4_B] = DIV4(16, 0x0fe0, CLK_ENABLE_ON_INIT),71[DIV4_SH] = DIV4(20, 0x000c, CLK_ENABLE_ON_INIT),72[DIV4_I] = DIV4(28, 0x000e, CLK_ENABLE_ON_INIT),73};7475#define MSTPCR0 0xffc0003076#define MSTPCR1 0xffc000347778enum { MSTP027, MSTP026, MSTP025, MSTP024,79MSTP009, MSTP008, MSTP003, MSTP002,80MSTP001, MSTP000, MSTP119, MSTP105,81MSTP104, MSTP_NR };8283static struct clk mstp_clks[MSTP_NR] = {84/* MSTPCR0 */85[MSTP027] = SH_CLK_MSTP32(&div4_clks[DIV4_P], MSTPCR0, 27, 0),86[MSTP026] = SH_CLK_MSTP32(&div4_clks[DIV4_P], MSTPCR0, 26, 0),87[MSTP025] = SH_CLK_MSTP32(&div4_clks[DIV4_P], MSTPCR0, 25, 0),88[MSTP024] = SH_CLK_MSTP32(&div4_clks[DIV4_P], MSTPCR0, 24, 0),89[MSTP009] = SH_CLK_MSTP32(&div4_clks[DIV4_P], MSTPCR0, 9, 0),90[MSTP008] = SH_CLK_MSTP32(&div4_clks[DIV4_P], MSTPCR0, 8, 0),91[MSTP003] = SH_CLK_MSTP32(&div4_clks[DIV4_P], MSTPCR0, 3, 0),92[MSTP002] = SH_CLK_MSTP32(&div4_clks[DIV4_P], MSTPCR0, 2, 0),93[MSTP001] = SH_CLK_MSTP32(&div4_clks[DIV4_P], MSTPCR0, 1, 0),94[MSTP000] = SH_CLK_MSTP32(&div4_clks[DIV4_P], MSTPCR0, 0, 0),9596/* MSTPCR1 */97[MSTP119] = SH_CLK_MSTP32(NULL, MSTPCR1, 19, 0),98[MSTP105] = SH_CLK_MSTP32(NULL, MSTPCR1, 5, 0),99[MSTP104] = SH_CLK_MSTP32(NULL, MSTPCR1, 4, 0),100};101102#define CLKDEV_CON_ID(_id, _clk) { .con_id = _id, .clk = _clk }103104static struct clk_lookup lookups[] = {105/* main clocks */106CLKDEV_CON_ID("extal", &extal_clk),107CLKDEV_CON_ID("pll_clk", &pll_clk),108109/* DIV4 clocks */110CLKDEV_CON_ID("peripheral_clk", &div4_clks[DIV4_P]),111CLKDEV_CON_ID("shywaya_clk", &div4_clks[DIV4_SHA]),112CLKDEV_CON_ID("ddr_clk", &div4_clks[DIV4_DDR]),113CLKDEV_CON_ID("bus_clk", &div4_clks[DIV4_B]),114CLKDEV_CON_ID("shyway_clk", &div4_clks[DIV4_SH]),115CLKDEV_CON_ID("cpu_clk", &div4_clks[DIV4_I]),116117/* MSTP32 clocks */118{119/* SCIF3 */120.dev_id = "sh-sci.3",121.con_id = "sci_fck",122.clk = &mstp_clks[MSTP027],123}, {124/* SCIF2 */125.dev_id = "sh-sci.2",126.con_id = "sci_fck",127.clk = &mstp_clks[MSTP026],128}, {129/* SCIF1 */130.dev_id = "sh-sci.1",131.con_id = "sci_fck",132.clk = &mstp_clks[MSTP025],133}, {134/* SCIF0 */135.dev_id = "sh-sci.0",136.con_id = "sci_fck",137.clk = &mstp_clks[MSTP024],138},139CLKDEV_CON_ID("h8ex_fck", &mstp_clks[MSTP003]),140CLKDEV_CON_ID("csm_fck", &mstp_clks[MSTP002]),141CLKDEV_CON_ID("fe1_fck", &mstp_clks[MSTP001]),142CLKDEV_CON_ID("fe0_fck", &mstp_clks[MSTP000]),143{144/* TMU0 */145.dev_id = "sh_tmu.0",146.con_id = "tmu_fck",147.clk = &mstp_clks[MSTP008],148}, {149/* TMU1 */150.dev_id = "sh_tmu.1",151.con_id = "tmu_fck",152.clk = &mstp_clks[MSTP008],153}, {154/* TMU2 */155.dev_id = "sh_tmu.2",156.con_id = "tmu_fck",157.clk = &mstp_clks[MSTP008],158}, {159/* TMU3 */160.dev_id = "sh_tmu.3",161.con_id = "tmu_fck",162.clk = &mstp_clks[MSTP009],163}, {164/* TMU4 */165.dev_id = "sh_tmu.4",166.con_id = "tmu_fck",167.clk = &mstp_clks[MSTP009],168}, {169/* TMU5 */170.dev_id = "sh_tmu.5",171.con_id = "tmu_fck",172.clk = &mstp_clks[MSTP009],173},174CLKDEV_CON_ID("hudi_fck", &mstp_clks[MSTP119]),175CLKDEV_CON_ID("dmac_11_6_fck", &mstp_clks[MSTP105]),176CLKDEV_CON_ID("dmac_5_0_fck", &mstp_clks[MSTP104]),177};178179int __init arch_clk_init(void)180{181int i, ret = 0;182183for (i = 0; i < ARRAY_SIZE(clks); i++)184ret |= clk_register(clks[i]);185for (i = 0; i < ARRAY_SIZE(lookups); i++)186clkdev_add(&lookups[i]);187188if (!ret)189ret = sh_clk_div4_register(div4_clks, ARRAY_SIZE(div4_clks),190&div4_table);191if (!ret)192ret = sh_clk_mstp32_register(mstp_clks, MSTP_NR);193194return ret;195}196197198