1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
|
From 466743ec93a99240c1a5a04d65f490fd8370fbc3 Mon Sep 17 00:00:00 2001
From: notro <notro@tronnes.org>
Date: Sun, 6 Jul 2014 12:09:30 +0200
Subject: [PATCH 048/114] BCM2708: Migrate to the Common Clock Framework
As part of moving towards using Device Tree, the Common Clock Framework
has to be used instead of the BCM2708 clock implementation.
Selecting COMMON_CLK removes the need to set CLKDEV_LOOKUP and HAVE_CLK explicitly.
CONFIG_ARCH_BCM2708_CHIPIT #ifdef's are removed. They are no longer in use.
Signed-off-by: Noralf Tronnes <notro@tronnes.org>
---
arch/arm/Kconfig | 3 +-
arch/arm/mach-bcm2708/Makefile | 2 +-
arch/arm/mach-bcm2708/bcm2708.c | 79 +++++++++++++++++------------------------
arch/arm/mach-bcm2708/clock.c | 61 -------------------------------
arch/arm/mach-bcm2708/clock.h | 24 -------------
5 files changed, 34 insertions(+), 135 deletions(-)
delete mode 100644 arch/arm/mach-bcm2708/clock.c
delete mode 100644 arch/arm/mach-bcm2708/clock.h
diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index ba9c18e..0f2287f 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -385,11 +385,10 @@ config ARCH_BCM2708
bool "Broadcom BCM2708 family"
select CPU_V6
select ARM_AMBA
- select HAVE_CLK
select HAVE_SCHED_CLOCK
select NEED_MACH_GPIO_H
select NEED_MACH_MEMORY_H
- select CLKDEV_LOOKUP
+ select COMMON_CLK
select ARCH_HAS_CPUFREQ
select GENERIC_CLOCKEVENTS
select ARM_ERRATA_411920
diff --git a/arch/arm/mach-bcm2708/Makefile b/arch/arm/mach-bcm2708/Makefile
index a722f3f..21e3521 100644
--- a/arch/arm/mach-bcm2708/Makefile
+++ b/arch/arm/mach-bcm2708/Makefile
@@ -2,6 +2,6 @@
# Makefile for the linux kernel.
#
-obj-$(CONFIG_MACH_BCM2708) += clock.o bcm2708.o armctrl.o vcio.o power.o dma.o
+obj-$(CONFIG_MACH_BCM2708) += bcm2708.o armctrl.o vcio.o power.o dma.o
obj-$(CONFIG_BCM2708_GPIO) += bcm2708_gpio.o
obj-$(CONFIG_BCM2708_VCMEM) += vc_mem.o
diff --git a/arch/arm/mach-bcm2708/bcm2708.c b/arch/arm/mach-bcm2708/bcm2708.c
index 633be19..ef12cb8 100644
--- a/arch/arm/mach-bcm2708/bcm2708.c
+++ b/arch/arm/mach-bcm2708/bcm2708.c
@@ -27,6 +27,8 @@
#include <linux/interrupt.h>
#include <linux/amba/bus.h>
#include <linux/amba/clcd.h>
+#include <linux/clk-provider.h>
+#include <linux/clkdev.h>
#include <linux/clockchips.h>
#include <linux/cnt32_to_63.h>
#include <linux/io.h>
@@ -58,7 +60,6 @@
#include "bcm2708.h"
#include "armctrl.h"
-#include "clock.h"
#ifdef CONFIG_BCM_VC_CMA
#include <linux/broadcom/vc_cma.h>
@@ -84,7 +85,7 @@
/* command line parameters */
static unsigned boardrev, serial;
-static unsigned uart_clock;
+static unsigned uart_clock = UART0_CLOCK;
static unsigned disk_led_gpio = 16;
static unsigned disk_led_active_low = 1;
static unsigned reboot_part = 0;
@@ -196,51 +197,39 @@ static void __init bcm2708_clocksource_init(void)
}
}
+struct clk __init *bcm2708_clk_register(const char *name, unsigned long fixed_rate)
+{
+ struct clk *clk;
-/*
- * These are fixed clocks.
- */
-static struct clk ref24_clk = {
- .rate = UART0_CLOCK, /* The UART is clocked at 3MHz via APB_CLK */
-};
+ clk = clk_register_fixed_rate(NULL, name, NULL, CLK_IS_ROOT,
+ fixed_rate);
+ if (IS_ERR(clk))
+ pr_err("%s not registered\n", name);
-static struct clk osc_clk = {
-#ifdef CONFIG_ARCH_BCM2708_CHIPIT
- .rate = 27000000,
-#else
- .rate = 500000000, /* ARM clock is set from the VideoCore booter */
-#endif
-};
+ return clk;
+}
-/* warning - the USB needs a clock > 34MHz */
+void __init bcm2708_register_clkdev(struct clk *clk, const char *name)
+{
+ int ret;
-static struct clk sdhost_clk = {
-#ifdef CONFIG_ARCH_BCM2708_CHIPIT
- .rate = 4000000, /* 4MHz */
-#else
- .rate = 250000000, /* 250MHz */
-#endif
-};
+ ret = clk_register_clkdev(clk, NULL, name);
+ if (ret)
+ pr_err("%s alias not registered\n", name);
+}
-static struct clk_lookup lookups[] = {
- { /* UART0 */
- .dev_id = "dev:f1",
- .clk = &ref24_clk,
- },
- { /* USB */
- .dev_id = "bcm2708_usb",
- .clk = &osc_clk,
- }, { /* SPI */
- .dev_id = "bcm2708_spi.0",
- .clk = &sdhost_clk,
- }, { /* BSC0 */
- .dev_id = "bcm2708_i2c.0",
- .clk = &sdhost_clk,
- }, { /* BSC1 */
- .dev_id = "bcm2708_i2c.1",
- .clk = &sdhost_clk,
- }
-};
+void __init bcm2708_init_clocks(void)
+{
+ struct clk *clk;
+
+ clk = bcm2708_clk_register("uart0_clk", uart_clock);
+ bcm2708_register_clkdev(clk, "dev:f1");
+
+ clk = bcm2708_clk_register("sdhost_clk", 250000000);
+ bcm2708_register_clkdev(clk, "bcm2708_spi.0");
+ bcm2708_register_clkdev(clk, "bcm2708_i2c.0");
+ bcm2708_register_clkdev(clk, "bcm2708_i2c.1");
+}
#define UART0_IRQ { IRQ_UART, 0 /*NO_IRQ*/ }
#define UART0_DMA { 15, 14 }
@@ -755,11 +744,7 @@ void __init bcm2708_init(void)
printk("bcm2708.uart_clock = %d\n", uart_clock);
pm_power_off = bcm2708_power_off;
- if (uart_clock)
- lookups[0].clk->rate = uart_clock;
-
- for (i = 0; i < ARRAY_SIZE(lookups); i++)
- clkdev_add(&lookups[i]);
+ bcm2708_init_clocks();
bcm_register_device(&bcm2708_dmaman_device);
bcm_register_device(&bcm2708_vcio_device);
diff --git a/arch/arm/mach-bcm2708/clock.c b/arch/arm/mach-bcm2708/clock.c
deleted file mode 100644
index 4fc556e..0000000
--- a/arch/arm/mach-bcm2708/clock.c
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * linux/arch/arm/mach-bcm2708/clock.c
- *
- * Copyright (C) 2010 Broadcom
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- */
-#include <linux/module.h>
-#include <linux/kernel.h>
-#include <linux/device.h>
-#include <linux/list.h>
-#include <linux/errno.h>
-#include <linux/err.h>
-#include <linux/string.h>
-#include <linux/clk.h>
-#include <linux/mutex.h>
-
-#include <asm/clkdev.h>
-
-#include "clock.h"
-
-int clk_enable(struct clk *clk)
-{
- return 0;
-}
-EXPORT_SYMBOL(clk_enable);
-
-void clk_disable(struct clk *clk)
-{
-}
-EXPORT_SYMBOL(clk_disable);
-
-unsigned long clk_get_rate(struct clk *clk)
-{
- return clk->rate;
-}
-EXPORT_SYMBOL(clk_get_rate);
-
-long clk_round_rate(struct clk *clk, unsigned long rate)
-{
- return clk->rate;
-}
-EXPORT_SYMBOL(clk_round_rate);
-
-int clk_set_rate(struct clk *clk, unsigned long rate)
-{
- return -EIO;
-}
-EXPORT_SYMBOL(clk_set_rate);
diff --git a/arch/arm/mach-bcm2708/clock.h b/arch/arm/mach-bcm2708/clock.h
deleted file mode 100644
index 5f9d725..0000000
--- a/arch/arm/mach-bcm2708/clock.h
+++ /dev/null
@@ -1,24 +0,0 @@
-/*
- * linux/arch/arm/mach-bcm2708/clock.h
- *
- * Copyright (C) 2010 Broadcom
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- */
-struct module;
-
-struct clk {
- unsigned long rate;
-};
--
1.8.3.2
|