summaryrefslogtreecommitdiff
path: root/drivers/dsp/syslink/omap_notify/plat/omap4_notify_setup.c
blob: f62d0ad588473fdf56d44cfc1f2d14cc9f7c91ea (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
/*
 * omap4_notify_setup.c
 *
 * OMAP4 device-specific functions to setup the Notify module.
 *
 * 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.
 */

/* Linux headers */
#include <linux/spinlock.h>
/*#include <linux/module.h>
#include <linux/init.h>
#include <linux/fs.h>
#include <linux/mm.h>
#include <linux/uaccess.h>
#include <linux/io.h>
#include <asm/pgtable.h>*/

/* Module headers */
#include <syslink/multiproc.h>

#include <syslink/notify.h>
#include <syslink/notify_setup_proxy.h>
#include <syslink/notify_ducatidriver.h>
#include <syslink/notify_driver.h>
#include <syslink/notifydefs.h>


/* Handle to the NotifyDriver for line 0 */
static struct notify_ducatidrv_object *notify_setup_driver_handles[
						MULTIPROC_MAXPROCESSORS];

/* Handle to the Notify objects */
static
struct notify_object *notify_setup_notify_handles[MULTIPROC_MAXPROCESSORS];


/* Function to perform device specific setup for Notify module.
 * This function creates the Notify drivers. */
int notify_setup_omap4_attach(u16 proc_id, void *shared_addr)
{
	s32 status = NOTIFY_S_SUCCESS;
	struct notify_ducatidrv_params notify_shm_params;

	if (WARN_ON(unlikely(shared_addr == NULL))) {
		status = NOTIFY_E_INVALIDARG;
		goto exit;
	}
	if (WARN_ON(unlikely(proc_id == multiproc_self()))) {
		status = NOTIFY_E_INVALIDARG;
		goto exit;
	}

	notify_ducatidrv_params_init(&notify_shm_params);

	/* Currently not supporting caching on host side. */
	notify_shm_params.cache_enabled = false;
	notify_shm_params.line_id = 0;
	notify_shm_params.local_int_id = 77u; /* TBD: Ipc_getConfig */
	notify_shm_params.remote_int_id = 0u; /* TBD: Ipc_getConfig */
	notify_shm_params.remote_proc_id = proc_id;
	notify_shm_params.shared_addr = shared_addr;

	notify_setup_driver_handles[proc_id] = notify_ducatidrv_create(
							&notify_shm_params);
	if (notify_setup_driver_handles[proc_id] == NULL) {
		status = NOTIFY_E_FAIL;
		pr_err("notify_setup_omap4_attach: "
			"notify_ducatidrv_create failed! status = 0x%x",
			status);
		goto exit;
	}

	notify_setup_notify_handles[proc_id] = \
			notify_create(notify_setup_driver_handles[proc_id],
					proc_id, 0u, NULL);
	if (notify_setup_notify_handles[proc_id] == NULL) {
		status = NOTIFY_E_FAIL;
		pr_err("notify_setup_omap4_attach: notify_create "
			"failed!");
		goto exit;
	}

exit:
	if (status < 0) {
		pr_err("notify_setup_omap4_attach failed! "
			"status = 0x%x", status);
	}
	return status;
}


/* Function to perform device specific destroy for Notify module.
 * This function deletes the Notify drivers. */
int notify_setup_omap4_detach(u16 proc_id)
{
	s32 status = NOTIFY_S_SUCCESS;
	s32 tmp_status = NOTIFY_S_SUCCESS;

	if (WARN_ON(unlikely(proc_id == multiproc_self()))) {
		status = NOTIFY_E_INVALIDARG;
		goto exit;
	}

	/* Delete the notify driver to the M3 (Line 0) */
	status = notify_delete(&(notify_setup_notify_handles[proc_id]));
	if (status < 0) {
		pr_err("notify_setup_omap4_detach: notify_delete "
			"failed for line 0!");
	}

	tmp_status = notify_ducatidrv_delete(
				&(notify_setup_driver_handles[proc_id]));
	if ((tmp_status < 0) && (status >= 0)) {
		status = tmp_status;
		pr_err("notify_setup_omap4_detach: "
			"notify_ducatidrv_delete failed for line 0!");
	}

exit:
	if (status < 0) {
		pr_err("notify_setup_omap4_detach failed! "
			"status = 0x%x", status);
	}
	return status;
}


/* Return the amount of shared memory required  */
uint notify_setup_omap4_shared_mem_req(u16 remote_proc_id, void *shared_addr)
{
	int status = NOTIFY_S_SUCCESS;
	uint mem_req = 0x0;
	struct notify_ducatidrv_params params;

	if (WARN_ON(unlikely(shared_addr == NULL))) {
		status = NOTIFY_E_INVALIDARG;
		goto exit;
	}

	notify_ducatidrv_params_init(&params);
	params.shared_addr = shared_addr;

	mem_req = notify_ducatidrv_shared_mem_req(&params);

exit:
	if (status < 0) {
		pr_err("notify_setup_omap4_shared_mem_req failed!"
			" status = 0x%x", status);
	}
	return mem_req;
}

bool notify_setup_omap4_int_line_available(u16 remote_proc_id)
{
	return true;
}