Skip to content

Migrate to the Common Clock Framework #630

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jul 8, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions arch/arm/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -388,11 +388,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
Expand Down
2 changes: 1 addition & 1 deletion arch/arm/mach-bcm2708/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
79 changes: 32 additions & 47 deletions arch/arm/mach-bcm2708/bcm2708.c
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down Expand Up @@ -58,7 +60,6 @@

#include "bcm2708.h"
#include "armctrl.h"
#include "clock.h"

#ifdef CONFIG_BCM_VC_CMA
#include <linux/broadcom/vc_cma.h>
Expand All @@ -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;
Expand Down Expand Up @@ -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 }
Expand Down Expand Up @@ -783,11 +772,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);
Expand Down
61 changes: 0 additions & 61 deletions arch/arm/mach-bcm2708/clock.c

This file was deleted.

24 changes: 0 additions & 24 deletions arch/arm/mach-bcm2708/clock.h

This file was deleted.

5 changes: 3 additions & 2 deletions drivers/spi/spi-bcm2708.c
Original file line number Diff line number Diff line change
Expand Up @@ -545,7 +545,7 @@ static int bcm2708_spi_probe(struct platform_device *pdev)
}

/* initialise the hardware */
clk_enable(clk);
clk_prepare_enable(clk);
bcm2708_wr(bs, SPI_CS, SPI_CS_REN | SPI_CS_CLEAR_RX | SPI_CS_CLEAR_TX);

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

out_free_irq:
free_irq(bs->irq, master);
clk_disable_unprepare(bs->clk);
out_workqueue:
destroy_workqueue(bs->workq);
out_iounmap:
Expand All @@ -585,7 +586,7 @@ static int bcm2708_spi_remove(struct platform_device *pdev)

flush_work_sync(&bs->work);

clk_disable(bs->clk);
clk_disable_unprepare(bs->clk);
clk_put(bs->clk);
free_irq(bs->irq, master);
iounmap(bs->base);
Expand Down