summaryrefslogtreecommitdiff
path: root/arch/arm/plat-omap/include/syslink/notify_driverdefs.h
blob: 0e79562d0867e1d0a41ab4e45f78e99994d107e4 (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
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
/*
 * notify_driverdefs.h
 *
 * Notify driver support for OMAP Processors.
 *
 * Copyright (C) 2008-2009 Texas Instruments, Inc.
 *
 * This package is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 as
 * published by the Free Software Foundation.
 *
 * THIS PACKAGE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
 * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
 * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
 */


#if !defined NOTIFYDRIVERDEFS_H
#define NOTIFYDRIVERDEFS_H


#include <syslink/host_os.h>

/*  ----------------------------------- Notify */
#include <syslink/notify.h>
#include <syslink/notify_shmdriver.h>
#include <syslink/notifydefs.h>
#include <syslink/multiproc.h>

#define NOTIFY_BASE_CMD		(0x100)

/*
 *  Command for Notify_getConfig
 */
#define CMD_NOTIFY_GETCONFIG		(NOTIFY_BASE_CMD + 1u)

/*
 *  Command for Notify_setup
 */
#define CMD_NOTIFY_SETUP		(NOTIFY_BASE_CMD + 2u)

/*
 *  Command for Notify_destroy
 */
#define CMD_NOTIFY_DESTROY		(NOTIFY_BASE_CMD + 3u)

/*
 *  Command for Notify_registerEvent
 */
#define CMD_NOTIFY_REGISTEREVENT	 (NOTIFY_BASE_CMD + 4u)

/*
 *  Command for Notify_unregisterEvent
 */
#define CMD_NOTIFY_UNREGISTEREVENT	 (NOTIFY_BASE_CMD + 5u)

/*
 *  Command for Notify_sendEvent
 */
#define CMD_NOTIFY_SENDEVENT		(NOTIFY_BASE_CMD + 6u)

/*
 *  Command for Notify_disable
 */
#define CMD_NOTIFY_DISABLE		(NOTIFY_BASE_CMD + 7u)

/*
 *  Command for Notify_restore
 */
#define CMD_NOTIFY_RESTORE		(NOTIFY_BASE_CMD + 8u)

/*
 *  Command for Notify_disableEvent
 */
#define CMD_NOTIFY_DISABLEEVENT	(NOTIFY_BASE_CMD + 9u)

/*
 *  Command for Notify_enableEvent
 */
#define CMD_NOTIFY_ENABLEEVENT	(NOTIFY_BASE_CMD + 10u)

/*!
 *  @brief  Command for Notify_attach
 */
#define CMD_NOTIFY_ATTACH                    (NOTIFY_BASE_CMD + 11u)

/*!
 *  @brief  Command for Notify_detach
 */
#define CMD_NOTIFY_DETACH                    (NOTIFY_BASE_CMD + 12u)

/*
 *  const  NOTIFY_SYSTEM_KEY_MASK
 *
 *  desc   Mask to check for system key.
 *
 */

#define NOTIFY_SYSTEM_KEY_MASK	(unsigned short int) 0xFFFF0000

/*
 *  const  NOTIFY_EVENT_MASK
 *
 *  desc   Mask to check for event ID.
 *
 */

#define NOTIFY_EVENT_MASK	(unsigned short int) 0x0000FFFF

struct notify_cmd_args {
	int apiStatus;
	/* Status of the API being called. */
};

/*
 * Command arguments for Notify_getConfig
 */
struct notify_cmd_args_get_config {
	struct notify_cmd_args commonArgs;
	struct notify_config *cfg;
};

/*
 * Command arguments for Notify_setup
 */
struct notify_cmd_args_setup {
	struct notify_cmd_args commonArgs;
	struct notify_config *cfg;
};

/*
 * Command arguments for Notify_destroy
 */
struct notify_cmd_args_destroy {
	struct notify_cmd_args commonArgs;
};

/*
 * Command arguments for Notify_registerEvent
 */
struct notify_cmd_args_register_event {
	struct notify_cmd_args commonArgs;
	struct notify_driver_object *handle;
	u16 procId;
	u32 eventNo;
	notify_callback_fxn fnNotifyCbck;
	void *cbckArg;
	u32 pid;
};

/*
 * Command arguments for Notify_unregisterEvent
 */
struct notify_cmd_args_unregister_event {
	struct notify_cmd_args		commonArgs;
	struct notify_driver_object *handle;
	u16 procId;
	u32 eventNo;
	notify_callback_fxn fnNotifyCbck;
	void *cbckArg;
	u32 pid;
};

/*
 * Command arguments for Notify_sendEvent
 */
struct notify_cmd_args_send_event {
	struct notify_cmd_args commonArgs;
	struct notify_driver_object *handle;
	u16 procId;
	u32 eventNo;
	u32 payload;
	bool waitClear;
};

/*
 * Command arguments for Notify_disable
 */
struct notify_cmd_args_disable {
	struct notify_cmd_args commonArgs;
	u16 procId;
	u32 flags;
};

/*
 * Command arguments for Notify_restore
 */
struct notify_cmd_args_restore {
	struct notify_cmd_args commonArgs;
	u32 key;
	u16 procId;
};

/*
 * Command arguments for Notify_disableEvent
 */
struct notify_cmd_args_disable_event {
	struct notify_cmd_args commonArgs;
	struct notify_driver_object *handle;
	u16 procId;
	u32 eventNo;
};

/*
 * Command arguments for Notify_enableEvent
 */
struct notify_cmd_args_enable_event {
	struct notify_cmd_args commonArgs;
	void *notify_driver_handle;
	u16 procId;
	u32 eventNo;
};

/*
 * Command arguments for Notify_exit
 */
struct notify_cmd_args_exit {
	struct notify_cmd_args commonArgs;
};


enum {
	NOTIFY_DRIVERINITSTATUS_NOTDONE = 0,
	/* Driver initialization is not done. */
	NOTIFY_DRIVERINITSTATUS_DONE = 1,
	/* Driver initialization is complete. */
	NOTIFY_DRIVERINITSTATUS_INPROGRESS = 2,
	/* Driver initialization is in progress. */
	NOTIFY_DRIVERINITSTATUS_ENDVALUE = 3
	/* End delimiter indicating start of invalid values for this enum */
};

/*
 *This structure defines information for all processors supported by
 *the Notify driver.
 *An instance of this object is provided for each processor handled by
 *the Notify driver, when registering itself with the Notify module.
 *
 */
struct notify_driver_proc_info {
	u32 max_events;
	u32 reserved_events;
	bool event_priority;
	u32 payload_size;
	u16 proc_id;
};

/*
 * This structure defines the structure for specifying Notify driver
 * attributes to the Notify module.
 * This structure provides information about the Notify driver to the
 * Notify module. The information is used by the Notify module mainly
 * for parameter validation. It may also be used by the Notify module
 * to take appropriate action if required, based on the characteristics
 * of the Notify driver.
 */
struct notify_driver_attrs {
	u32 numProc;
	struct notify_driver_proc_info
				proc_info[MULTIPROC_MAXPROCESSORS];
};


/* ========================================
 *  Function pointer types
 * ========================================
 */
/*
 * This type defines the function to register a callback for an event
 *  with the Notify driver.
 *  This function gets called internally from the Notify_registerEvent
 *  API. The Notify_registerEvent () function passes on the
 *  request into the Notify driver identified by the Notify Handle.
 *
 */
typedef int(*NotifyDriver_RegisterEvent)(struct notify_driver_object *handle,
		u16 procId, u32 eventNo, notify_callback_fxn cbckFxn,
		void *cbckArg);
/*
 * This type defines the function to unregister a callback for an event
 *  with the Notify driver.
 *  This function gets called internally from the Notify_unregisterEvent
 *  API. The Notify_unregisterEvent () function passes on the
 *  request into the Notify driver identified by the Notify Handle.
 *
 */
typedef int(*NotifyDriver_UnregisterEvent) (struct notify_driver_object *handle,
		u16 procId, u32 eventNo, notify_callback_fxn  cbckFxn,
		void *cbckArg);

/*
 * This type defines the function to send a notification event to the
 *  registered users for this notification on the specified processor.
 *  This function gets called internally from the Notify_sendEvent ()
 *  API. The Notify_sendEvent () function passes on the initialization
 *  request into the Notify driver identified by the Notify Handle.
 */
typedef int(*NotifyDriver_SendEvent) (struct notify_driver_object *handle,
		u16 procId, u32 eventNo, u32 payload, bool waitClear);

/*
 * This type defines the function to disable all events for the
 *  specified processor ID.
 *  This function gets called internally from the Notify_disable ()
 *  API. The Notify_disable () function passes on the request into the
 *  Notify driver identified by the Notify Handle.
 */
typedef u32(*NotifyDriver_Disable) (struct notify_driver_object *handle,
							u16 procId);

/*
 * This type defines the function to restore all events for the
 *  specified processor ID.
 *  This function gets called internally from the Notify_restore ()
 *  API. The Notify_restore () function passes on the request into the
 *  Notify driver identified by the Notify Handle.
 */
typedef void (*NotifyDriver_Restore) (struct notify_driver_object *handle,
				u32 key, u16 procId);

/*
 * This type defines the function to disable specified event for the
 *  specified processor ID.
 *  This function gets called internally from the Notify_disableEvent ()
 *  API. The Notify_disableEvent () function passes on the request into
 *  the Notify driver identified by the Notify Handle.
 */
typedef void (*NotifyDriver_DisableEvent) (struct notify_driver_object *handle,
			u16 procId, u32 eventNo);

/*
 * This type defines the function to enable specified event for the
 *  specified processor ID.
 *  This function gets called internally from the Notify_enableEvent ()
 *  API. The Notify_enableEvent () function passes on the request into
 *  the Notify driver identified by the Notify Handle.
 *
 */
typedef void (*NotifyDriver_EnableEvent) (struct notify_driver_object *handle,
		u16 procId, u32 eventNo);


/*
 * This structure defines the function table interface for the Notify
 * driver.
 * This function table interface must be implemented by each Notify
 * driver and registered with the Notify module.
 *
 */
struct notify_interface {
	NotifyDriver_RegisterEvent register_event;
	/* interface function registerEvent  */
	NotifyDriver_UnregisterEvent unregister_event;
	/* interface function unregisterEvent  */
	NotifyDriver_SendEvent send_event;
	/* interface function sendEvent  */
	NotifyDriver_Disable disable;
	/* interface function disable  */
	NotifyDriver_Restore restore;
	/* interface function restore  */
	NotifyDriver_DisableEvent disable_event;
	/* interface function disableEvent  */
	NotifyDriver_EnableEvent enable_event;
};


union notify_drv_procevents{
	struct {
		struct notify_shmdrv_attrs  attrs;
		struct notify_shmdrv_ctrl *ctrl_ptr;
       } shm_events;

	struct {
		/*Attributes */
		unsigned long int  num_events;
		unsigned long int  send_event_pollcount;
		/*Control Paramters */
		unsigned long int send_init_status ;
		struct notify_shmdrv_eventreg_mask  reg_mask ;
	} non_shm_events;
};


/*
 * This structure defines the Notify driver object and handle used
 * internally to contain all information required for the Notify driver
 * This object contains all information for the Notify module to be
 * able to identify and interact with the Notify driver.
 */
struct notify_driver_object {
	int is_init;
	struct notify_interface fn_table;
	char name[NOTIFY_MAX_NAMELEN];
	struct notify_driver_attrs attrs;
	u32 *disable_flag[NOTIFY_MAXNESTDEPTH];
	void *driver_object;
};


struct notify_drv_eventlist {
       unsigned long int event_handler_count;
       struct list_head listeners;
};



struct notify_drv_eventlistner{
	struct list_head element;
	fn_notify_cbck fn_notify_cbck;
	void *cbck_arg;
};


struct notify_drv_proc_module {

       unsigned long int proc_id;
       struct notify_drv_eventlist *event_list;
       struct notify_shmdrv_eventreg *reg_chart;
       union notify_drv_procevents events_obj;
};

/*
 *  Defines the Notify state object, which contains all the module
 *  specific information.
 */
struct notify_module_object {
	atomic_t ref_count;
	struct notify_config cfg;
	/* Notify configuration structure */
	struct notify_config def_cfg;
	/* Default module configuration */
	struct mutex *gate_handle;
	/* Handle of gate to be used for local thread safety */
	struct notify_driver_object drivers[NOTIFY_MAX_DRIVERS];
	/* Array of configured drivers. */
	u32 disable_depth;
	/* Current disable depth for Notify module. */
};
#endif  /* !defined (NOTIFYDRIVERDEFS_H) */