2 * linux/arch/arm/mach-sa1100/clock.c
4 #include <linux/module.h>
5 #include <linux/kernel.h>
6 #include <linux/device.h>
7 #include <linux/list.h>
8 #include <linux/errno.h>
10 #include <linux/string.h>
11 #include <linux/clk.h>
12 #include <linux/spinlock.h>
13 #include <linux/mutex.h>
15 #include <mach/hardware.h>
18 * Very simple clock implementation - we only have one clock to deal with.
24 static void clk_gpio27_enable(void)
27 * First, set up the 3.6864MHz clock on GPIO 27 for the SA-1111:
28 * (SA-1110 Developer's Manual, section 9.1.2.1)
30 GAFR
|= GPIO_32_768kHz
;
31 GPDR
|= GPIO_32_768kHz
;
32 TUCR
= TUCR_3_6864MHz
;
35 static void clk_gpio27_disable(void)
38 GPDR
&= ~GPIO_32_768kHz
;
39 GAFR
&= ~GPIO_32_768kHz
;
42 static struct clk clk_gpio27
;
44 static DEFINE_SPINLOCK(clocks_lock
);
46 struct clk
*clk_get(struct device
*dev
, const char *id
)
48 const char *devname
= dev_name(dev
);
50 return strcmp(devname
, "sa1111.0") ? ERR_PTR(-ENOENT
) : &clk_gpio27
;
52 EXPORT_SYMBOL(clk_get
);
54 void clk_put(struct clk
*clk
)
57 EXPORT_SYMBOL(clk_put
);
59 int clk_enable(struct clk
*clk
)
63 spin_lock_irqsave(&clocks_lock
, flags
);
64 if (clk
->enabled
++ == 0)
66 spin_unlock_irqrestore(&clocks_lock
, flags
);
69 EXPORT_SYMBOL(clk_enable
);
71 void clk_disable(struct clk
*clk
)
75 WARN_ON(clk
->enabled
== 0);
77 spin_lock_irqsave(&clocks_lock
, flags
);
78 if (--clk
->enabled
== 0)
80 spin_unlock_irqrestore(&clocks_lock
, flags
);
82 EXPORT_SYMBOL(clk_disable
);
84 unsigned long clk_get_rate(struct clk
*clk
)
88 EXPORT_SYMBOL(clk_get_rate
);