static int __init msm_serial_probe(struct platform_device *pdev)
{
	struct msm_port *msm_port;
	struct resource *resource;
	struct uart_port *port;
	int irq;
#ifdef CONFIG_SERIAL_MSM_RX_WAKEUP
	struct msm_serial_platform_data *pdata = pdev->dev.platform_data;
#endif

	if (unlikely(pdev->id < 0 || pdev->id >= UART_NR))
		return -ENXIO;

	printk(KERN_INFO "msm_serial: detected port #%d\n", pdev->id);

	port = get_port_from_line(pdev->id);
	port->dev = &pdev->dev;
	msm_port = UART_TO_MSM(port);

	msm_port->clk = clk_get(&pdev->dev, "uart_clk");
	if (unlikely(IS_ERR(msm_port->clk)))
		return PTR_ERR(msm_port->clk);
	port->uartclk = clk_get_rate(msm_port->clk);

// BEGIN 0010274: [email protected] 2010-10-27
// Fixed a problem that system don't go to sleep mode.
#if defined(CONFIG_MACH_LGE_BRYCE)
	if(uart_det_flag){
		clk_enable(msm_port->clk);
		msm_uart_driver.cons = NULL;
	}
#endif	
// END 0010274: [email protected] 2010-10-27

	resource = platform_get_resource(pdev, IORESOURCE_MEM, 0);
	if (unlikely(!resource))
		return -ENXIO;
	port->mapbase = resource->start;

	irq = platform_get_irq(pdev, 0);
	if (unlikely(irq < 0))
		return -ENXIO;
	port->irq = irq;

	platform_set_drvdata(pdev, port);

	if (unlikely(set_irq_wake(port->irq, 1)))
		return -ENXIO;

#ifdef CONFIG_SERIAL_MSM_RX_WAKEUP
	if (pdata == NULL)
		msm_port->wakeup.irq = -1;
	else {
		msm_port->wakeup.irq = pdata->wakeup_irq;
		msm_port->wakeup.ignore = 1;
		msm_port->wakeup.inject_rx = pdata->inject_rx_on_wakeup;
		msm_port->wakeup.rx_to_inject = pdata->rx_to_inject;

		if (unlikely(msm_port->wakeup.irq <= 0))
			return -EINVAL;
	}
#endif

#ifdef CONFIG_SERIAL_MSM_CLOCK_CONTROL
	msm_port->clk_state = MSM_CLK_PORT_OFF;
	hrtimer_init(&msm_port->clk_off_timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
	msm_port->clk_off_timer.function = msm_serial_clock_off;
	msm_port->clk_off_delay = ktime_set(0, 1000000);  /* 1 ms */
#endif

	pm_runtime_enable(port->dev);
	return uart_add_one_port(&msm_uart_driver, port);
}
示例#2
0
static int __init null_init(void)
{
	unsigned int i;

	if (bs > PAGE_SIZE) {
		pr_warn("null_blk: invalid block size\n");
		pr_warn("null_blk: defaults block size to %lu\n", PAGE_SIZE);
		bs = PAGE_SIZE;
	}

	if (use_lightnvm && bs != 4096) {
		pr_warn("null_blk: LightNVM only supports 4k block size\n");
		pr_warn("null_blk: defaults block size to 4k\n");
		bs = 4096;
	}

	if (use_lightnvm && queue_mode != NULL_Q_MQ) {
		pr_warn("null_blk: LightNVM only supported for blk-mq\n");
		pr_warn("null_blk: defaults queue mode to blk-mq\n");
		queue_mode = NULL_Q_MQ;
	}

	if (queue_mode == NULL_Q_MQ && use_per_node_hctx) {
		if (submit_queues < nr_online_nodes) {
			pr_warn("null_blk: submit_queues param is set to %u.",
							nr_online_nodes);
			submit_queues = nr_online_nodes;
		}
	} else if (submit_queues > nr_cpu_ids)
		submit_queues = nr_cpu_ids;
	else if (!submit_queues)
		submit_queues = 1;

	mutex_init(&lock);

	/* Initialize a separate list for each CPU for issuing softirqs */
	for_each_possible_cpu(i) {
		struct completion_queue *cq = &per_cpu(completion_queues, i);

		init_llist_head(&cq->list);

		if (irqmode != NULL_IRQ_TIMER)
			continue;

		hrtimer_init(&cq->timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
		cq->timer.function = null_cmd_timer_expired;
	}

	null_major = register_blkdev(0, "nullb");
	if (null_major < 0)
		return null_major;

	if (use_lightnvm) {
		ppa_cache = kmem_cache_create("ppa_cache", 64 * sizeof(u64),
								0, 0, NULL);
		if (!ppa_cache) {
			pr_err("null_blk: unable to create ppa cache\n");
			return -ENOMEM;
		}
	}

	for (i = 0; i < nr_devices; i++) {
		if (null_add_dev()) {
			unregister_blkdev(null_major, "nullb");
			goto err_ppa;
		}
	}

	pr_info("null: module loaded\n");
	return 0;
err_ppa:
	kmem_cache_destroy(ppa_cache);
	return -EINVAL;
}
示例#3
0
static int gs_probe(
	struct i2c_client *client, const struct i2c_device_id *id)
{	
      int ret;
      struct gs_data *gs;
    
	if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) {
		printk(KERN_ERR "gs_probe: need I2C_FUNC_I2C\n");
		ret = -ENODEV;
		goto err_check_functionality_failed;
	}
#ifndef   GS_POLLING 	
	ret = gs_config_int_pin();
	if(ret <0)
	{
		goto err_check_functionality_failed;
	}
#endif

	gs = kzalloc(sizeof(*gs), GFP_KERNEL);
	if (gs == NULL) {
		ret = -ENOMEM;
		goto err_alloc_data_failed;
	}
	mutex_init(&gs->mlock);

	INIT_WORK(&gs->work, gs_work_func);
	gs->client = client;
	i2c_set_clientdata(client, gs);

#if 0
	
    ret = i2c_smbus_write_byte_data(gs->client, 0x20, 0x47); /* device command = ctrl_reg1 */
	if (ret < 0) {
		printk(KERN_ERR "i2c_smbus_write_byte_data failed\n");
		/* fail? */
		goto err_detect_failed;
	}
#endif	


	ret = reg_write(gs, GS_ST_REG_CTRL2, 0x00); /* device command = ctrl_reg2 */
	if (ret < 0) {
		printk(KERN_ERR "i2c_smbus_write_byte_data failed\n");
		/* fail? */
		goto err_detect_failed;
	}

#if 0

	ret = i2c_smbus_write_byte_data(gs->client, 0x22, 0x04); /* device command = ctrl_reg3 */
	if (ret < 0) {
		printk(KERN_ERR "i2c_smbus_write_byte_data failed\n");
		/* fail? */
		goto err_detect_failed;
	}
#endif

	if (sensor_dev == NULL)
	{
		gs->input_dev = input_allocate_device();
		if (gs->input_dev == NULL) {
			ret = -ENOMEM;
			printk(KERN_ERR "gs_probe: Failed to allocate input device\n");
			goto err_input_dev_alloc_failed;
		}
		
		gs->input_dev->name = "sensors";
		sensor_dev = gs->input_dev;
		
	}else{

		gs->input_dev = sensor_dev;
	}
	
	gs->input_dev->id.vendor = GS_ST35DE;//for  akm8973 compass detect.

	set_bit(EV_ABS,gs->input_dev->evbit);
	
	set_bit(ABS_X, gs->input_dev->absbit);
	set_bit(ABS_Y, gs->input_dev->absbit);
	set_bit(ABS_Z, gs->input_dev->absbit);
	
	set_bit(EV_SYN,gs->input_dev->evbit);


	gs->input_dev->id.bustype = BUS_I2C;
	//gs->input_dev->open = gs_st_input_open;
	//gs->input_dev->close = gs_st_input_close;
	
	input_set_drvdata(gs->input_dev, gs);
	
	
	ret = input_register_device(gs->input_dev);
	if (ret) {
		printk(KERN_ERR "gs_probe: Unable to register %s input device\n", gs->input_dev->name);
		goto err_input_register_device_failed;
	}
	
	ret = misc_register(&gsensor_device);
	if (ret) {
		printk(KERN_ERR "gs_probe: gsensor_device register failed\n");

		goto err_misc_device_register_failed;
	}

#ifndef   GS_POLLING 
	if (client->irq) {
		ret = request_irq(client->irq, gs_irq_handler, 0, client->name, gs);
		
		if (ret == 0)
			gs->use_irq = 1;
		else
			dev_err(&client->dev, "request_irq failed\n");
	}
#endif 


	if (!gs->use_irq) {
		hrtimer_init(&gs->timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
		gs->timer.function = gs_timer_func;
		
	}
	
#ifdef CONFIG_HAS_EARLYSUSPEND
	gs->early_suspend.level = EARLY_SUSPEND_LEVEL_BLANK_SCREEN + 1;
	gs->early_suspend.suspend = gs_early_suspend;
	gs->early_suspend.resume = gs_late_resume;
	register_early_suspend(&gs->early_suspend);
#endif

      gs_wq = create_singlethread_workqueue("gs_wq");
	if (!gs_wq)
		return -ENOMEM;
	
	  this_gs_data =gs;


	printk(KERN_INFO "gs_probe: Start LIS35DE  in %s mode\n", gs->use_irq ? "interrupt" : "polling");

	return 0;
	
err_misc_device_register_failed:
		misc_deregister(&gsensor_device);
		

err_input_register_device_failed:
	input_free_device(gs->input_dev);

err_input_dev_alloc_failed:
err_detect_failed:
	kfree(gs);


err_alloc_data_failed:
#ifndef   GS_POLLING 
	gs_free_int();
#endif
err_check_functionality_failed:
	return ret;
}
示例#4
0
static int __devinit bh1721fvc_probe(struct i2c_client *client,
				    const struct i2c_device_id *id)
{
	int err = 0;
	struct bh1721fvc_data *bh1721fvc;
	struct input_dev *input_dev;
	struct bh1721fvc_platform_data *pdata = client->dev.platform_data;
	struct i2c_adapter *adapter = to_i2c_adapter(client->dev.parent);

	if (!i2c_check_functionality(adapter, I2C_FUNC_I2C))
		return -EIO;

	bh1721fvc = kzalloc(sizeof(*bh1721fvc), GFP_KERNEL);
	if (!bh1721fvc) {
		pr_err("%s, failed to alloc memory for module data\n",
			__func__);
		return -ENOMEM;
	}

#if defined(CONFIG_MACH_SAMSUNG_P5)
	bh1721fvc->output = pdata->output;
#endif

	bh1721fvc->reset = pdata->reset;
	if (!bh1721fvc->reset) {
		pr_err("%s: reset callback is null\n", __func__);
		err = -EIO;
		goto err_reset_null;
	}

	err = bh1721fvc->reset();
	if (err) {
		pr_err("%s: Failed to reset\n", __func__);
		goto err_reset_failed;
	}

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

	mutex_init(&bh1721fvc->lock);
	hrtimer_init(&bh1721fvc->timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);

	bh1721fvc->light_poll_delay = ns_to_ktime(200 * NSEC_PER_MSEC);
	bh1721fvc->state = POWER_DOWN;
	bh1721fvc->measure_mode = AUTO_MEASURE;
	bh1721fvc->timer.function = bh1721fvc_timer_func;

	err = bh1721fvc_test_luxvalue(bh1721fvc);
	if (err < 0) {
		printk("data read fail : %d!!\n", err);
		goto err_create_workqueue;
	}
	else
		printk("Lux : %d\n", err);

	bh1721fvc->wq = alloc_workqueue("bh1721fvc_wq",
		WQ_UNBOUND | WQ_RESCUER, 1);
	if (!bh1721fvc->wq) {
		err = -ENOMEM;
		pr_err("%s: could not create workqueue\n", __func__);
		goto err_create_workqueue;
	}

	INIT_WORK(&bh1721fvc->work_light, bh1721fvc_work_func_light);

	input_dev = input_allocate_device();
	if (!input_dev) {
		pr_err("%s: could not allocate input device\n", __func__);
		err = -ENOMEM;
		goto err_input_allocate_device_light;
	}
	input_set_drvdata(input_dev, bh1721fvc);
	input_dev->name = "light_sensor";
	input_set_capability(input_dev, EV_ABS, ABS_MISC);
	input_set_abs_params(input_dev, ABS_MISC,
		LUX_MIN_VALUE, LUX_MAX_VALUE, 0, 0);
	bh1721fvc_dbmsg("registering lightsensor-level input device\n");
	err = input_register_device(input_dev);
	if (err < 0) {
		pr_err("%s: could not register input device\n", __func__);
		input_free_device(input_dev);
		goto err_input_register_device_light;
	}
	bh1721fvc->input_dev = input_dev;
	err = sysfs_create_group(&input_dev->dev.kobj,
		&bh1721fvc_attribute_group);
	if (err) {
		pr_err("%s: could not create sysfs group\n", __func__);
		goto err_sysfs_create_group_light;
	}

#ifdef FACTORY_TEST
	bh1721fvc->factory_class = class_create(THIS_MODULE, "lightsensor");

	if (IS_ERR(bh1721fvc->factory_class)) {
		pr_err("Failed to create class(lightsensor)!\n");
		err = PTR_ERR(bh1721fvc->factory_class);
		goto err_factory_sysfs_create;
	}

	bh1721fvc->factory_dev = device_create(bh1721fvc->factory_class, NULL,
			0, bh1721fvc, "switch_cmd");

	if (IS_ERR(bh1721fvc->factory_dev)) {
		pr_err("Failed to create device(switch_cmd_dev)!\n");
		err = PTR_ERR(bh1721fvc->factory_dev);
		goto err_factory_device_create;
	}

	err = device_create_file(bh1721fvc->factory_dev,
			&dev_attr_lightsensor_file_cmd);

	if (err < 0) {
		pr_err("Failed to create device file(%s)!\n",
				dev_attr_lightsensor_file_cmd.attr.name);
		goto err_file_cmd_attr_create;
	}

	err = device_create_file(bh1721fvc->factory_dev,
			&dev_attr_lightsensor_file_illuminance);

	if (err < 0) {
		pr_err("Failed to create device file(%s)!\n",
			dev_attr_lightsensor_file_illuminance.attr.name);
		goto err_illuminance_attr_create;
	}
#endif

	goto done;

#ifdef FACTORY_TEST
err_illuminance_attr_create:
	device_remove_file(bh1721fvc->factory_dev,
			&dev_attr_lightsensor_file_cmd);
err_file_cmd_attr_create:
	device_destroy(bh1721fvc->factory_class, 0);
err_factory_device_create:
	class_destroy(bh1721fvc->factory_class);
err_factory_sysfs_create:
	sysfs_remove_group(&bh1721fvc->input_dev->dev.kobj,
				&bh1721fvc_attribute_group);
#endif
err_sysfs_create_group_light:
	input_unregister_device(bh1721fvc->input_dev);
err_input_register_device_light:
err_input_allocate_device_light:
	destroy_workqueue(bh1721fvc->wq);
err_create_workqueue:
	mutex_destroy(&bh1721fvc->lock);
err_reset_failed:
err_reset_null:
	kfree(bh1721fvc);
done:
	return err;
}
static int msm_afe_open(struct snd_pcm_substream *substream)
{
	struct snd_pcm_runtime *runtime = substream->runtime;
	struct pcm_afe_info *prtd = NULL;
	int ret = 0;

	prtd = kzalloc(sizeof(struct pcm_afe_info), GFP_KERNEL);
	if (prtd == NULL) {
		pr_err("Failed to allocate memory for msm_audio\n");
		return -ENOMEM;
	} else
		pr_debug("prtd %x\n", (unsigned int)prtd);

	mutex_init(&prtd->lock);
	spin_lock_init(&prtd->dsp_lock);
	prtd->dsp_cnt = 0;

	mutex_lock(&prtd->lock);

	if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
		runtime->hw = msm_afe_hardware_playback;
	else
		runtime->hw = msm_afe_hardware_capture;

	prtd->substream = substream;
	runtime->private_data = prtd;
	prtd->audio_client = q6afe_audio_client_alloc(prtd);
	if (!prtd->audio_client) {
		pr_debug("%s: Could not allocate memory\n", __func__);
		mutex_unlock(&prtd->lock);
		kfree(prtd);
		return -ENOMEM;
	}

	hrtimer_init(&prtd->hrt, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
	if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
		prtd->hrt.function = afe_hrtimer_callback;
	else if (substream->stream == SNDRV_PCM_STREAM_CAPTURE)
		prtd->hrt.function = afe_hrtimer_rec_callback;

	mutex_unlock(&prtd->lock);
	ret = snd_pcm_hw_constraint_list(runtime, 0,
				SNDRV_PCM_HW_PARAM_RATE,
				&constraints_sample_rates);
	if (ret < 0)
		pr_err("snd_pcm_hw_constraint_list failed\n");
	/* Ensure that buffer size is a multiple of period size */
	ret = snd_pcm_hw_constraint_integer(runtime,
					    SNDRV_PCM_HW_PARAM_PERIODS);
	if (ret < 0)
		pr_err("snd_pcm_hw_constraint_integer failed\n");

	if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) {
		ret = snd_pcm_hw_constraint_minmax(runtime,
			SNDRV_PCM_HW_PARAM_BUFFER_BYTES,
			MIN_CAPTURE_NUM_PERIODS * MIN_CAPTURE_PERIOD_SIZE,
			MAX_CAPTURE_NUM_PERIODS * MAX_CAPTURE_PERIOD_SIZE);

		if (ret < 0) {
			pr_err("constraint for buffer bytes min max ret = %d\n",
			      ret);
		}
	}

	return 0;
}
示例#6
0
static int vibrator_probe(struct platform_device *pdev)
{
	int nRet, i;   /* initialized below */

	struct pwm_vibrator_platform_data *pdata = pdev->dev.platform_data;
	struct pwm_vib_data *data;

	DbgOut((KERN_DEBUG "tspdrv: %s\n", __func__));
	data = kzalloc(sizeof(struct pwm_vib_data), GFP_KERNEL);
	if (!data) {
		dev_err(&pdev->dev, "tspdrv: %s: no memory\n", __func__);
		return -ENOMEM;
	}
	/*                                        
                                             
  */
	pwm_priv = data;

	if (pdata) {
		data->power = pdata->power;
		data->gpio_enable = pdata->gpio_enable;
		data->pwm_port = pdata->port;
		data->pwm_freq = pdata->freq;
		data->pwm_duty = pdata->duty;
	}
	if(data->power)
		data->power(1);
	
	/* /register a miscellaneous device */
	nRet = misc_register(&miscdev);
	if (nRet) {
		dev_err(&pdev->dev, "tspdrv: %s: misc_register failed\n",
				__func__);
		goto err_misc_register;
	}

	DbgRecorderInit(());
	/* to set PWM freq, disable amp, etc...*/
	ImmVibeSPI_ForceOut_Initialize();//Currently, Timer stats is disabled. 
	/* 5milliseconds's timer setting!!*/
	VibeOSKernelLinuxInitTimer();

	/* Get and concatenate device name and initialize data buffer */
	g_cchDeviceName = 0;
	for (i=0; i<NUM_ACTUATORS; i++) {
		char *szName = g_szDeviceName + g_cchDeviceName;
		ImmVibeSPI_Device_GetName(i, szName, VIBE_MAX_DEVICE_NAME_LENGTH);

		/* Append version information and get buffer length */
		strcat(szName, VERSION_STR);
		g_cchDeviceName += strlen(szName);

		g_SamplesBuffer[i].nIndexPlayingBuffer = -1; /* Not playing */
		g_SamplesBuffer[i].actuatorSamples[0].nBufferSize = 0;
		g_SamplesBuffer[i].actuatorSamples[1].nBufferSize = 0;
	}

	/*                                                                        */
#if defined(CONFIG_TSPDRV_TIMED_OUTPUT)
	spin_lock_init(&vibe_lock);

	hrtimer_init(&vibe_timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
	vibe_timer.function = vibrator_timer_func;

	timed_dev.name     = "vibrator";
	timed_dev.get_time = vibrator_get_time;
	timed_dev.enable   = vibrator_enable;
	nRet = timed_output_dev_register(&timed_dev);
	if (nRet < 0) {
		dev_err(&pdev->dev, "tspdrv: %s: timed_output_dev_register failed\n", __func__);
		goto err_timed_output_dev_register;
	}
#endif

	platform_set_drvdata(pdev, data);

	dev_info(&pdev->dev, "tspdrv: probed\n");
	return 0;

/*                                                                        */
#if defined(CONFIG_TSPDRV_TIMED_OUTPUT)
	timed_output_dev_unregister(&timed_dev);
err_timed_output_dev_register:
	hrtimer_cancel(&vibe_timer);
#endif
	DbgRecorderTerminate(());
	VibeOSKernelLinuxTerminateTimer();
	ImmVibeSPI_ForceOut_Terminate();
	misc_deregister(&miscdev);
err_misc_register:
	kfree(data);
	return nRet;
}
static int
othc_configure_hsed(struct pm8058_othc *dd, struct platform_device *pd)
{
	int rc;
	struct input_dev *ipd;
	struct pmic8058_othc_config_pdata *pdata = pd->dev.platform_data;
	struct othc_hsed_config *hsed_config = pdata->hsed_config;

	dd->othc_sdev.name = "pm8058-h2w";
	dd->othc_sdev.print_name = othc_headset_print_name;

	rc = switch_dev_register(&dd->othc_sdev);
	if (rc) {
		pr_err("Unable to register switch device\n");
		return rc;
	}

	ipd = input_allocate_device();
	if (ipd == NULL) {
		pr_err("Unable to allocate memory\n");
		rc = -ENOMEM;
		goto fail_input_alloc;
	}

	/* Get the IRQ for Headset Insert-remove and Switch-press */
	dd->othc_irq_sw = platform_get_irq(pd, 0);
	dd->othc_irq_ir = platform_get_irq(pd, 1);
	if (dd->othc_irq_ir < 0 || dd->othc_irq_sw < 0) {
		pr_err("othc resource:IRQs absent\n");
		rc = -ENXIO;
		goto fail_micbias_config;
	}

	if (pdata->hsed_name != NULL)
		ipd->name = pdata->hsed_name;
	else
		ipd->name = "pmic8058_othc";

	ipd->phys = "pmic8058_othc/input0";
	ipd->dev.parent = &pd->dev;

	dd->othc_ipd = ipd;
	dd->othc_sw_state = false;
	dd->switch_debounce_ms = hsed_config->switch_debounce_ms;
	dd->othc_support_n_switch = hsed_config->othc_support_n_switch;
	dd->accessory_support = pdata->hsed_config->accessories_support;
	dd->detection_delay_ms = pdata->hsed_config->detection_delay_ms;

	if (dd->othc_support_n_switch == true)
		dd->switch_config = hsed_config->switch_config;

	if (dd->accessory_support == true) {
		dd->accessory_info = pdata->hsed_config->accessories;
		dd->num_accessories = pdata->hsed_config->othc_num_accessories;
		dd->accessories_adc_support =
				pdata->hsed_config->accessories_adc_support;
		dd->accessories_adc_channel =
				pdata->hsed_config->accessories_adc_channel;
		dd->video_out_gpio = pdata->hsed_config->video_out_gpio;
	}

	/* Configure the MIC_BIAS line for headset detection */
	rc = pm8058_configure_micbias(dd);
	if (rc < 0)
		goto fail_micbias_config;

	/* Configure for the switch events */
	rc = pm8058_configure_switch(dd);
	if (rc < 0)
		goto fail_micbias_config;

	/* Configure the accessory */
	if (dd->accessory_support == true) {
		rc = pm8058_configure_accessory(dd);
		if (rc < 0)
			goto fail_micbias_config;
	}

	input_set_drvdata(ipd, dd);
	spin_lock_init(&dd->lock);

	rc = input_register_device(ipd);
	if (rc) {
		pr_err("Unable to register OTHC device\n");
		goto fail_micbias_config;
	}

	hrtimer_init(&dd->timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
	dd->timer.function = pm8058_othc_timer;

	INIT_DELAYED_WORK(&dd->detect_work, detect_work_f);

	if (dd->othc_support_n_switch == true)
		INIT_WORK(&dd->switch_work, switch_work_f);

	/* Request the HEADSET IR interrupt */
	rc = request_threaded_irq(dd->othc_irq_ir, NULL, pm8058_nc_ir,
		IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING | IRQF_DISABLED,
				"pm8058_othc_ir", dd);
	if (rc < 0) {
		pr_err("Unable to request pm8058_othc_ir IRQ\n");
		goto fail_ir_irq;
	}

	/* Request the  SWITCH press/release interrupt */
	rc = request_threaded_irq(dd->othc_irq_sw, NULL, pm8058_no_sw,
	IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING | IRQF_DISABLED,
			"pm8058_othc_sw", dd);
	if (rc < 0) {
		pr_err("Unable to request pm8058_othc_sw IRQ\n");
		goto fail_sw_irq;
	}

	/* Check if the accessory is already inserted during boot up */
	rc = pm8058_irq_get_rt_status(dd->pm_chip, dd->othc_irq_ir);
	if (rc < 0) {
		pr_err("Unable to get accessory status at boot\n");
		goto fail_ir_irq;
	}
	if (rc) {
		pr_debug("Accessory inserted during boot up\n");
		/* process the data and report the inserted accessory */
		rc = pm8058_accessory_report(dd, 1);
		if (rc)
			pr_debug("Unabele to detect accessory at boot up\n");
	}

	device_init_wakeup(&pd->dev,
			hsed_config->hsed_bias_config->othc_wakeup);

	return 0;

fail_sw_irq:
	free_irq(dd->othc_irq_ir, dd);
fail_ir_irq:
	input_unregister_device(ipd);
	dd->othc_ipd = NULL;
fail_micbias_config:
	input_free_device(ipd);
fail_input_alloc:
	switch_dev_unregister(&dd->othc_sdev);
	return rc;
}
示例#8
0
static int cypress_ts_probe(struct i2c_client *client, const struct i2c_device_id *id)
{
    struct cypress_ts_data *ts;
     //uint8_t buf0[4];
     uint8_t buf1[13];
     //	struct i2c_msg msg[2];
     int ret = 0;
     uint16_t max_x, max_y;
     // struct rmi_i2c_data *pdata;
	   struct proc_dir_entry *dir,*refresh;//ZTE_WLY_CRDB00509514
	   ret = gpio_request(GPIO_TOUCH_EN_OUT, "touch voltage");
	if (ret)
	{
		printk("gpio 31 request is error!\n");
		goto err_check_functionality_failed;
	}	   
    gpio_direction_output(GPIO_TOUCH_EN_OUT, 1);
/*ZTE_DELET_TIMER_WLY_001,2010-5-06 START*/
    msleep(20);
/*ZTE_DELET_TIMER_WLY_001,2010-5-06 START*/
    if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C))
    {
        printk(KERN_ERR "cypress_ts_probe: need I2C_FUNC_I2C\n");
        ret = -ENODEV;
        goto err_check_functionality_failed;
    }
    ts = kzalloc(sizeof(*ts), GFP_KERNEL);
    if (ts == NULL)
    {
        ret = -ENOMEM;
        goto err_alloc_data_failed;
    }

    INIT_WORK(&ts->work, cypress_ts_work_func);
    ts->client = client;
    	
    i2c_set_clientdata(client, ts);
    client->driver = &cypress_ts_driver;
    printk("wly: %s\n", __FUNCTION__);
    {
        int retry = 3;
		
        while (retry-- > 0)
        {
            ret = cypress_i2c_read(ts->client, 0x00, buf1, 13);
	/*ZTE_DELET_TIMER_WLY_001,2010-5-06 START*/   
	     if (ret >= 0)
    	     break;	
    	       msleep(10);
/*ZTE_DELET_TIMER_WLY_001,2010-5-06 START*/
        }
	 if (retry < 0)
	 {
	     ret = -1;
	     goto err_detect_failed;
	 }
    }
    firmware_version = buf1[12];
    ts->input_dev = input_allocate_device();

    if (ts->input_dev == NULL)
    {
        ret = -ENOMEM;
        printk(KERN_ERR "cypress_ts_probe: Failed to allocate input device\n");
        goto err_input_dev_alloc_failed;
    }
    // cypress_td = ts;
    ts->input_dev->name = "cypress_touch";
    ts->input_dev->phys = "cypress_touch/input0";
//ZTE_SET_BIT_WLY_0518,BEGIN
/*
    ts->input_dev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS);
    ts->input_dev->absbit[0] = BIT(ABS_X) | BIT(ABS_Y) | BIT(ABS_PRESSURE);
    ts->input_dev->absbit[BIT_WORD(ABS_MISC)] = BIT_MASK(ABS_MISC);
    ts->input_dev->keybit[BIT_WORD(BTN_TOUCH)] = BIT_MASK(BTN_TOUCH);
*/
//ZTE_SET_BIT_WLY_0518,END
    set_bit(EV_SYN, ts->input_dev->evbit);
    set_bit(EV_KEY, ts->input_dev->evbit);
    set_bit(BTN_TOUCH, ts->input_dev->keybit);
    set_bit(EV_ABS, ts->input_dev->evbit);
    /*ZTE_TOUCH_WLY_006, @2010-04-14,begin*/
    //ZTE_SET_BIT_WLY_0518,BEGIN
    set_bit(ABS_MT_TOUCH_MAJOR, ts->input_dev->absbit);
    set_bit(ABS_MT_POSITION_X, ts->input_dev->absbit);
    set_bit(ABS_MT_POSITION_Y, ts->input_dev->absbit);
    set_bit(ABS_MT_WIDTH_MAJOR, ts->input_dev->absbit);
    /*ZTE_TOUCH_WLY_006, @2010-04-14,end*/
#ifdef CYPRESS_GESTURE//ZTE_TOUCH_ZT_002
    set_bit(EVENT_SINGLE_CLICK, ts->input_dev->absbit);
    set_bit(EVENT_TAP_HOLD, ts->input_dev->absbit);
    set_bit(EVENT_EARLY_TAP, ts->input_dev->absbit);
    set_bit(EVENT_FLICK, ts->input_dev->absbit);
    set_bit(EVENT_PRESS, ts->input_dev->absbit);
     set_bit(EVENT_PINCH, ts->input_dev->absbit);
    //ZTE_SET_BIT_WLY_0518,END
#endif
    /*ZTE_TOUCH_WLY_006, @2010-04-14,begin*/
	
    //ZTE_TS_ZT_20100428_001 begin
#if defined(CONFIG_MACH_BLADE)//P729B
    max_x=479;
    max_y=799;
#elif defined(CONFIG_MACH_R750)||defined(CONFIG_MACH_JOECDMA)
    max_x=319;
    max_y=479;
#else//other projects
    max_x=319;
    max_y=479;
#endif
    //ZTE_TS_ZT_20100428_001 end

    //ZTE_XUKE_TOUCH_20100901 //ZTE_TOUCH_LIWEI_20101014
    #ifdef TOUCHSCREEN_DUPLICATED_FILTER	
    ts->dup_threshold = (max_y+1)/LCD_MAX_Y; 
    printk("xuke:dup_threshold %d\n", ts->dup_threshold);
    #endif


    //ZTE_SET_BIT_WLY_0518,BEGIN
    /*
    input_set_abs_params(ts->input_dev, ABS_X, 0, max_x, 0, 0);
    input_set_abs_params(ts->input_dev, ABS_Y, 0, max_y, 0, 0);
    input_set_abs_params(ts->input_dev, ABS_PRESSURE, 0, 255, 0, 0);
    */
    //ZTE_SET_BIT_WLY_0518,END
    input_set_abs_params(ts->input_dev, ABS_MT_TOUCH_MAJOR, 0, 255, 0, 0);
    input_set_abs_params(ts->input_dev, ABS_MT_POSITION_X, 0, max_x, 0, 0);
    input_set_abs_params(ts->input_dev, ABS_MT_POSITION_Y, 0, max_y, 0, 0);
    input_set_abs_params(ts->input_dev, ABS_MT_WIDTH_MAJOR, 0, 255, 0, 0);
    /*ZTE_TOUCH_WLY_006, @2010-04-14,end*/
#ifdef CYPRESS_GESTURE//ZTE_TOUCH_ZT_002
    input_set_abs_params(ts->input_dev, EVENT_SINGLE_CLICK, 0, 255, 0, 0);
    input_set_abs_params(ts->input_dev, EVENT_TAP_HOLD, 0, 255, 0, 0);
    input_set_abs_params(ts->input_dev, EVENT_EARLY_TAP, 0, 255, 0, 0);
    input_set_abs_params(ts->input_dev, EVENT_FLICK, 0, 255, 0, 0);
    input_set_abs_params(ts->input_dev, EVENT_PRESS, 0, 128, 0, 0);
    input_set_abs_params(ts->input_dev, EVENT_PINCH, 0, 255, 0, 0);//wly add
#endif

    ret = input_register_device(ts->input_dev);
    if (ret)
    {
        printk(KERN_ERR "cypress_ts_probe: Unable to register %s input device\n", ts->input_dev->name);
        goto err_input_register_device_failed;
    }
	
    /*ZTE_WLY_RESUME_001,2010-4-23 START*/
    /*ZTE_DELET_TIMER_WLY_001,2010-5-06 START*/
    //hrtimer_init(&ts->resume_timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
    //ts->resume_timer.function = cypress_ts_resume_func;
    /*ZTE_DELET_TIMER_WLY_001,2010-5-06 START*/
    /*ZTE_WLY_RESUME_001,2010-4-23 START*/

    cypress_td = ts;
    if (client->irq)
    {
        ret = request_irq(ts->client->irq, cypress_ts_irq_handler, IRQF_TRIGGER_FALLING, "cypress_touch", ts);
        if (ret == 0) ts->use_irq = 1;
    }
    if (!ts->use_irq)
    {
        hrtimer_init(&ts->timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
        ts->timer.function = cypress_ts_timer_func;
        hrtimer_start(&ts->timer, ktime_set(1, 0), HRTIMER_MODE_REL);
    }
#ifdef CONFIG_HAS_EARLYSUSPEND
    ts->early_suspend.level = EARLY_SUSPEND_LEVEL_BLANK_SCREEN + 1;
    ts->early_suspend.suspend = cypress_ts_early_suspend;
    ts->early_suspend.resume = cypress_ts_late_resume;
    register_early_suspend(&ts->early_suspend);
#endif

    printk(KERN_INFO "cypress_ts_probe: Start touchscreen %s in %s mode\n", ts->input_dev->name,
        ts->use_irq ? "interrupt" : "polling");
    //ZTE_WLY_CRDB00509514,BEGIN
    dir = proc_mkdir("touchscreen", NULL);
    refresh = create_proc_entry("ts_information", 0777, dir);//ZTE_WLY_CRDB00517999
    if (refresh) {
        refresh->data		= NULL;
        refresh->read_proc  = proc_read_val;
        refresh->write_proc = proc_write_val;	
    }
    //ZTE_WLY_CRDB00509514,END

#if defined(CONFIG_TOUCHSCREEN_VIRTUAL_KEYS)//ZTE_TS_ZT_20100513_001
	ts_key_report_init();
#endif

    return 0;
err_input_register_device_failed:
    input_unregister_device(ts->input_dev);

err_input_dev_alloc_failed:
    input_free_device(ts->input_dev);
err_detect_failed:
    //err_power_failed:
    kfree(ts);
err_alloc_data_failed:
err_check_functionality_failed:
    gpio_free(GPIO_TOUCH_EN_OUT);	
    return ret;
}
static int gp2a_i2c_probe(struct i2c_client *client,
			const struct i2c_device_id *id)
{
	int ret = -ENODEV;
	struct input_dev *input_dev;
	struct gp2a_data *gp2a;
	struct gp2a_platform_data *pdata = client->dev.platform_data;

	pr_info("==============================\n");
	pr_info("=========     GP2A     =======\n");
	pr_info("==============================\n");

	if (!pdata) {
		pr_err("%s: missing pdata!\n", __func__);
		return ret;
	}
	/*
	if (!pdata->power || !pdata->light_adc_value) {
		pr_err("%s: incomplete pdata!\n", __func__);
		return ret;
	}
	*/
	if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) {
		pr_err("%s: i2c functionality check failed!\n", __func__);
		return ret;
	}

	gp2a = kzalloc(sizeof(struct gp2a_data), GFP_KERNEL);
	if (!gp2a) {
		pr_err("%s: failed to alloc memory for module data\n",
			__func__);
		return -ENOMEM;
	}

#if defined(CONFIG_OPTICAL_WAKE_ENABLE)
	if (system_rev >= 0x03) {
		pr_info("GP2A Reset GPIO = GPX0(1) (rev%02d)\n", system_rev);
		gp2a->enable_wakeup = true;
	} else {
		pr_info("GP2A Reset GPIO = GPL0(6) (rev%02d)\n", system_rev);
		gp2a->enable_wakeup = false;
	}
#else
	gp2a->enable_wakeup = false;
#endif

	gp2a->pdata = pdata;
	gp2a->i2c_client = client;
	i2c_set_clientdata(client, gp2a);

	/* wake lock init */
	wake_lock_init(&gp2a->prx_wake_lock, WAKE_LOCK_SUSPEND,
			"prx_wake_lock");
	mutex_init(&gp2a->power_mutex);
	mutex_init(&gp2a->adc_mutex);

	ret = gp2a_setup_irq(gp2a);
	if (ret) {
		pr_err("%s: could not setup irq\n", __func__);
		goto err_setup_irq;
	}

	/* allocate proximity input_device */
	input_dev = input_allocate_device();
	if (!input_dev) {
		pr_err("%s: could not allocate input device\n", __func__);
		goto err_input_allocate_device_proximity;
	}

	gp2a->proximity_input_dev = input_dev;
	input_set_drvdata(input_dev, gp2a);
	input_dev->name = "proximity_sensor";
	input_set_capability(input_dev, EV_ABS, ABS_DISTANCE);
	input_set_abs_params(input_dev, ABS_DISTANCE, 0, 1, 0, 0);

	gp2a_dbgmsg("registering proximity input device\n");
	ret = input_register_device(input_dev);
	if (ret < 0) {
		pr_err("%s: could not register input device\n", __func__);
		input_free_device(input_dev);
		goto err_input_register_device_proximity;
	}

	ret = sysfs_create_group(&input_dev->dev.kobj,
				 &proximity_attribute_group);
	if (ret) {
		pr_err("%s: could not create sysfs group\n", __func__);
		goto err_sysfs_create_group_proximity;
	}

	/* hrtimer settings.  we poll for light values using a timer. */
	hrtimer_init(&gp2a->timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
	gp2a->light_poll_delay =
			ns_to_ktime(LIGHT_TIMER_PERIOD_MS * NSEC_PER_MSEC);
	gp2a->timer.function = gp2a_timer_func;

	/* the timer just fires off a work queue request.  we need a thread
	   to read the i2c (can be slow and blocking). */
	gp2a->wq = create_singlethread_workqueue("gp2a_wq");
	if (!gp2a->wq) {
		ret = -ENOMEM;
		pr_err("%s: could not create workqueue\n", __func__);
		goto err_create_workqueue;
	}

	/* this is the thread function we run on the work queue */
	INIT_WORK(&gp2a->work_light, gp2a_work_func_light);

#ifdef GP2A_MODE_B
	/* this is the thread function we run on the work queue */
	INIT_WORK(&gp2a->work_proximity, gp2a_work_func_proximity);
#endif

	/* allocate lightsensor-level input_device */
	input_dev = input_allocate_device();
	if (!input_dev) {
		pr_err("%s: could not allocate input device\n", __func__);
		ret = -ENOMEM;
		goto err_input_allocate_device_light;
	}

	input_set_drvdata(input_dev, gp2a);
	input_dev->name = "light_sensor";
	input_set_capability(input_dev, EV_ABS, ABS_MISC);
	input_set_abs_params(input_dev, ABS_MISC, 0, 1, 0, 0);

	gp2a_dbgmsg("registering lightsensor-level input device\n");
	ret = input_register_device(input_dev);
	if (ret < 0) {
		pr_err("%s: could not register input device\n", __func__);
		input_free_device(input_dev);
		goto err_input_register_device_light;
	}

	gp2a->light_input_dev = input_dev;
	ret = sysfs_create_group(&input_dev->dev.kobj,
				&light_attribute_group);
	if (ret) {
		pr_err("%s: could not create sysfs group\n", __func__);
		goto err_sysfs_create_group_light;
	}

	/* alloc platform device for adc client */
	pdev_gp2a_adc = platform_device_alloc("gp2a-adc", -1);
	if (!pdev_gp2a_adc) {
		pr_err("%s: could not allocation pdev_gp2a_adc.\n", __func__);
		ret = -ENOMEM;
		goto err_platform_allocate_device_adc;
	}

	/* Register adc client */
	gp2a->padc = s3c_adc_register(pdev_gp2a_adc, NULL, NULL, 0);

	if (IS_ERR(gp2a->padc)) {
		dev_err(&pdev_gp2a_adc->dev, "cannot register adc\n");
		ret = PTR_ERR(gp2a->padc);
		goto err_platform_register_device_adc;
	}

	/* set sysfs for light sensor */

	ret = misc_register(&light_device);
	if (ret)
		pr_err(KERN_ERR "misc_register failed - light\n");

	gp2a->lightsensor_class = class_create(THIS_MODULE, "lightsensor");
	if (IS_ERR(gp2a->lightsensor_class))
		pr_err("Failed to create class(lightsensor)!\n");

	gp2a->switch_cmd_dev = device_create(gp2a->lightsensor_class,
		NULL, 0, NULL, "switch_cmd");
	if (IS_ERR(gp2a->switch_cmd_dev))
		pr_err("Failed to create device(switch_cmd_dev)!\n");

	if (device_create_file(gp2a->switch_cmd_dev,
		&dev_attr_lightsensor_file_illuminance) < 0)
		pr_err("Failed to create device file(%s)!\n",
			dev_attr_lightsensor_file_illuminance.attr.name);

	dev_set_drvdata(gp2a->switch_cmd_dev, gp2a);

/* new sysfs */
	ret = sensors_register(gp2a->light_dev, gp2a, light_sensor_attrs,
						"light_sensor");
	if (ret) {
		pr_err("%s: cound not register light sensor device(%d).\n",
		__func__, ret);
		goto out_light_sensor_register_failed;
	}

	ret = sensors_register(gp2a->proximity_dev,
			gp2a, proximity_sensor_attrs, "proximity_sensor");
	if (ret) {
		pr_err("%s: cound not register proximity sensor device(%d).\n",
		__func__, ret);
		goto out_proximity_sensor_register_failed;
	}

	/* set initial proximity value as 1 */
	gp2a->prox_value = 1;
	input_report_abs(gp2a->proximity_input_dev, ABS_DISTANCE, 1);
	input_sync(gp2a->proximity_input_dev);

	gp2a->adc_total = 0;

	goto done;

	/* error, unwind it all */
out_light_sensor_register_failed:
	sensors_unregister(gp2a->light_dev);
out_proximity_sensor_register_failed:
	sensors_unregister(gp2a->proximity_dev);

err_sysfs_create_group_light:
	input_unregister_device(gp2a->light_input_dev);
err_input_register_device_light:
err_input_allocate_device_light:
	destroy_workqueue(gp2a->wq);
err_platform_allocate_device_adc:
	platform_device_unregister(pdev_gp2a_adc);
err_platform_register_device_adc:
	s3c_adc_release(gp2a->padc);
err_create_workqueue:
	sysfs_remove_group(&gp2a->proximity_input_dev->dev.kobj,
			&proximity_attribute_group);
err_sysfs_create_group_proximity:
	input_unregister_device(gp2a->proximity_input_dev);
err_input_register_device_proximity:
err_input_allocate_device_proximity:
	free_irq(gp2a->irq, 0);
	gpio_free(gp2a->pdata->p_out);
err_setup_irq:
	mutex_destroy(&gp2a->adc_mutex);
	mutex_destroy(&gp2a->power_mutex);

	wake_lock_destroy(&gp2a->prx_wake_lock);
	kfree(gp2a);
done:
	return ret;
}
示例#10
0
int gpio_event_matrix_func(struct gpio_event_input_devs *input_devs,
	struct gpio_event_info *info, void **data, int func)
{
	int i;
	int err;
	int key_count;
	struct gpio_kp *kp;
	struct gpio_event_matrix_info *mi;

	mi = container_of(info, struct gpio_event_matrix_info, info);
	if (func == GPIO_EVENT_FUNC_SUSPEND || func == GPIO_EVENT_FUNC_RESUME) {
		/* TODO: disable scanning */
		return 0;
	}

	if (func == GPIO_EVENT_FUNC_INIT) {
		if (mi->keymap == NULL ||
		   mi->input_gpios == NULL ||
		   mi->output_gpios == NULL) {
			err = -ENODEV;
			pr_err("gpiomatrix: Incomplete pdata\n");
			goto err_invalid_platform_data;
		}
		key_count = mi->ninputs * mi->noutputs;

		*data = kp = kzalloc(sizeof(*kp) + sizeof(kp->keys_pressed[0]) *
				     BITS_TO_LONGS(key_count), GFP_KERNEL);
		if (kp == NULL) {
			err = -ENOMEM;
			pr_err("gpiomatrix: Failed to allocate private data\n");
			goto err_kp_alloc_failed;
		}
		kp->input_devs = input_devs;
		kp->keypad_info = mi;
		for (i = 0; i < key_count; i++) {
			unsigned short keyentry = mi->keymap[i];
			unsigned short keycode = keyentry & MATRIX_KEY_MASK;
			unsigned short dev = keyentry >> MATRIX_CODE_BITS;
			if (dev >= input_devs->count) {
				pr_err("gpiomatrix: bad device index %d >= "
					"%d for key code %d\n",
					dev, input_devs->count, keycode);
				err = -EINVAL;
				goto err_bad_keymap;
			}
			if (keycode && keycode <= KEY_MAX)
				input_set_capability(input_devs->dev[dev],
							EV_KEY, keycode);
		}

		for (i = 0; i < mi->noutputs; i++) {
			if (gpio_cansleep(mi->output_gpios[i])) {
				pr_err("gpiomatrix: unsupported output gpio %d,"
					" can sleep\n", mi->output_gpios[i]);
				err = -EINVAL;
				goto err_request_output_gpio_failed;
			}
			err = gpio_request(mi->output_gpios[i], "gpio_kp_out");
			if (err) {
				pr_err("gpiomatrix: gpio_request failed for "
					"output %d\n", mi->output_gpios[i]);
				goto err_request_output_gpio_failed;
			}
			if (mi->flags & GPIOKPF_DRIVE_INACTIVE)
				err = gpio_direction_output(mi->output_gpios[i],
					!(mi->flags & GPIOKPF_ACTIVE_HIGH));
			else
				err = gpio_direction_input(mi->output_gpios[i]);
			if (err) {
				pr_err("gpiomatrix: gpio_configure failed for "
					"output %d\n", mi->output_gpios[i]);
				goto err_output_gpio_configure_failed;
			}
		}
		for (i = 0; i < mi->ninputs; i++) {
			err = gpio_request(mi->input_gpios[i], "gpio_kp_in");
			if (err) {
				pr_err("gpiomatrix: gpio_request failed for "
					"input %d\n", mi->input_gpios[i]);
				goto err_request_input_gpio_failed;
			}
			err = gpio_direction_input(mi->input_gpios[i]);
			if (err) {
				pr_err("gpiomatrix: gpio_direction_input failed"
					" for input %d\n", mi->input_gpios[i]);
				goto err_gpio_direction_input_failed;
			}
		}

		if (mi->setup_ninputs_gpio)
			mi->setup_ninputs_gpio();

		kp->current_output = mi->noutputs;
		kp->key_state_changed = 1;

		hrtimer_init(&kp->timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
		kp->timer.function = gpio_keypad_timer_func;
		wake_lock_init(&kp->wake_lock, WAKE_LOCK_SUSPEND, "gpio_kp");
		err = gpio_keypad_request_irqs(kp);
		kp->use_irq = err == 0;

		pr_info("GPIO Matrix Keypad Driver: Start keypad matrix for "
			"%s%s in %s mode\n", input_devs->dev[0]->name,
			(input_devs->count > 1) ? "..." : "",
			kp->use_irq ? "interrupt" : "polling");

		if (kp->use_irq)
			wake_lock(&kp->wake_lock);
		hrtimer_start(&kp->timer, ktime_set(0, 0), HRTIMER_MODE_REL);

		return 0;
	}

	err = 0;
	kp = *data;

	if (kp->use_irq)
		for (i = mi->noutputs - 1; i >= 0; i--)
			free_irq(gpio_to_irq(mi->input_gpios[i]), kp);

	hrtimer_cancel(&kp->timer);
	wake_lock_destroy(&kp->wake_lock);
	for (i = mi->noutputs - 1; i >= 0; i--) {
err_gpio_direction_input_failed:
		gpio_free(mi->input_gpios[i]);
err_request_input_gpio_failed:
		;
	}
	for (i = mi->noutputs - 1; i >= 0; i--) {
err_output_gpio_configure_failed:
		gpio_free(mi->output_gpios[i]);
err_request_output_gpio_failed:
		;
	}
err_bad_keymap:
	kfree(kp);
err_kp_alloc_failed:
err_invalid_platform_data:
	return err;
}
示例#11
0
void mdp_config_vsync(struct msm_fb_data_type *mfd)
{

	/* vsync on primary lcd only for now */
	if ((mfd->dest != DISPLAY_LCD) || (mfd->panel_info.pdest != DISPLAY_1)
	    || (!vsync_mode)) {
		goto err_handle;
	}

	if (mfd->panel_info.lcd.vsync_enable) {
		mfd->total_porch_lines = mfd->panel_info.lcd.v_back_porch +
		    mfd->panel_info.lcd.v_front_porch +
		    mfd->panel_info.lcd.v_pulse_width;
		mfd->total_lcd_lines =
		    mfd->panel_info.yres + mfd->total_porch_lines;
		mfd->lcd_ref_usec_time =
		    100000000 / mfd->panel_info.lcd.refx100;
		mfd->vsync_handler_pending = FALSE;
		mfd->last_vsync_timetick.tv.sec = 0;
		mfd->last_vsync_timetick.tv.nsec = 0;

#ifdef MDP_HW_VSYNC
		if (mdp_vsync_clk == NULL)
			mdp_vsync_clk = clk_get(NULL, "mdp_vsync_clk");

		if (IS_ERR(mdp_vsync_clk)) {
			printk(KERN_ERR "error: can't get mdp_vsync_clk!\n");
			mfd->use_mdp_vsync = 0;
		} else
			mfd->use_mdp_vsync = 1;

		if (mfd->use_mdp_vsync) {
			uint32 vsync_cnt_cfg, vsync_cnt_cfg_dem;
			uint32 mdp_vsync_clk_speed_hz;

			mdp_vsync_clk_speed_hz = clk_get_rate(mdp_vsync_clk);

			if (mdp_vsync_clk_speed_hz == 0) {
				mfd->use_mdp_vsync = 0;
			} else {
				/*
				 * Do this calculation in 2 steps for
				 * rounding uint32 properly.
				 */
				vsync_cnt_cfg_dem =
				    (mfd->panel_info.lcd.refx100 *
				     mfd->total_lcd_lines) / 100;
				vsync_cnt_cfg =
				    (mdp_vsync_clk_speed_hz) /
				    vsync_cnt_cfg_dem;

				/* MDP cmd block enable */
				mdp_pipe_ctrl(MDP_CMD_BLOCK, MDP_BLOCK_POWER_ON,
					      FALSE);
				mdp_hw_vsync_clk_enable(mfd);

				mdp_set_sync_cfg_0(mfd, vsync_cnt_cfg);

				/*
				 * load the last line + 1 to be in the
				 * safety zone
				 */
				vsync_load_cnt = mfd->panel_info.yres;

				/* line counter init value at the next pulse */
				MDP_OUTP(MDP_BASE + MDP_PRIM_VSYNC_INIT_VAL,
							vsync_load_cnt);

				/*
				 * external vsync source pulse width and
				 * polarity flip
				 */
				MDP_OUTP(MDP_BASE + MDP_PRIM_VSYNC_OUT_CTRL,
							BIT(30) | BIT(0));


				/* threshold */
				MDP_OUTP(MDP_BASE + 0x200,
					 (vsync_above_th << 16) |
					 (vsync_start_th));

				mdp_hw_vsync_clk_disable(mfd);
				/* MDP cmd block disable */
				mdp_pipe_ctrl(MDP_CMD_BLOCK,
					      MDP_BLOCK_POWER_OFF, FALSE);
			}
		}
#else
		mfd->use_mdp_vsync = 0;
		hrtimer_init(&mfd->dma_hrtimer, CLOCK_MONOTONIC,
			     HRTIMER_MODE_REL);
		mfd->dma_hrtimer.function = mdp_dma2_vsync_hrtimer_handler;
		mfd->vsync_width_boundary = vmalloc(mfd->panel_info.xres * 4);
#endif

		mfd->channel_irq = 0;
		if (mfd->panel_info.lcd.hw_vsync_mode) {
			u32 vsync_gpio = mfd->vsync_gpio;
			u32 ret;

			if (vsync_gpio == -1) {
				MSM_FB_INFO("vsync_gpio not defined!\n");
				goto err_handle;
			}

			ret = gpio_tlmm_config(GPIO_CFG
					(vsync_gpio,
					(mfd->use_mdp_vsync) ? 1 : 0,
					GPIO_CFG_INPUT,
					GPIO_CFG_PULL_DOWN,
					GPIO_CFG_2MA),
					GPIO_CFG_ENABLE);
			if (ret)
				goto err_handle;

			if (!mfd->use_mdp_vsync) {
				mfd->channel_irq = MSM_GPIO_TO_INT(vsync_gpio);
				if (request_irq
				    (mfd->channel_irq,
				     &mdp_hw_vsync_handler_proxy,
				     IRQF_TRIGGER_FALLING, "VSYNC_GPIO",
				     (void *)mfd)) {
					MSM_FB_INFO
					("irq=%d failed! vsync_gpio=%d\n",
						mfd->channel_irq,
						vsync_gpio);
					goto err_handle;
				}
			}
		}

		mdp_set_vsync((unsigned long)mfd);
	}

	return;

err_handle:
	if (mfd->vsync_width_boundary)
		vfree(mfd->vsync_width_boundary);
	mfd->panel_info.lcd.vsync_enable = FALSE;
	printk(KERN_ERR "%s: failed!\n", __func__);
}
示例#12
0
int __init archos_audio_gpio_init(void)
{
	const struct archos_audio_config *audio_cfg;
	struct clk *clkout2_src_ck;
	struct clk *sys_clkout2;
	struct clk *core_ck;

	/* audio  */
	audio_cfg = omap_get_config( ARCHOS_TAG_AUDIO, struct archos_audio_config );
	if (audio_cfg == NULL) {
		pr_err("archos_audio_gpio_init: no board configuration found\n");
		return -ENODEV;
	}
	if ( hardware_rev >= audio_cfg->nrev ) {
		pr_err("archos_audio_gpio_init: hardware_rev (%i) >= nrev (%i)\n",
			hardware_rev, audio_cfg->nrev);
		return -ENODEV;
	}

	audio_gpio = audio_cfg->rev[hardware_rev];

	// a32 & a43 protos where using clkout1.
	if (hardware_rev >= 1 || !(machine_is_archos_a32() || machine_is_archos_a43())) {
		core_ck = clk_get(NULL, "cm_96m_fck");
		if (IS_ERR(core_ck)) {
			printk(KERN_ERR "failed to get core_ck\n");
		}
	
		clkout2_src_ck = clk_get(NULL, "clkout2_src_ck");
		if (IS_ERR(clkout2_src_ck)) {
			printk(KERN_ERR "failed to get clkout2_src_ck\n");
		}
	
		sys_clkout2 = clk_get(NULL, "sys_clkout2");
		if (IS_ERR(sys_clkout2)) {
			printk(KERN_ERR "failed to get sys_clkout2\n");
		}
	
		if ( clk_set_parent(clkout2_src_ck, core_ck) != 0) {
			printk(KERN_ERR "failed to set sys_clkout2 parent to clkout2\n");
		}
	
		/* Set the clock to 12 Mhz */
		omap2_clksel_set_rate(sys_clkout2, 12000000);

		clk_put(sys_clkout2);
		clk_put(clkout2_src_ck);
		clk_put(core_ck);

		sysclock_name = sys_clkout2_name;
		use_mcbsp1_fclk = 1;
	} else {
		sysclock_name = sys_clkout1_name;
	}

	if (GPIO_PIN( audio_gpio.spdif ) != -1)
		archos_gpio_init_output( &audio_gpio.spdif, "spdif" );

	if (GPIO_PIN( audio_gpio.hp_on ) != -1)
		archos_gpio_init_output( &audio_gpio.hp_on, "hp_on" );

	if (GPIO_PIN( audio_gpio.headphone_plugged ) != -1)
		archos_gpio_init_input( &audio_gpio.headphone_plugged, "hp_detect" );

	if (GPIO_PIN( audio_gpio.vamp_vbat ) != -1)
		archos_gpio_init_output( &audio_gpio.vamp_vbat, "vamp_vbat" );
	if (GPIO_PIN( audio_gpio.vamp_dc ) != -1)
		archos_gpio_init_output( &audio_gpio.vamp_dc, "vamp_dc" );

	// XXX maybe prevents OFF mode?
	if (GPIO_PIN( audio_gpio.headphone_plugged ) != -1)
		gpio_set_debounce(GPIO_PIN(audio_gpio.headphone_plugged), (1 + 1) * 0x1f);

	if (GPIO_PIN(audio_gpio.vamp_dc) != -1) {
		int ret = platform_device_register(&archos_audio_vamp_device);
		if (ret < 0)
			return ret;

		ret = platform_driver_register(&archos_audio_vamp_driver);
		if (ret < 0)
			return ret;

		ret = device_create_file(&archos_audio_vamp_device.dev, &dev_attr_vamp_vusb_ctrl);
		if (ret < 0)
			return ret;

		hrtimer_init(&vamp_watchdog_timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
		vamp_watchdog_timer.function = vamp_watchdog_timer_func;
	}

	pr_debug("%s init done\n", __FUNCTION__);
	return 0;
}
示例#13
0
static int __init star_vib_probe(struct platform_device *pdev )
{
	struct pwm_vib_platform_data*	pdata;
//	struct pwm_device*	pwm;
	int		err;

	printk("vib: %s,%s,%d\n", __FILE__, __FUNCTION__, __LINE__);

	pvib	=	kzalloc(sizeof(struct pwm_vib_data), GFP_KERNEL);
	if (!pvib) {
		dev_err(&pdev->dev, "no memory for state\n");
		err	=	-ENOMEM;
		goto	err_alloc;
	}

	pdata	=	pdev->dev.platform_data;
	if(pdata){
		pvib->dev			=	&pdev->dev;
		pvib->gpio_enable	=	pdata->enable;
		pvib->duty			=	pdata->duty_ns;
		pvib->period		=	pdata->period_ns;
		pvib->power			=	pdata->power;
	} else {
		err	=   -EBUSY;
		goto    err_exit;
	}

	if(pvib->power)
		pvib->power("vcc_motor_3v0", 1);

	gpio_request(pdata->enable, "vib_enable");
	gpio_direction_output(pdata->enable, 1);
	gpio_set_value(pdata->enable, 0);
	
	pvib->pwm	=	pwm_request(pdata->pwm_id, "vibrator");
	if (IS_ERR(pvib->pwm)) {
		dev_err(&pdev->dev, "unable to request PWM for vibrator\n");
		err	=	PTR_ERR(pvib->pwm);
		goto	err_pwm;
	}
	else
		dev_dbg(&pdev->dev, "got pwm for vibrator\n");

	hrtimer_init(&pvib->timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
	pvib->timer.function	=	star_vib_timeout;

	platform_set_drvdata(pdev, pvib);

	// sysfs setup
	if (sysfs_create_group(&pvib->dev->kobj, &star_vib_group)) {
		dev_err(&pdev->dev, "failed to create sys filesystem\n");
		err	=	-ENOSYS;
		goto	err_sysfs;
	}

	pwm_config(pvib->pwm, pvib->duty, pvib->period);
	pwm_enable(pvib->pwm);

	printk("vibrator probe success\n");

	#if VIB_DEBUG 
	printk("testing vibrator\n");
	// hrtimer_start(&pvib->timer, ktime_set(1, 0), HRTIMER_MODE_REL);
	hrtimer_start(&pvib->timer, ktime_set(0, 500 * 1000 * 1000), HRTIMER_MODE_REL);
	STAR_VIB_ENABLE();
	#endif

	return	0;

err_sysfs:
	pwm_free(pvib->pwm);
err_pwm:
err_alloc:
err_exit:
	return	err;
}
示例#14
0
static int max77693_haptic_probe(struct platform_device *pdev)
{
	int error = 0;
	struct max77693_dev *max77693 = dev_get_drvdata(pdev->dev.parent);
	struct max77693_platform_data *max77693_pdata
		= dev_get_platdata(max77693->dev);
	struct max77693_haptic_platform_data *pdata
		= max77693_pdata->haptic_data;
	struct max77693_haptic_data *hap_data;

	pr_debug("[VIB] ++ %s\n", __func__);
	 if (pdata == NULL) {
		pr_err("%s: no pdata\n", __func__);
		return -ENODEV;
	}

	hap_data = kzalloc(sizeof(struct max77693_haptic_data), GFP_KERNEL);
	if (!hap_data)
		return -ENOMEM;

	platform_set_drvdata(pdev, hap_data);
	g_hap_data = hap_data;
	hap_data->max77693 = max77693;
	hap_data->i2c = max77693->haptic;
	hap_data->pmic_i2c = max77693->i2c;
	hap_data->pdata = pdata;

	hap_data->workqueue = create_singlethread_workqueue("hap_work");
	INIT_WORK(&(hap_data->work), haptic_work);
	spin_lock_init(&(hap_data->lock));

	hap_data->pwm = pwm_request(hap_data->pdata->pwm_id, "vibrator");
	if (IS_ERR(hap_data->pwm)) {
		pr_err("[VIB] Failed to request pwm\n");
		error = -EFAULT;
		goto err_pwm_request;
	}
	pwm_config(hap_data->pwm, pdata->period / 2, pdata->period);

	vibetonz_clk_on(&pdev->dev, true);

	if (pdata->init_hw)
		pdata->init_hw();

	hap_data->regulator
		= regulator_get(NULL, pdata->regulator_name);

	if (IS_ERR(hap_data->regulator)) {
		pr_err("[VIB] Failed to get vmoter regulator.\n");
		error = -EFAULT;
		goto err_regulator_get;
	}

	/* hrtimer init */
	hrtimer_init(&hap_data->timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
	hap_data->timer.function = haptic_timer_func;

	/* timed_output_dev init*/
	hap_data->tout_dev.name = "vibrator";
	hap_data->tout_dev.get_time = haptic_get_time;
	hap_data->tout_dev.enable = haptic_enable;

#ifdef CONFIG_ANDROID_TIMED_OUTPUT
	error = timed_output_dev_register(&hap_data->tout_dev);
	if (error < 0) {
		pr_err("[VIB] Failed to register timed_output : %d\n", error);
		error = -EFAULT;
		goto err_timed_output_register;
	}
#endif
	printk(KERN_DEBUG "[VIB] timed_output device is registrated\n");
	pr_debug("[VIB] -- %s\n", __func__);

	return error;

err_timed_output_register:
	regulator_put(hap_data->regulator);
err_regulator_get:
	pwm_free(hap_data->pwm);
err_pwm_request:
	kfree(hap_data);
	g_hap_data = NULL;
	return error;
}
示例#15
0
int gpio_event_matrix_func(struct input_dev *input_dev,
                           struct gpio_event_info *info, void **data, int func)
{
    int i;
    int err;
    int key_count;
    struct gpio_kp *kp;
    struct gpio_event_matrix_info *mi;

    mi = container_of(info, struct gpio_event_matrix_info, info);
    if (func == GPIO_EVENT_FUNC_SUSPEND || func == GPIO_EVENT_FUNC_RESUME) {
        /* TODO: disable scanning */
        return 0;
    }

    if (func == GPIO_EVENT_FUNC_INIT) {
        if (mi->keymap == NULL ||
                mi->input_gpios == NULL ||
                mi->output_gpios == NULL) {
            err = -ENODEV;
            pr_err("gpiomatrix: Incomplete pdata\n");
            goto err_invalid_platform_data;
        }
        key_count = mi->ninputs * mi->noutputs;

        *data = kp = kzalloc(sizeof(*kp) + sizeof(kp->keys_pressed[0]) *
                             BITS_TO_LONGS(key_count), GFP_KERNEL);
        if (kp == NULL) {
            err = -ENOMEM;
            pr_err("gpiomatrix: Failed to allocate private data\n");
            goto err_kp_alloc_failed;
        }
        kp->input_dev = input_dev;
        kp->keypad_info = mi;
        set_bit(EV_KEY, input_dev->evbit);
        for (i = 0; i < key_count; i++) {
            if (mi->keymap[i])
                set_bit(mi->keymap[i] & KEY_MAX,
                        input_dev->keybit);
        }

        for (i = 0; i < mi->noutputs; i++) {
            if (gpio_cansleep(mi->output_gpios[i])) {
                pr_err("gpiomatrix: unsupported output gpio %d,"
                       " can sleep\n", mi->output_gpios[i]);
                err = -EINVAL;
                goto err_request_output_gpio_failed;
            }
            err = gpio_request(mi->output_gpios[i], "gpio_kp_out");
            if (err) {
                pr_err("gpiomatrix: gpio_request failed for "
                       "output %d\n", mi->output_gpios[i]);
                goto err_request_output_gpio_failed;
            }
            if (mi->flags & GPIOKPF_DRIVE_INACTIVE)
                err = gpio_direction_output(mi->output_gpios[i],
                                            !(mi->flags & GPIOKPF_ACTIVE_HIGH));
            else
                err = gpio_direction_input(mi->output_gpios[i]);
            if (err) {
                pr_err("gpiomatrix: gpio_configure failed for "
                       "output %d\n", mi->output_gpios[i]);
                goto err_output_gpio_configure_failed;
            }
        }
        for (i = 0; i < mi->ninputs; i++) {
            err = gpio_request(mi->input_gpios[i], "gpio_kp_in");
            if (err) {
                pr_err("gpiomatrix: gpio_request failed for "
                       "input %d\n", mi->input_gpios[i]);
                goto err_request_input_gpio_failed;
            }
            err = gpio_direction_input(mi->input_gpios[i]);
            if (err) {
                pr_err("gpiomatrix: gpio_direction_input failed"
                       " for input %d\n", mi->input_gpios[i]);
                goto err_gpio_direction_input_failed;
            }
        }
        kp->current_output = mi->noutputs;
        kp->key_state_changed = 1;

        hrtimer_init(&kp->timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
        kp->timer.function = gpio_keypad_timer_func;
        wake_lock_init(&kp->wake_lock, WAKE_LOCK_SUSPEND, "gpio_kp");
        err = gpio_keypad_request_irqs(kp);
        kp->use_irq = err == 0;

        pr_info("GPIO Matrix Keypad Driver: Start keypad matrix for %s "
                "in %s mode\n", input_dev->name,
                kp->use_irq ? "interrupt" : "polling");

        if (kp->use_irq)
            wake_lock_timeout(&kp->wake_lock, HZ * 3 / 2);
        hrtimer_start(&kp->timer, ktime_set(0, 0), HRTIMER_MODE_REL);

        return 0;
    }

    err = 0;
    kp = *data;

    if (kp->use_irq)
        for (i = mi->noutputs - 1; i >= 0; i--)
            free_irq(gpio_to_irq(mi->input_gpios[i]), kp);

    hrtimer_cancel(&kp->timer);
    wake_lock_destroy(&kp->wake_lock);
    for (i = mi->noutputs - 1; i >= 0; i--) {
err_gpio_direction_input_failed:
        gpio_free(mi->input_gpios[i]);
err_request_input_gpio_failed:
        ;
    }
    for (i = mi->noutputs - 1; i >= 0; i--) {
err_output_gpio_configure_failed:
        gpio_free(mi->output_gpios[i]);
err_request_output_gpio_failed:
        ;
    }
    kfree(kp);
err_kp_alloc_failed:
err_invalid_platform_data:
    return err;
}
示例#16
0
/*******************************************************	
功能:
	触摸屏探测函数
	在注册驱动时调用(要求存在对应的client);
	用于IO,中断等资源申请;设备注册;触摸屏初始化等工作
参数:
	client:待驱动的设备结构体
	id:设备ID
return:
	执行结果码,0表示正常执行
********************************************************/
static int goodix_ts_probe(struct i2c_client *client, const struct i2c_device_id *id)
{
	struct goodix_ts_data *ts;
	int ret = 0;
	int retry=0;
	int count=0;
FNC_ENTERY;
	struct goodix_i2c_platform_data *pdata;
	dev_dbg(&client->dev,"Install touchscreen driver for guitar.\n");

	if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) 
	{
		dev_err(&client->dev, "System need I2C function.\n");
		ret = -ENODEV;
		goto err_check_functionality_failed;
	}
        
	if (!(((board_version == 1)&&(hw_version == 0))||(board_version == 0)))
        {
		printk("%s: system hardware version:%d, GOODIX touchscreen is unsupported!!!\n", __func__, hw_version);
		ret = -1;
		goto err_check_functionality_failed;
	}
	
	ts = kzalloc(sizeof(*ts), GFP_KERNEL);
	if (ts == NULL) {
		ret = -ENOMEM;
		goto err_alloc_data_failed;
	}

	/* 获取预定义资源 */
	pdata = client->dev.platform_data;
	if(pdata != NULL) {
		//ts->gpio_shutdown = pdata->gpio_shutdown;
		//ts->gpio_irq = pdata->gpio_irq;
		
		//use as s3c_gpio_cfgpin(ts->gpio_shutdown, pdata->shutdown_cfg);		/* output */
	}
	
#ifdef SHUTDOWN_PORT	
	ts->gpio_shutdown = SHUTDOWN_PORT;
	if(ts->gpio_shutdown)
	{
		//ret = gpio_request(ts->gpio_shutdown, "TS_SHUTDOWN");	//Request IO
		if (ret < 0) 
		{
			printk(KERN_ALERT "Failed to request GPIO:%d, ERRNO:%d\n", ts->gpio_shutdown, ret);
			goto err_gpio_request;
		}	
		gpio_direction_output(ts->gpio_shutdown, 0);	//Touchscreen is waiting to wake up
		ret = gpio_get_value(ts->gpio_shutdown);
		if (ret)
		{
			printk(KERN_ALERT  "Cannot set touchscreen to work.\n");
			goto err_i2c_failed;
		}
		ts->use_shutdown = 1;
		msleep(25);		//waiting for initialization of Guitar.
	}
#endif		
	RESETPIN_CFG;
	RESETPIN_SET1;
	mdelay(200);
	RESETPIN_SET0;
	mdelay(200);

	i2c_connect_client = client;				//used by Guitar Updating.
	//TODO: used to set speed of i2c transfer. Must change as your paltform.
//	s3c24xx_set_i2c_clockrate(client->adapter, 250, &count);	//set i2c <=250kHz
	dev_dbg(&client->dev, "i2c set frequency:%dkHz.\n", count);
#if 0
	for(retry=0; retry < 5; retry++)
	{
		
	ret=i2c_read_bytes(ts->client,version_data, GT80X_VERSION_LENGTH);
		ret =i2c_write_bytes(client, NULL, 0);	//Test i2c.
		if (ret > 0)
			break;
	}
	if(ret < 0)
	{
		dev_err(&client->dev, "Warnning: I2C connection might be something wrong!\n");
		goto err_i2c_failed;
	}
#endif
	if(ts->use_shutdown)
		gpio_set_value(ts->gpio_shutdown, 1);		//suspend
	
	INIT_WORK(&ts->work, goodix_ts_work_func);
	ts->client = client;
	i2c_set_clientdata(client, ts);
	pdata = client->dev.platform_data;
	
	ts->input_dev = input_allocate_device();
	if (ts->input_dev == NULL) {
		ret = -ENOMEM;
		dev_dbg(&client->dev,"Failed to allocate input device\n");
		goto err_input_dev_alloc_failed;
	}

	ts->input_dev->evbit[0] = BIT_MASK(EV_SYN) | BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS) ;
#ifndef GOODIX_MULTI_TOUCH	
	ts->input_dev->keybit[BIT_WORD(BTN_TOUCH)] = BIT_MASK(BTN_TOUCH);
	ts->input_dev->absbit[0] = BIT(ABS_X) | BIT(ABS_Y);

	input_set_abs_params(ts->input_dev, ABS_X, 0, SCREEN_MAX_HEIGHT, 0, 0);
	input_set_abs_params(ts->input_dev, ABS_Y, 0, SCREEN_MAX_WIDTH, 0, 0);
	input_set_abs_params(ts->input_dev, ABS_PRESSURE, 0, 255, 0, 0);	
#else
	//ts->input_dev->absbit[0] = BIT_MASK(ABS_MT_TRACKING_ID) |
	ts->input_dev->absbit[0] = 
		BIT_MASK(ABS_MT_TOUCH_MAJOR)| BIT_MASK(ABS_MT_WIDTH_MAJOR) |
  		BIT_MASK(ABS_MT_POSITION_X) | BIT_MASK(ABS_MT_POSITION_Y); 	// for android
	input_set_abs_params(ts->input_dev, ABS_MT_WIDTH_MAJOR, 0, 255, 0, 0);
	input_set_abs_params(ts->input_dev, ABS_MT_TOUCH_MAJOR, 0, 255, 0, 0);
	input_set_abs_params(ts->input_dev, ABS_MT_POSITION_X, 0, SCREEN_MAX_HEIGHT, 0, 0);
	input_set_abs_params(ts->input_dev, ABS_MT_POSITION_Y, 0, SCREEN_MAX_WIDTH, 0, 0);	
	//input_set_abs_params(ts->input_dev, ABS_MT_TRACKING_ID, 0, MAX_FINGER_NUM-1, 0, 0);	
#endif	

	sprintf(ts->phys, "input/ts)");
	ts->input_dev->name = s3c_ts_name;
	ts->input_dev->phys = ts->phys;
	ts->input_dev->id.bustype = BUS_I2C;
	ts->input_dev->id.vendor = 0xDEAD;
	ts->input_dev->id.product = 0xBEEF;
	ts->input_dev->id.version = 0x1103;	

	finger_list.length = 0;
	ret = input_register_device(ts->input_dev);
	if (ret) {
		dev_err(&client->dev,"Probe: Unable to register %s input device\n", ts->input_dev->name);
		goto err_input_register_device_failed;
	}

	ts->use_irq = 1;
	//ts->use_irq = 0;
	ts->retry = 0;
	ts->bad_data = 0;

#if defined(INT_PORT)	
	ts->gpio_irq = INT_PORT;
	client->irq=TS_INT; //If not define in client
	if (client->irq)
	{
	
#ifdef CONFIG_MACH_EMEV
				writel(readl(CHG_PULL1)|0xC000, CHG_PULL1);
				gpio_direction_input(irq_to_gpio(client->irq));
#endif
		//ret = gpio_request(ts->gpio_irq, "TS_INT");	//Request IO
		if (ret < 0) 
		{
			dev_err(&client->dev, "Failed to request GPIO:%d, ERRNO:%d\n", ts->gpio_irq, ret);
			goto err_int_request_failed;
		}
//		ret = s3c_gpio_cfgpin(ts->gpio_irq, INT_CFG);	//Set IO port function
		ret  = request_irq(client->irq, goodix_ts_irq_handler ,  IRQ_TYPE_EDGE_RISING,
			"GoodixIRQ", ts);
		if (ret != 0) {
			dev_err(&client->dev,"Can't allocate touchscreen's interrupt%d!ERRNO:%d\n",client->irq, ret);
			gpio_direction_input(ts->gpio_irq);
			gpio_free(ts->gpio_irq);
			goto err_int_request_failed;
		}
		else 
		{	
			disable_irq(client->irq);
			ts->use_irq = 1;
			dev_dbg(&client->dev,"Reques EIRQ %d succesd on GPIO:%d\n",client->irq, ts->gpio_irq);
		}
	}
#endif

err_int_request_failed:	
	if (!ts->use_irq) 
	{
		hrtimer_init(&ts->timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
		ts->timer.function = goodix_ts_timer_func;
		hrtimer_start(&ts->timer, ktime_set(1, 0), HRTIMER_MODE_REL);
	}

	flush_workqueue(goodix_wq);
	if(ts->use_shutdown)
	{		
		gpio_set_value(ts->gpio_shutdown, 0);	
	#ifdef SHUTDOWN_PORT	
		ts->power = goodix_ts_power;
	#endif
		msleep(30);
	}	
	
	ret = goodix_init_panel(ts);
	if(ret != 0) 
		goto err_init_godix_ts;
	if(ts->use_irq)
		enable_irq(client->irq);
	
	goodix_read_version(ts);
	//msleep(500);
	
#ifdef CONFIG_HAS_EARLYSUSPEND
	ts->early_suspend.level = EARLY_SUSPEND_LEVEL_BLANK_SCREEN + 1;
	ts->early_suspend.suspend = goodix_ts_early_suspend;
	ts->early_suspend.resume = goodix_ts_late_resume;
	register_early_suspend(&ts->early_suspend);
#endif
	dev_dbg(&client->dev,"Start  %s in %s mode\n", 
		ts->input_dev->name, ts->use_irq ? "Interrupt" : "Polling");
	return 0;

err_init_godix_ts:
	if(ts->use_irq)
	{
		free_irq(client->irq,ts);	
		gpio_free(ts->gpio_irq);
	}

err_input_register_device_failed:
	input_free_device(ts->input_dev);

err_input_dev_alloc_failed:
	i2c_set_clientdata(client, NULL);
err_i2c_failed:
	if(ts->use_shutdown)
	{
		gpio_direction_input(ts->gpio_shutdown);
		gpio_free(ts->gpio_shutdown);
	}
err_gpio_request:
	kfree(ts);
err_alloc_data_failed:
err_check_functionality_failed:
	return ret;
}
static int audiojack_probe(struct platform_device *pdev)
{
	int ret;
	struct htc_headset_gpio_platform_data *pdata = pdev->dev.platform_data;

	SYS_MSG("++++++++++++++++++++");

	pjack_info = kzalloc(sizeof(struct audio_jack_info), GFP_KERNEL);
	if (!pjack_info)
		return -ENOMEM;

	pjack_info->audio_jack_detect = pdata->hpin_gpio;
	pjack_info->key_enable_gpio = pdata->key_enable_gpio;
	pjack_info->mic_select_gpio = pdata->mic_select_gpio;
	pjack_info->mic_detect = pdata->mic_detect_gpio;
	pjack_info->microp_channel = pdata->microp_channel;
	pjack_info->audio_jack_flag = 0;
	pjack_info->last_pressed_key = 0;

	pjack_info->debounce_time = ktime_set(0, 500000000);
	hrtimer_init(&pjack_info->detection_timer,
		     CLOCK_MONOTONIC, HRTIMER_MODE_REL);
	pjack_info->detection_timer.function = detect_35mm_event_timer_func;

	INIT_WORK(&pjack_info->work, audiojack_work_func);
	INIT_WORK(&pjack_info->mic_work, mic_work_func);

	spin_lock_init(&pjack_info->spin_lock);
	wake_lock_init(&pjack_info->audiojack_wake_lock,
		WAKE_LOCK_SUSPEND, "audiojack");

	if (pjack_info->audio_jack_detect) {
		ret = gpio_request(pjack_info->audio_jack_detect,
				   "3.5mm_detect");
		if (ret < 0)
			goto err_request_detect_gpio;

		ret = gpio_direction_input(pjack_info->audio_jack_detect);
		if (ret < 0)
			goto err_set_detect_gpio;

		pjack_info->irq_jack =
			gpio_to_irq(pjack_info->audio_jack_detect);
		if (pjack_info->irq_jack < 0) {
			ret = pjack_info->irq_jack;
			goto err_request_detect_irq;
		}

		ret = request_irq(pjack_info->irq_jack,
				  detect_irq_handler,
				  IRQF_TRIGGER_LOW, "35mm_headset", NULL);
		if (ret < 0)
			goto err_request_detect_irq;

		ret = set_irq_wake(pjack_info->irq_jack, 1);
		if (ret < 0)
			goto err_set_irq_wake;
		pr_info("DET IRQ Registered!");
	}


	if (pjack_info->mic_detect) {
		ret = gpio_request(pjack_info->mic_detect,
				   "mic_detect");
		if (ret < 0)
			goto err_request_detect_gpio;

		ret = gpio_direction_input(pjack_info->mic_detect);
		if (ret < 0)
			goto err_set_detect_gpio;

		pjack_info->irq_mic =
			gpio_to_irq(pjack_info->mic_detect);
		if (pjack_info->irq_mic < 0) {
			ret = pjack_info->irq_mic;
			goto err_request_detect_irq;
		}

		ret = request_irq(pjack_info->irq_mic,
				  mic_irq_handler, IRQF_DISABLED | IRQF_TRIGGER_LOW, "mic_headset", NULL);
		if (ret < 0)
			goto err_request_detect_irq;

		disable_irq(pjack_info->irq_mic);
		pr_info("MIC IRQ Registered!");
	}
	hs_gpio_register();

	SYS_MSG("--------------------");

	return 0;

err_set_irq_wake:
	if (pjack_info->audio_jack_detect)
		free_irq(pjack_info->irq_jack, 0);
err_request_detect_irq:
err_set_detect_gpio:
	if (pjack_info->audio_jack_detect)
		gpio_free(pjack_info->audio_jack_detect);
err_request_detect_gpio:
	printk(KERN_ERR "Audiojack: Failed in audiojack_probe\n");

	return ret;
}
示例#18
0
static int qpnp_haptic_probe(struct spmi_device *spmi)
{
	struct qpnp_hap *hap;
	struct resource *hap_resource;
	int rc, i;

	hap = devm_kzalloc(&spmi->dev, sizeof(*hap), GFP_KERNEL);
	if (!hap)
		return -ENOMEM;

	hap->spmi = spmi;

	hap_resource = spmi_get_resource(spmi, 0, IORESOURCE_MEM, 0);
	if (!hap_resource) {
		dev_err(&spmi->dev, "Unable to get haptic base address\n");
		return -EINVAL;
	}
	hap->base = hap_resource->start;

	dev_set_drvdata(&spmi->dev, hap);

	rc = qpnp_hap_parse_dt(hap);
	if (rc) {
		dev_err(&spmi->dev, "DT parsing failed\n");
		return rc;
	}

	rc = qpnp_hap_config(hap);
	if (rc) {
		dev_err(&spmi->dev, "hap config failed\n");
		return rc;
	}

	mutex_init(&hap->lock);
	mutex_init(&hap->wf_lock);
	INIT_WORK(&hap->work, qpnp_hap_worker);

	hrtimer_init(&hap->hap_timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
	hap->hap_timer.function = qpnp_hap_timer;

	hap->timed_dev.name = "vibrator";
	hap->timed_dev.get_time = qpnp_hap_get_time;
	hap->timed_dev.enable = qpnp_hap_td_enable;

	rc = timed_output_dev_register(&hap->timed_dev);
	if (rc < 0) {
		dev_err(&spmi->dev, "timed_output registration failed\n");
		goto timed_output_fail;
	}

	for (i = 0; i < ARRAY_SIZE(qpnp_hap_attrs); i++) {
		rc = sysfs_create_file(&hap->timed_dev.dev->kobj,
				&qpnp_hap_attrs[i].attr);
		if (rc < 0) {
			dev_err(&spmi->dev, "sysfs creation failed\n");
			goto sysfs_fail;
		}
	}

	return 0;

sysfs_fail:
	for (i--; i >= 0; i--)
		sysfs_remove_file(&hap->timed_dev.dev->kobj,
				&qpnp_hap_attrs[i].attr);
	timed_output_dev_unregister(&hap->timed_dev);
timed_output_fail:
	cancel_work_sync(&hap->work);
	hrtimer_cancel(&hap->hap_timer);
	mutex_destroy(&hap->lock);
	mutex_destroy(&hap->wf_lock);

	return rc;
}
示例#19
0
static int gs_probe(
	struct i2c_client *client, const struct i2c_device_id *id)
{	
   int ret;
   struct gs_data *gs;

    /* updated for regulator interface */
	struct regulator *vreg_gp4=NULL;
	int rc;

	vreg_gp4 = regulator_get(NULL, "gp4");
    /* set gp4 voltage as 2700mV for all */
    rc = regulator_set_voltage(vreg_gp4,VREG_GP4_VOLTAGE_VALUE_2700,VREG_GP4_VOLTAGE_VALUE_2700);
	if (rc) {
		printk("%s: vreg_gp4  vreg_set_level failed \n", __func__);
		return rc;
	}
	
	rc = regulator_enable(vreg_gp4);
	if (rc) {
		printk("%s: vreg_gp4    vreg_enable failed \n", __func__);
		return rc;
	}
	mdelay(5);
   	if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) {
		printk(KERN_ERR "gs_probe: need I2C_FUNC_I2C\n");
		ret = -ENODEV;
		goto err_check_functionality_failed;
	}
#ifndef GS_POLLING
	ret = gs_config_int1_pin();
	if(ret <0)
	{
		goto err_check_functionality_failed;
	}
	
	ret = gs_config_int2_pin();
	if(ret <0)
	{
		goto err_check_functionality_failed;
	}	
#endif
	gs = kzalloc(sizeof(*gs), GFP_KERNEL);
	if (gs == NULL) {		
		ret = -ENOMEM;
		goto err_alloc_data_failed;
	}
	
		mutex_init(&gs->mlock);
	
	INIT_WORK(&gs->work, gs_work_func);
	gs->client = client;
	i2c_set_clientdata(client, gs);
	
	
	 ret =reg_read(gs,GS_ADI_REG_DEVID);		
	if ( ret <0 )
		goto err_detect_failed;
	switch (ret) {
	case ID_ADXL345:
		break;
	default:
		printk(KERN_ERR, "Failed to probe \n" );
		goto err_detect_failed;
	}
	 
	 ret = reg_write(gs,GS_ADI_REG_POWER_CTL,0x14);   /* auto low power ,deep sleep */
	if ( ret <0 )
		goto err_detect_failed;
	ret =  reg_write(gs,GS_ADI_REG_BW,0x0a);    /* Rate: 100Hz, IDD: 130uA */
      if ( ret <0 )
		goto err_detect_failed;
	 ret = reg_write(gs,GS_ADI_REG_DATA_FORMAT,0x01);  /* Data Format: 8g right justified  	128=1g  8g*/
	 if ( ret <0 )
			 goto err_detect_failed;

	 ret = reg_write(gs,GS_ADI_REG_INT_ENABLE,0x80); /* enable  int Int En: Data Rdy*/

	 if ( ret <0 )
			 goto err_detect_failed;

	 ret = reg_write(gs,GS_ADI_REG_TAP_AXES,0x01);	/* Z Axis Tap */
	 if ( ret <0 )
		goto err_detect_failed;
       ret = reg_write(gs,GS_ADI_REG_THRESH_TAP,0x20);	/* Tap Threshold: 2G */
	   if ( ret <0 )
			   goto err_detect_failed;


	 ret = reg_write(gs,GS_ADI_REG_DUR,0x50);	/* Dur:50ms */
	 if ( ret <0 )
			 goto err_detect_failed;


	 ret = reg_write(gs,GS_ADI_REG_LATENT,0x20);	 /* Latent: 40ms */
	 if ( ret <0 )
			 goto err_detect_failed;


	 ret = reg_write(gs,GS_ADI_REG_WINDOW,0xF0);	 /* Window: 300ms */
	 if ( ret <0 )
			 goto err_detect_failed;
	 
	if (sensor_dev == NULL)
	{
		gs->input_dev = input_allocate_device();
		if (gs->input_dev == NULL) {
			ret = -ENOMEM;
			printk(KERN_ERR "gs_probe: Failed to allocate input device\n");
			goto err_input_dev_alloc_failed;
		}
		gs->input_dev->name = "sensors";
		sensor_dev = gs->input_dev;
	}else{
	
		gs->input_dev = sensor_dev;
	}
	gs->input_dev->id.vendor = GS_ADIX345;//for akm8973 compass detect.

	set_bit(EV_ABS,gs->input_dev->evbit);
	
	/* < DTS20111208XXXXX  liujinggang 20111208 begin */
	/* modify for ES-version*/
	input_set_abs_params(gs->input_dev, ABS_X, -11520, 11520, 0, 0);
	input_set_abs_params(gs->input_dev, ABS_Y, -11520, 11520, 0, 0);
	input_set_abs_params(gs->input_dev, ABS_Z, -11520, 11520, 0, 0);
	/* DTS20111208XXXXX  liujinggang 20111208 end > */
	
	set_bit(EV_SYN,gs->input_dev->evbit);


	gs->input_dev->id.bustype = BUS_I2C;
	//gs->input_dev->open = gs_adi_input_open;
	//gs->input_dev->close = gs_adi_input_close;
	
	input_set_drvdata(gs->input_dev, gs);
	ret = input_register_device(gs->input_dev);
	if (ret) {
		printk(KERN_ERR "gs_probe: Unable to register %s input device\n", gs->input_dev->name);
		goto err_input_register_device_failed;
	}
	
	ret = misc_register(&gsensor_device);
	if (ret) {

		printk(KERN_ERR "gs_probe: gsensor_device register failed\n");

		goto err_misc_device_register_failed;
	}

	
#ifndef   GS_POLLING 
	if (client->irq) {
		ret = request_irq(client->irq, gs_irq_handler, 0, client->name, gs);
		
		if (ret == 0)
			gs->use_irq = 1;
		else
			dev_err(&client->dev, "request_irq failed\n");
	}
#endif 



	if (!gs->use_irq) {
		hrtimer_init(&gs->timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
		gs->timer.function = gs_timer_func;
		
	}
#ifdef CONFIG_HAS_EARLYSUSPEND
	gs->early_suspend.level = EARLY_SUSPEND_LEVEL_BLANK_SCREEN + 1;
	gs->early_suspend.suspend = gs_early_suspend;
	gs->early_suspend.resume = gs_late_resume;
	register_early_suspend(&gs->early_suspend);
#endif
	
	gs_wq = create_singlethread_workqueue("gs_wq");
	if (!gs_wq)
		return -ENOMEM;
	
#if 0
	else
		GS_SENSOR_ADI_FLAG =1;
#endif
      this_gs_data =gs;

	printk(KERN_INFO "gs_probe: Start gs_adixl345  in %s mode\n", gs->use_irq ? "interrupt" : "polling");

	return 0;
	
err_misc_device_register_failed:
	
	misc_deregister(&gsensor_device);

err_input_register_device_failed:
	input_free_device(gs->input_dev);

err_input_dev_alloc_failed:


err_detect_failed:

	kfree(gs);
	
#ifndef   GS_POLLING 
	gs_free_int1();
	gs_free_int2();
#endif	
	
err_alloc_data_failed:
err_check_functionality_failed:
	if (vreg_gp4!=NULL)
	{
        /* updated for regulator interface */
		rc = regulator_disable(vreg_gp4);
		if (rc) {
			printk("%s: vreg_gp4    vreg_enable failed \n", __func__);
			return rc;
		}
	}
	return ret;
}
示例#20
0
static int common_timer_create(struct k_itimer *new_timer)
{
	hrtimer_init(&new_timer->it.real.timer, new_timer->it_clock, 0);
	return 0;
}
示例#21
0
static int dock_switch_probe(struct platform_device *pdev)
{
    struct gpio_switch_platform_data *pdata = pdev->dev.platform_data;

    int ret = -EBUSY;
    int err;

    if (!pdata)
        return -EBUSY;

    switch_data = kzalloc(sizeof(struct dock_switch_data), GFP_KERNEL);
    if (!switch_data)
        return -ENOMEM;

    switch_data->gpio = pdata->gpio;
    switch_data->hs_gpio = DOCK_HS_GPIO;
    switch_data->irq = gpio_to_irq(pdata->gpio);
    switch_data->hs_irq = gpio_to_irq(DOCK_HS_GPIO);
    switch_data->sdev.print_state = switch_print_state;
    switch_data->sdev.name = DRIVER_NAME;
    switch_data->sdev.print_name = switch_print_name;
    switch_data->sdev.print_state = switch_print_state;
    ret = switch_dev_register(&switch_data->sdev);
    if (ret < 0)
        goto err_register_switch;

    INIT_WORK(&switch_data->work, dock_switch_work);

    ret = request_irq(switch_data->irq, dock_interrupt,
                      IRQF_DISABLED | IRQF_TRIGGER_FALLING | IRQF_TRIGGER_RISING,
                      DRIVER_NAME, switch_data);
    if (ret) {
        pr_err("dock_switch request irq failed\n");
        goto err_request_irq;
    }

    input_dock = input_allocate_device();
    if (input_dock == NULL) {
        pr_err("dock input_allocate_device error!\n");
        ret = -ENOMEM;
        goto err_alloc_input_dev;
    }

    err = dock_register_input(input_dock);
    if (err < 0) {
        pr_err("dock register_input error\n");
        goto err_register_input_dev;
    }

    /* Dock Headset */
    INIT_WORK(&switch_data->hs_work, dock_hs_switch_work);
    switch_data->hs_debounce_time = ktime_set(0, 250000000);
    hrtimer_init(&switch_data->timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
    switch_data->timer.function = detect_event_timer_func;

    ret = request_irq(switch_data->hs_irq, dock_hs_interrupt,
                      IRQF_DISABLED | IRQF_TRIGGER_FALLING | IRQF_TRIGGER_RISING,
                      "dock_hs", switch_data);
    if (ret) {
        pr_err("dock_switch request hs_irq failed\n");
        goto err_request_hs_det_irq;
    }

    dock_kobj = kobject_create_and_add("dock", NULL);
    if (dock_kobj == NULL)
        pr_err("%s: subsystem_register failed\n", __FUNCTION__);
    err = sysfs_create_group(dock_kobj, &attr_group);
    if (err)
        pr_err("%s: sysfs_create_group failed, %d\n", __FUNCTION__, __LINE__);

    // set current status
    dock_switch_work(&switch_data->work);

    printk(KERN_INFO "Dock switch driver probe done!\n");
    return 0;

err_request_hs_det_irq:
    input_unregister_device(input_dock);
err_register_input_dev:
    input_free_device(input_dock);
err_alloc_input_dev:
    free_irq(switch_data->irq, switch_data);
err_request_irq:
    switch_dev_unregister(&switch_data->sdev);
err_register_switch:
    kfree(switch_data);
    return ret;
}
static int gt801_ts_probe(struct i2c_client *client, const struct i2c_device_id *id)
{
    struct gt801_ts_data *ts;
	struct gt801_platform_data	*pdata = client->dev.platform_data;
    int ret = 0;

    gt801printk("%s \n",__FUNCTION__);
	
    if (!pdata) {
		dev_err(&client->dev, "empty platform_data\n");
		goto err_check_functionality_failed;
    }
    if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) {
        printk(KERN_ERR "gt801_ts_probe: need I2C_FUNC_I2C\n");
        ret = -ENODEV;
        goto err_check_functionality_failed;
    }
	
    ts = kzalloc(sizeof(*ts), GFP_KERNEL);
    if (ts == NULL) {
        ret = -ENOMEM;
        goto err_alloc_data_failed;
    }
    INIT_WORK(&ts->work, gt801_ts_work_func);
    ts->client = client;
    i2c_set_clientdata(client, ts);

	ret = setup_resetPin(client,ts);
	if(ret)
	{
		 printk("%s:setup_resetPin fail\n",__FUNCTION__);
		 goto err_input_dev_alloc_failed;
	}
	
	ret=gt801_chip_Init(ts->client);
	if(ret<0)
	{
		printk("%s:chips init failed\n",__FUNCTION__);
		goto err_resetpin_failed;
	}
	
    /* allocate input device */
    ts->input_dev = input_allocate_device();
    if (ts->input_dev == NULL) {
        ret = -ENOMEM;
        printk(KERN_ERR "%s: Failed to allocate input device\n",__FUNCTION__);
        goto err_input_dev_alloc_failed;
    }
	
	ts->model = pdata->model ? : 801;
	ts->swap_xy = pdata->swap_xy;
	ts->x_min = pdata->x_min;
	ts->x_max = pdata->x_max;
	ts->y_min = pdata->y_min;
	ts->y_max = pdata->y_max;
	snprintf(ts->phys, sizeof(ts->phys), "%s/input0", dev_name(&client->dev));
	snprintf(ts->name, sizeof(ts->name), "gt%d-touchscreen", ts->model);
	ts->input_dev->phys = ts->phys;
	ts->input_dev->name = ts->name;
	ts->input_dev->dev.parent = &client->dev;

#if SINGLTOUCH_MODE
	ts->input_dev->evbit[0] = BIT_MASK(EV_ABS)|BIT_MASK(EV_KEY);
	ts->input_dev->keybit[BIT_WORD(BTN_TOUCH)] = BIT_MASK(BTN_TOUCH);
	input_set_abs_params(ts->input_dev,ABS_X,
		    ts->x_min ? : 0,
			ts->x_max ? : 480,
			0, 0);
	input_set_abs_params(ts->input_dev,ABS_Y,
			ts->y_min ? : 0,
			ts->y_max ? : 800,
			0, 0);

#else
    ts->input_dev->evbit[0] = BIT_MASK(EV_SYN) | BIT_MASK(EV_ABS);
  //  ts->input_dev->absbit[0] = 
	//	BIT(ABS_MT_POSITION_X) | BIT(ABS_MT_POSITION_Y) | 
	//	BIT(ABS_MT_TOUCH_MAJOR) | BIT(ABS_MT_WIDTH_MAJOR);  // for android
    input_set_abs_params(ts->input_dev, ABS_MT_POSITION_X, 
		    ts->x_min ? : 0,
			ts->x_max ? : 480,
			0, 0);
    input_set_abs_params(ts->input_dev, ABS_MT_POSITION_Y,
			ts->y_min ? : 0,
			ts->y_max ? : 800,
			0, 0);
    input_set_abs_params(ts->input_dev, ABS_MT_TOUCH_MAJOR, 0, 1, 0, 0); //Finger Size
    input_set_abs_params(ts->input_dev, ABS_MT_WIDTH_MAJOR, 0, 10, 0, 0); //Touch Size
#endif
    ret = input_register_device(ts->input_dev);
    if (ret) {
        printk(KERN_ERR "%s: Unable to register %s input device\n", __FUNCTION__,ts->input_dev->name);
        goto err_input_register_device_failed;
    }
	
	client->irq = gpio_to_irq(client->irq);
    if (client->irq) {
		ret = setup_pendown(client,ts);
		if(ret)
		{
			 printk("%s:setup_pendown fail\n",__FUNCTION__);
			 goto err_input_register_device_failed;
		}
		
        ret = request_irq(client->irq, gt801_ts_irq_handler, IRQF_DISABLED | IRQF_TRIGGER_LOW, client->name, ts);
        if (ret == 0) {
            gt801printk("%s:register ISR (irq=%d)\n", __FUNCTION__,client->irq);
            ts->use_irq = 1;
        }
        else 
			dev_err(&client->dev, "request_irq failed\n");
    }

    if (!ts->use_irq) {
        hrtimer_init(&ts->timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
        ts->timer.function = gt801_ts_timer_func;
        hrtimer_start(&ts->timer, ktime_set(1, 0), HRTIMER_MODE_REL);
    }
#ifdef CONFIG_HAS_EARLYSUSPEND
    ts->early_suspend.level = EARLY_SUSPEND_LEVEL_BLANK_SCREEN + 1;
    ts->early_suspend.suspend = gt801_ts_early_suspend;
    ts->early_suspend.resume = gt801_ts_late_resume;
    register_early_suspend(&ts->early_suspend);
#endif

    printk(KERN_INFO "%s: Start touchscreen %s in %s mode\n", __FUNCTION__,ts->input_dev->name, ts->use_irq ? "interrupt" : "polling");

    return 0;

err_input_register_device_failed:
    input_free_device(ts->input_dev);
err_resetpin_failed:
	gpio_free(ts->gpio_reset);
err_input_dev_alloc_failed:
	kfree(ts);
err_alloc_data_failed:
err_check_functionality_failed:
	
    return ret;
}
示例#23
0
void mdp_config_vsync(struct msm_fb_data_type *mfd)
{
	/* vsync on primary lcd only for now */
	if ((mfd->dest != DISPLAY_LCD) || (mfd->panel_info.pdest != DISPLAY_1)
	    || (!vsync_mode)) {
		goto err_handle;
	}

	vsync_clk_status = 0;
	if (mfd->panel_info.lcd.vsync_enable) {
		mfd->total_porch_lines = mfd->panel_info.lcd.v_back_porch +
		    mfd->panel_info.lcd.v_front_porch +
		    mfd->panel_info.lcd.v_pulse_width;
		mfd->total_lcd_lines =
		    mfd->panel_info.yres + mfd->total_porch_lines;
		mfd->lcd_ref_usec_time =
		    100000000 / mfd->panel_info.lcd.refx100;
		mfd->vsync_handler_pending = FALSE;

		mfd->last_vsync_timetick.tv64 = 0;

#ifdef MDP_HW_VSYNC
		if (mdp_vsync_clk == NULL)
			mdp_vsync_clk = clk_get(NULL, "mdp_vsync_clk");

		if (IS_ERR(mdp_vsync_clk)) {
			printk(KERN_ERR "error: can't get mdp_vsync_clk!\n");
			mfd->use_mdp_vsync = 0;
		} else
			mfd->use_mdp_vsync = 1;

		if (mfd->use_mdp_vsync) {
			uint32 vsync_cnt_cfg_dem;
			uint32 mdp_vsync_clk_speed_hz;

			mdp_vsync_clk_speed_hz = clk_get_rate(mdp_vsync_clk);

			if (mdp_vsync_clk_speed_hz == 0) {
				mfd->use_mdp_vsync = 0;
			} else {
				/*
				 * Do this calculation in 2 steps for
				 * rounding uint32 properly.
				 */
				vsync_cnt_cfg_dem =
				    (mfd->panel_info.lcd.refx100 *
				     mfd->total_lcd_lines) / 100;
				vsync_cnt_cfg =
				    (mdp_vsync_clk_speed_hz) /
				    vsync_cnt_cfg_dem;
				mdp_vsync_cfg_regs(mfd, TRUE);
			}
		}
#else
		mfd->use_mdp_vsync = 0;
		hrtimer_init(&mfd->dma_hrtimer, CLOCK_MONOTONIC,
			     HRTIMER_MODE_REL);
		mfd->dma_hrtimer.function = mdp_dma2_vsync_hrtimer_handler;
		mfd->vsync_width_boundary = vmalloc(mfd->panel_info.xres * 4);
#endif

#ifdef CONFIG_FB_MSM_MDDI
		mfd->channel_irq = 0;
		if (mfd->panel_info.lcd.hw_vsync_mode) {
			u32 vsync_gpio = mfd->vsync_gpio;
			u32 ret;

			if (vsync_gpio == -1) {
				MSM_FB_INFO("vsync_gpio not defined!\n");
				goto err_handle;
			}

			ret = gpio_tlmm_config(GPIO_CFG
					(vsync_gpio,
					(mfd->use_mdp_vsync) ? 1 : 0,
					GPIO_CFG_INPUT,
					GPIO_CFG_PULL_DOWN,
					GPIO_CFG_2MA),
					GPIO_CFG_ENABLE);
			if (ret)
				goto err_handle;

			/*
			 * if use_mdp_vsync, then no interrupt need since
			 * mdp_vsync is feed directly to mdp to reset the
			 * write pointer counter. therefore no irq_handler
			 * need to reset write pointer counter.
			 */
			if (!mfd->use_mdp_vsync) {
				mfd->channel_irq = MSM_GPIO_TO_INT(vsync_gpio);
				if (request_irq
				    (mfd->channel_irq,
				     &mdp_hw_vsync_handler_proxy,
				     IRQF_TRIGGER_FALLING, "VSYNC_GPIO",
				     (void *)mfd)) {
					MSM_FB_INFO
					("irq=%d failed! vsync_gpio=%d\n",
						mfd->channel_irq,
						vsync_gpio);
					goto err_handle;
				}
			}
		}
#endif
		mdp_hw_vsync_clk_enable(mfd);
		mdp_set_vsync((unsigned long)mfd);
	}

	return;

err_handle:
	if (mfd->vsync_width_boundary)
		vfree(mfd->vsync_width_boundary);
	mfd->panel_info.lcd.vsync_enable = FALSE;
	printk(KERN_ERR "%s: failed!\n", __func__);
}
示例#24
0
static int __devinit pm8xxx_vib_probe(struct platform_device *pdev)

{
	const struct pm8xxx_vibrator_pwm_platform_data *pdata =
						pdev->dev.platform_data;
	struct pm8xxx_vib_pwm *vib;
	int rc;
	VIB_PWM_INFO("%s+\n", __func__);

	if (!pdata)
		return -EINVAL;
	if (pdata->duty_us > pdata->PERIOD_US  ||
			 pdata->duty_us < 0)
		return -EINVAL;
	vib = kzalloc(sizeof(*vib), GFP_KERNEL);
	if (!vib)
		return -ENOMEM;
	vib->pdata	= pdata;
	vib->vdd_gpio	= pdata->vdd_gpio;
	vib->ena_gpio	= pdata->ena_gpio;
	vib->dev	= &pdev->dev;
	spin_lock_init(&vib->lock);
	INIT_WORK(&vib->work, pm8xxx_vib_update);
	hrtimer_init(&vib->vib_timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
	vib->vib_timer.function = pm8xxx_vib_timer_func;
	vib->timed_dev.name = "vibrator";
	vib->timed_dev.get_time = pm8xxx_vib_get_time;
	vib->timed_dev.enable = pm8xxx_vib_enable;
	vib->pwm_vib = pwm_request(vib->pdata->bank, vib->timed_dev.name);
	if (vib->pwm_vib < 0){
		rc = -ENOMEM;
		VIB_PWM_ERR("%s, pwm_request fail\n", __func__);
		goto err_pwm_request;
	}

	rc = gpio_request(vib->ena_gpio, "TI_AMP_ena");
	if (rc) {
		rc = -ENOMEM;
		VIB_PWM_ERR("%s, gpio_request ena fail\n", __func__);
		goto err_ena_gpio_request;
	}
	rc= gpio_request(vib->vdd_gpio, "TI_AMP_vdd");
	if(rc) {
		rc = -ENOMEM;
		VIB_PWM_ERR("%s, gpio_request vdd fail\n", __func__);
		goto err_vdd_gpio_request;
	}
	rc = timed_output_dev_register(&vib->timed_dev);
	if (rc < 0)
		goto err_read_vib;
	rc = device_create_file(vib->timed_dev.dev, &dev_attr_dutys);
	if (rc < 0) {
		VIB_PWM_ERR("%s, create duty sysfs fail: dutys\n", __func__);
	}
	rc = device_create_file(vib->timed_dev.dev, &dev_attr_function_switch);
	if (rc < 0) {
		VIB_PWM_ERR("%s, create duty sysfs fail: function_switch\n", __func__);
	}

	platform_set_drvdata(pdev, vib);
	duty_us= vib->pdata->duty_us;
	period_us=vib->pdata->PERIOD_US;
	VIB_PWM_INFO("%s-\n", __func__);
	return 0;
err_vdd_gpio_request:
	gpio_free(vib->vdd_gpio);
err_ena_gpio_request:
	gpio_free(vib->ena_gpio);
err_pwm_request:
	pwm_free(vib->pwm_vib);
err_read_vib:
	kfree(vib);
	return rc;
}
示例#25
0
文件: cdc_ncm.c 项目: MintuJ/linux
int cdc_ncm_bind_common(struct usbnet *dev, struct usb_interface *intf, u8 data_altsetting)
{
	const struct usb_cdc_union_desc *union_desc = NULL;
	struct cdc_ncm_ctx *ctx;
	struct usb_driver *driver;
	u8 *buf;
	int len;
	int temp;
	u8 iface_no;

	ctx = kzalloc(sizeof(*ctx), GFP_KERNEL);
	if (!ctx)
		return -ENOMEM;

	hrtimer_init(&ctx->tx_timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
	ctx->tx_timer.function = &cdc_ncm_tx_timer_cb;
	ctx->bh.data = (unsigned long)dev;
	ctx->bh.func = cdc_ncm_txpath_bh;
	atomic_set(&ctx->stop, 0);
	spin_lock_init(&ctx->mtx);

	/* store ctx pointer in device data field */
	dev->data[0] = (unsigned long)ctx;

	/* only the control interface can be successfully probed */
	ctx->control = intf;

	/* get some pointers */
	driver = driver_of(intf);
	buf = intf->cur_altsetting->extra;
	len = intf->cur_altsetting->extralen;

	/* parse through descriptors associated with control interface */
	while ((len > 0) && (buf[0] > 2) && (buf[0] <= len)) {

		if (buf[1] != USB_DT_CS_INTERFACE)
			goto advance;

		switch (buf[2]) {
		case USB_CDC_UNION_TYPE:
			if (buf[0] < sizeof(*union_desc))
				break;

			union_desc = (const struct usb_cdc_union_desc *)buf;
			/* the master must be the interface we are probing */
			if (intf->cur_altsetting->desc.bInterfaceNumber !=
			    union_desc->bMasterInterface0) {
				dev_dbg(&intf->dev, "bogus CDC Union\n");
				goto error;
			}
			ctx->data = usb_ifnum_to_if(dev->udev,
						    union_desc->bSlaveInterface0);
			break;

		case USB_CDC_ETHERNET_TYPE:
			if (buf[0] < sizeof(*(ctx->ether_desc)))
				break;

			ctx->ether_desc =
					(const struct usb_cdc_ether_desc *)buf;
			break;

		case USB_CDC_NCM_TYPE:
			if (buf[0] < sizeof(*(ctx->func_desc)))
				break;

			ctx->func_desc = (const struct usb_cdc_ncm_desc *)buf;
			break;

		case USB_CDC_MBIM_TYPE:
			if (buf[0] < sizeof(*(ctx->mbim_desc)))
				break;

			ctx->mbim_desc = (const struct usb_cdc_mbim_desc *)buf;
			break;

		default:
			break;
		}
advance:
		/* advance to next descriptor */
		temp = buf[0];
		buf += temp;
		len -= temp;
	}

	/* some buggy devices have an IAD but no CDC Union */
	if (!union_desc && intf->intf_assoc && intf->intf_assoc->bInterfaceCount == 2) {
		ctx->data = usb_ifnum_to_if(dev->udev, intf->cur_altsetting->desc.bInterfaceNumber + 1);
		dev_dbg(&intf->dev, "CDC Union missing - got slave from IAD\n");
	}

	/* check if we got everything */
	if (!ctx->data || (!ctx->mbim_desc && !ctx->ether_desc)) {
		dev_dbg(&intf->dev, "CDC descriptors missing\n");
		goto error;
	}

	/* claim data interface, if different from control */
	if (ctx->data != ctx->control) {
		temp = usb_driver_claim_interface(driver, ctx->data, dev);
		if (temp) {
			dev_dbg(&intf->dev, "failed to claim data intf\n");
			goto error;
		}
	}

	iface_no = ctx->data->cur_altsetting->desc.bInterfaceNumber;

	/* reset data interface */
	temp = usb_set_interface(dev->udev, iface_no, 0);
	if (temp) {
		dev_dbg(&intf->dev, "set interface failed\n");
		goto error2;
	}

	/* initialize data interface */
	if (cdc_ncm_setup(dev))
		goto error2;

	/* configure data interface */
	temp = usb_set_interface(dev->udev, iface_no, data_altsetting);
	if (temp) {
		dev_dbg(&intf->dev, "set interface failed\n");
		goto error2;
	}

	cdc_ncm_find_endpoints(dev, ctx->data);
	cdc_ncm_find_endpoints(dev, ctx->control);
	if (!dev->in || !dev->out || !dev->status) {
		dev_dbg(&intf->dev, "failed to collect endpoints\n");
		goto error2;
	}

	usb_set_intfdata(ctx->data, dev);
	usb_set_intfdata(ctx->control, dev);

	if (ctx->ether_desc) {
		temp = usbnet_get_ethernet_addr(dev, ctx->ether_desc->iMACAddress);
		if (temp) {
			dev_dbg(&intf->dev, "failed to get mac address\n");
			goto error2;
		}
		dev_info(&intf->dev, "MAC-Address: %pM\n", dev->net->dev_addr);
	}

	/* usbnet use these values for sizing tx/rx queues */
	dev->hard_mtu = ctx->tx_max;
	dev->rx_urb_size = ctx->rx_max;

	/* cdc_ncm_setup will override dwNtbOutMaxSize if it is
	 * outside the sane range. Adding a pad byte here if necessary
	 * simplifies the handling in cdc_ncm_fill_tx_frame, making
	 * tx_max always represent the real skb max size.
	 */
	if (ctx->tx_max != le32_to_cpu(ctx->ncm_parm.dwNtbOutMaxSize) &&
	    ctx->tx_max % usb_maxpacket(dev->udev, dev->out, 1) == 0)
		ctx->tx_max++;

	return 0;

error2:
	usb_set_intfdata(ctx->control, NULL);
	usb_set_intfdata(ctx->data, NULL);
	if (ctx->data != ctx->control)
		usb_driver_release_interface(driver, ctx->data);
error:
	cdc_ncm_free((struct cdc_ncm_ctx *)dev->data[0]);
	dev->data[0] = 0;
	dev_info(&intf->dev, "bind() failure\n");
	return -ENODEV;
}
static int msm_vibrator_probe(struct platform_device *pdev)
{
	struct msm_vib *vib;
	int rc = 0;

	pr_info("[VIB] %s\n",__func__);

	vib = devm_kzalloc(&pdev->dev, sizeof(*vib), GFP_KERNEL);
	if (!vib)	{
		pr_err("%s : Failed to allocate memory\n", __func__);
		return -ENOMEM;
	}

	vib->motor_en = of_get_named_gpio(pdev->dev.of_node, "samsung,motor-en", 0);
	if (!gpio_is_valid(vib->motor_en)) {
		pr_err("%s:%d, reset gpio not specified\n",
				__func__, __LINE__);
		return -EINVAL;
	}
	vib->pmic_gpio_enabled = of_property_read_bool(pdev->dev.of_node, "samsung,is_pmic_vib_en");

	#ifdef CONFIG_SEC_AFYON_PROJECT
		vib->pmic_gpio_enabled = 0;
	#endif

	printk(KERN_ALERT " VIB PMIC GPIO ENABLED Flag is %d \n", vib->pmic_gpio_enabled);
	if (!(vib->pmic_gpio_enabled)){

	#if defined (CONFIG_GPIO_PCAL6416A)
		#ifdef CONFIG_MACH_ATLANTICLTE_ATT
		if(system_rev == 0) {
			rc = gpio_tlmm_config(GPIO_CFG(vib->motor_en, 0, GPIO_CFG_OUTPUT,
				GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), GPIO_CFG_ENABLE);
                        if (rc < 0) {
                                pr_err("%s: gpio_tlmm_config is failed\n",__func__);
                                gpio_free(vib->motor_en);
                                return rc;
                        }
		}
		else {
			rc = expander_gpio_config(GPIO_CFG(vib->motor_en, 0, GPIO_CFG_OUTPUT,
				GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), GPIO_CFG_ENABLE);

			if (rc < 0) {
				pr_err("%s: expander_tlmm_config is failed\n",__func__);
				return rc;
			}
		}
		#else
		rc = expander_gpio_config(GPIO_CFG(vib->motor_en, 0, GPIO_CFG_OUTPUT,
					GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), GPIO_CFG_ENABLE);

		if (rc < 0) {
				pr_err("%s: expander_tlmm_config is failed\n",__func__);
				return rc;
		}
		#endif

	#else

	rc = gpio_tlmm_config(GPIO_CFG(vib->motor_en, 0, GPIO_CFG_OUTPUT,
		GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), GPIO_CFG_ENABLE);
	if (rc < 0) {
		pr_err("%s: gpio_tlmm_config is failed\n",__func__);
		gpio_free(vib->motor_en);
		return rc;
	}
	#endif
	}
	vib->timeout = VIB_DEFAULT_TIMEOUT;

	INIT_WORK(&vib->work, msm_vibrator_update);
	mutex_init(&vib->lock);

	vib->queue = create_singlethread_workqueue("msm_vibrator");
	if (!vib->queue) {
		pr_err("%s(): can't create workqueue\n", __func__);
		return -ENOMEM;
	}

	hrtimer_init(&vib->vib_timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
	vib->vib_timer.function = vibrator_timer_func;

	vib->timed_dev.name = "vibrator";
	vib->timed_dev.get_time = vibrator_get_time;
	vib->timed_dev.enable = vibrator_enable;

	dev_set_drvdata(&pdev->dev, vib);

	rc = timed_output_dev_register(&vib->timed_dev);
	if (rc < 0) {
		pr_err("[VIB] timed_output_dev_register fail (rc=%d)\n", rc);
		goto err_read_vib;
	}

	return 0;

err_read_vib:
	destroy_workqueue(vib->queue);
	return rc;
}
示例#27
0
static int kpd_pdrv_probe(struct platform_device *pdev)
{
	
	int i, r;
	int err = 0;
	
	kpd_ldvt_test_init();//API 2 for kpd LFVT test enviroment settings

	/* initialize and register input device (/dev/input/eventX) */
	kpd_input_dev = input_allocate_device();
	if (!kpd_input_dev)
		return -ENOMEM;

	kpd_input_dev->name = KPD_NAME;
	kpd_input_dev->id.bustype = BUS_HOST;
	kpd_input_dev->id.vendor = 0x2454;
	kpd_input_dev->id.product = 0x6500;
	kpd_input_dev->id.version = 0x0010;
	kpd_input_dev->open = kpd_open;

	//fulfill custom settings	
	kpd_memory_setting();
	
	__set_bit(EV_KEY, kpd_input_dev->evbit);

#if (KPD_PWRKEY_USE_EINT||KPD_PWRKEY_USE_PMIC)
	__set_bit(KPD_PWRKEY_MAP, kpd_input_dev->keybit);
	kpd_keymap[8] = 0;
#endif
	for (i = 17; i < KPD_NUM_KEYS; i += 9)	/* only [8] works for Power key */
		kpd_keymap[i] = 0;

	for (i = 0; i < KPD_NUM_KEYS; i++) {
		if (kpd_keymap[i] != 0)
			__set_bit(kpd_keymap[i], kpd_input_dev->keybit);
	}

#ifdef CONFIG_TOUCHSCREEN_SWEEP2WAKE
	sweep2wake_setdev(kpd_input_dev);
	printk("[SWEEP2WAKE]: power key capture done\n");
#endif

#if KPD_AUTOTEST
	for (i = 0; i < ARRAY_SIZE(kpd_auto_keymap); i++)
		__set_bit(kpd_auto_keymap[i], kpd_input_dev->keybit);
#endif

#if KPD_HAS_SLIDE_QWERTY
	__set_bit(EV_SW, kpd_input_dev->evbit);
	__set_bit(SW_LID, kpd_input_dev->swbit);
#endif

#ifdef KPD_PMIC_RSTKEY_MAP
	__set_bit(KPD_PMIC_RSTKEY_MAP, kpd_input_dev->keybit);
#endif

/* LENOVO.SW BEGIN.chenyb1,2012.9.4, add for new standard */
#ifdef LENOVO_STD_LINECTL_EARPHONE
    __set_bit(KEY_INFO, kpd_input_dev->keybit);
#endif //LENOVO_STD_LINECTL_EARPHONE
/* LENOVO.SW END.chenyb1,2012.9.4, add for new standard */

	kpd_input_dev->dev.parent = &pdev->dev;
	r = input_register_device(kpd_input_dev);
	if (r) {
		printk(KPD_SAY "register input device failed (%d)\n", r);
		input_free_device(kpd_input_dev);
		return r;
	}

	/* register device (/dev/mt6575-kpd) */
	kpd_dev.parent = &pdev->dev;
	r = misc_register(&kpd_dev);
	if (r) {
		printk(KPD_SAY "register device failed (%d)\n", r);
		input_unregister_device(kpd_input_dev);
		return r;
	}

	/* register IRQ and EINT */
	kpd_set_debounce(KPD_KEY_DEBOUNCE);
	r = request_irq(MT_KP_IRQ_ID, kpd_irq_handler, IRQF_TRIGGER_FALLING, KPD_NAME, NULL);
	if (r) {
		printk(KPD_SAY "register IRQ failed (%d)\n", r);
		misc_deregister(&kpd_dev);
		input_unregister_device(kpd_input_dev);
		return r;
	}

#if KPD_PWRKEY_USE_EINT
	mt_eint_register();
#endif

#ifndef KPD_EARLY_PORTING /*add for avoid early porting build err the macro is defined in custom file*/
	long_press_reboot_function_setting();///API 4 for kpd long press reboot function setting
#endif	
	hrtimer_init(&aee_timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
	aee_timer.function = aee_timer_func;

#if AEE_ENABLE_5_15
    hrtimer_init(&aee_timer_5s, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
    aee_timer_5s.function = aee_timer_5s_func;
#endif

	if((err = kpd_create_attr(&kpd_pdrv.driver)))
	{
		kpd_print("create attr file fail\n");
		kpd_delete_attr(&kpd_pdrv.driver);
		return err;
	}

	return 0;
}
示例#28
0
static int bcm_bt_lpm_init(struct platform_device *pdev)
{
	int irq;
	int ret;
	int rc;

	pr_debug( "%s TOP\n",__FUNCTION__);

#if 0	//att XXX already done in board config
	rc = gpio_request(BT_WAKE_GPIO, "bcm2076_wake_gpio");
	if (unlikely(rc)) {
		return rc;
	}
#endif 	//att XXX already done in board config

#if BT_HOST_WAKE_INT_ENABLED
	pr_debug( "%s about to get the BT_HOST_WAKE GPIO\n",__FUNCTION__);
	rc = gpio_request(BT_HOST_WAKE_GPIO, "bcm2076_host_wake_gpio");
	if (unlikely(rc)) {
	pr_debug( "%s failed to get the BT_HOST_WAKE GPIO\n",__FUNCTION__);
		gpio_free(BT_WAKE_GPIO);
		return rc;
	}
#endif //BT_HOST_WAKE_INT_ENABLED

	hrtimer_init(&bt_lpm.enter_lpm_timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
	bt_lpm.enter_lpm_delay = ktime_set(1, 0);  /* 1 sec */
	bt_lpm.enter_lpm_timer.function = enter_lpm;

	bt_lpm.host_wake = 0;

#if BT_HOST_WAKE_INT_ENABLED
	pr_debug( "%s about to connect BT_HOST_WAKE_GPIO irq/isr\n",__FUNCTION__);

	//TI stores this in the board-config
	pr_debug( "%s using bowser_bluetooth_irq_num set in board config\n",__FUNCTION__);
	irq = bowser_bluetooth_irq_num;

	pr_debug( "%s about to call request_irq(host_wake_isr)\n",__FUNCTION__);
	ret = request_irq(irq, host_wake_isr, IRQF_TRIGGER_HIGH,
			  "bt host_wake", NULL);
	if (ret) {
		pr_debug( "%s failed to connect BT_HOST_WAKE_GPIO irq\n",__FUNCTION__);
		gpio_free(BT_WAKE_GPIO);
		gpio_free(BT_HOST_WAKE_GPIO);
		return ret;
	}
	pr_debug( "%s enabled BT_HOST_WAKE isr\n",__FUNCTION__);

#if 0	//TI says this is not needed, set in board config
	pr_debug( "%s about to set BT_HOST_WAKE irq\n",__FUNCTION__);
	ret = irq_set_irq_wake(irq, 1);
	if (ret) {
		pr_debug( "%s failed to set BT_HOST_WAKE irq\n",__FUNCTION__);
		gpio_free(BT_WAKE_GPIO);
		gpio_free(BT_HOST_WAKE_GPIO);
		return ret;
	}
#endif	//TI says this is not needed, set in board config

//	pr_debug( "%s skipping setting the directions of BT_HOST WAKE\n",__FUNCTION__);
//	gpio_direction_input(BT_HOST_WAKE_GPIO);
#else	//att XXX disabling this until TI enables it
	pr_debug( "%s skipping enabling the BT_HOST_WAKE irq\n",__FUNCTION__);
#endif //BT_HOST_WAKE_INT_ENABLED

	snprintf(bt_lpm.wake_lock_name, sizeof(bt_lpm.wake_lock_name),
			"BTLowPower");
	wake_lock_init(&bt_lpm.wake_lock, WAKE_LOCK_SUSPEND,
			 bt_lpm.wake_lock_name);

	return 0;
}
示例#29
0
static int __devinit lge_isa1200_probe(struct i2c_client *client,
			const struct i2c_device_id *id)
{
	struct lge_isa1200_context *context;
	struct lge_isa1200_platform_data *pdata;
	int ret = 0;

	dev_info(&client->dev, "%s()\n", __func__);

	if (!i2c_check_functionality(client->adapter,
			I2C_FUNC_SMBUS_BYTE_DATA)) {
		dev_err(&client->dev, "%s: no support for i2c read/write"
				"byte data\n", __func__);
		return -EIO;
	}

	pdata = client->dev.platform_data;
	if (!pdata) {
		dev_err(&client->dev, "%s: no platform data\n", __func__);
		return -EINVAL;
	}

	context = kzalloc(sizeof(struct lge_isa1200_context), GFP_KERNEL);
	if (!context) {
		ret = -ENOMEM;
		goto fail_1;
	}

	context->client = client;
	context->pdata = pdata;

	i2c_set_clientdata(client, context);

	/* init basic things : mutex, work, timer */
/*
	mutex_init(&context->lock);
*/
	INIT_WORK(&context->work, lge_isa1200_vibrator_work_func);

	hrtimer_init(&context->timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
	context->timer.function = lge_isa1200_vibrator_timer_func;

	/* gpio initialization */
	if (lge_is_one_gpio_mode_or_not(context)) {

		dev_err(&client->dev, "%s: lge_is_one_gpio_mode_or_not gpio_hen=%d\n", __func__, pdata->gpio_hen);

		ret = gpio_request(pdata->gpio_hen, "gpio_hen");
		if (ret) {
			dev_err(&client->dev, "%s: gpio %d request failed\n",
					__func__, pdata->gpio_hen);
			goto fail_2;
		}
		gpio_direction_output(pdata->gpio_hen, 0);
	} else {
		dev_err(&client->dev, "%s: invalid gpio configure\n", __func__);
		ret = -EINVAL;
		goto fail_2;
	}


    atomic_set(&context->vibe_level, pdata->default_vib_strength);

	/* register timed output device */
	context->dev.name = pdata->vibrator_name;

	context->dev.enable = lge_isa1200_vibrator_enable;
	context->dev.get_time = lge_isa1200_vibrator_get_time;

	ret = timed_output_dev_register(&context->dev);
	if (ret < 0) goto fail_3;

#if !defined(CONFIG_MACH_LGE_325_BOARD_VZW) && !defined(CONFIG_MACH_LGE_325_BOARD_LGU)
    /* turn off vibrator (initialization) */
	lge_isa1200_hw_vib_on_off(context, false);
#endif


#ifdef CONFIG_PRE_INITIAL_CODE
	lge_isa1200_hw_init(context);
#endif

	ret = device_create_file(context->dev.dev, &dev_attr_amp);
	if (ret < 0) goto fail_4;

	context_for_debugfs = context;

#ifdef CONFIG_DEBUG_FS
        debugfs_timpani_dent = debugfs_create_dir("lgvib", 0);
        if (!IS_ERR(debugfs_timpani_dent)) {
          debugfs_poke = debugfs_create_file("poke",
          S_IFREG | S_IRUGO, debugfs_timpani_dent,
          (void *) "poke", &codec_debug_ops);

        }
#endif

	return 0;

fail_4:
	timed_output_dev_unregister(&context->dev);
fail_3:
	gpio_free(context->pdata->gpio_hen);
fail_2:
#if 0 /*                                        */
	mutex_destroy(&context->mutex);
#endif
	i2c_set_clientdata(client, NULL);
	kfree(context);
fail_1:
	return ret;
}
//******************************************************************************
//
// Function Name:  VoIP_StartTelephony()
//
// Description:	This function starts full duplex telephony session
//
// Notes:	The full duplex DSP interface is in sharedmem, not vsharedmem.
//		But since its function is closely related to voice processing,
//		we put it here.
//
//******************************************************************************
Boolean VoIP_StartTelephony(
VPUDumpFramesCB_t telephony_dump_cb,
VPUDumpFramesCB_t telephony_fill_cb,
UInt16	 voip_codec_type,  	// codec mode for encoding the next speech frame
Boolean	       dtx_mode,	// Turn DTX on (TRUE) or off (FALSE): this is obsolete. contained in voip_codec_type
Boolean	     amr_if2_enable	// Select AMR IF1 (FALSE) or IF2 (TRUE) format: obsolete
)
{
#ifdef USE_HR_TIMER
    unsigned long delay_in_ms = 20L;

    intr_workqueue = create_workqueue("vt-gpt");
    if (!intr_workqueue)
    {
        return TRUE;
    }

    INIT_WORK(&intr_work, VoIP_Task_Entry);

    ktime = ktime_set( 0, (delay_in_ms*1000000) );

    hrtimer_init( &hr_timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL );

    hr_timer.function = &hrtimer_callback;

    hrtimer_start( &hr_timer, ktime, HRTIMER_MODE_REL );

#else
    struct gpt_cfg gptimer_config;

/* [email protected] 2011.12.02 start */
/* add patch CSP 476896 for audio loop */
/* review by liubing */
#ifdef USE_WORK_QUEUE_FOR_DL	
    intr_workqueue = create_workqueue("vt-gpt");
    if (!intr_workqueue)
    {
        return TRUE;
    }

    INIT_WORK(&intr_work, VoIP_Task_Entry);
#else
    tasklet_init(&(voip_task), VoIP_Task_Entry, NULL);
#endif	
/* [email protected] 2011.12.02 end */

    if ( gpt_request(VT_USE_GPT_INDEX) != VT_USE_GPT_INDEX )
        return TRUE;

    /* Disable Pedestral mode */
    gptimer_config.gctrl = SW_PEDEMODE;
    /* Set the clock to 1 Mhz */
    gptimer_config.gclk = 1024*1024;
    /* Configure the timer mode oneshot/periodic */
    gptimer_config.gmode = GPT_MODE_PERIODIC;

    /* Configure the timer for the above configration */
    if ( gpt_config(VT_USE_GPT_INDEX, &gptimer_config, gptimer_callback, NULL) != GPT_SUCCESS )
    {
        gpt_free(VT_USE_GPT_INDEX);
        return TRUE;
    }

    /* The timer starts here */
    if ( gpt_start(VT_USE_GPT_INDEX, 1000*20) != GPT_SUCCESS )
    {
        gpt_free(VT_USE_GPT_INDEX);
        return TRUE;
    }
#endif
    Telephony_DumpVPFramesCB=telephony_dump_cb;
    Telephony_FillVPFramesCB=telephony_fill_cb;

    return FALSE;
}