4 * DSP-BIOS Bridge driver support functions for TI OMAP processors.
6 * Interface to allocate and free bridge resources.
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 /* ----------------------------------- Host OS */
20 #include <linux/types.h>
21 #include <dspbridge/host_os.h>
23 /* ----------------------------------- DSP/BIOS Bridge */
24 #include <dspbridge/dbdefs.h>
26 /* ----------------------------------- Trace & Debug */
27 #include <dspbridge/dbc.h>
29 /* ----------------------------------- OS Adaptation Layer */
30 #include <dspbridge/cfg.h>
32 /* ----------------------------------- Platform Manager */
33 #include <dspbridge/drv.h>
34 #include <dspbridge/dev.h>
35 #include <dspbridge/dspapi.h>
37 /* ----------------------------------- Resource Manager */
38 #include <dspbridge/mgr.h>
40 /* ----------------------------------- This */
41 #include <dspbridge/dspdrv.h>
44 * ======== dsp_init ========
45 * Allocates bridge resources. Loads a base image onto DSP, if specified.
47 u32 dsp_init(u32 *init_status)
49 char dev_node[MAXREGPATHLENGTH] = "TIOMAP1510";
51 struct drv_object *drv_obj = NULL;
53 u32 device_node_string;
58 status = drv_create(&drv_obj);
65 /* Request Resources */
66 status = drv_request_resources((u32) &dev_node, &device_node_string);
68 /* Attempt to Start the Device */
69 status = dev_start_device((struct cfg_devnode *)
72 (void)drv_release_resources
73 ((u32) device_node_string, drv_obj);
75 dev_dbg(bridge, "%s: drv_request_resources Failed\n", __func__);
79 /* Unwind whatever was loaded */
81 /* irrespective of the status of dev_remove_device we conitinue
82 * unloading. Get the Driver Object iterate through and remove.
83 * Reset the status to E_FAIL to avoid going through
84 * api_init_complete2. */
85 for (device_node = drv_get_first_dev_extension();
87 device_node = drv_get_next_dev_extension(device_node)) {
88 (void)dev_remove_device((struct cfg_devnode *)
90 (void)drv_release_resources((u32) device_node, drv_obj);
92 /* Remove the Driver Object */
93 (void)drv_destroy(drv_obj);
96 dev_dbg(bridge, "%s: Logical device failed init\n", __func__);
97 } /* Unwinding the loaded drivers */
99 /* Attempt to Start the Board */
101 /* BRD_AutoStart could fail if the dsp execuetable is not the
102 * correct one. We should not propagate that error
103 * into the device loader. */
104 (void)api_init_complete2();
106 dev_dbg(bridge, "%s: Failed\n", __func__);
107 } /* End api_init_complete2 */
108 DBC_ENSURE((!status && drv_obj != NULL) ||
109 (status && drv_obj == NULL));
110 *init_status = status;
111 /* Return the Driver Object */
112 return (u32) drv_obj;
116 * ======== dsp_deinit ========
117 * Frees the resources allocated for bridge.
119 bool dsp_deinit(u32 device_context)
123 struct mgr_object *mgr_obj = NULL;
125 while ((device_node = drv_get_first_dev_extension()) != 0) {
126 (void)dev_remove_device((struct cfg_devnode *)device_node);
128 (void)drv_release_resources((u32) device_node,
129 (struct drv_object *)device_context);
132 (void)drv_destroy((struct drv_object *)device_context);
134 /* Get the Manager Object from Registry
135 * MGR Destroy will unload the DCD dll */
136 if (!cfg_get_object((u32 *) &mgr_obj, REG_MGR_OBJECT))
137 (void)mgr_destroy(mgr_obj);