2 * r8a73a4 clock framework support
4 * Copyright (C) 2013 Renesas Solutions Corp.
5 * Copyright (C) 2013 Magnus Damm
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; version 2 of the License.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20 #include <linux/init.h>
22 #include <linux/kernel.h>
23 #include <linux/sh_clk.h>
24 #include <linux/clkdev.h>
25 #include <mach/common.h>
27 #define CPG_BASE 0xe6150000
30 #define MPCKCR 0xe6150080
32 static struct clk_mapping cpg_mapping = {
37 static struct clk extalr_clk = {
39 .mapping = &cpg_mapping,
42 static struct clk extal1_clk = {
44 .mapping = &cpg_mapping,
47 static struct clk extal2_clk = {
49 .mapping = &cpg_mapping,
52 static struct clk *main_clks[] = {
59 static struct clk mstp_clks[MSTP_NR] = {
62 static struct clk_lookup lookups[] = {
65 void __init r8a73a4_clock_init(void)
67 void __iomem *cpg_base, *reg;
70 /* fix MPCLK to EXTAL2 for now.
71 * this is needed until more detailed clock topology is supported
73 cpg_base = ioremap_nocache(CPG_BASE, CPG_LEN);
75 reg = cpg_base + (MPCKCR - CPG_BASE);
76 iowrite32(ioread32(reg) | 1 << 7 | 0x0c, reg); /* set CKSEL */
79 for (k = 0; !ret && (k < ARRAY_SIZE(main_clks)); k++)
80 ret = clk_register(main_clks[k]);
83 ret = sh_clk_mstp_register(mstp_clks, MSTP_NR);
85 clkdev_add_table(lookups, ARRAY_SIZE(lookups));
90 panic("failed to setup r8a73a4 clocks\n");