2006-03-15 08:54:37 -07:00
|
|
|
/*
|
|
|
|
* linux/arch/arm/mach-sa1100/clock.c
|
|
|
|
*/
|
|
|
|
#include <linux/module.h>
|
|
|
|
#include <linux/kernel.h>
|
|
|
|
#include <linux/clk.h>
|
|
|
|
#include <linux/spinlock.h>
|
2007-08-20 03:18:02 -06:00
|
|
|
#include <linux/delay.h>
|
2010-11-17 02:04:33 -07:00
|
|
|
#include <linux/clkdev.h>
|
2006-03-15 08:54:37 -07:00
|
|
|
|
2007-08-20 03:18:02 -06:00
|
|
|
#include "clock.h"
|
2006-03-15 08:54:37 -07:00
|
|
|
|
|
|
|
static DEFINE_SPINLOCK(clocks_lock);
|
|
|
|
|
|
|
|
int clk_enable(struct clk *clk)
|
|
|
|
{
|
|
|
|
unsigned long flags;
|
|
|
|
|
|
|
|
spin_lock_irqsave(&clocks_lock, flags);
|
|
|
|
if (clk->enabled++ == 0)
|
2007-08-20 03:18:02 -06:00
|
|
|
clk->ops->enable(clk);
|
2006-03-15 08:54:37 -07:00
|
|
|
spin_unlock_irqrestore(&clocks_lock, flags);
|
2007-08-20 03:18:02 -06:00
|
|
|
|
|
|
|
if (clk->delay)
|
|
|
|
udelay(clk->delay);
|
|
|
|
|
2006-03-15 08:54:37 -07:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
EXPORT_SYMBOL(clk_enable);
|
|
|
|
|
|
|
|
void clk_disable(struct clk *clk)
|
|
|
|
{
|
|
|
|
unsigned long flags;
|
|
|
|
|
|
|
|
WARN_ON(clk->enabled == 0);
|
|
|
|
|
|
|
|
spin_lock_irqsave(&clocks_lock, flags);
|
|
|
|
if (--clk->enabled == 0)
|
2007-08-20 03:18:02 -06:00
|
|
|
clk->ops->disable(clk);
|
2006-03-15 08:54:37 -07:00
|
|
|
spin_unlock_irqrestore(&clocks_lock, flags);
|
|
|
|
}
|
|
|
|
EXPORT_SYMBOL(clk_disable);
|
|
|
|
|
|
|
|
unsigned long clk_get_rate(struct clk *clk)
|
|
|
|
{
|
2007-08-20 03:18:02 -06:00
|
|
|
unsigned long rate;
|
|
|
|
|
|
|
|
rate = clk->rate;
|
|
|
|
if (clk->ops->getrate)
|
|
|
|
rate = clk->ops->getrate(clk);
|
|
|
|
|
|
|
|
return rate;
|
2006-03-15 08:54:37 -07:00
|
|
|
}
|
|
|
|
EXPORT_SYMBOL(clk_get_rate);
|
|
|
|
|
2010-11-21 19:49:55 -07:00
|
|
|
void clk_dummy_enable(struct clk *clk)
|
2006-03-15 08:54:37 -07:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2010-11-21 19:49:55 -07:00
|
|
|
void clk_dummy_disable(struct clk *clk)
|
2006-03-15 08:54:37 -07:00
|
|
|
{
|
2007-08-20 03:18:02 -06:00
|
|
|
}
|
|
|
|
|
2010-11-21 19:49:55 -07:00
|
|
|
const struct clkops clk_dummy_ops = {
|
|
|
|
.enable = clk_dummy_enable,
|
|
|
|
.disable = clk_dummy_disable,
|
|
|
|
};
|
|
|
|
|
|
|
|
struct clk clk_dummy = {
|
|
|
|
.ops = &clk_dummy_ops,
|
2007-08-20 03:18:02 -06:00
|
|
|
};
|