d460f5823c6b9a645c465db6d8cafe65223981de
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 /* ----------------------------------- Platform Manager */
27 #include <dspbridge/drv.h>
28 #include <dspbridge/dev.h>
29 #include <dspbridge/dspapi.h>
31 /* ----------------------------------- Resource Manager */
32 #include <dspbridge/mgr.h>
34 /* ----------------------------------- This */
35 #include <dspbridge/dspdrv.h>
38 * ======== dsp_init ========
39 * Allocates bridge resources. Loads a base image onto DSP, if specified.
41 u32
dsp_init(u32
*init_status
)
43 char dev_node
[MAXREGPATHLENGTH
] = "TIOMAP1510";
45 struct drv_object
*drv_obj
= NULL
;
47 u32 device_node_string
;
52 status
= drv_create(&drv_obj
);
59 /* Request Resources */
60 status
= drv_request_resources((u32
) &dev_node
, &device_node_string
);
62 /* Attempt to Start the Device */
63 status
= dev_start_device((struct cfg_devnode
*)
66 (void)drv_release_resources
67 ((u32
) device_node_string
, drv_obj
);
69 dev_dbg(bridge
, "%s: drv_request_resources Failed\n", __func__
);
73 /* Unwind whatever was loaded */
75 /* irrespective of the status of dev_remove_device we continue
76 * unloading. Get the Driver Object iterate through and remove.
77 * Reset the status to E_FAIL to avoid going through
78 * api_init_complete2. */
79 for (device_node
= drv_get_first_dev_extension();
81 device_node
= drv_get_next_dev_extension(device_node
)) {
82 (void)dev_remove_device((struct cfg_devnode
*)
84 (void)drv_release_resources((u32
) device_node
, drv_obj
);
86 /* Remove the Driver Object */
87 (void)drv_destroy(drv_obj
);
90 dev_dbg(bridge
, "%s: Logical device failed init\n", __func__
);
91 } /* Unwinding the loaded drivers */
93 /* Attempt to Start the Board */
95 /* BRD_AutoStart could fail if the dsp executable is not the
96 * correct one. We should not propagate that error
97 * into the device loader. */
98 (void)api_init_complete2();
100 dev_dbg(bridge
, "%s: Failed\n", __func__
);
101 } /* End api_init_complete2 */
102 *init_status
= status
;
103 /* Return the Driver Object */
104 return (u32
) drv_obj
;
108 * ======== dsp_deinit ========
109 * Frees the resources allocated for bridge.
111 bool dsp_deinit(u32 device_context
)
115 struct mgr_object
*mgr_obj
= NULL
;
116 struct drv_data
*drv_datap
= dev_get_drvdata(bridge
);
118 while ((device_node
= drv_get_first_dev_extension()) != 0) {
119 (void)dev_remove_device((struct cfg_devnode
*)device_node
);
121 (void)drv_release_resources((u32
) device_node
,
122 (struct drv_object
*)device_context
);
125 (void)drv_destroy((struct drv_object
*)device_context
);
127 /* Get the Manager Object from driver data
128 * MGR Destroy will unload the DCD dll */
129 if (drv_datap
&& drv_datap
->mgr_object
) {
130 mgr_obj
= drv_datap
->mgr_object
;
131 (void)mgr_destroy(mgr_obj
);
133 pr_err("%s: Failed to retrieve the object handle\n", __func__
);