void pn544_factory_standby_set(void)
{
    int ret;
    struct pn544_dev *pn544_dev;
    struct pn544_i2c_platform_data *platform_data;
    uint8_t EEDATA_WRITE[9] = {0x08, 0x00, 0x06, 0x00, 0x9E, 0xAA, 0x00, 0x01, 0x01};

    platform_data = pn544_client->dev.platform_data;

    pn544_dev = i2c_get_clientdata(pn544_client);
    // 1. Go To Dnld mode 2

    gpio_set_value(pn544_dev->ven_gpio, 1);
    gpio_set_value(pn544_dev->firm_gpio, 1);
    msleep(10);
    gpio_set_value(pn544_dev->ven_gpio, 0);
    msleep(10);
    gpio_set_value(pn544_dev->ven_gpio, 1);
    msleep(10);

    // 2. I2c write
    dprintk("%s Go To I2c write\n", __func__);
    ret = 0;
    ret = i2c_master_send(pn544_client, EEDATA_WRITE, 9);
    if (ret != 9) {
         dprintk(PN544_DRV_NAME ":%s : i2c_master_send returned %d\n", __func__, ret);
    }
    msleep(10);

    // 3. HW reset 1,0,1
    dprintk("%s Go To PN544 reset\n", __func__);

    //--> # reset 1
    gpio_set_value(pn544_dev->firm_gpio, 0);
    gpio_set_value(pn544_dev->ven_gpio, 1);
    msleep(10);

    //--> # reset 0
    gpio_set_value(pn544_dev->firm_gpio, 0);
    gpio_set_value(pn544_dev->ven_gpio, 0);
    msleep(10);

    //--> # reset 1
    gpio_set_value(pn544_dev->firm_gpio, 0);
    gpio_set_value(pn544_dev->ven_gpio, 1);
    msleep(10);


    // 4. power off
    dprintk(PN544_DRV_NAME ":%s power off\n", __func__);
    gpio_set_value(pn544_dev->firm_gpio, 0);
    gpio_set_value(pn544_dev->ven_gpio, 0);
    msleep(10);
}
Пример #2
0
static void wimax_deinit_gpios(void)
{
	s3c_gpio_cfgpin(GPIO_WIMAX_DBGEN_28V, S3C_GPIO_OUTPUT);
	s3c_gpio_setpull(GPIO_WIMAX_DBGEN_28V, S3C_GPIO_PULL_NONE);
	gpio_set_value(GPIO_WIMAX_DBGEN_28V, GPIO_LEVEL_LOW);
	s3c_gpio_cfgpin(GPIO_WIMAX_I2C_CON, S3C_GPIO_OUTPUT);
	s3c_gpio_setpull(GPIO_WIMAX_I2C_CON, S3C_GPIO_PULL_NONE);
	gpio_set_value(GPIO_WIMAX_I2C_CON, GPIO_LEVEL_HIGH);

	s3c_gpio_cfgpin(GPIO_WIMAX_WAKEUP, S3C_GPIO_OUTPUT);
	s3c_gpio_setpull(GPIO_WIMAX_WAKEUP, S3C_GPIO_PULL_NONE);
	gpio_set_value(GPIO_WIMAX_WAKEUP, GPIO_LEVEL_LOW);
	s3c_gpio_cfgpin(GPIO_WIMAX_IF_MODE0, S3C_GPIO_OUTPUT);
	s3c_gpio_setpull(GPIO_WIMAX_IF_MODE0, S3C_GPIO_PULL_NONE);
	gpio_set_value(GPIO_WIMAX_IF_MODE0, GPIO_LEVEL_LOW);
	s3c_gpio_cfgpin(GPIO_WIMAX_CON0, S3C_GPIO_OUTPUT);
	s3c_gpio_setpull(GPIO_WIMAX_CON0, S3C_GPIO_PULL_NONE);
	gpio_set_value(GPIO_WIMAX_CON0, GPIO_LEVEL_LOW);
	s3c_gpio_cfgpin(GPIO_WIMAX_IF_MODE1, S3C_GPIO_OUTPUT);
	s3c_gpio_setpull(GPIO_WIMAX_IF_MODE1, S3C_GPIO_PULL_NONE);
	gpio_set_value(GPIO_WIMAX_IF_MODE1, GPIO_LEVEL_LOW);
	s3c_gpio_cfgpin(GPIO_WIMAX_CON2, S3C_GPIO_OUTPUT);
	s3c_gpio_setpull(GPIO_WIMAX_CON2, S3C_GPIO_PULL_NONE);
	gpio_set_value(GPIO_WIMAX_CON2, GPIO_LEVEL_LOW);
	s3c_gpio_cfgpin(GPIO_WIMAX_CON1, S3C_GPIO_OUTPUT);
	s3c_gpio_setpull(GPIO_WIMAX_CON1, S3C_GPIO_PULL_NONE);
	gpio_set_value(GPIO_WIMAX_CON1, GPIO_LEVEL_LOW);
	s3c_gpio_cfgpin(GPIO_WIMAX_RESET_N, S3C_GPIO_OUTPUT);
	s3c_gpio_setpull(GPIO_WIMAX_RESET_N, S3C_GPIO_PULL_NONE);
	gpio_set_value(GPIO_WIMAX_RESET_N, GPIO_LEVEL_LOW);
	s3c_gpio_cfgpin(GPIO_WIMAX_EN, S3C_GPIO_OUTPUT);
	s3c_gpio_setpull(GPIO_WIMAX_EN, S3C_GPIO_PULL_NONE);
	gpio_set_value(GPIO_WIMAX_EN, GPIO_LEVEL_LOW);
	s3c_gpio_cfgpin(GPIO_WIMAX_USB_EN, S3C_GPIO_OUTPUT);
	s3c_gpio_setpull(GPIO_WIMAX_USB_EN, S3C_GPIO_PULL_NONE);
	gpio_set_value(GPIO_WIMAX_USB_EN, GPIO_LEVEL_LOW);
#if defined(CONFIG_MACH_C1_REV02)
	s3c_gpio_cfgpin(USB_SEL, S3C_GPIO_OUTPUT);
	s3c_gpio_setpull(USB_SEL, S3C_GPIO_PULL_NONE);
#endif				/* CONFIG_MACH_C1_REV02 */
	s3c_gpio_cfgpin(GPIO_UART_SEL1, S3C_GPIO_OUTPUT);
	s3c_gpio_setpull(GPIO_UART_SEL1, S3C_GPIO_PULL_NONE);
	s3c_gpio_cfgpin(GPIO_UART_SEL, S3C_GPIO_OUTPUT);
	s3c_gpio_setpull(GPIO_UART_SEL, S3C_GPIO_PULL_NONE);

	s3c_gpio_cfgpin(GPIO_CMC_SCL_18V, S3C_GPIO_OUTPUT);
	s3c_gpio_setpull(GPIO_CMC_SCL_18V, S3C_GPIO_PULL_NONE);
	gpio_set_value(GPIO_CMC_SCL_18V, GPIO_LEVEL_LOW);

	s3c_gpio_cfgpin(GPIO_CMC_SDA_18V, S3C_GPIO_OUTPUT);
	s3c_gpio_setpull(GPIO_CMC_SDA_18V, S3C_GPIO_PULL_NONE);
	gpio_set_value(GPIO_CMC_SDA_18V, GPIO_LEVEL_LOW);

	s3c_gpio_cfgpin(GPIO_WIMAX_INT, S3C_GPIO_OUTPUT);
	s3c_gpio_setpull(GPIO_WIMAX_INT, S3C_GPIO_PULL_NONE);
	gpio_set_value(GPIO_WIMAX_INT, GPIO_LEVEL_LOW);

	switch_usb_ap();
}
Пример #3
0
static void switch_uart_ap(void)
{
	gpio_set_value(GPIO_UART_SEL, GPIO_LEVEL_HIGH);
}
static enum hrtimer_restart bt_enter_lpm(struct hrtimer *timer)
{
	gpio_set_value(GPIO_BT_WAKE, 0);

	return HRTIMER_NORESTART;
}
static int bcmi2cnfc_probe(struct i2c_client *client,
                           const struct i2c_device_id *id)
{
    int ret;
    struct bcmi2cnfc_i2c_platform_data *platform_data;
    struct bcmi2cnfc_dev *bcmi2cnfc_dev;

    platform_data = client->dev.platform_data;

    dev_info(&client->dev,
             "%s, probing bcmi2cnfc driver\n", __func__);
    if (platform_data == NULL) {
        dev_err(&client->dev,
                "nfc probe fail\n");
        return  -ENODEV;
    }

    if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) {
        dev_err(&client->dev,
                "need I2C_FUNC_I2C\n");
        return  -ENODEV;
    }

    ret = gpio_request(platform_data->irq_gpio, "nfc_int");
    if (ret)
        return  -ENODEV;
    ret = gpio_request(platform_data->en_gpio, "nfc_ven");
    if (ret)
        goto err_en;
    ret = gpio_request(platform_data->wake_gpio, "nfc_firm");
    if (ret)
        goto err_firm;

    gpio_set_value(platform_data->en_gpio, 0);
    gpio_set_value(platform_data->wake_gpio, 0);

    bcmi2cnfc_dev = kzalloc(sizeof(*bcmi2cnfc_dev), GFP_KERNEL);
    if (bcmi2cnfc_dev == NULL) {
        dev_err(&client->dev,
                "failed to allocate memory for module data\n");
        ret = -ENOMEM;
        goto err_exit;
    }

    bcmi2cnfc_dev->wake_gpio = platform_data->wake_gpio;
    bcmi2cnfc_dev->irq_gpio = platform_data->irq_gpio;
    bcmi2cnfc_dev->en_gpio = platform_data->en_gpio;
    bcmi2cnfc_dev->client   = client;
#if ACAR_PLATFORM
    platform_data->init();
#endif
    /* init mutex and queues */
    init_waitqueue_head(&bcmi2cnfc_dev->read_wq);
    mutex_init(&bcmi2cnfc_dev->read_mutex);
    spin_lock_init(&bcmi2cnfc_dev->irq_enabled_lock);

    bcmi2cnfc_dev->bcmi2cnfc_device.minor = MISC_DYNAMIC_MINOR;
    bcmi2cnfc_dev->bcmi2cnfc_device.name = "bcmi2cnfc";
    bcmi2cnfc_dev->bcmi2cnfc_device.fops = &bcmi2cnfc_dev_fops;

    ret = misc_register(&bcmi2cnfc_dev->bcmi2cnfc_device);
    if (ret) {
        dev_err(&client->dev,
                "misc_register failed\n");
        goto err_misc_register;
    }

    /* request irq.  the irq is set whenever the chip has data available
     * for reading.  it is cleared when all data has been read.
     */
    dev_info(&client->dev,
             "requesting IRQ %d\n", client->irq);
    bcmi2cnfc_dev->irq_enabled = true;
    ret = request_irq(client->irq, bcmi2cnfc_dev_irq_handler,
                      INTERRUPT_TRIGGER_TYPE, client->name, bcmi2cnfc_dev);
    if (ret) {
        dev_err(&client->dev, "request_irq failed\n");
        goto err_request_irq_failed;
    }
    i2c_set_clientdata(client, bcmi2cnfc_dev);
#if ACAR_PLATFORM || MSM_PLATFORM
    nfc_client = client;
#endif
    bcmi2cnfc_dev->packet_size = 0;
    dev_info(&client->dev,
             "%s, probing bcmi2cnfc driver exited successfully\n", __func__);
    return 0;

err_request_irq_failed:
    misc_deregister(&bcmi2cnfc_dev->bcmi2cnfc_device);
err_misc_register:
    mutex_destroy(&bcmi2cnfc_dev->read_mutex);
    kfree(bcmi2cnfc_dev);
err_exit:
    gpio_free(platform_data->wake_gpio);
err_firm:
    gpio_free(platform_data->en_gpio);
err_en:
    gpio_free(platform_data->irq_gpio);
    return ret;
}
static void incrediblec_reset(void)
{
       gpio_set_value(INCREDIBLEC_GPIO_PS_HOLD, 0);
}
static void set_h2w_clk(int n)
{
	gpio_set_value(INCREDIBLEC_GPIO_H2W_CLK, n);
}
Пример #8
0
static int h2_transceiver_mode(struct device *dev, int state)
{
	/* SIR when low, else MIR/FIR when HIGH */
	gpio_set_value(H2_IRDA_FIRSEL_GPIO_PIN, !(state & IR_SIRMODE));
	return 0;
}
Пример #9
0
static int bcm2079x_probe(struct i2c_client *client,
			   const struct i2c_device_id *id)
{
	int ret;
	struct bcm43341_platform_data *platform_data;		//                           
	struct bcm2079x_dev *bcm2079x_dev;

	platform_data = client->dev.platform_data;

	dev_info(&client->dev, "%s, probing bcm2079x driver flags = %x\n", __func__, client->flags);
	if (platform_data == NULL) {
		dev_err(&client->dev, "nfc probe fail\n");
		return -ENODEV;
	}

	if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) {
		dev_err(&client->dev, "need I2C_FUNC_I2C\n");
		return -ENODEV;
	}

	ret = gpio_request_one(platform_data->irq_gpio, GPIOF_IN, "nfc_int");
	if (ret)
		return -ENODEV;
	ret = gpio_request_one(platform_data->en_gpio, GPIOF_OUT_INIT_LOW, "nfc_ven");
	if (ret)
		goto err_en;
	ret = gpio_request_one(platform_data->wake_gpio, GPIOF_OUT_INIT_LOW,"nfc_firm");
	if (ret)
		goto err_firm;
/*
	dev_err(&client->dev,
			 "%s, IRQ_GPIO %x:\n", __func__, platform_data->irq_gpio);
	dev_err(&client->dev,
			 "%s, VEN_GPIO %x:\n", __func__, platform_data->en_gpio);
	dev_err(&client->dev,
			 "%s, WAKE_GPIO %x:\n", __func__, platform_data->wake_gpio);
*/   //hyunho.koh

	gpio_set_value(platform_data->en_gpio, 0);
	gpio_set_value(platform_data->wake_gpio, 0);

	bcm2079x_dev = kzalloc(sizeof(*bcm2079x_dev), GFP_KERNEL);
	if (bcm2079x_dev == NULL) {
		dev_err(&client->dev,
			"failed to allocate memory for module data\n");
		ret = -ENOMEM;
		goto err_exit;
	}

	bcm2079x_dev->wake_gpio = platform_data->wake_gpio;
	bcm2079x_dev->irq_gpio = platform_data->irq_gpio;
	bcm2079x_dev->en_gpio = platform_data->en_gpio;
	bcm2079x_dev->client = client;

	/* init mutex and queues */
	init_waitqueue_head(&bcm2079x_dev->read_wq);
	mutex_init(&bcm2079x_dev->read_mutex);
	spin_lock_init(&bcm2079x_dev->irq_enabled_lock);

	bcm2079x_dev->bcm2079x_device.minor = MISC_DYNAMIC_MINOR;
	bcm2079x_dev->bcm2079x_device.name = "bcm2079x-i2c";
	bcm2079x_dev->bcm2079x_device.fops = &bcm2079x_dev_fops;

	ret = misc_register(&bcm2079x_dev->bcm2079x_device);
	if (ret) {
		dev_err(&client->dev, "misc_register failed\n");
		goto err_misc_register;
	}

	wake_lock_init(&nfc_wake_lock, WAKE_LOCK_SUSPEND, "NFCWAKE");

	/* request irq.  the irq is set whenever the chip has data available
	 * for reading.  it is cleared when all data has been read.
	 */
	dev_info(&client->dev, "requesting IRQ %d\n", client->irq);
	bcm2079x_dev->irq_enabled = true;
	ret = request_irq(client->irq, bcm2079x_dev_irq_handler,
			  IRQF_TRIGGER_RISING, client->name, bcm2079x_dev);
	if (ret) {
		dev_err(&client->dev, "request_irq failed\n");
		goto err_request_irq_failed;
	}
	
	bcm2079x_dev->irq_wake_enabled = false;	//hyunho.koh
	 
	bcm2079x_disable_irq(bcm2079x_dev);
	i2c_set_clientdata(client, bcm2079x_dev);
	dev_info(&client->dev,
		 "%s, probing bcm2079x driver exited successfully\n",
		 __func__);
	return 0;

err_request_irq_failed:
	misc_deregister(&bcm2079x_dev->bcm2079x_device);
err_misc_register:
	mutex_destroy(&bcm2079x_dev->read_mutex);
	kfree(bcm2079x_dev);
err_exit:
	gpio_free(platform_data->wake_gpio);
err_firm:
	gpio_free(platform_data->en_gpio);
err_en:
	gpio_free(platform_data->irq_gpio);
	return ret;
}
void one_wire_lv_en(int enable)
{
    gpio_set_value(hi->pdata.tx_level_shift_en, 0);
}
void one_wire_uart_sw(int enable)
{
    gpio_set_value(hi->pdata.uart_sw, enable);
}
void one_wire_gpio_tx(int enable)
{
    HS_LOG("Set gpio[%d] = %d", hi->pdata.uart_tx, enable);
    gpio_set_value(hi->pdata.uart_tx, enable);
}
Пример #13
0
/* Wiggle the TCK like, moving JTAG one step further along its state machine */
static int jtag_tick(struct jtag_state *state) {
	gpio_set_value(state->tck, 0);
	gpio_set_value(state->tck, 1);
	gpio_set_value(state->tck, 0);
	return 0;
}
Пример #14
0
static int gp2a_opt_probe(struct i2c_client *client,
			 const struct i2c_device_id *id)
{
	int err = 0;
	int i;
#if USE_INTERRUPT
	int irq;
#endif
	int config;
    int ret;
	int a;

	struct gp2a_data *gp2a;
#ifdef STM_DEBUG
	printk(KERN_INFO "%s\n",__FUNCTION__);
#endif


#if defined(CONFIG_MACH_VASTO)
	vreg_proximity = vreg_get(NULL, "vcama");
	ret = vreg_set_level(vreg_proximity, 3000); // 2800 -> 3000 H/W requeset
	if (ret) {
		printk(KERN_ERR "%s: vreg set level failed (%d)\n", __func__, ret);
		return -EIO;
	}

	ret = vreg_enable(vreg_proximity);
	if (ret) {
		printk(KERN_ERR "%s: vreg enable failed (%d)\n", __func__, ret);
		return -EIO;
	}
#else  
	if( board_hw_revision < 3 )
	{
		vreg_proximity = vreg_get(0, "vcama");
		if (IS_ERR(vreg_proximity))
		{	
			printk("===== [PROXIMITY] proximity IS_ERR TEST =====\n");
			return PTR_ERR(vreg_proximity);
		}
	
	vreg_set_level(vreg_proximity, 12); // set to 3.0V voltage 
		vreg_enable(vreg_proximity); // voltage 
	}
	else
	{
		gpio_set_value(VIR_LED_EN, 1);
	}
#endif
	if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C))
	{
		printk(KERN_INFO "[GP2A] i2c_check_functionality error\n");
		err = -ENODEV;
		goto exit;
	}
	if ( !i2c_check_functionality(client->adapter,I2C_FUNC_SMBUS_BYTE_DATA) ) {
		printk(KERN_INFO "[GP2A] byte op is not permited.\n");
		goto exit;
	}

	/* OK. For now, we presume we have a valid client. We now create the
	client structure, even though we cannot fill it completely yet. */
	if (!(gp2a = kzalloc(sizeof(struct gp2a_data), GFP_KERNEL)))
	{
		err = -ENOMEM;
		goto exit;
	}
	memset(gp2a, 0, sizeof(struct gp2a_data));
	gp2a->client = client;
	i2c_set_clientdata(client, gp2a);

	opt_i2c_client = client;

	if (i2c_smbus_read_byte(client) < 0)
	{
		printk(KERN_ERR "[GP2A] i2c_smbus_read_byte error!!\n");
		goto exit_kfree;
	}
	else
	{
		printk("GP2A Device detected!\n");
	}

	printk("[%s] slave addr = %x\n", __func__, client->addr);
	
	/* Input device Settings */
	if(USE_INPUT_DEVICE)
	{
		gp2a->input_dev = input_allocate_device();
		if (gp2a->input_dev == NULL) 
		{
			pr_err("Failed to allocate input device\n");
			return -ENOMEM;
		}
		gp2a->input_dev->name = "proximity";
	
		set_bit(EV_SYN,gp2a->input_dev->evbit);
		set_bit(EV_ABS,gp2a->input_dev->evbit);
		
 	       input_set_abs_params(gp2a->input_dev, ABS_DISTANCE, 0, 1, 0, 0);
		
	
		err = input_register_device(gp2a->input_dev);
		if (err) 
		{
			pr_err("Unable to register %s input device\n", gp2a->input_dev->name);
			input_free_device(gp2a->input_dev);
			kfree(gp2a);
			return -1;
		}

	}

#if USE_INTERRUPT
	/* WORK QUEUE Settings */
	gp2a_wq = create_singlethread_workqueue("gp2a_wq");
	if (!gp2a_wq)
		return -ENOMEM;
	INIT_WORK(&gp2a->work_prox, gp2a_work_func_prox);
	gprintk("Workqueue Settings complete\n");
#endif

	/* misc device Settings */
	err = misc_register(&proximity_device);
	if(err) {
		pr_err(KERN_ERR "misc_register failed - prox \n");
	}

	/* wake lock init */
	wake_lock_init(&prx_wake_lock, WAKE_LOCK_SUSPEND, "prx_wake_lock");

	/* set sysfs for light sensor */
	proxsensor_class = class_create(THIS_MODULE, "proxsensor");
	if (IS_ERR(proxsensor_class))
		pr_err("Failed to create class(proxsensor)!\n");

	switch_cmd_dev = device_create(proxsensor_class, NULL, 0, NULL, "switch_cmd");	
	if (device_create_file(switch_cmd_dev, &dev_attr_proxsensor_file_state) < 0)
		pr_err("Failed to create device file(%s)!\n", dev_attr_proxsensor_file_state.attr.name);
	
	dev_set_drvdata(switch_cmd_dev,gp2a);
	
	/* ktime init */

	timeA = ktime_set(0,0);
	timeB = ktime_set(0,0);
	
	/* gpio config */ // set in board file
	config = GPIO_CFG(GPIO_SENSE_OUT, 0, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA);
	err = gpio_tlmm_config(config, GPIO_CFG_ENABLE);
	if (err) 
		printk(KERN_ERR "%s: gpio_tlmm_config(%#x)=%d\n", __func__, GPIO_SENSE_OUT, err);

//for(a = 0; a < 10 ; a++)
//{
	/* GP2A Regs INIT SETTINGS */
	for(i=1;i<5;i++)
	{
		opt_i2c_write((u8)(i),&gp2a_original_image[i]);
		mdelay(5);
		mdelay(5);
	//	printk("%d",i);
	}
//}
	mdelay(2);
#if USE_INTERRUPT
	/* INT Settings */	
	irq = gpio_to_irq(GPIO_SENSE_OUT);
	gp2a->irq = -1;
	set_irq_type(irq, IRQ_TYPE_EDGE_BOTH);

	err = request_irq(irq, gp2a_irq_handler, IRQF_DISABLED, "gp2a_int", gp2a);
	if (err)
	{
		printk("[GP2A] request_irq failed for gp2a\n");
		goto exit_kfree;
	}

	printk("[GP2A] register irq = %d\n",irq);
	err = set_irq_wake(irq, 1);
	printk("[GP2A] register wakeup source = %d\n",err);
	if (err) 
		printk("[GP2A] register wakeup source failed\n");
	
	gp2a->irq = irq;
	gprintk("INT Settings complete\n");
#endif
	
	// maintain power-down mode before using sensor
	gp2a_off(gp2a,ALL);
	
//++	// test for sensor 

/*
	printk("[GP2A] curr prox value = %d\n", gpio_get_value(GPIO_SENSE_OUT));
	gp2a_on(gp2a,PROXIMITY);
	printk("[GP2A] curr prox value = %d\n", gpio_get_value(GPIO_SENSE_OUT));
	
//--

	// maintain power-down mode before using sensor
	//ESD test sleep
	gp2a_off(gp2a,ALL);
*/

	printk("gp2a_opt_probe is OK!!\n");
	return 0;
	
exit_kfree:
	kfree(gp2a);
exit:
	return err;
}
Пример #15
0
static int cypress_touchkey_probe(struct i2c_client *client,
		const struct i2c_device_id *id)
{
	struct device *dev = &client->dev;
	struct input_dev *input_dev;

	u8 data[6];
	int err;
	int cnt;
	int touch_auto_calibration_on_off = 0;
#if defined(TOUCH_UPDATE)
	int ret;
	int retry = 10;
#endif
	printk(" cypress_touchkey_probe\n");

	gpio_set_value(TOUCHKEY_VDD_EN, 1);
	msleep(5);

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

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

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

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

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

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

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

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

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

	devdata->is_powering_on = true;

	devdata->pdata->touchkey_onoff(TOUCHKEY_ON);
	msleep(50);

	err = i2c_master_recv(client, data, sizeof(data));
	if (err < (int)sizeof(data)) {
		printk(KERN_DEBUG"[Touchkey] i2c master recv error %d\n", err);
		if (err >= 0)
			err = -EIO;
		dev_err(dev, "%s: error reading hardware version\n", __func__);
		goto err_read;
	}

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

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

	devdata->has_legacy_keycode = 1;
#if 0
	err = i2c_touchkey_write_byte(devdata, devdata->backlight_on);
	if (err) {
		dev_err(dev, "%s: touch keypad backlight on failed\n",
				__func__);
		goto err_backlight_on;
	}
#endif
	set_irq_type((IRQ_EINT_GROUP18_BASE + 6), IRQ_TYPE_LEVEL_LOW); // IRQ_TYPE_EDGE_FALLING);
	s3c_gpio_cfgpin(_3_GPIO_TOUCH_INT, S3C_GPIO_SFN(0xf));
	s3c_gpio_setpull(_3_GPIO_TOUCH_INT, S3C_GPIO_PULL_NONE);

	if (request_threaded_irq(client->irq, touchkey_interrupt_handler,
				touchkey_interrupt_thread, IRQF_TRIGGER_FALLING,
				DEVICE_NAME, devdata)) {
		dev_err(dev, "%s: Can't allocate irq.\n", __func__);
		goto err_req_irq;
	}
	mdelay(50); 
	touchkey_auto_calibration(1);
	mdelay(200); 
	i2c_touchkey_read	(devdata,0x00, data, 6);
	touch_auto_calibration_on_off = (data[5] & 0x80)>>7;
	printk("touchkey_auto_calibration=%d,data=%x \n",touch_auto_calibration_on_off,data[5]);

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

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

	dev_set_drvdata(touchkey_update_device.this_device, devdata);

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

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

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

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

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

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

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

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

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

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

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

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

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

	touchkey_wq = create_singlethread_workqueue(DEVICE_NAME);
	if (!touchkey_wq)
		goto err_create_wq;

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

	return 0;

err_create_wq:
#if defined(TOUCH_UPDATE)
	misc_deregister(&touchkey_update_device);
#endif
err_misc_reg:
err_req_irq:
err_backlight_on:
err_read:
	devdata->pdata->touchkey_onoff(TOUCHKEY_OFF);
	input_unregister_device(input_dev);
	goto err_input_alloc_dev;
err_input_reg_dev:
	input_free_device(input_dev);
err_input_alloc_dev:
err_null_keycodes:
	kfree(devdata);
	return err;
}
Пример #16
0
static void rx51_wl1251_set_power(bool enable)
{
	gpio_set_value(RX51_WL1251_POWER_GPIO, enable);
}
/*
 * Disable NAND write protect
 */
static void lpc32xx_wp_disable(struct lpc32xx_nand_host *host)
{
	if (gpio_is_valid(host->ncfg->wp_gpio))
		gpio_set_value(host->ncfg->wp_gpio, 1);
}
Пример #18
0
static void rx51_tsc2005_set_reset(bool enable)
{
	gpio_set_value(RX51_TSC2005_RESET_GPIO, enable);
}
static void set_h2w_dat(int n)
{
	gpio_set_value(INCREDIBLEC_GPIO_H2W_DATA, n);
}
Пример #20
0
static void rx51_charger_set_power(bool on)
{
	gpio_set_value(RX51_USB_TRANSCEIVER_RST_GPIO, on);
}
Пример #21
0
static void board_poweroff(void)
{
	/* int n_usbic_state; */
#if ( defined( CONFIG_MACH_SAMSUNG_P1WIFI ) )
	u8 hwsts = 0;
	u8 vbus_val = 0;

	twl_i2c_read_u8(TWL4030_MODULE_PM_MASTER, &hwsts, 0x0F /*REG_STS_HW_CONDITIONS*/);

	if(hwsts & 0x80)  // STS_VBUS		0x80
		vbus_val = 1;
	else
		vbus_val = 0;
#endif

	printk("\nPower off routine - Board Shutdown!! \n");

/*
#if defined(CONFIG_USB_ANDROID)
	android_usb_set_connected(0);
#endif
*/

	/* get_real_usbic_state(); */
	//gpio_direction_output(GPIO_MSM_RST,0);
	//gpio_direction_output(GPIO_FONE_ACTIVE, 0);
	// if (GPIO_TA_CONNECTED_N is LOW)
#if ( defined( CONFIG_MACH_SAMSUNG_LATONA ) ) // jypark72, to avoid build error
	if ( !gpio_get_value( OMAP_GPIO_TA_NCONNECTED ) || gpio_get_value( OMAP_GPIO_JIG_ON18 ) )
#elif ( defined( CONFIG_MACH_SAMSUNG_P1WIFI ) )
	if (vbus_val || gpio_get_value( OMAP_GPIO_JIG_ON18 ) )
#endif
	{
		printk("Warmreset by TA or USB or Jtag - check 2 pins : JIG_ON18, TA_nConnected \n\n");

		preempt_disable();
		local_irq_disable();
		local_fiq_disable();

#ifdef CONFIG_SAMSUNG_KERNEL_DEBUG
		omap_writel(0x54455352, OMAP343X_CTRL_BASE + 0x9C4); // set to normal reset
#endif

#if 1
		/* using watchdog reset */
		omap_watchdog_reset();
		//machine_restart("ta_inserted");
#else
		/* using core_dpll_warmreset with global reset */
		//omap3_configure_core_dpll_warmreset();
		machine_restart("ta_inserted");
#endif

		while(1);
	}
	else
	{
		while(1)
		{
			if (gpio_get_value(OMAP_GPIO_KEY_PWRON)) {
				printk("Power button is pressed\n\n");
			}
			else {
				printk("Power Off !\n\n");
				gpio_set_value( OMAP_GPIO_PS_HOLD_PU, 0 ); 
				twl4030_poweroff();
				//for(;;);
			}
		}
	}
	return;
}
Пример #22
0
static void VAR_SOM_OM3X_disable_lcd(struct omap_dss_device *dssdev)
{
	printk(KERN_DEBUG "VAR_SOM_OM3X_disable_lcd\n");
	gpio_set_value(VAR_SOM_OM3X_LCD_PANEL_BKLIGHT_GPIO, 0);
	lcd_enabled = 0;
}
static int mipi_dsi_cdp_panel_power(int on)
{
	static struct regulator *reg_l8, *reg_l23, *reg_l2;
	int rc;

	pr_debug("%s: state : %d\n", __func__, on);

	if (!dsi_power_on) {

		reg_l8 = regulator_get(&msm_mipi_dsi1_device.dev,
				"dsi_vdc");
		if (IS_ERR(reg_l8)) {
			pr_err("could not get 8038_l8, rc = %ld\n",
				PTR_ERR(reg_l8));
			return -ENODEV;
		}
		reg_l23 = regulator_get(&msm_mipi_dsi1_device.dev,
				"dsi_vddio");
		if (IS_ERR(reg_l23)) {
			pr_err("could not get 8038_l23, rc = %ld\n",
				PTR_ERR(reg_l23));
			return -ENODEV;
		}
		reg_l2 = regulator_get(&msm_mipi_dsi1_device.dev,
				"dsi_vdda");
		if (IS_ERR(reg_l2)) {
			pr_err("could not get 8038_l2, rc = %ld\n",
				PTR_ERR(reg_l2));
			return -ENODEV;
		}
		rc = regulator_set_voltage(reg_l8, 2800000, 3000000);
		if (rc) {
			pr_err("set_voltage l8 failed, rc=%d\n", rc);
			return -EINVAL;
		}
		rc = regulator_set_voltage(reg_l23, 1800000, 1800000);
		if (rc) {
			pr_err("set_voltage l23 failed, rc=%d\n", rc);
			return -EINVAL;
		}
		rc = regulator_set_voltage(reg_l2, 1200000, 1200000);
		if (rc) {
			pr_err("set_voltage l2 failed, rc=%d\n", rc);
			return -EINVAL;
		}
		rc = gpio_request(DISP_RST_GPIO, "disp_rst_n");
		if (rc) {
			pr_err("request gpio DISP_RST_GPIO failed, rc=%d\n",
				rc);
			gpio_free(DISP_RST_GPIO);
			return -ENODEV;
		}
		rc = gpio_request(DISP_3D_2D_MODE, "disp_3d_2d");
		if (rc) {
			pr_err("request gpio DISP_3D_2D_MODE failed, rc=%d\n",
				 rc);
			gpio_free(DISP_3D_2D_MODE);
			return -ENODEV;
			}
		rc = gpio_direction_output(DISP_3D_2D_MODE, 0);
		if (rc) {
			pr_err("gpio_direction_output failed for %d gpio rc=%d\n",
			DISP_3D_2D_MODE, rc);
			return -ENODEV;
			}
		dsi_power_on = true;
	}
	if (on) {
		rc = regulator_set_optimum_mode(reg_l8, 100000);
		if (rc < 0) {
			pr_err("set_optimum_mode l8 failed, rc=%d\n", rc);
			return -EINVAL;
		}
		rc = regulator_set_optimum_mode(reg_l23, 100000);
		if (rc < 0) {
			pr_err("set_optimum_mode l23 failed, rc=%d\n", rc);
			return -EINVAL;
		}
		rc = regulator_set_optimum_mode(reg_l2, 100000);
		if (rc < 0) {
			pr_err("set_optimum_mode l2 failed, rc=%d\n", rc);
			return -EINVAL;
		}
		rc = regulator_enable(reg_l8);
		if (rc) {
			pr_err("enable l8 failed, rc=%d\n", rc);
			return -ENODEV;
		}
		rc = regulator_enable(reg_l23);
		if (rc) {
			pr_err("enable l8 failed, rc=%d\n", rc);
			return -ENODEV;
		}
		rc = regulator_enable(reg_l2);
		if (rc) {
			pr_err("enable l2 failed, rc=%d\n", rc);
			return -ENODEV;
		}
		usleep(10000);
		gpio_set_value(DISP_RST_GPIO, 1);
		usleep(10);
		gpio_set_value(DISP_RST_GPIO, 0);
		usleep(20);
		gpio_set_value(DISP_RST_GPIO, 1);
		gpio_set_value(DISP_3D_2D_MODE, 1);
		usleep(20);
	} else {

		gpio_set_value(DISP_RST_GPIO, 0);

		rc = regulator_disable(reg_l2);
		if (rc) {
			pr_err("disable reg_l2 failed, rc=%d\n", rc);
			return -ENODEV;
		}
		rc = regulator_disable(reg_l8);
		if (rc) {
			pr_err("disable reg_l8 failed, rc=%d\n", rc);
			return -ENODEV;
		}
		rc = regulator_disable(reg_l23);
		if (rc) {
			pr_err("disable reg_l23 failed, rc=%d\n", rc);
			return -ENODEV;
		}
		rc = regulator_set_optimum_mode(reg_l8, 100);
		if (rc < 0) {
			pr_err("set_optimum_mode l8 failed, rc=%d\n", rc);
			return -EINVAL;
		}
		rc = regulator_set_optimum_mode(reg_l23, 100);
		if (rc < 0) {
			pr_err("set_optimum_mode l23 failed, rc=%d\n", rc);
			return -EINVAL;
		}
		rc = regulator_set_optimum_mode(reg_l2, 100);
		if (rc < 0) {
			pr_err("set_optimum_mode l2 failed, rc=%d\n", rc);
			return -EINVAL;
		}
		gpio_set_value(DISP_3D_2D_MODE, 0);
		usleep(20);
	}
	return 0;
}
Пример #24
0
static void VAR_SOM_OM3X_disable_dvi(struct omap_dss_device *dssdev)
{
	gpio_set_value(VAR_SOM_OM3X_DVI_PANEL_EN_GPIO, 0);

	dvi_enabled = 0;
}
Пример #25
0
static void switch_uart_wimax(void)
{
	gpio_set_value(GPIO_UART_SEL, GPIO_LEVEL_LOW);
	gpio_set_value(GPIO_UART_SEL1, GPIO_LEVEL_HIGH);
}
Пример #26
0
static void __init VAR_SOM_OM3X_init(void)
{
	VAR_SOM_OM3X_twldata.vaux2 = &VAR_SOM_OM3X_vaux2;

	omap3_mux_init(board_mux, OMAP_PACKAGE_CUS);
	
	// USB phy enable
	if (gpio_request(24,"GPIO24")<0)
		printk(KERN_ERR "Can't get GPIO24 for USB phy reset\n");
	gpio_direction_output(24, 1);
	gpio_set_value(24, 1);


	// SMSC 9221 interrupt
	if (gpio_request(29,"GPIO29")<0)
		printk(KERN_ERR "Can't get GPIO29 for ETH0\n");
	gpio_direction_input(29);

#if 0
#ifdef VER_2_1
	omap_mux_init_gpio(VAR_SOM_OM3X_USB3_PWR_ENn, OMAP_PIN_INPUT_PULLUP);
	if (gpio_request(VAR_SOM_OM3X_USB3_PWR_ENn,"USB3_PWR_ENn")<0)
		printk(KERN_ERR "Can't get 167 for USB3 power enable\n");
	gpio_direction_output(VAR_SOM_OM3X_USB3_PWR_ENn, 1);
	gpio_set_value(VAR_SOM_OM3X_USB3_PWR_ENn, 1);
#endif
#endif

	VAR_SOM_OM3X_i2c_init();

	platform_add_devices(VAR_SOM_OM3X_devices, ARRAY_SIZE(VAR_SOM_OM3X_devices));

#if defined (CONFIG_TOUCHSCREEN_CTW6120) || defined (CONFIG_TOUCHSCREEN_ADS7846)
	spi_register_board_info(VAR_SOM_OM3X_spi_board_info,
				ARRAY_SIZE(VAR_SOM_OM3X_spi_board_info));
#endif

	omap_serial_init();
#ifdef CONFIG_NOP_USB_XCEIV
	usb_nop_xceiv_register();
#endif

	omap_mux_init_gpio(VAR_SOM_OM3X_DVI_PANEL_EN_GPIO, OMAP_PIN_INPUT_PULLUP);


	usb_musb_init();

	usb_ehci_init(&ehci_pdata);
	VAR_SOM_OM3X_flash_init();
		ads7846_dev_init();
	ctw6120_dev_init();
	VAR_SOM_OM3X_init_smsc911x();

#ifdef CONFIG_PANEL_VARISCITE
	VAR_SOM_OM3X_display_init();
#endif
	/* Ensure SDRC pins are mux'd for self-refresh */
	omap_mux_init_signal("sdrc_cke0", OMAP_PIN_OUTPUT);
	omap_mux_init_signal("sdrc_cke1", OMAP_PIN_OUTPUT);

	/* Push Buttons */
	bp_add_device_buttons();
}
Пример #27
0
static void restore_uart_path(void)
{
	gpio_set_value(GPIO_UART_SEL, wimax_config.uart_sel);
	gpio_set_value(GPIO_UART_SEL1, wimax_config.uart_sel1);
}
Пример #28
0
static void imx6q_usbotg_vbus(bool on) {
	if (on)
		gpio_set_value(MX6_USB_OTG_PWR, 1);
	else
		gpio_set_value(MX6_USB_OTG_PWR, 0);
}
Пример #29
0
static void wimax_wakeup_assert(int enable)
{
	gpio_set_value(GPIO_WIMAX_WAKEUP, !enable);
}
static long pn544_dev_unlocked_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
{
    struct pn544_dev *pn544_dev = filp->private_data;

    switch (cmd) {
    case PN544_SET_PWR:
        if (arg == 2) {
            /*
            power on with firmware download (requires hw reset)
            */
            dprintk(PN544_DRV_NAME ":%s power on with firmware\n", __func__);

            gpio_set_value(pn544_dev->ven_gpio, 1);
            gpio_set_value(pn544_dev->firm_gpio, 1);
            msleep(10);
            gpio_set_value(pn544_dev->ven_gpio, 0);
            msleep(10);
            gpio_set_value(pn544_dev->ven_gpio, 1);
            msleep(10);
        } else if (arg == 1) {
            /* power on */
            dprintk(PN544_DRV_NAME ":%s power on\n", __func__);

            gpio_set_value(pn544_dev->firm_gpio, 0);
            gpio_set_value(pn544_dev->ven_gpio, 1);
            msleep(10);
#ifdef CONFIG_LGE_NFC_SET_IRQ_WAKEUP
            if (sIrqState == false) {
                irq_set_irq_wake(pn544_dev->client->irq,1);
                sIrqState = true;
                dprintk(PN544_DRV_NAME ":%s enable IRQ\n", __func__);
            }
            else {
                pr_err("%s IRQ is already enabled!\n", __func__);
            }
#endif
        } else  if (arg == 0) {
            /* power off */
            dprintk(PN544_DRV_NAME ":%s power off\n", __func__);
            gpio_set_value(pn544_dev->firm_gpio, 0);
            gpio_set_value(pn544_dev->ven_gpio, 0);
            msleep(10);
#ifdef CONFIG_LGE_NFC_SET_IRQ_WAKEUP
            if (sIrqState == true) {
                irq_set_irq_wake(pn544_dev->client->irq,0);
                sIrqState = false;
                dprintk(PN544_DRV_NAME ":%s disable IRQ\n", __func__);
            }
            else {
                pr_err("%s IRQ is already disabled!\n", __func__);
            }
#endif
#ifdef LGE_NFC_READ_IRQ_MODIFY
        } else if (arg == 3) {//DY_TEST
            dprintk("%s Read Cancle\n", __func__);
            cancle_read = true;
            do_reading = 1;
            wake_up(&pn544_dev->read_wq);
#endif
        } else {
                pr_err("%s bad arg %ld\n", __func__, arg);
            return -EINVAL;
        }
        break;
    case PN544_INTERRUPT_CMD:
        {
            /*
            pn544_disable_irq = level;
            */
            dprintk(PN544_DRV_NAME ":ioctl: pn544_interrupt enable level:%ld\n", arg);
            break;
        }
    case PN544_READ_POLLING_CMD:
        {
            stReadIntFlag = arg;
            dprintk(PN544_DRV_NAME ":ioctl: pn544_polling flag set:%ld\n", arg);
            break;
        }
    case PN544_HW_REVISION:
        {
            return pn544_get_hw_revision();
        }
    default:
        pr_err("%s bad ioctl %d\n", __func__, cmd);
        return -EINVAL;
    }

    return 0;
}