blob: 8aaf4e6b60c300760c443aa6fe4548fe165ff3b6 [file] [log] [blame]
Kukjin Kim1a0e8a52010-01-14 08:13:37 +09001/* linux/arch/arm/plat-s5p/clock.c
2 *
3 * Copyright 2009 Samsung Electronics Co., Ltd.
4 * http://www.samsung.com/
5 *
6 * S5P - Common clock support
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 as
10 * published by the Free Software Foundation.
11*/
12
13#include <linux/init.h>
14#include <linux/module.h>
15#include <linux/kernel.h>
16#include <linux/list.h>
17#include <linux/errno.h>
18#include <linux/err.h>
19#include <linux/clk.h>
20#include <linux/sysdev.h>
21#include <linux/io.h>
22#include <asm/div64.h>
23
24#include <plat/clock.h>
25#include <plat/clock-clksrc.h>
26#include <plat/s5p-clock.h>
27
28/* fin_apll, fin_mpll and fin_epll are all the same clock, which we call
29 * clk_ext_xtal_mux.
30*/
31struct clk clk_ext_xtal_mux = {
32 .name = "ext_xtal",
33 .id = -1,
34};
35
Thomas Abrahamf001d5b2010-04-19 20:05:08 +090036struct clk clk_xusbxti = {
37 .name = "xusbxti",
38 .id = -1,
39};
40
Thomas Abrahama443a632010-05-14 16:27:28 +090041struct clk s5p_clk_27m = {
Kukjin Kim0c1945d2010-02-24 16:40:36 +090042 .name = "clk_27m",
43 .id = -1,
44 .rate = 27000000,
45};
46
Kukjin Kim1a0e8a52010-01-14 08:13:37 +090047/* 48MHz USB Phy clock output */
48struct clk clk_48m = {
49 .name = "clk_48m",
50 .id = -1,
51 .rate = 48000000,
52};
53
54/* APLL clock output
55 * No need .ctrlbit, this is always on
56*/
57struct clk clk_fout_apll = {
58 .name = "fout_apll",
59 .id = -1,
60};
61
62/* MPLL clock output
63 * No need .ctrlbit, this is always on
64*/
65struct clk clk_fout_mpll = {
66 .name = "fout_mpll",
67 .id = -1,
68};
69
70/* EPLL clock output */
71struct clk clk_fout_epll = {
72 .name = "fout_epll",
73 .id = -1,
74 .ctrlbit = (1 << 31),
75};
76
Kukjin Kim3109e552010-09-01 15:35:30 +090077/* DPLL clock output */
78struct clk clk_fout_dpll = {
79 .name = "fout_dpll",
80 .id = -1,
81 .ctrlbit = (1 << 31),
82};
83
Thomas Abrahamf445dbd2010-05-17 09:38:52 +090084/* VPLL clock output */
85struct clk clk_fout_vpll = {
86 .name = "fout_vpll",
87 .id = -1,
88 .ctrlbit = (1 << 31),
89};
90
Kukjin Kim1a0e8a52010-01-14 08:13:37 +090091/* ARM clock */
92struct clk clk_arm = {
93 .name = "armclk",
94 .id = -1,
95 .rate = 0,
96 .ctrlbit = 0,
97};
98
99/* Possible clock sources for APLL Mux */
100static struct clk *clk_src_apll_list[] = {
101 [0] = &clk_fin_apll,
102 [1] = &clk_fout_apll,
103};
104
105struct clksrc_sources clk_src_apll = {
106 .sources = clk_src_apll_list,
107 .nr_sources = ARRAY_SIZE(clk_src_apll_list),
108};
109
110/* Possible clock sources for MPLL Mux */
111static struct clk *clk_src_mpll_list[] = {
112 [0] = &clk_fin_mpll,
113 [1] = &clk_fout_mpll,
114};
115
116struct clksrc_sources clk_src_mpll = {
117 .sources = clk_src_mpll_list,
118 .nr_sources = ARRAY_SIZE(clk_src_mpll_list),
119};
120
121/* Possible clock sources for EPLL Mux */
122static struct clk *clk_src_epll_list[] = {
123 [0] = &clk_fin_epll,
124 [1] = &clk_fout_epll,
125};
126
127struct clksrc_sources clk_src_epll = {
128 .sources = clk_src_epll_list,
129 .nr_sources = ARRAY_SIZE(clk_src_epll_list),
130};
131
Kukjin Kim3109e552010-09-01 15:35:30 +0900132/* Possible clock sources for DPLL Mux */
133static struct clk *clk_src_dpll_list[] = {
134 [0] = &clk_fin_dpll,
135 [1] = &clk_fout_dpll,
136};
137
138struct clksrc_sources clk_src_dpll = {
139 .sources = clk_src_dpll_list,
140 .nr_sources = ARRAY_SIZE(clk_src_dpll_list),
141};
142
Kukjin Kim0c1945d2010-02-24 16:40:36 +0900143struct clk clk_vpll = {
144 .name = "vpll",
145 .id = -1,
146};
147
Kukjin Kim1a0e8a52010-01-14 08:13:37 +0900148int s5p_gatectrl(void __iomem *reg, struct clk *clk, int enable)
149{
150 unsigned int ctrlbit = clk->ctrlbit;
151 u32 con;
152
153 con = __raw_readl(reg);
154 con = enable ? (con | ctrlbit) : (con & ~ctrlbit);
155 __raw_writel(con, reg);
156 return 0;
157}
158
159static struct clk *s5p_clks[] __initdata = {
160 &clk_ext_xtal_mux,
161 &clk_48m,
Kukjin Kim0c1945d2010-02-24 16:40:36 +0900162 &s5p_clk_27m,
Kukjin Kim1a0e8a52010-01-14 08:13:37 +0900163 &clk_fout_apll,
164 &clk_fout_mpll,
165 &clk_fout_epll,
Kukjin Kim3109e552010-09-01 15:35:30 +0900166 &clk_fout_dpll,
Thomas Abrahamf445dbd2010-05-17 09:38:52 +0900167 &clk_fout_vpll,
Kukjin Kim1a0e8a52010-01-14 08:13:37 +0900168 &clk_arm,
Kukjin Kim0c1945d2010-02-24 16:40:36 +0900169 &clk_vpll,
Thomas Abraham8fb9d2d2010-05-28 11:41:16 +0900170 &clk_xusbxti,
Kukjin Kim1a0e8a52010-01-14 08:13:37 +0900171};
172
173void __init s5p_register_clocks(unsigned long xtal_freq)
174{
175 int ret;
176
177 clk_ext_xtal_mux.rate = xtal_freq;
178
179 ret = s3c24xx_register_clocks(s5p_clks, ARRAY_SIZE(s5p_clks));
180 if (ret > 0)
181 printk(KERN_ERR "Failed to register s5p clocks\n");
182}