blob: 149b30cd1469f5af01038d7b9351065004ea331c [file] [log] [blame]
Eric Miao49cbe782009-01-20 14:15:18 +08001/*
2 * linux/arch/arm/mach-mmp/clock.h
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation.
7 */
8
Jean-Christop PLAGNIOL-VILLARD6d803ba2010-11-17 10:04:33 +01009#include <linux/clkdev.h>
Eric Miao49cbe782009-01-20 14:15:18 +080010
11struct clkops {
12 void (*enable)(struct clk *);
13 void (*disable)(struct clk *);
14 unsigned long (*getrate)(struct clk *);
Haojian Zhuang52585cc2011-04-08 20:15:38 +080015 int (*setrate)(struct clk *, unsigned long);
Eric Miao49cbe782009-01-20 14:15:18 +080016};
17
18struct clk {
19 const struct clkops *ops;
20
21 void __iomem *clk_rst; /* clock reset control register */
22 int fnclksel; /* functional clock select (APBC) */
23 uint32_t enable_val; /* value for clock enable (APMU) */
24 unsigned long rate;
25 int enabled;
26};
27
28extern struct clkops apbc_clk_ops;
Haojian Zhuang40928552009-09-10 14:01:22 +080029extern struct clkops apmu_clk_ops;
Eric Miao49cbe782009-01-20 14:15:18 +080030
31#define APBC_CLK(_name, _reg, _fnclksel, _rate) \
32struct clk clk_##_name = { \
Arnd Bergmann97b09da2011-10-01 22:03:45 +020033 .clk_rst = APBC_##_reg, \
Eric Miao49cbe782009-01-20 14:15:18 +080034 .fnclksel = _fnclksel, \
35 .rate = _rate, \
36 .ops = &apbc_clk_ops, \
37}
38
39#define APBC_CLK_OPS(_name, _reg, _fnclksel, _rate, _ops) \
40struct clk clk_##_name = { \
Arnd Bergmann97b09da2011-10-01 22:03:45 +020041 .clk_rst = APBC_##_reg, \
Eric Miao49cbe782009-01-20 14:15:18 +080042 .fnclksel = _fnclksel, \
43 .rate = _rate, \
44 .ops = _ops, \
45}
46
47#define APMU_CLK(_name, _reg, _eval, _rate) \
48struct clk clk_##_name = { \
Arnd Bergmann97b09da2011-10-01 22:03:45 +020049 .clk_rst = APMU_##_reg, \
Eric Miao49cbe782009-01-20 14:15:18 +080050 .enable_val = _eval, \
51 .rate = _rate, \
52 .ops = &apmu_clk_ops, \
53}
54
55#define APMU_CLK_OPS(_name, _reg, _eval, _rate, _ops) \
56struct clk clk_##_name = { \
Arnd Bergmann97b09da2011-10-01 22:03:45 +020057 .clk_rst = APMU_##_reg, \
Eric Miao49cbe782009-01-20 14:15:18 +080058 .enable_val = _eval, \
59 .rate = _rate, \
60 .ops = _ops, \
61}
62
63#define INIT_CLKREG(_clk, _devname, _conname) \
64 { \
65 .clk = _clk, \
66 .dev_id = _devname, \
67 .con_id = _conname, \
68 }
69
70extern struct clk clk_pxa168_gpio;
71extern struct clk clk_pxa168_timers;