static int sw_serial_get_resource(struct sw_serial_port *sport)
{
    char uart_para[16];
    int cnt, i = 0, ret;
    script_item_u *list = NULL;

    /* get register base */
    sport->mmres = platform_get_resource(sport->pdev, IORESOURCE_MEM, 0);
    if (!sport->mmres) {
        ret = -ENODEV;
        UART_ERR("%s: uart%d no IORESOURCE_MEM\n", __func__,
                sport->port_no);
        goto err_out;
    }

    /* get clock */
    sport->bus_clk_name = apb_clock_name[sport->port_no];
    sport->bus_clk = clk_get(NULL, sport->bus_clk_name);
    if (IS_ERR(sport->bus_clk)) {
        ret = PTR_ERR(sport->bus_clk);
        UART_ERR("%s: uart%d get bus clock failed\n", __func__,
                sport->port_no);
        goto iounmap;
    }

    sport->mod_clk_name = mod_clock_name[sport->port_no];
    sport->mod_clk = clk_get(NULL, sport->mod_clk_name);
    if (IS_ERR(sport->mod_clk)) {
        ret = PTR_ERR(sport->mod_clk);
        UART_ERR("%s: uart%d get mod clock failed\n", __func__,
                sport->port_no);
        goto iounmap;
    }

    sport->sclk = clk_get_rate(sport->mod_clk);
    /* get irq */
    sport->irq = platform_get_irq(sport->pdev, 0);
    if (sport->irq == 0) {
        ret = -EINVAL;
        UART_ERR("%s: uart%d no IORESOURCE_irq\n", __func__,
                sport->port_no);
        goto iounmap;
    }

    clk_enable(sport->bus_clk);
    clk_enable(sport->mod_clk);
    clk_reset(sport->mod_clk, AW_CCU_CLK_NRESET);

    sprintf(uart_para, "uart_para%d", sport->port_no);
    cnt = script_get_pio_list(uart_para, &list);
    if (!cnt) {
        ret = -EINVAL;
        UART_ERR("%s: uart%d get pio list from sys_config.fex failed\n",
                __func__, sport->port_no);
        goto free_pclk;
    }

    for (i = 0; i < cnt; i++)
        if (gpio_request(list[i].gpio.gpio, NULL)) {
            ret = -EINVAL;
            UART_ERR("%s: uart%d request gpio%d failed\n", __func__,
                    sport->port_no, list[i].gpio.gpio);
            goto free_pclk;
        }

    if (sw_gpio_setall_range(&list[0].gpio, cnt)) {
        UART_ERR("%s: uart%d gpio set all range error\n", __func__,
                sport->port_no);
        goto free_pclk;
    }

    return 0;

free_pclk:
    clk_put(sport->mod_clk);
    clk_put(sport->bus_clk);
iounmap:
err_out:
    while (i--)
        gpio_free(list[i].gpio.gpio);
    return ret;
}
Exemplo n.º 2
0
static int __devinit mma8x5x_probe(struct i2c_client *client,
				   const struct i2c_device_id *id)
{
	int result, chip_id;
	struct input_dev *idev;
	struct mma8x5x_data *pdata;
	struct i2c_adapter *adapter;
	adapter = to_i2c_adapter(client->dev.parent);
	/* power on the device */
	result = mma8x5x_config_regulator(client, 1);
	if (result)
		goto err_power_on;

	result = i2c_check_functionality(adapter,
					 I2C_FUNC_SMBUS_BYTE |
					 I2C_FUNC_SMBUS_BYTE_DATA);
	if (!result)
		goto err_check_id;

	chip_id = i2c_smbus_read_byte_data(client, MMA8X5X_WHO_AM_I);

	if (!mma8x5x_check_id(chip_id)) {
		dev_err(&client->dev,
			"read chip ID 0x%x is not equal to 0x%x,0x%x,0x%x,0x%x,0x%x!\n",
			chip_id, MMA8451_ID, MMA8452_ID, MMA8453_ID,
			MMA8652_ID, MMA8653_ID);
		result = -EINVAL;
		goto err_check_id;
	}
	/* set the private data */
	pdata = kzalloc(sizeof(struct mma8x5x_data), GFP_KERNEL);
	if (!pdata) {
		result = -ENOMEM;
		dev_err(&client->dev, "alloc data memory error!\n");
		goto err_check_id;
	}

	if (client->dev.of_node) {
		result = mma8x5x_parse_dt(&client->dev, pdata);
		if (result)
			goto err_parse_dt;
	} else {
		pdata->position = CONFIG_SENSORS_MMA_POSITION;
		pdata->int_pin = -1;
		pdata->int_flags = 0;
	}

	/* Initialize the MMA8X5X chip */
	pdata->client = client;
	pdata->chip_id = chip_id;
	pdata->mode = MODE_2G;
	pdata->poll_delay = POLL_INTERVAL;

	mutex_init(&pdata->data_lock);
	i2c_set_clientdata(client, pdata);
	/* Initialize the MMA8X5X chip */
	mma8x5x_device_init(client);
	if (pdata->use_int) {
		if (pdata->int_pin >= 0)
			client->irq = gpio_to_irq(pdata->int_pin);

		if (gpio_is_valid(pdata->int_pin)) {
			result = gpio_request(pdata->int_pin,
				"mma8x5x_irq_gpio");
			if (result) {
				dev_err(&client->dev, "irq gpio(%d) request failed",
					pdata->int_pin);
				goto err_request_gpio;
			}
			result = gpio_direction_input(pdata->int_pin);
			if (result) {
				dev_err(&client->dev,
					"set_direction for irq gpio failed\n");
				goto err_set_gpio_direction;
			}
		}
		device_init_wakeup(&client->dev, true);
		enable_irq_wake(client->irq);
		result = request_threaded_irq(client->irq, NULL,
			mma8x5x_interrupt,
			IRQ_TYPE_EDGE_RISING | IRQF_ONESHOT | IRQF_NO_SUSPEND,
			ACCEL_INPUT_DEV_NAME, (void *)client);
		if (result) {
			dev_err(&client->dev, "Could not allocate irq(%d) !\n",
				client->irq);
			goto err_register_irq;
		}
		mma8x5x_device_int_init(client);
	} else {
		INIT_DELAYED_WORK(&pdata->dwork, mma8x5x_dev_poll);
	}
	idev = input_allocate_device();
	if (!idev) {
		result = -ENOMEM;
		dev_err(&client->dev, "alloc input device failed!\n");
		goto err_alloc_poll_device;
	}
	input_set_drvdata(idev, pdata);
	idev->name = ACCEL_INPUT_DEV_NAME;
	idev->uniq = mma8x5x_id2name(pdata->chip_id);
	idev->id.bustype = BUS_I2C;
	idev->evbit[0] = BIT_MASK(EV_ABS);
	input_set_abs_params(idev, ABS_X, -0x7fff, 0x7fff, 0, 0);
	input_set_abs_params(idev, ABS_Y, -0x7fff, 0x7fff, 0, 0);
	input_set_abs_params(idev, ABS_Z, -0x7fff, 0x7fff, 0, 0);
	result = input_register_device(idev);
	if (result) {
		dev_err(&client->dev, "register input device failed!\n");
		goto err_register_device;
	}
	pdata->idev = idev;

	result = sysfs_create_group(&idev->dev.kobj, &mma8x5x_attr_group);
	if (result) {
		dev_err(&client->dev, "create device file failed!\n");
		result = -EINVAL;
		goto err_create_sysfs;
	}
	pdata->cdev = sensors_cdev;
	pdata->cdev.min_delay = POLL_INTERVAL_MIN * 1000;
	pdata->cdev.delay_msec = pdata->poll_delay;
	pdata->cdev.sensors_enable = mma8x5x_enable_set;
	pdata->cdev.sensors_poll_delay = mma8x5x_poll_delay_set;
	result = sensors_classdev_register(&client->dev, &pdata->cdev);
	if (result) {
		dev_err(&client->dev, "create class device file failed!\n");
		result = -EINVAL;
		goto err_create_class_sysfs;
	}
	dev_info(&client->dev,
		"%s:mma8x5x device driver probe successfully, position =%d\n",
		__func__, pdata->position);

	return 0;
err_create_class_sysfs:
	sysfs_remove_group(&idev->dev.kobj, &mma8x5x_attr_group);
err_create_sysfs:
	input_unregister_device(idev);
err_register_device:
	input_free_device(idev);
err_alloc_poll_device:
err_register_irq:
	if (pdata->use_int)
		device_init_wakeup(&client->dev, false);
err_set_gpio_direction:
	if (gpio_is_valid(pdata->int_pin) && pdata->use_int)
		gpio_free(pdata->int_pin);
err_request_gpio:
err_parse_dt:
	kfree(pdata);
err_check_id:
	mma8x5x_config_regulator(client, 0);
err_power_on:
	return result;
}
Exemplo n.º 3
0
static int __init touchkey_init(void)
{
	int ret = 0;
	int retry = 10;
	char data[3] = { 0, };

#if !(defined( CONFIG_S5PC110_T959_BOARD) || defined(CONFIG_S5PC110_KEPLER_BOARD)|| defined(CONFIG_S5PC110_DEMPSEY_BOARD)) 
	#if defined(CONFIG_S5PC110_HAWK_BOARD) || defined(CONFIG_S5PC110_VIBRANTPLUS_BOARD)
	#else
		touchkey_keycode[2] = KEY_ENTER;
	#endif
#endif

#if !(defined(CONFIG_ARIES_NTT) || defined(CONFIG_S5PC110_DEMPSEY_BOARD))
	if (ret = gpio_request(_3_GPIO_TOUCH_CE, "_3_GPIO_TOUCH_CE"))
		printk(KERN_ERR "Failed to request gpio %s:%d\n", __func__, __LINE__);
#endif
#ifndef CONFIG_S5PC110_DEMPSEY_BOARD

	if (ret = gpio_request(_3_GPIO_TOUCH_EN, "_3_GPIO_TOUCH_EN"))
		printk(KERN_ERR "Failed to request gpio %s:%d\n", __func__, __LINE__);
#endif
	if (ret = gpio_request(_3_TOUCH_SDA_28V, "_3_TOUCH_SDA_28V"))
		printk(KERN_ERR "Failed to request gpio %s:%d\n", __func__, __LINE__);
	if (ret = gpio_request(_3_TOUCH_SCL_28V, "_3_TOUCH_SCL_28V"))
		printk(KERN_ERR "Failed to request gpio %s:%d\n", __func__, __LINE__);

	ret = misc_register(&touchkey_update_device);
	if (ret) {
		printk("%s misc_register fail\n", __FUNCTION__);
	}

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

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

	if (device_create_file
	    (touchkey_update_device.this_device, &dev_attr_brightness) < 0) {
		printk("%s device_create_file fail dev_attr_touch_update\n",
		       __FUNCTION__);
		pr_err("Failed to create device file(%s)!\n",
		       dev_attr_brightness.attr.name);
	}
#ifdef CONFIG_KEYPAD_CYPRESS_TOUCH_USE_BLN
	ret = 0;
	ret = misc_register(&backlightnotification_device);
	if (ret) {
		printk("%s misc_register fail\n", __FUNCTION__, backlightnotification_device.name);
	}
	//add the backlightnotification attributes
	//add the backlightnotification attributes
	if (sysfs_create_group(&backlightnotification_device.this_device->kobj, &bln_notification_group) < 0)
	{
		printk("%s sysfs_create_group fail\n", __FUNCTION__);
		pr_err("Failed to create sysfs group for device (%s)!\n", backlightnotification_device.name);
	}
#endif

	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 defined (CONFIG_S5PC110_T959_BOARD) || defined(CONFIG_S5PC110_HAWK_BOARD) || defined(CONFIG_S5PC110_VIBRANTPLUS_BOARD)
	
	//NAGSM_Android_SEL_Kernel_Aakash_20100320

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

	//NAGSM_Android_SEL_Kernel_Aakash_20100320
#endif

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

	INIT_WORK(&touchkey_work, touchkey_work_func);

	init_hw();

	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]);
	touch_version = data[1];
	retry = 3;
#if 0 //def CONFIG_S5PC110_DEMPSEY_BOARD
	//update version "eclair/vendor/samsung/apps/Lcdtest/src/com/sec/android/app/lcdtest/touch_firmware.java"
	if ((data[1] < 0x8) ) {
		set_touchkey_debug('U');
		while (retry--) {
			if (ISSP_main() == 0) {
				printk("touchkey_update succeeded\n");
				set_touchkey_debug('C');
				break;
			}
			printk("touchkey_update failed... retry...\n");
			set_touchkey_debug('f');
		}
#ifndef CONFIG_S5PC110_DEMPSEY_BOARD
		if (retry <= 0) {
			gpio_direction_output(_3_GPIO_TOUCH_EN, 0);
#if !(defined(CONFIG_ARIES_NTT) || defined(CONFIG_S5PC110_DEMPSEY_BOARD))
			gpio_direction_output(_3_GPIO_TOUCH_CE, 0);
#endif
			msleep(300);
		}
#endif
		init_hw();	//after update, re initalize.
	}
#endif
	ret = i2c_add_driver(&touchkey_i2c_driver);

	if (ret) {
		printk
		    ("melfas touch keypad registration failed, module not inserted.ret= %d\n",
		     ret);
	}
	return ret;
}
static int anx7816_init_gpio(struct anx7816_data *anx7816)
{
	int ret = 0;

	pr_info("anx7816 init gpio\n");

	ret = gpio_request(anx7816->pdata->gpio_p_dwn, "anx_p_dwn_ctl");
	if (ret) {
		pr_err("%s : failed to request gpio %d\n", __func__,
				anx7816->pdata->gpio_p_dwn);
		goto out;
	}
	gpio_direction_output(anx7816->pdata->gpio_p_dwn, 1);

	ret = gpio_request(anx7816->pdata->gpio_reset, "anx7816_reset_n");
	if (ret) {
		pr_err("%s : failed to request gpio %d\n", __func__,
				anx7816->pdata->gpio_reset);
		goto err0;
	}
	gpio_direction_output(anx7816->pdata->gpio_reset, 0);
#if 0
	ret = gpio_request(anx7816->pdata->gpio_int, "anx7816_int_n");
	if (ret) {
		pr_err("%s : failed to request gpio %d\n", __func__,
				anx7816->pdata->gpio_int);
		goto err1;
	}
	gpio_direction_input(anx7816->pdata->gpio_int);
#endif
	ret = gpio_request(anx7816->pdata->gpio_cbl_det, "anx7816_cbl_det");
	if (ret) {
		pr_err("%s : failed to request gpio %d\n", __func__,
				anx7816->pdata->gpio_cbl_det);
		goto err2;
	}
	gpio_direction_input(anx7816->pdata->gpio_cbl_det);

	if (anx7816->pdata->external_ldo_control) {
		ret = gpio_request(anx7816->pdata->gpio_v10_ctrl,
							"anx7816_v10_ctrl");
			if (ret) {
				pr_err("%s : failed to request gpio %d\n",
						__func__,
						anx7816->pdata->gpio_v10_ctrl);
			goto err3;
		}
		gpio_direction_output(anx7816->pdata->gpio_v10_ctrl, 0);

		ret = gpio_request(anx7816->pdata->gpio_v33_ctrl,
							"anx7816_v33_ctrl");
			if (ret) {
				pr_err("%s : failed to request gpio %d\n",
						__func__,
						anx7816->pdata->gpio_v33_ctrl);
			goto err4;
		}
		gpio_direction_output(anx7816->pdata->gpio_v33_ctrl, 0);

		gpio_set_value(anx7816->pdata->gpio_v10_ctrl, 0);
		/* need to be check below */
		gpio_set_value(anx7816->pdata->gpio_v33_ctrl, 1);

	}
	gpio_set_value(anx7816->pdata->gpio_reset, 0);
	gpio_set_value(anx7816->pdata->gpio_p_dwn, 1);

#ifdef USE_HDMI_SWITCH
	ret = gpio_request(hdmi_switch_gpio, "anx7816_hdmi_switch_gpio");
	if (ret) {
		pr_err("%s : failed to request gpio %d\n", __func__,
				hdmi_switch_gpio);
		goto err5;
	}
	gpio_direction_output(hdmi_switch_gpio, 0);
	msleep(1);
	gpio_set_value(hdmi_switch_gpio, 1);
#endif

	goto out;

#ifdef USE_HDMI_SWITCH
err5:
	gpio_free(anx7816->pdata->gpio_v33_ctrl);
#endif
err4:
	gpio_free(anx7816->pdata->gpio_v10_ctrl);

err3:
	gpio_free(anx7816->pdata->gpio_cbl_det);
err2:
#if 0
	gpio_free(anx7816->pdata->gpio_int);
err1:
#endif
	gpio_free(anx7816->pdata->gpio_reset);
err0:
	gpio_free(anx7816->pdata->gpio_p_dwn);
out:
	return ret;
}
Exemplo n.º 5
0
static int __devinit s3c24xx_spi_probe(struct platform_device *pdev)
{
	struct s3c2410_spi_info *pdata;
	struct s3c24xx_spi *hw;
	struct spi_master *master;
	struct resource *res;
	int err = 0;

	master = spi_alloc_master(&pdev->dev, sizeof(struct s3c24xx_spi));
	if (master == NULL) {
		dev_err(&pdev->dev, "No memory for spi_master\n");
		err = -ENOMEM;
		goto err_nomem;
	}

	hw = spi_master_get_devdata(master);
	memset(hw, 0, sizeof(struct s3c24xx_spi));

	hw->master = spi_master_get(master);
	hw->pdata = pdata = pdev->dev.platform_data;
	hw->dev = &pdev->dev;

	if (pdata == NULL) {
		dev_err(&pdev->dev, "No platform data supplied\n");
		err = -ENOENT;
		goto err_no_pdata;
	}

	platform_set_drvdata(pdev, hw);
	init_completion(&hw->done);

	/* initialise fiq handler */

	s3c24xx_spi_initfiq(hw);

	/* setup the master state. */

	/* the spi->mode bits understood by this driver: */
	master->mode_bits = SPI_CPOL | SPI_CPHA | SPI_CS_HIGH;

	master->num_chipselect = hw->pdata->num_cs;
	master->bus_num = pdata->bus_num;

	/* setup the state for the bitbang driver */

	hw->bitbang.master         = hw->master;
	hw->bitbang.setup_transfer = s3c24xx_spi_setupxfer;
	hw->bitbang.chipselect     = s3c24xx_spi_chipsel;
	hw->bitbang.txrx_bufs      = s3c24xx_spi_txrx;

	hw->master->setup  = s3c24xx_spi_setup;
	hw->master->cleanup = s3c24xx_spi_cleanup;

	dev_dbg(hw->dev, "bitbang at %p\n", &hw->bitbang);

	/* find and map our resources */

	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
	if (res == NULL) {
		dev_err(&pdev->dev, "Cannot get IORESOURCE_MEM\n");
		err = -ENOENT;
		goto err_no_iores;
	}

	hw->ioarea = request_mem_region(res->start, resource_size(res),
					pdev->name);

	if (hw->ioarea == NULL) {
		dev_err(&pdev->dev, "Cannot reserve region\n");
		err = -ENXIO;
		goto err_no_iores;
	}

	hw->regs = ioremap(res->start, resource_size(res));
	if (hw->regs == NULL) {
		dev_err(&pdev->dev, "Cannot map IO\n");
		err = -ENXIO;
		goto err_no_iomap;
	}

	hw->irq = platform_get_irq(pdev, 0);
	if (hw->irq < 0) {
		dev_err(&pdev->dev, "No IRQ specified\n");
		err = -ENOENT;
		goto err_no_irq;
	}

	err = request_irq(hw->irq, s3c24xx_spi_irq, 0, pdev->name, hw);
	if (err) {
		dev_err(&pdev->dev, "Cannot claim IRQ\n");
		goto err_no_irq;
	}

	hw->clk = clk_get(&pdev->dev, "spi");
	if (IS_ERR(hw->clk)) {
		dev_err(&pdev->dev, "No clock for device\n");
		err = PTR_ERR(hw->clk);
		goto err_no_clk;
	}

	/* setup any gpio we can */

	if (!pdata->set_cs) {
		if (pdata->pin_cs < 0) {
			dev_err(&pdev->dev, "No chipselect pin\n");
			err = -EINVAL;
			goto err_register;
		}

		err = gpio_request(pdata->pin_cs, dev_name(&pdev->dev));
		if (err) {
			dev_err(&pdev->dev, "Failed to get gpio for cs\n");
			goto err_register;
		}

		hw->set_cs = s3c24xx_spi_gpiocs;
		gpio_direction_output(pdata->pin_cs, 1);
	} else
		hw->set_cs = pdata->set_cs;

	s3c24xx_spi_initialsetup(hw);

	/* register our spi controller */

	err = spi_bitbang_start(&hw->bitbang);
	if (err) {
		dev_err(&pdev->dev, "Failed to register SPI master\n");
		goto err_register;
	}

	return 0;

 err_register:
	if (hw->set_cs == s3c24xx_spi_gpiocs)
		gpio_free(pdata->pin_cs);

	clk_disable(hw->clk);
	clk_put(hw->clk);

 err_no_clk:
	free_irq(hw->irq, hw);

 err_no_irq:
	iounmap(hw->regs);

 err_no_iomap:
	release_resource(hw->ioarea);
	kfree(hw->ioarea);

 err_no_iores:
 err_no_pdata:
	spi_master_put(hw->master);

 err_nomem:
	return err;
}
Exemplo n.º 6
0
static int __init omap3pandora_soc_init(void)
{
    int ret;

    if (!machine_is_omap3_pandora())
        return -ENODEV;

    pr_info("OMAP3 Pandora SoC init\n");

    ret = gpio_request(OMAP3_PANDORA_DAC_POWER_GPIO, "dac_power");
    if (ret) {
        pr_err(PREFIX "Failed to get DAC power GPIO\n");
        return ret;
    }

    ret = gpio_direction_output(OMAP3_PANDORA_DAC_POWER_GPIO, 0);
    if (ret) {
        pr_err(PREFIX "Failed to set DAC power GPIO direction\n");
        goto fail0;
    }

    ret = gpio_request(OMAP3_PANDORA_AMP_POWER_GPIO, "amp_power");
    if (ret) {
        pr_err(PREFIX "Failed to get amp power GPIO\n");
        goto fail0;
    }

    ret = gpio_direction_output(OMAP3_PANDORA_AMP_POWER_GPIO, 0);
    if (ret) {
        pr_err(PREFIX "Failed to set amp power GPIO direction\n");
        goto fail1;
    }

    omap3pandora_snd_device = platform_device_alloc("soc-audio", -1);
    if (omap3pandora_snd_device == NULL) {
        pr_err(PREFIX "Platform device allocation failed\n");
        ret = -ENOMEM;
        goto fail1;
    }

    platform_set_drvdata(omap3pandora_snd_device, &omap3pandora_snd_data);
    omap3pandora_snd_data.dev = &omap3pandora_snd_device->dev;
    *(unsigned int *)omap_mcbsp_dai[0].private_data = 1; /* McBSP2 */
    *(unsigned int *)omap_mcbsp_dai[1].private_data = 3; /* McBSP4 */

    ret = platform_device_add(omap3pandora_snd_device);
    if (ret) {
        pr_err(PREFIX "Unable to add platform device\n");
        goto fail2;
    }

    return 0;

fail2:
    platform_device_put(omap3pandora_snd_device);
fail1:
    gpio_free(OMAP3_PANDORA_AMP_POWER_GPIO);
fail0:
    gpio_free(OMAP3_PANDORA_DAC_POWER_GPIO);
    return ret;
}
Exemplo n.º 7
0
static int bluetooth_set_power(void *data, enum rfkill_user_states state)
{
	unsigned int ret = 0; 
	switch (state) {

		case RFKILL_USER_STATE_UNBLOCKED:
			printk(KERN_DEBUG "[BT] Device Powering ON \n");
			s3c_setup_uart_cfg_gpio(0);

			if (gpio_is_valid(GPIO_BT_EN))
			{
				ret = gpio_request(GPIO_BT_EN, "GPB");
				if (ret < 0) {
					printk(KERN_ERR "[BT] Failed to request GPIO_BT_EN!\n");
					return ret;
				}
				gpio_direction_output(GPIO_BT_EN, GPIO_LEVEL_HIGH);
			}

			if (gpio_is_valid(GPIO_BT_nRST))
			{
				ret = gpio_request(GPIO_BT_nRST, "GPB");
				if (ret < 0) {
					gpio_free(GPIO_BT_EN);
					printk(KERN_ERR "[BT] Failed to request GPIO_BT_nRST\n");
					return ret;			
				}
				gpio_direction_output(GPIO_BT_nRST, GPIO_LEVEL_LOW);
			}
			printk(KERN_DEBUG "[BT] GPIO_BT_nRST = %d\n", gpio_get_value(GPIO_BT_nRST));

			/* Set GPIO_BT_WLAN_REG_ON high */ 
			s3c_gpio_setpull(GPIO_BT_EN, S3C_GPIO_PULL_NONE);
			gpio_set_value(GPIO_BT_EN, GPIO_LEVEL_HIGH);

			s3c_gpio_slp_cfgpin(GPIO_BT_EN, S3C_GPIO_SLP_OUT1);  
			s3c_gpio_slp_setpull_updown(GPIO_BT_EN, S3C_GPIO_PULL_NONE);

			printk( "[BT] GPIO_BT_EN = %d\n", gpio_get_value(GPIO_BT_EN));		
			/*FIXME sleep should be enabled disabled since the device is not booting 
			 * 			if its enabled*/
			msleep(100);  // 100msec, delay  between reg_on & rst. (bcm4329 powerup sequence)

			/* Set GPIO_BT_nRST high */
			s3c_gpio_setpull(GPIO_BT_nRST, S3C_GPIO_PULL_NONE);
			gpio_set_value(GPIO_BT_nRST, GPIO_LEVEL_HIGH);

			s3c_gpio_slp_cfgpin(GPIO_BT_nRST, S3C_GPIO_SLP_OUT1);
			s3c_gpio_slp_setpull_updown(GPIO_BT_nRST, S3C_GPIO_PULL_NONE);

			printk("[BT] GPIO_BT_nRST = %d\n", gpio_get_value(GPIO_BT_nRST));

			gpio_free(GPIO_BT_nRST);
			gpio_free(GPIO_BT_EN);

			break;

		case RFKILL_USER_STATE_SOFT_BLOCKED:
			printk(KERN_DEBUG "[BT] Device Powering OFF \n");
//			s3c_reset_uart_cfg_gpio(0);

			s3c_gpio_setpull(GPIO_BT_nRST, S3C_GPIO_PULL_NONE);
			gpio_set_value(GPIO_BT_nRST, GPIO_LEVEL_LOW);

			s3c_gpio_slp_cfgpin(GPIO_BT_nRST, S3C_GPIO_SLP_OUT0);
			s3c_gpio_slp_setpull_updown(GPIO_BT_nRST, S3C_GPIO_PULL_NONE);
			
			printk("[BT] GPIO_BT_nRST = %d\n",gpio_get_value(GPIO_BT_nRST));

			s3c_gpio_setpull(GPIO_BT_EN, S3C_GPIO_PULL_NONE);
			gpio_set_value(GPIO_BT_EN, GPIO_LEVEL_LOW);

			s3c_gpio_slp_cfgpin(GPIO_BT_EN, S3C_GPIO_SLP_OUT0);
			s3c_gpio_slp_setpull_updown(GPIO_BT_EN, S3C_GPIO_PULL_NONE);
			
			printk("[BT] GPIO_WLAN_BT_EN = %d\n", gpio_get_value(GPIO_WLAN_BT_EN));

			gpio_free(GPIO_BT_nRST);
			gpio_free(GPIO_BT_EN);

			break;

		default:
			printk(KERN_ERR "[BT] Bad bluetooth rfkill state %d\n", state);
	}

	return 0;
}
Exemplo n.º 8
0
static int tristate_dev_probe(struct platform_device *pdev)
{
	struct device *dev = &pdev->dev;
    
	int error=0;

	//void __iomem *cfg_reg;

        switch_data = kzalloc(sizeof(struct switch_dev_data), GFP_KERNEL);
        switch_data->dev = dev;
        
	    switch_data->key_pinctrl = devm_pinctrl_get(switch_data->dev);
         if (IS_ERR_OR_NULL(switch_data->key_pinctrl)) {
		        dev_err(switch_data->dev, "Failed to get pinctrl \n");
		        goto err_switch_dev_register;
	     }
         switch_data->set_state =pinctrl_lookup_state(switch_data->key_pinctrl,"key2_active"); 
         if (IS_ERR_OR_NULL(switch_data->set_state)) {
		        dev_err(switch_data->dev, "Failed to lookup_state \n");
		        goto err_switch_dev_register;
	     }        
        //switch_data->last_type = MODE_UNKNOWN;

        //tristate_supply_init();
/*
    switch_data->dev = dev;

    switch_data->input = input_allocate_device();

	switch_data->input->name = pdev->name;
	switch_data->input->phys = DRV_NAME"/input0";
	switch_data->input->dev.parent = &pdev->dev;

	switch_data->input->id.bustype = BUS_HOST;
	switch_data->input->id.vendor = 0x0001;
	switch_data->input->id.product = 0x0001;
	switch_data->input->id.version = 0x0100;

    input_set_drvdata(switch_data->input, switch_data);

	__set_bit(EV_KEY, switch_data->input->evbit);
 */
 
        //parse device tree node
		error = switch_dev_get_devtree_pdata(dev);
		if (error) {
			dev_err(dev, "parse device tree fail!!!\n");
			goto err_switch_dev_register;
		}
		
		//config irq gpio and request irq
	   switch_data->irq_key1 = gpio_to_irq(switch_data->key1_gpio);
       if (switch_data->irq_key1 <= 0)
       {
            printk("%s, irq number is not specified, irq #= %d, int pin=%d\n\n", __func__, switch_data->irq_key1, switch_data->key1_gpio);
            goto err_detect_irq_num_failed;
       }
       else
       {
        	error = gpio_request(switch_data->key1_gpio,"tristate_key1-int");        
        	if(error < 0)
        	{
        		printk(KERN_ERR "%s: gpio_request, err=%d", __func__, error);
        		//return retval;
        		goto err_request_gpio;
        	}
        	error = gpio_direction_input(switch_data->key1_gpio);
        	if(error < 0)
        	{
        		printk(KERN_ERR "%s: gpio_direction_input, err=%d", __func__, error);
        		//return retval;
        		goto err_set_gpio_input;
        	}
//printk("%s  gpio_get_value(%d)=%d \n",__func__,switch_data->key1_gpio,gpio_get_value(switch_data->key1_gpio));
        	error = request_irq(switch_data->irq_key1, switch_dev_interrupt,
			    IRQF_TRIGGER_FALLING|IRQF_TRIGGER_RISING, "tristate_key1", switch_data);
        	if (error) {
        		dev_err(dev,
        			"request_irq %i failed.\n",
        			switch_data->irq_key1);

        		switch_data->irq_key1 = -EINVAL;
        		goto err_request_irq;
            }
       }
       //config irq gpio and request irq
	   switch_data->irq_key2 = gpio_to_irq(switch_data->key2_gpio);
       if (switch_data->irq_key2 <= 0)
       {
            printk("%s, irq number is not specified, irq #= %d, int pin=%d\n\n", __func__, switch_data->irq_key2, switch_data->key2_gpio);
            goto err_detect_irq_num_failed;
       }
       else
       {
        	error = gpio_request(switch_data->key2_gpio,"tristate_key2-int");        
        	if(error < 0)
        	{
        		printk(KERN_ERR "%s: gpio_request, err=%d", __func__, error);
        		//return retval;
        		goto err_request_gpio;
        	}
        	error = gpio_direction_input(switch_data->key2_gpio);
        	if(error < 0)
        	{
        		printk(KERN_ERR "%s: gpio_direction_input, err=%d", __func__, error);
        		//return retval;
        		goto err_set_gpio_input;
        	}
        	//cfg_reg = (void __iomem *)0xffffff80000794d0;
            //writel_relaxed(0x00000000, cfg_reg);
            
                    	
//printk("%s  gpio_get_value(%d)=%d \n",__func__,switch_data->key2_gpio,gpio_get_value(switch_data->key2_gpio));
        	error = request_irq(switch_data->irq_key2, switch_dev_interrupt,
			    IRQF_TRIGGER_FALLING|IRQF_TRIGGER_RISING, "tristate_key2", switch_data);
			    
        	if (error) {
        		dev_err(dev,
        			"request_irq %i failed.\n",
        			switch_data->irq_key2);

        		switch_data->irq_key2 = -EINVAL;
        		goto err_request_irq;
            }
            
       }

        INIT_WORK(&switch_data->work, switch_dev_work);
        
        init_timer(&switch_data->s_timer);
        switch_data->s_timer.function = &timer_handle;
        switch_data->s_timer.expires = jiffies + 20*HZ;
  
        add_timer(&switch_data->s_timer);

        enable_irq_wake(switch_data->irq_key1);
        enable_irq_wake(switch_data->irq_key2);

        
        switch_data->sdev.name = DRV_NAME;
        //switch_data->sdev.print_state = switch_dev_print_state; //no need cause switch_class.c state_show()
       	error = switch_dev_register(&switch_data->sdev);
	    if (error < 0)
		    goto err_request_gpio;
		 //set_gpio_by_pinctrl();   
        //report the first switch
        //switch_dev_work(&switch_data->work);
        return 0;


err_request_gpio:
	switch_dev_unregister(&switch_data->sdev);        
err_request_irq:
err_detect_irq_num_failed:
err_set_gpio_input:
	gpio_free(switch_data->key2_gpio);
	gpio_free(switch_data->key1_gpio);
err_switch_dev_register:
	kfree(switch_data);	

	return error;
}
int tdmb_fc8050_spi_write_read(uint8* tx_data, int tx_length, uint8 *rx_data, int rx_length)
{
	int rc;

	struct spi_transfer	t = {
			.tx_buf		= tx_data,
			.rx_buf		= rx_data,
			.len		= tx_length+rx_length,
		};

	struct spi_message	m;	

	if (fc8050_ctrl_info.spi_ptr == NULL)
	{
		printk("tdmb_fc8050_spi_write_read error txdata=0x%x, length=%d\n", (unsigned int)tx_data, tx_length+rx_length);
	}

	mutex_lock(&fc8050_ctrl_info.mutex);

	spi_message_init(&m);
	spi_message_add_tail(&t, &m);
	rc = spi_sync(fc8050_ctrl_info.spi_ptr, &m);
	if ( rc < 0 )
	{
		printk("tdmb_fc8050_spi_read_burst result(%d), actual_len=%d\n",rc, m.actual_length);
	}

	mutex_unlock(&fc8050_ctrl_info.mutex);

	return TRUE;
}

#ifdef FEATURE_DMB_USE_WORKQUEUE
static irqreturn_t broadcast_tdmb_spi_isr(int irq, void *handle)
{
	struct tdmb_fc8050_ctrl_blk* fc8050_info_p;
	unsigned long flag;

	fc8050_info_p = (struct tdmb_fc8050_ctrl_blk *)handle;	
	if ( fc8050_info_p && fc8050_info_p->TdmbPowerOnState )
	{
		if (fc8050_info_p->spi_irq_status)
		{			
			printk("######### spi read function is so late skip #########\n");			
			return IRQ_HANDLED;
		}		
//		printk("***** broadcast_tdmb_spi_isr coming *******\n");
		spin_lock_irqsave(&fc8050_info_p->spin_lock, flag);
		queue_work(fc8050_info_p->spi_wq, &fc8050_info_p->spi_work);
		spin_unlock_irqrestore(&fc8050_info_p->spin_lock, flag);    
	}
	else
	{
		printk("broadcast_tdmb_spi_isr is called, but device is off state\n");
	}

	return IRQ_HANDLED; 
}

static void broacast_tdmb_spi_work(struct work_struct *tdmb_work)
{
	struct tdmb_fc8050_ctrl_blk *pTdmbWorkData;

	pTdmbWorkData = container_of(tdmb_work, struct tdmb_fc8050_ctrl_blk, spi_work);
	if ( pTdmbWorkData )
	{
//		printk("broadcast_tdmb_spi_work START\n");
		fc8050_isr_control(0);
		pTdmbWorkData->spi_irq_status = TRUE;
		broadcast_drv_if_isr();
		pTdmbWorkData->spi_irq_status = FALSE;
		fc8050_isr_control(1);
//		printk("broadcast_tdmb_spi_work END\n");
//		printk("broacast_tdmb_spi_work is called handle=0x%x\n", (unsigned int)pTdmbWorkData);
	}
	else
	{
		printk("~~~~~~~broadcast_tdmb_spi_work call but pTdmbworkData is NULL ~~~~~~~\n");
	}
}
#else
static irqreturn_t broadcast_tdmb_spi_event_handler(int irq, void *handle)
{
	struct tdmb_fc8050_ctrl_blk *fc8050_info_p;

	fc8050_info_p = (struct tdmb_fc8050_ctrl_blk *)handle;
	if ( fc8050_info_p && fc8050_info_p->TdmbPowerOnState )
	{
		if (fc8050_info_p->spi_irq_status)
		{
			printk("######### spi read function is so late skip ignore #########\n");
			return IRQ_HANDLED;
		}

		fc8050_isr_control(0);
		fc8050_info_p->spi_irq_status = TRUE;
		broadcast_drv_if_isr();
		fc8050_info_p->spi_irq_status = FALSE;
		fc8050_isr_control(1);

	}
	else
	{
		printk("broadcast_tdmb_spi_isr is called, but device is off state\n");
	}
	return IRQ_HANDLED;
}
#endif

static int broadcast_tdmb_fc8050_probe(struct spi_device *spi)
{
	int rc;
	
#ifdef ANTENNA_SWITCHING
	struct pm_gpio GPIO11_CFG = {
				.direction      = PM_GPIO_DIR_OUT,
				.pull           = PM_GPIO_PULL_NO,
				.function       = PM_GPIO_FUNC_NORMAL,
				.vin_sel        = 2,	/* for ESD TEST in I-pjt */
				.inv_int_pol    = 0,	
				};
	struct pm_gpio GPIO12_CFG = {
				.direction      = PM_GPIO_DIR_OUT,
				.pull           = PM_GPIO_PULL_NO,
				.function       = PM_GPIO_FUNC_NORMAL,
				.vin_sel        = 2,	/* for ESD TEST in I-pjt */
				.inv_int_pol    = 0,			
				};	
#endif  /* ANTENNA_SWITCHING */        

	fc8050_ctrl_info.TdmbPowerOnState = FALSE;
	
	fc8050_ctrl_info.spi_ptr 				= spi;
	fc8050_ctrl_info.spi_ptr->mode 			= SPI_MODE_0;
	fc8050_ctrl_info.spi_ptr->bits_per_word 	= 8;
	fc8050_ctrl_info.spi_ptr->max_speed_hz 	= ( 24000*1000 );
	rc = spi_setup(spi);
	printk("broadcast_tdmb_fc8050_probe spi_setup=%d\n", rc);
	BBM_HOSTIF_SELECT(NULL, 1);
	
#ifdef FEATURE_DMB_USE_WORKQUEUE
	INIT_WORK(&fc8050_ctrl_info.spi_work, broacast_tdmb_spi_work);
	fc8050_ctrl_info.spi_wq = create_singlethread_workqueue("tdmb_spi_wq");
	if(fc8050_ctrl_info.spi_wq == NULL){
		printk("Failed to setup tdmb spi workqueue \n");
		return -ENOMEM;
	}
#endif
#ifdef FEATURE_DMB_USE_WORKQUEUE
	rc = request_irq(spi->irq, broadcast_tdmb_spi_isr, IRQF_DISABLED | IRQF_TRIGGER_FALLING, spi->dev.driver->name, &fc8050_ctrl_info);
#else
	rc = request_threaded_irq(spi->irq, NULL, broadcast_tdmb_spi_event_handler, IRQF_DISABLED | IRQF_TRIGGER_FALLING,
		spi->dev.driver->name, &fc8050_ctrl_info);
#endif
	printk("broadcast_tdmb_fc8050_probe request_irq=%d\n", rc);

	gpio_request(101, "DMB_RESET_N");
	gpio_request(102, "DMB_EN");
	gpio_request(107, "DMB_INT_N");
	gpio_direction_output(DMB_RESET_N, false);      
	gpio_direction_output(DMB_EN, false);               
	gpio_direction_output(DMB_INT_N, false);           

#ifdef ANTENNA_SWITCHING
	pm8xxx_gpio_config(DMB_ANT_SEL_P, &GPIO11_CFG);
	pm8xxx_gpio_config(DMB_ANT_SEL_N, &GPIO12_CFG);
	gpio_set_value_cansleep(DMB_ANT_SEL_P, 1);	/* for ESD TEST in I-pjt */
	gpio_set_value_cansleep(DMB_ANT_SEL_N, 0);	/* for ESD TEST in I-pjt */
#endif  /* ANTENNA_SWITCHING */
	tdmb_fc8050_interrupt_lock();

	mutex_init(&fc8050_ctrl_info.mutex);

	wake_lock_init(&fc8050_ctrl_info.wake_lock,  WAKE_LOCK_SUSPEND, dev_name(&spi->dev));		
	spin_lock_init(&fc8050_ctrl_info.spin_lock);

#ifdef PM_QOS
	pm_qos_add_request(&fc8050_ctrl_info.pm_req_list, PM_QOS_CPU_DMA_LATENCY, PM_QOS_DEFAULT_VALUE);
#endif  /* PM_QOS */

	printk("broadcast_fc8050_probe End\n");

	return rc;
}

static int broadcast_tdmb_fc8050_remove(struct spi_device *spi)
{
	printk("broadcast_tdmb_fc8050_remove \n");
#ifdef FEATURE_DMB_USE_WORKQUEUE

	if (fc8050_ctrl_info.spi_wq)
	{
		flush_workqueue(fc8050_ctrl_info.spi_wq);
		destroy_workqueue(fc8050_ctrl_info.spi_wq);
	}
#endif
	free_irq(spi->irq, &fc8050_ctrl_info);

	mutex_destroy(&fc8050_ctrl_info.mutex);

	wake_lock_destroy(&fc8050_ctrl_info.wake_lock);

#ifdef PM_QOS
	pm_qos_remove_request(&fc8050_ctrl_info.pm_req_list);
#endif  /* PM_QOS */
	memset((unsigned char*)&fc8050_ctrl_info, 0x0, sizeof(struct tdmb_fc8050_ctrl_blk));
	return 0;
}

static int broadcast_tdmb_fc8050_suspend(struct spi_device *spi, pm_message_t mesg)
{
	printk("broadcast_tdmb_fc8050_suspend \n");
	return 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;
}
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;
}
Exemplo n.º 12
0
static int charging_ic_probe(struct platform_device *dev)
{
	int ret = 0;

	ret = gpio_request(CHG_EN_SET_N_OMAP, "hub charging_ic_en");
	if (ret < 0) {
		printk(KERN_ERR "%s: Failed to request GPIO_%d for "
				"charging_ic\n", __func__, CHG_EN_SET_N_OMAP);
		return -ENOSYS;
	}
	gpio_direction_output(CHG_EN_SET_N_OMAP, 0);

	ret = gpio_request(CHG_STATUS_N_OMAP, "hub charging_ic_status");
	if (ret < 0) {
		printk(KERN_ERR "%s: Failed to request GPIO_%d for "
				"charging_ic_status\n", __func__,
				CHG_STATUS_N_OMAP);
		goto err_gpio_request_failed;
	}
	gpio_direction_input(CHG_STATUS_N_OMAP);

	ret = request_irq(gpio_to_irq(CHG_STATUS_N_OMAP),
			charging_ic_interrupt_handler,
			IRQF_TRIGGER_RISING,
			"Charging_ic_driver", NULL);
	if (ret < 0) {
		printk(KERN_ERR "%s: Failed to request IRQ for "
				"charging_ic_status\n", __func__);
		goto err_request_irq_failed;
	}

#ifdef CONFIG_LGE_CHARGE_CONTROL_BATTERY_FET
	ret = gpio_request(CHAR_CONTROL, "hub battery_fet");
	if (ret < 0) {
		printk(KERN_ERR "%s: Failed to request GPIO_%d for "
				"charging_ic\n", __func__, CHAR_CONTROL);
		goto err_gpio_request_char_control;
	}
	gpio_direction_output(CHAR_CONTROL, 0);
#endif 

	INIT_DELAYED_WORK(&charging_ic_int_work,
				charging_ic_work_func);

	wake_lock_init(&power_off_charging_lock, WAKE_LOCK_SUSPEND, "Power Off Charging");
	
	charging_ic_status = CHARGING_IC_DEACTIVE;

	hub_charging_ic_intialize();

	// for AT Command AT%CHARGE
	// sysfs path : /sys/devices/platform/hub_charging_ic/charging_state
	ret = device_create_file(&dev->dev, &dev_attr_charging_state);
	if (ret < 0) {
		pr_err("%s:File device creation failed: %d\n", __func__, ret);
		//ret = -ENODEV;
	}

	// for Power Off Charging
	// sysfs path : /sys/devices/platform/hub_charging_ic/power_off_charging
	ret = device_create_file(&dev->dev, &dev_attr_power_off_charging);
	if (ret < 0) {
		pr_err("%s:File device creation failed: %d\n", __func__, ret);
		//ret = -ENODEV;
	}

	enable_irq_wake(gpio_to_irq(CHG_STATUS_N_OMAP)); //20101104 [email protected] enable charger wakeup
	return 0;

#ifdef CONFIG_LGE_CHARGE_CONTROL_BATTERY_FET
	gpio_free(CHAR_CONTROL);
err_gpio_request_char_control:
#endif 
	free_irq(gpio_to_irq(CHG_STATUS_N_OMAP), NULL);
err_request_irq_failed:
	gpio_free(CHG_STATUS_N_OMAP);
err_gpio_request_failed:
	gpio_free(CHG_EN_SET_N_OMAP);

	return ret;
}
/*
 * Probe for NAND controller
 */
static int lpc32xx_nand_probe(struct platform_device *pdev)
{
	struct lpc32xx_nand_host *host;
	struct mtd_info *mtd;
	struct nand_chip *chip;
	struct resource *rc;
	struct mtd_part_parser_data ppdata = {};
	int res;

	rc = platform_get_resource(pdev, IORESOURCE_MEM, 0);
	if (rc == NULL) {
		dev_err(&pdev->dev, "No memory resource found for device\n");
		return -EBUSY;
	}

	/* Allocate memory for the device structure (and zero it) */
	host = devm_kzalloc(&pdev->dev, sizeof(*host), GFP_KERNEL);
	if (!host) {
		dev_err(&pdev->dev, "failed to allocate device structure\n");
		return -ENOMEM;
	}
	host->io_base_dma = rc->start;

	host->io_base = devm_ioremap_resource(&pdev->dev, rc);
	if (IS_ERR(host->io_base))
		return PTR_ERR(host->io_base);

	if (pdev->dev.of_node)
		host->ncfg = lpc32xx_parse_dt(&pdev->dev);
	if (!host->ncfg) {
		dev_err(&pdev->dev,
			"Missing or bad NAND config from device tree\n");
		return -ENOENT;
	}
	if (host->ncfg->wp_gpio == -EPROBE_DEFER)
		return -EPROBE_DEFER;
	if (gpio_is_valid(host->ncfg->wp_gpio) &&
			gpio_request(host->ncfg->wp_gpio, "NAND WP")) {
		dev_err(&pdev->dev, "GPIO not available\n");
		return -EBUSY;
	}
	lpc32xx_wp_disable(host);

	host->pdata = dev_get_platdata(&pdev->dev);

	mtd = &host->mtd;
	chip = &host->nand_chip;
	chip->priv = host;
	mtd->priv = chip;
	mtd->owner = THIS_MODULE;
	mtd->dev.parent = &pdev->dev;

	/* Get NAND clock */
	host->clk = clk_get(&pdev->dev, NULL);
	if (IS_ERR(host->clk)) {
		dev_err(&pdev->dev, "Clock failure\n");
		res = -ENOENT;
		goto err_exit1;
	}
	clk_enable(host->clk);

	/* Set NAND IO addresses and command/ready functions */
	chip->IO_ADDR_R = SLC_DATA(host->io_base);
	chip->IO_ADDR_W = SLC_DATA(host->io_base);
	chip->cmd_ctrl = lpc32xx_nand_cmd_ctrl;
	chip->dev_ready = lpc32xx_nand_device_ready;
	chip->chip_delay = 20; /* 20us command delay time */

	/* Init NAND controller */
	lpc32xx_nand_setup(host);

	platform_set_drvdata(pdev, host);

	/* NAND callbacks for LPC32xx SLC hardware */
	chip->ecc.mode = NAND_ECC_HW_SYNDROME;
	chip->read_byte = lpc32xx_nand_read_byte;
	chip->read_buf = lpc32xx_nand_read_buf;
	chip->write_buf = lpc32xx_nand_write_buf;
	chip->ecc.read_page_raw = lpc32xx_nand_read_page_raw_syndrome;
	chip->ecc.read_page = lpc32xx_nand_read_page_syndrome;
	chip->ecc.write_page_raw = lpc32xx_nand_write_page_raw_syndrome;
	chip->ecc.write_page = lpc32xx_nand_write_page_syndrome;
	chip->ecc.write_oob = lpc32xx_nand_write_oob_syndrome;
	chip->ecc.read_oob = lpc32xx_nand_read_oob_syndrome;
	chip->ecc.calculate = lpc32xx_nand_ecc_calculate;
	chip->ecc.correct = nand_correct_data;
	chip->ecc.strength = 1;
	chip->ecc.hwctl = lpc32xx_nand_ecc_enable;

	/* bitflip_threshold's default is defined as ecc_strength anyway.
	 * Unfortunately, it is set only later at add_mtd_device(). Meanwhile
	 * being 0, it causes bad block table scanning errors in
	 * nand_scan_tail(), so preparing it here already. */
	mtd->bitflip_threshold = chip->ecc.strength;

	/*
	 * Allocate a large enough buffer for a single huge page plus
	 * extra space for the spare area and ECC storage area
	 */
	host->dma_buf_len = LPC32XX_DMA_DATA_SIZE + LPC32XX_ECC_SAVE_SIZE;
	host->data_buf = devm_kzalloc(&pdev->dev, host->dma_buf_len,
				      GFP_KERNEL);
	if (host->data_buf == NULL) {
		dev_err(&pdev->dev, "Error allocating memory\n");
		res = -ENOMEM;
		goto err_exit2;
	}

	res = lpc32xx_nand_dma_setup(host);
	if (res) {
		res = -EIO;
		goto err_exit2;
	}

	/* Find NAND device */
	if (nand_scan_ident(mtd, 1, NULL)) {
		res = -ENXIO;
		goto err_exit3;
	}

	/* OOB and ECC CPU and DMA work areas */
	host->ecc_buf = (uint32_t *)(host->data_buf + LPC32XX_DMA_DATA_SIZE);

	/*
	 * Small page FLASH has a unique OOB layout, but large and huge
	 * page FLASH use the standard layout. Small page FLASH uses a
	 * custom BBT marker layout.
	 */
	if (mtd->writesize <= 512)
		chip->ecc.layout = &lpc32xx_nand_oob_16;

	/* These sizes remain the same regardless of page size */
	chip->ecc.size = 256;
	chip->ecc.bytes = LPC32XX_SLC_DEV_ECC_BYTES;
	chip->ecc.prepad = chip->ecc.postpad = 0;

	/* Avoid extra scan if using BBT, setup BBT support */
	if (host->ncfg->use_bbt) {
		chip->bbt_options |= NAND_BBT_USE_FLASH;

		/*
		 * Use a custom BBT marker setup for small page FLASH that
		 * won't interfere with the ECC layout. Large and huge page
		 * FLASH use the standard layout.
		 */
		if (mtd->writesize <= 512) {
			chip->bbt_td = &bbt_smallpage_main_descr;
			chip->bbt_md = &bbt_smallpage_mirror_descr;
		}
	}

	/*
	 * Fills out all the uninitialized function pointers with the defaults
	 */
	if (nand_scan_tail(mtd)) {
		res = -ENXIO;
		goto err_exit3;
	}

	mtd->name = "nxp_lpc3220_slc";
	ppdata.of_node = pdev->dev.of_node;
	res = mtd_device_parse_register(mtd, NULL, &ppdata, host->ncfg->parts,
					host->ncfg->num_parts);
	if (!res)
		return res;

	nand_release(mtd);

err_exit3:
	dma_release_channel(host->dma_chan);
err_exit2:
	clk_disable(host->clk);
	clk_put(host->clk);
err_exit1:
	lpc32xx_wp_enable(host);
	gpio_free(host->ncfg->wp_gpio);

	return res;
}
Exemplo n.º 14
0
static int __devinit bd60910_bl_probe(struct i2c_client *client,
		const struct i2c_device_id *id)
{
	struct bd60910_bl_data *data = kzalloc(sizeof(struct bd60910_bl_data), GFP_KERNEL);
	int ret = 0;
    TRACE_CALL() ;
	if (!data)
		return -ENOMEM;
    // FORTE	data->comadj = sharpsl_param.comadj == -1 ? COMADJ_DEFAULT : sharpsl_param.comadj;

        ret = gpio_request(BL_ENABLE, "backlight");
	if (ret) {
		dev_dbg(&data->bl->dev, "Unable to request gpio!\n");
		goto err_gpio_bl;
	}
	ret = gpio_direction_output(BL_ENABLE, 1);      // TODO: FORTE Rev0.1 timing ???
	if (ret)
		goto err_gpio_dir;
	i2c_set_clientdata(client, data);
	data->i2c = client;
        bl_i2c_client = client ;
	data->bl = backlight_device_register("s5p_bl" /*"bd60910"*/, &client->dev,
			data, &bl_ops, NULL); /* YUNG@DISYS GB */
	if (IS_ERR(data->bl)) {
		ret = PTR_ERR(data->bl);
		goto err_reg;
	}

	data->bl->props.brightness = 69;
	data->bl->props.max_brightness = 255 ;
	data->bl->props.power = FB_BLANK_UNBLANK;

	backlight_update_status(data->bl);

#ifdef CONFIG_BL_HAS_EARLYSUSPEND
#ifdef CONFIG_MACH_TREBON
	bl_early_suspend.suspend = NULL;
	bl_early_suspend.resume =  NULL;
#else
	bl_early_suspend.suspend = bd60910_bl_early_suspend;
	bl_early_suspend.resume =  bd60910_bl_late_resume;
#endif

#if defined(CONFIG_MACH_CHIEF) && !defined(CONFIG_TIKAL_MPCS)
	bl_early_suspend.level = EARLY_SUSPEND_LEVEL_DISABLE_FB;
#else
	bl_early_suspend.level = EARLY_SUSPEND_LEVEL_BLANK_SCREEN;
#endif
	register_early_suspend(&bl_early_suspend);
#endif
#if defined(CONFIG_MACH_CHIEF) && !defined(CONFIG_MACH_TREBON)
        INIT_WORK(&bd60910_bl_work,bd60910_bl_workfunc);
#endif

	return 0;

err_reg:
	data->bl = NULL;
	i2c_set_clientdata(client, NULL);
err_gpio_dir:
	gpio_free(BL_ENABLE);
err_gpio_bl:
	kfree(data);
	return ret;
}
Exemplo n.º 15
0
static int aw_leds_probe(struct i2c_client *client,
		const struct i2c_device_id *id)
{
	int ret = 0;
	struct aw_leds_data *data;
	const struct device_node *np = client->dev.of_node;

	if (!i2c_check_functionality(client->adapter,
			I2C_FUNC_SMBUS_WRITE_BYTE | I2C_FUNC_SMBUS_READ_BYTE_DATA))
	{
		dev_err(&client->dev, "need I2C_FUNC_SMBUS*.\n");
		return -ENODEV;
	}

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

	if (of_property_read_u32(np, "aw_leds,gpio", &data->gpio)) {
		dev_err(&client->dev, "failed to read aw_leds,gpio from dt\n");
		goto exit;
	}

	data->leds[0] = AW_LED_INVALID;
	if (of_property_read_u32(np, "aw_leds,led0", &data->leds[0])) {
		dev_warn(&client->dev, "failed to read aw_leds,led0 from dt\n");
	}

	data->leds[1] = AW_LED_INVALID;
	if (of_property_read_u32(np, "aw_leds,led1", &data->leds[1])) {
		dev_warn(&client->dev, "failed to read aw_leds,led1 from dt\n");
	}

	data->leds[2] = AW_LED_INVALID;
	if (of_property_read_u32(np, "aw_leds,led2", &data->leds[2])) {
		dev_warn(&client->dev, "failed to read aw_leds,led2 from dt\n");
	}

	dev_dbg(&client->dev, "leds: %d %d %d\n",
		data->leds[0], data->leds[1], data->leds[2]);

	ret = gpio_request(data->gpio, "aw_leds-gpio");
	if (ret) {
		dev_err(&client->dev, "failed to request gpio %d\n", data->gpio);
		goto exit;
	}

	gpio_direction_output(data->gpio, 1);
	dev_dbg(&client->dev, "using gpio %d\n", data->gpio);

	data->vana = regulator_get(&client->dev, "vdd_ana");
	if (IS_ERR(data->vana)) {
		ret = PTR_ERR(data->vana);
		dev_err(&client->dev, "regulator get vdd_ana failed\n");
		goto reg_failed;
	}

	ret = regulator_enable(data->vana);
	if (ret) {
		dev_err(&client->dev, "regulator vdd_ana enable failed\n");
		goto reg_en_failed;
	}

	data->client = client;
	i2c_set_clientdata(client, data);
	mutex_init(&data->mutex);

	data->dev.minor = MISC_DYNAMIC_MINOR;
	data->dev.name = "aw-leds";
	data->dev.fops = &aw_leds_fops;
	ret = misc_register(&data->dev);
	if (ret < 0) {
		dev_err(&client->adapter->dev, "misc_register returned %d\n", ret);
		goto register_failed;
	}

	dev_dbg(&client->dev, "success\n");
	return 0;
register_failed:
	mutex_destroy(&data->mutex);
reg_en_failed:
	regulator_put(data->vana);
reg_failed:
	gpio_free(data->gpio);
exit:
	kfree(data);
	return ret;
}
Exemplo n.º 16
0
static int __devinit lp8720_i2c_probe(struct i2c_client *i2c,
			    const struct i2c_device_id *id)
{
	struct lp8720 *lp8720;
	struct lp8720_platform_data *pdata = i2c->dev.platform_data;
	int ret;
	u8 readbyte = 0;
	u8 enable = 0;

	if (!pdata) {
		dev_dbg(&i2c->dev, "No platform init data supplied\n");
		return -ENODEV;
	}

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

	lp8720->i2c = i2c;
	lp8720->dev = &i2c->dev;

	mutex_init(&lp8720->io_lock);
#if 0 /* don't verify pmic register because pmic register is changed by bootloader */
	ret = lp8720_i2c_read(i2c, 0x00, 1, &readbyte);
	if (ret == 0 &&
		readbyte != 0x05) {
		ret = -ENODEV;
		dev_err(&i2c->dev, "chip reported: [00h]= 0x%x\n", readbyte);
	}
	if (ret < 0) {
		dev_err(&i2c->dev, "failed to detect device. ret = %d\n", ret);
		goto err_detect;
	}
#endif

	ret = setup_regulators(lp8720, pdata);
	if (ret < 0)
		goto err_detect;

	i2c_set_clientdata(i2c, lp8720);

	ret = gpio_request(pdata->en_pin, pdata->name);
	if (ret) {
		printk(KERN_ERR "%s, ERROR [%s] - gpio_request(%d) failed\n",
				__func__,
				pdata->name,
				pdata->en_pin);
	}

	ret = gpio_direction_output(pdata->en_pin, 1);
	if (ret) {
		printk(KERN_ERR "%s, ERROR [%s] - gpio_direction_output(%d) failed\n",
				__func__,
				pdata->name,
				pdata->en_pin);
	}

	/* EXT_DVS_CTRL, EXT_SLEEP_CTRL => serial interface control */
	lp8720_i2c_read(i2c, LP8720_GENERAL_SETTINGS_REG, 1, &readbyte);
	enable = readbyte & ~0x06;
	lp8720_i2c_write(i2c, LP8720_GENERAL_SETTINGS_REG, 1, enable);
#if 0 /* keep pmic state set by bootloader */
	/* all ldo & buck disabled */
	lp8720_i2c_read(i2c, LP8720_ENABLE_REG, 1, &readbyte);
	enable = readbyte & 0xC0;
	lp8720_i2c_write(i2c, LP8720_ENABLE_REG, 1, enable);
#endif

	lp8720_i2c_read(i2c, LP8720_ENABLE_REG, 1, &readbyte);
	printk(KERN_DEBUG "%s, [%s] - ENABLE_REG : 0x%2x\n",
			__func__, pdata->name, readbyte);

	return 0;

err_detect:
	kfree(lp8720);
	return ret;
}
Exemplo n.º 17
0
static int __init touchkey_init(void)
{
	int ret = 0;

	gpio_request(_3_TOUCH_SDA_28V, "_3_TOUCH_SDA_28V");
	gpio_request(_3_TOUCH_SCL_28V, "_3_TOUCH_SCL_28V");
	gpio_request(_3_GPIO_TOUCH_EN, "_3_GPIO_TOUCH_EN");
	gpio_request(_3_GPIO_TOUCH_INT, "_3_GPIO_TOUCH_INT");

	/*20110222 N1_firmware_sync*/
	sec_touchkey= device_create(sec_class, NULL, 0, NULL, "sec_touchkey");

	if (IS_ERR(sec_touchkey)) {
		printk(KERN_ERR "Failed to create device(sec_touchkey)!\n");
	}
	if (device_create_file(sec_touchkey, &dev_attr_touchkey_firm_update)< 0) {
		printk(KERN_ERR "Failed to create device file(%s)!\n", dev_attr_touchkey_firm_update.attr.name);
	}
	if (device_create_file(sec_touchkey, &dev_attr_touchkey_firm_update_status)< 0)	{
		printk(KERN_ERR "Failed to create device file(%s)!\n", dev_attr_touchkey_firm_update_status.attr.name);
	}
	if (device_create_file(sec_touchkey, &dev_attr_touchkey_firm_version_phone)< 0)	{
		printk(KERN_ERR "Failed to create device file(%s)!\n", dev_attr_touchkey_firm_version_phone.attr.name);
	}
	if (device_create_file(sec_touchkey, &dev_attr_touchkey_firm_version_panel)< 0)	{
		printk(KERN_ERR "Failed to create device file(%s)!\n", dev_attr_touchkey_firm_version_panel.attr.name);
	}
	if (device_create_file(sec_touchkey, &dev_attr_touchkey_brightness)< 0)	{
		printk(KERN_ERR "Failed to create device file(%s)!\n", dev_attr_touchkey_brightness.attr.name);
	}
	/*end N1_firmware_sync*/

	ret = misc_register(&touchkey_update_device);
	if (ret) {
		printk(KERN_ERR "[TouchKey] %s misc_register fail\n", __func__);
	}

	if (device_create_file(touchkey_update_device.this_device, &dev_attr_touch_version) < 0) {
		printk(KERN_ERR "[TouchKey] %s device_create_file fail dev_attr_touch_version\n",  __func__);
	}

	if (device_create_file(touchkey_update_device.this_device, &dev_attr_touch_update) < 0) {
		printk(KERN_ERR "[TouchKey] %s device_create_file fail dev_attr_touch_update\n", __func__);
	}

	if (device_create_file(touchkey_update_device.this_device, &dev_attr_brightness) < 0) {
		printk(KERN_ERR "[TouchKey] %s device_create_file fail dev_attr_touch_update\n", __func__);
	}

	if (device_create_file(touchkey_update_device.this_device, &dev_attr_enable_disable) < 0) {
		printk(KERN_ERR "[TouchKey] %s device_create_file fail dev_attr_touch_update\n", __func__);
	}

	if (device_create_file(touchkey_update_device.this_device, &dev_attr_touchkey_menu) < 0) {
		printk(KERN_ERR	"%s device_create_file fail dev_attr_touchkey_menu\n",__func__);
	}

	if (device_create_file(touchkey_update_device.this_device, &dev_attr_touchkey_back) < 0) {
		printk(KERN_ERR "%s device_create_file fail dev_attr_touchkey_back\n", __func__);
	}

	if (device_create_file(touchkey_update_device.this_device, &dev_attr_touch_sensitivity) < 0) {
		printk("%s device_create_file fail dev_attr_touch_sensitivity\n", __func__);
	}

	touchkey_wq = create_singlethread_workqueue("melfas_touchkey_wq");
	if (!touchkey_wq) {
		return -ENOMEM;
	}

	INIT_WORK(&touchkey_work, touchkey_work_func);

	init_hw();

	ret = i2c_add_driver(&touchkey_i2c_driver);

	if (ret) {
		printk(KERN_ERR "[TouchKey] melfas touch keypad registration failed, module not inserted.ret= %d\n", ret);
	}

	/* Cypress Firmware Update>>>>>>>>>>
	   i2c_touchkey_read(KEYCODE_REG, data, 3);
	   printk(KERN_ERR"%s F/W version: 0x%x, Module version:0x%x\n", __FUNCTION__, data[1], data[2]);
	   retry = 3;

	   touch_version = data[1];
	   module_version = data[2];

	   // Firmware check & Update
	   if((module_version == DOOSUNGTECH_TOUCH_V1_2)&& (touch_version != TOUCH_FIRMWARE_V04)){
	   touchkey_update_status=1;
	   while (retry--) {
	   if (ISSP_main() == 0) {
	   printk(KERN_ERR"[TOUCHKEY]Touchkey_update succeeded\n");
	   touchkey_update_status=0;
	   break;
	   }
	   printk(KERN_ERR"touchkey_update failed... retry...\n");
	   }
	   if (retry <= 0) {
	   // disable ldo11
	   touchkey_ldo_on(0);
	   touchkey_update_status=-1;
	   msleep(300);

	   }

	   init_hw();	//after update, re initalize.
	   } else {
	   if(module_version != DOOSUNGTECH_TOUCH_V1_2){
	   printk(KERN_ERR "[TouchKey] Not F/W update. Cypess touch-key module is not DOOSUNG TECH. \n");
	   } else if(touch_version == TOUCH_FIRMWARE_V04){
	   printk(KERN_ERR "[TouchKey] Not F/W update. Cypess touch-key F/W version is latest. \n");
	   } else {
	   printk(KERN_ERR "[TouchKey] Not F/W update. Cypess touch-key version(module or F/W) is not valid. \n");
	   }
	   }

	   <<<<<<<<<<<<<< Cypress Firmware Update */

	return ret;
}
Exemplo n.º 18
0
static int msm8930_s5k6a2ya_vreg_off(void)
{
	int rc = 0;
	pr_info("[CAM] %s\n", __func__);

	/* reset pin */
	rc = gpio_request(CAM_PIN_GPIO_CAM2_RSTz, "s5k6a2ya");
	pr_info("[CAM] reset pin gpio_request, %d\n", CAM_PIN_GPIO_CAM2_RSTz);
	if (rc < 0)
		pr_err("[CAM] GPIO(%d) request failed", CAM_PIN_GPIO_CAM2_RSTz);
	else {
		gpio_direction_output(CAM_PIN_GPIO_CAM2_RSTz, 0);
		gpio_free(CAM_PIN_GPIO_CAM2_RSTz);
	}
	udelay(50);

	/* analog */
	pr_info("[CAM] sensor_power_disable(\"8038_l8\") == %d\n", rc);
	rc = camera_sensor_power_disable(reg_8038_l8);
	if (rc < 0)
		pr_err("[CAM] sensor_power_disable(\"reg_8038_l8\") FAILED %d\n", rc);
	udelay(50);

	/* 2nd digital */
	rc = gpio_request(CAM_PIN_GPIO_V_CAM2_D1V2_EN, "V_CAM2_D1V2_EN");
	pr_info("[CAM] 2nd cam digital gpio_request, %d\n", CAM_PIN_GPIO_V_CAM2_D1V2_EN);
	if (rc < 0)
		pr_err("[CAM] GPIO(%d) request failed", CAM_PIN_GPIO_V_CAM2_D1V2_EN);
	else {
		gpio_direction_output(CAM_PIN_GPIO_V_CAM2_D1V2_EN, 0);
		gpio_free(CAM_PIN_GPIO_V_CAM2_D1V2_EN);
	}
	msleep(1);

	/* digital */
	rc = gpio_request(CAM_PIN_GPIO_V_CAM_D1V8_EN, "V_CAM_D1V8_EN");
	pr_info("[CAM] digital gpio_request, %d\n", CAM_PIN_GPIO_V_CAM_D1V8_EN);
	if (rc < 0)
		pr_err("[CAM] GPIO(%d) request failed", CAM_PIN_GPIO_V_CAM_D1V8_EN);
	else {
		gpio_tlmm_config(
			GPIO_CFG(CAM_PIN_GPIO_V_CAM_D1V8_EN, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
			GPIO_CFG_ENABLE);
		gpio_direction_output(CAM_PIN_GPIO_V_CAM_D1V8_EN, 0);
		gpio_free(CAM_PIN_GPIO_V_CAM_D1V8_EN);
	}
	udelay(50);

	/* IO */
	rc = gpio_request(CAM_PIN_GPIO_V_CAMIO_1V8_EN, "V_CAMIO_1V8_EN");
	pr_info("[CAM] cam io gpio_request, %d\n", CAM_PIN_GPIO_V_CAMIO_1V8_EN);
	if (rc < 0)
		pr_err("[CAM] GPIO(%d) request failed", CAM_PIN_GPIO_V_CAMIO_1V8_EN);
	else {
		gpio_direction_output(CAM_PIN_GPIO_V_CAMIO_1V8_EN, 0);
		gpio_free(CAM_PIN_GPIO_V_CAMIO_1V8_EN);
	}

	/* VCM PD */
	rc = gpio_request(CAM_PIN_GPIO_CAM_VCM_PD, "CAM_VCM_PD");
	pr_info("[CAM] vcm pd gpio_request, %d\n", CAM_PIN_GPIO_CAM_VCM_PD);
	if (rc < 0)
		pr_err("[CAM] GPIO(%d) request failed", CAM_PIN_GPIO_CAM_VCM_PD);
	else {
		gpio_direction_output(CAM_PIN_GPIO_CAM_VCM_PD, 0);
		gpio_free(CAM_PIN_GPIO_CAM_VCM_PD);
	}
	udelay(50);

	/* VCM */
	pr_info("[CAM] sensor_power_disable(\"reg_8038_l17\") == %d\n", rc);
	rc = camera_sensor_power_disable(reg_8038_l17);
	if (rc < 0)
		pr_err("[CAM] sensor_power_disable(\"reg_8038_l17\") FAILED %d\n", rc);

	/* MIPI Switch */
	rc = gpio_request(CAM_PIN_GPIO_CAM2_SEL, "CAM2_SEL");
	pr_info("[CAM] cam sel gpio_request, %d\n", CAM_PIN_GPIO_CAM2_SEL);
	if (rc < 0)
		pr_err("[CAM] GPIO(%d) request failed", CAM_PIN_GPIO_CAM2_SEL);
	else {
		gpio_direction_output(CAM_PIN_GPIO_CAM2_SEL, 0);
		gpio_free(CAM_PIN_GPIO_CAM2_SEL);
	}
	udelay(50);

	return rc;
}
Exemplo n.º 19
0
static int wm97xx_bat_probe(struct platform_device *dev)
{
	int ret = 0;
	int props = 1;	/* POWER_SUPPLY_PROP_PRESENT */
	int i = 0;
	struct wm97xx_pdata *wmdata = dev->dev.platform_data;
	struct wm97xx_batt_pdata *pdata;

	if (!wmdata) {
		dev_err(&dev->dev, "No platform data supplied\n");
		return -EINVAL;
	}

	pdata = wmdata->batt_pdata;

	if (dev->id != -1)
		return -EINVAL;

	if (!pdata) {
		dev_err(&dev->dev, "No platform_data supplied\n");
		return -EINVAL;
	}

	if (gpio_is_valid(pdata->charge_gpio)) {
		ret = gpio_request(pdata->charge_gpio, "BATT CHRG");
		if (ret)
			goto err;
		ret = gpio_direction_input(pdata->charge_gpio);
		if (ret)
			goto err2;
		ret = request_irq(gpio_to_irq(pdata->charge_gpio),
				wm97xx_chrg_irq, 0,
				"AC Detect", dev);
		if (ret)
			goto err2;
		props++;	/* POWER_SUPPLY_PROP_STATUS */
	}

	if (pdata->batt_tech >= 0)
		props++;	/* POWER_SUPPLY_PROP_TECHNOLOGY */
	if (pdata->temp_aux >= 0)
		props++;	/* POWER_SUPPLY_PROP_TEMP */
	if (pdata->batt_aux >= 0)
		props++;	/* POWER_SUPPLY_PROP_VOLTAGE_NOW */
	if (pdata->max_voltage >= 0)
		props++;	/* POWER_SUPPLY_PROP_VOLTAGE_MAX */
	if (pdata->min_voltage >= 0)
		props++;	/* POWER_SUPPLY_PROP_VOLTAGE_MIN */

	prop = kzalloc(props * sizeof(*prop), GFP_KERNEL);
	if (!prop) {
		ret = -ENOMEM;
		goto err3;
	}

	prop[i++] = POWER_SUPPLY_PROP_PRESENT;
	if (pdata->charge_gpio >= 0)
		prop[i++] = POWER_SUPPLY_PROP_STATUS;
	if (pdata->batt_tech >= 0)
		prop[i++] = POWER_SUPPLY_PROP_TECHNOLOGY;
	if (pdata->temp_aux >= 0)
		prop[i++] = POWER_SUPPLY_PROP_TEMP;
	if (pdata->batt_aux >= 0)
		prop[i++] = POWER_SUPPLY_PROP_VOLTAGE_NOW;
	if (pdata->max_voltage >= 0)
		prop[i++] = POWER_SUPPLY_PROP_VOLTAGE_MAX;
	if (pdata->min_voltage >= 0)
		prop[i++] = POWER_SUPPLY_PROP_VOLTAGE_MIN;

	INIT_WORK(&bat_work, wm97xx_bat_work);

	if (!pdata->batt_name) {
		dev_info(&dev->dev, "Please consider setting proper battery "
				"name in platform definition file, falling "
				"back to name \"wm97xx-batt\"\n");
		bat_psy_desc.name = "wm97xx-batt";
	} else
		bat_psy_desc.name = pdata->batt_name;

	bat_psy_desc.properties = prop;
	bat_psy_desc.num_properties = props;

	bat_psy = power_supply_register(&dev->dev, &bat_psy_desc, NULL);
	if (!IS_ERR(bat_psy)) {
		schedule_work(&bat_work);
	} else {
		ret = PTR_ERR(bat_psy);
		goto err4;
	}

	return 0;
err4:
	kfree(prop);
err3:
	if (gpio_is_valid(pdata->charge_gpio))
		free_irq(gpio_to_irq(pdata->charge_gpio), dev);
err2:
	if (gpio_is_valid(pdata->charge_gpio))
		gpio_free(pdata->charge_gpio);
err:
	return ret;
}
Exemplo n.º 20
0
static int msm8930_s5k4e5yx_vreg_on(void)
{
	int rc;
	pr_info("[CAM] %s\n", __func__);

	/* VCM */
	rc = camera_sensor_power_enable("8038_l17", 2800000, &reg_8038_l17);
	pr_info("[CAM] vcm sensor_power_enable(\"8038_l17\", 2.8V) == %d\n", rc);
	if (rc < 0) {
		pr_err("[CAM] sensor_power_enable(\"8038_l17\", 2.8V) FAILED %d\n", rc);
		goto enable_s5k4e5yx_vcm_fail;
	}
	udelay(50);

	/* digital */
	rc = gpio_request(CAM_PIN_GPIO_V_CAM_D1V8_EN, "V_CAM_D1V8_EN");
	pr_info("[CAM] digital gpio_request, %d\n", CAM_PIN_GPIO_V_CAM_D1V8_EN);
	if (rc < 0) {
		pr_err("[CAM] GPIO(%d) request failed", CAM_PIN_GPIO_V_CAM_D1V8_EN);
		goto enable_s5k4e5yx_digital_fail;
	}

	gpio_tlmm_config(
		GPIO_CFG(CAM_PIN_GPIO_V_CAM_D1V8_EN, 0, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_2MA),
		GPIO_CFG_ENABLE);
	gpio_direction_output(CAM_PIN_GPIO_V_CAM_D1V8_EN, 1);
	gpio_free(CAM_PIN_GPIO_V_CAM_D1V8_EN);
	udelay(50);

	/* analog */
	rc = camera_sensor_power_enable("8038_l8", 2800000, &reg_8038_l8);
	pr_info("[CAM] analog sensor_power_enable(\"8038_l8\", 2.8V) == %d\n", rc);
	if (rc < 0) {
		pr_err("[CAM] sensor_power_enable(\"8038_l8\", 2.8V) FAILED %d\n", rc);
		goto enable_s5k4e5yx_analog_fail;
	}
	udelay(50);

	/* IO */
	rc = gpio_request(CAM_PIN_GPIO_V_CAMIO_1V8_EN, "V_CAMIO_1V8_EN");
	pr_info("[CAM] cam io gpio_request, %d\n", CAM_PIN_GPIO_V_CAMIO_1V8_EN);
	if (rc < 0) {
		pr_err("[CAM] GPIO(%d) request failed", CAM_PIN_GPIO_V_CAMIO_1V8_EN);
		goto enable_s5k4e5yx_io_fail;
	}
	gpio_direction_output(CAM_PIN_GPIO_V_CAMIO_1V8_EN, 1);
	gpio_free(CAM_PIN_GPIO_V_CAMIO_1V8_EN);
	udelay(50);

	return rc;

enable_s5k4e5yx_io_fail:
	camera_sensor_power_disable(reg_8038_l8);
enable_s5k4e5yx_analog_fail:
	rc = gpio_request(CAM_PIN_GPIO_V_CAM_D1V8_EN, "V_CAM_D1V8_EN");
	if (rc < 0)
		pr_err("[CAM] GPIO(%d) request failed", CAM_PIN_GPIO_V_CAM_D1V8_EN);
	else {
		gpio_direction_output(CAM_PIN_GPIO_V_CAM_D1V8_EN, 0);
		gpio_free(CAM_PIN_GPIO_V_CAM_D1V8_EN);
	}
enable_s5k4e5yx_digital_fail:
	camera_sensor_power_disable(reg_8038_l17);
enable_s5k4e5yx_vcm_fail:
	return rc;
}
Exemplo n.º 21
0
static int mipi_dsi_on(struct platform_device *pdev)
{
	int ret = 0;
	u32 clk_rate;
	struct msm_fb_data_type *mfd;
	struct fb_info *fbi;
	struct fb_var_screeninfo *var;
	struct msm_panel_info *pinfo;
	struct mipi_panel_info *mipi;
	u32 hbp, hfp, vbp, vfp, hspw, vspw, width, height;
	u32 ystride, bpp, data;
	u32 dummy_xres, dummy_yres;
	int target_type = 0;

	pr_debug("%s+:\n", __func__);

	mfd = platform_get_drvdata(pdev);
	fbi = mfd->fbi;
	var = &fbi->var;
	pinfo = &mfd->panel_info;
	esc_byte_ratio = pinfo->mipi.esc_byte_ratio;

	if (mipi_dsi_pdata && mipi_dsi_pdata->dsi_power_save)
		mipi_dsi_pdata->dsi_power_save(1);

	cont_splash_clk_ctrl(0);
	mipi_dsi_prepare_clocks();

	mipi_dsi_ahb_ctrl(1);

	clk_rate = mfd->fbi->var.pixclock;
	clk_rate = min(clk_rate, mfd->panel_info.clk_max);

	mipi_dsi_phy_ctrl(1);

	if (mdp_rev == MDP_REV_42 && mipi_dsi_pdata)
		target_type = mipi_dsi_pdata->target_type;

	mipi_dsi_phy_init(0, &(mfd->panel_info), target_type);

	mipi_dsi_clk_enable();

	MIPI_OUTP(MIPI_DSI_BASE + 0x114, 1);
	MIPI_OUTP(MIPI_DSI_BASE + 0x114, 0);

	hbp = var->left_margin;
	hfp = var->right_margin;
	vbp = var->upper_margin;
	vfp = var->lower_margin;
	hspw = var->hsync_len;
	vspw = var->vsync_len;
	width = mfd->panel_info.xres;
	height = mfd->panel_info.yres;

	mipi  = &mfd->panel_info.mipi;
	if (mfd->panel_info.type == MIPI_VIDEO_PANEL) {
		dummy_xres = mfd->panel_info.lcdc.xres_pad;
		dummy_yres = mfd->panel_info.lcdc.yres_pad;

		if (mdp_rev >= MDP_REV_41) {
			MIPI_OUTP(MIPI_DSI_BASE + 0x20,
				((hspw + hbp + width + dummy_xres) << 16 |
				(hspw + hbp)));
			MIPI_OUTP(MIPI_DSI_BASE + 0x24,
				((vspw + vbp + height + dummy_yres) << 16 |
				(vspw + vbp)));
			MIPI_OUTP(MIPI_DSI_BASE + 0x28,
				(vspw + vbp + height + dummy_yres +
					vfp - 1) << 16 | (hspw + hbp +
					width + dummy_xres + hfp - 1));
		} else {
			/* DSI_LAN_SWAP_CTRL */
			MIPI_OUTP(MIPI_DSI_BASE + 0x00ac, mipi->dlane_swap);

			MIPI_OUTP(MIPI_DSI_BASE + 0x20,
				((hbp + width + dummy_xres) << 16 | (hbp)));
			MIPI_OUTP(MIPI_DSI_BASE + 0x24,
				((vbp + height + dummy_yres) << 16 | (vbp)));
			MIPI_OUTP(MIPI_DSI_BASE + 0x28,
				(vbp + height + dummy_yres + vfp) << 16 |
					(hbp + width + dummy_xres + hfp));
		}

		MIPI_OUTP(MIPI_DSI_BASE + 0x2c, (hspw << 16));
		MIPI_OUTP(MIPI_DSI_BASE + 0x30, 0);
		MIPI_OUTP(MIPI_DSI_BASE + 0x34, (vspw << 16));

	} else {		/* command mode */
		if (mipi->dst_format == DSI_CMD_DST_FORMAT_RGB888)
			bpp = 3;
		else if (mipi->dst_format == DSI_CMD_DST_FORMAT_RGB666)
			bpp = 3;
		else if (mipi->dst_format == DSI_CMD_DST_FORMAT_RGB565)
			bpp = 2;
		else
			bpp = 3;	/* Default format set to RGB888 */

		ystride = width * bpp + 1;

		/* DSI_COMMAND_MODE_MDP_STREAM_CTRL */
		data = (ystride << 16) | (mipi->vc << 8) | DTYPE_DCS_LWRITE;
		MIPI_OUTP(MIPI_DSI_BASE + 0x5c, data);
		MIPI_OUTP(MIPI_DSI_BASE + 0x54, data);

		/* DSI_COMMAND_MODE_MDP_STREAM_TOTAL */
		data = height << 16 | width;
		MIPI_OUTP(MIPI_DSI_BASE + 0x60, data);
		MIPI_OUTP(MIPI_DSI_BASE + 0x58, data);
	}

	mipi_dsi_host_init(mipi);

#ifdef CONFIG_SHLCDC_BOARD /* CUST_ID_00142 */
#ifdef CONFIG_SHDISP_PANEL_FLUTE

#else
	if (mipi->force_clk_lane_hs) {
		u32 tmp;

		tmp = MIPI_INP(MIPI_DSI_BASE + 0xA8);
		tmp |= (1<<28);
		MIPI_OUTP(MIPI_DSI_BASE + 0xA8, tmp);
		wmb();
	}
#endif
#else /* CONFIG_SHLCDC_BOARD */
	if (mipi->force_clk_lane_hs) {
		u32 tmp;

		tmp = MIPI_INP(MIPI_DSI_BASE + 0xA8);
		tmp |= (1<<28);
		MIPI_OUTP(MIPI_DSI_BASE + 0xA8, tmp);
		wmb();
	}
#endif /* CONFIG_SHLCDC_BOARD */

	if (mdp_rev >= MDP_REV_41)
		mutex_lock(&mfd->dma->ov_mutex);
	else
		down(&mfd->dma->mutex);

	ret = panel_next_on(pdev);

	mipi_dsi_op_mode_config(mipi->mode);

	if (mfd->panel_info.type == MIPI_CMD_PANEL) {
		if (pinfo->lcd.vsync_enable) {
			if (pinfo->lcd.hw_vsync_mode && vsync_gpio >= 0) {
				if (mdp_rev >= MDP_REV_41) {
					if (gpio_request(vsync_gpio,
						"MDP_VSYNC") == 0)
						gpio_direction_input(
							vsync_gpio);
					else
						pr_err("%s: unable to \
							request gpio=%d\n",
							__func__, vsync_gpio);
				} else if (mdp_rev == MDP_REV_303) {
					if (!tlmm_settings && gpio_request(
						vsync_gpio, "MDP_VSYNC") == 0) {
						ret = gpio_tlmm_config(
							GPIO_CFG(
							vsync_gpio, 1,
							GPIO_CFG_INPUT,
							GPIO_CFG_PULL_DOWN,
							GPIO_CFG_2MA),
							GPIO_CFG_ENABLE);

						if (ret) {
							pr_err(
							"%s: unable to config \
							tlmm = %d\n",
							__func__, vsync_gpio);
						}
						tlmm_settings = TRUE;

						gpio_direction_input(
							vsync_gpio);
					} else {
						if (!tlmm_settings) {
							pr_err(
							"%s: unable to request \
							gpio=%d\n",
							__func__, vsync_gpio);
						}
					}
				}
Exemplo n.º 22
0
static int msm8930_s5k6a1gx_vreg_on(void)
{
	int rc;
	pr_info("[CAM] %s\n", __func__);

	/* VCM */
	rc = camera_sensor_power_enable("8038_l17", 2800000, &reg_8038_l17);
	pr_info("[CAM] sensor_power_enable(\"8038_l17\", 2.8V) == %d\n", rc);
	if (rc < 0) {
		pr_err("[CAM] sensor_power_enable(\"8038_l17\", 2.8V) FAILED %d\n", rc);
		goto enable_s5k6a1gx_vcm_fail;
	}
	udelay(50);

	/* digital */
	rc = gpio_request(CAM_PIN_GPIO_V_CAM_D1V8_EN, "V_CAM_D1V8_EN");
	pr_info("[CAM] digital gpio_request, %d\n", CAM_PIN_GPIO_V_CAM_D1V8_EN);
	if (rc < 0) {
		pr_err("[CAM] GPIO(%d) request failed", CAM_PIN_GPIO_V_CAM_D1V8_EN);
		goto enable_s5k6a1gx_digital_fail;
	}
	gpio_tlmm_config(
		GPIO_CFG(CAM_PIN_GPIO_V_CAM_D1V8_EN, 0, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_2MA),
		GPIO_CFG_ENABLE);
	gpio_direction_output(CAM_PIN_GPIO_V_CAM_D1V8_EN, 1);
	gpio_free(CAM_PIN_GPIO_V_CAM_D1V8_EN);


	/* VCM PD */ /* TODO */
	rc = gpio_request(CAM_PIN_GPIO_CAM_VCM_PD, "CAM_VCM_PD");
	pr_info("[CAM] vcm pd gpio_request, %d\n", CAM_PIN_GPIO_CAM_VCM_PD);
	if (rc < 0 && rc != -EBUSY) {
		pr_err("[CAM] GPIO(%d) request failed", CAM_PIN_GPIO_CAM_VCM_PD);
		goto enable_s5k6a1gx_vcm_pd;
	} else
		rc = 0;
	gpio_direction_output(CAM_PIN_GPIO_CAM_VCM_PD, 1);
	gpio_free(CAM_PIN_GPIO_CAM_VCM_PD);

	udelay(500);

	/* analog */
	rc = camera_sensor_power_enable("8038_l8", 2800000, &reg_8038_l8);
	pr_info("[CAM] sensor_power_enable(\"8038_l8\", 2.8V) == %d\n", rc);
	if (rc < 0) {
		pr_err("[CAM] sensor_power_enable(\"8038_l8\", 2.8V) FAILED %d\n", rc);
		goto enable_s5k6a1gx_analog_fail;
	}
	udelay(50);

	/* IO */
	rc = gpio_request(CAM_PIN_GPIO_V_CAMIO_1V8_EN, "V_CAMIO_1V8_EN");
	pr_info("[CAM] cam io gpio_request, %d\n", CAM_PIN_GPIO_V_CAMIO_1V8_EN);
	if (rc < 0) {
		pr_err("[CAM] GPIO(%d) request failed", CAM_PIN_GPIO_V_CAMIO_1V8_EN);
		goto enable_s5k6a1gx_io_fail;
	}
	gpio_direction_output(CAM_PIN_GPIO_V_CAMIO_1V8_EN, 1);
	gpio_free(CAM_PIN_GPIO_V_CAMIO_1V8_EN);
	udelay(50);

	/* reset pin */
	rc = gpio_request(CAM_PIN_GPIO_CAM2_RSTz, "s5k6a1gx");
	pr_info("[CAM] reset pin gpio_request, %d\n", CAM_PIN_GPIO_CAM2_RSTz);
	if (rc < 0) {
		pr_err("[CAM] GPIO(%d) request failed", CAM_PIN_GPIO_CAM2_RSTz);
		goto enable_s5k6a1gx_rst_fail;
	}
	gpio_direction_output(CAM_PIN_GPIO_CAM2_RSTz, 1);
	gpio_free(CAM_PIN_GPIO_CAM2_RSTz);
	udelay(50);

	/* 2nd cam digital */
	rc = gpio_request(CAM_PIN_GPIO_V_CAM2_D1V2_EN, "V_CAM2_D1V2_EN");
	pr_info("[CAM] 2nd cam digital gpio_request, %d\n", CAM_PIN_GPIO_V_CAM2_D1V2_EN);
	if (rc < 0) {
		pr_err("[CAM] GPIO(%d) request failed", CAM_PIN_GPIO_V_CAM2_D1V2_EN);
		goto enable_s5k6a1gx_2nd_digital_fail;
	}
	gpio_direction_output(CAM_PIN_GPIO_V_CAM2_D1V2_EN, 1);
	gpio_free(CAM_PIN_GPIO_V_CAM2_D1V2_EN);
	msleep(1);

	return rc;

enable_s5k6a1gx_2nd_digital_fail:
	rc = gpio_request(CAM_PIN_GPIO_CAM2_RSTz, "s5k6a1gx");
	if (rc < 0)
		pr_err("[CAM] GPIO(%d) request failed", CAM_PIN_GPIO_CAM2_RSTz);
	else {
		gpio_direction_output(CAM_PIN_GPIO_CAM2_RSTz, 0);
		gpio_free(CAM_PIN_GPIO_CAM2_RSTz);
	}
enable_s5k6a1gx_rst_fail:
	rc = gpio_request(CAM_PIN_GPIO_V_CAMIO_1V8_EN, "V_CAMIO_1V8_EN");
	if (rc < 0)
		pr_err("[CAM] GPIO(%d) request failed", CAM_PIN_GPIO_V_CAMIO_1V8_EN);
	else {
		gpio_direction_output(CAM_PIN_GPIO_V_CAMIO_1V8_EN, 0);
		gpio_free(CAM_PIN_GPIO_V_CAMIO_1V8_EN);
	}

enable_s5k6a1gx_io_fail:
	camera_sensor_power_disable(reg_8038_l8);
enable_s5k6a1gx_analog_fail:
	rc = gpio_request(CAM_PIN_GPIO_CAM_VCM_PD, "CAM_VCM_PD");
	if (rc < 0)
		pr_err("[CAM] GPIO(%d) request failed", CAM_PIN_GPIO_CAM_VCM_PD);
	else {
		gpio_direction_output(CAM_PIN_GPIO_CAM_VCM_PD, 0);
		gpio_free(CAM_PIN_GPIO_CAM_VCM_PD);
	}
enable_s5k6a1gx_vcm_pd:
	rc = gpio_request(CAM_PIN_GPIO_V_CAM_D1V8_EN, "V_CAM_D1V8_EN");
	if (rc < 0)
		pr_err("[CAM] GPIO(%d) request failed", CAM_PIN_GPIO_V_CAM_D1V8_EN);
	else {
		gpio_direction_output(CAM_PIN_GPIO_V_CAM_D1V8_EN, 0);
		gpio_free(CAM_PIN_GPIO_V_CAM_D1V8_EN);
	}
enable_s5k6a1gx_digital_fail:
	camera_sensor_power_disable(reg_8038_l17);
enable_s5k6a1gx_vcm_fail:

	return rc;
}
Exemplo n.º 23
0
static int bcm43457_bluetooth_probe(struct platform_device *pdev)
{
	int rc = 0;
	int ret;

	pr_info("[BT] bcm4354_bluetooth_probe.\n");

	bt_gpio.bt_en = of_get_gpio(pdev->dev.of_node, 0);

	rc = gpio_request(bt_gpio.bt_en, "bten_gpio");

	if (unlikely(rc)) {
		pr_err("[BT] bt_gpio.bt_en request failed.\n");
		return rc;
	}

	bt_gpio.bt_wake =of_get_gpio(pdev->dev.of_node, 1);

	rc = gpio_request(bt_gpio.bt_wake, "btwake_gpio");

	if (unlikely(rc)) {
		pr_err("[BT] bt_gpio.bt_wake request failed.\n");
		gpio_free(bt_gpio.bt_en);
		return rc;
	}

	bt_gpio.bt_hostwake =of_get_gpio(pdev->dev.of_node, 2);

	rc = gpio_request(bt_gpio.bt_hostwake,"bthostwake_gpio");

	if (unlikely(rc)) {
		pr_err("[BT] bt_gpio.bt_hostwake request failed.\n");
		gpio_free(bt_gpio.bt_wake);
		gpio_free(bt_gpio.bt_en);
		return rc;
	}

	gpio_direction_input(bt_gpio.bt_hostwake);
	gpio_direction_output(bt_gpio.bt_wake, 0);
	gpio_direction_output(bt_gpio.bt_en, 0);

	bt_rfkill = rfkill_alloc("bcm43457 Bluetooth", &pdev->dev,
				RFKILL_TYPE_BLUETOOTH, &bcm43457_bt_rfkill_ops,
				NULL);

	if (unlikely(!bt_rfkill)) {
		pr_err("[BT] bt_rfkill alloc failed.\n");
		gpio_free(bt_gpio.bt_hostwake);
		gpio_free(bt_gpio.bt_wake);
		gpio_free(bt_gpio.bt_en);
		return -ENOMEM;
	}

	rfkill_init_sw_state(bt_rfkill, 0);

	rc = rfkill_register(bt_rfkill);

	if (unlikely(rc)) {
		pr_err("[BT] bt_rfkill register failed.\n");
		rfkill_destroy(bt_rfkill);
		gpio_free(bt_gpio.bt_hostwake);
		gpio_free(bt_gpio.bt_wake);
		gpio_free(bt_gpio.bt_en);
		return -1;
	}

	rfkill_set_sw_state(bt_rfkill, true);

#ifdef BT_LPM_ENABLE
	ret = bcm_bt_lpm_init(pdev);
	if (ret) {
		rfkill_unregister(bt_rfkill);
		rfkill_destroy(bt_rfkill);

		gpio_free(bt_gpio.bt_hostwake);
		gpio_free(bt_gpio.bt_wake);
		gpio_free(bt_gpio.bt_en);
	}
#endif
	pr_info("[BT] bcm43457_bluetooth_probe End \n");
	return rc;
}
Exemplo n.º 24
0
static int __devinit gpio_keys_setup_key(struct platform_device *pdev,
					 struct input_dev *input,
					 struct gpio_button_data *bdata,
					 const struct gpio_keys_button *button)
{
	const char *desc = button->desc ? button->desc : "gpio_keys";
	struct device *dev = &pdev->dev;
	irq_handler_t isr;
	unsigned long irqflags;
	int irq, error;

	bdata->input = input;
	bdata->button = button;
	spin_lock_init(&bdata->lock);

	if (gpio_is_valid(button->gpio)) {

		error = gpio_request(button->gpio, desc);
		if (error < 0) {
			dev_err(dev, "Failed to request GPIO %d, error %d\n",
				button->gpio, error);
			return error;
		}

		error = gpio_direction_input(button->gpio);
		if (error < 0) {
			dev_err(dev,
				"Failed to configure direction for GPIO %d, error %d\n",
				button->gpio, error);
			goto fail;
		}

		if (button->debounce_interval) {
			error = gpio_set_debounce(button->gpio,
					button->debounce_interval * 1000);
			/* use timer if gpiolib doesn't provide debounce */
			if (error < 0)
				bdata->timer_debounce =
						button->debounce_interval;
		}

		irq = gpio_to_irq(button->gpio);
		if (irq < 0) {
			error = irq;
			dev_err(dev,
				"Unable to get irq number for GPIO %d, error %d\n",
				button->gpio, error);
			goto fail;
		}
		bdata->irq = irq;

		INIT_WORK(&bdata->work, gpio_keys_gpio_work_func);
		setup_timer(&bdata->timer,
			    gpio_keys_gpio_timer, (unsigned long)bdata);

		isr = gpio_keys_gpio_isr;
		irqflags = IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING;

	} else {
		if (!button->irq) {
			dev_err(dev, "No IRQ specified\n");
			return -EINVAL;
		}
		bdata->irq = button->irq;

		if (button->type && button->type != EV_KEY) {
			dev_err(dev, "Only EV_KEY allowed for IRQ buttons.\n");
			return -EINVAL;
		}

		bdata->timer_debounce = button->debounce_interval;
		setup_timer(&bdata->timer,
			    gpio_keys_irq_timer, (unsigned long)bdata);

		isr = gpio_keys_irq_isr;
		irqflags = 0;
	}

	input_set_capability(input, button->type ?: EV_KEY, button->code);

	/*
	 * If platform has specified that the button can be disabled,
	 * we don't want it to share the interrupt line.
	 */
	if (!button->can_disable)
		irqflags |= IRQF_SHARED;

	error = request_any_context_irq(bdata->irq, isr, irqflags, desc, bdata);
	if (error < 0) {
		dev_err(dev, "Unable to claim irq %d; error %d\n",
			bdata->irq, error);
		goto fail;
	}

	return 0;

fail:
	if (gpio_is_valid(button->gpio))
		gpio_free(button->gpio);

	return error;
}
Exemplo n.º 25
0
/*
 * ftn for video
 */
static int s5p_tv_v_open(struct file *file)
{
	int ret = 0,err;
	unsigned int status;
	ref_count_tv ++ ;
	mutex_lock(mutex_for_fo);

	if (s5ptv_status.tvout_output_enable) {
		mutex_unlock(mutex_for_fo);
		goto re_open;
		BASEPRINTK("tvout drv. already used !!\n");
		ret =  -EBUSY;
		goto drv_used;
	}

#ifdef CONFIG_CPU_S5PC110
	s5p_tv_clk_gate( true );
#endif
	
#ifdef CONFIG_CPU_S5PC110

#if defined(CONFIG_S5PC110_KEPLER_BOARD)//Kepler

	err = gpio_request(S5PC11X_GPJ4(4),"TV_EN");
	udelay(50);
	gpio_direction_output(S5PC11X_GPJ4(4),1);
	gpio_set_value(S5PC11X_GPJ4(4),1);
	udelay(50);

	err = gpio_request(S5PC11X_GPJ2(6),"EAR_SEL");
	udelay(50);
	gpio_direction_output(S5PC11X_GPJ2(6),0);
	gpio_set_value(S5PC11X_GPJ2(6),0);
	udelay(50);

#elif (defined CONFIG_S5PC110_T959_BOARD)//T959
	status=get_headset_status();
	printk("s5p_tv_v_open: get_headset_status:%d\n",status);
	
	if((SEC_HEADSET_3_POLE_DEVICE==status)||(SEC_TVOUT_DEVICE==status))
	{
		printk("EAR_SEL:Low\n");
		err = gpio_request(S5PC11X_GPJ2(6),"EAR_SEL"); //GPIO_EARPATH_SEL
		udelay(50);
		gpio_direction_output(S5PC11X_GPJ2(6),0);
		gpio_set_value(S5PC11X_GPJ2(6),0);
		udelay(50);
	}
	else if(SEC_HEADSET_4_POLE_DEVICE==status)
	{
		printk("EAR_SEL:High\n");
		err = gpio_request(S5PC11X_GPJ2(6),"EAR_SEL"); //GPIO_EARPATH_SEL
		udelay(50);
		gpio_direction_output(S5PC11X_GPJ2(6),0);
		gpio_set_value(S5PC11X_GPJ2(6),1);
		udelay(50);
	}

#endif

#endif

	_s5p_tv_if_init_param();

	s5p_tv_v4l2_init_param();

	mutex_unlock(mutex_for_fo);
	#if 0
	mutex_lock(mutex_for_i2c);
	/* for ddc(hdcp port) */
	if(s5ptv_status.hpd_status) {
		if (i2c_add_driver(&hdcp_i2c_driver)) 
			BASEPRINTK("HDCP port add failed\n");
		hdcp_i2c_drv_state = true;
	} else 
		hdcp_i2c_drv_state = false;

	mutex_unlock(mutex_for_i2c);
	#endif
	printk("\n\nTV open success\n\n");
re_open:
	/* for i2c probing */
	udelay(100);
	
	return 0;

drv_used:
	mutex_unlock(mutex_for_fo);
	return ret;
}
Exemplo n.º 26
0
int gpio_event_input_func(struct gpio_event_input_devs *input_devs,
			struct gpio_event_info *info, void **data, int func)
{
	int ret;
	int i;
	unsigned long irqflags;
	struct gpio_event_input_info *di;
	struct gpio_input_state *ds = *data;
	struct kobject *keyboard_kobj;

	di = container_of(info, struct gpio_event_input_info, info);

#ifdef CONFIG_POWER_KEY_CLR_RESET
	gis = di;
#endif

	if (func == GPIO_EVENT_FUNC_SUSPEND) {
		if (ds->use_irq)
			for (i = 0; i < di->keymap_size; i++)
				disable_irq(gpio_to_irq(di->keymap[i].gpio));
#ifndef CONFIG_MFD_MAX8957
		hrtimer_cancel(&ds->timer);
#endif
		return 0;
	}
	if (func == GPIO_EVENT_FUNC_RESUME) {
		spin_lock_irqsave(&ds->irq_lock, irqflags);
		if (ds->use_irq)
			for (i = 0; i < di->keymap_size; i++)
				enable_irq(gpio_to_irq(di->keymap[i].gpio));
#ifndef CONFIG_MFD_MAX8957
		hrtimer_start(&ds->timer, ktime_set(0, 0), HRTIMER_MODE_REL);
#endif
		spin_unlock_irqrestore(&ds->irq_lock, irqflags);
		return 0;
	}

	if (func == GPIO_EVENT_FUNC_INIT) {
		if (ktime_to_ns(di->poll_time) <= 0)
			di->poll_time = ktime_set(0, 20 * NSEC_PER_MSEC);

		*data = ds = kzalloc(sizeof(*ds) + sizeof(ds->key_state[0]) *
					di->keymap_size, GFP_KERNEL);
		if (ds == NULL) {
			ret = -ENOMEM;
			KEY_LOGE("KEY_ERR: %s: "
				"Failed to allocate private data\n", __func__);
			goto err_ds_alloc_failed;
		}
		ds->debounce_count = di->keymap_size;
		ds->input_devs = input_devs;
		ds->info = di;
		wake_lock_init(&ds->wake_lock, WAKE_LOCK_SUSPEND, "gpio_input");
#ifdef CONFIG_MFD_MAX8957
		wake_lock_init(&ds->key_pressed_wake_lock, WAKE_LOCK_SUSPEND, "pwr_key_pressed");
#endif
#ifdef CONFIG_POWER_KEY_CLR_RESET
		wake_lock_init(&key_reset_clr_wake_lock, WAKE_LOCK_SUSPEND, "gpio_input_pwr_clear");
#endif
		spin_lock_init(&ds->irq_lock);
		if (board_build_flag() == 0)
			ds->debug_log = 0;
		else
			ds->debug_log = 1;

		for (i = 0; i < di->keymap_size; i++) {
			int dev = di->keymap[i].dev;
			if (dev >= input_devs->count) {
				KEY_LOGE("KEY_ERR: %s: bad device "
					"index %d >= %d for key code %d\n",
					__func__, dev, input_devs->count,
					di->keymap[i].code);
				ret = -EINVAL;
				goto err_bad_keymap;
			}
			input_set_capability(input_devs->dev[dev], di->type,
					     di->keymap[i].code);
			ds->key_state[i].ds = ds;
			ds->key_state[i].debounce = DEBOUNCE_UNKNOWN;
		}

		for (i = 0; i < di->keymap_size; i++) {
			ret = gpio_request(di->keymap[i].gpio, "gpio_kp_in");
			if (ret) {
				KEY_LOGE("KEY_ERR: %s: gpio_request "
					"failed for %d\n", __func__, di->keymap[i].gpio);
				goto err_gpio_request_failed;
			}
			ret = gpio_direction_input(di->keymap[i].gpio);
			if (ret) {
				KEY_LOGE("KEY_ERR: %s: "
					"gpio_direction_input failed for %d\n",
					__func__, di->keymap[i].gpio);
				goto err_gpio_configure_failed;
			}
		}

		if (di->setup_input_gpio)
			di->setup_input_gpio();
#ifdef CONFIG_MFD_MAX8957
		ki_queue = create_singlethread_workqueue("ki_queue");
#endif

		ret = gpio_event_input_request_irqs(ds);

		keyboard_kobj = kobject_create_and_add("keyboard", NULL);
		if (keyboard_kobj == NULL) {
			KEY_LOGE("KEY_ERR: %s: subsystem_register failed\n", __func__);
			ret = -ENOMEM;
			return ret;
		}
		if (sysfs_create_file(keyboard_kobj, &dev_attr_vol_wakeup.attr))
			KEY_LOGE("KEY_ERR: %s: sysfs_create_file "
					"return %d\n", __func__, ret);
		wakeup_bitmask = 0;
		set_wakeup = 0;
		spin_lock_irqsave(&ds->irq_lock, irqflags);
		ds->use_irq = ret == 0;

		KEY_LOGI("GPIO Input Driver: Start gpio inputs for %s%s in %s "
			"mode\n", input_devs->dev[0]->name,
			(input_devs->count > 1) ? "..." : "",
			ret == 0 ? "interrupt" : "polling");

#ifndef CONFIG_MFD_MAX8957
		hrtimer_init(&ds->timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
		ds->timer.function = gpio_event_input_timer_func;
		hrtimer_start(&ds->timer, ktime_set(0, 0), HRTIMER_MODE_REL);
#endif
		spin_unlock_irqrestore(&ds->irq_lock, irqflags);
		return 0;
	}

	ret = 0;
	spin_lock_irqsave(&ds->irq_lock, irqflags);
#ifndef CONFIG_MFD_MAX8957
	hrtimer_cancel(&ds->timer);
#endif
	if (ds->use_irq) {
		for (i = di->keymap_size - 1; i >= 0; i--) {
			free_irq(gpio_to_irq(di->keymap[i].gpio),
				 &ds->key_state[i]);
		}
	}
	spin_unlock_irqrestore(&ds->irq_lock, irqflags);

	for (i = di->keymap_size - 1; i >= 0; i--) {
err_gpio_configure_failed:
		gpio_free(di->keymap[i].gpio);
err_gpio_request_failed:
		;
	}
err_bad_keymap:
	wake_lock_destroy(&ds->wake_lock);
#ifdef CONFIG_MFD_MAX8957
	wake_lock_destroy(&ds->key_pressed_wake_lock);
#endif
#ifdef CONFIG_POWER_KEY_CLR_RESET
	wake_lock_destroy(&key_reset_clr_wake_lock);
#endif
	kfree(ds);
err_ds_alloc_failed:
	return ret;
}
Exemplo n.º 27
0
static int __init at91_cf_probe(struct platform_device *pdev)
{
	struct at91_cf_socket	*cf;
	struct at91_cf_data	*board = pdev->dev.platform_data;
	struct resource		*io;
	int			status;

	if (!board || !board->det_pin || !board->rst_pin)
		return -ENODEV;

	io = platform_get_resource(pdev, IORESOURCE_MEM, 0);
	if (!io)
		return -ENODEV;

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

	cf->board = board;
	cf->pdev = pdev;
	cf->phys_baseaddr = io->start;
	platform_set_drvdata(pdev, cf);

	/* must be a GPIO; ergo must trigger on both edges */
	status = gpio_request(board->det_pin, "cf_det");
	if (status < 0)
		goto fail0;
	status = request_irq(board->det_pin, at91_cf_irq, 0, driver_name, cf);
	if (status < 0)
		goto fail00;
	device_init_wakeup(&pdev->dev, 1);

	status = gpio_request(board->rst_pin, "cf_rst");
	if (status < 0)
		goto fail0a;

	if (board->vcc_pin) {
		status = gpio_request(board->vcc_pin, "cf_vcc");
		if (status < 0)
			goto fail0b;
	}

	/*
	 * The card driver will request this irq later as needed.
	 * but it causes lots of "irqNN: nobody cared" messages
	 * unless we report that we handle everything (sigh).
	 * (Note:  DK board doesn't wire the IRQ pin...)
	 */
	if (board->irq_pin) {
		status = gpio_request(board->irq_pin, "cf_irq");
		if (status < 0)
			goto fail0c;
		status = request_irq(board->irq_pin, at91_cf_irq,
				IRQF_SHARED, driver_name, cf);
		if (status < 0)
			goto fail0d;
		cf->socket.pci_irq = board->irq_pin;
	} else
		cf->socket.pci_irq = nr_irqs + 1;

	/* pcmcia layer only remaps "real" memory not iospace */
	cf->socket.io_offset = (unsigned long)
			ioremap(cf->phys_baseaddr + CF_IO_PHYS, SZ_2K);
	if (!cf->socket.io_offset) {
		status = -ENXIO;
		goto fail1;
	}

	/* reserve chip-select regions */
	if (!request_mem_region(io->start, io->end + 1 - io->start,
				driver_name)) {
		status = -ENXIO;
		goto fail1;
	}

	pr_info("%s: irqs det #%d, io #%d\n", driver_name,
		board->det_pin, board->irq_pin);

	cf->socket.owner = THIS_MODULE;
	cf->socket.dev.parent = &pdev->dev;
	cf->socket.ops = &at91_cf_ops;
	cf->socket.resource_ops = &pccard_static_ops;
	cf->socket.features = SS_CAP_PCCARD | SS_CAP_STATIC_MAP
				| SS_CAP_MEM_ALIGN;
	cf->socket.map_size = SZ_2K;
	cf->socket.io[0].res = io;

	status = pcmcia_register_socket(&cf->socket);
	if (status < 0)
		goto fail2;

	return 0;

fail2:
	release_mem_region(io->start, io->end + 1 - io->start);
fail1:
	if (cf->socket.io_offset)
		iounmap((void __iomem *) cf->socket.io_offset);
	if (board->irq_pin) {
		free_irq(board->irq_pin, cf);
fail0d:
		gpio_free(board->irq_pin);
	}
fail0c:
	if (board->vcc_pin)
		gpio_free(board->vcc_pin);
fail0b:
	gpio_free(board->rst_pin);
fail0a:
	device_init_wakeup(&pdev->dev, 0);
	free_irq(board->det_pin, cf);
fail00:
	gpio_free(board->det_pin);
fail0:
	kfree(cf);
	return status;
}
Exemplo n.º 28
0
static int lbee9qmb_rfkill_btwake_probe(struct platform_device *pdev)
{
	struct lbee9qmb_platform_data *plat = pdev->dev.platform_data;
	struct rfkill *rfkill;

	int rc;
	int irq;
	int ret;
	int host_wake;

	if (!plat) {
		dev_err(&pdev->dev, "no platform data\n");
		return -ENOSYS;
	}
	
	wake_lock_init(&bt_lpm.bt_wake_lock, WAKE_LOCK_SUSPEND,
				"bt_wake");
#ifdef BRCM_HOST_WAKE
	wake_lock_init(&bt_lpm.host_wake_lock, WAKE_LOCK_SUSPEND,
				"host_wake");
	bt_lpm.gpio_host_wake=plat->gpio_hostwake;
	//spin_lock_init(&bt_lpm.bt_lock);
	INIT_WORK(&bt_lpm.host_wake_work, brcm_host_wake_work_func);
#endif

	rc = gpio_request(plat->gpio_btwake, "lbee9qmb_reset_btwake");
	if (rc < 0) {
		dev_err(&pdev->dev, "gpio_request failed\n");
		return rc;
	}

	rfkill = rfkill_alloc("lbee9qmb-rfkill_btwake", &pdev->dev,
			RFKILL_TYPE_BLUETOOTH, &lbee9qmb_rfkill_btwake_ops, pdev);
	if (!rfkill) {
		rc = -ENOMEM;
		goto fail_gpio;
	}
	platform_set_drvdata(pdev, rfkill);
	gpio_direction_output(plat->gpio_btwake, 1);
	
	rc = rfkill_register(rfkill);
	if (rc < 0)
		goto fail_alloc;

#ifdef BRCM_HOST_WAKE
	rc = gpio_request(plat->gpio_hostwake, "lbee9qmb_reset_hostwake");
	gpio_direction_input(plat->gpio_hostwake);
	host_wake=gpio_get_value(bt_lpm.gpio_host_wake);
	irq = gpio_to_irq(plat->gpio_hostwake);
	bt_lpm.host_wake_irq=irq;
#ifdef BRCM_WAKELOCKTIMEOUT
	hrtimer_init(&bt_lpm.check_hostwakeup_timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
	bt_lpm.check_hostwakeup_delay = ktime_set(5, 0);  /* 5 sec */
	bt_lpm.check_hostwakeup_timer.function = check_hostwakeup;

	set_irq_type(irq, IRQ_TYPE_EDGE_RISING);
	
	ret = request_irq(irq, host_wake_isr, 0,
			"bt host_wake", NULL);
#else
	ret = request_irq(irq, host_wake_isr, IRQF_TRIGGER_HIGH,
			"bt host_wake", NULL);
#endif			
	
	printk(KERN_ERR "BRCM_LPM: irq=%d ret=%d HOST_WAKE=%d\n",irq,ret,host_wake);
#endif

	return 0;

fail_alloc:
	rfkill_destroy(rfkill);
fail_gpio:
	gpio_free(plat->gpio_btwake);

	return rc;
		
}
Exemplo n.º 29
0
static int Ruby_s5k3h2yx_vreg_on(void)
{
	int rc = 0;

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

	
	if (system_rev >= 3)
	rc = camera_sensor_power_enable("8058_l8", 2850000, &ruby_reg_8058_l8);
	else
	rc = camera_sensor_power_enable("8058_l10", 2850000, &ruby_reg_8058_l10);
	pr_info("[CAM] sensor_power_enable(\"8058_l10\", 2.8V) == %d\n", rc);
	if (rc < 0) {
		pr_err("[CAM] sensor_power_enable(\"8058_l10\", 2.8V) FAILED %d\n", rc);
		goto init_fail;
	}
	udelay(50);
	
	rc = camera_sensor_power_enable("8058_l24", 1200000, &ruby_reg_8058_l24);
	pr_info("[CAM] sensor_power_enable(\"8058_l24\", 1.2V) == %d\n", rc);
	if (rc < 0) {
		pr_err("[CAM] sensor_power_enable(\"8058_l24\", 1.2V) FAILED %d\n", rc);
		goto init_fail;
	}
	udelay(50);
	
	rc = camera_sensor_power_enable("8058_l9", 1800000, &ruby_reg_8058_l9);
	pr_info("[CAM] sensor_power_enable(\"8058_l9\", 1.8V) == %d\n", rc);
	if (rc < 0) {
		pr_err("[CAM] sensor_power_enable(\"8058_l9\", 1.8V) FAILED %d\n", rc);
		goto init_fail;
	}
	udelay(50);
	
	rc = camera_sensor_power_enable("8058_l15", 2800000, &ruby_reg_8058_l15);
	pr_info("[CAM] sensor_power_enable(\"8058_l15\", 2.8V) == %d\n", rc);
	if (rc < 0) {
		pr_err("[CAM] sensor_power_enable(\"8058_l15\", 2.8V) FAILED %d\n", rc);
		goto init_fail;
	}
	udelay(50);

	
	rc = camera_sensor_power_enable("8058_l12", 1800000, &ruby_reg_8058_l12);
	pr_info("[CAM] sensor_power_enable(\"8058_l12\", 1.8V) == %d\n", rc);
	if (rc < 0) {
		pr_err("[CAM] sensor_power_enable(\"8058_l12\", 1.8V) FAILED %d\n", rc);
		goto init_fail;
	}


	ruby_config_camera_on_gpios();

	rc = gpio_request(RUBY_GPIO_MCLK_SWITCH, "CAM_SEL");
	if (rc < 0)
	{
		pr_err("[CAM] GPIO (%d) request fail\n", RUBY_GPIO_MCLK_SWITCH);
		goto init_fail;
	}
	gpio_direction_output(RUBY_GPIO_MCLK_SWITCH, 1);
	gpio_free(RUBY_GPIO_MCLK_SWITCH);


init_fail:
	return rc;
}
Exemplo n.º 30
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();
}