4 * DSP-BIOS Bridge driver support functions for TI OMAP processors.
6 * Implementation of Manager interface to the device object at the
7 * driver level. This queries the NDB data base and retrieves the
8 * data about Node and Processor.
10 * Copyright (C) 2005-2006 Texas Instruments, Inc.
12 * This package is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License version 2 as
14 * published by the Free Software Foundation.
16 * THIS PACKAGE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
17 * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
18 * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
21 #include <linux/types.h>
23 /* ----------------------------------- Host OS */
24 #include <dspbridge/host_os.h>
26 /* ----------------------------------- DSP/BIOS Bridge */
27 #include <dspbridge/dbdefs.h>
29 /* ----------------------------------- OS Adaptation Layer */
30 #include <dspbridge/sync.h>
32 /* ----------------------------------- Others */
33 #include <dspbridge/dbdcd.h>
34 #include <dspbridge/drv.h>
35 #include <dspbridge/dev.h>
37 /* ----------------------------------- This */
38 #include <dspbridge/mgr.h>
40 /* ----------------------------------- Defines, Data Structures, Typedefs */
44 struct dcd_manager *dcd_mgr; /* Proc/Node data manager */
47 /* ----------------------------------- Globals */
51 * ========= mgr_create =========
53 * MGR Object gets created only once during driver Loading.
55 int mgr_create(struct mgr_object **mgr_obj,
56 struct cfg_devnode *dev_node_obj)
59 struct mgr_object *pmgr_obj = NULL;
60 struct drv_data *drv_datap = dev_get_drvdata(bridge);
62 pmgr_obj = kzalloc(sizeof(struct mgr_object), GFP_KERNEL);
64 status = dcd_create_manager(ZLDLLNAME, &pmgr_obj->dcd_mgr);
66 /* If succeeded store the handle in the MGR Object */
68 drv_datap->mgr_object = (void *)pmgr_obj;
71 pr_err("%s: Failed to store MGR object\n",
78 dcd_destroy_manager(pmgr_obj->dcd_mgr);
82 /* failed to Create DCD Manager */
93 * ========= mgr_destroy =========
94 * This function is invoked during bridge driver unloading.Frees MGR object.
96 int mgr_destroy(struct mgr_object *hmgr_obj)
99 struct mgr_object *pmgr_obj = (struct mgr_object *)hmgr_obj;
100 struct drv_data *drv_datap = dev_get_drvdata(bridge);
103 if (hmgr_obj->dcd_mgr)
104 dcd_destroy_manager(hmgr_obj->dcd_mgr);
107 /* Update the driver data with NULL for MGR Object */
109 drv_datap->mgr_object = NULL;
112 pr_err("%s: Failed to store MGR object\n", __func__);
119 * ======== mgr_enum_node_info ========
120 * Enumerate and get configuration information about nodes configured
121 * in the node database.
123 int mgr_enum_node_info(u32 node_id, struct dsp_ndbprops *pndb_props,
124 u32 undb_props_size, u32 *pu_num_nodes)
127 struct dsp_uuid node_uuid;
129 struct dcd_genericobj gen_obj;
130 struct mgr_object *pmgr_obj = NULL;
131 struct drv_data *drv_datap = dev_get_drvdata(bridge);
134 /* Get the Manager Object from the driver data */
135 if (!drv_datap || !drv_datap->mgr_object) {
136 pr_err("%s: Failed to retrieve the object handle\n", __func__);
139 pmgr_obj = drv_datap->mgr_object;
141 /* Forever loop till we hit failed or no more items in the
142 * Enumeration. We will exit the loop other than 0; */
144 status = dcd_enumerate_object(node_index++, DSP_DCDNODETYPE,
148 *pu_num_nodes = node_index;
149 if (node_id == (node_index - 1)) {
150 status = dcd_get_object_def(pmgr_obj->dcd_mgr,
151 &node_uuid, DSP_DCDNODETYPE, &gen_obj);
154 /* Get the Obj def */
155 *pndb_props = gen_obj.obj_data.node_obj.ndb_props;
159 /* the last status is not 0, but neither an error */
167 * ======== mgr_enum_processor_info ========
168 * Enumerate and get configuration information about available
171 int mgr_enum_processor_info(u32 processor_id,
172 struct dsp_processorinfo *
173 processor_info, u32 processor_info_size,
179 struct dsp_uuid temp_uuid;
182 struct dcd_genericobj gen_obj;
183 struct mgr_object *pmgr_obj = NULL;
184 struct mgr_processorextinfo *ext_info;
185 struct dev_object *hdev_obj;
186 struct drv_object *hdrv_obj;
188 struct cfg_devnode *dev_node;
189 struct drv_data *drv_datap = dev_get_drvdata(bridge);
190 bool proc_detect = false;
194 /* Retrieve the Object handle from the driver data */
195 if (!drv_datap || !drv_datap->drv_object) {
197 pr_err("%s: Failed to retrieve the object handle\n", __func__);
199 hdrv_obj = drv_datap->drv_object;
203 status = drv_get_dev_object(processor_id, hdrv_obj, &hdev_obj);
205 status = dev_get_dev_type(hdev_obj, (u8 *) &dev_type);
206 status = dev_get_dev_node(hdev_obj, &dev_node);
207 if (dev_type != DSP_UNIT)
211 processor_info->processor_type = DSPTYPE64;
217 /* Get The Manager Object from the driver data */
218 if (drv_datap && drv_datap->mgr_object) {
219 pmgr_obj = drv_datap->mgr_object;
221 dev_dbg(bridge, "%s: Failed to get MGR Object\n", __func__);
224 /* Forever loop till we hit no more items in the
225 * Enumeration. We will exit the loop other than 0; */
226 while (status1 == 0) {
227 status1 = dcd_enumerate_object(temp_index++,
228 DSP_DCDPROCESSORTYPE,
234 /* Get the Object properties to find the Device/Processor
236 if (proc_detect != false)
239 status2 = dcd_get_object_def(pmgr_obj->dcd_mgr,
240 (struct dsp_uuid *)&temp_uuid,
241 DSP_DCDPROCESSORTYPE, &gen_obj);
243 /* Get the Obj def */
244 if (processor_info_size <
245 sizeof(struct mgr_processorextinfo)) {
246 *processor_info = gen_obj.obj_data.proc_info;
249 ext_info = (struct mgr_processorextinfo *)
251 *ext_info = gen_obj.obj_data.ext_proc_obj;
253 dev_dbg(bridge, "%s: Got proctype from DCD %x\n",
254 __func__, processor_info->processor_type);
255 /* See if we got the needed processor */
256 if (dev_type == DSP_UNIT) {
257 if (processor_info->processor_type ==
260 } else if (dev_type == IVA_UNIT) {
261 if (processor_info->processor_type ==
265 /* User applciatiuons aonly check for chip type, so
266 * this clumsy overwrite */
267 processor_info->processor_type = DSPTYPE64;
269 dev_dbg(bridge, "%s: Failed to get DCD processor info "
270 "%x\n", __func__, status2);
274 *pu_num_procs = proc_index;
275 if (proc_detect == false) {
276 dev_dbg(bridge, "%s: Failed to get proc info from DCD, so use "
277 "CFG registry\n", __func__);
278 processor_info->processor_type = DSPTYPE64;
285 * ======== mgr_exit ========
286 * Decrement reference count, and free resources when reference count is
297 * ======== mgr_get_dcd_handle ========
298 * Retrieves the MGR handle. Accessor Function.
300 int mgr_get_dcd_handle(struct mgr_object *mgr_handle,
304 struct mgr_object *pmgr_obj = (struct mgr_object *)mgr_handle;
306 *dcd_handle = (u32) NULL;
308 *dcd_handle = (u32) pmgr_obj->dcd_mgr;
316 * ======== mgr_init ========
317 * Initialize MGR's private state, keeping a reference count on each call.
324 ret = dcd_init(); /* DCD Module */
333 * ======== mgr_wait_for_bridge_events ========
334 * Block on any Bridge event(s)
336 int mgr_wait_for_bridge_events(struct dsp_notification **anotifications,
337 u32 count, u32 *pu_index,
341 struct sync_object *sync_events[MAX_EVENTS];
344 for (i = 0; i < count; i++)
345 sync_events[i] = anotifications[i]->handle;
347 status = sync_wait_on_multiple_events(sync_events, count, utimeout,