Merge remote-tracking branch 'moduleh/module.h-split'
[linux-2.6/next.git] / arch / arm / mach-nuc93x / clock.c
blob0521efbc48c95bca3bcc0700330c637723a4c192
1 /*
2 * linux/arch/arm/mach-nuc93x/clock.c
4 * Copyright (c) 2008 Nuvoton technology corporation
6 * Wan ZongShun <mcuos.com@gmail.com>
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License.
13 #include <linux/module.h>
14 #include <linux/kernel.h>
15 #include <linux/list.h>
16 #include <linux/errno.h>
17 #include <linux/err.h>
18 #include <linux/string.h>
19 #include <linux/clk.h>
20 #include <linux/spinlock.h>
21 #include <linux/platform_device.h>
22 #include <linux/io.h>
24 #include <mach/hardware.h>
26 #include "clock.h"
28 static DEFINE_SPINLOCK(clocks_lock);
30 int clk_enable(struct clk *clk)
32 unsigned long flags;
34 spin_lock_irqsave(&clocks_lock, flags);
35 if (clk->enabled++ == 0)
36 (clk->enable)(clk, 1);
37 spin_unlock_irqrestore(&clocks_lock, flags);
39 return 0;
41 EXPORT_SYMBOL(clk_enable);
43 void clk_disable(struct clk *clk)
45 unsigned long flags;
47 WARN_ON(clk->enabled == 0);
49 spin_lock_irqsave(&clocks_lock, flags);
50 if (--clk->enabled == 0)
51 (clk->enable)(clk, 0);
52 spin_unlock_irqrestore(&clocks_lock, flags);
54 EXPORT_SYMBOL(clk_disable);
56 unsigned long clk_get_rate(struct clk *clk)
58 return 27000000;
60 EXPORT_SYMBOL(clk_get_rate);
62 void nuc93x_clk_enable(struct clk *clk, int enable)
64 unsigned int clocks = clk->cken;
65 unsigned long clken;
67 clken = __raw_readl(NUC93X_VA_CLKPWR);
69 if (enable)
70 clken |= clocks;
71 else
72 clken &= ~clocks;
74 __raw_writel(clken, NUC93X_VA_CLKPWR);
77 void clks_register(struct clk_lookup *clks, size_t num)
79 int i;
81 for (i = 0; i < num; i++)
82 clkdev_add(&clks[i]);