static int __devinit sec_keyboard_probe(struct platform_device *pdev)
{
	struct sec_keyboard_platform_data *pdata = pdev->dev.platform_data;
	struct sec_keyboard_drvdata *ddata;
	struct input_dev *input;
	int i, error;

	if (pdata == NULL) {
		printk(KERN_ERR "%s: no pdata\n", __func__);
		return -ENODEV;
	}

	ddata = kzalloc(sizeof(struct sec_keyboard_drvdata), GFP_KERNEL);
	if (NULL == ddata) {
		error = -ENOMEM;
		goto err_free_mem;
	}

	input = input_allocate_device();
	if (NULL == input) {
		printk(KERN_ERR "[Keyboard] failed to allocate input device.\n");
		error = -ENOMEM;
		goto err_free_mem;
	}

	ddata->input_dev = input;
	ddata->acc_power = pdata->acc_power;
	ddata->check_uart_path = pdata->check_uart_path;
	ddata->acc_int_gpio = pdata->accessory_irq_gpio;
	ddata->led_on = false;
	ddata->dockconnected = false;
	ddata->pre_connected = false;
	ddata->remap_key = 0;
	ddata->kl = UNKOWN_KEYLAYOUT;
	ddata->callbacks.check_keyboard_dock = check_keyboard_dock;
	if (pdata->register_cb)
		pdata->register_cb(&ddata->callbacks);
	ddata->noti_univ_kbd_dock = pdata->noti_univ_kbd_dock;

	memcpy(ddata->keycode, sec_keycodes, sizeof(sec_keycodes));

	INIT_DELAYED_WORK(&ddata->remap_dwork, sec_keyboard_remapkey);
	INIT_DELAYED_WORK(&ddata->power_dwork, sec_keyboard_power);
	INIT_DELAYED_WORK(&ddata->ack_dwork, sec_keyboard_ack);

	platform_set_drvdata(pdev, ddata);
	input_set_drvdata(input, ddata);

	input->name = pdev->name;
	input->dev.parent = &pdev->dev;
	input->id.bustype = BUS_RS232;
	input->event = sec_keyboard_event;

	__set_bit(EV_KEY, input->evbit);
	__set_bit(EV_LED, input->evbit);
	__set_bit(LED_CAPSL, input->ledbit);
	/* framework doesn't use repeat event */
	/* __set_bit(EV_REP, input->evbit); */

	for (i = 0; i < KEYBOARD_SIZE; i++) {
		if (KEY_RESERVED != ddata->keycode[i])
			input_set_capability(input, EV_KEY, ddata->keycode[i]);
	}

	/* for the UK keyboard */
	input_set_capability(input, EV_KEY, KEY_NUMERIC_POUND);

	/* for the remaped keys */
	input_set_capability(input, EV_KEY, KEY_NEXTSONG);
	input_set_capability(input, EV_KEY, KEY_PREVIOUSSONG);

	/* for the wakeup key */
	input_set_capability(input, EV_KEY, KEY_WAKEUP);

	error = input_register_device(input);
	if (error < 0) {
		printk(KERN_ERR "[Keyboard] failed to register input device.\n");
		error = -ENOMEM;
		goto err_input_allocate_device;
	}

	ddata->serio_driver.driver.name = pdev->name;
	ddata->serio_driver.id_table = sec_serio_ids;
	ddata->serio_driver.interrupt = sec_keyboard_interrupt,
	ddata->serio_driver.connect = sec_keyboard_connect,
	ddata->serio_driver.disconnect = sec_keyboard_disconnect,

	error = serio_register_driver(&ddata->serio_driver);
	if (error < 0) {
		printk(KERN_ERR "[Keyboard] failed to register serio\n");
		error = -ENOMEM;
		goto err_reg_serio;
	}

#ifdef CONFIG_HAS_EARLYSUSPEND
	ddata->early_suspend.level = EARLY_SUSPEND_LEVEL_BLANK_SCREEN + 1;
	ddata->early_suspend.suspend = keyboard_early_suspend;
	ddata->early_suspend.resume = keyboard_late_resume;
	register_early_suspend(&ddata->early_suspend);
#endif	/* CONFIG_HAS_EARLYSUSPEND */

	ddata->keyboard_dev = device_create(sec_class, NULL, 0,
		ddata, "sec_keyboard");
	if (IS_ERR(ddata->keyboard_dev)) {
		printk(KERN_ERR "[Keyboard] failed to create device for the sysfs\n");
		error = -ENODEV;
		goto err_sysfs_create_group;
	}

	error = sysfs_create_group(&ddata->keyboard_dev->kobj, &attr_group);
	if (error) {
		printk(KERN_ERR "[Keyboard] failed to create sysfs group\n");
		goto err_sysfs_create_group;
	}

	return 0;

err_sysfs_create_group:
#ifdef CONFIG_HAS_EARLYSUSPEND
	unregister_early_suspend(&ddata->early_suspend);
#endif
	serio_unregister_driver(&ddata->serio_driver);
err_reg_serio:
err_input_allocate_device:
	input_free_device(input);
	del_timer_sync(&ddata->remap_dwork.timer);
	del_timer_sync(&ddata->power_dwork.timer);
	del_timer_sync(&ddata->ack_dwork.timer);
err_free_mem:
	kfree(ddata);
	return error;

}
Beispiel #2
0
static int bma250_probe(struct i2c_client *client,
		const struct i2c_device_id *id)
{
	int err = 0;
	int tempvalue;
	struct bma250_data *data;

	bma_dbg("bma250: probe\n");
	if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) {
		printk(KERN_INFO "i2c_check_functionality error\n");
		goto exit;
	}
	data = kzalloc(sizeof(struct bma250_data), GFP_KERNEL);
	if (!data) {
		err = -ENOMEM;
		goto exit;
	}
	/* read chip id */
	tempvalue = 0;
	tempvalue = i2c_smbus_read_word_data(client, BMA250_CHIP_ID_REG);

	if ((tempvalue&0x00FF) == BMA250_CHIP_ID) {
		printk(KERN_INFO "Bosch Sensortec Device detected!\n" \
				"BMA250 registered I2C driver!\n");
	} else if ((tempvalue&0x00FF) == BMA150_CHIP_ID) {
		printk(KERN_INFO "Bosch Sensortec Device detected!\n" \
				"BMA150 registered I2C driver!\n");
	}
	else {
		printk(KERN_INFO "Bosch Sensortec Device not found, \
				i2c error %d \n", tempvalue);
		err = -1;
		goto kfree_exit;
	}
	i2c_set_clientdata(client, data);
	data->bma250_client = client;
	mutex_init(&data->value_mutex);
	mutex_init(&data->mode_mutex);
	mutex_init(&data->enable_mutex);
	bma250_set_bandwidth(client, BMA250_BW_SET);
	bma250_set_range(client, BMA250_RANGE_SET);

	INIT_DELAYED_WORK(&data->work, bma250_work_func);
	bma_dbg("bma: INIT_DELAYED_WORK\n");
	atomic_set(&data->delay, BMA250_MAX_DELAY);
	atomic_set(&data->enable, 0);
	err = bma250_input_init(data);
	if (err < 0)
	{
		bma_dbg("bma: bma250_input_init err\n");
		goto kfree_exit;
	}
	err = sysfs_create_group(&data->input->dev.kobj,
						 &bma250_attribute_group);
	if (err < 0)
	{
		bma_dbg("bma: sysfs_create_group err\n");
		goto error_sysfs;
	}
#ifdef CONFIG_HAS_EARLYSUSPEND
	data->early_suspend.level = EARLY_SUSPEND_LEVEL_BLANK_SCREEN + 1;
	data->early_suspend.suspend = bma250_early_suspend;
	data->early_suspend.resume = bma250_late_resume;
	register_early_suspend(&data->early_suspend);
#endif
	return 0;

error_sysfs:
	bma250_input_delete(data);

kfree_exit:
	kfree(data);
exit:
	return err;
}
Beispiel #3
0
static int mddi_probe(struct platform_device *pdev)
{
	struct msm_fb_data_type *mfd;
	struct platform_device *mdp_dev = NULL;
	struct msm_fb_panel_data *pdata = NULL;
	int rc;
	resource_size_t size ;
	u32 clk_rate;

	if ((pdev->id == 0) && (pdev->num_resources >= 0)) {
		mddi_pdata = pdev->dev.platform_data;

		size =  resource_size(&pdev->resource[0]);
		msm_pmdh_base =  ioremap(pdev->resource[0].start, size);

		MSM_FB_INFO("primary mddi base phy_addr = 0x%x virt = 0x%x\n",
				pdev->resource[0].start, (int) msm_pmdh_base);

		if (unlikely(!msm_pmdh_base))
			return -ENOMEM;

		if (mddi_pdata && mddi_pdata->mddi_power_save)
			mddi_pdata->mddi_power_save(1);

		mddi_resource_initialized = 1;
		return 0;
	}

	if (!mddi_resource_initialized)
		return -EPERM;

	mfd = platform_get_drvdata(pdev);

	if (!mfd)
		return -ENODEV;

	if (mfd->key != MFD_KEY)
		return -EINVAL;

	if (pdev_list_cnt >= MSM_FB_MAX_DEV_LIST)
		return -ENOMEM;

	mdp_dev = platform_device_alloc("mdp", pdev->id);
	if (!mdp_dev)
		return -ENOMEM;

	/*
	 * link to the latest pdev
	 */
	mfd->pdev = mdp_dev;
	mfd->dest = DISPLAY_LCD;

	/*
	 * alloc panel device data
	 */
	if (platform_device_add_data
	    (mdp_dev, pdev->dev.platform_data,
	     sizeof(struct msm_fb_panel_data))) {
		printk(KERN_ERR "mddi_probe: platform_device_add_data failed!\n");
		platform_device_put(mdp_dev);
		return -ENOMEM;
	}
	/*
	 * data chain
	 */
	pdata = mdp_dev->dev.platform_data;
	pdata->on = mddi_on;
	pdata->off = mddi_off;
	pdata->next = pdev;

	/*
	 * get/set panel specific fb info
	 */
	mfd->panel_info = pdata->panel_info;

	if (mfd->index == 0)
		mfd->fb_imgType = MSMFB_DEFAULT_TYPE;
	else
		mfd->fb_imgType = MDP_RGB_565;

	clk_rate = mfd->panel_info.clk_max;
	if (mddi_pdata &&
	    mddi_pdata->mddi_sel_clk &&
	    mddi_pdata->mddi_sel_clk(&clk_rate))
			printk(KERN_ERR
			  "%s: can't select mddi io clk targate rate = %d\n",
			  __func__, clk_rate);

	if (clk_set_max_rate(mddi_clk, clk_rate) < 0)
		printk(KERN_ERR "%s: clk_set_max_rate failed\n", __func__);
	mfd->panel_info.clk_rate = mfd->panel_info.clk_min;

	if (!mddi_client_type)
		mddi_client_type = mfd->panel_info.lcd.rev;
	else if (!mfd->panel_info.lcd.rev)
		printk(KERN_ERR
		"%s: mddi client is trying to revert back to type 1	!!!\n",
		__func__);

	/*
	 * set driver data
	 */
	platform_set_drvdata(mdp_dev, mfd);
	rc = pm_runtime_set_active(&pdev->dev);
	if (rc < 0)
		printk(KERN_ERR "pm_runtime: fail to set active\n");

	rc = 0;
	pm_runtime_enable(&pdev->dev);
	/*
	 * register in mdp driver
	 */
	rc = platform_device_add(mdp_dev);
	if (rc)
		goto mddi_probe_err;

	pdev_list[pdev_list_cnt++] = pdev;

#ifdef CONFIG_HAS_EARLYSUSPEND
	mfd->mddi_early_suspend.level = EARLY_SUSPEND_LEVEL_DISABLE_FB;
	mfd->mddi_early_suspend.suspend = mddi_early_suspend;
	mfd->mddi_early_suspend.resume = mddi_early_resume;
	register_early_suspend(&mfd->mddi_early_suspend);
#endif

	mfd->pm_qos_req = pm_qos_add_request(PM_QOS_SYSTEM_BUS_FREQ,
					       PM_QOS_DEFAULT_VALUE);
	if (!mfd->pm_qos_req)
		goto mddi_probe_err;

	return 0;

mddi_probe_err:
	platform_device_put(mdp_dev);
	return rc;
}
static int __devinit dock_keyboard_probe(struct platform_device *pdev)
{
	struct dock_keyboard_platform_data *pdata = pdev->dev.platform_data;
	struct dock_keyboard_data *data;
	struct input_dev *input;
	int i;
	int ret;

	pr_debug("kbd: probe\n");

	data = kzalloc(sizeof(struct dock_keyboard_data), GFP_KERNEL);
	if (unlikely(IS_ERR(data))) {
		ret = -ENOMEM;
		goto err_alloc_mem;
	}

	sec_dock_kbd_driver.private_data = data;

	INIT_WORK(&data->work_msg, key_event_work);
	platform_set_drvdata(pdev, data);

	input = input_allocate_device();
	if (unlikely(IS_ERR(input))) {
		pr_err("kbd: failed to allocate input device.\n");
		ret = -ENOMEM;
		goto err_alloc_input_dev;
	}

	data->input_dev = input;
	input_set_drvdata(data->input_dev, data);
	data->kl = UNKNOWN_KEYLAYOUT;

	input->name = pdev->name;
	input->dev.parent = &pdev->dev;
	input->id.bustype = BUS_RS232;
	input->event = dock_keyboard_event;

	set_bit(EV_SYN, input->evbit);
	set_bit(EV_KEY, input->evbit);
	set_bit(EV_LED, input->evbit);
	set_bit(LED_CAPSL, input->ledbit);

	for (i = 0; i < KEYBOARD_SIZE; i++) {
		if (KEY_RESERVED != dock_keycodes[i].keycode) {
			input_set_capability(input, EV_KEY,
					     dock_keycodes[i].keycode);
		}
	}

	/* for the UK keyboard */
	input_set_capability(input, EV_KEY, KEY_NUMERIC_POUND);

	/* for the remaped keys */
	input_set_capability(input, EV_KEY, KEY_NEXTSONG);
	input_set_capability(input, EV_KEY, KEY_PREVIOUSSONG);

	ret = input_register_device(data->input_dev);
	if (unlikely(ret)) {
		pr_err("kbd: failed to register input device.\n");
		goto err_reg_input_dev;
	}

	data->dock_irq_gpio = pdata->dock_irq_gpio;
	data->power = pdata->power;

	if (pdata->register_cb)
		pdata->register_cb(input, dock_keyboard_cb);

#ifdef CONFIG_HAS_EARLYSUSPEND
	data->early_suspend.level = EARLY_SUSPEND_LEVEL_BLANK_SCREEN + 1;
	data->early_suspend.suspend = dock_keyboard_early_suspend;
	data->early_suspend.resume = dock_keyboard_late_resume;
	register_early_suspend(&data->early_suspend);
#endif /* CONFIG_HAS_EARLYSUSPEND */

	init_timer(&data->key_timer);
	data->key_timer.data = (unsigned long)data;
	data->key_timer.expires = jiffies + HZ / 3;
	data->key_timer.function = remapkey_timer;

	init_timer(&data->off_timer);
	data->off_timer.data = (unsigned long)data;
	data->off_timer.expires = jiffies + HZ * 2 / 3;
	data->off_timer.function = power_off_timer;

	ret = serio_register_driver(&sec_dock_kbd_driver.serio_drv);
	if (unlikely(ret)) {
		pr_err("kbd: failed to register serio driver!\n");
		goto err_reg_serio_drv;
	}

	return 0;

err_reg_serio_drv:
#ifdef CONFIG_HAS_EARLYSUSPEND
	unregister_early_suspend(&data->early_suspend);
#endif
	if (pdata->register_cb)
		pdata->register_cb(NULL, NULL);
	input_unregister_device(input);
err_reg_input_dev:
	input_free_device(input);
	input_set_drvdata(input, NULL);
err_alloc_input_dev:
	kfree(data);
err_alloc_mem:
	return ret;
}
static int cyttsp4_btn_probe(struct cyttsp4_device *ttsp)
{
	struct cyttsp4_btn_data *bd;
	struct device *dev = &ttsp->dev;
	struct cyttsp4_btn_platform_data *pdata = dev_get_platdata(dev);
	int rc = 0;

	dev_info(dev, "%s\n", __func__);
	dev_dbg(dev, "%s: debug on\n", __func__);
	dev_vdbg(dev, "%s: verbose debug on\n", __func__);

/*Increase the judgment conditions*/
	if (pdata == NULL) {
		dev_err(dev, "%s: Missing platform data\n", __func__);
		rc = -ENODEV;
		goto error_no_pdata;
	}
	bd = kzalloc(sizeof(*bd), GFP_KERNEL);
	if (bd == NULL) {
		dev_err(dev, "%s: Error, kzalloc\n", __func__);
		rc = -ENOMEM;
		goto error_alloc_data_failed;
	}

	mutex_init(&bd->report_lock);
	bd->ttsp = ttsp;
	bd->pdata = pdata;
	dev_set_drvdata(dev, bd);
	/* Create the input device and register it. */
	dev_vdbg(dev, "%s: Create the input device and register it\n",
		__func__);
	bd->input = input_allocate_device();
	if (bd->input == NULL) {
		dev_err(dev, "%s: Error, failed to allocate input device\n",
			__func__);
		rc = -ENOSYS;
		goto error_alloc_failed;
	}

	bd->input->name = ttsp->name;
	scnprintf(bd->phys, sizeof(bd->phys)-1, "%s", dev_name(dev));
	bd->input->phys = bd->phys;
	bd->input->dev.parent = &bd->ttsp->dev;
	bd->input->open = cyttsp4_btn_open;
	bd->input->close = cyttsp4_btn_close;
	input_set_drvdata(bd->input, bd);

	pm_runtime_enable(dev);

	/* get sysinfo */
	bd->si = cyttsp4_request_sysinfo(ttsp);
	if (bd->si) {
		rc = cyttsp4_setup_input_device(ttsp);
		if (rc)
			goto error_init_input;
	} else {
		dev_err(dev, "%s: Fail get sysinfo pointer from core p=%p\n",
			__func__, bd->si);
		cyttsp4_subscribe_attention(ttsp, CY_ATTEN_STARTUP,
			cyttsp4_setup_input_attention, 0);
	}

#ifdef CONFIG_HAS_EARLYSUSPEND
	bd->es.level = EARLY_SUSPEND_LEVEL_BLANK_SCREEN + 1;
	bd->es.suspend = cyttsp4_btn_early_suspend;
	bd->es.resume = cyttsp4_btn_late_resume;
	register_early_suspend(&bd->es);
#endif

	dev_dbg(dev, "%s: ok\n", __func__);
	return 0;

error_init_input:
	pm_runtime_suspend(dev);
	pm_runtime_disable(dev);
	input_free_device(bd->input);
error_alloc_failed:
	dev_set_drvdata(dev, NULL);
	kfree(bd);
error_alloc_data_failed:
error_no_pdata:
	dev_err(dev, "%s failed.\n", __func__);
	return rc;
}
static int __devinit adxl34x_i2c_probe(struct i2c_client *client,
				       const struct i2c_device_id *id)
{
	struct adxl34x *ac;
	int error = -1;
	struct adxl34x_platform_data *devpd = client->dev.platform_data;

	if (!devpd) {
		dev_err(&client->dev, "No platfrom data: Using default initialization\n");
		error = -EINVAL;
		goto get_platdata_error;
	}

	error = i2c_check_functionality(client->adapter,
			I2C_FUNC_SMBUS_BYTE_DATA);
	if (!error) {
		dev_err(&client->dev, "SMBUS Byte Data not Supported %d\n", error);
		goto i2c_detect_error;
	}

	ac = kzalloc(sizeof(struct adxl34x), GFP_KERNEL);
	if (NULL == ac) {
		dev_err(&client->dev, "alloc adxl34x failed\n");
		error = -ENOMEM;
		goto alloc_mem_error;
	}

	i2c_set_clientdata(client, ac);
	ac->bus = client;

	if (i2c_check_functionality(client->adapter,
				    I2C_FUNC_SMBUS_READ_I2C_BLOCK))
		ac->read_block = adxl34x_i2c_smbus_read_block_data;
	else
		ac->read_block = adxl34x_i2c_master_read_block_data;

	ac->read = adxl34x_i2c_smbus_read;
	ac->write = adxl34x_i2c_smbus_write;

	error = adxl34x_initialize(client, ac);
	if (error) {
		dev_err(&client->dev, "initialize failed %d.\n", error);
		goto init_error;
	}

#ifdef CONFIG_HAS_EARLYSUSPEND
	ac->early_suspend.level = EARLY_SUSPEND_LEVEL_BLANK_SCREEN + 1;
	ac->early_suspend.suspend = adxl34x_early_suspend;
	ac->early_suspend.resume = adxl34x_late_resume;
	register_early_suspend(&ac->early_suspend);
#endif

	return 0;

init_error:
	i2c_set_clientdata(client, NULL);
	kfree(ac);
	ac = NULL;
alloc_mem_error:
i2c_detect_error:
get_platdata_error:

	return error;
}
static int __devinit mma8452_probe(struct i2c_client *client,
				   const struct i2c_device_id *id)
{
	int result, client_id;
	struct input_dev *idev;
	struct i2c_adapter *adapter;
	struct mma8452_data *mma;

	const struct mma8452_platform_data *pdata = client->dev.platform_data;
	
	if (!pdata) {
		dev_err(&client->dev, "platform data for layout is NULL; exiting\n");
		return -EINVAL;
	}


	/* Allocate memory for driver data */
	mma = kzalloc(sizeof(struct mma8452_data), GFP_KERNEL);
	if (!mma) {
		printk(KERN_ERR "mma8452_probe: memory allocation failed.\n");
		return -ENOMEM;
	}

	mma8452_i2c_client = client;

	printk(SENSOR_TAG "come into %s\n",__FUNCTION__);
	adapter = to_i2c_adapter(client->dev.parent);
	result = i2c_check_functionality(adapter,
					 I2C_FUNC_SMBUS_BYTE |
					 I2C_FUNC_SMBUS_BYTE_DATA);
	if (!result)
		goto err_out;
	else
		printk(SENSOR_TAG "i2c_check_functionality() was called success\n");

	client_id = i2c_smbus_read_byte_data(client, MMA8452_WHO_AM_I);

	if (client_id != MMA8452_ID && client_id != MMA8452_ID) {
		dev_err(&client->dev,
			"read chip ID 0x%x is not equal to 0x%x or 0x%x!\n",
			result, MMA8452_ID, MMA8452_ID);
    	printk(SENSOR_TAG "I2C read error\n");
		result = -EINVAL;
		goto err_out;
	}else{
		printk(SENSOR_TAG "read chip ID is :0x%x\n",client_id);
	}

	/* Initialize the MMA8452 chip */
	result = mma8452_change_mode(client, senstive_mode);
	if (result) {
		dev_err(&client->dev,
			"error when init mma8452 chip:(%d)\n", result);
		goto err_out;
	}

	hwmon_dev = hwmon_device_register(&client->dev);
	if (!hwmon_dev) {
		result = -ENOMEM;
		dev_err(&client->dev,
			"error when register hwmon device\n");
		goto err_out;
	}

	mma8452_idev = input_allocate_polled_device();
	if (!mma8452_idev) {
		result = -ENOMEM;
		dev_err(&client->dev, "alloc poll device failed!\n");
		goto err_alloc_poll_device;
	}
	mma8452_idev->poll = mma8452_dev_poll;
	mma8452_idev->poll_interval = POLL_INTERVAL;
	mma8452_idev->poll_interval_min = POLL_INTERVAL_MIN;
	mma8452_idev->poll_interval_max = POLL_INTERVAL_MAX;
	idev = mma8452_idev->input;
	if (client_id == MMA8452_ID)
		idev->name = "mma8452";
	else
		idev->name = "mma8452";
	idev->id.bustype = BUS_I2C;
	idev->evbit[0] = BIT_MASK(EV_ABS);

	input_set_abs_params(idev, ABS_X, -8192, 8191, INPUT_FUZZ, INPUT_FLAT);
	input_set_abs_params(idev, ABS_Y, -8192, 8191, INPUT_FUZZ, INPUT_FLAT);
	input_set_abs_params(idev, ABS_Z, -8192, 8191, INPUT_FUZZ, INPUT_FLAT);

	result = input_register_polled_device(mma8452_idev);
	if (result) {
		dev_err(&client->dev, "register poll device failed!\n");
		goto err_register_polled_device;
	}

	mma->mma_early_suspend.suspend = mma8452_early_suspend;
	mma->mma_early_suspend.resume = mma8452_early_resume;
	register_early_suspend(&mma->mma_early_suspend);
	
    result = sysfs_create_group(&idev->dev.kobj, &mma8452_attr_group);
	if (result) {
		dev_err(&client->dev, "create device file failed!\n");
		result = -EINVAL;
		goto err_register_polled_device;
	}
	mma_status.position = (*pdata).axis_map_cordination;
	return 0;    
err_register_polled_device:
	input_free_polled_device(mma8452_idev);
err_alloc_poll_device:
	hwmon_device_unregister(&client->dev);
err_out:
	return result;
}
Beispiel #8
0
static int yas_probe(struct i2c_client *i2c, const struct i2c_device_id *id)
{
    struct yas_state *st;
    struct iio_dev *indio_dev;
    int ret, i;
    s8 *bias;
    struct yas_acc_platform_data *pdata;

    I("%s\n", __func__);

    this_client = i2c;
    indio_dev = iio_device_alloc(sizeof(*st));
    if (!indio_dev) {
        ret = -ENOMEM;
        goto error_ret;
    }
    i2c_set_clientdata(i2c, indio_dev);

    indio_dev->name = id->name;
    indio_dev->dev.parent = &i2c->dev;
    indio_dev->info = &yas_info;
    indio_dev->channels = yas_channels;
    indio_dev->num_channels = ARRAY_SIZE(yas_channels);
    indio_dev->modes = INDIO_DIRECT_MODE;

    st = iio_priv(indio_dev);
    st->client = i2c;
    st->sampling_frequency = 20;
    st->acc.callback.device_open = yas_device_open;
    st->acc.callback.device_close = yas_device_close;
    st->acc.callback.device_read = yas_device_read;
    st->acc.callback.device_write = yas_device_write;
    st->acc.callback.usleep = yas_usleep;
    st->acc.callback.current_time = yas_current_time;
    st->indio_dev = indio_dev;
    INIT_DELAYED_WORK(&st->work, yas_work_func);
    mutex_init(&st->lock);
#ifdef CONFIG_HAS_EARLYSUSPEND
    st->sus.level = EARLY_SUSPEND_LEVEL_BLANK_SCREEN + 1;
    st->sus.suspend = yas_early_suspend;
    st->sus.resume = yas_late_resume;
    register_early_suspend(&st->sus);
#endif
    ret = yas_probe_buffer(indio_dev);
    if (ret)
        goto error_free_dev;
    ret = yas_probe_trigger(indio_dev);
    if (ret)
        goto error_remove_buffer;
    ret = iio_device_register(indio_dev);
    if (ret)
        goto error_remove_trigger;
    ret = yas_acc_driver_init(&st->acc);
    if (ret < 0) {
        ret = -EFAULT;
        goto error_unregister_iio;
    }
    ret = st->acc.init();
    if (ret < 0) {
        ret = -EFAULT;
        goto error_unregister_iio;
    }
    ret = st->acc.set_enable(1);
    if (ret < 0) {
        ret = -EFAULT;
        goto error_driver_term;
    }

    pdata = kzalloc(sizeof(*pdata), GFP_KERNEL);
    if (pdata == NULL)
        E("%s: memory allocation for pdata failed.", __func__);
    else
        yas_parse_dt(&i2c->dev , pdata);

    for (i = 0; i < 3; i++) {
        st->accel_data[i] = 0;
        bias = (s8 *)&pdata->gs_kvalue;
        st->calib_bias[i] = -(bias[2-i] *
                              YAS_GRAVITY_EARTH / 256);
        I("%s: calib_bias[%d] = %d\n", __func__, i, st->calib_bias[i]);
    }

    mutex_lock(&st->lock);
    if ((pdata->placement < 8) && (pdata->placement >= 0)) {
        ret = st->acc.set_position(pdata->placement);
        I("%s: set position = %d\n", __func__, pdata->placement);
    } else {
        ret = st->acc.set_position(5);
        D("%s: set default position = 5\n", __func__);
    }
    mutex_unlock(&st->lock);

#ifdef CONFIG_CIR_ALWAYS_READY
    module.IRQ = i2c->irq;
    I("%s: IRQ = %d\n", __func__, module.IRQ);
    ret = request_irq(module.IRQ, kxtj2_irq_handler, IRQF_TRIGGER_RISING,
                      "kxtj2", &module);
    enable_irq_wake(module.IRQ);
    if (ret)
        E("%s: Could not request irq = %d\n", __func__, module.IRQ);

    module.kxtj2_wq = create_singlethread_workqueue("kxtj2_wq");
    if (!module.kxtj2_wq) {
        E("%s: Can't create workqueue\n", __func__);
        ret = -ENOMEM;
        goto error_create_singlethread_workqueue;
    }
#endif

    init_irq_work(&st->iio_irq_work, iio_trigger_work);
    g_st = st;

    ret = create_sysfs_interfaces(st);
    if (ret) {
        E("%s: create_sysfs_interfaces fail, ret = %d\n",
          __func__, ret);
        goto err_create_fixed_sysfs;
    }

    return 0;

err_create_fixed_sysfs:

#ifdef CONFIG_CIR_ALWAYS_READY
    if (module.kxtj2_wq)
        destroy_workqueue(module.kxtj2_wq);
error_create_singlethread_workqueue:
#endif
    kfree(pdata);
error_driver_term:
    st->acc.term();
error_unregister_iio:
    iio_device_unregister(indio_dev);
error_remove_trigger:
    yas_remove_trigger(indio_dev);
error_remove_buffer:
    yas_remove_buffer(indio_dev);
error_free_dev:
#ifdef CONFIG_HAS_EARLYSUSPEND
    unregister_early_suspend(&st->sus);
#endif
    iio_device_free(indio_dev);
error_ret:
    i2c_set_clientdata(i2c, NULL);
    this_client = NULL;
    return ret;
}
Beispiel #9
0
static int __devinit mipi_samsung_disp_probe(struct platform_device *pdev)
{
	int ret, rc;
	struct platform_device *msm_fb_added_dev;
	struct lcd_device *lcd_device;
	struct backlight_device *bd = NULL;

	printk(KERN_INFO "[lcd] mipi_samsung_disp_probe start\n");
	if (pdev->id == 0) {
		msd.mipi_samsung_disp_pdata = pdev->dev.platform_data;

		printk(KERN_INFO
		"[lcd] pdev->id =%d,  pdev-name = %s\n", pdev->id, pdev->name);
		sec_debug_mdp_init();
		printk(KERN_INFO "[lcd] mipi_samsung_disp_probe end since pdev-id is 0\n");

		return 0;
	}

	printk(KERN_INFO "[lcd] msm_fb_add_device : %s\n", pdev->name);

	msm_fb_added_dev = msm_fb_add_device(pdev);

	mutex_init(&dsi_tx_mutex);

#if defined(CONFIG_HAS_EARLYSUSPEND) || defined(CONFIG_LCD_CLASS_DEVICE)
	msd.msm_pdev = msm_fb_added_dev;
#endif

	pm_gpio8 = PM8921_GPIO_PM_TO_SYS(PMIC_GPIO_ERR_FG);

	rc = gpio_request(pm_gpio8, "err_fg");

	if (rc) {
		pr_err("request gpio err_fg failed, rc=%d\n", rc);
		return -ENODEV;
	}

	rc = pm8xxx_gpio_config(pm_gpio8, &gpio_get_param);

	if (rc) {
		pr_err("gpio_config mlcd_rst failed (3), rc=%d\n", rc);
		return -EINVAL;
	}

#if defined(CONFIG_HAS_EARLYSUSPEND)
	msd.early_suspend.suspend = mipi_samsung_disp_early_suspend;
	msd.early_suspend.resume = mipi_samsung_disp_late_resume;
	msd.early_suspend.level = EARLY_SUSPEND_LEVEL_BLANK_SCREEN;
	register_early_suspend(&msd.early_suspend);
#endif

#if defined(CONFIG_LCD_CLASS_DEVICE)
	printk(KERN_INFO "[lcd] lcd_device_register for panel start\n");

	lcd_device = lcd_device_register("panel", &pdev->dev, NULL,
			&mipi_samsung_disp_props);

	if (IS_ERR(lcd_device)) {
		ret = PTR_ERR(lcd_device);
		printk(KERN_ERR "lcd : failed to register device\n");
		return ret;
	}

	sysfs_remove_file(&lcd_device->dev.kobj,
			&dev_attr_lcd_power.attr);

	ret = sysfs_create_file(&lcd_device->dev.kobj,
			&dev_attr_lcd_power.attr);
	if (ret) {
		pr_info("sysfs create fail-%s\n",
				dev_attr_lcd_power.attr.name);
	}

	ret = sysfs_create_file(&lcd_device->dev.kobj,
			&dev_attr_lcd_type.attr);
	if (ret) {
		pr_info("sysfs create fail-%s\n",
				dev_attr_lcd_type.attr.name);
	}

	ret = sysfs_create_file(&lcd_device->dev.kobj,
			&dev_attr_window_type.attr);
	if (ret) {
		pr_info("sysfs create fail-%s\n",
				dev_attr_window_type.attr.name);
	}

	ret = sysfs_create_file(&lcd_device->dev.kobj,
					&dev_attr_power_reduce.attr);
	if (ret) {
		pr_info("sysfs create fail-%s\n",
				dev_attr_power_reduce.attr.name);
	}

	ret = sysfs_create_file(&lcd_device->dev.kobj,
					&dev_attr_siop_enable.attr);
	if (ret) {
		pr_info("sysfs create fail-%s\n",
				dev_attr_siop_enable.attr.name);
	}
	
	ret = sysfs_create_file(&lcd_device->dev.kobj,
					&dev_attr_backlight.attr);
	if (ret) {
		pr_info("sysfs create fail-%s\n",
				dev_attr_backlight.attr.name);
	}

#if defined(RUMTIME_MIPI_CLK_CHANGE)
	ret = sysfs_create_file(&lcd_device->dev.kobj,
						&dev_attr_fps_change.attr);
	if (ret) {
		pr_info("sysfs create fail-%s\n",
				dev_attr_fps_change.attr.name);
	}
#endif

	ret = sysfs_create_file(&lcd_device->dev.kobj,
						&dev_attr_temperature.attr);
	if (ret) {
		pr_info("sysfs create fail-%s\n",
				dev_attr_temperature.attr.name);
	}

	printk(KERN_INFO "[lcd] backlight_device_register for panel start\n");

	bd = backlight_device_register("panel", &lcd_device->dev,
			NULL, NULL, NULL);
	if (IS_ERR(bd)) {
		ret = PTR_ERR(bd);
		pr_info("backlight : failed to register device\n");
		return ret;
	}

	ret = sysfs_create_file(&bd->dev.kobj,
			&dev_attr_auto_brightness.attr);
	if (ret) {
		pr_info("sysfs create fail-%s\n",
				dev_attr_auto_brightness.attr.name);
	}
#endif

#if defined(CONFIG_MDNIE_LITE_TUNING)
	pr_info("[%s] CONFIG_MDNIE_LITE_TUNING ok ! init class called!\n",
		__func__);
	mdnie_lite_tuning_init();
#endif

#if defined(DDI_VIDEO_ENHANCE_TUNING)
	ret = sysfs_create_file(&lcd_device->dev.kobj,
			&dev_attr_tuning.attr);
	if (ret) {
		pr_info("sysfs create fail-%s\n",
				dev_attr_tuning.attr.name);
	}
#endif

	printk(KERN_INFO "[lcd] mipi_samsung_disp_probe end\n");

	return 0;
}
static int ofn_input_dev_open(struct input_dev *dev)
{
	int  rc = 0;
	struct avago_ofn_data  *dd = input_get_drvdata(dev);
	uint8_t            buf[2];
	uint8_t delta_xy_buf[2] = {23, 23}; 
	uint8_t motion = 23;
       static int open_time = 0;

       open_time++;
       if (open_time > 1)
       {
           return 0; // only open one time
       }
       
	if (!dd) {
		rc = -ENOMEM;
		goto dev_open_exit;
	}
    
#if 1
	printk("chenjun: ofn_input_dev_open: SHUTDOWN = %d\n", gpio_get_value(GPIO_OFN_SHUTDOWN));
	printk("chenjun: ofn_input_dev_open: RESET = %d\n", gpio_get_value(GPIO_OFN_RESET));

#if 0	
	gpio_direction_output(GPIO_OFN_SHUTDOWN, 1);
	gpio_direction_output(GPIO_OFN_RESET, 1);
       mdelay(803); // Minimum: 500ms

       gpio_direction_output(GPIO_OFN_RESET, 1);
#endif

	
	
#if 0
	rc = gpio_direction_input(GPIO_OFN_MOTION);
	if (rc) {
		goto dev_open_exit;
	}
	rc = request_irq(GPIO_OFN_MOTION_INT, &ofn_interrupt,
		                   IRQF_TRIGGER_FALLING, "ofn", 0); 
	if (rc) {

		goto dev_open_exit;
	}
#endif
#if 1
	gpio_direction_output(GPIO_OFN_SHUTDOWN, 0);
	gpio_direction_output(GPIO_OFN_RESET, 0);
       udelay(23); // 39 // Minimum: 20us
	gpio_direction_output(GPIO_OFN_RESET, 1);

       mdelay(100); // 203 // Minimum: 100ms
#endif

#if 0
	init_timer(&ofn_next_key_timer);
	ofn_next_key_timer.function = ofn_next_key_timer_callback;
	ofn_next_key_timer.data = 0;
#endif
	rc = ofn_config(dd);
     if (rc!=0)
	 goto	ofn_config_fail;

#if 1
	rc = gpio_direction_input(GPIO_OFN_MOTION);
	if (rc) {
		goto dev_open_exit;
	}
	rc = request_irq(GPIO_OFN_MOTION_INT, &ofn_interrupt,
		                   IRQF_TRIGGER_FALLING, "ofn", 0); 
	if (rc) {
		goto dev_open_exit;
	}
#endif
#if 1
//
        rc = ofn_i2c_read(dd->clientp, 0x02, &motion, 1);
        rc = ofn_i2c_read(dd->clientp, OFN_REG_DELTA_X, &delta_xy_buf[0], 1);
        rc = ofn_i2c_read(dd->clientp, OFN_REG_DELTA_Y, &delta_xy_buf[1], 1);
//

    rc = ofn_i2c_read(dd->clientp, OFN_REG_PRODUCT_ID, buf, 1);
    if (rc)
	goto ofn_config_fail;

#endif

#ifdef CONFIG_HAS_EARLYSUSPEND

	dd->early_suspend.level = 52;
	dd->early_suspend.suspend = ofn_early_suspend;
	dd->early_suspend.resume = ofn_late_resume;
	register_early_suspend(&dd->early_suspend);
#endif

	return 0;


ofn_config_fail:
dev_open_exit:
	return rc;
#endif
}
Beispiel #11
0
static int __devinit bd2802_probe(struct i2c_client *client,
			const struct i2c_device_id *id)
{
	struct bd2802_led *led;
	int ret, i;

	pr_warning("%s() -- start\n", __func__);

	led = kzalloc(sizeof(struct bd2802_led), GFP_KERNEL);
	if (!led) {
		dev_err(&client->dev, "failed to allocate driver data\n");
		return -ENOMEM;
	}

	led->client = client;
	i2c_set_clientdata(client, led);

	INIT_WORK(&led->work, bd2802_work_func);
	INIT_WORK(&led->touchkey_work, bd2802_touchkey_work_func);
	INIT_WORK(&led->ledmin_work, bd2802_ledmin_work_func);
	
	led->bd2802_wq = create_singlethread_workqueue("bd2802_wq");
	if (!led->bd2802_wq)
		return -ENOMEM;

	led->touchkey_wq = create_singlethread_workqueue("touchkey_wq");
	if (!led->touchkey_wq)
		return -ENOMEM;

	led->ledmin_wq = create_singlethread_workqueue("ledmin_wq");
	if (!led->ledmin_wq)
		return -ENOMEM;

	bd2802_i2c_client = led->client;
	/* Default attributes */
	led->wave_pattern = BD2802_PATTERN_FULL;
	led->blink_enable =0;
	led->led_state = BD2802_SEQ;
	led->key_led = ALL;
	led->key_direction= FORWARD;
	led->led_counter=0;
#if defined(BLINK_ON_BOOTING)
	led->white_current = BD2802_CURRENT_WHITE_MAX;
	led->blue_current = BD2802_CURRENT_000;
#else
	led->white_current = BD2802_CURRENT_WHITE_MAX;
	led->blue_current = BD2802_CURRENT_BLUE_MAX;
#endif

	init_rwsem(&led->rwsem);

	for (i = 0; i < ARRAY_SIZE(bd2802_attributes); i++) {
		ret = device_create_file(&led->client->dev,
						bd2802_attributes[i]);
		if (ret) {
			dev_err(&led->client->dev, "failed: sysfs file %s\n",
					bd2802_attributes[i]->attr.name);
			goto failed_unregister_dev_file;
		}
	}

	hrtimer_init(&led->timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
	led->timer.function = bd2802_timer_func;
#if defined(BLINK_ON_BOOTING)
#else
	hrtimer_start(&led->timer, ktime_set(4, 0), HRTIMER_MODE_REL);
#endif
	
	hrtimer_init(&led->touchkey_timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
	led->touchkey_timer.function = bd2802_touchkey_timer_func;
	
	hrtimer_init(&led->ledmin_timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
	led->ledmin_timer.function = bd2802_ledmin_timer_func;
	

#ifdef CONFIG_HAS_EARLYSUSPEND
	led->early_suspend.level = EARLY_SUSPEND_LEVEL_BLANK_SCREEN;
	led->early_suspend.suspend = bd2802_early_suspend;
	led->early_suspend.resume = bd2802_late_resume;
	register_early_suspend(&led->early_suspend);
#endif

	bd2802_configure(led);
#if defined(BLINK_ON_BOOTING)
	led->blink_enable =1;
#endif
	bd2802_on(led);
	bd2802_enable(led);

//LGE_UPDATE
	led->led_state=BD2802_ON;
//LGE_UPDATE
	return 0;

failed_unregister_dev_file:
	for (i--; i >= 0; i--)
		device_remove_file(&led->client->dev, bd2802_attributes[i]);

	return ret;
}
int __init acer_panel_init(void)
{
	int err;
	struct resource *res;

	tegra_get_board_info(&board_info);

	acer_carveouts[1].base = tegra_carveout_start;
	acer_carveouts[1].size = tegra_carveout_size;

	tegra_gpio_enable(LVDS_SHUTDOWN);
	tegra_gpio_enable(LCD_VDD);
	tegra_gpio_enable(LCD_CABC);
	tegra_gpio_enable(BL_ENABLE);
#if defined(CONFIG_TEGRA_HDMI)
	tegra_gpio_enable(HDMI_HPD);
#endif
	gpio_request(LVDS_SHUTDOWN, "lvds_shutdown");
	gpio_request(LCD_VDD, "lcd_vdd");
	gpio_request(LCD_CABC, "lcd_cabc");
	gpio_request(BL_ENABLE, "bl_enable");
#if defined(CONFIG_TEGRA_HDMI)
	gpio_request(HDMI_HPD, "hdmi_hpd");
#endif

	gpio_direction_output(LVDS_SHUTDOWN,1);
	gpio_direction_output(LCD_VDD, 1);
	gpio_direction_output(LCD_CABC,0);
	gpio_direction_output(BL_ENABLE,1);

#if defined(CONFIG_TEGRA_HDMI)
	tegra_gpio_enable(HDMI_5V);
	err = gpio_request(HDMI_5V, "hdmi_5V_enable");
	if (err) {
		pr_err("[HDMI] request 5V_enable failed\n");
	}
#if HDMI_5V_ALWAYS_ON
	err = gpio_direction_output(HDMI_5V, 1);
#else
	err = gpio_direction_output(HDMI_5V, 0);
#endif
	if (err) {
		pr_err("[HDMI] failed to set direction of hdmi_5V_enable\n");
	}
#endif

#ifdef CONFIG_HAS_EARLYSUSPEND
	acer_panel_early_suspender.suspend = acer_panel_early_suspend;
	acer_panel_early_suspender.resume = acer_panel_late_resume;
	acer_panel_early_suspender.level = EARLY_SUSPEND_LEVEL_DISABLE_FB;
	register_early_suspend(&acer_panel_early_suspender);
#endif

	err = platform_add_devices(acer_gfx_devices,
			ARRAY_SIZE(acer_gfx_devices));

#if defined(CONFIG_TEGRA_GRHOST) && defined(CONFIG_TEGRA_DC)
	if ((acer_board_type == BOARD_PICASSO_M) || (acer_board_type == BOARD_PICASSO_E2)) {
		res = nvhost_get_resource_byname(&acer_pm_disp1_device,
				IORESOURCE_MEM, "fbmem");
	}else{
		res = nvhost_get_resource_byname(&acer_p2_disp1_device,
				IORESOURCE_MEM, "fbmem");
	}
	res->start = tegra_fb_start;
	res->end = tegra_fb_start + tegra_fb_size - 1;
#endif

	/* Copy the bootloader fb to the fb. */
	tegra_move_framebuffer(tegra_fb_start, tegra_bootloader_fb_start,
				min(tegra_fb_size, tegra_bootloader_fb_size));

#if defined(CONFIG_TEGRA_GRHOST) && defined(CONFIG_TEGRA_DC)
	if(!err){
		if ((acer_board_type == BOARD_PICASSO_M) || (acer_board_type == BOARD_PICASSO_E2)) {
			err = nvhost_device_register(&acer_pm_disp1_device);
		}else{
			err = nvhost_device_register(&acer_p2_disp1_device);
		}
	}
#if defined(CONFIG_TEGRA_HDMI)
	res = nvhost_get_resource_byname(&acer_disp2_device,
				IORESOURCE_MEM, "fbmem");
	res->start = tegra_fb2_start;
	res->end = tegra_fb2_start + tegra_fb2_size - 1;
	if (!err)
		err = nvhost_device_register(&acer_disp2_device);
#endif
#endif

#if defined(CONFIG_TEGRA_GRHOST) && defined(CONFIG_TEGRA_NVAVP)
	if (!err)
		err = nvhost_device_register(&nvavp_device);
#endif
	return err;
}
static int rt9396_probe(struct i2c_client *i2c_dev, const struct i2c_device_id *i2c_dev_id)
{
	struct lge_backlight_platform_data *pdata;
	struct rt9396_driver_data *drvdata;
	struct backlight_device *bd;
	int err;

	rt9396_powerstate = NORMAL_STATE;
	dprintk("start, client addr=0x%x\n", i2c_dev->addr);

	pdata = i2c_dev->dev.platform_data;
	if(!pdata)
		return -EINVAL;

	drvdata = kzalloc(sizeof(struct rt9396_driver_data), GFP_KERNEL);
	if (!drvdata) {
		dev_err(&i2c_dev->dev, "failed to allocate memory\n");
		return -ENOMEM;
	}

	if (pdata && pdata->platform_init)
		pdata->platform_init();

	drvdata->client = i2c_dev;
	drvdata->gpio = pdata->gpio;
	drvdata->max_intensity = LCD_LED_MAX;
	if (pdata->max_current > 0)
		drvdata->max_intensity = pdata->max_current;
	drvdata->intensity = LCD_LED_MIN;
	drvdata->mode = NORMAL_MODE;
	drvdata->state = UNINIT_STATE;
	drvdata->version = pdata->version;

	if(rt9396_setup_version(drvdata) != 0) {
		eprintk("Error while requesting gpio %d\n", drvdata->gpio);
		kfree(drvdata);
		return -ENODEV;
	}

	if (drvdata->gpio && gpio_request(drvdata->gpio, "rt9396_en") != 0) {
		eprintk("Error while requesting gpio %d\n", drvdata->gpio);
		kfree(drvdata);
		return -ENODEV;
	}
	gpio_tlmm_config(GPIO_CFG(drvdata->gpio, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), GPIO_CFG_ENABLE);

	bd = backlight_device_register("rt9396-bl", &i2c_dev->dev, NULL, &rt9396_ops, NULL);
	if (bd == NULL) {
		eprintk("entering rt9396 probe function error \n");
		kfree(drvdata);
		return -1;
	}
	bd->props.power = FB_BLANK_UNBLANK;
	bd->props.brightness = drvdata->intensity;
	bd->props.max_brightness = drvdata->max_intensity;
	drvdata->bd = bd;

	if (led_classdev_register(&i2c_dev->dev, &rt9396_led_dev) == 0) {
		eprintk("Registering led class dev successfully.\n");
		drvdata->led = &rt9396_led_dev;
		err = device_create_file(drvdata->led->dev, &dev_attr_alc);
		err = device_create_file(drvdata->led->dev, &dev_attr_reg);
		err = device_create_file(drvdata->led->dev, &dev_attr_drvstat);
		err = device_create_file(drvdata->led->dev, &dev_attr_chargerlogo);
	}
// [Caio99BR][[email protected]] Workaround for bug of screen still awake after lock
#ifndef CONFIG_MACH_LGE_2ND_GEN_KK_WORKAROUD
	if (led_classdev_register(&i2c_dev->dev, &rt9396_keyled_dev) == 0) {
		eprintk("Registering led class dev successfully.\n");
		drvdata->led = &rt9396_keyled_dev;
	}
#endif

	i2c_set_clientdata(i2c_dev, drvdata);
	i2c_set_adapdata(i2c_dev->adapter, i2c_dev);

	rt9396_device_init(drvdata);
	rt9396_send_intensity(drvdata, RT9396BL_DEFAULT_BRIGHTNESS);

#ifdef CONFIG_HAS_EARLYSUSPEND
	drvdata->early_suspend.suspend = rt9396_early_suspend;
	drvdata->early_suspend.resume = rt9396_late_resume;
	drvdata->early_suspend.level = EARLY_SUSPEND_LEVEL_BLANK_SCREEN - 40;
	register_early_suspend(&drvdata->early_suspend);
#endif

	rt9396_ref = drvdata;

	eprintk("done\n");
	return 0;
}
Beispiel #14
0
static int cm3217_probe(struct i2c_client *client, const struct i2c_device_id *id)
{
    struct cm3217_data *cm3217;
    struct cm3217_platform_data *pdata = pdata = client->dev.platform_data;
    char com1 = CM3217_COM1_VALUE, com2 = CM3217_COM2_VALUE;
    int err;

    if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C))
    {
        dev_err(&client->dev, "Must have I2C_FUNC_I2C.\n");
        err = -ENODEV;
        goto alloc_memory_fail;
    }

    cm3217 = kmalloc(sizeof(struct cm3217_data), GFP_KERNEL);
    if(!cm3217) {
        printk("cm3217 alloc memory err !!!\n");
        err = -ENOMEM;
        goto alloc_memory_fail;
    }

    if(pdata->init_platform_hw)
        pdata->init_platform_hw();

    cm3217->client = client;
    i2c_set_clientdata(client, cm3217);
    cm3217->power_pin = pdata->power_pin;
    cm3217->irq_pin = pdata->irq_pin;
    cm3217->status = SENSOR_OFF;
    glight = cm3217;

    //init cm3217
    client->addr = CM3217_ADDR_COM1;
    cm3217_command_set(client, &com1, 1);
    client->addr = CM3217_ADDR_COM2;
    cm3217_command_set(client, &com2, 1);

    cm3217->input = input_allocate_device();
    if (!cm3217->input) {
        err = -ENOMEM;
        printk(KERN_ERR"cm3217: Failed to allocate input device\n");
        goto exit_input_allocate_device_failed;
    }
    set_bit(EV_ABS, cm3217->input->evbit);
    /* light sensor data */
    input_set_abs_params(cm3217->input, ABS_MISC, 0, 10, 0, 0);
    cm3217->input->name = "lightsensor-level";

    err = input_register_device(cm3217->input);
    if (err < 0) {
        printk(KERN_ERR"cm3217: Unable to register input device: %s\n",cm3217->input->name);
        goto exit_input_register_device_failed;
    }
    /*
    	if(cm3217->power_pin != INVALID_GPIO)
    	{
    		gpio_request(cm3217->power_pin, "cm3217_power_pin");
    		gpio_pull_updown(cm3217->power_pin,PullDisable);
    	}
    */
    INIT_WORK(&cm3217->timer_work, adc_timer_work);
    setup_timer(&cm3217->timer, adc_timer, (unsigned long)cm3217);
    err = misc_register(&cm3217_device);
    if (err < 0) {
        printk(KERN_ERR"cm3217_probe: lightsensor_device register failed\n");
        goto exit_misc_register_fail;
    }
    printk("lightsensor cm3217 driver created !\n");
    //cm3217_start(cm3217);
#ifdef CONFIG_HAS_EARLYSUSPEND
    cm3217_early_suspend.suspend = cm3217_suspend;
    cm3217_early_suspend.resume = cm3217_resume;
    cm3217_early_suspend.level = 0x2;
    register_early_suspend(&cm3217_early_suspend);
#endif
    return 0;
exit_misc_register_fail:
    //gpio_free(pdata->power_pin);
    input_unregister_device(cm3217->input);
exit_input_register_device_failed:
    input_free_device(cm3217->input);
exit_input_allocate_device_failed:
    kfree(cm3217);
alloc_memory_fail:
    printk("%s error\n",__FUNCTION__);
    return err;
}
static int ssp_probe(struct spi_device *spi)
{
	struct ssp_data *data;
	struct ssp_platform_data *pdata;
	int iRet = 0;

	pr_info("[SSP] %s, is called\n", __func__);

	pdata = spi->dev.platform_data;
	if (pdata == NULL) {
		pr_err("[SSP] %s, platform_data is null\n", __func__);
		iRet = -ENOMEM;
		goto exit;
	}

	data = kzalloc(sizeof(*data), GFP_KERNEL);
	if (data == NULL) {
		pr_err("[SSP] %s, failed to allocate memory for data\n", __func__);
		iRet = -ENOMEM;
		goto exit;
	}

	data->set_mcu_reset = pdata->set_mcu_reset;
	data->ap_int = pdata->ap_int;
	data->mcu_int1 = pdata->mcu_int1;
	data->mcu_int2 = pdata->mcu_int2;

	/* AP system_rev */
	if (pdata->check_ap_rev)
		data->ap_rev = pdata->check_ap_rev();
	else
		data->ap_rev = 0;

	/* Get sensor positions */
	if (pdata->get_positions) {
		pdata->get_positions(&data->accel_position,
			&data->mag_position);
	} else {
		data->accel_position = 0;
		data->mag_position = 0;
	}
	if (pdata->mag_matrix) {
		data->mag_matrix_size = pdata->mag_matrix_size;
		data->mag_matrix = pdata->mag_matrix;
	}

#ifdef CONFIG_SENSORS_SSP_SHTC1
	/* Get pdata for cp thermister */
	if (pdata->cp_thm_adc_table) {
		data->cp_thm_adc_channel = pdata->cp_thm_adc_channel;
		data->cp_thm_adc_arr_size= pdata->cp_thm_adc_arr_size;
		data->cp_thm_adc_table = pdata->cp_thm_adc_table;
	}
	/* Get pdata for batt thermister */
	if (pdata->batt_thm_adc_table) {
		data->batt_thm_adc_arr_size= pdata->batt_thm_adc_arr_size;
		data->batt_thm_adc_table = pdata->batt_thm_adc_table;
	}
	/* Get pdata for chg thermister */
	if (pdata->chg_thm_adc_table) {
		data->chg_thm_adc_arr_size= pdata->chg_thm_adc_arr_size;
		data->chg_thm_adc_table = pdata->chg_thm_adc_table;
	}
#endif

	spi->mode = SPI_MODE_1;
	if (spi_setup(spi)) {
		pr_err("[SSP] %s, failed to setup spi\n", __func__);
		goto err_setup;
	}

	data->bProbeIsDone = false;
	data->fw_dl_state = FW_DL_STATE_NONE;
	data->spi = spi;
	spi_set_drvdata(spi, data);

#ifdef CONFIG_SENSORS_SSP_SHTC1
	mutex_init(&data->cp_temp_adc_lock);
	mutex_init(&data->bulk_temp_read_lock);
#endif
#ifdef CONFIG_SENSORS_SSP_STM
	mutex_init(&data->comm_mutex);
	mutex_init(&data->pending_mutex);
#endif

	if (data->set_mcu_reset == NULL) {
		pr_err("[SSP] %s, function callback is null\n", __func__);
		iRet = -EIO;
		goto err_reset_null;
	}

	pr_info("\n#####################################################\n");

	INIT_DELAYED_WORK(&data->work_firmware, work_function_firmware_update);

	wake_lock_init(&data->ssp_wake_lock,
		WAKE_LOCK_SUSPEND, "ssp_wake_lock");

	iRet = initialize_input_dev(data);
	if (iRet < 0) {
		pr_err("[SSP]: %s - could not create input device\n", __func__);
		goto err_input_register_device;
	}

	iRet = initialize_debug_timer(data);
	if (iRet < 0) {
		pr_err("[SSP]: %s - could not create workqueue\n", __func__);
		goto err_create_workqueue;
	}

	iRet = initialize_irq(data);
	if (iRet < 0) {
		pr_err("[SSP]: %s - could not create irq\n", __func__);
		goto err_setup_irq;
	}

	iRet = initialize_sysfs(data);
	if (iRet < 0) {
		pr_err("[SSP]: %s - could not create sysfs\n", __func__);
		goto err_sysfs_create;
	}

	iRet = initialize_event_symlink(data);
	if (iRet < 0) {
		pr_err("[SSP]: %s - could not create symlink\n", __func__);
		goto err_symlink_create;
	}

	initialize_variable(data);

	ssp_enable(data, true);
	/* check boot loader binary */
	data->fw_dl_state = check_fwbl(data);

	if (data->fw_dl_state == FW_DL_STATE_NONE) {
		iRet = initialize_mcu(data);
		if (iRet == ERROR) {
			data->uResetCnt++;
			toggle_mcu_reset(data);
			msleep(SSP_SW_RESET_TIME);
			initialize_mcu(data);
		} else if (iRet < ERROR) {
			pr_err("[SSP] %s, initialize_mcu failed\n", __func__);
			goto err_read_reg;
		}
	}

#ifdef CONFIG_HAS_EARLYSUSPEND
	data->early_suspend.suspend = ssp_early_suspend;
	data->early_suspend.resume = ssp_late_resume;
	register_early_suspend(&data->early_suspend);
#endif

#ifdef CONFIG_SENSORS_SSP_SENSORHUB
	/* init sensorhub device */
	iRet = ssp_sensorhub_initialize(data);
	if (iRet < 0) {
		pr_err("[SSP] %s, ssp_sensorhub_initialize err(%d)", __func__, iRet);
		ssp_sensorhub_remove(data);
	}
#endif

	data->bMcuDumpMode = ssp_check_sec_dump_mode();
	pr_info("[SSP]: %s - setup debuglevel %d!\n", __func__, data->bMcuDumpMode);

	pr_info("[SSP]: %s - probe success!\n", __func__);

	enable_debug_timer(data);

	if (data->fw_dl_state == FW_DL_STATE_NEED_TO_SCHEDULE) {
		pr_info("[SSP] Firmware update is scheduled\n");
		schedule_delayed_work(&data->work_firmware,
				msecs_to_jiffies(1000));
		data->fw_dl_state = FW_DL_STATE_SCHEDULED;
	} else if (data->fw_dl_state == FW_DL_STATE_FAIL) {
		data->bSspShutdown = true;
	}

	data->bProbeIsDone = true;
	iRet = 0;

	goto exit;

err_read_reg:
err_symlink_create:
	remove_sysfs(data);
err_sysfs_create:
	free_irq(data->iIrq, data);
	gpio_free(data->mcu_int1);
err_setup_irq:
	destroy_workqueue(data->debug_wq);
err_create_workqueue:
	remove_input_dev(data);
err_input_register_device:
	wake_lock_destroy(&data->ssp_wake_lock);
err_reset_null:
#ifdef CONFIG_SENSORS_SSP_STM
	mutex_destroy(&data->comm_mutex);
	mutex_destroy(&data->pending_mutex);
#endif
#ifdef CONFIG_SENSORS_SSP_SHTC1
	mutex_destroy(&data->bulk_temp_read_lock);
	mutex_destroy(&data->cp_temp_adc_lock);
#endif

err_setup:
	kfree(data);
	pr_err("[SSP] %s, probe failed!\n", __func__);
exit:
	pr_info("#####################################################\n\n");
	return iRet;
}
Beispiel #16
0
int hua_ts_device_probe(struct hua_input_device *dev)
{
	int ret;
	struct hua_ts_device *ts = (struct hua_ts_device *) dev;
	struct hua_input_chip *chip = dev->chip;
	struct hua_input_core *core = chip->core;
	struct input_dev *input = dev->input;
	const struct hua_ts_touch_key *key, *key_end;
	const char *name;

	ret = hua_input_add_kobject(&core->prop_kobj, "board_properties");
	if (ret < 0 && ret != -EEXIST)
	{
		pr_red_info("hua_input_add_kobject");
		return ret;
	}

	name = kasprintf(GFP_KERNEL, "virtualkeys.%s", input->name);
	if (name == NULL)
	{
		ret = -ENOMEM;
		pr_red_info("kasprintf");
		goto out_hua_input_remove_kobject;
	}

	hua_ts_board_properties_attr.attr.name = name;

	ret = hua_input_create_sysfs_files(dev, &core->prop_kobj, &hua_ts_board_properties_attr, 1);
	if (ret < 0)
	{
		pr_red_info("hua_input_add_kobject");
		goto out_kfree_name;
	}

	ret = sysfs_create_files(&dev->misc_dev.dev->kobj, hua_ts_device_attributes);
	if (ret < 0)
	{
		pr_red_info("sysfs_create_files");
		goto out_hua_input_remove_sysfs_files;
	}

#ifdef CONFIG_HAS_EARLYSUSPEND
	ts->early_suspend.level = EARLY_SUSPEND_LEVEL_BLANK_SCREEN + 1;
	ts->early_suspend.suspend = hua_ts_suspend;
	ts->early_suspend.resume = hua_ts_resume;
	register_early_suspend(&ts->early_suspend);
#elif defined(CONFIG_FB) && defined(CONFIG_HUAMOBILE_USE_FB_NOTIFILER)
	ts->fb_notifier.notifier_call = hua_ts_fb_notifier_call;
	ret = fb_register_client(&ts->fb_notifier);
	if (ret < 0)
	{
		pr_red_info("fb_register_client");
	}
#else
	ts->pm_notifier.notifier_call = hua_ts_pm_notifier_call;
	ret = register_pm_notifier(&ts->pm_notifier);
	if (ret < 0)
	{
		pr_red_info("register_pm_notifier");
	}
#endif

	set_bit(INPUT_PROP_DIRECT, input->propbit);

	set_bit(EV_KEY, input->evbit);
	set_bit(BTN_TOUCH, input->keybit);

	if (ts->keys && ts->key_count)
	{
		for (key = ts->keys, key_end = key + ts->key_count; key < key_end; key++)
		{
			set_bit(key->code, input->keybit);
		}
	}

	set_bit(EV_ABS, input->evbit);
	input_set_abs_params(input, ABS_MT_POSITION_X, ts->xmin, ts->xmax, dev->fuzz, dev->flat);
	input_set_abs_params(input, ABS_MT_POSITION_Y, ts->ymin, ts->ymax, 0, 0);
	input_set_abs_params(input, ABS_MT_TRACKING_ID, 0, ts->point_count - 1, 0, 0);

	input->open = hua_ts_device_open;
	dev->remove = hua_ts_device_remove;

	ts->touch_count = 0;

	pr_green_info("huamobile touch screen %s probe complete", dev->name);

	return 0;

out_hua_input_remove_sysfs_files:
	hua_input_remove_sysfs_files(&core->prop_kobj, &hua_ts_board_properties_attr, 1);
out_kfree_name:
	kfree(name);
out_hua_input_remove_kobject:
	hua_input_remove_kobject(&core->prop_kobj);
	return ret;
}
static int htc_headset_mgr_probe(struct platform_device *pdev)
{
	int ret;

	struct htc_headset_mgr_platform_data *pdata = pdev->dev.platform_data;

	HS_LOG("++++++++++++++++++++");

	hi = kzalloc(sizeof(struct htc_headset_mgr_info), GFP_KERNEL);
	if (!hi)
		return -ENOMEM;

	hi->pdata.driver_flag = pdata->driver_flag;
	hi->pdata.headset_devices_num = pdata->headset_devices_num;
	hi->pdata.headset_devices = pdata->headset_devices;
	hi->pdata.headset_config_num = pdata->headset_config_num;
	hi->pdata.headset_config = pdata->headset_config;

	hi->pdata.hptv_det_hp_gpio = pdata->hptv_det_hp_gpio;
	hi->pdata.hptv_det_tv_gpio = pdata->hptv_det_tv_gpio;
	hi->pdata.hptv_sel_gpio = pdata->hptv_sel_gpio;

	hi->pdata.headset_init = pdata->headset_init;
	hi->pdata.headset_power = pdata->headset_power;

	if (hi->pdata.headset_init)
		hi->pdata.headset_init();

	hi->driver_init_seq = 0;

	hi->early_suspend.suspend = htc_headset_mgr_early_suspend;
	hi->early_suspend.resume = htc_headset_mgr_late_resume;
	register_early_suspend(&hi->early_suspend);

	wake_lock_init(&hi->hs_wake_lock, WAKE_LOCK_SUSPEND, DRIVER_NAME);

	hi->hpin_jiffies = jiffies;
	hi->usb_headset.type = USB_NO_HEADSET;
	hi->usb_headset.status = STATUS_DISCONNECTED;

	hi->hs_35mm_type = HEADSET_UNPLUG;
	hi->h2w_35mm_type = HEADSET_UNPLUG;
	hi->is_ext_insert = 0;
	hi->mic_bias_state = 0;
	hi->mic_detect_counter = 0;
	hi->key_level_flag = -1;
	hi->quick_boot_status = 0;

	atomic_set(&hi->btn_state, 0);

	hi->tty_enable_flag = 0;
	hi->fm_flag = 0;
	hi->debug_flag = 0;

	mutex_init(&hi->mutex_lock);

	hi->sdev_h2w.name = "h2w";
	hi->sdev_h2w.print_name = h2w_print_name;

	ret = switch_dev_register(&hi->sdev_h2w);
	if (ret < 0)
		goto err_h2w_switch_dev_register;

	hi->sdev_usb_audio.name = "usb_audio";
	hi->sdev_usb_audio.print_name = usb_audio_print_name;

	ret = switch_dev_register(&hi->sdev_usb_audio);
	if (ret < 0)
		goto err_usb_audio_switch_dev_register;

	detect_wq = create_workqueue("detect");
	if (detect_wq == NULL) {
		ret = -ENOMEM;
		HS_ERR("Failed to create detect workqueue");
		goto err_create_detect_work_queue;
	}

	button_wq = create_workqueue("button");
	if (button_wq  == NULL) {
		ret = -ENOMEM;
		HS_ERR("Failed to create button workqueue");
		goto err_create_button_work_queue;
	}

	hi->input = input_allocate_device();
	if (!hi->input) {
		ret = -ENOMEM;
		goto err_request_input_dev;
	}

	hi->input->name = "h2w headset";
	set_bit(EV_SYN, hi->input->evbit);
	set_bit(EV_KEY, hi->input->evbit);
	set_bit(KEY_END, hi->input->keybit);
	set_bit(KEY_MUTE, hi->input->keybit);
	set_bit(KEY_VOLUMEDOWN, hi->input->keybit);
	set_bit(KEY_VOLUMEUP, hi->input->keybit);
	set_bit(KEY_NEXTSONG, hi->input->keybit);
	set_bit(KEY_PLAYPAUSE, hi->input->keybit);
	set_bit(KEY_PREVIOUSSONG, hi->input->keybit);
	set_bit(KEY_MEDIA, hi->input->keybit);
	set_bit(KEY_SEND, hi->input->keybit);

	ret = input_register_device(hi->input);
	if (ret < 0)
	goto err_register_input_dev;

	ret = register_attributes();
	if (ret)
		goto err_register_attributes;

	if (hi->pdata.driver_flag & DRIVER_HS_MGR_RPC_SERVER) {
		/* Create RPC server */
		ret = msm_rpc_create_server(&hs_rpc_server);
		if (ret < 0) {
			HS_ERR("Failed to create RPC server");
			goto err_create_rpc_server;
		}
		HS_LOG("Create RPC server successfully");
	}

	headset_mgr_init();
	hs_notify_driver_ready(DRIVER_NAME);

	HS_LOG("--------------------");

	return 0;

err_create_rpc_server:

err_register_attributes:
	input_unregister_device(hi->input);

err_register_input_dev:
	input_free_device(hi->input);

err_request_input_dev:
	destroy_workqueue(button_wq);

err_create_button_work_queue:
	destroy_workqueue(detect_wq);

err_create_detect_work_queue:
	switch_dev_unregister(&hi->sdev_usb_audio);

err_usb_audio_switch_dev_register:
	switch_dev_unregister(&hi->sdev_h2w);

err_h2w_switch_dev_register:
	mutex_destroy(&hi->mutex_lock);
	wake_lock_destroy(&hi->hs_wake_lock);
	kfree(hi);

	HS_ERR("Failed to register %s driver", DRIVER_NAME);

	return ret;
}
Beispiel #18
0
static int cypress_touchkey_probe(struct i2c_client *client,
		const struct i2c_device_id *id)
{
	struct device *dev = &client->dev;
	struct input_dev *input_dev;
	struct cypress_touchkey_devdata *devdata;
	u8 data[3];
	int err;
	int cnt;
#if defined(TOUCH_UPDATE)
	int ret;
	int retry = 10;
#endif

	if (!dev->platform_data) {
		dev_err(dev, "%s: Platform data is NULL\n", __func__);
		return -EINVAL;
	}

	devdata = kzalloc(sizeof(*devdata), GFP_KERNEL);
	if (devdata == NULL) {
		dev_err(dev, "%s: failed to create our state\n", __func__);
		return -ENODEV;
	}

	devdata->client = client;
	i2c_set_clientdata(client, devdata);

	devdata->pdata = client->dev.platform_data;
#if defined(TOUCH_UPDATE)
	tempdata = devdata;
#endif
	if (!devdata->pdata->keycode) {
		dev_err(dev, "%s: Invalid platform data\n", __func__);
		err = -EINVAL;
		goto err_null_keycodes;
	}

	strlcpy(devdata->client->name, DEVICE_NAME, I2C_NAME_SIZE);

	input_dev = input_allocate_device();
	if (!input_dev) {
		err = -ENOMEM;
		goto err_input_alloc_dev;
	}

	devdata->input_dev = input_dev;
	dev_set_drvdata(&input_dev->dev, devdata);
	input_dev->name = DEVICE_NAME;
	input_dev->id.bustype = BUS_HOST;

	for (cnt = 0; cnt < devdata->pdata->keycode_cnt; cnt++)
		input_set_capability(input_dev, EV_KEY,
					devdata->pdata->keycode[cnt]);

	err = input_register_device(input_dev);
	if (err)
		goto err_input_reg_dev;

	devdata->is_powering_on = true;

	devdata->pdata->touchkey_onoff(TOUCHKEY_ON);

	err = i2c_master_recv(client, data, sizeof(data));
	if (err < sizeof(data)) {
		if (err >= 0)
			err = -EIO;
		dev_err(dev, "%s: error reading hardware version\n", __func__);
		goto err_read;
	}

	dev_info(dev, "%s: hardware rev1 = %#02x, rev2 = %#02x\n", __func__,
				data[1], data[2]);

	devdata->backlight_on = BACKLIGHT_ON;
	devdata->backlight_off = BACKLIGHT_OFF;

	devdata->has_legacy_keycode = 1;

	err = i2c_touchkey_write_byte(devdata, devdata->backlight_on);
	if (err) {
		dev_err(dev, "%s: touch keypad backlight on failed\n",
				__func__);
		goto err_backlight_on;
	}

	if (request_threaded_irq(client->irq, touchkey_interrupt_handler,
				touchkey_interrupt_thread, IRQF_TRIGGER_FALLING,
				DEVICE_NAME, devdata)) {
		dev_err(dev, "%s: Can't allocate irq.\n", __func__);
		goto err_req_irq;
	}

#ifdef CONFIG_HAS_EARLYSUSPEND
	devdata->early_suspend.suspend = cypress_touchkey_early_suspend;
	devdata->early_suspend.resume = cypress_touchkey_early_resume;
#endif
	register_early_suspend(&devdata->early_suspend);

	devdata->is_powering_on = false;
#if defined(TOUCH_UPDATE)
	ret = misc_register(&touchkey_update_device);
	if (ret) {
		printk("%s misc_register fail\n", __FUNCTION__);
	}

	if (device_create_file
	    (touchkey_update_device.this_device, &dev_attr_touch_version) < 0) {
		printk("%s device_create_file fail dev_attr_touch_version\n",
		       __FUNCTION__);
		pr_err("Failed to create device file(%s)!\n",
		       dev_attr_touch_version.attr.name);
	}

	if (device_create_file
	    (touchkey_update_device.this_device, &dev_attr_touch_update) < 0) {
		printk("%s device_create_file fail dev_attr_touch_update\n",
		       __FUNCTION__);
		pr_err("Failed to create device file(%s)!\n",
		       dev_attr_touch_update.attr.name);
	}

	if (device_create_file
	    (touchkey_update_device.this_device, &dev_attr_brightness) < 0) {
		printk("%s device_create_file fail dev_attr_touch_update\n",
		       __FUNCTION__);
		pr_err("Failed to create device file(%s)!\n",
		       dev_attr_brightness.attr.name);
	}

	if (device_create_file
	    (touchkey_update_device.this_device,
	     &dev_attr_enable_disable) < 0) {
		printk("%s device_create_file fail dev_attr_touch_update\n",
		       __FUNCTION__);
		pr_err("Failed to create device file(%s)!\n",
		       dev_attr_enable_disable.attr.name);
	}

	touchkey_wq = create_singlethread_workqueue(DEVICE_NAME);
	if (!touchkey_wq)
		return -ENOMEM;

	while (retry--) {
		if (get_touchkey_firmware(data) == 0)	//melfas need delay for multiple read
			break;
	}
	printk("%s F/W version: 0x%x, Module version:0x%x\n", __FUNCTION__,
	       data[1], data[2]);
#endif

#ifdef CONFIG_GENERIC_BLN
	bln_devdata = devdata;
#endif

	return 0;

err_req_irq:
err_backlight_on:
err_read:
	devdata->pdata->touchkey_onoff(TOUCHKEY_OFF);
	input_unregister_device(input_dev);
	goto err_input_alloc_dev;
err_input_reg_dev:
	input_free_device(input_dev);
err_input_alloc_dev:
err_null_keycodes:
	kfree(devdata);
	return err;
}
int __init grouper_panel_init(void)
{
	int err;
	struct resource __maybe_unused *res;
	struct board_info board_info;

	tegra_get_board_info(&board_info);

#if defined(CONFIG_TEGRA_NVMAP)
	grouper_carveouts[1].base = tegra_carveout_start;
	grouper_carveouts[1].size = tegra_carveout_size;
#endif
/*
	gpio_request(grouper_lvds_avdd_en, "lvds_avdd_en");
	gpio_direction_output(grouper_lvds_avdd_en, 1);
	tegra_gpio_enable(grouper_lvds_avdd_en);

	//gpio_request(grouper_lvds_stdby, "lvds_stdby");
	//gpio_direction_output(grouper_lvds_stdby, 1);
	//tegra_gpio_enable(grouper_lvds_stdby);

	gpio_request(grouper_lvds_rst, "lvds_rst");
	gpio_direction_output(grouper_lvds_rst, 1);
	tegra_gpio_enable(grouper_lvds_rst);

	if (board_info.fab == BOARD_FAB_A00) {
		gpio_request(grouper_lvds_rs_a00, "lvds_rs");
		gpio_direction_output(grouper_lvds_rs_a00, 0);
		tegra_gpio_enable(grouper_lvds_rs_a00);
	} else {
		gpio_request(grouper_lvds_rs, "lvds_rs");
		gpio_direction_output(grouper_lvds_rs, 0);
		tegra_gpio_enable(grouper_lvds_rs);
	}

	gpio_request(grouper_lvds_lr, "lvds_lr");
	gpio_direction_output(grouper_lvds_lr, 1);
	tegra_gpio_enable(grouper_lvds_lr);
*/
/*
	gpio_request(grouper_lvds_shutdown, "lvds_shutdown");
	gpio_direction_output(grouper_lvds_shutdown, 1);
	tegra_gpio_enable(grouper_lvds_shutdown);
*/
	tegra_gpio_enable(grouper_hdmi_hpd);
	gpio_request(grouper_hdmi_hpd, "hdmi_hpd");
	gpio_direction_input(grouper_hdmi_hpd);

#ifdef CONFIG_HAS_EARLYSUSPEND
	grouper_panel_early_suspender.suspend = grouper_panel_early_suspend;
	grouper_panel_early_suspender.resume = grouper_panel_late_resume;
	grouper_panel_early_suspender.level = EARLY_SUSPEND_LEVEL_DISABLE_FB;
	register_early_suspend(&grouper_panel_early_suspender);
#endif

#ifdef CONFIG_TEGRA_GRHOST
	err = nvhost_device_register(&tegra_grhost_device);
	if (err)
		return err;
#endif

	err = platform_add_devices(grouper_gfx_devices,
				ARRAY_SIZE(grouper_gfx_devices));

#if defined(CONFIG_TEGRA_GRHOST) && defined(CONFIG_TEGRA_DC)
	res = nvhost_get_resource_byname(&grouper_disp1_device,
					 IORESOURCE_MEM, "fbmem");
	res->start = tegra_fb_start;
	res->end = tegra_fb_start + tegra_fb_size - 1;
#endif

	/* Copy the bootloader fb to the fb. */
//	tegra_move_framebuffer(tegra_fb_start, tegra_bootloader_fb_start,
//				min(tegra_fb_size, tegra_bootloader_fb_size));

#if defined(CONFIG_TEGRA_GRHOST) && defined(CONFIG_TEGRA_DC)
	if (!err)
		err = nvhost_device_register(&grouper_disp1_device);

	res = nvhost_get_resource_byname(&grouper_disp2_device,
					 IORESOURCE_MEM, "fbmem");
	res->start = tegra_fb2_start;
	res->end = tegra_fb2_start + tegra_fb2_size - 1;
	if (!err)
		err = nvhost_device_register(&grouper_disp2_device);
#endif

#if defined(CONFIG_TEGRA_GRHOST) && defined(CONFIG_TEGRA_NVAVP)
	if (!err)
		err = nvhost_device_register(&nvavp_device);
#endif
	return err;
}
static int s3cfb_probe(struct platform_device *pdev)
{
	struct s3c_platform_fb *pdata = NULL;
	struct resource *res = NULL;
	struct s3cfb_global *fbdev[2];
	int ret = 0;
	int i = 0;
#ifdef CONFIG_FB_S3C_MDNIE
	u32 reg;
#endif

#ifdef CONFIG_S5PV310_DEV_PD
	/* to use the runtime PM helper functions */
	pm_runtime_enable(&pdev->dev);
	/* enable the power domain */
	pm_runtime_get_sync(&pdev->dev);
#endif
	fbfimd = kzalloc(sizeof(struct s3cfb_fimd_desc), GFP_KERNEL);

	if (FIMD_MAX == 2)
		fbfimd->dual = 1;
	else
		fbfimd->dual = 0;

	for (i = 0; i < FIMD_MAX; i++) {
		/* global structure */
		fbfimd->fbdev[i] = kzalloc(sizeof(struct s3cfb_global), GFP_KERNEL);
		fbdev[i] = fbfimd->fbdev[i];
		if (!fbdev[i]) {
			dev_err(fbdev[i]->dev, "failed to allocate for	\
				global fb structure fimd[%d]!\n", i);
			goto err0;
		}

		fbdev[i]->dev = &pdev->dev;

		/* platform_data*/
		pdata = to_fb_plat(&pdev->dev);
		fbdev[i]->lcd = (struct s3cfb_lcd *)pdata->lcd;

		if (pdata->cfg_gpio)
			pdata->cfg_gpio(pdev);

		if (pdata->clk_on)
			pdata->clk_on(pdev, &fbdev[i]->clock);

		/* io memory */
		res = platform_get_resource(pdev, IORESOURCE_MEM, i);
		if (!res) {
			dev_err(fbdev[i]->dev,
				"failed to get io memory region\n");
			ret = -EINVAL;
			goto err1;
		}
		res = request_mem_region(res->start,
					res->end - res->start + 1, pdev->name);
		if (!res) {
			dev_err(fbdev[i]->dev,
				"failed to request io memory region\n");
			ret = -EINVAL;
			goto err1;
		}
		fbdev[i]->regs = ioremap(res->start, res->end - res->start + 1);
		if (!fbdev[i]->regs) {
			dev_err(fbdev[i]->dev, "failed to remap io region\n");
			ret = -EINVAL;
			goto err1;
		}

		fbdev[i]->wq_count = 0;
		init_waitqueue_head(&fbdev[i]->wq);

		/* irq */
		fbdev[i]->irq = platform_get_irq(pdev, 0);
		if (request_irq(fbdev[i]->irq, s3cfb_irq_frame, IRQF_SHARED,
				pdev->name, fbdev[i])) {
			dev_err(fbdev[i]->dev, "request_irq failed\n");
			ret = -EINVAL;
			goto err2;
		}

#ifdef CONFIG_FB_S3C_TRACE_UNDERRUN
		if (request_irq(platform_get_irq(pdev, 1), s3cfb_irq_fifo,
				IRQF_DISABLED, pdev->name, fbdev[i])) {
			dev_err(fbdev[i]->dev, "request_irq failed\n");
			ret = -EINVAL;
			goto err2;
		}

		s3cfb_set_fifo_interrupt(fbdev[i], 1);
		dev_info(fbdev[i]->dev, "fifo underrun trace\n");
#endif
#ifdef CONFIG_FB_S3C_MDNIE
		/* only FIMD0 is supported */
		if (i == 0)
			s3c_mdnie_setup();
#endif
		/* hw setting */
		s3cfb_init_global(fbdev[i]);

		/* alloc fb_info */
		if (s3cfb_alloc_framebuffer(fbdev[i], i)) {
			dev_err(fbdev[i]->dev, "alloc error fimd[%d]\n", i);
			goto err3;
		}

		/* register fb_info */
		if (s3cfb_register_framebuffer(fbdev[i])) {
			dev_err(fbdev[i]->dev, "register error fimd[%d]\n", i);
			goto err3;
		}

		/* enable display */
		s3cfb_set_clock(fbdev[i]);

		/* Set Alpha value width to 8-bit alpha value
		 * 1 : 8bit mode
		 * 2 : 4bit mode
		 */
		s3cfb_set_alpha_value(fbdev[i], 1);

#ifdef CONFIG_FB_S3C_MDNIE
		/* only FIMD0 is supported */
		if (i == 0) {
			reg = readl(S3C_VA_SYS + 0x0210);
			reg &= ~(1<<13);
			reg &= ~(1<<12);
			reg &= ~(3<<10);
			reg |= (1<<0);
			reg &= ~(1<<1);
			writel(reg, S3C_VA_SYS + 0x0210);
			writel(3, fbdev[i]->regs + 0x27c);

			s3c_mdnie_init_global(fbdev[i]);
			s3c_mdnie_start(fbdev[i]);
		}
#endif
		s3cfb_enable_window(fbdev[0], pdata->default_win);
		s3cfb_update_power_state(fbdev[i], pdata->default_win,
					FB_BLANK_UNBLANK);
		s3cfb_display_on(fbdev[i]);

		fbdev[i]->system_state = POWER_ON;
#ifdef CONFIG_HAS_WAKELOCK
#ifdef CONFIG_HAS_EARLYSUSPEND
		fbdev[i]->early_suspend.suspend = s3cfb_early_suspend;
		fbdev[i]->early_suspend.resume = s3cfb_late_resume;
		fbdev[i]->early_suspend.level = EARLY_SUSPEND_LEVEL_DISABLE_FB;
		register_early_suspend(&fbdev[i]->early_suspend);
#endif
#endif
	}
static int sc7798_panel_probe(struct platform_device *pdev)
{
	int ret = 0;

	lcd = kzalloc(sizeof(struct sc7798_dsi_lcd), GFP_KERNEL);
	if (!lcd)
		return -ENOMEM;

	lcd->dev = &pdev->dev;
	lcd->bl = DEFAULT_GAMMA_LEVEL;
	lcd->lcd_id = gPanelID;
	lcd->current_brightness	= 255;
	lcd->panel_awake = true;	

	dev_info(lcd->dev, "%s function entered\n", __func__);			
	
	{
		int n = 0;

		dev_info(lcd->dev, "panelID : [0x%02X], [0x%02X], [0x%02X]\n", gPanelID[0], gPanelID[1], gPanelID[2]);		

	}	
	
	platform_set_drvdata(pdev, lcd);	

	mutex_init(&lcd->lock);

#ifdef CONFIG_LCD_CLASS_DEVICE
	ret = device_create_file(lcd_dev, &dev_attr_lcd_type);
	if (ret < 0)
		printk("Failed to add lcd_type sysfs entries, %d\n",	__LINE__);		
#endif			
	
#ifdef ESD_OPERATION
	lcd->esd_workqueue = create_singlethread_workqueue("esd_workqueue");
	if (!lcd->esd_workqueue) {
		dev_info(lcd->dev, "esd_workqueue create fail\n");
		return 0;
	}
	
	INIT_WORK(&(lcd->esd_work), esd_work_func);
	
	lcd->esd_port = ESD_PORT_NUM;
	
	if (request_threaded_irq(gpio_to_irq(lcd->esd_port), NULL,
			esd_interrupt_handler, IRQF_TRIGGER_RISING, "esd_interrupt", lcd)) {
			dev_info(lcd->dev, "esd irq request fail\n");
			free_irq(gpio_to_irq(lcd->esd_port), NULL);
			lcd->lcd_connected = 0;
	}
	    
#ifdef ESD_TEST
	setup_timer(&lcd->esd_test_timer, esd_test_timer_func, 0);
	mod_timer(&lcd->esd_test_timer,  jiffies + (30*HZ));
#endif

	lcd->esd_processing = false; 
	lcd->lcd_connected = 1;	
	lcd->esd_enable = 1;		
#endif	
	
#ifdef CONFIG_HAS_EARLYSUSPEND
  lcd->earlysuspend.level   = EARLY_SUSPEND_LEVEL_DISABLE_FB - 1;
  lcd->earlysuspend.suspend = sc7798_dsi_early_suspend;
  lcd->earlysuspend.resume  = sc7798_dsi_late_resume;
  register_early_suspend(&lcd->earlysuspend);
#endif	

	return 0;
}
int __init cardhu_panel_init(void)
{
	int err;
	struct resource __maybe_unused *res;

	tegra_get_board_info(&board_info);
	tegra_get_display_board_info(&display_board_info);

#if defined(CONFIG_TEGRA_NVMAP)
	cardhu_carveouts[1].base = tegra_carveout_start;
	cardhu_carveouts[1].size = tegra_carveout_size;
#endif

#if defined(CONFIG_ION_TEGRA)
	tegra_ion_data.heaps[0].base = tegra_carveout_start;
	tegra_ion_data.heaps[0].size = tegra_carveout_size;
#endif

	cardhu_panel_preinit();
	if (is_dsi_panel())
		goto skip_lvds;
#if defined(CONFIG_TEGRA_DC)
	if (WARN_ON(board_info.board_id == BOARD_E1291 &&
		((board_info.sku & SKU_TOUCHSCREEN_MECH_FIX) == 0))) {
		/* use 55Hz panel timings to reduce noise on sensitive touch */
		printk("Using cardhu_panel_modes_55hz\n");
		cardhu_disp1_out.parent_clk = "pll_p";
		cardhu_disp1_out.modes = cardhu_panel_modes_55hz;
		cardhu_disp1_out.n_modes = ARRAY_SIZE(cardhu_panel_modes_55hz);
	}

	if (display_board_info.board_id == BOARD_DISPLAY_PM313) {
		/* initialize the values */
#if defined(PM313_LVDS_PANEL_19X12)
		cardhu_disp1_out.modes = panel_19X12_modes;
		cardhu_disp1_out.n_modes = ARRAY_SIZE(panel_19X12_modes);
		cardhu_disp1_out.parent_clk = "pll_d_out0";
#if (PM313_LVDS_PANEL_BPP == 1)
		cardhu_disp1_out.depth = 18;
#else
		cardhu_disp1_out.depth = 24;
#endif
		cardhu_fb_data.xres = 1920;
		cardhu_fb_data.yres = 1200;

		cardhu_disp2_out.parent_clk = "pll_d2_out0";
		cardhu_hdmi_fb_data.xres = 1920;
		cardhu_hdmi_fb_data.yres = 1200;
#endif

		/* lvds configuration */
		err = gpio_request(pm313_R_FDE, "R_FDE");
		err |= gpio_direction_output(pm313_R_FDE, 1);

		err |= gpio_request(pm313_R_FB, "R_FB");
		err |= gpio_direction_output(pm313_R_FB, 1);

		err |= gpio_request(pm313_MODE0, "MODE0");
		err |= gpio_direction_output(pm313_MODE0, 1);

		err |= gpio_request(pm313_MODE1, "MODE1");
		err |= gpio_direction_output(pm313_MODE1, 0);

		err |= gpio_request(pm313_BPP, "BPP");
		err |= gpio_direction_output(pm313_BPP, PM313_LVDS_PANEL_BPP);

		err = gpio_request(pm313_lvds_shutdown, "lvds_shutdown");
		/* free ride provided by bootloader */
		err |= gpio_direction_output(pm313_lvds_shutdown, 1);

		if (err)
			printk(KERN_ERR "ERROR(s) in LVDS configuration\n");
	}
/*        else if ((display_board_info.board_id == BOARD_DISPLAY_E1247 &&
				board_info.board_id == BOARD_PM269) ||
				(board_info.board_id == BOARD_E1257) ||
				(board_info.board_id == BOARD_PM305) ||
				(board_info.board_id == BOARD_PM311)) {
		gpio_request(e1247_pm269_lvds_shutdown, "lvds_shutdown");
		gpio_direction_output(e1247_pm269_lvds_shutdown, 1);
	} else {
		gpio_request(cardhu_lvds_shutdown, "lvds_shutdown");
		gpio_direction_output(cardhu_lvds_shutdown, 1);
	}
*/
	if ( tegra3_get_project_id() == TEGRA3_PROJECT_P1801 ){
		printk("P1801 display setting, set HDMI as main display\n ");
		cardhu_fb_data.xres = 1920;
		cardhu_fb_data.yres = 1080;

		cardhu_disp1_pdata.default_out = &cardhu_disp1_out_P1801;
		cardhu_disp1_device.resource	= cardhu_disp1_resources_P1801;
		cardhu_disp1_device.num_resources = ARRAY_SIZE(cardhu_disp1_resources_P1801);
	}

	if (tegra3_get_project_id()==0x4 ){
		printk("Check TF700T setting \n ");
		cardhu_disp1_out.modes = panel_19X12_modes;
		cardhu_disp1_out.n_modes = ARRAY_SIZE(panel_19X12_modes);
		cardhu_disp1_out.parent_clk = "pll_d_out0";
		cardhu_disp1_out.depth = 24;

		cardhu_fb_data.xres = 1920;
		cardhu_fb_data.yres = 1200;

		cardhu_disp2_out.parent_clk = "pll_d2_out0";
		cardhu_hdmi_fb_data.xres = 1920;
		cardhu_hdmi_fb_data.yres = 1200;

		gpio_request(TEGRA_GPIO_PU5, "LDO_EN");
		gpio_request(TEGRA_GPIO_PBB3, "TF700T_1.2V");
		gpio_request(TEGRA_GPIO_PC6, "TF700T_1.8V");
		gpio_request(TEGRA_GPIO_PX0, "TF700T_I2C_Switch");
		gpio_request(TEGRA_GPIO_PD2, "TF700T_OSC");
	}

#endif
	if (tegra3_get_project_id()==0x4 ){
		tegra_gpio_enable(cardhu_hdmi_enb);
		gpio_request(cardhu_hdmi_enb, "hdmi_5v_en");
		gpio_direction_output(cardhu_hdmi_enb, 0);
	} else {
		tegra_gpio_enable(cardhu_hdmi_enb);
		gpio_request(cardhu_hdmi_enb, "hdmi_5v_en");
		gpio_direction_output(cardhu_hdmi_enb, 1);
	}

skip_lvds:
	gpio_request(cardhu_hdmi_hpd, "hdmi_hpd");
	gpio_direction_input(cardhu_hdmi_hpd);

#if !(DC_CTRL_MODE & TEGRA_DC_OUT_ONE_SHOT_MODE)
	tegra_gpio_enable(e1506_lcd_te);
	gpio_request(e1506_lcd_te, "lcd_te");
	gpio_direction_input(e1506_lcd_te);
#endif

#ifdef CONFIG_HAS_EARLYSUSPEND
	cardhu_panel_early_suspender.suspend = cardhu_panel_early_suspend;
	cardhu_panel_early_suspender.resume = cardhu_panel_late_resume;
	cardhu_panel_early_suspender.level = EARLY_SUSPEND_LEVEL_DISABLE_FB;
	register_early_suspend(&cardhu_panel_early_suspender);
#endif

#ifdef CONFIG_TEGRA_GRHOST
	err = tegra3_register_host1x_devices();
	if (err)
		return err;
#endif

	err = platform_add_devices(cardhu_gfx_devices,
				ARRAY_SIZE(cardhu_gfx_devices));

#if defined(CONFIG_TEGRA_GRHOST) && defined(CONFIG_TEGRA_DC)
	res = nvhost_get_resource_byname(&cardhu_disp1_device,
					 IORESOURCE_MEM, "fbmem");
	res->start = tegra_fb_start;
	res->end = tegra_fb_start + tegra_fb_size - 1;
#endif

	/* Copy the bootloader fb to the fb. */
	tegra_move_framebuffer(tegra_fb_start, tegra_bootloader_fb_start,
				min(tegra_fb_size, tegra_bootloader_fb_size));

#if defined(CONFIG_TEGRA_GRHOST) && defined(CONFIG_TEGRA_DC)
	if (!err)
		err = nvhost_device_register(&cardhu_disp1_device);

	if ( tegra3_get_project_id() != TEGRA3_PROJECT_P1801 ){

		res = nvhost_get_resource_byname(&cardhu_disp2_device,
						 IORESOURCE_MEM, "fbmem");
		res->start = tegra_fb2_start;
		res->end = tegra_fb2_start + tegra_fb2_size - 1;

		/* Copy the bootloader fb to the fb2. */
		tegra_move_framebuffer(tegra_fb2_start, tegra_bootloader_fb_start,
					min(tegra_fb2_size, tegra_bootloader_fb_size));

		if (!err)
			err = nvhost_device_register(&cardhu_disp2_device);
	}

#endif

#if defined(CONFIG_TEGRA_GRHOST) && defined(CONFIG_TEGRA_NVAVP)
	if (!err)
		err = nvhost_device_register(&nvavp_device);
#endif
	return err;
}
Beispiel #23
0
static int __init rmnet_late_init(void)
{
	register_early_suspend(&rmnet_power_suspend);
	return 0;
}
Beispiel #24
0
static int __init aat28xx_probe(struct i2c_client *i2c_dev, const struct i2c_device_id *i2c_dev_id)
{
	struct aat28xx_platform_data *pdata;
	struct aat28xx_driver_data *drvdata;
	struct backlight_device *bd;
	int err;

	dprintk("start, client addr=0x%x\n", i2c_dev->addr);

	pdata = i2c_dev->dev.platform_data;
	if(!pdata)
		return -EINVAL;
		
	drvdata = kzalloc(sizeof(struct aat28xx_driver_data), GFP_KERNEL);
	if (!drvdata) {
		dev_err(&i2c_dev->dev, "failed to allocate memory\n");
		return -ENOMEM;
	}

	if (pdata && pdata->platform_init)
		pdata->platform_init();

	drvdata->client = i2c_dev;
	drvdata->gpio = pdata->gpio;
	drvdata->max_intensity = LCD_LED_MAX;
	if (pdata->max_current > 0)
		drvdata->max_intensity = pdata->max_current;
	drvdata->intensity = LCD_LED_MIN;
	drvdata->mode = NORMAL_MODE;
	drvdata->state = UNINIT_STATE;
	drvdata->version = pdata->version;

	if(aat28xx_setup_version(drvdata) != 0) {
		eprintk("Error while requesting gpio %d\n", drvdata->gpio);
		kfree(drvdata);
		return -ENODEV;
	}		
	if (drvdata->gpio && gpio_request(drvdata->gpio, "aat28xx_en") != 0) {
		eprintk("Error while requesting gpio %d\n", drvdata->gpio);
		kfree(drvdata);
		return -ENODEV;
	}

	bd = backlight_device_register("aat28xx-bl", &i2c_dev->dev, NULL, &aat28xx_ops);
	if (bd == NULL) {
		eprintk("entering aat28xx probe function error \n");
		if (gpio_is_valid(drvdata->gpio))
			gpio_free(drvdata->gpio);
		kfree(drvdata);
		return -1;
	}
	bd->props.power = FB_BLANK_UNBLANK;
	bd->props.brightness = drvdata->intensity;
	bd->props.max_brightness = drvdata->max_intensity;
	drvdata->bd = bd;

#ifdef CONFIG_BACKLIGHT_LEDS_CLASS
	if (led_classdev_register(&i2c_dev->dev, &aat28xx_led_dev) == 0) {
		eprintk("Registering led class dev successfully.\n");
		drvdata->led = &aat28xx_led_dev;
		err = device_create_file(drvdata->led->dev, &dev_attr_alc);
		err = device_create_file(drvdata->led->dev, &dev_attr_reg);
		err = device_create_file(drvdata->led->dev, &dev_attr_drvstat);
	}
#endif

	i2c_set_clientdata(i2c_dev, drvdata);
	i2c_set_adapdata(i2c_dev->adapter, i2c_dev);

	aat28xx_device_init(drvdata);
	aat28xx_send_intensity(drvdata, DEFAULT_BRIGHTNESS);

#ifdef CONFIG_HAS_EARLYSUSPEND
	drvdata->early_suspend.suspend = aat28xx_early_suspend;
	drvdata->early_suspend.resume = aat28xx_late_resume;
	drvdata->early_suspend.level = EARLY_SUSPEND_LEVEL_BLANK_SCREEN - 40;
	register_early_suspend(&drvdata->early_suspend);
#endif

	eprintk("done\n");
	return 0;
}
static int mmc328x_init_probe(struct platform_device *pdev)
{
	unsigned char data[16] = {0};
	int res = 0;
	int ret33 = 0;

	if (get_hw_revision() == 0x09) {
		printk("[SENSOR] hw_revision : 0x09\n ");
		vreg_sensor = regulator_get(NULL, "vmmc2");
		ret33 = regulator_enable(vreg_sensor);

		if (ret33) {
			printk("[SENSOR] Error, %s: vreg enable failed (%d)\n", __func__, ret33);
		}

	}

	pr_info("mmc328x driver: probe\n");
	g_client = omap_gpio_i2c_init(OMAP_GPIO_FM_SDA	, OMAP_GPIO_FM_SCL, MMC328X_I2C_ADDR, 200);

	res = misc_register(&mmc328x_device);
	if (res) {
		pr_err("%s: mmc328x_device register failed\n", __FUNCTION__);
		goto out;
	}

	res = device_create_file(mmc328x_device.this_device, &dev_attr_mmc328x);
	if (res) {
		pr_err("%s: device_create_file failed\n", __FUNCTION__);
		goto out_deregister;
	}

	res = sysfs_create_group(&mmc328x_device.this_device->kobj,&mmc328x_group);
	if (res < 0){
		pr_info("failed to create sysfs files\n");
		goto out_sysinfo;
	}

	/* send SET/RESET cmd to mag sensor first of all */
#ifdef CONFIG_SENSORS_MMC328X 
	data[0] = MMC328X_REG_CTRL;
	data[1] = MMC328X_CTRL_RRM;
	if (mmc328x_i2c_tx_data(data, 2) < 0) {
	}
	msleep(MMC328X_DELAY_RRM);
	data[0] = MMC328X_REG_CTRL;
	data[1] = MMC328X_CTRL_TM;
	if (mmc328x_i2c_tx_data(data, 2) < 0) {
	}
	msleep(5*MMC328X_DELAY_TM);
#endif

	data[0] = MMC328X_REG_CTRL;
	data[1] = MMC328X_CTRL_RM;
	if (mmc328x_i2c_tx_data(data, 2) < 0) {
		/* assume RM always success */
	}
#ifndef CONFIG_SENSORS_MMC328X 
	/* wait external capacitor charging done for next RM */
	msleep(MMC328X_DELAY_RM);
#else
	msleep(10*MMC328X_DELAY_RM);
	data[0] = MMC328X_REG_CTRL;
	data[1] = MMC328X_CTRL_TM;
	if (mmc328x_i2c_tx_data(data, 2) < 0) {
	}
#endif

#if defined(CONFIG_HAS_EARLYSUSPEND)
	early_suspend.level = EARLY_SUSPEND_LEVEL_BLANK_SCREEN + 1;
	early_suspend.suspend = (void *)mmc328x_magnetic_suspend;
	early_suspend.resume  = (void *)mmc328x_magnetic_resume;
	register_early_suspend(&early_suspend);
#endif

	return 0;
out_sysinfo:
	sysfs_remove_group(&mmc328x_device.this_device->kobj,&mmc328x_group);
out_deregister:
	misc_deregister(&mmc328x_device);
out:
	return res;
}
Beispiel #26
0
static int wacom_i2c_probe(struct i2c_client *client,
                           const struct i2c_device_id *id)
{
    struct wacom_g5_platform_data *pdata = client->dev.platform_data;
    struct wacom_i2c *wac_i2c;
    struct input_dev *input;
    int ret = 0;
#if defined(CONFIG_MACH_T0)
    int digitizer_type = 0;
#endif

    firmware_updating_state = false;

    if (pdata == NULL) {
        printk(KERN_ERR "%s: no pdata\n", __func__);
        ret = -ENODEV;
        goto err_i2c_fail;
    }

    /*Check I2C functionality */
    if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) {
        printk(KERN_ERR "[E-PEN] No I2C functionality found\n");
        ret = -ENODEV;
        goto err_i2c_fail;
    }

    /*Obtain kernel memory space for wacom i2c */
    wac_i2c = kzalloc(sizeof(struct wacom_i2c), GFP_KERNEL);
    if (NULL == wac_i2c) {
        printk(KERN_ERR "[E-PEN] failed to allocate wac_i2c.\n");
        ret = -ENOMEM;
        goto err_freemem;
    }

    wac_i2c->client_boot = i2c_new_dummy(client->adapter,
                                         WACOM_I2C_BOOT);
    if (!wac_i2c->client_boot) {
        dev_err(&client->dev, "Fail to register sub client[0x%x]\n",
                WACOM_I2C_BOOT);
    }

    input = input_allocate_device();
    if (NULL == input) {
        printk(KERN_ERR "[E-PEN] failed to allocate input device.\n");
        ret = -ENOMEM;
        goto err_input_allocate_device;
    } else
        wacom_i2c_set_input_values(client, wac_i2c, input);

    wac_i2c->wac_feature = &wacom_feature_EMR;
    wac_i2c->wac_pdata = pdata;
    wac_i2c->input_dev = input;
    wac_i2c->client = client;
    wac_i2c->irq = client->irq;
#ifdef WACOM_PDCT_WORK_AROUND
    wac_i2c->irq_pdct = gpio_to_irq(pdata->gpio_pendct);
#endif

#ifdef WACOM_PEN_DETECT
    wac_i2c->gpio_pen_insert = pdata->gpio_pen_insert;
#endif

#ifdef WACOM_HAVE_FWE_PIN
    wac_i2c->have_fwe_pin = true;
#ifdef CONFIG_MACH_T0
    if (system_rev < WACOM_FWE1_HWID)
        wac_i2c->have_fwe_pin = false;
#endif
#endif

    /*Change below if irq is needed */
    wac_i2c->irq_flag = 1;

    /*Register callbacks */
    wac_i2c->callbacks.check_prox = wacom_check_emr_prox;
    if (wac_i2c->wac_pdata->register_cb)
        wac_i2c->wac_pdata->register_cb(&wac_i2c->callbacks);

    /* Firmware Feature */
    wacom_i2c_init_firm_data();
#ifdef WACOM_IMPORT_FW_ALGO
    wac_i2c->use_offset_table = true;
    wac_i2c->use_aveTransition = false;
#endif

#if defined(CONFIG_MACH_Q1_BD)
    /* Change Origin offset by rev */
    if (system_rev < 6) {
        origin_offset[0] = origin_offset_48[0];
        origin_offset[1] = origin_offset_48[1];
    }
    /* Reset IC */
    wacom_i2c_reset_hw(wac_i2c->wac_pdata);
#elif defined(CONFIG_MACH_T0)
    wac_i2c->wac_pdata->late_resume_platform_hw();
    msleep(200);

    /*Set data by digitizer type*/
    digitizer_type = wacom_i2c_get_digitizer_type();

    if (digitizer_type == EPEN_DTYPE_B746) {
        printk(KERN_DEBUG"[E-PEN] Use Box filter\n");
        wac_i2c->use_aveTransition = true;
    } else if (digitizer_type == EPEN_DTYPE_B713) {
        printk(KERN_DEBUG"[E-PEN] Reset tilt for B713\n");

        /*Change tuning version for B713*/
        tuning_version = tuning_version_B713;

        memcpy(tilt_offsetX, tilt_offsetX_B713, sizeof(tilt_offsetX));
        memcpy(tilt_offsetY, tilt_offsetY_B713, sizeof(tilt_offsetY));
    } else if (digitizer_type == EPEN_DTYPE_B660) {
        printk(KERN_DEBUG"[E-PEN] Reset tilt and origin for B660\n");

        origin_offset[0] = EPEN_B660_ORG_X;
        origin_offset[1] = EPEN_B660_ORG_Y;
        memset(tilt_offsetX, 0, sizeof(tilt_offsetX));
        memset(tilt_offsetY, 0, sizeof(tilt_offsetY));
        wac_i2c->use_offset_table = false;
    }

    /*Set switch type*/
    wac_i2c->invert_pen_insert = wacom_i2c_invert_by_switch_type();
#elif defined(CONFIG_MACH_KONA)
    wac_i2c->wac_pdata->late_resume_platform_hw();
    msleep(200);
#endif
#ifdef WACOM_PDCT_WORK_AROUND
    wac_i2c->pen_pdct = PDCT_NOSIGNAL;
#endif

#if defined(CONFIG_MACH_P4NOTE)
    wac_i2c->wac_pdata->resume_platform_hw();
    msleep(200);
#endif
    wac_i2c->power_enable = true;

    ret = wacom_i2c_query(wac_i2c);

    if (ret < 0)
        epen_reset_result = false;
    else
        epen_reset_result = true;

#if defined(CONFIG_MACH_P4NOTE)
    input_set_abs_params(input, ABS_X, WACOM_POSX_OFFSET,
                         wac_i2c->wac_feature->x_max, 4, 0);
    input_set_abs_params(input, ABS_Y, WACOM_POSY_OFFSET,
                         wac_i2c->wac_feature->y_max, 4, 0);
    input_set_abs_params(input, ABS_PRESSURE, 0,
                         WACOM_MAX_PRESSURE, 0, 0);
#else
    input_set_abs_params(wac_i2c->input_dev, ABS_X, pdata->min_x,
                         pdata->max_x, 4, 0);
    input_set_abs_params(wac_i2c->input_dev, ABS_Y, pdata->min_y,
                         pdata->max_y, 4, 0);
#ifdef CONFIG_MACH_T0
    input_set_abs_params(wac_i2c->input_dev, ABS_PRESSURE,
                         0, wac_i2c->wac_feature->pressure_max, 0, 0);
#else
    input_set_abs_params(wac_i2c->input_dev, ABS_PRESSURE,
                         pdata->min_pressure, pdata->max_pressure, 0, 0);
#endif
#endif
    input_set_drvdata(input, wac_i2c);

    /*Before registering input device, data in each input_dev must be set */
    ret = input_register_device(input);
    if (ret) {
        pr_err("[E-PEN] failed to register input device.\n");
        goto err_register_device;
    }

    /*Change below if irq is needed */
    wac_i2c->irq_flag = 1;

    /*Set client data */
    i2c_set_clientdata(client, wac_i2c);
    i2c_set_clientdata(wac_i2c->client_boot, wac_i2c);

    /*Initializing for semaphor */
    mutex_init(&wac_i2c->lock);
    wake_lock_init(&wac_i2c->wakelock, WAKE_LOCK_SUSPEND, "wacom");
    INIT_DELAYED_WORK(&wac_i2c->resume_work, wacom_i2c_resume_work);
#if defined(WACOM_IRQ_WORK_AROUND)
    INIT_DELAYED_WORK(&wac_i2c->pendct_dwork, wacom_i2c_pendct_work);
#endif
#ifdef WACOM_STATE_CHECK
    INIT_DELAYED_WORK(&wac_i2c->wac_statecheck_work, wac_statecheck_work);
#endif


#ifdef CONFIG_HAS_EARLYSUSPEND
    wac_i2c->early_suspend.level = EARLY_SUSPEND_LEVEL_BLANK_SCREEN + 1;
    wac_i2c->early_suspend.suspend = wacom_i2c_early_suspend;
    wac_i2c->early_suspend.resume = wacom_i2c_late_resume;
    register_early_suspend(&wac_i2c->early_suspend);
#endif

    wac_i2c->dev = device_create(sec_class, NULL, 0, NULL, "sec_epen");
    if (IS_ERR(wac_i2c->dev)) {
        printk(KERN_ERR "Failed to create device(wac_i2c->dev)!\n");
        goto err_sysfs_create_group;
    } else {
        dev_set_drvdata(wac_i2c->dev, wac_i2c);
        ret = sysfs_create_group(&wac_i2c->dev->kobj, &epen_attr_group);
        if (ret) {
            printk(KERN_ERR
                   "[E-PEN]: failed to create sysfs group\n");
            goto err_sysfs_create_group;
        }
    }

    /* firmware info */
    printk(KERN_NOTICE "[E-PEN] wacom fw ver : 0x%x, new fw ver : 0x%x\n",
           wac_i2c->wac_feature->fw_version, Firmware_version_of_file);

#ifdef CONFIG_SEC_TOUCHSCREEN_DVFS_LOCK
    INIT_DELAYED_WORK(&wac_i2c->dvfs_work, free_dvfs_lock);
    if (exynos_cpufreq_get_level(WACOM_DVFS_LOCK_FREQ,
                                 &wac_i2c->cpufreq_level))
        printk(KERN_ERR "[E-PEN] exynos_cpufreq_get_level Error\n");
#ifdef SEC_BUS_LOCK
    wac_i2c->dvfs_lock_status = false;
#if defined(CONFIG_MACH_P4NOTE)
    wac_i2c->bus_dev = dev_get("exynos-busfreq");
#endif	/* CONFIG_MACH_P4NOTE */
#endif	/* SEC_BUS_LOCK */
#endif	/* CONFIG_SEC_TOUCHSCREEN_DVFS_LOCK */

    /*Request IRQ */
    if (wac_i2c->irq_flag) {
        ret =
            request_threaded_irq(wac_i2c->irq, NULL, wacom_interrupt,
                                 IRQF_DISABLED | IRQF_TRIGGER_RISING |
                                 IRQF_ONESHOT, wac_i2c->name, wac_i2c);
        if (ret < 0) {
            printk(KERN_ERR
                   "[E-PEN] failed to request irq(%d) - %d\n",
                   wac_i2c->irq, ret);
            goto err_request_irq;
        }

#if defined(WACOM_PDCT_WORK_AROUND)
        ret =
            request_threaded_irq(wac_i2c->irq_pdct, NULL,
                                 wacom_interrupt_pdct,
                                 IRQF_DISABLED | IRQF_TRIGGER_RISING |
                                 IRQF_TRIGGER_FALLING | IRQF_ONESHOT,
                                 wac_i2c->name, wac_i2c);
        if (ret < 0) {
            printk(KERN_ERR
                   "[E-PEN] failed to request irq(%d) - %d\n",
                   wac_i2c->irq_pdct, ret);
            goto err_request_irq;
        }
#endif
    }

#ifdef WACOM_DEBOUNCEINT_BY_ESD
    /*Invert gpio value for  first irq.
        schedule_delayed_work in wacom_i2c_input_open*/
    pen_insert_state = gpio_get_value(wac_i2c->gpio_pen_insert);
    wac_i2c->pen_insert = pen_insert_state;
#if defined(CONFIG_MACH_T0)
    if (wac_i2c->invert_pen_insert) {
        wac_i2c->pen_insert = !wac_i2c->pen_insert;
        pen_insert_state = wac_i2c->pen_insert;
    }
#endif
#endif

    return 0;

err_request_irq:
err_sysfs_create_group:
err_register_device:
    input_unregister_device(input);
err_input_allocate_device:
    input_free_device(input);
err_freemem:
    kfree(wac_i2c);
err_i2c_fail:
    return ret;
}
Beispiel #27
0
/*
 *  sensor probe
 *
 */
static int
sensor_probe(struct platform_device *pdev)
{
	int input_registered = 0;
	int sysfs_created = 0;
	int rt;

	LIGHT_DBG("\n[LIGHT] in PROBE called  [%s] start, line [%d]===\n",
													 __FUNCTION__,__LINE__);

	// device memory allocate
	data = kzalloc(sizeof(struct sensor_data), GFP_KERNEL);
	if (!data) {
		rt = -ENOMEM;
		goto err;
	}
	
	// device memory initialize
	data->enabled = 1;
	data->delay = SENSOR_DEFAULT_DELAY;

	// ligth device alloate
	input_data = input_allocate_device();
	if (!input_data) {
		rt = -ENOMEM;
		printk(KERN_ERR
			   "[LIGHT] sensor_probe: Failed to allocate input_data device\n");
		goto err;
	}
	data->input_device = input_data;

	// data store device member
	input_set_drvdata(input_data,data);

	// HAL interface event bit setting
	set_bit(EV_ABS, input_data->evbit);
	set_bit(ABS_X,     input_data->absbit);
/* FUJITSU:2012-03-06 ACE add start */
	input_set_capability(input_data, EV_ABS, ABS_WAKE);
	input_set_capability(input_data, EV_ABS, ABS_CONTROL_REPORT);
/* FUJITSU:2012-03-06 ACE add end */
	input_set_abs_params(input_data, ABS_X, -1872, 1872, 0, 0);

	input_data->name = SENSOR_NAME;
	input_data->open = input_open;
	input_data->close = input_close;

	// device register
	rt = input_register_device(input_data);
	if (rt) {
		printk(KERN_ERR
			   "[LIGHT] sensor_probe: Unable to register input_data device: %s\n",
			   input_data->name);
		goto err;
	}
	input_registered = 1;

	// sysfs device setting
	rt = sysfs_create_group(&input_data->dev.kobj,
			&sensor_attribute_group);
	if (rt) {
		printk(KERN_ERR
			   "[LIGHT] sensor_probe: sysfs_create_group failed[%s]\n",
			   input_data->name);
		goto err;
	}
	sysfs_created = 1;

	mutex_init(&data->mutex);
	this_data = input_data;

	//initialize work queue(timer functions)
	INIT_WORK(&g_proxi_work_data, light_work_bh);
	setup_timer(&tmdrv_timer, light_timer_func, 0);
	g_ls_probe_init = 1;

/* FUJITSU:2011-11-07 EARLYSUSPEND start */
#ifdef CONFIG_HAS_EARLYSUSPEND
	e_sus_fcn.suspend = light_early_suspend;
	e_sus_fcn.resume = light_late_resume;
	e_sus_fcn.level = EARLY_SUSPEND_LEVEL_BLANK_SCREEN;
	register_early_suspend(&e_sus_fcn);
#endif
/* FUJITSU:2011-11-07 EARLYSUSPEND end */

	return 0;

	err:
	if (data != NULL) {
		printk(KERN_CRIT "[LIGHT] sensor_probe: failed to initilie the light driver\n");
		if (input_data != NULL) {

			if (sysfs_created) {
				sysfs_remove_group(&input_data->dev.kobj,
						&sensor_attribute_group);
			}

			if (input_registered) {
				input_unregister_device(input_data);
			}
			else {
				input_free_device(input_data);
			}
			input_data = NULL;
		}
		kfree(data);
	}

	return rt;
}
static int __devinit ist30xx_probe(struct i2c_client *		client,
				   const struct i2c_device_id * id)
{
	int ret;
	struct ist30xx_data *data;
	struct input_dev *input_dev;

#if 0
	/* [email protected] */
	struct touch_platform_data *ts_pdata;
//	struct ist30xx_ts_device *dev;

	ts_pdata = client->dev.platform_data;
//	dev = &ist30xx_ts_dev;
	/* [email protected] */
#endif

	tsp_info("\n%s(), the i2c addr=0x%x \n", __func__, client->addr);

/*	dev->power = ts_pdata->power;
	dev->num_irq = ts_pdata->irq;
	dev->sda_gpio = ts_pdata->sda;
	dev->scl_gpio  = ts_pdata->scl;*/

	if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) {
		tsp_debug("failed to i2c functionality check");
		ret = -ENODEV;
		goto err_check_functionality_failed;
	}
	
	data = kzalloc(sizeof(*data), GFP_KERNEL);
	if (!data)
		return -ENOMEM;

	data->client = client;

	if(client->dev.of_node) {
		data->pdata = devm_kzalloc(&client->dev, sizeof(struct ist30xx_tsi_platform_data), GFP_KERNEL);
		if(!data->pdata) {
			tsp_debug("failed to allocate platform_data");
			return -ENOMEM;
		}

		ret = ist30xx_parse_dt(&client->dev, data->pdata);
		if(ret) {
			tsp_debug("device tree parsing failed");
			return ret;
		}
	} else {
		data->pdata = client->dev.platform_data;
	}

	ret = ist30xx_regulator_configure(data, true);
	if (ret < 0) {
			tsp_debug("Failed to configure regulators");
	}

	ret = ist30xx_ldo_power_on(data, true);
	if (ret < 0) {
			tsp_debug("Failed to power on");
	}

	input_dev = input_allocate_device();
	if (!input_dev) {
		ret = -ENOMEM;
		tsp_err("%s(), input_allocate_device failed (%d)\n", __func__, ret);
		goto err_alloc_dev;
	}

#if 0
	DMSG("[ TSP ] irq : %d, scl : %d, sda : %d\n", client->irq, ts_pdata->scl, ts_pdata->sda);
#endif
	data->num_fingers = IST30XX_MAX_MT_FINGERS;
	data->num_keys = IST30XX_MAX_MT_FINGERS;
	data->irq_enabled = 1;
	data->client = client;
	data->input_dev = input_dev;
#if 0
	/* [email protected] */
	data->power = ts_pdata->power;
	/* [email protected] */
#endif
	i2c_set_clientdata(client, data);

#if (LINUX_VERSION_CODE > KERNEL_VERSION(3, 0, 0))
	input_mt_init_slots(input_dev, IST30XX_MAX_MT_FINGERS);
#endif

	input_dev->name = "ist30xx_ts_input";
	input_dev->id.bustype = BUS_I2C;
	input_dev->dev.parent = &client->dev;

	set_bit(EV_ABS, input_dev->evbit);
#if (LINUX_VERSION_CODE > KERNEL_VERSION(3, 0, 0))
	set_bit(INPUT_PROP_DIRECT, input_dev->propbit);
#endif

	input_set_abs_params(input_dev, ABS_MT_POSITION_X, 0, IST30XX_MAX_X, 0, 0);
	input_set_abs_params(input_dev, ABS_MT_POSITION_Y, 0, IST30XX_MAX_Y, 0, 0);
#if (LINUX_VERSION_CODE > KERNEL_VERSION(3, 0, 0))
	input_set_abs_params(input_dev, ABS_MT_TOUCH_MAJOR, 0, IST30XX_MAX_W, 0, 0);
#else
	input_set_abs_params(input_dev, ABS_MT_TOUCH_MAJOR, 0, IST30XX_MAX_Z, 0, 0);
	input_set_abs_params(input_dev, ABS_MT_WIDTH_MAJOR, 0, IST30XX_MAX_W, 0, 0);
#endif

#if IST30XX_USE_KEY
	{
		int i;
		set_bit(EV_KEY, input_dev->evbit);
		set_bit(EV_SYN, input_dev->evbit);
		for (i = 1; i < ARRAY_SIZE(ist30xx_key_code); i++)
			set_bit(ist30xx_key_code[i], input_dev->keybit);
	}
#endif

	input_set_drvdata(input_dev, data);
	ret = input_register_device(input_dev);
	if (ret) {
		input_free_device(input_dev);
		goto err_reg_dev;
	}

#if defined(CONFIG_FB)
	data->fb_notif.notifier_call = fb_notifier_callback;
	ret = fb_register_client(&data->fb_notif);
	if(ret)
		tsp_debug("Unable to register fb_notifier \n");
	else
		tsp_debug("Register fb_notifier \n");
#elif defined(CONFIG_HAS_EARLYSUSPEND)
	data->early_suspend.level = EARLY_SUSPEND_LEVEL_BLANK_SCREEN + 1;
	data->early_suspend.suspend = ist30xx_early_suspend;
	data->early_suspend.resume = ist30xx_late_resume;
	register_early_suspend(&data->early_suspend);
#endif

	ts_data = data;

	ret = ist30xx_init_system();
	if (ret) {
		dev_err(&client->dev, "chip initialization failed\n");
		goto err_init_drv;
	}

	ret = ist30xx_init_update_sysfs();
	if (ret)
		goto err_init_drv;

#if IST30XX_DEBUG
	ret = ist30xx_init_misc_sysfs();
	if (ret)
		goto err_init_drv;
#endif

# if IST30XX_FACTORY_TEST
	ret = ist30xx_init_factory_sysfs();
	if (ret)
		goto err_init_drv;
#endif

#if IST30XX_TRACKING_MODE
	ret = ist30xx_init_tracking_sysfs();
	if (ret)
		goto err_init_drv;
#endif

	ret = request_threaded_irq(client->irq, NULL, ist30xx_irq_thread,
				   IRQF_TRIGGER_FALLING | IRQF_ONESHOT, "ist30xx_ts", data);
	if (ret)
		goto err_irq;

	ist30xx_disable_irq(data);

#if IST30XX_INTERNAL_BIN
# if IST30XX_UPDATE_BY_WORKQUEUE
	INIT_DELAYED_WORK(&work_fw_update, fw_update_func);
	schedule_delayed_work(&work_fw_update, IST30XX_UPDATE_DELAY);
# else
	ret = ist30xx_auto_bin_update(data);
	if (ret < 0)
		goto err_irq;
# endif
#endif  // IST30XX_INTERNAL_BIN

	ret = ist30xx_get_info(data);
	tsp_info("Get info: %s\n", (ret == 0 ? "success" : "fail"));

	INIT_DELAYED_WORK(&work_reset_check, reset_work_func);

#if IRQ_THREAD_WORK_QUEUE
	INIT_WORK(&work_irq_thread, irq_thread_func);
#endif

#if IST30XX_DETECT_TA
	ist30xx_ta_status = 0;
#endif

#if IST30XX_EVENT_MODE
	init_timer(&idle_timer);
	idle_timer.function = timer_handler;
	idle_timer.expires = jiffies_64 + (EVENT_TIMER_INTERVAL);

	mod_timer(&idle_timer, get_jiffies_64() + EVENT_TIMER_INTERVAL);

	ktime_get_ts(&t_event);
#endif

	ist30xx_initialized = 1;

	return 0;

err_irq:
	ist30xx_disable_irq(data);
	free_irq(client->irq, data);
err_init_drv:
#if IST30XX_EVENT_MODE
	get_event_mode = false;
#endif
	tsp_err("Error, ist30xx init driver\n");
//	ist30xx_power_off();
	ist30xx_ts_off();
	input_unregister_device(input_dev);
	return 0;

err_reg_dev:
err_alloc_dev:
	tsp_err("Error, ist30xx mem free\n");
	kfree(data);
err_check_functionality_failed:
	return 0;
}
Beispiel #29
0
static int mddi_ext_probe(struct platform_device *pdev)
{
	struct msm_fb_data_type *mfd;
	struct platform_device *mdp_dev = NULL;
	struct msm_fb_panel_data *pdata = NULL;
	int rc;
	resource_size_t size ;
	u32 clk_rate;

	if ((pdev->id == 0) && (pdev->num_resources >= 0)) {
		mddi_ext_pdata = pdev->dev.platform_data;

		size =  resource_size(&pdev->resource[0]);
		msm_emdh_base = ioremap(pdev->resource[0].start, size);

		MSM_FB_INFO("external mddi base address = 0x%x\n",
				pdev->resource[0].start);

		if (unlikely(!msm_emdh_base))
			return -ENOMEM;

		mddi_ext_resource_initialized = 1;
		return 0;
	}

	if (!mddi_ext_resource_initialized)
		return -EPERM;

	mfd = platform_get_drvdata(pdev);

	if (!mfd)
		return -ENODEV;

	if (mfd->key != MFD_KEY)
		return -EINVAL;

	if (pdev_list_cnt >= MSM_FB_MAX_DEV_LIST)
		return -ENOMEM;

	mdp_dev = platform_device_alloc("mdp", pdev->id);
	if (!mdp_dev)
		return -ENOMEM;

	/////////////////////////////////////////
	// link to the latest pdev
	/////////////////////////////////////////
	mfd->pdev = mdp_dev;
	mfd->dest = DISPLAY_EXT_MDDI;

	/////////////////////////////////////////
	// alloc panel device data
	/////////////////////////////////////////
	if (platform_device_add_data
	    (mdp_dev, pdev->dev.platform_data,
	     sizeof(struct msm_fb_panel_data))) {
		printk(KERN_ERR "mddi_ext_probe: platform_device_add_data failed!\n");
		platform_device_put(mdp_dev);
		return -ENOMEM;
	}
	/////////////////////////////////////////
	// data chain
	/////////////////////////////////////////
	pdata = mdp_dev->dev.platform_data;
	pdata->on = mddi_ext_on;
	pdata->off = mddi_ext_off;
	pdata->next = pdev;

	/////////////////////////////////////////
	// get/set panel specific fb info
	/////////////////////////////////////////
	mfd->panel_info = pdata->panel_info;
	mfd->fb_imgType = MDP_RGB_565;

	clk_rate = mfd->panel_info.clk_max;
	if (mddi_ext_pdata &&
	    mddi_ext_pdata->mddi_sel_clk &&
	    mddi_ext_pdata->mddi_sel_clk(&clk_rate))
			printk(KERN_ERR
			  "%s: can't select mddi io clk targate rate = %d\n",
			  __func__, clk_rate);

	if (clk_set_max_rate(mddi_ext_clk, clk_rate) < 0)
		printk(KERN_ERR "%s: clk_set_max_rate failed\n", __func__);
	mfd->panel_info.clk_rate = mfd->panel_info.clk_min;

	/////////////////////////////////////////
	// set driver data
	/////////////////////////////////////////
	platform_set_drvdata(mdp_dev, mfd);

	/////////////////////////////////////////
	// register in mdp driver
	/////////////////////////////////////////
	rc = platform_device_add(mdp_dev);
	if (rc) {
		goto mddi_ext_probe_err;
	}

	pdev_list[pdev_list_cnt++] = pdev;

#ifdef CONFIG_HAS_EARLYSUSPEND
	mfd->mddi_ext_early_suspend.level = EARLY_SUSPEND_LEVEL_DISABLE_FB;
	mfd->mddi_ext_early_suspend.suspend = mddi_ext_early_suspend;
	mfd->mddi_ext_early_suspend.resume = mddi_ext_early_resume;
	register_early_suspend(&mfd->mddi_ext_early_suspend);
#endif

	return 0;

      mddi_ext_probe_err:
	platform_device_put(mdp_dev);
	return rc;
}
Beispiel #30
0
static int __devinit nastech_ts_probe(struct i2c_client *client,
				      const struct i2c_device_id *id)
{
	struct nas_ts_priv *ts;
	struct input_dev *input_dev;
	int ret = 0;
	unsigned char datareg[2];
#ifdef  SHOW_VERSION
	unsigned char version[10];
#endif

	struct touch_platform_data *pdata = pdata = client->dev.platform_data;

	printk("nastech_ts_probe\r\n");

	if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) {
		printk(KERN_ERR "%s: need I2C_FUNC_I2C\n", __func__);
		ret = -ENODEV;
		goto err_check_functionality_failed;
	}
	ts = kzalloc(sizeof(struct nas_ts_priv), GFP_KERNEL);
	input_dev = input_allocate_device();

	if (!ts || !input_dev) {
		ret = -ENOMEM;
		goto alloc_fail;
	}
	i2c_set_clientdata(client, ts);

	ts->dev = input_dev;

	input_dev->name = "nastech-ts";

	input_dev->dev.parent = &client->dev;

	__set_bit(EV_SYN, input_dev->evbit);
	__set_bit(EV_KEY, input_dev->evbit);
	__set_bit(BTN_TOUCH, input_dev->keybit);
	__set_bit(EV_ABS, input_dev->evbit);

	input_set_abs_params(input_dev, ABS_X, x_min, x_max, 0, 0);
	input_set_abs_params(input_dev, ABS_Y, y_min, y_max, 0, 0);
	input_set_abs_params(input_dev, ABS_HAT0X, x_min, x_max, 0, 0);
	input_set_abs_params(input_dev, ABS_HAT0Y, y_min, y_max, 0, 0);
	/*Android MT */
	input_set_abs_params(input_dev, ABS_MT_POSITION_X, x_min, x_max, 0, 0);
	input_set_abs_params(input_dev, ABS_MT_POSITION_Y, y_min, y_max, 0, 0);
	input_set_abs_params(input_dev, ABS_MT_TOUCH_MAJOR, 0, 255, 0, 0);
	input_set_abs_params(input_dev, ABS_MT_WIDTH_MAJOR, 0, 15, 0, 0);
	ret = input_register_device(ts->dev);
	if (ret) {
		printk(KERN_ERR "%s: Failed to allocate input device\n",
		       __func__);
		goto input_dev_fail;
	}

	if (pdata->init_irq)		
		pdata->init_irq();

	if (pdata->enable)		
		pdata->enable(1);
	ts->client = client;
	ts->pdata = pdata;
	INIT_WORK(&ts->work, nastech_ts_work);

	ret = request_irq(client->irq, nastech_ts_isr,
			  IRQF_DISABLED | IRQF_TRIGGER_RISING,
			  "nastech-ts irq", ts);
	if (ret) {
		printk(KERN_ERR "%s: request irq failed\n", __func__);
		goto irq_fail;
	}
#ifdef CONFIG_HAS_EARLYSUSPEND
	ts->early_suspend.level = EARLY_SUSPEND_LEVEL_STOP_DRAWING;
	ts->early_suspend.suspend = nastech_ts_early_suspend;
	ts->early_suspend.resume = nastech_ts_late_resume;
	register_early_suspend(&ts->early_suspend);
#endif
	dev_set_drvdata(&input_dev->dev, ts);
	atomic_set(&nastech_status, 1);	/* on */
	ret = i2c_smbus_read_i2c_block_data(client, NAS_SPECOP, 1, &datareg[0]);
	atomic_set(&nastech_calibration, 0);
	nastech_create_proc_file(ts);
	nastech_set_power_mode(ts->client, 1);
	nastech_set_int_mode(ts->client, INT_MODE_FMOV);
#ifdef SHOW_VERSION
	ret = i2c_smbus_read_i2c_block_data(client, NAS_VERSION_START,
					  NAS_VERSION_END - NAS_VERSION_START +
					  1, version);
	if (ret < 0)
		printk(KERN_ERR "touch read version: error = 0x%x\n", ret);
	else
		printk(KERN_ERR
		       "touch read verion OK and 0x30=0x%x 0x31=0x%x 0x32=0x%x 0x33=0x%x 0x33=0x%x\n",
		       version[0], version[1], version[2], version[3],
		       version[4]);
#endif
	return 0;

irq_fail:
	free_irq(client->irq, client);

input_dev_fail:
	i2c_set_clientdata(client, NULL);
	input_free_device(input_dev);

alloc_fail:
	kfree(ts);
err_check_functionality_failed:
	return ret;
}