1 /* arch/arm/mach-lh7a40x/clocks.c
3 * Copyright (C) 2004 Marc Singer
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.
11 #include <linux/cpufreq.h>
12 #include <mach/hardware.h>
13 #include <mach/clocks.h>
14 #include <linux/err.h>
19 struct list_head node
;
27 #define MAINDIV1(c) (((c) >> 7) & 0x0f)
28 #define MAINDIV2(c) (((c) >> 11) & 0x1f)
29 #define PS(c) (((c) >> 18) & 0x03)
30 #define PREDIV(c) (((c) >> 2) & 0x1f)
31 #define HCLKDIV(c) (((c) >> 0) & 0x02)
32 #define PCLKDIV(c) (((c) >> 16) & 0x03)
34 unsigned int cpufreq_get (unsigned int cpu
) /* in kHz */
36 return fclkfreq_get ()/1000;
38 EXPORT_SYMBOL(cpufreq_get
);
40 unsigned int fclkfreq_get (void)
42 unsigned int clkset
= CSC_CLKSET
;
46 * (MAINDIV1(clkset
) + 2)
47 / (PREDIV(clkset
) + 2)
48 * (MAINDIV2(clkset
) + 2)
53 unsigned int hclkfreq_get (void)
55 unsigned int clkset
= CSC_CLKSET
;
56 unsigned int hclk
= fclkfreq_get () / (HCLKDIV(clkset
) + 1);
61 unsigned int pclkfreq_get (void)
63 unsigned int clkset
= CSC_CLKSET
;
64 int pclkdiv
= PCLKDIV(clkset
);
68 pclk
= hclkfreq_get () / (1 << pclkdiv
);
75 struct clk
*clk_get (struct device
*dev
, const char *id
)
77 return dev
&& strcmp(dev_name(dev
), "cldc-lh7a40x") == 0
78 ? NULL
: ERR_PTR(-ENOENT
);
80 EXPORT_SYMBOL(clk_get
);
82 void clk_put (struct clk
*clk
)
85 EXPORT_SYMBOL(clk_put
);
87 int clk_enable (struct clk
*clk
)
91 EXPORT_SYMBOL(clk_enable
);
93 void clk_disable (struct clk
*clk
)
96 EXPORT_SYMBOL(clk_disable
);
98 unsigned long clk_get_rate (struct clk
*clk
)
102 EXPORT_SYMBOL(clk_get_rate
);
104 long clk_round_rate (struct clk
*clk
, unsigned long rate
)
108 EXPORT_SYMBOL(clk_round_rate
);
110 int clk_set_rate (struct clk
*clk
, unsigned long rate
)
114 EXPORT_SYMBOL(clk_set_rate
);