Ejemplo n.º 1
0
static int p3_enable_clk_cs(struct p3_dev *p3_device)
{
	int ret_val = 0;
	struct spi_device *spidev = NULL;
	struct s3c64xx_spi_driver_data *sdd = NULL;

	//P3_DBG_MSG("%s CLK is %lu.\n", __func__, clock);

	spin_lock_irq(&p3_device->ese_spi_lock);
	spidev = spi_dev_get(p3_device->spi);
	spin_unlock_irq(&p3_device->ese_spi_lock);
	if (spidev == NULL) {
		P3_ERR_MSG("%s - Failed to get spi dev.\n", __func__);
		return -1;
	}

	sdd = spi_master_get_devdata(spidev->master);
	if (!sdd){
		P3_ERR_MSG("%s - Failed to get spi dev.\n", __func__);
		return -EFAULT;
	}
	pm_runtime_get_sync(&sdd->pdev->dev); /* Enable clk */

	/* set spi clock rate */
	//clk_set_rate(sdd->src_clk, clock * 2);

	p3_device->enabled_clk = true;
	spi_dev_put(spidev);

	/*  CS control*/
	gpio_set_value(p3_device->cs_gpio, 0);
	usleep_range(50,70);

	return ret_val;
}
Ejemplo n.º 2
0
static int __devinit pmic_probe(struct spi_device *spi)
{
	struct tps6524x *hw;
	struct device *dev = &spi->dev;
	const struct supply_info *info = supply_info;
	struct regulator_init_data *init_data;
	struct regulator_config config = { };
	int ret = 0, i;

	init_data = dev->platform_data;
	if (!init_data) {
		dev_err(dev, "could not find regulator platform data\n");
		return -EINVAL;
	}

	hw = devm_kzalloc(&spi->dev, sizeof(struct tps6524x), GFP_KERNEL);
	if (!hw) {
		dev_err(dev, "cannot allocate regulator private data\n");
		return -ENOMEM;
	}
	spi_set_drvdata(spi, hw);

	memset(hw, 0, sizeof(struct tps6524x));
	hw->dev = dev;
	hw->spi = spi_dev_get(spi);
	mutex_init(&hw->lock);

	for (i = 0; i < N_REGULATORS; i++, info++, init_data++) {
		hw->desc[i].name	= info->name;
		hw->desc[i].id		= i;
		hw->desc[i].n_voltages	= info->n_voltages;
		hw->desc[i].ops		= &regulator_ops;
		hw->desc[i].type	= REGULATOR_VOLTAGE;
		hw->desc[i].owner	= THIS_MODULE;

		if (info->flags & FIXED_VOLTAGE)
			hw->desc[i].n_voltages = 1;

		config.dev = dev;
		config.init_data = init_data;
		config.driver_data = hw;

		hw->rdev[i] = regulator_register(&hw->desc[i], &config);
		if (IS_ERR(hw->rdev[i])) {
			ret = PTR_ERR(hw->rdev[i]);
			hw->rdev[i] = NULL;
			goto fail;
		}
	}

	return 0;

fail:
	pmic_remove(spi);
	return ret;
}
Ejemplo n.º 3
0
/* Normal World */
static int p61_ioctl_config_spi_gpio(
    struct p61_dev *p61_device)
{
    struct spi_device *spidev = NULL;
    int ret_val = 0;

    if (!p61_device->isGpio_cfgDone) {
        pr_info("%s SET_SPI_CONFIGURATION\n", __func__);
        spin_lock_irq(&p61_device->ese_spi_lock);
        spidev = spi_dev_get(p61_device->spi);
        spin_unlock_irq(&p61_device->ese_spi_lock);
#if 0
        ret_val = ese_spi_request_gpios(spidev);
        if (ret_val < 0)
            pr_err("%s: couldn't config spi gpio\n", __func__);
#endif
        p61_device->isGpio_cfgDone = true;

        p61_device->null_buffer =
            kmalloc(DEFAULT_BUFFER_SIZE, GFP_KERNEL);
        if (p61_device->null_buffer == NULL) {
            ret_val = -ENOMEM;
            pr_err("%s null_buffer == NULL, -ENOMEM\n",
                   __func__);
            //goto vfsspi_open_out;
        }
        p61_device->buffer =
            kmalloc(DEFAULT_BUFFER_SIZE, GFP_KERNEL);
        if (p61_device->buffer == NULL) {
            ret_val = -ENOMEM;
            kfree(p61_device->null_buffer);
            pr_err("%s buffer == NULL, -ENOMEM\n",
                   __func__);
            //goto vfsspi_open_out;
        }

        spi_dev_put(spidev);
        usleep_range(950, 1000);
    }
    return ret_val;
}
Ejemplo n.º 4
0
static int p3_set_clk(struct p3_dev *p3_device, unsigned long arg)
{
	int ret_val = 0;
	unsigned long clock = 0;
	struct spi_device *spidev = NULL;
	struct s3c64xx_spi_driver_data *sdd = NULL;

	if (arg >= 100000)
		clock = arg;
	else
		return -1;
	P3_DBG_MSG("%s CLK is %lu.\n", __func__, clock);

	spin_lock_irq(&p3_device->ese_spi_lock);
	spidev = spi_dev_get(p3_device->spi);
	spin_unlock_irq(&p3_device->ese_spi_lock);
	if (spidev == NULL) {
		P3_ERR_MSG("%s - Failed to get spi dev.\n", __func__);
		return -1;
	}

	//if (clock < 10000)
	//	clock = P3_SPI_CLOCK;
	spidev->max_speed_hz = (u32)clock;

	sdd = spi_master_get_devdata(spidev->master);
	if (!sdd){
		P3_ERR_MSG("%s - Failed to get spi dev.\n", __func__);
		return -EFAULT;
	}
	/*pm_runtime_get_sync(&sdd->pdev->dev);*/ /*Need to move to Enable*/
	/*P3_DBG_MSG("%s pm_runtime_get_sync.\n", __func__);*/

	/* set spi clock rate */
	clk_set_rate(sdd->src_clk, clock * 2);

	spi_dev_put(spidev);

	return ret_val;
}
Ejemplo n.º 5
0
static int p3_disable_clk_cs(struct p3_dev *p3_device)
{
	int ret_val = 0;
	//unsigned short clock = 0;
	struct spi_device *spidev = NULL;
	struct s3c64xx_spi_driver_data *sdd = NULL;

	if (!p3_device->enabled_clk) {
		P3_ERR_MSG("%s - clock was not enabled!\n", __func__);
		return ret_val;
	}

	/* CS High */
	gpio_set_value(p3_device->cs_gpio, 1);

	spin_lock_irq(&p3_device->ese_spi_lock);
	spidev = spi_dev_get(p3_device->spi);
	spin_unlock_irq(&p3_device->ese_spi_lock);
	if (spidev == NULL) {
		P3_ERR_MSG("%s - Failed to get spi dev!\n", __func__);
		return -1;
	}

	P3_DBG_MSG("%s DISABLE_SPI_CLOCK\n", __func__);

	sdd = spi_master_get_devdata(spidev->master);
	if (!sdd){
		P3_ERR_MSG("%s - Failed to get spi dev.\n", __func__);
		return -EFAULT;
	}

	p3_device->enabled_clk = false;
	pm_runtime_put(&sdd->pdev->dev);

	spi_dev_put(spidev);

	return ret_val;
}
Ejemplo n.º 6
0
static int p61_disable_clk(struct p61_dev *p61_device)
{
    int ret_val = 0;
    struct spi_device *spidev = NULL;
    struct s3c64xx_spi_driver_data *sdd = NULL;

    if (!p61_device->enabled_clk) {
        pr_err("%s - clock was not enabled!\n", __func__);
        return ret_val;
    }

    spin_lock_irq(&p61_device->ese_spi_lock);
    spidev = spi_dev_get(p61_device->spi);
    spin_unlock_irq(&p61_device->ese_spi_lock);
    if (spidev == NULL) {
        pr_err("%s - Failed to get spi dev!\n", __func__);
        return -1;
    }

    sdd = spi_master_get_devdata(spidev->master);
    if (!sdd) {
        pr_err("%s - Failed to get spi dev.\n", __func__);
        return -1;
    }

    p61_device->enabled_clk = false;
    pm_runtime_put(&sdd->pdev->dev); /* Disable clock */

    spi_dev_put(spidev);

    //CS disable
    gpio_set_value(p61_device->cspin, 1);
    if (wake_lock_active(&p61_device->ese_lock)) {
        pr_info("%s: [NFC-ESE] wake unlock.\n", __func__);
        wake_unlock(&p61_device->ese_lock);
    }
    return ret_val;
}
Ejemplo n.º 7
0
static int p3_enable_clk(struct p3_dev *p3_device)
{
	int ret_val = 0;
	struct spi_device *spidev = NULL;
	struct s3c64xx_spi_driver_data *sdd = NULL;

	/* for defence MULTI-OPEN */
	if (p3_device->enabled_clk) {
		P3_ERR_MSG("%s - clock was ALREADY enabled!\n", __func__);
		return -EBUSY;
	}

	spin_lock_irq(&p3_device->ese_spi_lock);
	spidev = spi_dev_get(p3_device->spi);
	spin_unlock_irq(&p3_device->ese_spi_lock);
	if (spidev == NULL) {
		P3_ERR_MSG("%s - Failed to get spi dev.\n", __func__);
		return -1;
	}

	sdd = spi_master_get_devdata(spidev->master);
	if (!sdd){
		P3_ERR_MSG("%s - Failed to get spi dev.\n", __func__);
		return -EFAULT;
	}
	pm_runtime_get_sync(&sdd->pdev->dev); /* Enable clk */

	/* set spi clock rate */
	clk_set_rate(sdd->src_clk, spidev->max_speed_hz * 2);
#ifdef FEATURE_ESE_WAKELOCK
	wake_lock(&p3_device->ese_lock);
#endif
	p3_device->enabled_clk = true;
	spi_dev_put(spidev);

	return ret_val;
}
Ejemplo n.º 8
0
static int p61_set_clk(struct p61_dev *p61_device)
{
    int ret_val = 0;
    struct spi_device *spidev = NULL;
    struct s3c64xx_spi_driver_data *sdd = NULL;

    spin_lock_irq(&p61_device->ese_spi_lock);
    spidev = spi_dev_get(p61_device->spi);
    spin_unlock_irq(&p61_device->ese_spi_lock);
    if (spidev == NULL) {
        pr_err("%s - Failed to get spi dev\n", __func__);
        return -1;
    }

    spidev->max_speed_hz = P61_SPI_CLOCK;
    sdd = spi_master_get_devdata(spidev->master);
    if (!sdd) {
        pr_err("%s - Failed to get spi dev.\n", __func__);
        return -1;
    }
    pm_runtime_get_sync(&sdd->pdev->dev); /* Enable clk */

    /* set spi clock rate */
    clk_set_rate(sdd->src_clk, spidev->max_speed_hz * 2);

    p61_device->enabled_clk = true;
    spi_dev_put(spidev);

    //CS enable
    gpio_set_value(p61_device->cspin, 0);
    usleep_range(50, 70);
    if (!wake_lock_active(&p61_device->ese_lock)) {
        pr_info("%s: [NFC-ESE] wake lock.\n", __func__);
        wake_lock(&p61_device->ese_lock);
    }
    return ret_val;
}
Ejemplo n.º 9
0
static int p3_disable_clk(struct p3_dev *p3_device)
{
	int ret_val = 0;
	//unsigned short clock = 0;
	struct spi_device *spidev = NULL;
	struct s3c64xx_spi_driver_data *sdd = NULL;

	if (!p3_device->enabled_clk) {
		P3_ERR_MSG("%s - clock was not enabled!\n", __func__);
		return ret_val;
	}

	spin_lock_irq(&p3_device->ese_spi_lock);
	spidev = spi_dev_get(p3_device->spi);
	spin_unlock_irq(&p3_device->ese_spi_lock);
	if (spidev == NULL) {
		P3_ERR_MSG("%s - Failed to get spi dev!\n", __func__);
		return -1;
	}

	sdd = spi_master_get_devdata(spidev->master);
	if (!sdd){
		P3_ERR_MSG("%s - Failed to get spi dev.\n", __func__);
		return -EFAULT;
	}

	p3_device->enabled_clk = false;
	pm_runtime_put_sync(&sdd->pdev->dev); /* Disable clock */

	spi_dev_put(spidev);
#ifdef FEATURE_ESE_WAKELOCK
	if (wake_lock_active(&p3_device->ese_lock))
		wake_unlock(&p3_device->ese_lock);
#endif
	return ret_val;
}