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