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
|
/*
* cfg.c
*
* DSP-BIOS Bridge driver support functions for TI OMAP processors.
*
* Implementation of platform specific config services.
*
* Copyright (C) 2005-2006 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.
*/
#include <linux/types.h>
/* ----------------------------------- DSP/BIOS Bridge */
#include <dspbridge/dbdefs.h>
/* ----------------------------------- Trace & Debug */
#include <dspbridge/dbc.h>
/* ----------------------------------- OS Adaptation Layer */
/* ----------------------------------- This */
#include <dspbridge/cfg.h>
#include <dspbridge/drv.h>
struct drv_ext {
struct list_head link;
char sz_string[MAXREGPATHLENGTH];
};
/*
* ======== cfg_exit ========
* Purpose:
* Discontinue usage of the CFG module.
*/
void cfg_exit(void)
{
/* Do nothing */
}
/*
* ======== cfg_get_auto_start ========
* Purpose:
* Retreive the autostart mask, if any, for this board.
*/
int cfg_get_auto_start(struct cfg_devnode *dev_node_obj,
OUT u32 *auto_start)
{
int status = 0;
u32 dw_buf_size;
struct drv_data *drv_datap = dev_get_drvdata(bridge);
dw_buf_size = sizeof(*auto_start);
if (!dev_node_obj)
status = -EFAULT;
if (!auto_start || !drv_datap)
status = -EFAULT;
if (DSP_SUCCEEDED(status))
*auto_start = (drv_datap->base_img) ? 1 : 0;
DBC_ENSURE((status == 0 &&
(*auto_start == 0 || *auto_start == 1))
|| status != 0);
return status;
}
/*
* ======== cfg_get_dev_object ========
* Purpose:
* Retrieve the Device Object handle for a given devnode.
*/
int cfg_get_dev_object(struct cfg_devnode *dev_node_obj,
OUT u32 *value)
{
int status = 0;
u32 dw_buf_size;
struct drv_data *drv_datap = dev_get_drvdata(bridge);
if (!drv_datap)
status = -EPERM;
if (!dev_node_obj)
status = -EFAULT;
if (!value)
status = -EFAULT;
dw_buf_size = sizeof(value);
if (DSP_SUCCEEDED(status)) {
/* check the device string and then store dev object */
if (!
(strcmp
((char *)((struct drv_ext *)dev_node_obj)->sz_string,
"TIOMAP1510")))
*value = (u32)drv_datap->dev_object;
}
if (DSP_FAILED(status))
pr_err("%s: Failed, status 0x%x\n", __func__, status);
return status;
}
/*
* ======== cfg_get_exec_file ========
* Purpose:
* Retreive the default executable, if any, for this board.
*/
int cfg_get_exec_file(struct cfg_devnode *dev_node_obj, u32 buf_size,
OUT char *str_exec_file)
{
int status = 0;
struct drv_data *drv_datap = dev_get_drvdata(bridge);
if (!dev_node_obj)
status = -EFAULT;
else if (!str_exec_file || !drv_datap)
status = -EFAULT;
if (strlen(drv_datap->base_img) > buf_size)
status = -EINVAL;
if (DSP_SUCCEEDED(status) && drv_datap->base_img)
strcpy(str_exec_file, drv_datap->base_img);
if (DSP_FAILED(status))
pr_err("%s: Failed, status 0x%x\n", __func__, status);
DBC_ENSURE(((status == 0) &&
(strlen(str_exec_file) <= buf_size))
|| (status != 0));
return status;
}
/*
* ======== cfg_get_object ========
* Purpose:
* Retrieve the Object handle from the Registry
*/
int cfg_get_object(OUT u32 *value, u8 dw_type)
{
int status = -EINVAL;
struct drv_data *drv_datap = dev_get_drvdata(bridge);
DBC_REQUIRE(value != NULL);
if (!drv_datap)
return -EPERM;
switch (dw_type) {
case (REG_DRV_OBJECT):
if (drv_datap->drv_object) {
*value = (u32)drv_datap->drv_object;
status = 0;
} else {
status = -ENODATA;
}
break;
case (REG_MGR_OBJECT):
if (drv_datap->mgr_object) {
*value = (u32)drv_datap->mgr_object;
status = 0;
} else {
status = -ENODATA;
}
break;
default:
break;
}
if (DSP_FAILED(status)) {
*value = 0;
pr_err("%s: Failed, status 0x%x\n", __func__, status);
}
DBC_ENSURE((DSP_SUCCEEDED(status) && *value != 0) ||
(DSP_FAILED(status) && *value == 0));
return status;
}
/*
* ======== cfg_init ========
* Purpose:
* Initialize the CFG module's private state.
*/
bool cfg_init(void)
{
return true;
}
/*
* ======== cfg_set_dev_object ========
* Purpose:
* Store the Device Object handle and dev_node pointer for a given devnode.
*/
int cfg_set_dev_object(struct cfg_devnode *dev_node_obj, u32 value)
{
int status = 0;
struct drv_data *drv_datap = dev_get_drvdata(bridge);
if (!drv_datap) {
pr_err("%s: Failed, status 0x%x\n", __func__, status);
return -EPERM;
}
if (!dev_node_obj)
status = -EFAULT;
if (DSP_SUCCEEDED(status)) {
/* Store the Bridge device object in the Registry */
if (!(strcmp((char *)dev_node_obj, "TIOMAP1510")))
drv_datap->dev_object = (void *) value;
}
if (DSP_FAILED(status))
pr_err("%s: Failed, status 0x%x\n", __func__, status);
return status;
}
/*
* ======== cfg_set_object ========
* Purpose:
* Store the Driver Object handle
*/
int cfg_set_object(u32 value, u8 dw_type)
{
int status = -EINVAL;
struct drv_data *drv_datap = dev_get_drvdata(bridge);
if (!drv_datap)
return -EPERM;
switch (dw_type) {
case (REG_DRV_OBJECT):
drv_datap->drv_object = (void *)value;
status = 0;
break;
case (REG_MGR_OBJECT):
drv_datap->mgr_object = (void *)value;
status = 0;
break;
default:
break;
}
if (DSP_FAILED(status))
pr_err("%s: Failed, status 0x%x\n", __func__, status);
return status;
}
|