diff options
author | wanzongshun <mcuos.com@gmail.com> | 2009-06-10 10:50:44 -0400 |
---|---|---|
committer | Russell King <rmk+kernel@arm.linux.org.uk> | 2009-06-11 09:45:18 -0400 |
commit | 0e4a34bb6565346a8d7cc56cab412a1f98d5b1cd (patch) | |
tree | d0a7ec7e72bde2b9b9a4650fe311d5f22163ee26 /arch/arm/mach-w90x900/clock.c | |
parent | c52d3d688b09c50de12cb2fbdfebb18b3b664b00 (diff) |
[ARM] 5549/1: Add clock api for w90p910 platform.
Add clock api for w90p910 platform.
Signed-off-by: Wan ZongShun <mcuos.com@gmail.com>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Diffstat (limited to 'arch/arm/mach-w90x900/clock.c')
-rw-r--r-- | arch/arm/mach-w90x900/clock.c | 77 |
1 files changed, 77 insertions, 0 deletions
diff --git a/arch/arm/mach-w90x900/clock.c b/arch/arm/mach-w90x900/clock.c new file mode 100644 index 000000000000..f420613cd395 --- /dev/null +++ b/arch/arm/mach-w90x900/clock.c | |||
@@ -0,0 +1,77 @@ | |||
1 | /* | ||
2 | * linux/arch/arm/mach-w90x900/clock.c | ||
3 | * | ||
4 | * Copyright (c) 2008 Nuvoton technology corporation | ||
5 | * | ||
6 | * Wan ZongShun <mcuos.com@gmail.com> | ||
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 as published by | ||
10 | * the Free Software Foundation; either version 2 of the License. | ||
11 | */ | ||
12 | |||
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> | ||
23 | |||
24 | #include <mach/hardware.h> | ||
25 | |||
26 | #include "clock.h" | ||
27 | |||
28 | static DEFINE_SPINLOCK(clocks_lock); | ||
29 | |||
30 | int clk_enable(struct clk *clk) | ||
31 | { | ||
32 | unsigned long flags; | ||
33 | |||
34 | spin_lock_irqsave(&clocks_lock, flags); | ||
35 | if (clk->enabled++ == 0) | ||
36 | (clk->enable)(clk, 1); | ||
37 | spin_unlock_irqrestore(&clocks_lock, flags); | ||
38 | |||
39 | return 0; | ||
40 | } | ||
41 | EXPORT_SYMBOL(clk_enable); | ||
42 | |||
43 | void clk_disable(struct clk *clk) | ||
44 | { | ||
45 | unsigned long flags; | ||
46 | |||
47 | WARN_ON(clk->enabled == 0); | ||
48 | |||
49 | spin_lock_irqsave(&clocks_lock, flags); | ||
50 | if (--clk->enabled == 0) | ||
51 | (clk->enable)(clk, 0); | ||
52 | spin_unlock_irqrestore(&clocks_lock, flags); | ||
53 | } | ||
54 | EXPORT_SYMBOL(clk_disable); | ||
55 | |||
56 | void w90x900_clk_enable(struct clk *clk, int enable) | ||
57 | { | ||
58 | unsigned int clocks = clk->cken; | ||
59 | unsigned long clken; | ||
60 | |||
61 | clken = __raw_readl(W90X900_VA_CLKPWR); | ||
62 | |||
63 | if (enable) | ||
64 | clken |= clocks; | ||
65 | else | ||
66 | clken &= ~clocks; | ||
67 | |||
68 | __raw_writel(clken, W90X900_VA_CLKPWR); | ||
69 | } | ||
70 | |||
71 | void clks_register(struct clk_lookup *clks, size_t num) | ||
72 | { | ||
73 | int i; | ||
74 | |||
75 | for (i = 0; i < num; i++) | ||
76 | clkdev_add(&clks[i]); | ||
77 | } | ||