aboutsummaryrefslogtreecommitdiff
path: root/arch/sh/include/asm/hwblk.h
blob: e29461bbe84d3b67950c7144fbd5de44c4c8f7d0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#ifndef __ASM_SH_HWBLK_H
#define __ASM_SH_HWBLK_H

#include <asm/clock.h>
#include <asm/io.h>

#define HWBLK_CNT_USAGE 0
#define HWBLK_CNT_IDLE 1
#define HWBLK_CNT_DEVICES 2
#define HWBLK_CNT_NR 3

#define HWBLK_AREA_FLAG_PARENT (1 << 0) /* valid parent */

#define HWBLK_AREA(_flags, _parent)		\
{						\
	.flags = _flags,			\
	.parent = _parent,			\
}

struct hwblk_area {
	int cnt[HWBLK_CNT_NR];
	unsigned char parent;
	unsigned char flags;
};

#define HWBLK(_mstp, _bit, _area)		\
{						\
	.mstp = (void __iomem *)_mstp,		\
	.bit = _bit,				\
	.area = _area,				\
}

struct hwblk {
	void __iomem *mstp;
	unsigned char bit;
	unsigned char area;
	int cnt[HWBLK_CNT_NR];
};

struct hwblk_info {
	struct hwblk_area *areas;
	int nr_areas;
	struct hwblk *hwblks;
	int nr_hwblks;
};

#if !defined(CONFIG_CPU_SUBTYPE_SH7722) && \
    !defined(CONFIG_CPU_SUBTYPE_SH7723) && \
    !defined(CONFIG_CPU_SUBTYPE_SH7724)
/* Should be defined by processor-specific code */
int arch_hwblk_init(void);
int arch_hwblk_sleep_mode(void);

int hwblk_register(struct hwblk_info *info);
int hwblk_init(void);

void hwblk_enable(struct hwblk_info *info, int hwblk);
void hwblk_disable(struct hwblk_info *info, int hwblk);

void hwblk_cnt_inc(struct hwblk_info *info, int hwblk, int cnt);
void hwblk_cnt_dec(struct hwblk_info *info, int hwblk, int cnt);

/* allow clocks to enable and disable hardware blocks */
#define SH_HWBLK_CLK(_hwblk, _parent, _flags)	\
[_hwblk] = {					\
	.parent		= _parent,		\
	.arch_flags	= _hwblk,		\
	.flags		= _flags,		\
}

int sh_hwblk_clk_register(struct clk *clks, int nr);
#else
#define hwblk_init() 0
#endif
#endif /* __ASM_SH_HWBLK_H */