[ARM] OMAP3 clock: avoid invalid FREQSEL values during DPLL rate rounding
[linux-ginger.git] / arch / arm / mach-integrator / clock.c
blob989ecf5f5c4685a9b8afedf0677e8e0a88d63f82
1 /*
2 * linux/arch/arm/mach-integrator/clock.c
4 * Copyright (C) 2004 ARM Limited.
5 * Written by Deep Blue Solutions Limited.
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.
11 #include <linux/module.h>
12 #include <linux/kernel.h>
13 #include <linux/errno.h>
14 #include <linux/clk.h>
15 #include <linux/mutex.h>
17 #include <asm/clkdev.h>
18 #include <mach/clkdev.h>
20 int clk_enable(struct clk *clk)
22 return 0;
24 EXPORT_SYMBOL(clk_enable);
26 void clk_disable(struct clk *clk)
29 EXPORT_SYMBOL(clk_disable);
31 unsigned long clk_get_rate(struct clk *clk)
33 return clk->rate;
35 EXPORT_SYMBOL(clk_get_rate);
37 long clk_round_rate(struct clk *clk, unsigned long rate)
39 struct icst525_vco vco;
40 vco = icst525_khz_to_vco(clk->params, rate / 1000);
41 return icst525_khz(clk->params, vco) * 1000;
43 EXPORT_SYMBOL(clk_round_rate);
45 int clk_set_rate(struct clk *clk, unsigned long rate)
47 int ret = -EIO;
49 if (clk->setvco) {
50 struct icst525_vco vco;
52 vco = icst525_khz_to_vco(clk->params, rate / 1000);
53 clk->rate = icst525_khz(clk->params, vco) * 1000;
54 clk->setvco(clk, vco);
55 ret = 0;
57 return ret;
59 EXPORT_SYMBOL(clk_set_rate);