aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm/mach-shmobile/clock-r8a73a4.c
diff options
context:
space:
mode:
authorKuninori Morimoto <kuninori.morimoto.gx@renesas.com>2013-04-05 00:20:40 -0400
committerSimon Horman <horms+renesas@verge.net.au>2013-06-07 01:24:44 -0400
commit5e634d98635a135016d77e03de2cecbaba8d9d56 (patch)
treec634826a9c0f970c58209f276ca3078b31b73300 /arch/arm/mach-shmobile/clock-r8a73a4.c
parent58645fe9a81d517eb99a137868f11ac39aa71eb9 (diff)
ARM: shmobile: r8a73a4: add main clock
Almost all clock needs main clock which is basis clock on r8a73a4. This patch adds it, and, set parent clock via CKSCR register. Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> Signed-off-by: Simon Horman <horms+renesas@verge.net.au>
Diffstat (limited to 'arch/arm/mach-shmobile/clock-r8a73a4.c')
-rw-r--r--arch/arm/mach-shmobile/clock-r8a73a4.c53
1 files changed, 53 insertions, 0 deletions
diff --git a/arch/arm/mach-shmobile/clock-r8a73a4.c b/arch/arm/mach-shmobile/clock-r8a73a4.c
index e710c00c3822..42942b4359dc 100644
--- a/arch/arm/mach-shmobile/clock-r8a73a4.c
+++ b/arch/arm/mach-shmobile/clock-r8a73a4.c
@@ -22,6 +22,7 @@
22#include <linux/kernel.h> 22#include <linux/kernel.h>
23#include <linux/sh_clk.h> 23#include <linux/sh_clk.h>
24#include <linux/clkdev.h> 24#include <linux/clkdev.h>
25#include <mach/clock.h>
25#include <mach/common.h> 26#include <mach/common.h>
26 27
27#define CPG_BASE 0xe6150000 28#define CPG_BASE 0xe6150000
@@ -31,6 +32,8 @@
31#define SMSTPCR2 0xe6150138 32#define SMSTPCR2 0xe6150138
32#define SMSTPCR5 0xe6150144 33#define SMSTPCR5 0xe6150144
33 34
35#define CKSCR 0xE61500C0
36
34static struct clk_mapping cpg_mapping = { 37static struct clk_mapping cpg_mapping = {
35 .phys = CPG_BASE, 38 .phys = CPG_BASE,
36 .len = CPG_LEN, 39 .len = CPG_LEN,
@@ -51,10 +54,32 @@ static struct clk extal2_clk = {
51 .mapping = &cpg_mapping, 54 .mapping = &cpg_mapping,
52}; 55};
53 56
57static struct sh_clk_ops followparent_clk_ops = {
58 .recalc = followparent_recalc,
59};
60
61static struct clk main_clk = {
62 /* .parent will be set r8a73a4_clock_init */
63 .ops = &followparent_clk_ops,
64};
65
66SH_CLK_RATIO(div2, 1, 2);
67SH_CLK_RATIO(div4, 1, 4);
68
69SH_FIXED_RATIO_CLK(main_div2_clk, main_clk, div2);
70SH_FIXED_RATIO_CLK(extal1_div2_clk, extal1_clk, div2);
71SH_FIXED_RATIO_CLK(extal2_div2_clk, extal2_clk, div2);
72SH_FIXED_RATIO_CLK(extal2_div4_clk, extal2_clk, div4);
73
54static struct clk *main_clks[] = { 74static struct clk *main_clks[] = {
55 &extalr_clk, 75 &extalr_clk,
56 &extal1_clk, 76 &extal1_clk,
77 &extal1_div2_clk,
57 &extal2_clk, 78 &extal2_clk,
79 &extal2_div2_clk,
80 &extal2_div4_clk,
81 &main_clk,
82 &main_div2_clk,
58}; 83};
59 84
60enum { 85enum {
@@ -74,6 +99,13 @@ static struct clk mstp_clks[MSTP_NR] = {
74}; 99};
75 100
76static struct clk_lookup lookups[] = { 101static struct clk_lookup lookups[] = {
102 /* main clock */
103 CLKDEV_CON_ID("extal1", &extal1_clk),
104 CLKDEV_CON_ID("extal1_div2", &extal1_div2_clk),
105 CLKDEV_CON_ID("extal2", &extal2_clk),
106 CLKDEV_CON_ID("extal2_div2", &extal2_div2_clk),
107 CLKDEV_CON_ID("extal2_div4", &extal2_div4_clk),
108
77 CLKDEV_DEV_ID("sh-sci.0", &mstp_clks[MSTP204]), 109 CLKDEV_DEV_ID("sh-sci.0", &mstp_clks[MSTP204]),
78 CLKDEV_DEV_ID("sh-sci.1", &mstp_clks[MSTP203]), 110 CLKDEV_DEV_ID("sh-sci.1", &mstp_clks[MSTP203]),
79 CLKDEV_DEV_ID("sh-sci.2", &mstp_clks[MSTP206]), 111 CLKDEV_DEV_ID("sh-sci.2", &mstp_clks[MSTP206]),
@@ -90,6 +122,7 @@ void __init r8a73a4_clock_init(void)
90{ 122{
91 void __iomem *cpg_base, *reg; 123 void __iomem *cpg_base, *reg;
92 int k, ret = 0; 124 int k, ret = 0;
125 u32 ckscr;
93 126
94 /* fix MPCLK to EXTAL2 for now. 127 /* fix MPCLK to EXTAL2 for now.
95 * this is needed until more detailed clock topology is supported 128 * this is needed until more detailed clock topology is supported
@@ -100,6 +133,26 @@ void __init r8a73a4_clock_init(void)
100 iowrite32(ioread32(reg) | 1 << 7 | 0x0c, reg); /* set CKSEL */ 133 iowrite32(ioread32(reg) | 1 << 7 | 0x0c, reg); /* set CKSEL */
101 iounmap(cpg_base); 134 iounmap(cpg_base);
102 135
136 reg = ioremap_nocache(CKSCR, PAGE_SIZE);
137 BUG_ON(!reg);
138 ckscr = ioread32(reg);
139 iounmap(reg);
140
141 switch ((ckscr >> 28) & 0x3) {
142 case 0:
143 main_clk.parent = &extal1_clk;
144 break;
145 case 1:
146 main_clk.parent = &extal1_div2_clk;
147 break;
148 case 2:
149 main_clk.parent = &extal2_clk;
150 break;
151 case 3:
152 main_clk.parent = &extal2_div2_clk;
153 break;
154 }
155
103 for (k = 0; !ret && (k < ARRAY_SIZE(main_clks)); k++) 156 for (k = 0; !ret && (k < ARRAY_SIZE(main_clks)); k++)
104 ret = clk_register(main_clks[k]); 157 ret = clk_register(main_clks[k]);
105 158