mmsys_pwrmgr.h
5.24 KB
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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
/*****************************************************************************
* Copyright Statement:
* --------------------
* This software is protected by Copyright and the information contained
* herein is confidential. The software may not be copied and the information
* contained herein may not be used or disclosed except with the written
* permission of MediaTek Inc. (C) 2001
*
*****************************************************************************/
/*****************************************************************************
*
* Filename:
* ---------
* mmsys_pwrmgr.h
*
* Project:
* --------
* MAUI
*
* Description:
* ------------
* Header file for mm_power_ctrl
*
* Author:
* -------
* -------
*
*============================================================================
* HISTORY
* Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
*------------------------------------------------------------------------------
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
*------------------------------------------------------------------------------
* Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
*============================================================================
****************************************************************************/
#ifndef __DRV_MMSYS_H__
#define __DRV_MMSYS_H__
#include "kal_public_api.h"
#include "reg_base.h"
#include "Drvpdn.h"
#if defined(DRV_FEATURE__MM_POWER_CTRL_IF)
enum { MMPWRMGR_OPT_32BIT_REG = 0x01, MMPWRMGR_OPT_16BIT_REG = 0x02, MMPWRMGR_OPT_NEVER_OFF = 0x04 };
//#define MMPWRMGR_MAX_DEV 32
/*
* NoteXXX: MAUI Codegen doesn't support C99. It is not allowed to use (kal_int32)
* cast when defining enum value.
* But ADS linker will produce compile warning if not cast.
* Use GEN_FOR_PC option to solve the problem.
*/
/*******************************************************************************
* MMSYSPMG device ID
*******************************************************************************/
typedef enum {
#define X_MMPWRMGR_USER(a, b, c, d, e, f) MMPWRMGR_##a,
#define X_MMPWRMGR_DUMMY(a, b, c, d, e, f) MMPWRMGR_##a,
#include "mmsys_pwrmgr_def.h"
#undef X_MMPWRMGR_USER
#undef X_MMPWRMGR_DUMMY
MMPWRMGR_MAX_DEV_END
} MMPWRMGR_DEVICE;
#define MMPMG_MAP_TABLE_ENTRY_NUM MMPWRMGR_MAX_DEV
extern kal_uint32 MMPWRMGR_CON_REG_TABLE[MMPMG_MAP_TABLE_ENTRY_NUM];
extern kal_uint32 MMPWRMGR_SET_REG_TABLE[MMPMG_MAP_TABLE_ENTRY_NUM];
extern kal_uint32 MMPWRMGR_CLR_REG_TABLE[MMPMG_MAP_TABLE_ENTRY_NUM];
extern kal_uint32 MMPWRMGR_REG_WIDTH_TABLE[MMPMG_MAP_TABLE_ENTRY_NUM];
extern kal_uint32 MMPWRMGR_REG_BIT_TABLE[MMPMG_MAP_TABLE_ENTRY_NUM];
#if 0
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
#endif
/*******************************************************************************
* Define macros
*******************************************************************************/
/*
* MMPWRMGR_SET(kal_uint32 dev): power down device
* @dev: device ID (EX: MMPWRMGR_UART1)
*/
#define MMPWRMGR_SET(dev) \
do { \
if (MMPWRMGR_REG_WIDTH_TABLE[dev] & MMPWRMGR_OPT_32BIT_REG) { \
*(volatile kal_uint32 *)(MMPWRMGR_SET_REG_TABLE[dev]) = (kal_uint32)(MMPWRMGR_REG_BIT_TABLE[dev]); \
} else { \
*(volatile kal_uint16 *)(MMPWRMGR_SET_REG_TABLE[dev]) = (kal_uint16)(MMPWRMGR_REG_BIT_TABLE[dev]); \
} \
} while (0)
/*
* MMSYSPMG_CLR(kal_uint32 dev): power up device
* @dev: device ID (EX: MMSYSPMG_UART1)
*/
#define MMPWRMGR_CLR(dev) \
do { \
if (MMPWRMGR_REG_WIDTH_TABLE[dev] & MMPWRMGR_OPT_32BIT_REG) { \
*(volatile kal_uint32 *)(MMPWRMGR_CLR_REG_TABLE[dev]) = (kal_uint32)(MMPWRMGR_REG_BIT_TABLE[dev]); \
} else { \
*(volatile kal_uint16 *)(MMPWRMGR_CLR_REG_TABLE[dev]) = (kal_uint16)(MMPWRMGR_REG_BIT_TABLE[dev]); \
} \
} while (0)
/*
* MMSYSPMG_STATUS(kal_uint32 dev, type s, type): get device power down status
* @dev: device ID (EX: MMSYSPMG_UART1)
* @s: returned power down status
* @t: type of s
*/
#define MMPWRMGR_STATUS(dev, s, t) \
do { \
if (MMPWRMGR_REG_WIDTH_TABLE[dev]& MMPWRMGR_OPT_32BIT_REG) { \
(s) = (t)(*(volatile kal_uint32 *)(MMPWRMGR_CON_REG_TABLE[dev]) & MMPWRMGR_REG_BIT_TABLE[dev]); \
} else { \
(s) = (t)(*(volatile kal_uint16 *)(MMPWRMGR_CON_REG_TABLE[dev]) & MMPWRMGR_REG_BIT_TABLE[dev]); \
} \
} while (0)
#endif //#if defined(DRV_FEATURE__MM_POWER_CTRL_IF)
#endif //__DRV_MMSYS_H__