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

Merge branch 'clks' into devel

authored by

Russell King and committed by
Russell King
11224303 773e9610

+64 -270
+1
arch/arm/Kconfig
··· 271 271 select ARM_VIC 272 272 select GENERIC_GPIO 273 273 select HAVE_CLK 274 + select COMMON_CLKDEV 274 275 select ARCH_REQUIRE_GPIOLIB 275 276 help 276 277 This enables support for the Cirrus EP93xx series of CPUs.
+1 -1
arch/arm/mach-aaec2000/Makefile
··· 3 3 # 4 4 5 5 # Common support (must be linked before board specific support) 6 - obj-y += core.o clock.o 6 + obj-y += core.o 7 7 8 8 # Specific board support 9 9 obj-$(CONFIG_MACH_AAED2000) += aaed2000.o
-99
arch/arm/mach-aaec2000/clock.c
··· 1 - /* 2 - * linux/arch/arm/mach-aaec2000/clock.c 3 - * 4 - * Copyright (C) 2005 Nicolas Bellido Y Ortega 5 - * 6 - * Based on linux/arch/arm/mach-integrator/clock.c 7 - * 8 - * This program is free software; you can redistribute it and/or modify 9 - * it under the terms of the GNU General Public License version 2 as 10 - * published by the Free Software Foundation. 11 - */ 12 - #include <linux/module.h> 13 - #include <linux/kernel.h> 14 - #include <linux/list.h> 15 - #include <linux/errno.h> 16 - #include <linux/err.h> 17 - #include <linux/string.h> 18 - #include <linux/clk.h> 19 - #include <linux/mutex.h> 20 - 21 - #include "clock.h" 22 - 23 - static LIST_HEAD(clocks); 24 - static DEFINE_MUTEX(clocks_mutex); 25 - 26 - struct clk *clk_get(struct device *dev, const char *id) 27 - { 28 - struct clk *p, *clk = ERR_PTR(-ENOENT); 29 - 30 - mutex_lock(&clocks_mutex); 31 - list_for_each_entry(p, &clocks, node) { 32 - if (strcmp(id, p->name) == 0 && try_module_get(p->owner)) { 33 - clk = p; 34 - break; 35 - } 36 - } 37 - mutex_unlock(&clocks_mutex); 38 - 39 - return clk; 40 - } 41 - EXPORT_SYMBOL(clk_get); 42 - 43 - void clk_put(struct clk *clk) 44 - { 45 - module_put(clk->owner); 46 - } 47 - EXPORT_SYMBOL(clk_put); 48 - 49 - int clk_enable(struct clk *clk) 50 - { 51 - return 0; 52 - } 53 - EXPORT_SYMBOL(clk_enable); 54 - 55 - void clk_disable(struct clk *clk) 56 - { 57 - } 58 - EXPORT_SYMBOL(clk_disable); 59 - 60 - unsigned long clk_get_rate(struct clk *clk) 61 - { 62 - return clk->rate; 63 - } 64 - EXPORT_SYMBOL(clk_get_rate); 65 - 66 - long clk_round_rate(struct clk *clk, unsigned long rate) 67 - { 68 - return rate; 69 - } 70 - EXPORT_SYMBOL(clk_round_rate); 71 - 72 - int clk_set_rate(struct clk *clk, unsigned long rate) 73 - { 74 - return 0; 75 - } 76 - EXPORT_SYMBOL(clk_set_rate); 77 - 78 - int clk_register(struct clk *clk) 79 - { 80 - mutex_lock(&clocks_mutex); 81 - list_add(&clk->node, &clocks); 82 - mutex_unlock(&clocks_mutex); 83 - return 0; 84 - } 85 - EXPORT_SYMBOL(clk_register); 86 - 87 - void clk_unregister(struct clk *clk) 88 - { 89 - mutex_lock(&clocks_mutex); 90 - list_del(&clk->node); 91 - mutex_unlock(&clocks_mutex); 92 - } 93 - EXPORT_SYMBOL(clk_unregister); 94 - 95 - static int __init clk_init(void) 96 - { 97 - return 0; 98 - } 99 - arch_initcall(clk_init);
-23
arch/arm/mach-aaec2000/clock.h
··· 1 - /* 2 - * linux/arch/arm/mach-aaec2000/clock.h 3 - * 4 - * Copyright (C) 2005 Nicolas Bellido Y Ortega 5 - * 6 - * Based on linux/arch/arm/mach-integrator/clock.h 7 - * 8 - * This program is free software; you can redistribute it and/or modify 9 - * it under the terms of the GNU General Public License version 2 as 10 - * published by the Free Software Foundation. 11 - */ 12 - struct module; 13 - 14 - struct clk { 15 - struct list_head node; 16 - unsigned long rate; 17 - struct module *owner; 18 - const char *name; 19 - void *data; 20 - }; 21 - 22 - int clk_register(struct clk *clk); 23 - void clk_unregister(struct clk *clk);
+23 -6
arch/arm/mach-aaec2000/core.c
··· 19 19 #include <linux/interrupt.h> 20 20 #include <linux/timex.h> 21 21 #include <linux/signal.h> 22 + #include <linux/clk.h> 22 23 23 24 #include <mach/hardware.h> 24 25 #include <asm/irq.h> ··· 31 30 #include <asm/mach/map.h> 32 31 33 32 #include "core.h" 34 - #include "clock.h" 35 33 36 34 /* 37 35 * Common I/O mapping: ··· 229 229 &clcd_device, 230 230 }; 231 231 232 - static struct clk aaec2000_clcd_clk = { 233 - .name = "CLCDCLK", 234 - }; 232 + void clk_disable(struct clk *clk) 233 + { 234 + } 235 + 236 + int clk_set_rate(struct clk *clk, unsigned long rate) 237 + { 238 + return 0; 239 + } 240 + 241 + int clk_enable(struct clk *clk) 242 + { 243 + return 0; 244 + } 245 + 246 + struct clk *clk_get(struct device *dev, const char *id) 247 + { 248 + return dev && strcmp(dev_name(dev), "mb:16") == 0 ? NULL : ERR_PTR(-ENOENT); 249 + } 250 + 251 + void clk_put(struct clk *clk) 252 + { 253 + } 235 254 236 255 void __init aaec2000_set_clcd_plat_data(struct aaec2000_clcd_info *clcd) 237 256 { ··· 283 264 static int __init aaec2000_init(void) 284 265 { 285 266 int i; 286 - 287 - clk_register(&aaec2000_clcd_clk); 288 267 289 268 for (i = 0; i < ARRAY_SIZE(amba_devs); i++) { 290 269 struct amba_device *d = amba_devs[i];
+22 -44
arch/arm/mach-ep93xx/clock.c
··· 16 16 #include <linux/module.h> 17 17 #include <linux/string.h> 18 18 #include <linux/io.h> 19 + 20 + #include <asm/clkdev.h> 19 21 #include <asm/div64.h> 20 22 #include <mach/hardware.h> 21 23 22 24 struct clk { 23 - char *name; 24 25 unsigned long rate; 25 26 int users; 26 27 u32 enable_reg; ··· 29 28 }; 30 29 31 30 static struct clk clk_uart = { 32 - .name = "UARTCLK", 33 31 .rate = 14745600, 34 32 }; 35 - static struct clk clk_pll1 = { 36 - .name = "pll1", 37 - }; 38 - static struct clk clk_f = { 39 - .name = "fclk", 40 - }; 41 - static struct clk clk_h = { 42 - .name = "hclk", 43 - }; 44 - static struct clk clk_p = { 45 - .name = "pclk", 46 - }; 47 - static struct clk clk_pll2 = { 48 - .name = "pll2", 49 - }; 33 + static struct clk clk_pll1; 34 + static struct clk clk_f; 35 + static struct clk clk_h; 36 + static struct clk clk_p; 37 + static struct clk clk_pll2; 50 38 static struct clk clk_usb_host = { 51 - .name = "usb_host", 52 39 .enable_reg = EP93XX_SYSCON_CLOCK_CONTROL, 53 40 .enable_mask = EP93XX_SYSCON_CLOCK_USH_EN, 54 41 }; 55 42 43 + #define INIT_CK(dev,con,ck) \ 44 + { .dev_id = dev, .con_id = con, .clk = ck } 56 45 57 - static struct clk *clocks[] = { 58 - &clk_uart, 59 - &clk_pll1, 60 - &clk_f, 61 - &clk_h, 62 - &clk_p, 63 - &clk_pll2, 64 - &clk_usb_host, 46 + static struct clk_lookup clocks[] = { 47 + INIT_CK("apb:uart1", NULL, &clk_uart), 48 + INIT_CK("apb:uart2", NULL, &clk_uart), 49 + INIT_CK("apb:uart3", NULL, &clk_uart), 50 + INIT_CK(NULL, "pll1", &clk_pll1), 51 + INIT_CK(NULL, "fclk", &clk_f), 52 + INIT_CK(NULL, "hclk", &clk_h), 53 + INIT_CK(NULL, "pclk", &clk_p), 54 + INIT_CK(NULL, "pll2", &clk_pll2), 55 + INIT_CK(NULL, "usb_host", &clk_usb_host), 65 56 }; 66 57 67 - struct clk *clk_get(struct device *dev, const char *id) 68 - { 69 - int i; 70 - 71 - for (i = 0; i < ARRAY_SIZE(clocks); i++) { 72 - if (!strcmp(clocks[i]->name, id)) 73 - return clocks[i]; 74 - } 75 - 76 - return ERR_PTR(-ENOENT); 77 - } 78 - EXPORT_SYMBOL(clk_get); 79 58 80 59 int clk_enable(struct clk *clk) 81 60 { ··· 87 106 } 88 107 EXPORT_SYMBOL(clk_get_rate); 89 108 90 - void clk_put(struct clk *clk) 91 - { 92 - } 93 - EXPORT_SYMBOL(clk_put); 94 - 95 - 96 109 97 110 static char fclk_divisors[] = { 1, 2, 4, 8, 16, 1, 1, 1 }; 98 111 static char hclk_divisors[] = { 1, 2, 4, 5, 6, 8, 16, 32 }; ··· 113 138 static int __init ep93xx_clock_init(void) 114 139 { 115 140 u32 value; 141 + int i; 116 142 117 143 value = __raw_readl(EP93XX_SYSCON_CLOCK_SET1); 118 144 if (!(value & 0x00800000)) { /* PLL1 bypassed? */ ··· 141 165 clk_f.rate / 1000000, clk_h.rate / 1000000, 142 166 clk_p.rate / 1000000); 143 167 168 + for (i = 0; i < ARRAY_SIZE(clocks); i++) 169 + clkdev_add(&clocks[i]); 144 170 return 0; 145 171 } 146 172 arch_initcall(ep93xx_clock_init);
+7
arch/arm/mach-ep93xx/include/mach/clkdev.h
··· 1 + #ifndef __ASM_MACH_CLKDEV_H 2 + #define __ASM_MACH_CLKDEV_H 3 + 4 + #define __clk_get(clk) ({ 1; }) 5 + #define __clk_put(clk) do { } while (0) 6 + 7 + #endif
+4 -88
arch/arm/mach-lh7a40x/clocks.c
··· 14 14 #include <linux/err.h> 15 15 16 16 struct module; 17 - struct icst525_params; 18 17 19 18 struct clk { 20 19 struct list_head node; 21 20 unsigned long rate; 22 21 struct module *owner; 23 22 const char *name; 24 - // void *data; 25 - // const struct icst525_params *params; 26 - // void (*setvco)(struct clk *, struct icst525_vco vco); 27 23 }; 28 - 29 - int clk_register(struct clk *clk); 30 - void clk_unregister(struct clk *clk); 31 24 32 25 /* ----- */ 33 26 ··· 72 79 73 80 /* ----- */ 74 81 75 - static LIST_HEAD(clocks); 76 - static DECLARE_MUTEX(clocks_sem); 77 - 78 82 struct clk *clk_get (struct device *dev, const char *id) 79 83 { 80 - struct clk *p; 81 - struct clk *clk = ERR_PTR(-ENOENT); 82 - 83 - down (&clocks_sem); 84 - list_for_each_entry (p, &clocks, node) { 85 - if (strcmp (id, p->name) == 0 86 - && try_module_get(p->owner)) { 87 - clk = p; 88 - break; 89 - } 90 - } 91 - up (&clocks_sem); 92 - 93 - return clk; 84 + return dev && strcmp(dev_name(dev), "cldc-lh7a40x") == 0 85 + ? NULL : ERR_PTR(-ENOENT); 94 86 } 95 87 EXPORT_SYMBOL(clk_get); 96 88 97 89 void clk_put (struct clk *clk) 98 90 { 99 - module_put(clk->owner); 100 91 } 101 92 EXPORT_SYMBOL(clk_put); 102 93 ··· 95 118 } 96 119 EXPORT_SYMBOL(clk_disable); 97 120 98 - int clk_use (struct clk *clk) 99 - { 100 - return 0; 101 - } 102 - EXPORT_SYMBOL(clk_use); 103 - 104 - void clk_unuse (struct clk *clk) 105 - { 106 - } 107 - EXPORT_SYMBOL(clk_unuse); 108 - 109 121 unsigned long clk_get_rate (struct clk *clk) 110 122 { 111 - return clk->rate; 123 + return 0; 112 124 } 113 125 EXPORT_SYMBOL(clk_get_rate); 114 126 ··· 109 143 110 144 int clk_set_rate (struct clk *clk, unsigned long rate) 111 145 { 112 - int ret = -EIO; 113 - return ret; 146 + return -EIO; 114 147 } 115 148 EXPORT_SYMBOL(clk_set_rate); 116 - 117 - #if 0 118 - /* 119 - * These are fixed clocks. 120 - */ 121 - static struct clk kmi_clk = { 122 - .name = "KMIREFCLK", 123 - .rate = 24000000, 124 - }; 125 - 126 - static struct clk uart_clk = { 127 - .name = "UARTCLK", 128 - .rate = 24000000, 129 - }; 130 - 131 - static struct clk mmci_clk = { 132 - .name = "MCLK", 133 - .rate = 33000000, 134 - }; 135 - #endif 136 - 137 - static struct clk clcd_clk = { 138 - .name = "CLCDCLK", 139 - .rate = 0, 140 - }; 141 - 142 - int clk_register (struct clk *clk) 143 - { 144 - down (&clocks_sem); 145 - list_add (&clk->node, &clocks); 146 - up (&clocks_sem); 147 - return 0; 148 - } 149 - EXPORT_SYMBOL(clk_register); 150 - 151 - void clk_unregister (struct clk *clk) 152 - { 153 - down (&clocks_sem); 154 - list_del (&clk->node); 155 - up (&clocks_sem); 156 - } 157 - EXPORT_SYMBOL(clk_unregister); 158 - 159 - static int __init clk_init (void) 160 - { 161 - clk_register(&clcd_clk); 162 - return 0; 163 - } 164 - arch_initcall(clk_init);
+2 -5
arch/arm/mach-netx/fb.c
··· 22 22 #include <linux/dma-mapping.h> 23 23 #include <linux/amba/bus.h> 24 24 #include <linux/amba/clcd.h> 25 + #include <linux/err.h> 25 26 26 27 #include <mach/netx-regs.h> 27 28 #include <mach/hardware.h> 28 - 29 - struct clk {}; 30 - 31 - static struct clk fb_clk; 32 29 33 30 static struct clcd_panel *netx_panel; 34 31 ··· 82 85 83 86 struct clk *clk_get(struct device *dev, const char *id) 84 87 { 85 - return &fb_clk; 88 + return dev && strcmp(dev_name(dev), "fb") == 0 ? NULL : ERR_PTR(-ENOENT); 86 89 } 87 90 88 91 void clk_put(struct clk *clk)
+1 -1
drivers/mmc/host/mmci.c
··· 500 500 } 501 501 502 502 host = mmc_priv(mmc); 503 - host->clk = clk_get(&dev->dev, "MCLK"); 503 + host->clk = clk_get(&dev->dev, NULL); 504 504 if (IS_ERR(host->clk)) { 505 505 ret = PTR_ERR(host->clk); 506 506 host->clk = NULL;
+1 -1
drivers/serial/amba-pl010.c
··· 692 692 goto free; 693 693 } 694 694 695 - uap->clk = clk_get(&dev->dev, "UARTCLK"); 695 + uap->clk = clk_get(&dev->dev, NULL); 696 696 if (IS_ERR(uap->clk)) { 697 697 ret = PTR_ERR(uap->clk); 698 698 goto unmap;
+1 -1
drivers/serial/amba-pl011.c
··· 756 756 goto free; 757 757 } 758 758 759 - uap->clk = clk_get(&dev->dev, "UARTCLK"); 759 + uap->clk = clk_get(&dev->dev, NULL); 760 760 if (IS_ERR(uap->clk)) { 761 761 ret = PTR_ERR(uap->clk); 762 762 goto unmap;
+1 -1
drivers/video/amba-clcd.c
··· 343 343 { 344 344 int ret; 345 345 346 - fb->clk = clk_get(&fb->dev->dev, "CLCDCLK"); 346 + fb->clk = clk_get(&fb->dev->dev, NULL); 347 347 if (IS_ERR(fb->clk)) { 348 348 ret = PTR_ERR(fb->clk); 349 349 goto out;