|
27 | 27 | #include <linux/interrupt.h>
|
28 | 28 | #include <linux/amba/bus.h>
|
29 | 29 | #include <linux/amba/clcd.h>
|
| 30 | +#include <linux/clk-provider.h> |
| 31 | +#include <linux/clkdev.h> |
30 | 32 | #include <linux/clockchips.h>
|
31 | 33 | #include <linux/cnt32_to_63.h>
|
32 | 34 | #include <linux/io.h>
|
|
58 | 60 |
|
59 | 61 | #include "bcm2708.h"
|
60 | 62 | #include "armctrl.h"
|
61 |
| -#include "clock.h" |
62 | 63 |
|
63 | 64 | #ifdef CONFIG_BCM_VC_CMA
|
64 | 65 | #include <linux/broadcom/vc_cma.h>
|
|
84 | 85 |
|
85 | 86 | /* command line parameters */
|
86 | 87 | static unsigned boardrev, serial;
|
87 |
| -static unsigned uart_clock; |
| 88 | +static unsigned uart_clock = UART0_CLOCK; |
88 | 89 | static unsigned disk_led_gpio = 16;
|
89 | 90 | static unsigned disk_led_active_low = 1;
|
90 | 91 | static unsigned reboot_part = 0;
|
@@ -196,51 +197,44 @@ static void __init bcm2708_clocksource_init(void)
|
196 | 197 | }
|
197 | 198 | }
|
198 | 199 |
|
| 200 | +struct clk __init *bcm2708_clk_register(const char *name, unsigned long fixed_rate) |
| 201 | +{ |
| 202 | + struct clk *clk; |
199 | 203 |
|
200 |
| -/* |
201 |
| - * These are fixed clocks. |
202 |
| - */ |
203 |
| -static struct clk ref24_clk = { |
204 |
| - .rate = UART0_CLOCK, /* The UART is clocked at 3MHz via APB_CLK */ |
205 |
| -}; |
| 204 | + clk = clk_register_fixed_rate(NULL, name, NULL, CLK_IS_ROOT, |
| 205 | + fixed_rate); |
| 206 | + if (IS_ERR(clk)) |
| 207 | + pr_err("%s not registered\n", name); |
206 | 208 |
|
207 |
| -static struct clk osc_clk = { |
208 |
| -#ifdef CONFIG_ARCH_BCM2708_CHIPIT |
209 |
| - .rate = 27000000, |
210 |
| -#else |
211 |
| - .rate = 500000000, /* ARM clock is set from the VideoCore booter */ |
212 |
| -#endif |
213 |
| -}; |
| 209 | + return clk; |
| 210 | +} |
214 | 211 |
|
215 |
| -/* warning - the USB needs a clock > 34MHz */ |
| 212 | +void __init bcm2708_register_clkdev(struct clk *clk, const char *name) |
| 213 | +{ |
| 214 | + int ret; |
216 | 215 |
|
217 |
| -static struct clk sdhost_clk = { |
218 |
| -#ifdef CONFIG_ARCH_BCM2708_CHIPIT |
219 |
| - .rate = 4000000, /* 4MHz */ |
220 |
| -#else |
221 |
| - .rate = 250000000, /* 250MHz */ |
222 |
| -#endif |
223 |
| -}; |
| 216 | + ret = clk_register_clkdev(clk, NULL, name); |
| 217 | + if (ret) |
| 218 | + pr_err("%s alias not registered\n", name); |
| 219 | +} |
224 | 220 |
|
225 |
| -static struct clk_lookup lookups[] = { |
226 |
| - { /* UART0 */ |
227 |
| - .dev_id = "dev:f1", |
228 |
| - .clk = &ref24_clk, |
229 |
| - }, |
230 |
| - { /* USB */ |
231 |
| - .dev_id = "bcm2708_usb", |
232 |
| - .clk = &osc_clk, |
233 |
| - }, { /* SPI */ |
234 |
| - .dev_id = "bcm2708_spi.0", |
235 |
| - .clk = &sdhost_clk, |
236 |
| - }, { /* BSC0 */ |
237 |
| - .dev_id = "bcm2708_i2c.0", |
238 |
| - .clk = &sdhost_clk, |
239 |
| - }, { /* BSC1 */ |
240 |
| - .dev_id = "bcm2708_i2c.1", |
241 |
| - .clk = &sdhost_clk, |
242 |
| - } |
243 |
| -}; |
| 221 | +void __init bcm2708_init_clocks(void) |
| 222 | +{ |
| 223 | + struct clk *clk; |
| 224 | + |
| 225 | + clk = bcm2708_clk_register("uart0_clk", uart_clock); |
| 226 | + bcm2708_register_clkdev(clk, "dev:f1"); |
| 227 | + |
| 228 | + /* ARM clock is set from the VideoCore booter */ |
| 229 | + /* warning - the USB needs a clock > 34MHz */ |
| 230 | + clk = bcm2708_clk_register("osc_clk", 500000000); |
| 231 | + bcm2708_register_clkdev(clk, "bcm2708_usb"); |
| 232 | + |
| 233 | + clk = bcm2708_clk_register("sdhost_clk", 250000000); |
| 234 | + bcm2708_register_clkdev(clk, "bcm2708_spi.0"); |
| 235 | + bcm2708_register_clkdev(clk, "bcm2708_i2c.0"); |
| 236 | + bcm2708_register_clkdev(clk, "bcm2708_i2c.1"); |
| 237 | +} |
244 | 238 |
|
245 | 239 | #define UART0_IRQ { IRQ_UART, 0 /*NO_IRQ*/ }
|
246 | 240 | #define UART0_DMA { 15, 14 }
|
@@ -783,11 +777,7 @@ void __init bcm2708_init(void)
|
783 | 777 | printk("bcm2708.uart_clock = %d\n", uart_clock);
|
784 | 778 | pm_power_off = bcm2708_power_off;
|
785 | 779 |
|
786 |
| - if (uart_clock) |
787 |
| - lookups[0].clk->rate = uart_clock; |
788 |
| - |
789 |
| - for (i = 0; i < ARRAY_SIZE(lookups); i++) |
790 |
| - clkdev_add(&lookups[i]); |
| 780 | + bcm2708_init_clocks(); |
791 | 781 |
|
792 | 782 | bcm_register_device(&bcm2708_dmaman_device);
|
793 | 783 | bcm_register_device(&bcm2708_vcio_device);
|
|
0 commit comments