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 --- a/arch/arm/Kconfig
25 +++ b/arch/arm/Kconfig
26 @@ -385,11 +385,10 @@ config ARCH_BCM2708
27 bool "Broadcom BCM2708 family"
31 select HAVE_SCHED_CLOCK
32 select NEED_MACH_GPIO_H
33 select NEED_MACH_MEMORY_H
34 - select CLKDEV_LOOKUP
36 select ARCH_HAS_CPUFREQ
37 select GENERIC_CLOCKEVENTS
38 select ARM_ERRATA_411920
39 --- a/arch/arm/mach-bcm2708/Makefile
40 +++ b/arch/arm/mach-bcm2708/Makefile
42 # Makefile for the linux kernel.
45 -obj-$(CONFIG_MACH_BCM2708) += clock.o bcm2708.o armctrl.o vcio.o power.o dma.o
46 +obj-$(CONFIG_MACH_BCM2708) += bcm2708.o armctrl.o vcio.o power.o dma.o
47 obj-$(CONFIG_BCM2708_GPIO) += bcm2708_gpio.o
48 obj-$(CONFIG_BCM2708_VCMEM) += vc_mem.o
49 --- a/arch/arm/mach-bcm2708/bcm2708.c
50 +++ b/arch/arm/mach-bcm2708/bcm2708.c
52 #include <linux/interrupt.h>
53 #include <linux/amba/bus.h>
54 #include <linux/amba/clcd.h>
55 +#include <linux/clk-provider.h>
56 +#include <linux/clkdev.h>
57 #include <linux/clockchips.h>
58 #include <linux/cnt32_to_63.h>
66 #ifdef CONFIG_BCM_VC_CMA
67 #include <linux/broadcom/vc_cma.h>
70 /* command line parameters */
71 static unsigned boardrev, serial;
72 -static unsigned uart_clock;
73 +static unsigned uart_clock = UART0_CLOCK;
74 static unsigned disk_led_gpio = 16;
75 static unsigned disk_led_active_low = 1;
76 static unsigned reboot_part = 0;
77 @@ -196,51 +197,39 @@ static void __init bcm2708_clocksource_i
81 +struct clk __init *bcm2708_clk_register(const char *name, unsigned long fixed_rate)
86 - * These are fixed clocks.
88 -static struct clk ref24_clk = {
89 - .rate = UART0_CLOCK, /* The UART is clocked at 3MHz via APB_CLK */
91 + clk = clk_register_fixed_rate(NULL, name, NULL, CLK_IS_ROOT,
94 + pr_err("%s not registered\n", name);
96 -static struct clk osc_clk = {
97 -#ifdef CONFIG_ARCH_BCM2708_CHIPIT
100 - .rate = 500000000, /* ARM clock is set from the VideoCore booter */
106 -/* warning - the USB needs a clock > 34MHz */
107 +void __init bcm2708_register_clkdev(struct clk *clk, const char *name)
111 -static struct clk sdhost_clk = {
112 -#ifdef CONFIG_ARCH_BCM2708_CHIPIT
113 - .rate = 4000000, /* 4MHz */
115 - .rate = 250000000, /* 250MHz */
118 + ret = clk_register_clkdev(clk, NULL, name);
120 + pr_err("%s alias not registered\n", name);
123 -static struct clk_lookup lookups[] = {
125 - .dev_id = "dev:f1",
129 - .dev_id = "bcm2708_usb",
132 - .dev_id = "bcm2708_spi.0",
133 - .clk = &sdhost_clk,
135 - .dev_id = "bcm2708_i2c.0",
136 - .clk = &sdhost_clk,
138 - .dev_id = "bcm2708_i2c.1",
139 - .clk = &sdhost_clk,
142 +void __init bcm2708_init_clocks(void)
146 + clk = bcm2708_clk_register("uart0_clk", uart_clock);
147 + bcm2708_register_clkdev(clk, "dev:f1");
149 + clk = bcm2708_clk_register("sdhost_clk", 250000000);
150 + bcm2708_register_clkdev(clk, "bcm2708_spi.0");
151 + bcm2708_register_clkdev(clk, "bcm2708_i2c.0");
152 + bcm2708_register_clkdev(clk, "bcm2708_i2c.1");
155 #define UART0_IRQ { IRQ_UART, 0 /*NO_IRQ*/ }
156 #define UART0_DMA { 15, 14 }
157 @@ -755,11 +744,7 @@ void __init bcm2708_init(void)
158 printk("bcm2708.uart_clock = %d\n", uart_clock);
159 pm_power_off = bcm2708_power_off;
162 - lookups[0].clk->rate = uart_clock;
164 - for (i = 0; i < ARRAY_SIZE(lookups); i++)
165 - clkdev_add(&lookups[i]);
166 + bcm2708_init_clocks();
168 bcm_register_device(&bcm2708_dmaman_device);
169 bcm_register_device(&bcm2708_vcio_device);
170 --- a/arch/arm/mach-bcm2708/clock.c
174 - * linux/arch/arm/mach-bcm2708/clock.c
176 - * Copyright (C) 2010 Broadcom
178 - * This program is free software; you can redistribute it and/or modify
179 - * it under the terms of the GNU General Public License as published by
180 - * the Free Software Foundation; either version 2 of the License, or
181 - * (at your option) any later version.
183 - * This program is distributed in the hope that it will be useful,
184 - * but WITHOUT ANY WARRANTY; without even the implied warranty of
185 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
186 - * GNU General Public License for more details.
188 - * You should have received a copy of the GNU General Public License
189 - * along with this program; if not, write to the Free Software
190 - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
192 -#include <linux/module.h>
193 -#include <linux/kernel.h>
194 -#include <linux/device.h>
195 -#include <linux/list.h>
196 -#include <linux/errno.h>
197 -#include <linux/err.h>
198 -#include <linux/string.h>
199 -#include <linux/clk.h>
200 -#include <linux/mutex.h>
202 -#include <asm/clkdev.h>
206 -int clk_enable(struct clk *clk)
210 -EXPORT_SYMBOL(clk_enable);
212 -void clk_disable(struct clk *clk)
215 -EXPORT_SYMBOL(clk_disable);
217 -unsigned long clk_get_rate(struct clk *clk)
221 -EXPORT_SYMBOL(clk_get_rate);
223 -long clk_round_rate(struct clk *clk, unsigned long rate)
227 -EXPORT_SYMBOL(clk_round_rate);
229 -int clk_set_rate(struct clk *clk, unsigned long rate)
233 -EXPORT_SYMBOL(clk_set_rate);
234 --- a/arch/arm/mach-bcm2708/clock.h
238 - * linux/arch/arm/mach-bcm2708/clock.h
240 - * Copyright (C) 2010 Broadcom
242 - * This program is free software; you can redistribute it and/or modify
243 - * it under the terms of the GNU General Public License as published by
244 - * the Free Software Foundation; either version 2 of the License, or
245 - * (at your option) any later version.
247 - * This program is distributed in the hope that it will be useful,
248 - * but WITHOUT ANY WARRANTY; without even the implied warranty of
249 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
250 - * GNU General Public License for more details.
252 - * You should have received a copy of the GNU General Public License
253 - * along with this program; if not, write to the Free Software
254 - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
259 - unsigned long rate;