Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

ARM: 6483/1: arm & sh: factorised duplicated clkdev.c

factorise some generic infrastructure to assist looking up struct clks
for the ARM & SH architecture.

as the code is identical at 99%

put the arch specific code for allocation as example in asm/clkdev.h

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
Acked-by: Paul Mundt <lethal@linux-sh.org>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>

authored by

Jean-Christop PLAGNIOL-VILLARD and committed by
Russell King
6d803ba7 64d2dc38

+176 -355
+21 -21
arch/arm/Kconfig
··· 221 221 bool "ARM Ltd. Integrator family" 222 222 select ARM_AMBA 223 223 select ARCH_HAS_CPUFREQ 224 - select COMMON_CLKDEV 224 + select CLKDEV_LOOKUP 225 225 select ICST 226 226 select GENERIC_CLOCKEVENTS 227 227 select PLAT_VERSATILE ··· 231 231 config ARCH_REALVIEW 232 232 bool "ARM Ltd. RealView family" 233 233 select ARM_AMBA 234 - select COMMON_CLKDEV 234 + select CLKDEV_LOOKUP 235 235 select ICST 236 236 select GENERIC_CLOCKEVENTS 237 237 select ARCH_WANT_OPTIONAL_GPIOLIB ··· 245 245 bool "ARM Ltd. Versatile family" 246 246 select ARM_AMBA 247 247 select ARM_VIC 248 - select COMMON_CLKDEV 248 + select CLKDEV_LOOKUP 249 249 select ICST 250 250 select GENERIC_CLOCKEVENTS 251 251 select ARCH_WANT_OPTIONAL_GPIOLIB ··· 259 259 select ARCH_WANT_OPTIONAL_GPIOLIB 260 260 select ARM_AMBA 261 261 select ARM_TIMER_SP804 262 - select COMMON_CLKDEV 262 + select CLKDEV_LOOKUP 263 263 select GENERIC_CLOCKEVENTS 264 264 select HAVE_CLK 265 265 select ICST ··· 280 280 depends on MMU 281 281 select CPU_V6 282 282 select ARM_AMBA 283 - select COMMON_CLKDEV 283 + select CLKDEV_LOOKUP 284 284 select GENERIC_CLOCKEVENTS 285 285 select ARCH_WANT_OPTIONAL_GPIOLIB 286 286 help ··· 327 327 select CPU_ARM920T 328 328 select ARM_AMBA 329 329 select ARM_VIC 330 - select COMMON_CLKDEV 330 + select CLKDEV_LOOKUP 331 331 select ARCH_REQUIRE_GPIOLIB 332 332 select ARCH_HAS_HOLES_MEMORYMODEL 333 333 select ARCH_USES_GETTIMEOFFSET ··· 347 347 bool "Freescale MXC/iMX-based" 348 348 select GENERIC_CLOCKEVENTS 349 349 select ARCH_REQUIRE_GPIOLIB 350 - select COMMON_CLKDEV 350 + select CLKDEV_LOOKUP 351 351 help 352 352 Support for Freescale MXC/iMX-based family of processors 353 353 354 354 config ARCH_STMP3XXX 355 355 bool "Freescale STMP3xxx" 356 356 select CPU_ARM926T 357 - select COMMON_CLKDEV 357 + select CLKDEV_LOOKUP 358 358 select ARCH_REQUIRE_GPIOLIB 359 359 select GENERIC_CLOCKEVENTS 360 360 select USB_ARCH_HAS_EHCI ··· 472 472 select HAVE_IDE 473 473 select ARM_AMBA 474 474 select USB_ARCH_HAS_OHCI 475 - select COMMON_CLKDEV 475 + select CLKDEV_LOOKUP 476 476 select GENERIC_TIME 477 477 select GENERIC_CLOCKEVENTS 478 478 help ··· 506 506 bool "Marvell PXA168/910/MMP2" 507 507 depends on MMU 508 508 select ARCH_REQUIRE_GPIOLIB 509 - select COMMON_CLKDEV 509 + select CLKDEV_LOOKUP 510 510 select GENERIC_CLOCKEVENTS 511 511 select TICK_ONESHOT 512 512 select PLAT_PXA ··· 539 539 bool "Nuvoton W90X900 CPU" 540 540 select CPU_ARM926T 541 541 select ARCH_REQUIRE_GPIOLIB 542 - select COMMON_CLKDEV 542 + select CLKDEV_LOOKUP 543 543 select GENERIC_CLOCKEVENTS 544 544 help 545 545 Support for Nuvoton (Winbond logic dept.) ARM9 processor, ··· 553 553 config ARCH_NUC93X 554 554 bool "Nuvoton NUC93X CPU" 555 555 select CPU_ARM926T 556 - select COMMON_CLKDEV 556 + select CLKDEV_LOOKUP 557 557 help 558 558 Support for Nuvoton (Winbond logic dept.) NUC93X MCU,The NUC93X is a 559 559 low-power and high performance MPEG-4/JPEG multimedia controller chip. ··· 564 564 select GENERIC_CLOCKEVENTS 565 565 select GENERIC_GPIO 566 566 select HAVE_CLK 567 - select COMMON_CLKDEV 567 + select CLKDEV_LOOKUP 568 568 select ARCH_HAS_BARRIERS if CACHE_L2X0 569 569 select ARCH_HAS_CPUFREQ 570 570 help ··· 574 574 config ARCH_PNX4008 575 575 bool "Philips Nexperia PNX4008 Mobile" 576 576 select CPU_ARM926T 577 - select COMMON_CLKDEV 577 + select CLKDEV_LOOKUP 578 578 select ARCH_USES_GETTIMEOFFSET 579 579 help 580 580 This enables support for Philips PNX4008 mobile platform. ··· 584 584 depends on MMU 585 585 select ARCH_MTD_XIP 586 586 select ARCH_HAS_CPUFREQ 587 - select COMMON_CLKDEV 587 + select CLKDEV_LOOKUP 588 588 select ARCH_REQUIRE_GPIOLIB 589 589 select GENERIC_CLOCKEVENTS 590 590 select TICK_ONESHOT ··· 761 761 bool "Telechips TCC ARM926-based systems" 762 762 select CPU_ARM926T 763 763 select HAVE_CLK 764 - select COMMON_CLKDEV 764 + select CLKDEV_LOOKUP 765 765 select GENERIC_CLOCKEVENTS 766 766 help 767 767 Support for Telechips TCC ARM926-based systems. ··· 785 785 select ARM_AMBA 786 786 select ARM_VIC 787 787 select GENERIC_CLOCKEVENTS 788 - select COMMON_CLKDEV 788 + select CLKDEV_LOOKUP 789 789 select GENERIC_GPIO 790 790 help 791 791 Support for ST-Ericsson U300 series mobile platforms. ··· 795 795 select CPU_V7 796 796 select ARM_AMBA 797 797 select GENERIC_CLOCKEVENTS 798 - select COMMON_CLKDEV 798 + select CLKDEV_LOOKUP 799 799 select ARCH_REQUIRE_GPIOLIB 800 800 help 801 801 Support for ST-Ericsson's Ux500 architecture ··· 805 805 select ARM_AMBA 806 806 select ARM_VIC 807 807 select CPU_ARM926T 808 - select COMMON_CLKDEV 808 + select CLKDEV_LOOKUP 809 809 select GENERIC_CLOCKEVENTS 810 810 select ARCH_REQUIRE_GPIOLIB 811 811 help ··· 817 817 select ARCH_REQUIRE_GPIOLIB 818 818 select ZONE_DMA 819 819 select HAVE_IDE 820 - select COMMON_CLKDEV 820 + select CLKDEV_LOOKUP 821 821 select GENERIC_ALLOCATOR 822 822 select ARCH_HAS_HOLES_MEMORYMODEL 823 823 help ··· 837 837 bool "ST SPEAr" 838 838 select ARM_AMBA 839 839 select ARCH_REQUIRE_GPIOLIB 840 - select COMMON_CLKDEV 840 + select CLKDEV_LOOKUP 841 841 select GENERIC_CLOCKEVENTS 842 842 select HAVE_CLK 843 843 help
-4
arch/arm/common/Kconfig
··· 37 37 38 38 config SHARP_SCOOP 39 39 bool 40 - 41 - config COMMON_CLKDEV 42 - bool 43 - select HAVE_CLK
-1
arch/arm/common/Makefile
··· 16 16 obj-$(CONFIG_ARCH_IXP2000) += uengine.o 17 17 obj-$(CONFIG_ARCH_IXP23XX) += uengine.o 18 18 obj-$(CONFIG_PCI_HOST_ITE8152) += it8152.o 19 - obj-$(CONFIG_COMMON_CLKDEV) += clkdev.o
-179
arch/arm/common/clkdev.c
··· 1 - /* 2 - * arch/arm/common/clkdev.c 3 - * 4 - * Copyright (C) 2008 Russell King. 5 - * 6 - * This program is free software; you can redistribute it and/or modify 7 - * it under the terms of the GNU General Public License version 2 as 8 - * published by the Free Software Foundation. 9 - * 10 - * Helper for the clk API to assist looking up a struct clk. 11 - */ 12 - #include <linux/module.h> 13 - #include <linux/kernel.h> 14 - #include <linux/device.h> 15 - #include <linux/list.h> 16 - #include <linux/errno.h> 17 - #include <linux/err.h> 18 - #include <linux/string.h> 19 - #include <linux/mutex.h> 20 - #include <linux/clk.h> 21 - #include <linux/slab.h> 22 - 23 - #include <asm/clkdev.h> 24 - #include <mach/clkdev.h> 25 - 26 - static LIST_HEAD(clocks); 27 - static DEFINE_MUTEX(clocks_mutex); 28 - 29 - /* 30 - * Find the correct struct clk for the device and connection ID. 31 - * We do slightly fuzzy matching here: 32 - * An entry with a NULL ID is assumed to be a wildcard. 33 - * If an entry has a device ID, it must match 34 - * If an entry has a connection ID, it must match 35 - * Then we take the most specific entry - with the following 36 - * order of precedence: dev+con > dev only > con only. 37 - */ 38 - static struct clk *clk_find(const char *dev_id, const char *con_id) 39 - { 40 - struct clk_lookup *p; 41 - struct clk *clk = NULL; 42 - int match, best = 0; 43 - 44 - list_for_each_entry(p, &clocks, node) { 45 - match = 0; 46 - if (p->dev_id) { 47 - if (!dev_id || strcmp(p->dev_id, dev_id)) 48 - continue; 49 - match += 2; 50 - } 51 - if (p->con_id) { 52 - if (!con_id || strcmp(p->con_id, con_id)) 53 - continue; 54 - match += 1; 55 - } 56 - 57 - if (match > best) { 58 - clk = p->clk; 59 - if (match != 3) 60 - best = match; 61 - else 62 - break; 63 - } 64 - } 65 - return clk; 66 - } 67 - 68 - struct clk *clk_get_sys(const char *dev_id, const char *con_id) 69 - { 70 - struct clk *clk; 71 - 72 - mutex_lock(&clocks_mutex); 73 - clk = clk_find(dev_id, con_id); 74 - if (clk && !__clk_get(clk)) 75 - clk = NULL; 76 - mutex_unlock(&clocks_mutex); 77 - 78 - return clk ? clk : ERR_PTR(-ENOENT); 79 - } 80 - EXPORT_SYMBOL(clk_get_sys); 81 - 82 - struct clk *clk_get(struct device *dev, const char *con_id) 83 - { 84 - const char *dev_id = dev ? dev_name(dev) : NULL; 85 - 86 - return clk_get_sys(dev_id, con_id); 87 - } 88 - EXPORT_SYMBOL(clk_get); 89 - 90 - void clk_put(struct clk *clk) 91 - { 92 - __clk_put(clk); 93 - } 94 - EXPORT_SYMBOL(clk_put); 95 - 96 - void clkdev_add(struct clk_lookup *cl) 97 - { 98 - mutex_lock(&clocks_mutex); 99 - list_add_tail(&cl->node, &clocks); 100 - mutex_unlock(&clocks_mutex); 101 - } 102 - EXPORT_SYMBOL(clkdev_add); 103 - 104 - void __init clkdev_add_table(struct clk_lookup *cl, size_t num) 105 - { 106 - mutex_lock(&clocks_mutex); 107 - while (num--) { 108 - list_add_tail(&cl->node, &clocks); 109 - cl++; 110 - } 111 - mutex_unlock(&clocks_mutex); 112 - } 113 - 114 - #define MAX_DEV_ID 20 115 - #define MAX_CON_ID 16 116 - 117 - struct clk_lookup_alloc { 118 - struct clk_lookup cl; 119 - char dev_id[MAX_DEV_ID]; 120 - char con_id[MAX_CON_ID]; 121 - }; 122 - 123 - struct clk_lookup *clkdev_alloc(struct clk *clk, const char *con_id, 124 - const char *dev_fmt, ...) 125 - { 126 - struct clk_lookup_alloc *cla; 127 - 128 - cla = kzalloc(sizeof(*cla), GFP_KERNEL); 129 - if (!cla) 130 - return NULL; 131 - 132 - cla->cl.clk = clk; 133 - if (con_id) { 134 - strlcpy(cla->con_id, con_id, sizeof(cla->con_id)); 135 - cla->cl.con_id = cla->con_id; 136 - } 137 - 138 - if (dev_fmt) { 139 - va_list ap; 140 - 141 - va_start(ap, dev_fmt); 142 - vscnprintf(cla->dev_id, sizeof(cla->dev_id), dev_fmt, ap); 143 - cla->cl.dev_id = cla->dev_id; 144 - va_end(ap); 145 - } 146 - 147 - return &cla->cl; 148 - } 149 - EXPORT_SYMBOL(clkdev_alloc); 150 - 151 - int clk_add_alias(const char *alias, const char *alias_dev_name, char *id, 152 - struct device *dev) 153 - { 154 - struct clk *r = clk_get(dev, id); 155 - struct clk_lookup *l; 156 - 157 - if (IS_ERR(r)) 158 - return PTR_ERR(r); 159 - 160 - l = clkdev_alloc(r, alias, alias_dev_name); 161 - clk_put(r); 162 - if (!l) 163 - return -ENODEV; 164 - clkdev_add(l); 165 - return 0; 166 - } 167 - EXPORT_SYMBOL(clk_add_alias); 168 - 169 - /* 170 - * clkdev_drop - remove a clock dynamically allocated 171 - */ 172 - void clkdev_drop(struct clk_lookup *cl) 173 - { 174 - mutex_lock(&clocks_mutex); 175 - list_del(&cl->node); 176 - mutex_unlock(&clocks_mutex); 177 - kfree(cl); 178 - } 179 - EXPORT_SYMBOL(clkdev_drop);
+6 -16
arch/arm/include/asm/clkdev.h
··· 12 12 #ifndef __ASM_CLKDEV_H 13 13 #define __ASM_CLKDEV_H 14 14 15 - struct clk; 16 - struct device; 15 + #include <linux/slab.h> 17 16 18 - struct clk_lookup { 19 - struct list_head node; 20 - const char *dev_id; 21 - const char *con_id; 22 - struct clk *clk; 23 - }; 17 + #include <mach/clkdev.h> 24 18 25 - struct clk_lookup *clkdev_alloc(struct clk *clk, const char *con_id, 26 - const char *dev_fmt, ...); 27 - 28 - void clkdev_add(struct clk_lookup *cl); 29 - void clkdev_drop(struct clk_lookup *cl); 30 - 31 - void clkdev_add_table(struct clk_lookup *, size_t); 32 - int clk_add_alias(const char *, const char *, char *, struct device *); 19 + static inline struct clk_lookup_alloc *__clkdev_alloc(size_t size) 20 + { 21 + return kzalloc(size, GFP_KERNEL); 22 + } 33 23 34 24 #endif
+1 -2
arch/arm/mach-bcmring/clock.c
··· 21 21 #include <linux/string.h> 22 22 #include <linux/clk.h> 23 23 #include <linux/spinlock.h> 24 + #include <linux/clkdev.h> 24 25 #include <mach/csp/hw_cfg.h> 25 26 #include <mach/csp/chipcHw_def.h> 26 27 #include <mach/csp/chipcHw_reg.h> 27 28 #include <mach/csp/chipcHw_inline.h> 28 - 29 - #include <asm/clkdev.h> 30 29 31 30 #include "clock.h" 32 31
+1 -1
arch/arm/mach-bcmring/core.c
··· 30 30 #include <linux/amba/bus.h> 31 31 #include <linux/clocksource.h> 32 32 #include <linux/clockchips.h> 33 + #include <linux/clkdev.h> 33 34 34 35 #include <mach/csp/mm_addr.h> 35 36 #include <mach/hardware.h> 36 - #include <asm/clkdev.h> 37 37 #include <linux/io.h> 38 38 #include <asm/irq.h> 39 39 #include <asm/hardware/arm_timer.h>
+1 -1
arch/arm/mach-davinci/clock.h
··· 68 68 #ifndef __ASSEMBLER__ 69 69 70 70 #include <linux/list.h> 71 - #include <asm/clkdev.h> 71 + #include <linux/clkdev.h> 72 72 73 73 #define PLLSTAT_GOSTAT BIT(0) 74 74 #define PLLCMD_GOSET BIT(0)
+1 -1
arch/arm/mach-ep93xx/clock.c
··· 19 19 #include <linux/string.h> 20 20 #include <linux/io.h> 21 21 #include <linux/spinlock.h> 22 + #include <linux/clkdev.h> 22 23 23 24 #include <mach/hardware.h> 24 25 25 - #include <asm/clkdev.h> 26 26 #include <asm/div64.h> 27 27 28 28
+1 -2
arch/arm/mach-imx/clock-imx1.c
··· 22 22 #include <linux/err.h> 23 23 #include <linux/clk.h> 24 24 #include <linux/io.h> 25 - 26 - #include <asm/clkdev.h> 25 + #include <linux/clkdev.h> 27 26 28 27 #include <mach/clock.h> 29 28 #include <mach/hardware.h>
+1 -1
arch/arm/mach-imx/clock-imx21.c
··· 21 21 #include <linux/clk.h> 22 22 #include <linux/io.h> 23 23 #include <linux/module.h> 24 + #include <linux/clkdev.h> 24 25 25 26 #include <mach/clock.h> 26 27 #include <mach/hardware.h> 27 28 #include <mach/common.h> 28 - #include <asm/clkdev.h> 29 29 #include <asm/div64.h> 30 30 31 31 #define IO_ADDR_CCM(off) (MX21_IO_ADDRESS(MX21_CCM_BASE_ADDR + (off)))
+1 -1
arch/arm/mach-imx/clock-imx27.c
··· 21 21 #include <linux/clk.h> 22 22 #include <linux/io.h> 23 23 #include <linux/module.h> 24 + #include <linux/clkdev.h> 24 25 25 - #include <asm/clkdev.h> 26 26 #include <asm/div64.h> 27 27 28 28 #include <mach/clock.h>
+1 -2
arch/arm/mach-integrator/core.c
··· 21 21 #include <linux/amba/bus.h> 22 22 #include <linux/amba/serial.h> 23 23 #include <linux/io.h> 24 + #include <linux/clkdev.h> 24 25 25 - #include <asm/clkdev.h> 26 - #include <mach/clkdev.h> 27 26 #include <mach/hardware.h> 28 27 #include <mach/platform.h> 29 28 #include <asm/irq.h>
+1 -2
arch/arm/mach-integrator/impd1.c
··· 22 22 #include <linux/amba/clcd.h> 23 23 #include <linux/io.h> 24 24 #include <linux/slab.h> 25 + #include <linux/clkdev.h> 25 26 26 - #include <asm/clkdev.h> 27 - #include <mach/clkdev.h> 28 27 #include <asm/hardware/icst.h> 29 28 #include <mach/lm.h> 30 29 #include <mach/impd1.h>
+1 -2
arch/arm/mach-integrator/integrator_cp.c
··· 21 21 #include <linux/amba/mmci.h> 22 22 #include <linux/io.h> 23 23 #include <linux/gfp.h> 24 + #include <linux/clkdev.h> 24 25 25 - #include <asm/clkdev.h> 26 - #include <mach/clkdev.h> 27 26 #include <mach/hardware.h> 28 27 #include <mach/platform.h> 29 28 #include <asm/irq.h>
+1 -2
arch/arm/mach-lpc32xx/clock.c
··· 90 90 #include <linux/clk.h> 91 91 #include <linux/amba/bus.h> 92 92 #include <linux/amba/clcd.h> 93 + #include <linux/clkdev.h> 93 94 94 95 #include <mach/hardware.h> 95 - #include <asm/clkdev.h> 96 - #include <mach/clkdev.h> 97 96 #include <mach/platform.h> 98 97 #include "clock.h" 99 98 #include "common.h"
+1 -1
arch/arm/mach-mmp/clock.h
··· 6 6 * published by the Free Software Foundation. 7 7 */ 8 8 9 - #include <asm/clkdev.h> 9 + #include <linux/clkdev.h> 10 10 11 11 struct clkops { 12 12 void (*enable)(struct clk *);
+1 -2
arch/arm/mach-mx25/clock.c
··· 21 21 #include <linux/list.h> 22 22 #include <linux/clk.h> 23 23 #include <linux/io.h> 24 - 25 - #include <asm/clkdev.h> 24 + #include <linux/clkdev.h> 26 25 27 26 #include <mach/clock.h> 28 27 #include <mach/hardware.h>
+1 -1
arch/arm/mach-mx3/clock-imx31.c
··· 23 23 #include <linux/clk.h> 24 24 #include <linux/err.h> 25 25 #include <linux/io.h> 26 + #include <linux/clkdev.h> 26 27 27 - #include <asm/clkdev.h> 28 28 #include <asm/div64.h> 29 29 30 30 #include <mach/clock.h>
+1 -2
arch/arm/mach-mx3/clock-imx35.c
··· 21 21 #include <linux/list.h> 22 22 #include <linux/clk.h> 23 23 #include <linux/io.h> 24 - 25 - #include <asm/clkdev.h> 24 + #include <linux/clkdev.h> 26 25 27 26 #include <mach/clock.h> 28 27 #include <mach/hardware.h>
+1 -1
arch/arm/mach-mx5/clock-mx51.c
··· 14 14 #include <linux/delay.h> 15 15 #include <linux/clk.h> 16 16 #include <linux/io.h> 17 + #include <linux/clkdev.h> 17 18 18 - #include <asm/clkdev.h> 19 19 #include <asm/div64.h> 20 20 21 21 #include <mach/hardware.h>
+1 -1
arch/arm/mach-mxc91231/clock.c
··· 2 2 #include <linux/kernel.h> 3 3 #include <linux/init.h> 4 4 #include <linux/io.h> 5 + #include <linux/clkdev.h> 5 6 6 7 #include <mach/clock.h> 7 8 #include <mach/hardware.h> 8 9 #include <mach/common.h> 9 10 10 - #include <asm/clkdev.h> 11 11 #include <asm/bug.h> 12 12 #include <asm/div64.h> 13 13
+1 -1
arch/arm/mach-nomadik/clock.c
··· 7 7 #include <linux/module.h> 8 8 #include <linux/errno.h> 9 9 #include <linux/clk.h> 10 - #include <asm/clkdev.h> 10 + #include <linux/clkdev.h> 11 11 #include "clock.h" 12 12 13 13 /*
+1 -1
arch/arm/mach-nuc93x/clock.h
··· 10 10 * the Free Software Foundation; either version 2 of the License. 11 11 */ 12 12 13 - #include <asm/clkdev.h> 13 + #include <linux/clkdev.h> 14 14 15 15 void nuc93x_clk_enable(struct clk *clk, int enable); 16 16 void clks_register(struct clk_lookup *clks, size_t num);
+1 -1
arch/arm/mach-omap1/clock.c
··· 17 17 #include <linux/err.h> 18 18 #include <linux/clk.h> 19 19 #include <linux/io.h> 20 + #include <linux/clkdev.h> 20 21 21 22 #include <asm/mach-types.h> 22 - #include <asm/clkdev.h> 23 23 24 24 #include <plat/cpu.h> 25 25 #include <plat/usb.h>
+1 -1
arch/arm/mach-omap2/dpll3xxx.c
··· 26 26 #include <linux/clk.h> 27 27 #include <linux/io.h> 28 28 #include <linux/bitops.h> 29 + #include <linux/clkdev.h> 29 30 30 31 #include <plat/cpu.h> 31 32 #include <plat/clock.h> 32 - #include <asm/clkdev.h> 33 33 34 34 #include "clock.h" 35 35 #include "prm.h"
+1 -2
arch/arm/mach-pnx4008/clock.c
··· 21 21 #include <linux/err.h> 22 22 #include <linux/delay.h> 23 23 #include <linux/io.h> 24 - 25 - #include <asm/clkdev.h> 24 + #include <linux/clkdev.h> 26 25 27 26 #include <mach/hardware.h> 28 27 #include <mach/clock.h>
+1 -1
arch/arm/mach-pxa/clock.c
··· 11 11 #include <linux/spinlock.h> 12 12 #include <linux/platform_device.h> 13 13 #include <linux/delay.h> 14 + #include <linux/clkdev.h> 14 15 15 - #include <asm/clkdev.h> 16 16 #include <mach/pxa2xx-regs.h> 17 17 #include <mach/hardware.h> 18 18
+1 -1
arch/arm/mach-pxa/clock.h
··· 1 - #include <asm/clkdev.h> 1 + #include <linux/clkdev.h> 2 2 3 3 struct clkops { 4 4 void (*enable)(struct clk *);
+1 -2
arch/arm/mach-realview/core.c
··· 30 30 #include <linux/ata_platform.h> 31 31 #include <linux/amba/mmci.h> 32 32 #include <linux/gfp.h> 33 + #include <linux/clkdev.h> 33 34 34 - #include <asm/clkdev.h> 35 35 #include <asm/system.h> 36 36 #include <mach/hardware.h> 37 37 #include <asm/irq.h> ··· 47 47 48 48 #include <asm/hardware/gic.h> 49 49 50 - #include <mach/clkdev.h> 51 50 #include <mach/platform.h> 52 51 #include <mach/irqs.h> 53 52 #include <plat/timer-sp.h>
+3 -3
arch/arm/mach-shmobile/Kconfig
··· 6 6 bool "SH-Mobile G3 (SH7367)" 7 7 select CPU_V6 8 8 select HAVE_CLK 9 - select COMMON_CLKDEV 9 + select CLKDEV_LOOKUP 10 10 select SH_CLK_CPG 11 11 select GENERIC_CLOCKEVENTS 12 12 ··· 14 14 bool "SH-Mobile G4 (SH7377)" 15 15 select CPU_V7 16 16 select HAVE_CLK 17 - select COMMON_CLKDEV 17 + select CLKDEV_LOOKUP 18 18 select SH_CLK_CPG 19 19 select GENERIC_CLOCKEVENTS 20 20 ··· 22 22 bool "SH-Mobile AP4 (SH7372)" 23 23 select CPU_V7 24 24 select HAVE_CLK 25 - select COMMON_CLKDEV 25 + select CLKDEV_LOOKUP 26 26 select SH_CLK_CPG 27 27 select GENERIC_CLOCKEVENTS 28 28
+1 -1
arch/arm/mach-shmobile/clock-sh7367.c
··· 20 20 #include <linux/kernel.h> 21 21 #include <linux/io.h> 22 22 #include <linux/sh_clk.h> 23 + #include <linux/clkdev.h> 23 24 #include <mach/common.h> 24 - #include <asm/clkdev.h> 25 25 26 26 /* SH7367 registers */ 27 27 #define RTFRQCR 0xe6150000
+1 -1
arch/arm/mach-shmobile/clock-sh7372.c
··· 20 20 #include <linux/kernel.h> 21 21 #include <linux/io.h> 22 22 #include <linux/sh_clk.h> 23 + #include <linux/clkdev.h> 23 24 #include <mach/common.h> 24 - #include <asm/clkdev.h> 25 25 26 26 /* SH7372 registers */ 27 27 #define FRQCRA 0xe6150000
+1 -1
arch/arm/mach-shmobile/clock-sh7377.c
··· 20 20 #include <linux/kernel.h> 21 21 #include <linux/io.h> 22 22 #include <linux/sh_clk.h> 23 + #include <linux/clkdev.h> 23 24 #include <mach/common.h> 24 - #include <asm/clkdev.h> 25 25 26 26 /* SH7377 registers */ 27 27 #define RTFRQCR 0xe6150000
+1 -2
arch/arm/mach-tcc8k/clock.c
··· 12 12 #include <linux/io.h> 13 13 #include <linux/module.h> 14 14 #include <linux/spinlock.h> 15 - 16 - #include <asm/clkdev.h> 15 + #include <linux/clkdev.h> 17 16 18 17 #include <mach/clock.h> 19 18 #include <mach/irqs.h>
+1 -1
arch/arm/mach-tegra/clock.c
··· 25 25 #include <linux/slab.h> 26 26 #include <linux/seq_file.h> 27 27 #include <linux/regulator/consumer.h> 28 - #include <asm/clkdev.h> 28 + #include <linux/clkdev.h> 29 29 30 30 #include "clock.h" 31 31 #include "board.h"
+1 -1
arch/arm/mach-tegra/clock.h
··· 21 21 #define __MACH_TEGRA_CLOCK_H 22 22 23 23 #include <linux/list.h> 24 - #include <asm/clkdev.h> 24 + #include <linux/clkdev.h> 25 25 26 26 #define DIV_BUS (1 << 0) 27 27 #define DIV_U71 (1 << 1)
+1 -2
arch/arm/mach-tegra/tegra2_clocks.c
··· 24 24 #include <linux/delay.h> 25 25 #include <linux/io.h> 26 26 #include <linux/hrtimer.h> 27 - 28 - #include <asm/clkdev.h> 27 + #include <linux/clkdev.h> 29 28 30 29 #include <mach/iomap.h> 31 30
+1 -1
arch/arm/mach-u300/clock.c
··· 25 25 #include <linux/timer.h> 26 26 #include <linux/io.h> 27 27 #include <linux/seq_file.h> 28 + #include <linux/clkdev.h> 28 29 29 - #include <asm/clkdev.h> 30 30 #include <mach/hardware.h> 31 31 #include <mach/syscon.h> 32 32
+1 -2
arch/arm/mach-ux500/clock.c
··· 13 13 #include <linux/err.h> 14 14 #include <linux/clk.h> 15 15 #include <linux/io.h> 16 - 17 - #include <asm/clkdev.h> 16 + #include <linux/clkdev.h> 18 17 19 18 #include <plat/mtu.h> 20 19 #include <mach/hardware.h>
+1 -2
arch/arm/mach-versatile/core.c
··· 31 31 #include <linux/amba/pl022.h> 32 32 #include <linux/io.h> 33 33 #include <linux/gfp.h> 34 + #include <linux/clkdev.h> 34 35 35 - #include <asm/clkdev.h> 36 36 #include <asm/system.h> 37 37 #include <asm/irq.h> 38 38 #include <asm/leds.h> ··· 46 46 #include <asm/mach/irq.h> 47 47 #include <asm/mach/time.h> 48 48 #include <asm/mach/map.h> 49 - #include <mach/clkdev.h> 50 49 #include <mach/hardware.h> 51 50 #include <mach/platform.h> 52 51 #include <plat/timer-sp.h>
+1 -2
arch/arm/mach-vexpress/ct-ca9x4.c
··· 8 8 #include <linux/platform_device.h> 9 9 #include <linux/amba/bus.h> 10 10 #include <linux/amba/clcd.h> 11 + #include <linux/clkdev.h> 11 12 12 - #include <asm/clkdev.h> 13 13 #include <asm/pgtable.h> 14 14 #include <asm/hardware/arm_timer.h> 15 15 #include <asm/hardware/cache-l2x0.h> ··· 18 18 #include <asm/pmu.h> 19 19 #include <asm/smp_twd.h> 20 20 21 - #include <mach/clkdev.h> 22 21 #include <mach/ct-ca9x4.h> 23 22 24 23 #include <plat/timer-sp.h>
+1 -2
arch/arm/mach-vexpress/v2m.c
··· 11 11 #include <linux/spinlock.h> 12 12 #include <linux/sysdev.h> 13 13 #include <linux/usb/isp1760.h> 14 + #include <linux/clkdev.h> 14 15 15 - #include <asm/clkdev.h> 16 16 #include <asm/sizes.h> 17 17 #include <asm/mach/flash.h> 18 18 #include <asm/mach/map.h> 19 19 #include <asm/mach/time.h> 20 20 #include <asm/hardware/arm_timer.h> 21 21 22 - #include <mach/clkdev.h> 23 22 #include <mach/motherboard.h> 24 23 25 24 #include <plat/timer-sp.h>
+1 -1
arch/arm/mach-w90x900/clock.h
··· 10 10 * the Free Software Foundation; either version 2 of the License. 11 11 */ 12 12 13 - #include <asm/clkdev.h> 13 + #include <linux/clkdev.h> 14 14 15 15 void nuc900_clk_enable(struct clk *clk, int enable); 16 16 void nuc900_subclk_enable(struct clk *clk, int enable);
+2 -2
arch/arm/plat-omap/Kconfig
··· 11 11 12 12 config ARCH_OMAP1 13 13 bool "TI OMAP1" 14 - select COMMON_CLKDEV 14 + select CLKDEV_LOOKUP 15 15 help 16 16 "Systems based on omap7xx, omap15xx or omap16xx" 17 17 18 18 config ARCH_OMAP2PLUS 19 19 bool "TI OMAP2/3/4" 20 - select COMMON_CLKDEV 20 + select CLKDEV_LOOKUP 21 21 help 22 22 "Systems based on OMAP2, OMAP3 or OMAP4" 23 23
+1 -1
arch/arm/plat-omap/include/plat/clkdev_omap.h
··· 8 8 #ifndef __ARCH_ARM_PLAT_OMAP_INCLUDE_PLAT_CLKDEV_OMAP_H 9 9 #define __ARCH_ARM_PLAT_OMAP_INCLUDE_PLAT_CLKDEV_OMAP_H 10 10 11 - #include <asm/clkdev.h> 11 + #include <linux/clkdev.h> 12 12 13 13 struct omap_clk { 14 14 u16 cpu;
+1 -1
arch/arm/plat-spear/include/plat/clock.h
··· 15 15 #define __PLAT_CLOCK_H 16 16 17 17 #include <linux/list.h> 18 - #include <asm/clkdev.h> 18 + #include <linux/clkdev.h> 19 19 #include <linux/types.h> 20 20 21 21 /* clk structure flags */
+1 -1
arch/arm/plat-stmp3xxx/clock.c
··· 25 25 #include <linux/err.h> 26 26 #include <linux/delay.h> 27 27 #include <linux/io.h> 28 + #include <linux/clkdev.h> 28 29 29 30 #include <asm/mach-types.h> 30 - #include <asm/clkdev.h> 31 31 #include <mach/platform.h> 32 32 #include <mach/regs-clkctrl.h> 33 33
+1 -1
arch/sh/Kconfig
··· 1 1 config SUPERH 2 2 def_bool y 3 3 select EMBEDDED 4 - select HAVE_CLK 4 + select CLKDEV_LOOKUP 5 5 select HAVE_IDE if HAS_IOPORT 6 6 select HAVE_MEMBLOCK 7 7 select HAVE_OPROFILE
+1 -1
arch/sh/boards/mach-highlander/setup.c
··· 24 24 #include <linux/interrupt.h> 25 25 #include <linux/usb/r8a66597.h> 26 26 #include <linux/usb/m66592.h> 27 + #include <linux/clkdev.h> 27 28 #include <net/ax88796.h> 28 29 #include <asm/machvec.h> 29 30 #include <mach/highlander.h> 30 - #include <asm/clkdev.h> 31 31 #include <asm/clock.h> 32 32 #include <asm/heartbeat.h> 33 33 #include <asm/io.h>
+17 -21
arch/sh/include/asm/clkdev.h
··· 1 1 /* 2 - * arch/sh/include/asm/clkdev.h 3 - * 4 - * Cloned from arch/arm/include/asm/clkdev.h: 5 - * 6 - * Copyright (C) 2008 Russell King. 2 + * Copyright (C) 2010 Paul Mundt <lethal@linux-sh.org> 7 3 * 8 4 * This program is free software; you can redistribute it and/or modify 9 5 * it under the terms of the GNU General Public License version 2 as ··· 7 11 * 8 12 * Helper for the clk API to assist looking up a struct clk. 9 13 */ 10 - #ifndef __ASM_CLKDEV_H 11 - #define __ASM_CLKDEV_H 12 14 13 - struct clk; 15 + #ifndef __CLKDEV__H_ 16 + #define __CLKDEV__H_ 14 17 15 - struct clk_lookup { 16 - struct list_head node; 17 - const char *dev_id; 18 - const char *con_id; 19 - struct clk *clk; 20 - }; 18 + #include <linux/bootmem.h> 19 + #include <linux/mm.h> 20 + #include <linux/slab.h> 21 21 22 - struct clk_lookup *clkdev_alloc(struct clk *clk, const char *con_id, 23 - const char *dev_fmt, ...); 22 + #include <asm/clock.h> 24 23 25 - void clkdev_add(struct clk_lookup *cl); 26 - void clkdev_drop(struct clk_lookup *cl); 24 + static inline struct clk_lookup_alloc *__clkdev_alloc(size_t size) 25 + { 26 + if (!slab_is_available()) 27 + return alloc_bootmem_low_pages(size); 28 + else 29 + return kzalloc(size, GFP_KERNEL); 30 + } 27 31 28 - void clkdev_add_table(struct clk_lookup *, size_t); 29 - int clk_add_alias(const char *, const char *, char *, struct device *); 32 + #define __clk_put(clk) 33 + #define __clk_get(clk) ({ 1; }) 30 34 31 - #endif 35 + #endif /* __CLKDEV_H__ */
+1 -1
arch/sh/kernel/Makefile
··· 11 11 12 12 CFLAGS_REMOVE_return_address.o = -pg 13 13 14 - obj-y := clkdev.o debugtraps.o dma-nommu.o dumpstack.o \ 14 + obj-y := debugtraps.o dma-nommu.o dumpstack.o \ 15 15 idle.o io.o irq.o irq_$(BITS).o kdebugfs.o \ 16 16 machvec.o nmi_debug.o process.o \ 17 17 process_$(BITS).o ptrace.o ptrace_$(BITS).o \
+24 -19
arch/sh/kernel/clkdev.c drivers/clk/clkdev.c
··· 1 1 /* 2 - * arch/sh/kernel/clkdev.c 3 - * 4 - * Cloned from arch/arm/common/clkdev.c: 2 + * drivers/clk/clkdev.c 5 3 * 6 4 * Copyright (C) 2008 Russell King. 7 5 * ··· 18 20 #include <linux/string.h> 19 21 #include <linux/mutex.h> 20 22 #include <linux/clk.h> 21 - #include <linux/slab.h> 22 - #include <linux/bootmem.h> 23 - #include <linux/mm.h> 24 - #include <asm/clock.h> 25 - #include <asm/clkdev.h> 23 + #include <linux/clkdev.h> 26 24 27 25 static LIST_HEAD(clocks); 28 26 static DEFINE_MUTEX(clocks_mutex); ··· 50 56 continue; 51 57 match += 1; 52 58 } 53 - if (match == 0) 54 - continue; 55 59 56 60 if (match > best) { 57 61 clk = p->clk; 58 - best = match; 62 + if (match != 3) 63 + best = match; 64 + else 65 + break; 59 66 } 60 67 } 61 68 return clk; ··· 68 73 69 74 mutex_lock(&clocks_mutex); 70 75 clk = clk_find(dev_id, con_id); 76 + if (clk && !__clk_get(clk)) 77 + clk = NULL; 71 78 mutex_unlock(&clocks_mutex); 72 79 73 80 return clk ? clk : ERR_PTR(-ENOENT); 74 81 } 75 82 EXPORT_SYMBOL(clk_get_sys); 83 + 84 + struct clk *clk_get(struct device *dev, const char *con_id) 85 + { 86 + const char *dev_id = dev ? dev_name(dev) : NULL; 87 + 88 + return clk_get_sys(dev_id, con_id); 89 + } 90 + EXPORT_SYMBOL(clk_get); 91 + 92 + void clk_put(struct clk *clk) 93 + { 94 + __clk_put(clk); 95 + } 96 + EXPORT_SYMBOL(clk_put); 76 97 77 98 void clkdev_add(struct clk_lookup *cl) 78 99 { ··· 122 111 { 123 112 struct clk_lookup_alloc *cla; 124 113 125 - if (!slab_is_available()) 126 - cla = alloc_bootmem_low_pages(sizeof(*cla)); 127 - else 128 - cla = kzalloc(sizeof(*cla), GFP_KERNEL); 129 - 114 + cla = __clkdev_alloc(sizeof(*cla)); 130 115 if (!cla) 131 116 return NULL; 132 117 ··· 168 161 */ 169 162 void clkdev_drop(struct clk_lookup *cl) 170 163 { 171 - struct clk_lookup_alloc *cla = container_of(cl, struct clk_lookup_alloc, cl); 172 - 173 164 mutex_lock(&clocks_mutex); 174 165 list_del(&cl->node); 175 166 mutex_unlock(&clocks_mutex); 176 - kfree(cla); 167 + kfree(cl); 177 168 } 178 169 EXPORT_SYMBOL(clkdev_drop);
+1 -1
arch/sh/kernel/cpu/clock-cpg.c
··· 2 2 #include <linux/compiler.h> 3 3 #include <linux/slab.h> 4 4 #include <linux/io.h> 5 - #include <asm/clkdev.h> 5 + #include <linux/clkdev.h> 6 6 #include <asm/clock.h> 7 7 8 8 static struct clk master_clk = {
-16
arch/sh/kernel/cpu/clock.c
··· 48 48 return ret; 49 49 } 50 50 51 - /* 52 - * Returns a clock. Note that we first try to use device id on the bus 53 - * and clock name. If this fails, we try to use clock name only. 54 - */ 55 - struct clk *clk_get(struct device *dev, const char *con_id) 56 - { 57 - const char *dev_id = dev ? dev_name(dev) : NULL; 58 - 59 - return clk_get_sys(dev_id, con_id); 60 - } 61 - EXPORT_SYMBOL_GPL(clk_get); 62 - 63 - void clk_put(struct clk *clk) 64 - { 65 - } 66 - EXPORT_SYMBOL_GPL(clk_put); 67 51
+1 -1
arch/sh/kernel/cpu/sh4/clock-sh4-202.c
··· 13 13 #include <linux/kernel.h> 14 14 #include <linux/err.h> 15 15 #include <linux/io.h> 16 - #include <asm/clkdev.h> 16 + #include <linux/clkdev.h> 17 17 #include <asm/clock.h> 18 18 #include <asm/freq.h> 19 19
+1 -1
arch/sh/kernel/cpu/sh4a/clock-sh7343.c
··· 21 21 #include <linux/init.h> 22 22 #include <linux/kernel.h> 23 23 #include <linux/io.h> 24 - #include <asm/clkdev.h> 24 + #include <linux/clkdev.h> 25 25 #include <asm/clock.h> 26 26 27 27 /* SH7343 registers */
+1 -1
arch/sh/kernel/cpu/sh4a/clock-sh7366.c
··· 21 21 #include <linux/init.h> 22 22 #include <linux/kernel.h> 23 23 #include <linux/io.h> 24 - #include <asm/clkdev.h> 24 + #include <linux/clkdev.h> 25 25 #include <asm/clock.h> 26 26 27 27 /* SH7366 registers */
+1 -1
arch/sh/kernel/cpu/sh4a/clock-sh7722.c
··· 21 21 #include <linux/init.h> 22 22 #include <linux/kernel.h> 23 23 #include <linux/io.h> 24 - #include <asm/clkdev.h> 24 + #include <linux/clkdev.h> 25 25 #include <asm/clock.h> 26 26 #include <asm/hwblk.h> 27 27 #include <cpu/sh7722.h>
+1 -1
arch/sh/kernel/cpu/sh4a/clock-sh7723.c
··· 22 22 #include <linux/kernel.h> 23 23 #include <linux/io.h> 24 24 #include <linux/clk.h> 25 - #include <asm/clkdev.h> 25 + #include <linux/clkdev.h> 26 26 #include <asm/clock.h> 27 27 #include <asm/hwblk.h> 28 28 #include <cpu/sh7723.h>
+1 -1
arch/sh/kernel/cpu/sh4a/clock-sh7724.c
··· 22 22 #include <linux/kernel.h> 23 23 #include <linux/io.h> 24 24 #include <linux/clk.h> 25 - #include <asm/clkdev.h> 25 + #include <linux/clkdev.h> 26 26 #include <asm/clock.h> 27 27 #include <asm/hwblk.h> 28 28 #include <cpu/sh7724.h>
+1 -1
arch/sh/kernel/cpu/sh4a/clock-sh7757.c
··· 12 12 #include <linux/init.h> 13 13 #include <linux/kernel.h> 14 14 #include <linux/io.h> 15 - #include <asm/clkdev.h> 15 + #include <linux/clkdev.h> 16 16 #include <asm/clock.h> 17 17 #include <asm/freq.h> 18 18
+1 -1
arch/sh/kernel/cpu/sh4a/clock-sh7763.c
··· 13 13 #include <linux/init.h> 14 14 #include <linux/kernel.h> 15 15 #include <linux/io.h> 16 - #include <asm/clkdev.h> 16 + #include <linux/clkdev.h> 17 17 #include <asm/clock.h> 18 18 #include <asm/freq.h> 19 19 #include <asm/io.h>
+1 -1
arch/sh/kernel/cpu/sh4a/clock-sh7780.c
··· 12 12 #include <linux/init.h> 13 13 #include <linux/kernel.h> 14 14 #include <linux/io.h> 15 - #include <asm/clkdev.h> 15 + #include <linux/clkdev.h> 16 16 #include <asm/clock.h> 17 17 #include <asm/freq.h> 18 18 #include <asm/io.h>
+1 -1
arch/sh/kernel/cpu/sh4a/clock-sh7785.c
··· 14 14 #include <linux/clk.h> 15 15 #include <linux/io.h> 16 16 #include <linux/cpufreq.h> 17 - #include <asm/clkdev.h> 17 + #include <linux/clkdev.h> 18 18 #include <asm/clock.h> 19 19 #include <asm/freq.h> 20 20 #include <cpu/sh7785.h>
+1 -1
arch/sh/kernel/cpu/sh4a/clock-sh7786.c
··· 13 13 #include <linux/kernel.h> 14 14 #include <linux/clk.h> 15 15 #include <linux/io.h> 16 - #include <asm/clkdev.h> 16 + #include <linux/clkdev.h> 17 17 #include <asm/clock.h> 18 18 #include <asm/freq.h> 19 19
+1 -1
arch/sh/kernel/cpu/sh4a/clock-shx3.c
··· 14 14 #include <linux/init.h> 15 15 #include <linux/kernel.h> 16 16 #include <linux/io.h> 17 - #include <asm/clkdev.h> 17 + #include <linux/clkdev.h> 18 18 #include <asm/clock.h> 19 19 #include <asm/freq.h> 20 20
+2
drivers/Kconfig
··· 111 111 source "drivers/staging/Kconfig" 112 112 113 113 source "drivers/platform/Kconfig" 114 + 115 + source "drivers/clk/Kconfig" 114 116 endmenu
+2
drivers/Makefile
··· 114 114 obj-$(CONFIG_STAGING) += staging/ 115 115 obj-y += platform/ 116 116 obj-y += ieee802154/ 117 + #common clk code 118 + obj-y += clk/
+4
drivers/clk/Kconfig
··· 1 + 2 + config CLKDEV_LOOKUP 3 + bool 4 + select HAVE_CLK
+2
drivers/clk/Makefile
··· 1 + 2 + obj-$(CONFIG_CLKDEV_LOOKUP) += clkdev.o
+36
include/linux/clkdev.h
··· 1 + /* 2 + * include/linux/clkdev.h 3 + * 4 + * Copyright (C) 2008 Russell King. 5 + * 6 + * This program is free software; you can redistribute it and/or modify 7 + * it under the terms of the GNU General Public License version 2 as 8 + * published by the Free Software Foundation. 9 + * 10 + * Helper for the clk API to assist looking up a struct clk. 11 + */ 12 + #ifndef __CLKDEV_H 13 + #define __CLKDEV_H 14 + 15 + #include <asm/clkdev.h> 16 + 17 + struct clk; 18 + struct device; 19 + 20 + struct clk_lookup { 21 + struct list_head node; 22 + const char *dev_id; 23 + const char *con_id; 24 + struct clk *clk; 25 + }; 26 + 27 + struct clk_lookup *clkdev_alloc(struct clk *clk, const char *con_id, 28 + const char *dev_fmt, ...); 29 + 30 + void clkdev_add(struct clk_lookup *cl); 31 + void clkdev_drop(struct clk_lookup *cl); 32 + 33 + void clkdev_add_table(struct clk_lookup *, size_t); 34 + int clk_add_alias(const char *, const char *, char *, struct device *); 35 + 36 + #endif