Skip to content

Commit beabc66

Browse files
committed
Merge pull request #630 from notro/clock
Migrate to the Common Clock Framework
2 parents e09d010 + 44b50f3 commit beabc66

File tree

6 files changed

+37
-137
lines changed

6 files changed

+37
-137
lines changed

arch/arm/Kconfig

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -388,11 +388,10 @@ config ARCH_BCM2708
388388
bool "Broadcom BCM2708 family"
389389
select CPU_V6
390390
select ARM_AMBA
391-
select HAVE_CLK
392391
select HAVE_SCHED_CLOCK
393392
select NEED_MACH_GPIO_H
394393
select NEED_MACH_MEMORY_H
395-
select CLKDEV_LOOKUP
394+
select COMMON_CLK
396395
select ARCH_HAS_CPUFREQ
397396
select GENERIC_CLOCKEVENTS
398397
select ARM_ERRATA_411920

arch/arm/mach-bcm2708/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@
22
# Makefile for the linux kernel.
33
#
44

5-
obj-$(CONFIG_MACH_BCM2708) += clock.o bcm2708.o armctrl.o vcio.o power.o dma.o
5+
obj-$(CONFIG_MACH_BCM2708) += bcm2708.o armctrl.o vcio.o power.o dma.o
66
obj-$(CONFIG_BCM2708_GPIO) += bcm2708_gpio.o
77
obj-$(CONFIG_BCM2708_VCMEM) += vc_mem.o

arch/arm/mach-bcm2708/bcm2708.c

Lines changed: 32 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@
2727
#include <linux/interrupt.h>
2828
#include <linux/amba/bus.h>
2929
#include <linux/amba/clcd.h>
30+
#include <linux/clk-provider.h>
31+
#include <linux/clkdev.h>
3032
#include <linux/clockchips.h>
3133
#include <linux/cnt32_to_63.h>
3234
#include <linux/io.h>
@@ -58,7 +60,6 @@
5860

5961
#include "bcm2708.h"
6062
#include "armctrl.h"
61-
#include "clock.h"
6263

6364
#ifdef CONFIG_BCM_VC_CMA
6465
#include <linux/broadcom/vc_cma.h>
@@ -84,7 +85,7 @@
8485

8586
/* command line parameters */
8687
static unsigned boardrev, serial;
87-
static unsigned uart_clock;
88+
static unsigned uart_clock = UART0_CLOCK;
8889
static unsigned disk_led_gpio = 16;
8990
static unsigned disk_led_active_low = 1;
9091
static unsigned reboot_part = 0;
@@ -196,51 +197,39 @@ static void __init bcm2708_clocksource_init(void)
196197
}
197198
}
198199

200+
struct clk __init *bcm2708_clk_register(const char *name, unsigned long fixed_rate)
201+
{
202+
struct clk *clk;
199203

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);
206208

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+
}
214211

215-
/* warning - the USB needs a clock > 34MHz */
212+
void __init bcm2708_register_clkdev(struct clk *clk, const char *name)
213+
{
214+
int ret;
216215

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+
}
224220

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+
clk = bcm2708_clk_register("sdhost_clk", 250000000);
229+
bcm2708_register_clkdev(clk, "bcm2708_spi.0");
230+
bcm2708_register_clkdev(clk, "bcm2708_i2c.0");
231+
bcm2708_register_clkdev(clk, "bcm2708_i2c.1");
232+
}
244233

245234
#define UART0_IRQ { IRQ_UART, 0 /*NO_IRQ*/ }
246235
#define UART0_DMA { 15, 14 }
@@ -783,11 +772,7 @@ void __init bcm2708_init(void)
783772
printk("bcm2708.uart_clock = %d\n", uart_clock);
784773
pm_power_off = bcm2708_power_off;
785774

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]);
775+
bcm2708_init_clocks();
791776

792777
bcm_register_device(&bcm2708_dmaman_device);
793778
bcm_register_device(&bcm2708_vcio_device);

arch/arm/mach-bcm2708/clock.c

Lines changed: 0 additions & 61 deletions
This file was deleted.

arch/arm/mach-bcm2708/clock.h

Lines changed: 0 additions & 24 deletions
This file was deleted.

drivers/spi/spi-bcm2708.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -545,7 +545,7 @@ static int bcm2708_spi_probe(struct platform_device *pdev)
545545
}
546546

547547
/* initialise the hardware */
548-
clk_enable(clk);
548+
clk_prepare_enable(clk);
549549
bcm2708_wr(bs, SPI_CS, SPI_CS_REN | SPI_CS_CLEAR_RX | SPI_CS_CLEAR_TX);
550550

551551
err = spi_register_master(master);
@@ -561,6 +561,7 @@ static int bcm2708_spi_probe(struct platform_device *pdev)
561561

562562
out_free_irq:
563563
free_irq(bs->irq, master);
564+
clk_disable_unprepare(bs->clk);
564565
out_workqueue:
565566
destroy_workqueue(bs->workq);
566567
out_iounmap:
@@ -585,7 +586,7 @@ static int bcm2708_spi_remove(struct platform_device *pdev)
585586

586587
flush_work_sync(&bs->work);
587588

588-
clk_disable(bs->clk);
589+
clk_disable_unprepare(bs->clk);
589590
clk_put(bs->clk);
590591
free_irq(bs->irq, master);
591592
iounmap(bs->base);

0 commit comments

Comments
 (0)