Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
Tony Lindgren | b915855 | 2005-07-10 19:58:14 +0100 | [diff] [blame] | 2 | * linux/arch/arm/plat-omap/clock.c |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3 | * |
Tony Lindgren | 1a8bfa1 | 2005-11-10 14:26:50 +0000 | [diff] [blame] | 4 | * Copyright (C) 2004 - 2005 Nokia corporation |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5 | * Written by Tuukka Tikkanen <tuukka.tikkanen@elektrobit.com> |
| 6 | * |
Tony Lindgren | 1a8bfa1 | 2005-11-10 14:26:50 +0000 | [diff] [blame] | 7 | * Modified for omap shared clock framework by Tony Lindgren <tony@atomide.com> |
| 8 | * |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 9 | * This program is free software; you can redistribute it and/or modify |
| 10 | * it under the terms of the GNU General Public License version 2 as |
| 11 | * published by the Free Software Foundation. |
| 12 | */ |
Tony Lindgren | 1a8bfa1 | 2005-11-10 14:26:50 +0000 | [diff] [blame] | 13 | #include <linux/version.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 14 | #include <linux/kernel.h> |
Tony Lindgren | 1a8bfa1 | 2005-11-10 14:26:50 +0000 | [diff] [blame] | 15 | #include <linux/init.h> |
| 16 | #include <linux/module.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 17 | #include <linux/list.h> |
| 18 | #include <linux/errno.h> |
| 19 | #include <linux/err.h> |
Tim Schmielau | 4e57b68 | 2005-10-30 15:03:48 -0800 | [diff] [blame] | 20 | #include <linux/string.h> |
Russell King | f8ce254 | 2006-01-07 16:15:52 +0000 | [diff] [blame] | 21 | #include <linux/clk.h> |
Arjan van de Ven | 0043170 | 2006-01-12 18:42:23 +0000 | [diff] [blame] | 22 | #include <linux/mutex.h> |
Tony Lindgren | b824efa | 2006-04-02 17:46:20 +0100 | [diff] [blame] | 23 | #include <linux/platform_device.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 24 | |
Tony Lindgren | bb13b5f | 2005-07-10 19:58:18 +0100 | [diff] [blame] | 25 | #include <asm/io.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 26 | #include <asm/semaphore.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 27 | |
Tony Lindgren | 1a8bfa1 | 2005-11-10 14:26:50 +0000 | [diff] [blame] | 28 | #include <asm/arch/clock.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 29 | |
Juha Yrjola | 7df3450 | 2006-06-26 16:16:22 -0700 | [diff] [blame] | 30 | static LIST_HEAD(clocks); |
Arjan van de Ven | 0043170 | 2006-01-12 18:42:23 +0000 | [diff] [blame] | 31 | static DEFINE_MUTEX(clocks_mutex); |
Juha Yrjola | 7df3450 | 2006-06-26 16:16:22 -0700 | [diff] [blame] | 32 | static DEFINE_SPINLOCK(clockfw_lock); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 33 | |
Tony Lindgren | 1a8bfa1 | 2005-11-10 14:26:50 +0000 | [diff] [blame] | 34 | static struct clk_functions *arch_clock; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 35 | |
Tony Lindgren | 1a8bfa1 | 2005-11-10 14:26:50 +0000 | [diff] [blame] | 36 | /*------------------------------------------------------------------------- |
Tony Lindgren | f07adc5 | 2006-01-17 15:27:09 -0800 | [diff] [blame] | 37 | * Standard clock functions defined in include/linux/clk.h |
Tony Lindgren | 1a8bfa1 | 2005-11-10 14:26:50 +0000 | [diff] [blame] | 38 | *-------------------------------------------------------------------------*/ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 39 | |
Tony Lindgren | b824efa | 2006-04-02 17:46:20 +0100 | [diff] [blame] | 40 | /* |
| 41 | * Returns a clock. Note that we first try to use device id on the bus |
| 42 | * and clock name. If this fails, we try to use clock name only. |
| 43 | */ |
Tony Lindgren | 1a8bfa1 | 2005-11-10 14:26:50 +0000 | [diff] [blame] | 44 | struct clk * clk_get(struct device *dev, const char *id) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 45 | { |
| 46 | struct clk *p, *clk = ERR_PTR(-ENOENT); |
Tony Lindgren | b824efa | 2006-04-02 17:46:20 +0100 | [diff] [blame] | 47 | int idno; |
| 48 | |
| 49 | if (dev == NULL || dev->bus != &platform_bus_type) |
| 50 | idno = -1; |
| 51 | else |
| 52 | idno = to_platform_device(dev)->id; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 53 | |
Arjan van de Ven | 0043170 | 2006-01-12 18:42:23 +0000 | [diff] [blame] | 54 | mutex_lock(&clocks_mutex); |
Tony Lindgren | b824efa | 2006-04-02 17:46:20 +0100 | [diff] [blame] | 55 | |
| 56 | list_for_each_entry(p, &clocks, node) { |
| 57 | if (p->id == idno && |
| 58 | strcmp(id, p->name) == 0 && try_module_get(p->owner)) { |
| 59 | clk = p; |
Tony Lindgren | 67d4d83 | 2006-04-09 22:21:05 +0100 | [diff] [blame] | 60 | goto found; |
Tony Lindgren | b824efa | 2006-04-02 17:46:20 +0100 | [diff] [blame] | 61 | } |
| 62 | } |
| 63 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 64 | list_for_each_entry(p, &clocks, node) { |
| 65 | if (strcmp(id, p->name) == 0 && try_module_get(p->owner)) { |
| 66 | clk = p; |
| 67 | break; |
| 68 | } |
| 69 | } |
Tony Lindgren | b824efa | 2006-04-02 17:46:20 +0100 | [diff] [blame] | 70 | |
Tony Lindgren | 67d4d83 | 2006-04-09 22:21:05 +0100 | [diff] [blame] | 71 | found: |
Arjan van de Ven | 0043170 | 2006-01-12 18:42:23 +0000 | [diff] [blame] | 72 | mutex_unlock(&clocks_mutex); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 73 | |
| 74 | return clk; |
| 75 | } |
| 76 | EXPORT_SYMBOL(clk_get); |
| 77 | |
Tony Lindgren | 1a8bfa1 | 2005-11-10 14:26:50 +0000 | [diff] [blame] | 78 | int clk_enable(struct clk *clk) |
| 79 | { |
| 80 | unsigned long flags; |
| 81 | int ret = 0; |
| 82 | |
Tony Lindgren | b824efa | 2006-04-02 17:46:20 +0100 | [diff] [blame] | 83 | if (clk == NULL || IS_ERR(clk)) |
| 84 | return -EINVAL; |
| 85 | |
Tony Lindgren | 1a8bfa1 | 2005-11-10 14:26:50 +0000 | [diff] [blame] | 86 | spin_lock_irqsave(&clockfw_lock, flags); |
Tony Lindgren | f07adc5 | 2006-01-17 15:27:09 -0800 | [diff] [blame] | 87 | if (arch_clock->clk_enable) |
Tony Lindgren | 1a8bfa1 | 2005-11-10 14:26:50 +0000 | [diff] [blame] | 88 | ret = arch_clock->clk_enable(clk); |
Tony Lindgren | 1a8bfa1 | 2005-11-10 14:26:50 +0000 | [diff] [blame] | 89 | spin_unlock_irqrestore(&clockfw_lock, flags); |
| 90 | |
| 91 | return ret; |
| 92 | } |
| 93 | EXPORT_SYMBOL(clk_enable); |
| 94 | |
| 95 | void clk_disable(struct clk *clk) |
| 96 | { |
| 97 | unsigned long flags; |
| 98 | |
Tony Lindgren | b824efa | 2006-04-02 17:46:20 +0100 | [diff] [blame] | 99 | if (clk == NULL || IS_ERR(clk)) |
| 100 | return; |
| 101 | |
Tony Lindgren | 1a8bfa1 | 2005-11-10 14:26:50 +0000 | [diff] [blame] | 102 | spin_lock_irqsave(&clockfw_lock, flags); |
Tony Lindgren | f07adc5 | 2006-01-17 15:27:09 -0800 | [diff] [blame] | 103 | if (arch_clock->clk_disable) |
Tony Lindgren | 1a8bfa1 | 2005-11-10 14:26:50 +0000 | [diff] [blame] | 104 | arch_clock->clk_disable(clk); |
Tony Lindgren | 1a8bfa1 | 2005-11-10 14:26:50 +0000 | [diff] [blame] | 105 | spin_unlock_irqrestore(&clockfw_lock, flags); |
| 106 | } |
| 107 | EXPORT_SYMBOL(clk_disable); |
| 108 | |
Tony Lindgren | 1a8bfa1 | 2005-11-10 14:26:50 +0000 | [diff] [blame] | 109 | int clk_get_usecount(struct clk *clk) |
| 110 | { |
| 111 | unsigned long flags; |
| 112 | int ret = 0; |
| 113 | |
Tony Lindgren | b824efa | 2006-04-02 17:46:20 +0100 | [diff] [blame] | 114 | if (clk == NULL || IS_ERR(clk)) |
| 115 | return 0; |
| 116 | |
Tony Lindgren | 1a8bfa1 | 2005-11-10 14:26:50 +0000 | [diff] [blame] | 117 | spin_lock_irqsave(&clockfw_lock, flags); |
| 118 | ret = clk->usecount; |
| 119 | spin_unlock_irqrestore(&clockfw_lock, flags); |
| 120 | |
| 121 | return ret; |
| 122 | } |
| 123 | EXPORT_SYMBOL(clk_get_usecount); |
| 124 | |
| 125 | unsigned long clk_get_rate(struct clk *clk) |
| 126 | { |
| 127 | unsigned long flags; |
| 128 | unsigned long ret = 0; |
| 129 | |
Tony Lindgren | b824efa | 2006-04-02 17:46:20 +0100 | [diff] [blame] | 130 | if (clk == NULL || IS_ERR(clk)) |
| 131 | return 0; |
| 132 | |
Tony Lindgren | 1a8bfa1 | 2005-11-10 14:26:50 +0000 | [diff] [blame] | 133 | spin_lock_irqsave(&clockfw_lock, flags); |
| 134 | ret = clk->rate; |
| 135 | spin_unlock_irqrestore(&clockfw_lock, flags); |
| 136 | |
| 137 | return ret; |
| 138 | } |
| 139 | EXPORT_SYMBOL(clk_get_rate); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 140 | |
| 141 | void clk_put(struct clk *clk) |
| 142 | { |
| 143 | if (clk && !IS_ERR(clk)) |
| 144 | module_put(clk->owner); |
| 145 | } |
| 146 | EXPORT_SYMBOL(clk_put); |
| 147 | |
Tony Lindgren | 1a8bfa1 | 2005-11-10 14:26:50 +0000 | [diff] [blame] | 148 | /*------------------------------------------------------------------------- |
Tony Lindgren | f07adc5 | 2006-01-17 15:27:09 -0800 | [diff] [blame] | 149 | * Optional clock functions defined in include/linux/clk.h |
Tony Lindgren | 1a8bfa1 | 2005-11-10 14:26:50 +0000 | [diff] [blame] | 150 | *-------------------------------------------------------------------------*/ |
Tony Lindgren | bb13b5f | 2005-07-10 19:58:18 +0100 | [diff] [blame] | 151 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 152 | long clk_round_rate(struct clk *clk, unsigned long rate) |
| 153 | { |
Tony Lindgren | 1a8bfa1 | 2005-11-10 14:26:50 +0000 | [diff] [blame] | 154 | unsigned long flags; |
| 155 | long ret = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 156 | |
Tony Lindgren | b824efa | 2006-04-02 17:46:20 +0100 | [diff] [blame] | 157 | if (clk == NULL || IS_ERR(clk)) |
| 158 | return ret; |
| 159 | |
Tony Lindgren | 1a8bfa1 | 2005-11-10 14:26:50 +0000 | [diff] [blame] | 160 | spin_lock_irqsave(&clockfw_lock, flags); |
| 161 | if (arch_clock->clk_round_rate) |
| 162 | ret = arch_clock->clk_round_rate(clk, rate); |
| 163 | spin_unlock_irqrestore(&clockfw_lock, flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 164 | |
Tony Lindgren | 1a8bfa1 | 2005-11-10 14:26:50 +0000 | [diff] [blame] | 165 | return ret; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 166 | } |
| 167 | EXPORT_SYMBOL(clk_round_rate); |
| 168 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 169 | int clk_set_rate(struct clk *clk, unsigned long rate) |
| 170 | { |
Tony Lindgren | 1a8bfa1 | 2005-11-10 14:26:50 +0000 | [diff] [blame] | 171 | unsigned long flags; |
Tony Lindgren | b824efa | 2006-04-02 17:46:20 +0100 | [diff] [blame] | 172 | int ret = -EINVAL; |
| 173 | |
| 174 | if (clk == NULL || IS_ERR(clk)) |
| 175 | return ret; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 176 | |
Tony Lindgren | 1a8bfa1 | 2005-11-10 14:26:50 +0000 | [diff] [blame] | 177 | spin_lock_irqsave(&clockfw_lock, flags); |
| 178 | if (arch_clock->clk_set_rate) |
| 179 | ret = arch_clock->clk_set_rate(clk, rate); |
| 180 | spin_unlock_irqrestore(&clockfw_lock, flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 181 | |
| 182 | return ret; |
| 183 | } |
| 184 | EXPORT_SYMBOL(clk_set_rate); |
| 185 | |
Tony Lindgren | 1a8bfa1 | 2005-11-10 14:26:50 +0000 | [diff] [blame] | 186 | int clk_set_parent(struct clk *clk, struct clk *parent) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 187 | { |
Tony Lindgren | 1a8bfa1 | 2005-11-10 14:26:50 +0000 | [diff] [blame] | 188 | unsigned long flags; |
Tony Lindgren | b824efa | 2006-04-02 17:46:20 +0100 | [diff] [blame] | 189 | int ret = -EINVAL; |
| 190 | |
| 191 | if (clk == NULL || IS_ERR(clk) || parent == NULL || IS_ERR(parent)) |
| 192 | return ret; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 193 | |
Tony Lindgren | 1a8bfa1 | 2005-11-10 14:26:50 +0000 | [diff] [blame] | 194 | spin_lock_irqsave(&clockfw_lock, flags); |
| 195 | if (arch_clock->clk_set_parent) |
| 196 | ret = arch_clock->clk_set_parent(clk, parent); |
| 197 | spin_unlock_irqrestore(&clockfw_lock, flags); |
| 198 | |
| 199 | return ret; |
| 200 | } |
| 201 | EXPORT_SYMBOL(clk_set_parent); |
| 202 | |
| 203 | struct clk *clk_get_parent(struct clk *clk) |
| 204 | { |
| 205 | unsigned long flags; |
| 206 | struct clk * ret = NULL; |
| 207 | |
Tony Lindgren | b824efa | 2006-04-02 17:46:20 +0100 | [diff] [blame] | 208 | if (clk == NULL || IS_ERR(clk)) |
| 209 | return ret; |
| 210 | |
Tony Lindgren | 1a8bfa1 | 2005-11-10 14:26:50 +0000 | [diff] [blame] | 211 | spin_lock_irqsave(&clockfw_lock, flags); |
| 212 | if (arch_clock->clk_get_parent) |
| 213 | ret = arch_clock->clk_get_parent(clk); |
| 214 | spin_unlock_irqrestore(&clockfw_lock, flags); |
| 215 | |
| 216 | return ret; |
| 217 | } |
| 218 | EXPORT_SYMBOL(clk_get_parent); |
| 219 | |
| 220 | /*------------------------------------------------------------------------- |
| 221 | * OMAP specific clock functions shared between omap1 and omap2 |
| 222 | *-------------------------------------------------------------------------*/ |
| 223 | |
| 224 | unsigned int __initdata mpurate; |
| 225 | |
| 226 | /* |
| 227 | * By default we use the rate set by the bootloader. |
| 228 | * You can override this with mpurate= cmdline option. |
| 229 | */ |
| 230 | static int __init omap_clk_setup(char *str) |
| 231 | { |
| 232 | get_option(&str, &mpurate); |
| 233 | |
| 234 | if (!mpurate) |
| 235 | return 1; |
| 236 | |
| 237 | if (mpurate < 1000) |
| 238 | mpurate *= 1000000; |
| 239 | |
| 240 | return 1; |
| 241 | } |
| 242 | __setup("mpurate=", omap_clk_setup); |
| 243 | |
| 244 | /* Used for clocks that always have same value as the parent clock */ |
| 245 | void followparent_recalc(struct clk *clk) |
| 246 | { |
Tony Lindgren | b824efa | 2006-04-02 17:46:20 +0100 | [diff] [blame] | 247 | if (clk == NULL || IS_ERR(clk)) |
| 248 | return; |
| 249 | |
Tony Lindgren | 1a8bfa1 | 2005-11-10 14:26:50 +0000 | [diff] [blame] | 250 | clk->rate = clk->parent->rate; |
| 251 | } |
| 252 | |
| 253 | /* Propagate rate to children */ |
| 254 | void propagate_rate(struct clk * tclk) |
| 255 | { |
| 256 | struct clk *clkp; |
| 257 | |
Tony Lindgren | b824efa | 2006-04-02 17:46:20 +0100 | [diff] [blame] | 258 | if (tclk == NULL || IS_ERR(tclk)) |
| 259 | return; |
| 260 | |
Tony Lindgren | 1a8bfa1 | 2005-11-10 14:26:50 +0000 | [diff] [blame] | 261 | list_for_each_entry(clkp, &clocks, node) { |
| 262 | if (likely(clkp->parent != tclk)) |
| 263 | continue; |
| 264 | if (likely((u32)clkp->recalc)) |
| 265 | clkp->recalc(clkp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 266 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 267 | } |
| 268 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 269 | int clk_register(struct clk *clk) |
| 270 | { |
Tony Lindgren | b824efa | 2006-04-02 17:46:20 +0100 | [diff] [blame] | 271 | if (clk == NULL || IS_ERR(clk)) |
| 272 | return -EINVAL; |
| 273 | |
Arjan van de Ven | 0043170 | 2006-01-12 18:42:23 +0000 | [diff] [blame] | 274 | mutex_lock(&clocks_mutex); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 275 | list_add(&clk->node, &clocks); |
| 276 | if (clk->init) |
| 277 | clk->init(clk); |
Arjan van de Ven | 0043170 | 2006-01-12 18:42:23 +0000 | [diff] [blame] | 278 | mutex_unlock(&clocks_mutex); |
Tony Lindgren | 1a8bfa1 | 2005-11-10 14:26:50 +0000 | [diff] [blame] | 279 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 280 | return 0; |
| 281 | } |
| 282 | EXPORT_SYMBOL(clk_register); |
| 283 | |
| 284 | void clk_unregister(struct clk *clk) |
| 285 | { |
Tony Lindgren | b824efa | 2006-04-02 17:46:20 +0100 | [diff] [blame] | 286 | if (clk == NULL || IS_ERR(clk)) |
| 287 | return; |
| 288 | |
Arjan van de Ven | 0043170 | 2006-01-12 18:42:23 +0000 | [diff] [blame] | 289 | mutex_lock(&clocks_mutex); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 290 | list_del(&clk->node); |
Arjan van de Ven | 0043170 | 2006-01-12 18:42:23 +0000 | [diff] [blame] | 291 | mutex_unlock(&clocks_mutex); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 292 | } |
| 293 | EXPORT_SYMBOL(clk_unregister); |
| 294 | |
Tony Lindgren | 1a8bfa1 | 2005-11-10 14:26:50 +0000 | [diff] [blame] | 295 | void clk_deny_idle(struct clk *clk) |
Tony Lindgren | bb13b5f | 2005-07-10 19:58:18 +0100 | [diff] [blame] | 296 | { |
Tony Lindgren | 1a8bfa1 | 2005-11-10 14:26:50 +0000 | [diff] [blame] | 297 | unsigned long flags; |
| 298 | |
Tony Lindgren | b824efa | 2006-04-02 17:46:20 +0100 | [diff] [blame] | 299 | if (clk == NULL || IS_ERR(clk)) |
| 300 | return; |
| 301 | |
Tony Lindgren | 1a8bfa1 | 2005-11-10 14:26:50 +0000 | [diff] [blame] | 302 | spin_lock_irqsave(&clockfw_lock, flags); |
| 303 | if (arch_clock->clk_deny_idle) |
| 304 | arch_clock->clk_deny_idle(clk); |
| 305 | spin_unlock_irqrestore(&clockfw_lock, flags); |
Tony Lindgren | bb13b5f | 2005-07-10 19:58:18 +0100 | [diff] [blame] | 306 | } |
Tony Lindgren | 1a8bfa1 | 2005-11-10 14:26:50 +0000 | [diff] [blame] | 307 | EXPORT_SYMBOL(clk_deny_idle); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 308 | |
Tony Lindgren | 1a8bfa1 | 2005-11-10 14:26:50 +0000 | [diff] [blame] | 309 | void clk_allow_idle(struct clk *clk) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 310 | { |
Tony Lindgren | 1a8bfa1 | 2005-11-10 14:26:50 +0000 | [diff] [blame] | 311 | unsigned long flags; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 312 | |
Tony Lindgren | b824efa | 2006-04-02 17:46:20 +0100 | [diff] [blame] | 313 | if (clk == NULL || IS_ERR(clk)) |
| 314 | return; |
| 315 | |
Tony Lindgren | 1a8bfa1 | 2005-11-10 14:26:50 +0000 | [diff] [blame] | 316 | spin_lock_irqsave(&clockfw_lock, flags); |
| 317 | if (arch_clock->clk_allow_idle) |
| 318 | arch_clock->clk_allow_idle(clk); |
| 319 | spin_unlock_irqrestore(&clockfw_lock, flags); |
| 320 | } |
| 321 | EXPORT_SYMBOL(clk_allow_idle); |
Tony Lindgren | bb13b5f | 2005-07-10 19:58:18 +0100 | [diff] [blame] | 322 | |
Tony Lindgren | 1a8bfa1 | 2005-11-10 14:26:50 +0000 | [diff] [blame] | 323 | /*-------------------------------------------------------------------------*/ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 324 | |
Tony Lindgren | 1a8bfa1 | 2005-11-10 14:26:50 +0000 | [diff] [blame] | 325 | int __init clk_init(struct clk_functions * custom_clocks) |
| 326 | { |
| 327 | if (!custom_clocks) { |
| 328 | printk(KERN_ERR "No custom clock functions registered\n"); |
| 329 | BUG(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 330 | } |
| 331 | |
Tony Lindgren | 1a8bfa1 | 2005-11-10 14:26:50 +0000 | [diff] [blame] | 332 | arch_clock = custom_clocks; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 333 | |
| 334 | return 0; |
| 335 | } |