summaryrefslogtreecommitdiff
path: root/include/asm-arm/arch-mxc/mxc_mu.h
blob: e07aab0f50853045a5f1f614f9a58d613b2b20ae (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
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
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
/*
 * Copyright 2004-2007 Freescale Semiconductor, Inc. All Rights Reserved.
 */

/*
 * The code contained herein is licensed under the GNU Lesser General
 * Public License.  You may obtain a copy of the GNU Lesser General
 * Public License Version 2.1 or later at the following locations:
 *
 * http://www.opensource.org/licenses/lgpl-license.html
 * http://www.gnu.org/copyleft/lgpl.html
 */

/*!
 * @defgroup MU Messaging Unit (MU) Driver
 */

/*!
 * @file arch-mxc/mxc_mu.h
 *
 * @brief This file contains the MU chip level configuration details and
 * public API declarations.
 *
 * @ingroup MU
 */

#ifndef __ASM_ARCH_MXC_MU_H__
#define __ASM_ARCH_MXC_MU_H__

#ifdef __KERNEL__

#include <asm/hardware.h>

/* MU configuration */

/*!
 * Number of channels in MU indicated using NUM_MU_CHANNELS
 */
#define NUM_MU_CHANNELS          4

/*!
 * Channel transmit/receive size indicated using CH_SIZE
 */
#define CH_SIZE                  4

/*!
 * Maximum Buffer Size is a sequence of 16, 32, 64, 128,256,...
 * ie., a value where only the MSB is 1. The value should be a
 * power of 2. It should be noted that the buffer is filled and
 * emptied as multiples of 4 bytes. Also, 4 bytes of the total allocated
 * space will not be used since empty space calculation always returns
 * available space minus 1 inorder to differentiate between full and empty
 * buffer.
 */
#define MAX_BUF_SIZE             1024
#endif				/* __KERNEL__ */

/*!
 * IOCTL commands
 */

/*!
 * SENDINT      : To issue general purpose interrupt to DSP
 */
#define SENDINT                  1

/*!
 * SENDNMI      : To issue NMI to DSP
 */
#define SENDNMI                  2

/*!
 * SENDDSPRESET : To issue DSP Hardware Reset
 */
#define SENDDSPRESET             3

/*!
 * SENDMURESET  : To issue MU Reset
 */
#define SENDMURESET              4

/*!
 * RXENABLE     : To enable receive interrupt
 */
#define RXENABLE                 5

/*!
 * TXENABLE     : To enable transmit interrupt
 */
#define TXENABLE                 6

/*!
 * GPENABLE     : To enable general purpose interrupt
 */
#define GPENABLE                 7

/*!
 * BYTESWAP_RD  : To enable byte swapping on read
 */
#define BYTESWAP_RD              8

/*!
 * BYTESWAP_WR  : To enable byte swapping on write
 */
#define BYTESWAP_WR               9

/*!
 * Error Indicators
 */
/*!
 * Error: NO_DATA: If no data is available in receive register or
 * if no transmit register is empty, this error is returned
 */
#define NO_DATA                  129

/*!
 * Error: NO_ACCESS: If user is accessing an incorrect register i.e., a register
 * not allocated to user, this error is returned
 */
#define NO_ACCESS                132

/*!
 * enum mu_oper
 * This datatype is to indicate whether the operation
 * related to receive, transmit or general purpose
 */
enum mu_oper {
	TX,
	RX,
	GP,
};

/*!
 * To declare array of function pointers of type callbackfn
 */
typedef void (*callbackfn) (int chnum);

#ifdef __KERNEL__
/*!
 * This function is called by other modules to bind their
 * call back functions.
 *
 * @param   chand         The channel handler associated with the channel
 *                        to be accessed is passed
 * @param   callback      the caller's callback function
 * @param   muoper        The value passed is TX, RX, GP
 *
 * @return                Returns 0 on success or REG_INVALID error if invalid
 *                        channel is obtained from the channel handler
 *                        Returns -1 if muoper is other than RX, TX or GP
 */
int mxc_mu_bind(int chand, callbackfn callback, enum mu_oper muoper);

/*!
 * This function is called by other modules to unbind their
 * call back functions
 *
 * @param   chand    The channel handler associated with the channel
 *                   to be accessed is passed
 * @param   muoper   The value passed is TX, RX, GP
 *
 * @return           Returns 0 on success or REG_INVALID error if invalid
 *                   channel is obtained from the channel handler
 *                   Returns -1 if muoper is other than RX, TX or GP, or
 *                   if disabling interrupt failed
 */
int mxc_mu_unbind(int chand, enum mu_oper muoper);

/*!
 * Allocating Resources:
 * Allocating channels required to the caller if they are free.
 * 'reg_allocated' variable holds all the registers that have been allocated
 *
 * @param   chnum   The channel number required is passed
 *
 * @return          Returns unique channel handler associated with channel. This
 *                  channel handler is used to validate the user accessing the
 *                  channel.
 *                  If invalid channel is passed, it returns REG_INVALID error.
 *                  If no channel is available, returns error.
 *                  Returns channel handler - on success
 *                  Returns -1 - on error
 */
int mxc_mu_alloc_channel(int chnum);

/*!
 * Deallocating Resources:
 *
 * @param   chand   The channel handler associated with the channel
 *                  that is to be freed is passed.
 *
 * @return          Returns 0 on success and -1 if channel was not
 *                  already allocated or REG_INVALID error if invalid
 *                  channel is obtained from the channel handler
 */
int mxc_mu_dealloc_channel(int chand);

/*!
 * This function is called by other modules to read from one of the
 * receive registers on the MCU side.
 *
 * @param   chand         The channel handler associated with the channel
 *                        to be accessed is passed
 * @param   mu_msg        Buffer where the read data has to be stored
 *                        is passed by pointer as an argument
 *
 * @return                Returns 0 on success or
 *                        Returns NO_DATA error if there is no data to read or
 *                        Returns NO_ACCESS error if the incorrect channel
 *                        is accessed or REG_INVALID error if invalid
 *                        channel is obtained from the channel handler
 *                        Returns -1 if the buffer passed is not allocated
 */
int mxc_mu_mcuread(int chand, char *mu_msg);

/*!
 * This function is called by other modules to write to one of the
 * transmit registers on the MCU side
 *
 * @param   chand         The channel handler associated with the channel
 *                        to be accessed is passed
 * @param   mu_msg        Buffer where the write data has to be stored
 *                        is passed by pointer as an argument
 *
 * @return                Returns 0 on success or
 *                        Returns NO_DATA error if the register not empty or
 *                        Returns NO_ACCESS error if the incorrect channel
 *                        is accessed or REG_INVALID error if invalid
 *                        channel is obtained from the channel handler
 *                        Returns -1 if the buffer passed is not allocated
 */
int mxc_mu_mcuwrite(int chand, char *mu_msg);

/*!
 * This function is called by the user and other modules to enable desired
 * interrupt
 *
 * @param   chand     The channel handler associated with the channel
 *                    to be accessed is passed
 * @param    muoper   The value passed is TX, RX, GP
 *
 * @return           Returns 0 on success or REG_INVALID error if invalid
 *                   channel is obtained from the channel handler
 *                   Returns -1 if muoper is other than RX, TX or GP
 */
int mxc_mu_intenable(int chand, enum mu_oper muoper);

/*!
 * This function is called by unbind function of this module and
 * can also be called from other modules to enable desired
 * receive Interrupt
 *
 * @param   chand    The channel handler associated with the channel
 *                   whose interrupt to be disabled is passed
 * @param   muoper   The value passed is TX, RX, GP
 *
 * @return           Returns 0 on success or REG_INVALID error if invalid
 *                   channel is obtained from the channel handler
 *                   Returns -1 if muoper is other than RX, TX or GP
 */
int mxc_mu_intdisable(int chand, enum mu_oper muoper);

/*!
 * This function is used by other modules to reset the MU Unit. This would reset
 * both the MCU side and the DSP side
 */
int mxc_mu_reset(void);

/*!
 * This function is used by other modules to issue DSP hardware reset.
 */
int mxc_mu_dsp_reset(void);

/*!
 * This function is used by other modules to deassert DSP hardware reset.
 */
int mxc_mu_dsp_deassert(void);

/*!
 * This function is used by other modules to issue DSP Non-Maskable
 * Interrupt to the DSP
 */
int mxc_mu_dsp_nmi(void);

/*!
 * This function is used by other modules to retrieve the DSP reset state.
 *
 * @return   Returns 1 if DSP in reset state and 0 otherwise
 */
int mxc_mu_dsp_reset_status(void);

/*!
 * This function is used by other modules to retrieve the DSP Power Mode.
 *
 * @return   Returns a value from which power mode of the DSP side of
 *           of MU unit can be inferred
 *           0 - Run mode,  1 - Wait mode
 *           2 - Stop mode, 3 - DSM mode
 */
unsigned int mxc_mu_dsp_pmode_status(void);

#endif				/* __KERNEL__ */

#endif				/* __ASM_ARCH_MXC_MU_H__ */