GUI: Fix Tomato RAF theme for all builds. Compilation typo.
[tomato.git] / release / src-rt-6.x.4708 / linux / linux-2.6.36 / drivers / staging / tidspbridge / services / cfg.c
bloba7af74f482dd8df0257d88e8eaf9299288b79896
1 /*
2 * cfg.c
4 * DSP-BIOS Bridge driver support functions for TI OMAP processors.
6 * Implementation of platform specific config services.
8 * Copyright (C) 2005-2006 Texas Instruments, Inc.
10 * This package is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License version 2 as
12 * published by the Free Software Foundation.
14 * THIS PACKAGE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
15 * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
16 * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
19 #include <linux/types.h>
21 /* ----------------------------------- DSP/BIOS Bridge */
22 #include <dspbridge/dbdefs.h>
24 /* ----------------------------------- Trace & Debug */
25 #include <dspbridge/dbc.h>
27 /* ----------------------------------- OS Adaptation Layer */
29 /* ----------------------------------- This */
30 #include <dspbridge/cfg.h>
31 #include <dspbridge/drv.h>
33 struct drv_ext {
34 struct list_head link;
35 char sz_string[MAXREGPATHLENGTH];
39 * ======== cfg_exit ========
40 * Purpose:
41 * Discontinue usage of the CFG module.
43 void cfg_exit(void)
45 /* Do nothing */
49 * ======== cfg_get_auto_start ========
50 * Purpose:
51 * Retreive the autostart mask, if any, for this board.
53 int cfg_get_auto_start(struct cfg_devnode *dev_node_obj,
54 u32 *auto_start)
56 int status = 0;
57 u32 dw_buf_size;
58 struct drv_data *drv_datap = dev_get_drvdata(bridge);
60 dw_buf_size = sizeof(*auto_start);
61 if (!dev_node_obj)
62 status = -EFAULT;
63 if (!auto_start || !drv_datap)
64 status = -EFAULT;
65 if (!status)
66 *auto_start = (drv_datap->base_img) ? 1 : 0;
68 DBC_ENSURE((status == 0 &&
69 (*auto_start == 0 || *auto_start == 1))
70 || status != 0);
71 return status;
75 * ======== cfg_get_dev_object ========
76 * Purpose:
77 * Retrieve the Device Object handle for a given devnode.
79 int cfg_get_dev_object(struct cfg_devnode *dev_node_obj,
80 u32 *value)
82 int status = 0;
83 u32 dw_buf_size;
84 struct drv_data *drv_datap = dev_get_drvdata(bridge);
86 if (!drv_datap)
87 status = -EPERM;
89 if (!dev_node_obj)
90 status = -EFAULT;
92 if (!value)
93 status = -EFAULT;
95 dw_buf_size = sizeof(value);
96 if (!status) {
98 /* check the device string and then store dev object */
99 if (!
100 (strcmp
101 ((char *)((struct drv_ext *)dev_node_obj)->sz_string,
102 "TIOMAP1510")))
103 *value = (u32)drv_datap->dev_object;
105 if (status)
106 pr_err("%s: Failed, status 0x%x\n", __func__, status);
107 return status;
111 * ======== cfg_get_exec_file ========
112 * Purpose:
113 * Retreive the default executable, if any, for this board.
115 int cfg_get_exec_file(struct cfg_devnode *dev_node_obj, u32 buf_size,
116 char *str_exec_file)
118 int status = 0;
119 struct drv_data *drv_datap = dev_get_drvdata(bridge);
121 if (!dev_node_obj)
122 status = -EFAULT;
124 else if (!str_exec_file || !drv_datap)
125 status = -EFAULT;
127 if (strlen(drv_datap->base_img) > buf_size)
128 status = -EINVAL;
130 if (!status && drv_datap->base_img)
131 strcpy(str_exec_file, drv_datap->base_img);
133 if (status)
134 pr_err("%s: Failed, status 0x%x\n", __func__, status);
135 DBC_ENSURE(((status == 0) &&
136 (strlen(str_exec_file) <= buf_size))
137 || (status != 0));
138 return status;
142 * ======== cfg_get_object ========
143 * Purpose:
144 * Retrieve the Object handle from the Registry
146 int cfg_get_object(u32 *value, u8 dw_type)
148 int status = -EINVAL;
149 struct drv_data *drv_datap = dev_get_drvdata(bridge);
151 DBC_REQUIRE(value != NULL);
153 if (!drv_datap)
154 return -EPERM;
156 switch (dw_type) {
157 case (REG_DRV_OBJECT):
158 if (drv_datap->drv_object) {
159 *value = (u32)drv_datap->drv_object;
160 status = 0;
161 } else {
162 status = -ENODATA;
164 break;
165 case (REG_MGR_OBJECT):
166 if (drv_datap->mgr_object) {
167 *value = (u32)drv_datap->mgr_object;
168 status = 0;
169 } else {
170 status = -ENODATA;
172 break;
174 default:
175 break;
177 if (status) {
178 *value = 0;
179 pr_err("%s: Failed, status 0x%x\n", __func__, status);
181 DBC_ENSURE((!status && *value != 0) || (status && *value == 0));
182 return status;
186 * ======== cfg_init ========
187 * Purpose:
188 * Initialize the CFG module's private state.
190 bool cfg_init(void)
192 return true;
196 * ======== cfg_set_dev_object ========
197 * Purpose:
198 * Store the Device Object handle and dev_node pointer for a given devnode.
200 int cfg_set_dev_object(struct cfg_devnode *dev_node_obj, u32 value)
202 int status = 0;
203 struct drv_data *drv_datap = dev_get_drvdata(bridge);
205 if (!drv_datap) {
206 pr_err("%s: Failed, status 0x%x\n", __func__, status);
207 return -EPERM;
210 if (!dev_node_obj)
211 status = -EFAULT;
213 if (!status) {
214 /* Store the Bridge device object in the Registry */
216 if (!(strcmp((char *)dev_node_obj, "TIOMAP1510")))
217 drv_datap->dev_object = (void *) value;
219 if (status)
220 pr_err("%s: Failed, status 0x%x\n", __func__, status);
222 return status;
226 * ======== cfg_set_object ========
227 * Purpose:
228 * Store the Driver Object handle
230 int cfg_set_object(u32 value, u8 dw_type)
232 int status = -EINVAL;
233 struct drv_data *drv_datap = dev_get_drvdata(bridge);
235 if (!drv_datap)
236 return -EPERM;
238 switch (dw_type) {
239 case (REG_DRV_OBJECT):
240 drv_datap->drv_object = (void *)value;
241 status = 0;
242 break;
243 case (REG_MGR_OBJECT):
244 drv_datap->mgr_object = (void *)value;
245 status = 0;
246 break;
247 default:
248 break;
250 if (status)
251 pr_err("%s: Failed, status 0x%x\n", __func__, status);
252 return status;