/* * ======== dsp_deinit ======== * Frees the resources allocated for bridge. */ bool dsp_deinit(u32 device_context) { bool ret = true; u32 device_node; struct mgr_object *mgr_obj = NULL; struct drv_data *drv_datap = dev_get_drvdata(bridge); while ((device_node = drv_get_first_dev_extension()) != 0) { (void)dev_remove_device((struct cfg_devnode *)device_node); (void)drv_release_resources((u32) device_node, (struct drv_object *)device_context); } (void)drv_destroy((struct drv_object *)device_context); /* Get the Manager Object from driver data * MGR Destroy will unload the DCD dll */ if (drv_datap && drv_datap->mgr_object) { mgr_obj = drv_datap->mgr_object; (void)mgr_destroy(mgr_obj); } else { pr_err("%s: Failed to retrieve the object handle\n", __func__); } api_exit(); return ret; }
/* * ======== dsp_deinit ======== * Frees the resources allocated for bridge. */ bool dsp_deinit(u32 deviceContext) { bool ret = true; u32 device_node; struct mgr_object *mgr_obj = NULL; while ((device_node = drv_get_first_dev_extension()) != 0) { (void)dev_remove_device((struct cfg_devnode *)device_node); (void)drv_release_resources((u32) device_node, (struct drv_object *)deviceContext); } (void)drv_destroy((struct drv_object *)deviceContext); /* Get the Manager Object from Registry * MGR Destroy will unload the DCD dll */ if (DSP_SUCCEEDED(cfg_get_object((u32 *) &mgr_obj, REG_MGR_OBJECT))) (void)mgr_destroy(mgr_obj); wcd_exit(); return ret; }
/* * ======== dsp_init ======== * Allocates bridge resources. Loads a base image onto DSP, if specified. */ u32 dsp_init(OUT u32 *init_status) { char dev_node[MAXREGPATHLENGTH] = "TIOMAP1510"; int status = -EPERM; struct drv_object *drv_obj = NULL; u32 device_node; u32 device_node_string; if (!wcd_init()) goto func_cont; status = drv_create(&drv_obj); if (DSP_FAILED(status)) { wcd_exit(); goto func_cont; } /* End drv_create */ /* Request Resources */ status = drv_request_resources((u32) &dev_node, &device_node_string); if (DSP_SUCCEEDED(status)) { /* Attempt to Start the Device */ status = dev_start_device((struct cfg_devnode *) device_node_string); if (DSP_FAILED(status)) (void)drv_release_resources ((u32) device_node_string, drv_obj); } else { dev_dbg(bridge, "%s: drv_request_resources Failed\n", __func__); status = -EPERM; } /* Unwind whatever was loaded */ if (DSP_FAILED(status)) { /* irrespective of the status of dev_remove_device we conitinue * unloading. Get the Driver Object iterate through and remove. * Reset the status to E_FAIL to avoid going through * wcd_init_complete2. */ for (device_node = drv_get_first_dev_extension(); device_node != 0; device_node = drv_get_next_dev_extension(device_node)) { (void)dev_remove_device((struct cfg_devnode *) device_node); (void)drv_release_resources((u32) device_node, drv_obj); } /* Remove the Driver Object */ (void)drv_destroy(drv_obj); drv_obj = NULL; wcd_exit(); dev_dbg(bridge, "%s: Logical device failed init\n", __func__); } /* Unwinding the loaded drivers */ func_cont: /* Attempt to Start the Board */ if (DSP_SUCCEEDED(status)) { /* BRD_AutoStart could fail if the dsp execuetable is not the * correct one. We should not propagate that error * into the device loader. */ (void)wcd_init_complete2(); } else { dev_dbg(bridge, "%s: Failed\n", __func__); } /* End wcd_init_complete2 */ DBC_ENSURE((DSP_SUCCEEDED(status) && drv_obj != NULL) || (DSP_FAILED(status) && drv_obj == NULL)); *init_status = status; /* Return the Driver Object */ return (u32) drv_obj; }