aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Abraham <thomas.abraham@linaro.org>2013-03-09 03:03:01 -0500
committerKukjin Kim <kgene.kim@samsung.com>2013-03-25 05:17:05 -0400
commitf2585b1cce24d7bc5b4a1de582bf81e43813f840 (patch)
tree4f08cb0c5d754dbe59dd018c98dc8fc5d4e3d14c
parent6e3ad26816b7281ce3b51296180aeba5d1528d1c (diff)
clk: exynos5440: register clocks using common clock framework
The Exynos5440 clocks are statically listed and registered using the Samsung specific common clock helper functions. Signed-off-by: Thomas Abraham <thomas.abraham@linaro.org> Acked-by: Mike Turquette <mturquette@linaro.org> Signed-off-by: Kukjin Kim <kgene.kim@samsung.com>
-rw-r--r--Documentation/devicetree/bindings/clock/exynos5440-clock.txt61
-rw-r--r--drivers/clk/samsung/Makefile1
-rw-r--r--drivers/clk/samsung/clk-exynos5440.c139
3 files changed, 201 insertions, 0 deletions
diff --git a/Documentation/devicetree/bindings/clock/exynos5440-clock.txt b/Documentation/devicetree/bindings/clock/exynos5440-clock.txt
new file mode 100644
index 000000000000..4499e9966bc9
--- /dev/null
+++ b/Documentation/devicetree/bindings/clock/exynos5440-clock.txt
@@ -0,0 +1,61 @@
1* Samsung Exynos5440 Clock Controller
2
3The Exynos5440 clock controller generates and supplies clock to various
4controllers within the Exynos5440 SoC.
5
6Required Properties:
7
8- comptible: should be "samsung,exynos5440-clock".
9
10- reg: physical base address of the controller and length of memory mapped
11 region.
12
13- #clock-cells: should be 1.
14
15The following is the list of clocks generated by the controller. Each clock is
16assigned an identifier and client nodes use this identifier to specify the
17clock which they consume.
18
19
20 [Core Clocks]
21
22 Clock ID
23 ----------------------------
24
25 xtal 1
26 arm_clk 2
27
28 [Peripheral Clock Gates]
29
30 Clock ID
31 ----------------------------
32
33 spi_baud 16
34 pb0_250 17
35 pr0_250 18
36 pr1_250 19
37 b_250 20
38 b_125 21
39 b_200 22
40 sata 23
41 usb 24
42 gmac0 25
43 cs250 26
44 pb0_250_o 27
45 pr0_250_o 28
46 pr1_250_o 29
47 b_250_o 30
48 b_125_o 31
49 b_200_o 32
50 sata_o 33
51 usb_o 34
52 gmac0_o 35
53 cs250_o 36
54
55Example: An example of a clock controller node is listed below.
56
57 clock: clock-controller@0x10010000 {
58 compatible = "samsung,exynos5440-clock";
59 reg = <0x160000 0x10000>;
60 #clock-cells = <1>;
61 };
diff --git a/drivers/clk/samsung/Makefile b/drivers/clk/samsung/Makefile
index f18fb0718157..b7c232e67425 100644
--- a/drivers/clk/samsung/Makefile
+++ b/drivers/clk/samsung/Makefile
@@ -5,3 +5,4 @@
5obj-$(CONFIG_COMMON_CLK) += clk.o clk-pll.o 5obj-$(CONFIG_COMMON_CLK) += clk.o clk-pll.o
6obj-$(CONFIG_ARCH_EXYNOS4) += clk-exynos4.o 6obj-$(CONFIG_ARCH_EXYNOS4) += clk-exynos4.o
7obj-$(CONFIG_SOC_EXYNOS5250) += clk-exynos5250.o 7obj-$(CONFIG_SOC_EXYNOS5250) += clk-exynos5250.o
8obj-$(CONFIG_SOC_EXYNOS5440) += clk-exynos5440.o
diff --git a/drivers/clk/samsung/clk-exynos5440.c b/drivers/clk/samsung/clk-exynos5440.c
new file mode 100644
index 000000000000..d588e939c235
--- /dev/null
+++ b/drivers/clk/samsung/clk-exynos5440.c
@@ -0,0 +1,139 @@
1/*
2 * Copyright (c) 2013 Samsung Electronics Co., Ltd.
3 * Author: Thomas Abraham <thomas.ab@samsung.com>
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 2 as
7 * published by the Free Software Foundation.
8 *
9 * Common Clock Framework support for Exynos5440 SoC.
10*/
11
12#include <linux/clk.h>
13#include <linux/clkdev.h>
14#include <linux/clk-provider.h>
15#include <linux/of.h>
16#include <linux/of_address.h>
17
18#include <plat/cpu.h>
19#include "clk.h"
20#include "clk-pll.h"
21
22#define CLKEN_OV_VAL 0xf8
23#define CPU_CLK_STATUS 0xfc
24#define MISC_DOUT1 0x558
25
26/*
27 * Let each supported clock get a unique id. This id is used to lookup the clock
28 * for device tree based platforms.
29 */
30enum exynos5440_clks {
31 none, xtal, arm_clk,
32
33 spi_baud = 16, pb0_250, pr0_250, pr1_250, b_250, b_125, b_200, sata,
34 usb, gmac0, cs250, pb0_250_o, pr0_250_o, pr1_250_o, b_250_o, b_125_o,
35 b_200_o, sata_o, usb_o, gmac0_o, cs250_o,
36
37 nr_clks,
38};
39
40/* parent clock name list */
41PNAME(mout_armclk_p) = { "cplla", "cpllb" };
42PNAME(mout_spi_p) = { "div125", "div200" };
43
44/* fixed rate clocks generated outside the soc */
45struct samsung_fixed_rate_clock exynos5440_fixed_rate_ext_clks[] __initdata = {
46 FRATE(none, "xtal", NULL, CLK_IS_ROOT, 0),
47};
48
49/* fixed rate clocks */
50struct samsung_fixed_rate_clock exynos5440_fixed_rate_clks[] __initdata = {
51 FRATE(none, "ppll", NULL, CLK_IS_ROOT, 1000000000),
52 FRATE(none, "usb_phy0", NULL, CLK_IS_ROOT, 60000000),
53 FRATE(none, "usb_phy1", NULL, CLK_IS_ROOT, 60000000),
54 FRATE(none, "usb_ohci12", NULL, CLK_IS_ROOT, 12000000),
55 FRATE(none, "usb_ohci48", NULL, CLK_IS_ROOT, 48000000),
56};
57
58/* fixed factor clocks */
59struct samsung_fixed_factor_clock exynos5440_fixed_factor_clks[] __initdata = {
60 FFACTOR(none, "div250", "ppll", 1, 4, 0),
61 FFACTOR(none, "div200", "ppll", 1, 5, 0),
62 FFACTOR(none, "div125", "div250", 1, 2, 0),
63};
64
65/* mux clocks */
66struct samsung_mux_clock exynos5440_mux_clks[] __initdata = {
67 MUX(none, "mout_spi", mout_spi_p, MISC_DOUT1, 5, 1),
68 MUX_A(arm_clk, "arm_clk", mout_armclk_p,
69 CPU_CLK_STATUS, 0, 1, "armclk"),
70};
71
72/* divider clocks */
73struct samsung_div_clock exynos5440_div_clks[] __initdata = {
74 DIV(spi_baud, "div_spi", "mout_spi", MISC_DOUT1, 3, 2),
75};
76
77/* gate clocks */
78struct samsung_gate_clock exynos5440_gate_clks[] __initdata = {
79 GATE(pb0_250, "pb0_250", "div250", CLKEN_OV_VAL, 3, 0, 0),
80 GATE(pr0_250, "pr0_250", "div250", CLKEN_OV_VAL, 4, 0, 0),
81 GATE(pr1_250, "pr1_250", "div250", CLKEN_OV_VAL, 5, 0, 0),
82 GATE(b_250, "b_250", "div250", CLKEN_OV_VAL, 9, 0, 0),
83 GATE(b_125, "b_125", "div125", CLKEN_OV_VAL, 10, 0, 0),
84 GATE(b_200, "b_200", "div200", CLKEN_OV_VAL, 11, 0, 0),
85 GATE(sata, "sata", "div200", CLKEN_OV_VAL, 12, 0, 0),
86 GATE(usb, "usb", "div200", CLKEN_OV_VAL, 13, 0, 0),
87 GATE(gmac0, "gmac0", "div200", CLKEN_OV_VAL, 14, 0, 0),
88 GATE(cs250, "cs250", "div250", CLKEN_OV_VAL, 19, 0, 0),
89 GATE(pb0_250_o, "pb0_250_o", "pb0_250", CLKEN_OV_VAL, 3, 0, 0),
90 GATE(pr0_250_o, "pr0_250_o", "pr0_250", CLKEN_OV_VAL, 4, 0, 0),
91 GATE(pr1_250_o, "pr1_250_o", "pr1_250", CLKEN_OV_VAL, 5, 0, 0),
92 GATE(b_250_o, "b_250_o", "b_250", CLKEN_OV_VAL, 9, 0, 0),
93 GATE(b_125_o, "b_125_o", "b_125", CLKEN_OV_VAL, 10, 0, 0),
94 GATE(b_200_o, "b_200_o", "b_200", CLKEN_OV_VAL, 11, 0, 0),
95 GATE(sata_o, "sata_o", "sata", CLKEN_OV_VAL, 12, 0, 0),
96 GATE(usb_o, "usb_o", "usb", CLKEN_OV_VAL, 13, 0, 0),
97 GATE(gmac0_o, "gmac0_o", "gmac", CLKEN_OV_VAL, 14, 0, 0),
98 GATE(cs250_o, "cs250_o", "cs250", CLKEN_OV_VAL, 19, 0, 0),
99};
100
101static __initdata struct of_device_id ext_clk_match[] = {
102 { .compatible = "samsung,clock-xtal", .data = (void *)0, },
103 {},
104};
105
106/* register exynos5440 clocks */
107void __init exynos5440_clk_init(struct device_node *np)
108{
109 void __iomem *reg_base;
110
111 reg_base = of_iomap(np, 0);
112 if (!reg_base) {
113 pr_err("%s: failed to map clock controller registers,"
114 " aborting clock initialization\n", __func__);
115 return;
116 }
117
118 samsung_clk_init(np, reg_base, nr_clks, NULL, 0);
119 samsung_clk_of_register_fixed_ext(exynos5440_fixed_rate_ext_clks,
120 ARRAY_SIZE(exynos5440_fixed_rate_ext_clks), ext_clk_match);
121
122 samsung_clk_register_pll2550x("cplla", "xtal", reg_base + 0x1c, 0x10);
123 samsung_clk_register_pll2550x("cpllb", "xtal", reg_base + 0x20, 0x10);
124
125 samsung_clk_register_fixed_rate(exynos5440_fixed_rate_clks,
126 ARRAY_SIZE(exynos5440_fixed_rate_clks));
127 samsung_clk_register_fixed_factor(exynos5440_fixed_factor_clks,
128 ARRAY_SIZE(exynos5440_fixed_factor_clks));
129 samsung_clk_register_mux(exynos5440_mux_clks,
130 ARRAY_SIZE(exynos5440_mux_clks));
131 samsung_clk_register_div(exynos5440_div_clks,
132 ARRAY_SIZE(exynos5440_div_clks));
133 samsung_clk_register_gate(exynos5440_gate_clks,
134 ARRAY_SIZE(exynos5440_gate_clks));
135
136 pr_info("Exynos5440: arm_clk = %ldHz\n", _get_rate("armclk"));
137 pr_info("exynos5440 clock initialization complete\n");
138}
139CLK_OF_DECLARE(exynos5440_clk, "samsung,exynos5440-clock", exynos5440_clk_init);