blob: 5c8b6564fdc225ff49970cf5768f5cc2db1a733a [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
Russell Kingf4b8b312010-01-14 12:48:06 +00002 * linux/arch/arm/plat-versatile/clock.c
Linus Torvalds1da177e2005-04-16 15:20:36 -07003 *
4 * Copyright (C) 2004 ARM Limited.
5 * Written by Deep Blue Solutions Limited.
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation.
10 */
11#include <linux/module.h>
12#include <linux/kernel.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070013#include <linux/errno.h>
Russell Kingf8ce2542006-01-07 16:15:52 +000014#include <linux/clk.h>
Arjan van de Ven00431702006-01-12 18:42:23 +000015#include <linux/mutex.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070016
Russell Kingc5a0adb2010-01-16 20:16:10 +000017#include <asm/hardware/icst.h>
Russell Kingf4b8b312010-01-14 12:48:06 +000018
Russell Kingd72fbdf2008-11-08 20:08:08 +000019#include <mach/clkdev.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070020
21int clk_enable(struct clk *clk)
22{
23 return 0;
24}
25EXPORT_SYMBOL(clk_enable);
26
27void clk_disable(struct clk *clk)
28{
29}
30EXPORT_SYMBOL(clk_disable);
31
Linus Torvalds1da177e2005-04-16 15:20:36 -070032unsigned long clk_get_rate(struct clk *clk)
33{
34 return clk->rate;
35}
36EXPORT_SYMBOL(clk_get_rate);
37
38long clk_round_rate(struct clk *clk, unsigned long rate)
39{
Russell King9bf5b2e2010-03-01 16:18:39 +000040 long ret = -EIO;
41 if (clk->ops && clk->ops->round)
42 ret = clk->ops->round(clk, rate);
43 return ret;
Linus Torvalds1da177e2005-04-16 15:20:36 -070044}
45EXPORT_SYMBOL(clk_round_rate);
46
47int clk_set_rate(struct clk *clk, unsigned long rate)
48{
49 int ret = -EIO;
Russell King9bf5b2e2010-03-01 16:18:39 +000050 if (clk->ops && clk->ops->set)
51 ret = clk->ops->set(clk, rate);
Russell Kingd72fbdf2008-11-08 20:08:08 +000052 return ret;
Linus Torvalds1da177e2005-04-16 15:20:36 -070053}
54EXPORT_SYMBOL(clk_set_rate);
Russell King9bf5b2e2010-03-01 16:18:39 +000055
56long icst_clk_round(struct clk *clk, unsigned long rate)
57{
58 struct icst_vco vco;
59 vco = icst_hz_to_vco(clk->params, rate);
60 return icst_hz(clk->params, vco);
61}
62EXPORT_SYMBOL(icst_clk_round);
63
64int icst_clk_set(struct clk *clk, unsigned long rate)
65{
66 struct icst_vco vco;
67
68 vco = icst_hz_to_vco(clk->params, rate);
69 clk->rate = icst_hz(clk->params, vco);
70 clk->ops->setvco(clk, vco);
71
72 return 0;
73}
74EXPORT_SYMBOL(icst_clk_set);