From 466743ec93a99240c1a5a04d65f490fd8370fbc3 Mon Sep 17 00:00:00 2001 From: notro Date: Sun, 6 Jul 2014 12:09:30 +0200 Subject: [PATCH 048/114] BCM2708: Migrate to the Common Clock Framework As part of moving towards using Device Tree, the Common Clock Framework has to be used instead of the BCM2708 clock implementation. Selecting COMMON_CLK removes the need to set CLKDEV_LOOKUP and HAVE_CLK explicitly. CONFIG_ARCH_BCM2708_CHIPIT #ifdef's are removed. They are no longer in use. Signed-off-by: Noralf Tronnes --- arch/arm/Kconfig | 3 +- arch/arm/mach-bcm2708/Makefile | 2 +- arch/arm/mach-bcm2708/bcm2708.c | 79 +++++++++++++++++------------------------ arch/arm/mach-bcm2708/clock.c | 61 ------------------------------- arch/arm/mach-bcm2708/clock.h | 24 ------------- 5 files changed, 34 insertions(+), 135 deletions(-) delete mode 100644 arch/arm/mach-bcm2708/clock.c delete mode 100644 arch/arm/mach-bcm2708/clock.h diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig index ba9c18e..0f2287f 100644 --- a/arch/arm/Kconfig +++ b/arch/arm/Kconfig @@ -385,11 +385,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 diff --git a/arch/arm/mach-bcm2708/Makefile b/arch/arm/mach-bcm2708/Makefile index a722f3f..21e3521 100644 --- a/arch/arm/mach-bcm2708/Makefile +++ b/arch/arm/mach-bcm2708/Makefile @@ -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 diff --git a/arch/arm/mach-bcm2708/bcm2708.c b/arch/arm/mach-bcm2708/bcm2708.c index 633be19..ef12cb8 100644 --- a/arch/arm/mach-bcm2708/bcm2708.c +++ b/arch/arm/mach-bcm2708/bcm2708.c @@ -27,6 +27,8 @@ #include #include #include +#include +#include #include #include #include @@ -58,7 +60,6 @@ #include "bcm2708.h" #include "armctrl.h" -#include "clock.h" #ifdef CONFIG_BCM_VC_CMA #include @@ -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; @@ -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 } @@ -755,11 +744,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); diff --git a/arch/arm/mach-bcm2708/clock.c b/arch/arm/mach-bcm2708/clock.c deleted file mode 100644 index 4fc556e..0000000 --- a/arch/arm/mach-bcm2708/clock.c +++ /dev/null @@ -1,61 +0,0 @@ -/* - * linux/arch/arm/mach-bcm2708/clock.c - * - * Copyright (C) 2010 Broadcom - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -#include "clock.h" - -int clk_enable(struct clk *clk) -{ - return 0; -} -EXPORT_SYMBOL(clk_enable); - -void clk_disable(struct clk *clk) -{ -} -EXPORT_SYMBOL(clk_disable); - -unsigned long clk_get_rate(struct clk *clk) -{ - return clk->rate; -} -EXPORT_SYMBOL(clk_get_rate); - -long clk_round_rate(struct clk *clk, unsigned long rate) -{ - return clk->rate; -} -EXPORT_SYMBOL(clk_round_rate); - -int clk_set_rate(struct clk *clk, unsigned long rate) -{ - return -EIO; -} -EXPORT_SYMBOL(clk_set_rate); diff --git a/arch/arm/mach-bcm2708/clock.h b/arch/arm/mach-bcm2708/clock.h deleted file mode 100644 index 5f9d725..0000000 --- a/arch/arm/mach-bcm2708/clock.h +++ /dev/null @@ -1,24 +0,0 @@ -/* - * linux/arch/arm/mach-bcm2708/clock.h - * - * Copyright (C) 2010 Broadcom - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ -struct module; - -struct clk { - unsigned long rate; -}; -- 1.8.3.2