const: constify remaining dev_pm_ops
[linux-2.6-block.git] / arch / arm / mach-lh7a40x / clocks.c
CommitLineData
638b2666
MS
1/* arch/arm/mach-lh7a40x/clocks.c
2 *
3 * Copyright (C) 2004 Marc Singer
4 *
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * version 2 as published by the Free Software Foundation.
8 *
9 */
a09e64fb
RK
10#include <mach/hardware.h>
11#include <mach/clocks.h>
638b2666
MS
12#include <linux/err.h>
13
14struct module;
638b2666
MS
15
16struct clk {
17 struct list_head node;
18 unsigned long rate;
19 struct module *owner;
20 const char *name;
638b2666
MS
21};
22
638b2666
MS
23/* ----- */
24
25#define MAINDIV1(c) (((c) >> 7) & 0x0f)
26#define MAINDIV2(c) (((c) >> 11) & 0x1f)
27#define PS(c) (((c) >> 18) & 0x03)
28#define PREDIV(c) (((c) >> 2) & 0x1f)
29#define HCLKDIV(c) (((c) >> 0) & 0x02)
30#define PCLKDIV(c) (((c) >> 16) & 0x03)
31
638b2666
MS
32unsigned int fclkfreq_get (void)
33{
34 unsigned int clkset = CSC_CLKSET;
35 unsigned int gclk
36 = XTAL_IN
37 / (1 << PS(clkset))
38 * (MAINDIV1(clkset) + 2)
39 / (PREDIV(clkset) + 2)
40 * (MAINDIV2(clkset) + 2)
41 ;
42 return gclk;
43}
44
45unsigned int hclkfreq_get (void)
46{
47 unsigned int clkset = CSC_CLKSET;
48 unsigned int hclk = fclkfreq_get () / (HCLKDIV(clkset) + 1);
49
50 return hclk;
51}
52
53unsigned int pclkfreq_get (void)
54{
55 unsigned int clkset = CSC_CLKSET;
56 int pclkdiv = PCLKDIV(clkset);
57 unsigned int pclk;
58 if (pclkdiv == 0x3)
59 pclkdiv = 0x2;
60 pclk = hclkfreq_get () / (1 << pclkdiv);
61
62 return pclk;
63}
64
65/* ----- */
66
638b2666
MS
67struct clk *clk_get (struct device *dev, const char *id)
68{
80a5931b
RK
69 return dev && strcmp(dev_name(dev), "cldc-lh7a40x") == 0
70 ? NULL : ERR_PTR(-ENOENT);
638b2666
MS
71}
72EXPORT_SYMBOL(clk_get);
73
74void clk_put (struct clk *clk)
75{
638b2666
MS
76}
77EXPORT_SYMBOL(clk_put);
78
79int clk_enable (struct clk *clk)
80{
81 return 0;
82}
83EXPORT_SYMBOL(clk_enable);
84
85void clk_disable (struct clk *clk)
86{
87}
88EXPORT_SYMBOL(clk_disable);
89
638b2666
MS
90unsigned long clk_get_rate (struct clk *clk)
91{
80a5931b 92 return 0;
638b2666
MS
93}
94EXPORT_SYMBOL(clk_get_rate);
95
96long clk_round_rate (struct clk *clk, unsigned long rate)
97{
98 return rate;
99}
100EXPORT_SYMBOL(clk_round_rate);
101
102int clk_set_rate (struct clk *clk, unsigned long rate)
103{
80a5931b 104 return -EIO;
638b2666
MS
105}
106EXPORT_SYMBOL(clk_set_rate);