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 /* ----------------------------------- Platform Manager */
30 #include <dspbridge/drv.h>
31 #include <dspbridge/dev.h>
32 #include <dspbridge/dspapi.h>
34 /* ----------------------------------- Resource Manager */
35 #include <dspbridge/mgr.h>
37 /* ----------------------------------- This */
38 #include <dspbridge/dspdrv.h>
41 * ======== dsp_init ========
42 * Allocates bridge resources. Loads a base image onto DSP, if specified.
44 u32
dsp_init(u32
*init_status
)
46 char dev_node
[MAXREGPATHLENGTH
] = "TIOMAP1510";
48 struct drv_object
*drv_obj
= NULL
;
50 u32 device_node_string
;
55 status
= drv_create(&drv_obj
);
62 /* Request Resources */
63 status
= drv_request_resources((u32
) &dev_node
, &device_node_string
);
65 /* Attempt to Start the Device */
66 status
= dev_start_device((struct cfg_devnode
*)
69 (void)drv_release_resources
70 ((u32
) device_node_string
, drv_obj
);
72 dev_dbg(bridge
, "%s: drv_request_resources Failed\n", __func__
);
76 /* Unwind whatever was loaded */
78 /* irrespective of the status of dev_remove_device we conitinue
79 * unloading. Get the Driver Object iterate through and remove.
80 * Reset the status to E_FAIL to avoid going through
81 * api_init_complete2. */
82 for (device_node
= drv_get_first_dev_extension();
84 device_node
= drv_get_next_dev_extension(device_node
)) {
85 (void)dev_remove_device((struct cfg_devnode
*)
87 (void)drv_release_resources((u32
) device_node
, drv_obj
);
89 /* Remove the Driver Object */
90 (void)drv_destroy(drv_obj
);
93 dev_dbg(bridge
, "%s: Logical device failed init\n", __func__
);
94 } /* Unwinding the loaded drivers */
96 /* Attempt to Start the Board */
98 /* BRD_AutoStart could fail if the dsp execuetable is not the
99 * correct one. We should not propagate that error
100 * into the device loader. */
101 (void)api_init_complete2();
103 dev_dbg(bridge
, "%s: Failed\n", __func__
);
104 } /* End api_init_complete2 */
105 DBC_ENSURE((!status
&& drv_obj
!= NULL
) ||
106 (status
&& drv_obj
== NULL
));
107 *init_status
= status
;
108 /* Return the Driver Object */
109 return (u32
) drv_obj
;
113 * ======== dsp_deinit ========
114 * Frees the resources allocated for bridge.
116 bool dsp_deinit(u32 device_context
)
120 struct mgr_object
*mgr_obj
= NULL
;
121 struct drv_data
*drv_datap
= dev_get_drvdata(bridge
);
123 while ((device_node
= drv_get_first_dev_extension()) != 0) {
124 (void)dev_remove_device((struct cfg_devnode
*)device_node
);
126 (void)drv_release_resources((u32
) device_node
,
127 (struct drv_object
*)device_context
);
130 (void)drv_destroy((struct drv_object
*)device_context
);
132 /* Get the Manager Object from driver data
133 * MGR Destroy will unload the DCD dll */
134 if (drv_datap
&& drv_datap
->mgr_object
) {
135 mgr_obj
= drv_datap
->mgr_object
;
136 (void)mgr_destroy(mgr_obj
);
138 pr_err("%s: Failed to retrieve the object handle\n", __func__
);