예제 #1
0
static int __init mhl_msm_init(void)
{
	int32_t     ret;

	pr_debug("%s\n", __func__);
	mhl_msm_state = kzalloc(sizeof(struct mhl_msm_state_t), GFP_KERNEL);
	if (!mhl_msm_state) {
		pr_err("mhl_msm_init FAILED: out of memory\n");
		ret = -ENOMEM;
		goto init_exit;
	}

	mhl_msm_state->i2c_client = NULL;
	ret = i2c_add_driver(&mhl_sii_i2c_driver);
	if (ret) {
		pr_err("MHL: I2C driver add failed: %d\n", ret);
		ret = -ENODEV;
		goto init_exit;
	} else {
		if (mhl_msm_state->i2c_client == NULL) {
			pr_err("MHL: I2C driver add failed\n");
			ret = -ENODEV;
			goto init_exit;
		}
		pr_info("MHL: I2C driver added\n");
	}

	/* Request IRQ stuff here */
	pr_debug("MHL: mhl_msm_state->mhl_data->irq=[%d]\n",
		mhl_msm_state->mhl_data->irq);
	ret = request_threaded_irq(mhl_msm_state->mhl_data->irq, NULL,
				   &mhl_tx_isr,
				 IRQF_TRIGGER_LOW | IRQF_ONESHOT,
				 "mhl_tx_isr", mhl_msm_state);
	if (ret != 0) {
		pr_err("request_threaded_irq failed, status: %d\n",
			ret);
		ret = -EACCES; /* Error code???? */
		goto init_exit;
	} else
		pr_debug("request_threaded_irq succeeded\n");

	mhl_msm_state->cur_state = POWER_STATE_D0_MHL;

	/* MHL SII 8334 chip specific init */
	mhl_chip_init();
	init_completion(&mhl_msm_state->rgnd_done);
	return 0;

init_exit:
	pr_err("Exiting from the init with err\n");
	i2c_del_driver(&mhl_sii_i2c_driver);
	if (!mhl_msm_state) {
		kfree(mhl_msm_state);
		mhl_msm_state = NULL;
	 }
	 return ret;
}
예제 #2
0
/*
 * I2C probe
 */
static int mhl_i2c_probe(struct i2c_client *client,
	const struct i2c_device_id *id)
{
	int ret;
	struct msm_mhl_platform_data *tmp = client->dev.platform_data;
	if (!tmp->mhl_enabled) {
		ret = -ENODEV;
		pr_warn("MHL feautre left disabled\n");
		goto probe_early_exit;
	}
	mhl_msm_state->mhl_data = kzalloc(sizeof(struct msm_mhl_platform_data),
		GFP_KERNEL);
	if (!(mhl_msm_state->mhl_data)) {
		ret = -ENOMEM;
		pr_err("MHL I2C Probe failed - no mem\n");
		goto probe_early_exit;
	}
	mhl_msm_state->i2c_client = client;
	spin_lock_init(&mhl_state_lock);
	i2c_set_clientdata(client, mhl_msm_state);
	mhl_msm_state->mhl_data = client->dev.platform_data;
	pr_debug("MHL: mhl_msm_state->mhl_data->irq=[%d]\n",
		mhl_msm_state->mhl_data->irq);
	msc_send_workqueue = create_workqueue("mhl_msc_cmd_queue");

	mhl_msm_state->cur_state = POWER_STATE_D0_MHL;
	/* Init GPIO stuff here */
	ret = mhl_sii_gpio_setup(1);
	if (ret) {
		pr_err("MHL: mhl_gpio_init has failed\n");
		ret = -ENODEV;
		goto probe_early_exit;
	}
	mhl_sii_power_on();
	/* MHL SII 8334 chip specific init */
	mhl_chip_init();
	init_completion(&mhl_msm_state->rgnd_done);
	/* Request IRQ stuff here */
	pr_debug("MHL: mhl_msm_state->mhl_data->irq=[%d]\n",
		mhl_msm_state->mhl_data->irq);
	ret = request_threaded_irq(mhl_msm_state->mhl_data->irq, NULL,
				   &mhl_tx_isr,
				 IRQF_TRIGGER_LOW | IRQF_ONESHOT,
				 "mhl_tx_isr", mhl_msm_state);
	if (ret) {
		pr_err("request_threaded_irq failed, status: %d\n",
			ret);
		goto probe_exit;
	} else {
		pr_debug("request_threaded_irq succeeded\n");
	}

	INIT_WORK(&mhl_msm_state->mhl_msc_send_work, mhl_msc_send_work);
	INIT_LIST_HEAD(&mhl_msm_state->list_cmd);
	mhl_msm_state->msc_command_put_work = list_cmd_put;
	mhl_msm_state->msc_command_get_work = list_cmd_get;
	init_completion(&mhl_msm_state->msc_cmd_done);

	pr_debug("i2c probe successful\n");
	return 0;

probe_exit:
	if (mhl_msm_state->mhl_data) {
		/* free the gpios */
		mhl_sii_gpio_setup(0);
		kfree(mhl_msm_state->mhl_data);
		mhl_msm_state->mhl_data = NULL;
	}
probe_early_exit:
	return ret;
}