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.
10 #include <mach/hardware.h>
11 #include <mach/clocks.h>
12 #include <linux/err.h>
13 #include <linux/device.h>
14 #include <linux/string.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 fclkfreq_get (void)
36 unsigned int clkset = CSC_CLKSET;
40 * (MAINDIV1(clkset) + 2)
41 / (PREDIV(clkset) + 2)
42 * (MAINDIV2(clkset) + 2)
47 unsigned int hclkfreq_get (void)
49 unsigned int clkset = CSC_CLKSET;
50 unsigned int hclk = fclkfreq_get () / (HCLKDIV(clkset) + 1);
55 unsigned int pclkfreq_get (void)
57 unsigned int clkset = CSC_CLKSET;
58 int pclkdiv = PCLKDIV(clkset);
62 pclk = hclkfreq_get () / (1 << pclkdiv);
69 struct clk *clk_get (struct device *dev, const char *id)
71 return dev && strcmp(dev_name(dev), "cldc-lh7a40x") == 0
72 ? NULL : ERR_PTR(-ENOENT);
74 EXPORT_SYMBOL(clk_get);
76 void clk_put (struct clk *clk)
79 EXPORT_SYMBOL(clk_put);
81 int clk_enable (struct clk *clk)
85 EXPORT_SYMBOL(clk_enable);
87 void clk_disable (struct clk *clk)
90 EXPORT_SYMBOL(clk_disable);
92 unsigned long clk_get_rate (struct clk *clk)
96 EXPORT_SYMBOL(clk_get_rate);
98 long clk_round_rate (struct clk *clk, unsigned long rate)
102 EXPORT_SYMBOL(clk_round_rate);
104 int clk_set_rate (struct clk *clk, unsigned long rate)
108 EXPORT_SYMBOL(clk_set_rate);