Ejemplo n.º 1
0
int msm_adsp_get(const char *name, struct msm_adsp_module **out,
		 struct msm_adsp_ops *ops, void *driver_data)
{
	struct msm_adsp_module *module;
	int rc = 0;
	static uint32_t init_info_cmd_sent;

	mutex_lock(&adsp_info.lock);
	MM_INFO("acquired adsp info lock\n");
	if (!init_info_cmd_sent) {
		init_waitqueue_head(&adsp_info.init_info_wait);
		msm_get_init_info();
		rc = wait_event_timeout(adsp_info.init_info_wait,
			adsp_info.init_info_state == ADSP_STATE_INIT_INFO,
			5 * HZ);
		if (!rc) {
			MM_ERR("adsp: INIT_INFO failed\n");
			mutex_unlock(&adsp_info.lock);
			return -ETIMEDOUT;

		}
		init_info_cmd_sent++;
	}
	mutex_unlock(&adsp_info.lock);

	module = find_adsp_module_by_name(&adsp_info, name);
	if (!module)
		return -ENODEV;

	MM_INFO("adsp: opening module %s\n", module->name);
	mutex_lock(&module->lock);

	if (module->ops) {
		rc = -EBUSY;
		goto done;
	}

	rc = adsp_rpc_init(module);
	if (rc)
		goto done;

	module->ops = ops;
	module->driver_data = driver_data;
	*out = module;
	rc = rpc_adsp_rtos_app_to_modem(RPC_ADSP_RTOS_CMD_REGISTER_APP,
					module->id, module);
	if (rc) {
		module->ops = NULL;
		module->driver_data = NULL;
		*out = NULL;
		MM_ERR("adsp: REGISTER_APP failed\n");
		goto done;
	}

	MM_DBG("adsp: module %s has been registered\n", module->name);

done:
	mutex_unlock(&module->lock);
	return rc;
}
Ejemplo n.º 2
0
int msm_adsp_get(const char *name, struct msm_adsp_module **out,
		 struct msm_adsp_ops *ops, void *driver_data)
{
	struct msm_adsp_module *module;
	int rc = 0;

#if CONFIG_MSM_AMSS_VERSION >= 6350
	static uint32_t init_info_cmd_sent;
	if (!init_info_cmd_sent) {
		msm_get_init_info();
		init_waitqueue_head(&adsp_info.init_info_wait);
		rc = wait_event_timeout(adsp_info.init_info_wait,
			adsp_info.init_info_state == ADSP_STATE_INIT_INFO,
			5 * HZ);
		if (!rc) {
			pr_info("adsp: INIT_INFO failed\n");
			return -ETIMEDOUT;
		}
		init_info_cmd_sent++;
	}
#endif

	module = find_adsp_module_by_name(&adsp_info, name);
	if (!module)
		return -ENODEV;

	mutex_lock(&module->lock);
	pr_info("adsp: opening module %s\n", module->name);
	if (module->open_count++ == 0 && module->clk)
		clk_enable(module->clk);

	mutex_lock(&adsp_open_lock);
	if (adsp_open_count++ == 0) {
		enable_irq(INT_ADSP);
		prevent_suspend();
	}
	mutex_unlock(&adsp_open_lock);

	if (module->ops) {
		rc = -EBUSY;
		goto done;
	}

	rc = adsp_rpc_init(module);
	if (rc)
		goto done;

	module->ops = ops;
	module->driver_data = driver_data;
	*out = module;
	rc = rpc_adsp_rtos_app_to_modem(RPC_ADSP_RTOS_CMD_REGISTER_APP,
					module->id, module);
	if (rc) {
		module->ops = NULL;
		module->driver_data = NULL;
		*out = NULL;
		pr_err("adsp: REGISTER_APP failed\n");
		goto done;
	}

	pr_info("adsp: module %s has been registered\n", module->name);

done:
	mutex_lock(&adsp_open_lock);
	if (rc && --adsp_open_count == 0) {
		disable_irq(INT_ADSP);
		allow_suspend();
	}
	if (rc && --module->open_count == 0 && module->clk)
		clk_disable(module->clk);
	mutex_unlock(&adsp_open_lock);
	mutex_unlock(&module->lock);
	return rc;
}