blob: c01d72cb6757ec68374086b9ebafc41eee6bfafb [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
8#define HWBLK_CNT_NR 1
9
Magnus Damm79714ac2009-07-03 10:08:05 +000010#define HWBLK_AREA_FLAG_PARENT (1 << 0) /* valid parent */
11
12#define HWBLK_AREA(_flags, _parent) \
13{ \
14 .flags = _flags, \
15 .parent = _parent, \
16}
17
18struct hwblk_area {
Magnus Damm0f8ee182009-07-17 14:24:55 +000019 int cnt[HWBLK_CNT_NR];
Magnus Damm79714ac2009-07-03 10:08:05 +000020 unsigned char parent;
21 unsigned char flags;
22};
23
24#define HWBLK(_mstp, _bit, _area) \
25{ \
26 .mstp = (void __iomem *)_mstp, \
27 .bit = _bit, \
28 .area = _area, \
29}
30
31struct hwblk {
32 void __iomem *mstp;
33 unsigned char bit;
34 unsigned char area;
Magnus Damm0f8ee182009-07-17 14:24:55 +000035 int cnt[HWBLK_CNT_NR];
Magnus Damm79714ac2009-07-03 10:08:05 +000036};
37
38struct hwblk_info {
39 struct hwblk_area *areas;
40 int nr_areas;
41 struct hwblk *hwblks;
42 int nr_hwblks;
43};
44
45/* Should be defined by processor-specific code */
46int arch_hwblk_init(void);
47int arch_hwblk_sleep_mode(void);
48
49int hwblk_register(struct hwblk_info *info);
50int hwblk_init(void);
51
Magnus Damm0f8ee182009-07-17 14:24:55 +000052void hwblk_enable(struct hwblk_info *info, int hwblk);
53void hwblk_disable(struct hwblk_info *info, int hwblk);
54
55void hwblk_cnt_inc(struct hwblk_info *info, int hwblk, int cnt);
56void hwblk_cnt_dec(struct hwblk_info *info, int hwblk, int cnt);
57
Magnus Damm79714ac2009-07-03 10:08:05 +000058/* allow clocks to enable and disable hardware blocks */
59#define SH_HWBLK_CLK(_name, _id, _parent, _hwblk, _flags) \
60{ \
61 .name = _name, \
62 .id = _id, \
63 .parent = _parent, \
64 .arch_flags = _hwblk, \
65 .flags = _flags, \
66}
67
68int sh_hwblk_clk_register(struct clk *clks, int nr);
69
70#endif /* __ASM_SH_HWBLK_H */