From mboxrd@z Thu Jan 1 00:00:00 1970 From: dmitry_eremin@mentor.com (Dmitry Eremin-Solenikov) Date: Fri, 1 Nov 2013 14:52:11 +0400 Subject: [PATCH 4/4] ARM: sa1100: switch to COMMON_CLK framework In-Reply-To: <1383303131-29550-1-git-send-email-dmitry_eremin@mentor.com> References: <1383303131-29550-1-git-send-email-dmitry_eremin@mentor.com> Message-ID: <1383303131-29550-4-git-send-email-dmitry_eremin@mentor.com> To: linux-arm-kernel@lists.infradead.org List-Id: linux-arm-kernel.lists.infradead.org Implement common clock framework support for SA-1100. Signed-off-by: Dmitry Eremin-Solenikov --- arch/arm/Kconfig | 2 +- arch/arm/mach-sa1100/clock.c | 100 ---------------------------------- arch/arm/mach-sa1100/generic.c | 2 + drivers/clk/Makefile | 1 + drivers/clk/clk-sa1100.c | 121 +++++++++++++++++++++++++++++++++++++++++ include/linux/clk/sa1100.h | 14 +++++ 6 files changed, 139 insertions(+), 101 deletions(-) delete mode 100644 arch/arm/mach-sa1100/clock.c create mode 100644 drivers/clk/clk-sa1100.c create mode 100644 include/linux/clk/sa1100.h diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig index 5c86d8a..b28e518 100644 --- a/arch/arm/Kconfig +++ b/arch/arm/Kconfig @@ -686,8 +686,8 @@ config ARCH_SA1100 select ARCH_MTD_XIP select ARCH_REQUIRE_GPIOLIB select ARCH_SPARSEMEM_ENABLE - select CLKDEV_LOOKUP select CLKSRC_MMIO + select COMMON_CLK select CPU_FREQ select CPU_SA1100 select GENERIC_CLOCKEVENTS diff --git a/arch/arm/mach-sa1100/clock.c b/arch/arm/mach-sa1100/clock.c deleted file mode 100644 index 172ebd0..0000000 --- a/arch/arm/mach-sa1100/clock.c +++ /dev/null @@ -1,100 +0,0 @@ -/* - * linux/arch/arm/mach-sa1100/clock.c - */ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -struct clkops { - void (*enable)(struct clk *); - void (*disable)(struct clk *); -}; - -struct clk { - const struct clkops *ops; - unsigned int enabled; -}; - -#define DEFINE_CLK(_name, _ops) \ -struct clk clk_##_name = { \ - .ops = _ops, \ - } - -static DEFINE_SPINLOCK(clocks_lock); - -static void clk_gpio27_enable(struct clk *clk) -{ - /* - * First, set up the 3.6864MHz clock on GPIO 27 for the SA-1111: - * (SA-1110 Developer's Manual, section 9.1.2.1) - */ - GAFR |= GPIO_32_768kHz; - GPDR |= GPIO_32_768kHz; - TUCR = TUCR_3_6864MHz; -} - -static void clk_gpio27_disable(struct clk *clk) -{ - TUCR = 0; - GPDR &= ~GPIO_32_768kHz; - GAFR &= ~GPIO_32_768kHz; -} - -int clk_enable(struct clk *clk) -{ - unsigned long flags; - - if (clk) { - spin_lock_irqsave(&clocks_lock, flags); - if (clk->enabled++ == 0) - clk->ops->enable(clk); - spin_unlock_irqrestore(&clocks_lock, flags); - } - - return 0; -} -EXPORT_SYMBOL(clk_enable); - -void clk_disable(struct clk *clk) -{ - unsigned long flags; - - if (clk) { - WARN_ON(clk->enabled == 0); - spin_lock_irqsave(&clocks_lock, flags); - if (--clk->enabled == 0) - clk->ops->disable(clk); - spin_unlock_irqrestore(&clocks_lock, flags); - } -} -EXPORT_SYMBOL(clk_disable); - -const struct clkops clk_gpio27_ops = { - .enable = clk_gpio27_enable, - .disable = clk_gpio27_disable, -}; - -static DEFINE_CLK(gpio27, &clk_gpio27_ops); - -static struct clk_lookup sa11xx_clkregs[] = { - CLKDEV_INIT("sa1111.0", NULL, &clk_gpio27), - CLKDEV_INIT("sa1100-rtc", NULL, NULL), -}; - -static int __init sa11xx_clk_init(void) -{ - clkdev_add_table(sa11xx_clkregs, ARRAY_SIZE(sa11xx_clkregs)); - return 0; -} -core_initcall(sa11xx_clk_init); diff --git a/arch/arm/mach-sa1100/generic.c b/arch/arm/mach-sa1100/generic.c index d4ea142..f35dd06 100644 --- a/arch/arm/mach-sa1100/generic.c +++ b/arch/arm/mach-sa1100/generic.c @@ -20,6 +20,7 @@ #include #include #include +#include #include