1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20#include <linux/types.h>
21#include <dspbridge/host_os.h>
22
23
24#include <dspbridge/dbdefs.h>
25
26
27#include <dspbridge/dbc.h>
28
29
30#include <dspbridge/drv.h>
31#include <dspbridge/dev.h>
32#include <dspbridge/dspapi.h>
33
34
35#include <dspbridge/mgr.h>
36
37
38#include <dspbridge/dspdrv.h>
39
40
41
42
43
44u32 dsp_init(u32 *init_status)
45{
46 char dev_node[MAXREGPATHLENGTH] = "TIOMAP1510";
47 int status = -EPERM;
48 struct drv_object *drv_obj = NULL;
49 u32 device_node;
50 u32 device_node_string;
51
52 if (!api_init())
53 goto func_cont;
54
55 status = drv_create(&drv_obj);
56 if (status) {
57 api_exit();
58 goto func_cont;
59 }
60
61
62
63 status = drv_request_resources((u32) &dev_node, &device_node_string);
64 if (!status) {
65
66 status = dev_start_device((struct cfg_devnode *)
67 device_node_string);
68 if (status)
69 (void)drv_release_resources
70 ((u32) device_node_string, drv_obj);
71 } else {
72 dev_dbg(bridge, "%s: drv_request_resources Failed\n", __func__);
73 status = -EPERM;
74 }
75
76
77 if (status) {
78
79
80
81
82 for (device_node = drv_get_first_dev_extension();
83 device_node != 0;
84 device_node = drv_get_next_dev_extension(device_node)) {
85 (void)dev_remove_device((struct cfg_devnode *)
86 device_node);
87 (void)drv_release_resources((u32) device_node, drv_obj);
88 }
89
90 (void)drv_destroy(drv_obj);
91 drv_obj = NULL;
92 api_exit();
93 dev_dbg(bridge, "%s: Logical device failed init\n", __func__);
94 }
95func_cont:
96
97 if (!status) {
98
99
100
101 (void)api_init_complete2();
102 } else {
103 dev_dbg(bridge, "%s: Failed\n", __func__);
104 }
105 DBC_ENSURE((!status && drv_obj != NULL) ||
106 (status && drv_obj == NULL));
107 *init_status = status;
108
109 return (u32) drv_obj;
110}
111
112
113
114
115
116bool dsp_deinit(u32 device_context)
117{
118 bool ret = true;
119 u32 device_node;
120 struct mgr_object *mgr_obj = NULL;
121 struct drv_data *drv_datap = dev_get_drvdata(bridge);
122
123 while ((device_node = drv_get_first_dev_extension()) != 0) {
124 (void)dev_remove_device((struct cfg_devnode *)device_node);
125
126 (void)drv_release_resources((u32) device_node,
127 (struct drv_object *)device_context);
128 }
129
130 (void)drv_destroy((struct drv_object *)device_context);
131
132
133
134 if (drv_datap && drv_datap->mgr_object) {
135 mgr_obj = drv_datap->mgr_object;
136 (void)mgr_destroy(mgr_obj);
137 } else {
138 pr_err("%s: Failed to retrieve the object handle\n", __func__);
139 }
140
141 api_exit();
142
143 return ret;
144}
145