2 * linux/arch/arm/mach-w90x900/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>
24 #include <mach/hardware.h>
30 static DEFINE_SPINLOCK(clocks_lock);
32 int clk_enable(struct clk *clk)
36 spin_lock_irqsave(&clocks_lock, flags);
37 if (clk->enabled++ == 0)
38 (clk->enable)(clk, 1);
39 spin_unlock_irqrestore(&clocks_lock, flags);
43 EXPORT_SYMBOL(clk_enable);
45 void clk_disable(struct clk *clk)
52 WARN_ON(clk->enabled == 0);
54 spin_lock_irqsave(&clocks_lock, flags);
55 if (--clk->enabled == 0)
56 (clk->enable)(clk, 0);
57 spin_unlock_irqrestore(&clocks_lock, flags);
59 EXPORT_SYMBOL(clk_disable);
61 unsigned long clk_get_rate(struct clk *clk)
65 EXPORT_SYMBOL(clk_get_rate);
67 void nuc900_clk_enable(struct clk *clk, int enable)
69 unsigned int clocks = clk->cken;
72 clken = __raw_readl(W90X900_VA_CLKPWR);
79 __raw_writel(clken, W90X900_VA_CLKPWR);
82 void nuc900_subclk_enable(struct clk *clk, int enable)
84 unsigned int clocks = clk->cken;
87 clken = __raw_readl(W90X900_VA_CLKPWR + SUBCLK);
94 __raw_writel(clken, W90X900_VA_CLKPWR + SUBCLK);
97 /* dummy functions, should not be called */
98 long clk_round_rate(struct clk *clk, unsigned long rate)
103 EXPORT_SYMBOL(clk_round_rate);
105 int clk_set_rate(struct clk *clk, unsigned long rate)
110 EXPORT_SYMBOL(clk_set_rate);
112 int clk_set_parent(struct clk *clk, struct clk *parent)
117 EXPORT_SYMBOL(clk_set_parent);
119 struct clk *clk_get_parent(struct clk *clk)
124 EXPORT_SYMBOL(clk_get_parent);