blob: 855e945c61997750d87ca478f020c7dcf9217e70 [file] [log] [blame]
Magnus Damm79714ac2009-07-03 10:08:05 +00001#ifndef __ASM_SH_HWBLK_H
2#define __ASM_SH_HWBLK_H
3
4#include <asm/clock.h>
5#include <asm/io.h>
6
Magnus Damm0f8ee182009-07-17 14:24:55 +00007#define HWBLK_CNT_USAGE 0
Magnus Damm6a93dde2009-08-14 10:48:16 +00008#define HWBLK_CNT_IDLE 1
9#define HWBLK_CNT_DEVICES 2
10#define HWBLK_CNT_NR 3
Magnus Damm0f8ee182009-07-17 14:24:55 +000011
Magnus Damm79714ac2009-07-03 10:08:05 +000012#define HWBLK_AREA_FLAG_PARENT (1 << 0) /* valid parent */
13
14#define HWBLK_AREA(_flags, _parent) \
15{ \
16 .flags = _flags, \
17 .parent = _parent, \
18}
19
20struct hwblk_area {
Magnus Damm0f8ee182009-07-17 14:24:55 +000021 int cnt[HWBLK_CNT_NR];
Magnus Damm79714ac2009-07-03 10:08:05 +000022 unsigned char parent;
23 unsigned char flags;
24};
25
26#define HWBLK(_mstp, _bit, _area) \
27{ \
28 .mstp = (void __iomem *)_mstp, \
29 .bit = _bit, \
30 .area = _area, \
31}
32
33struct hwblk {
34 void __iomem *mstp;
35 unsigned char bit;
36 unsigned char area;
Magnus Damm0f8ee182009-07-17 14:24:55 +000037 int cnt[HWBLK_CNT_NR];
Magnus Damm79714ac2009-07-03 10:08:05 +000038};
39
40struct hwblk_info {
41 struct hwblk_area *areas;
42 int nr_areas;
43 struct hwblk *hwblks;
44 int nr_hwblks;
45};
46
47/* Should be defined by processor-specific code */
48int arch_hwblk_init(void);
49int arch_hwblk_sleep_mode(void);
50
51int hwblk_register(struct hwblk_info *info);
52int hwblk_init(void);
53
Magnus Damm0f8ee182009-07-17 14:24:55 +000054void hwblk_enable(struct hwblk_info *info, int hwblk);
55void hwblk_disable(struct hwblk_info *info, int hwblk);
56
57void hwblk_cnt_inc(struct hwblk_info *info, int hwblk, int cnt);
58void hwblk_cnt_dec(struct hwblk_info *info, int hwblk, int cnt);
59
Magnus Damm79714ac2009-07-03 10:08:05 +000060/* allow clocks to enable and disable hardware blocks */
Magnus Damm08134c32010-05-10 14:01:44 +000061#define SH_HWBLK_CLK(_hwblk, _parent, _flags) \
62[_hwblk] = { \
63 .parent = _parent, \
64 .arch_flags = _hwblk, \
65 .flags = _flags, \
Magnus Damm79714ac2009-07-03 10:08:05 +000066}
67
68int sh_hwblk_clk_register(struct clk *clks, int nr);
69
70#endif /* __ASM_SH_HWBLK_H */