static int yacd5c1sbdbc_vreg_init(void)
{
	int rc = 0;
	pr_err("%s:%d\n", __func__, __LINE__);

	rc = sgpio_init(sgpios, CAMIO_MAX);
	if (rc < 0) {
		SKYCERR("%s: sgpio_init failed \n", __func__);
		goto sensor_init_fail;
	}

	rc = svreg_init(svregs, CAMV_MAX);
	if (rc < 0) {
		SKYCERR("%s: svreg_init failed \n", __func__);
		goto sensor_init_fail;
	}

	return rc;

#if 0
#if 0        
    if (vreg_l16_2p8 == NULL) {
        vreg_l16_2p8 = regulator_get(NULL, "8921_l16");
        if (IS_ERR(vreg_l16_2p8)) {
        	printk("%s: vreg_l16_2p8 get failed \n", __func__);
            vreg_l16_2p8 = NULL;
            return -ENODEV;
        }

		rc = regulator_set_voltage(vreg_l16_2p8, 2800000, 2800000);
		if (rc) {
			printk("%s: unable to set vreg_l16_2p8 voltage to 2.8V\n", __func__);
			goto fail;
		}
    }
    
    if (vreg_s4_1p8 == NULL) {
        vreg_s4_1p8 = regulator_get(NULL, "8921_s4");
        if (IS_ERR(vreg_s4_1p8)) {
        	printk("%s: vreg_s4_1p8 get failed \n", __func__);
            vreg_s4_1p8 = NULL;
            return -ENODEV;
        }
		rc = regulator_set_voltage(vreg_s4_1p8, 1800000, 1800000);
		if (rc) {
			printk("%s: unable to set vreg_s4_1p8 voltage to 1.8V\n", __func__);
			goto fail;
		}
    }
#endif

#if 1 //wsyang_temp for 2M
    if (vreg_lvs5_1p8 == NULL) {
        vreg_lvs5_1p8 = regulator_get(NULL, "8921_lvs5");
        if (IS_ERR(vreg_lvs5_1p8)) {
        	printk("%s: vreg_lvs5_1p8 get failed \n", __func__);
            vreg_lvs5_1p8 = NULL;
            return -ENODEV;
        }
//		rc = regulator_set_voltage(vreg_lvs5_1p8, 1800000, 1800000);
//		if (rc) {
//			SKYCERR("%s: unable to set vreg_lvs5_1p8 voltage to 1.8V\n", __func__);
//			goto fail;
//		}
    }

    if (vreg_lvs6_1p8 == NULL) {
        vreg_lvs6_1p8 = regulator_get(NULL, "8921_lvs6");
        if (IS_ERR(vreg_lvs6_1p8)) {
        	printk("%s: vreg_lvs6_1p8 get failed \n", __func__);
            vreg_lvs6_1p8 = NULL;
            return -ENODEV;
        }
//		rc = regulator_set_voltage(vreg_lvs6_1p8, 1800000, 1800000);
//		if (rc) {
//			printk("%s: unable to set vreg_lvs6_1p8 voltage to 1.8V\n", __func__);
//			goto fail;
//		}
    }

    if (vreg_l11_2p85 == NULL) {
        vreg_l11_2p85 = regulator_get(NULL, "8921_l11");
        if (IS_ERR(vreg_l11_2p85)) {
        	printk("%s: vreg_l11_2p85 get failed \n", __func__);
            vreg_l11_2p85 = NULL;
            return -ENODEV;
        }
        rc = regulator_set_voltage(vreg_l11_2p85, 2800000, 2800000);
//		rc = regulator_set_voltage(vreg_l11_2p85, 2850000, 2850000);
		if (rc) {
			printk("%s: unable to set vreg_l11_2p85 voltage to 2.8V\n", __func__);
			goto fail;
		}
    }    
#endif //wsyang_temp for 2M
    return rc;

fail:
	printk("%s Failed!:%d\n",__func__, __LINE__);
#if 0
	if(vreg_l16_2p8) {
		regulator_put(vreg_l16_2p8);
	}
	if(vreg_s4_1p8) {
		regulator_put(vreg_s4_1p8);
	}
#endif    
	if(vreg_lvs6_1p8) {
		regulator_put(vreg_lvs6_1p8);
	}
	if(vreg_l11_2p85) {
		regulator_put(vreg_l11_2p85);
	}
	if(vreg_lvs5_1p8) {
		regulator_put(vreg_lvs5_1p8);
	}
#endif
sensor_init_fail:
    return -ENODEV;
}
예제 #2
0
static mali_bool init_mali_clock(void)
{
	mali_bool ret = MALI_TRUE;

	gpu_power_state = 0;

	if (mali_clock != 0)
		return ret; // already initialized

	mali_dvfs_lock = _mali_osk_lock_init(_MALI_OSK_LOCKFLAG_NONINTERRUPTABLE
			| _MALI_OSK_LOCKFLAG_ONELOCK, 0, 0);
	if (mali_dvfs_lock == NULL)
		return _MALI_OSK_ERR_FAULT;

	if (mali_clk_set_rate(mali_gpu_clk, GPU_MHZ) == MALI_FALSE)
	{
		ret = MALI_FALSE;
		goto err_clock_get;
	}

	MALI_PRINT(("init_mali_clock mali_clock %p \n", mali_clock));


#ifdef CONFIG_REGULATOR
#if USING_MALI_PMM
	g3d_regulator = regulator_get(&mali_gpu_device.dev, "vdd_g3d");
#else
	g3d_regulator = regulator_get(NULL, "vdd_g3d");
#endif

	if (IS_ERR(g3d_regulator))
	{
		MALI_PRINT( ("MALI Error : failed to get vdd_g3d\n"));
		ret = MALI_FALSE;
		goto err_regulator;
	}

	regulator_enable(g3d_regulator);

	MALI_DEBUG_PRINT(1, ("= regulator_enable -> use cnt: %d \n",mali_regulator_get_usecount()));
	mali_regulator_set_voltage(mali_gpu_vol, mali_gpu_vol);
#endif

	MALI_DEBUG_PRINT(2, ("MALI Clock is set at mali driver\n"));


	MALI_DEBUG_PRINT(3,("::clk_put:: %s mali_parent_clock - normal\n", __FUNCTION__));
	MALI_DEBUG_PRINT(3,("::clk_put:: %s mpll_clock  - normal\n", __FUNCTION__));

	mali_clk_put(MALI_FALSE);

	return MALI_TRUE;


#ifdef CONFIG_REGULATOR
err_regulator:
	regulator_put(g3d_regulator);
#endif

err_clock_get:
	mali_clk_put(MALI_TRUE);

	return ret;
}
예제 #3
0
static void mop500_prox_deactivate(struct device *dev)
{
	regulator_disable(prox_regulator);
	regulator_put(prox_regulator);
}
int video_harden_regulator_disable(video_harden_dev_id_enum dev_id)
{
    int ret = 0;

    printk(KERN_INFO "dev_id is %d.\n", dev_id);

    ret = video_harden_device_id_check(dev_id);
    if (ret != 0) {
        return -1;
    }

    ret = down_interruptible(&video_harden_busy_lock);
	if (0 != ret) {
		printk(KERN_ERR "video_harden_busy_lock failed\n");
		return -1;
	}

    if ((video_harden_regulator_vote.vcodec_bit == 0)
     && (video_harden_regulator_vote.jpeg_bit == 0)
     && (video_harden_regulator_vote.isp_bit == 0)) {
        up(&video_harden_busy_lock);
        printk(KERN_ERR "Video harden regulator disable is already done! skip.\n");
        return -1;
    }

    switch (dev_id) {
        case VIDEO_HARDEN_DEV_ID_VCODEC: /* VCODEC */
            video_harden_regulator_vote.vcodec_bit    = 0;
            break;

        case VIDEO_HARDEN_DEV_ID_JPEG: /* JPEG */
            video_harden_regulator_vote.jpeg_bit      = 0;
            break;

        case VIDEO_HARDEN_DEV_ID_ISP: /* ISP */
            video_harden_regulator_vote.isp_bit       = 0;
            break;

        default:
            break;
    }

    if ((video_harden_regulator_vote.vcodec_bit == 0)
        && (video_harden_regulator_vote.jpeg_bit == 0)
        && (video_harden_regulator_vote.isp_bit == 0)) {
        /* AO_SC SC_PW_MTCMOS_DIS0 [0x834]: VIDEO HARDEN power off */
        if (NULL != media_pd_vdd) {
            ret = regulator_disable(media_pd_vdd);
            if (ret) {
                up(&video_harden_busy_lock);
                printk(KERN_ERR "Regulator vdec disable failed ret=%d.\n", ret);
                return -1;
            }
            regulator_put(media_pd_vdd);
            media_pd_vdd = NULL;
        }

        printk(KERN_INFO "video harden regulator disable is successful.\n");
    } else {
        printk(KERN_INFO "can't disable video harden Regulator, other module is runing on!.\n");
    }

    up(&video_harden_busy_lock);

    printk(KERN_INFO "%s, g_video_harden_vote is 0x%x.\n",
        __func__, *((unsigned int *)&video_harden_regulator_vote));

    return ret;
}
/**
 * db5500_keypad_probe() - Initialze the the keypad driver
 * @pdev: pointer to platform device structure
 *
 * This function will allocate and initialize the instance
 * data and request the irq and register to input subsystem driver.
 */
static int __devinit db5500_keypad_probe(struct platform_device *pdev)
{
	struct db5500_keypad_platform_data *plat;
	struct db5500_keypad *keypad;
	struct resource *res;
	struct input_dev *input;
	void __iomem *base;
	struct clk *clk;
	int ret;
	int irq;
	int i;

	plat = pdev->dev.platform_data;
	if (!plat) {
		dev_err(&pdev->dev, "invalid keypad platform data\n");
		ret = -EINVAL;
		goto out_ret;
	}

	irq = platform_get_irq(pdev, 0);
	if (irq < 0) {
		dev_err(&pdev->dev, "failed to get keypad irq\n");
		ret = -EINVAL;
		goto out_ret;
	}

	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
	if (res == NULL) {
		dev_err(&pdev->dev, "missing platform resources\n");
		ret = -EINVAL;
		goto out_ret;
	}

	res = request_mem_region(res->start, resource_size(res), pdev->name);
	if (!res) {
		dev_err(&pdev->dev, "failed to request I/O memory\n");
		ret = -EBUSY;
		goto out_ret;
	}

	base = ioremap(res->start, resource_size(res));
	if (!base) {
		dev_err(&pdev->dev, "failed to remap I/O memory\n");
		ret = -ENXIO;
		goto out_freerequest_memregions;
	}

	clk = clk_get(&pdev->dev, NULL);
	if (IS_ERR(clk)) {
		dev_err(&pdev->dev, "failed to clk_get\n");
		ret = PTR_ERR(clk);
		goto out_iounmap;
	}

	keypad = kzalloc(sizeof(struct db5500_keypad), GFP_KERNEL);
	if (!keypad) {
		dev_err(&pdev->dev, "failed to allocate keypad memory\n");
		ret = -ENOMEM;
		goto out_freeclk;
	}

	input = input_allocate_device();
	if (!input) {
		dev_err(&pdev->dev, "failed to input_allocate_device\n");
		ret = -ENOMEM;
		goto out_freekeypad;
	}

	keypad->regulator = regulator_get(&pdev->dev, "v-ape");
	if (IS_ERR(keypad->regulator)) {
		dev_err(&pdev->dev, "regulator_get failed\n");
		keypad->regulator = NULL;
		ret = -EINVAL;
		goto out_regulator_get;
	} else {
		ret = regulator_enable(keypad->regulator);
		if (ret < 0) {
			dev_err(&pdev->dev, "regulator_enable failed\n");
			goto out_regulator_enable;
		}
	}

	input->id.bustype = BUS_HOST;
	input->name = "db5500-keypad";
	input->dev.parent = &pdev->dev;

	input->keycode = keypad->keymap;
	input->keycodesize = sizeof(keypad->keymap[0]);
	input->keycodemax = ARRAY_SIZE(keypad->keymap);

	input_set_capability(input, EV_MSC, MSC_SCAN);

	__set_bit(EV_KEY, input->evbit);
	if (!plat->no_autorepeat)
		__set_bit(EV_REP, input->evbit);

	matrix_keypad_build_keymap(plat->keymap_data, KEYPAD_ROW_SHIFT,
				   input->keycode, input->keybit);

	ret = input_register_device(input);
	if (ret) {
		dev_err(&pdev->dev,
			"unable to register input device: %d\n", ret);
		goto out_freeinput;
	}

	keypad->irq	= irq;
	keypad->board	= plat;
	keypad->input	= input;
	keypad->base	= base;
	keypad->clk	= clk;

	INIT_DELAYED_WORK(&keypad->switch_work, db5500_gpio_switch_work);
	INIT_DELAYED_WORK(&keypad->gpio_work, db5500_gpio_release_work);

	clk_enable(keypad->clk);
if (!keypad->board->init) {
		dev_err(&pdev->dev, "init funtion not defined\n");
		ret = -EINVAL;
		goto out_unregisterinput;
	}

	if (keypad->board->init() < 0) {
		dev_err(&pdev->dev, "keyboard init config failed\n");
		ret = -EINVAL;
		goto out_unregisterinput;
	}

	if (!keypad->board->exit) {
		dev_err(&pdev->dev, "exit funtion not defined\n");
		ret = -EINVAL;
		goto out_unregisterinput;
	}

	if (keypad->board->exit() < 0) {
		dev_err(&pdev->dev,  "keyboard exit config failed\n");
		ret = -EINVAL;
		goto out_unregisterinput;
	}

	for (i = 0; i < keypad->board->krow; i++) {
		keypad->db5500_rows[i] = *plat->gpio_input_pins;
		keypad->gpio_input_irq[i] =
				GPIO_TO_IRQ(keypad->db5500_rows[i]);
		plat->gpio_input_pins++;
	}

	for (i = 0; i < keypad->board->kcol; i++) {
		keypad->db5500_cols[i] = *plat->gpio_output_pins;
		plat->gpio_output_pins++;
	}

	for (i = 0; i < keypad->board->krow; i++) {
		ret =  request_threaded_irq(keypad->gpio_input_irq[i],
				NULL, db5500_keypad_gpio_irq,
				IRQF_TRIGGER_FALLING | IRQF_NO_SUSPEND,
				"db5500-keypad-gpio", keypad);
		if (ret) {
			dev_err(&pdev->dev, "allocate gpio irq %d failed\n",
						keypad->gpio_input_irq[i]);
			goto out_unregisterinput;
		}
		enable_irq_wake(keypad->gpio_input_irq[i]);
	}

	ret = request_threaded_irq(keypad->irq, NULL, db5500_keypad_irq,
				   IRQF_ONESHOT, "db5500-keypad", keypad);
	if (ret) {
		dev_err(&pdev->dev, "allocate irq %d failed\n", keypad->irq);
		goto out_unregisterinput;
	}

	platform_set_drvdata(pdev, keypad);

	clk_disable(keypad->clk);
	regulator_disable(keypad->regulator);
	return 0;

out_unregisterinput:
	input_unregister_device(input);
	input = NULL;
	clk_disable(keypad->clk);
out_freeinput:
	input_free_device(input);
out_regulator_enable:
	regulator_put(keypad->regulator);
out_regulator_get:
	input_free_device(input);
out_freekeypad:
	kfree(keypad);
out_freeclk:
	clk_put(clk);
out_iounmap:
	iounmap(base);
out_freerequest_memregions:
	release_mem_region(res->start, resource_size(res));
out_ret:
	return ret;
}
static void tegra_vibrator_exit(void)
{
	regulator_put(tegra_vibrator_regulator);
}
static int msm_csid_release(struct csid_device *csid_dev)
{
	uint32_t irq;

	if (csid_dev->csid_state != CSID_POWER_UP) {
		pr_err("%s: csid invalid state %d\n", __func__,
			csid_dev->csid_state);
		return -EINVAL;
	}

	CDBG("%s:%d, hw_version = 0x%x\n", __func__, __LINE__,
		csid_dev->hw_version);

	irq = msm_camera_io_r(csid_dev->base +
		csid_dev->ctrl_reg->csid_reg.csid_irq_status_addr);
	msm_camera_io_w(irq, csid_dev->base +
		csid_dev->ctrl_reg->csid_reg.csid_irq_clear_cmd_addr);
	msm_camera_io_w(0, csid_dev->base +
		csid_dev->ctrl_reg->csid_reg.csid_irq_mask_addr);

	disable_irq(csid_dev->irq->start);

	if (csid_dev->hw_version == CSID_VERSION_V20) {
		msm_cam_clk_enable(&csid_dev->pdev->dev, csid_clk_info,
			csid_dev->csid_clk, csid_dev->num_clk, 0);

		msm_camera_enable_vreg(&csid_dev->pdev->dev,
			csid_8960_vreg_info, ARRAY_SIZE(csid_8960_vreg_info),
			NULL, 0, &csid_dev->csi_vdd, 0);

		msm_camera_config_vreg(&csid_dev->pdev->dev,
			csid_8960_vreg_info, ARRAY_SIZE(csid_8960_vreg_info),
			NULL, 0, &csid_dev->csi_vdd, 0);
	} else if (csid_dev->hw_version == CSID_VERSION_V22) {
		msm_cam_clk_enable(&csid_dev->pdev->dev,
			csid_clk_info,
			csid_dev->csid_clk,
			csid_dev->num_clk, 0);

		msm_camera_enable_vreg(&csid_dev->pdev->dev,
			csid_vreg_info, ARRAY_SIZE(csid_vreg_info),
			NULL, 0, &csid_dev->csi_vdd, 0);

		msm_camera_config_vreg(&csid_dev->pdev->dev,
			csid_vreg_info, ARRAY_SIZE(csid_vreg_info),
			NULL, 0, &csid_dev->csi_vdd, 0);
	} else if ((csid_dev->hw_version >= CSID_VERSION_V30 &&
		csid_dev->hw_version < CSID_VERSION_V31) ||
		(csid_dev->hw_version == CSID_VERSION_V40) ||
		(csid_dev->hw_version == CSID_VERSION_V31_1) ||
		(csid_dev->hw_version == CSID_VERSION_V31_3)) {
		msm_cam_clk_enable(&csid_dev->pdev->dev, csid_clk_info,
			csid_dev->csid_clk, csid_dev->num_clk, 0);
		msm_camera_enable_vreg(&csid_dev->pdev->dev,
			csid_vreg_info, ARRAY_SIZE(csid_vreg_info),
			NULL, 0, &csid_dev->csi_vdd, 0);
		msm_camera_config_vreg(&csid_dev->pdev->dev,
			csid_vreg_info, ARRAY_SIZE(csid_vreg_info),
			NULL, 0, &csid_dev->csi_vdd, 0);
	} else if ((csid_dev->hw_version == CSID_VERSION_V31) ||
		(csid_dev->hw_version == CSID_VERSION_V32) ||
		(csid_dev->hw_version == CSID_VERSION_V33) ||
		(csid_dev->hw_version == CSID_VERSION_V37) ||
		(csid_dev->hw_version == CSID_VERSION_V34)) {
		msm_cam_clk_enable(&csid_dev->pdev->dev, csid_clk_info,
			csid_dev->csid_clk, csid_dev->num_clk, 0);
		msm_camera_enable_vreg(&csid_dev->pdev->dev,
			csid_vreg_info, ARRAY_SIZE(csid_vreg_info),
			NULL, 0, &csid_dev->csi_vdd, 0);

		msm_camera_config_vreg(&csid_dev->pdev->dev,
			csid_vreg_info, ARRAY_SIZE(csid_vreg_info),
			NULL, 0, &csid_dev->csi_vdd, 0);
	} else {
		pr_err("%s:%d, invalid hw version : 0x%x", __func__, __LINE__,
			csid_dev->hw_version);
		return -EINVAL;
	}

	if (!IS_ERR_OR_NULL(csid_dev->reg_ptr)) {
		regulator_disable(csid_dev->reg_ptr);
		regulator_put(csid_dev->reg_ptr);
	}

	iounmap(csid_dev->base);
	csid_dev->base = NULL;
	csid_dev->csid_state = CSID_POWER_DOWN;
	return 0;
}
예제 #8
0
int __init acpuclk_cortex_init(struct platform_device *pdev,
	struct acpuclk_drv_data *data)
{
	unsigned long max_cpu_khz = 0;
	int i, rc;

	acpuclk_init_data = data;
	mutex_init(&acpuclk_init_data->lock);

	bus_perf_client = msm_bus_scale_register_client(
		acpuclk_init_data->bus_scale);
	if (!bus_perf_client) {
		pr_err("Unable to register bus client\n");
		BUG();
	}

	for (i = 0; i < NUM_SRC; i++) {
		if (!acpuclk_init_data->src_clocks[i].name)
			continue;
		acpuclk_init_data->src_clocks[i].clk =
			clk_get(&pdev->dev,
				acpuclk_init_data->src_clocks[i].name);
		BUG_ON(IS_ERR(acpuclk_init_data->src_clocks[i].clk));
		/*
		 * Prepare the PLLs because we enable/disable them
		 * in atomic context during power collapse/restore.
		 */
		BUG_ON(clk_prepare(acpuclk_init_data->src_clocks[i].clk));
	}

	/* Improve boot time by ramping up CPU immediately */
	for (i = 0; acpuclk_init_data->freq_tbl[i].khz != 0 &&
			acpuclk_init_data->freq_tbl[i].use_for_scaling; i++)
		max_cpu_khz = acpuclk_init_data->freq_tbl[i].khz;

	/* Initialize regulators */
	rc = increase_vdd(acpuclk_init_data->freq_tbl[i].vdd_cpu,
		acpuclk_init_data->freq_tbl[i].vdd_mem);
	if (rc)
		goto err_vdd;

	rc = regulator_enable(acpuclk_init_data->vdd_mem);
	if (rc) {
		dev_err(&pdev->dev, "regulator_enable for mem failed\n");
		goto err_vdd;
	}

	rc = regulator_enable(acpuclk_init_data->vdd_cpu);
	if (rc) {
		dev_err(&pdev->dev, "regulator_enable for cpu failed\n");
		goto err_vdd_cpu;
	}

	acpuclk_cortex_set_rate(0, max_cpu_khz, SETRATE_INIT);

	acpuclk_register(&acpuclk_cortex_data);
	cpufreq_table_init();

	return 0;

err_vdd_cpu:
	regulator_disable(acpuclk_init_data->vdd_mem);
err_vdd:
	regulator_put(acpuclk_init_data->vdd_mem);
	regulator_put(acpuclk_init_data->vdd_cpu);

	for (i = 0; i < NUM_SRC; i++) {
		if (!acpuclk_init_data->src_clocks[i].name)
			continue;
		clk_unprepare(acpuclk_init_data->src_clocks[i].clk);
		clk_put(acpuclk_init_data->src_clocks[i].clk);
	}
	return rc;
}
int msm_jpeg_platform_init(struct platform_device *pdev,
	struct resource **mem,
	void **base,
	int *irq,
	irqreturn_t (*handler) (int, void *),
	void *context)
{
	int rc = -1;
	int i = 0;
	int jpeg_irq;
	struct resource *jpeg_mem, *jpeg_io, *jpeg_irq_res;
	void *jpeg_base;
	struct msm_jpeg_device *pgmn_dev =
		(struct msm_jpeg_device *) context;

	pgmn_dev->state = MSM_JPEG_IDLE;

	jpeg_mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
	if (!jpeg_mem) {
		JPEG_PR_ERR("%s: no mem resource?\n", __func__);
		return -ENODEV;
	}

	jpeg_irq_res = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
	if (!jpeg_irq_res) {
		JPEG_PR_ERR("no irq resource?\n");
		return -ENODEV;
	}
	jpeg_irq = jpeg_irq_res->start;
	JPEG_DBG("%s base address: 0x%x, jpeg irq number: %d\n", __func__,
		jpeg_mem->start, jpeg_irq);

	pgmn_dev->jpeg_bus_client =
		msm_bus_scale_register_client(&msm_jpeg_bus_client_pdata);
	if (!pgmn_dev->jpeg_bus_client) {
		JPEG_PR_ERR("%s: Registration Failed!\n", __func__);
		pgmn_dev->jpeg_bus_client = 0;
		return -EINVAL;
	}
	msm_bus_scale_client_update_request(
		pgmn_dev->jpeg_bus_client, 1);

	jpeg_io = request_mem_region(jpeg_mem->start,
		resource_size(jpeg_mem), pdev->name);
	if (!jpeg_io) {
		JPEG_PR_ERR("%s: region already claimed\n", __func__);
		return -EBUSY;
	}

	jpeg_base = ioremap(jpeg_mem->start, resource_size(jpeg_mem));
	if (!jpeg_base) {
		rc = -ENOMEM;
		JPEG_PR_ERR("%s: ioremap failed\n", __func__);
		goto fail_remap;
	}

	pgmn_dev->jpeg_fs = regulator_get(&pgmn_dev->pdev->dev, "vdd");
	rc = regulator_enable(pgmn_dev->jpeg_fs);
	if (rc) {
		JPEG_PR_ERR("%s:%d]jpeg regulator get failed\n",
				__func__, __LINE__);
		goto fail_fs;
	}

	rc = msm_cam_clk_enable(&pgmn_dev->pdev->dev, jpeg_8x_clk_info,
	 pgmn_dev->jpeg_clk, ARRAY_SIZE(jpeg_8x_clk_info), 1);
	if (rc < 0) {
		JPEG_PR_ERR("%s: clk failed rc = %d\n", __func__, rc);
		goto fail_clk;
	}

	pgmn_dev->hw_version = readl_relaxed(jpeg_base +
		JPEG_HW_VERSION);
	JPEG_DBG_HIGH("%s:%d] jpeg HW version 0x%x", __func__, __LINE__,
		pgmn_dev->hw_version);

	pgmn_dev->jpeg_vbif = ioremap(VBIF_BASE_ADDRESS, VBIF_REGION_SIZE);
	if (!pgmn_dev->jpeg_vbif) {
		rc = -ENOMEM;
		JPEG_PR_ERR("%s:%d] ioremap failed\n", __func__, __LINE__);
		goto fail_vbif;
	}
	JPEG_DBG("%s:%d] jpeg_vbif 0x%x", __func__, __LINE__,
		(uint32_t)pgmn_dev->jpeg_vbif);

#ifdef CONFIG_MSM_IOMMU
	for (i = 0; i < pgmn_dev->iommu_cnt; i++) {
		rc = iommu_attach_device(pgmn_dev->domain,
				pgmn_dev->iommu_ctx_arr[i]);
		if (rc < 0) {
			rc = -ENODEV;
			JPEG_PR_ERR("%s: Device attach failed\n", __func__);
			goto fail_iommu;
		}
		JPEG_DBG("%s:%d] dom 0x%x ctx 0x%x", __func__, __LINE__,
					(uint32_t)pgmn_dev->domain,
					(uint32_t)pgmn_dev->iommu_ctx_arr[i]);
	}
#endif
	set_vbif_params(pgmn_dev, pgmn_dev->jpeg_vbif);

	rc = request_irq(jpeg_irq, handler, IRQF_TRIGGER_RISING, "jpeg",
		context);
	if (rc) {
		JPEG_PR_ERR("%s: request_irq failed, %d\n", __func__,
			jpeg_irq);
		goto fail_request_irq;
	}

	*mem  = jpeg_mem;
	*base = jpeg_base;
	*irq  = jpeg_irq;

	pgmn_dev->jpeg_client = msm_ion_client_create(-1, "camera/jpeg");
	JPEG_DBG("%s:%d] success\n", __func__, __LINE__);

	pgmn_dev->state = MSM_JPEG_INIT;
	return rc;

fail_request_irq:
#ifdef CONFIG_MSM_IOMMU
	for (i = 0; i < pgmn_dev->iommu_cnt; i++) {
		JPEG_PR_ERR("%s:%d] dom 0x%x ctx 0x%x", __func__, __LINE__,
					(uint32_t)pgmn_dev->domain,
					(uint32_t)pgmn_dev->iommu_ctx_arr[i]);
		iommu_detach_device(pgmn_dev->domain,
					pgmn_dev->iommu_ctx_arr[i]);
	}
#endif

fail_iommu:
	iounmap(pgmn_dev->jpeg_vbif);

fail_vbif:
	msm_cam_clk_enable(&pgmn_dev->pdev->dev, jpeg_8x_clk_info,
	pgmn_dev->jpeg_clk, ARRAY_SIZE(jpeg_8x_clk_info), 0);

fail_clk:
	rc = regulator_disable(pgmn_dev->jpeg_fs);
	if (!rc)
		regulator_put(pgmn_dev->jpeg_fs);
	else
		JPEG_PR_ERR("%s:%d] regulator disable failed %d",
			__func__, __LINE__, rc);
	pgmn_dev->jpeg_fs = NULL;

fail_fs:
	iounmap(jpeg_base);

fail_remap:
	release_mem_region(jpeg_mem->start, resource_size(jpeg_mem));
	JPEG_DBG("%s:%d] fail\n", __func__, __LINE__);
	return rc;
}
int msm_camera_config_vreg(struct device *dev, struct camera_vreg_t *cam_vreg,
		int num_vreg, enum msm_camera_vreg_name_t *vreg_seq,
		int num_vreg_seq, struct regulator **reg_ptr, int config)
{
	int i = 0, j = 0;
	int rc = 0;
	struct camera_vreg_t *curr_vreg;

	if (num_vreg_seq > num_vreg) {
		pr_err("%s:%d vreg sequence invalid\n", __func__, __LINE__);
		return -EINVAL;
	}
	if (!num_vreg_seq)
		num_vreg_seq = num_vreg;

	if (config) {
		for (i = 0; i < num_vreg_seq; i++) {
			if (vreg_seq) {
				j = vreg_seq[i];
				if (j >= num_vreg)
					continue;
			} else
				j = i;
			curr_vreg = &cam_vreg[j];
			reg_ptr[j] = regulator_get(dev,
				curr_vreg->reg_name);
			if (IS_ERR(reg_ptr[j])) {
				pr_err("%s: %s get failed\n",
					 __func__,
					 curr_vreg->reg_name);
				reg_ptr[j] = NULL;
				goto vreg_get_fail;
			}
			if (curr_vreg->type == REG_LDO) {
				rc = regulator_set_voltage(
					reg_ptr[j],
					curr_vreg->min_voltage,
					curr_vreg->max_voltage);
				if (rc < 0) {
					pr_err("%s: %s set voltage failed\n",
						__func__,
						curr_vreg->reg_name);
					goto vreg_set_voltage_fail;
				}
				if (curr_vreg->op_mode >= 0) {
					rc = regulator_set_optimum_mode(
						reg_ptr[j],
						curr_vreg->op_mode);
					if (rc < 0) {
						pr_err(
						"%s:%s set optimum mode fail\n",
						__func__,
						curr_vreg->reg_name);
						goto vreg_set_opt_mode_fail;
					}
				}
			}
		}
	} else {
		for (i = num_vreg_seq-1; i >= 0; i--) {
			if (vreg_seq) {
				j = vreg_seq[i];
				if (j >= num_vreg)
					continue;
			} else
				j = i;
			curr_vreg = &cam_vreg[j];
			if (reg_ptr[j]) {
				if (curr_vreg->type == REG_LDO) {
					if (curr_vreg->op_mode >= 0) {
						regulator_set_optimum_mode(
							reg_ptr[j], 0);
					}
					regulator_set_voltage(
						reg_ptr[j], 0, curr_vreg->
						max_voltage);
				}
				regulator_put(reg_ptr[j]);
				reg_ptr[j] = NULL;
			}
		}
	}
	return 0;

vreg_unconfig:
if (curr_vreg->type == REG_LDO)
	regulator_set_optimum_mode(reg_ptr[j], 0);

vreg_set_opt_mode_fail:
if (curr_vreg->type == REG_LDO)
	regulator_set_voltage(reg_ptr[j], 0,
		curr_vreg->max_voltage);

vreg_set_voltage_fail:
	regulator_put(reg_ptr[j]);
	reg_ptr[j] = NULL;

vreg_get_fail:
	for (i--; i >= 0; i--) {
		if (vreg_seq) {
			j = vreg_seq[i];
			if (j >= num_vreg)
				continue;
		} else
			j = i;
		curr_vreg = &cam_vreg[j];
		goto vreg_unconfig;
	}
	return -ENODEV;
}
int msm_camera_config_single_vreg(struct device *dev,
	struct camera_vreg_t *cam_vreg, struct regulator **reg_ptr, int config)
{
	int rc = 0;

	if (config) {
		if (cam_vreg->type == REG_SUB_LDO) {
			if (cam_vreg->sub_reg_name == NULL) {
				pr_err("%s : can't find sub reg name", __func__);
				goto vreg_get_fail;
			}
			CDBG("%s enable %s\n", __func__, cam_vreg->sub_reg_name);
		} else {
			if (cam_vreg->reg_name == NULL) {
				pr_err("%s : can't find reg name", __func__);
				goto vreg_get_fail;
			}
	            CDBG("%s enable %s\n", __func__, cam_vreg->reg_name);
		}
		if (cam_vreg->type == REG_SUB_LDO) {
			*reg_ptr = regulator_get(dev, cam_vreg->sub_reg_name);
			if (IS_ERR(*reg_ptr)) {
				pr_err("%s: %s get failed\n", __func__,
				cam_vreg->sub_reg_name);
				*reg_ptr = NULL;
				goto vreg_get_fail;
			}
		} else {
			*reg_ptr = regulator_get(dev, cam_vreg->reg_name);
			if (IS_ERR(*reg_ptr)) {
				pr_err("%s: %s get failed\n", __func__,
					cam_vreg->reg_name);
				*reg_ptr = NULL;
				goto vreg_get_fail;
			}
		}

		if (cam_vreg->type == REG_LDO || cam_vreg->type == REG_SUB_LDO) {
			rc = regulator_set_voltage(
				*reg_ptr, cam_vreg->min_voltage,
				cam_vreg->max_voltage);
			if (rc < 0) {
				if (cam_vreg->type == REG_SUB_LDO)
					pr_err("%s: %s set voltage failed\n",
						__func__, cam_vreg->sub_reg_name);
				else
					pr_err("%s: %s set voltage failed\n",
						__func__, cam_vreg->reg_name);

				goto vreg_set_voltage_fail;
			}
			if (cam_vreg->op_mode >= 0) {
				rc = regulator_set_optimum_mode(*reg_ptr,
					cam_vreg->op_mode);
				if (rc < 0) {
					if (cam_vreg->type == REG_SUB_LDO)
						pr_err(
							"%s: %s set optimum mode failed\n",
							__func__, cam_vreg->sub_reg_name);
					else
						pr_err(
							"%s: %s set optimum mode failed\n",
							__func__, cam_vreg->reg_name);

					goto vreg_set_opt_mode_fail;
				}
			}
		}
		rc = regulator_enable(*reg_ptr);
		if (rc < 0) {
			if (cam_vreg->type == REG_SUB_LDO)
				pr_err("%s: %s enable failed\n",
					__func__, cam_vreg->sub_reg_name);
			else
				pr_err("%s: %s enable failed\n",
					__func__, cam_vreg->reg_name);

			goto vreg_unconfig;
		}
	} else {
		if (*reg_ptr) {
			if (cam_vreg->type == REG_SUB_LDO)
				CDBG("%s disable %s\n", __func__, cam_vreg->sub_reg_name);
			else
				CDBG("%s disable %s\n", __func__, cam_vreg->reg_name);

			regulator_disable(*reg_ptr);
			if (cam_vreg->type == REG_LDO || cam_vreg->type == REG_SUB_LDO) {
				if (cam_vreg->op_mode >= 0)
					regulator_set_optimum_mode(*reg_ptr, 0);
				regulator_set_voltage(
					*reg_ptr, 0, cam_vreg->max_voltage);
			}
			regulator_put(*reg_ptr);
			*reg_ptr = NULL;
		} else {
			if (cam_vreg->type == REG_SUB_LDO)
				pr_err("%s can't disable %s\n", __func__, cam_vreg->sub_reg_name);
			else
				pr_err("%s can't disable %s\n", __func__, cam_vreg->reg_name);
		}
	}
	return 0;

vreg_unconfig:
if (cam_vreg->type == REG_LDO)
	regulator_set_optimum_mode(*reg_ptr, 0);

vreg_set_opt_mode_fail:
if (cam_vreg->type == REG_LDO)
	regulator_set_voltage(*reg_ptr, 0, cam_vreg->max_voltage);

vreg_set_voltage_fail:
	regulator_put(*reg_ptr);
	*reg_ptr = NULL;

vreg_get_fail:
	return -ENODEV;
}
예제 #12
0
static void pwm_ir_tx_remove(struct pwm_ir_dev *dev)
{
    if (dev->reg)
        regulator_put(dev->reg);
    pwm_free(dev->pwm);
}
int32_t yacd5c1sbdbc_sensor_power_down(struct msm_sensor_ctrl_t *s_ctrl)
{
    int32_t rc = 0;
	pr_err("%s\n", __func__);

#if 1//wsyang_temp
    if(booting_skip_check == 1) {// except AF_power_down for booting
        if (s_ctrl->func_tbl->sensor_stop_stream) {
            s_ctrl->func_tbl->sensor_stop_stream(s_ctrl);   
            msleep(20);
        }
    }
    else {
        booting_skip_check = 1;
    }
#endif

#if 0
	msm_sensor_probe_off(&s_ctrl->sensor_i2c_client->client->dev);
#else
    msm_sensor_power_down(s_ctrl);
    pr_err(" %s : msm_sensor_power_down : rc = %d E\n",__func__, rc);  
#endif

	if (sgpio_ctrl(sgpios, CAMIO_RST_N, 0) < 0)	rc = -EIO;
	mdelay(1); /* > 20 cycles (approx. 0.64us) */
	if (sgpio_ctrl(sgpios, CAMIO_STB_N, 0) < 0)	rc = -EIO;

	if (svreg_ctrl(svregs, CAMV_CORE_1P8V, 0) < 0)	rc = -EIO;
	if (svreg_ctrl(svregs, CAMV_A_2P8V, 0) < 0)	rc = -EIO;
	if (svreg_ctrl(svregs, CAMV_IO_1P8V, 0) < 0)	rc = -EIO;

	if (sgpio_ctrl(sgpios, CAM1_IOVDD_EN, 0) < 0)	rc = -EIO;

	svreg_release(svregs, CAMV_MAX);
	sgpio_release(sgpios, CAMIO_MAX);

#ifdef CONFIG_PANTECH_CAMERA_TUNER
    kfree(yacd5c1sbdbc_recommend_tuner_settings);
#endif
	pr_err("%s X (%d)\n", __func__, rc);
	return rc;

#if 0
    /* Reset  *********************************************************/
	gpio_set_value_cansleep(data->sensor_platform_info->sensor_reset, 0);
	usleep_range(1000, 2000);
	gpio_free(data->sensor_platform_info->sensor_reset);
    mdelay(1);

    /* Standby *********************************************************/
    if(data->sensor_platform_info->sensor_pwd)
    {
        gpio_set_value_cansleep(data->sensor_platform_info->sensor_pwd, 0);
        gpio_free(data->sensor_platform_info->sensor_pwd);
    }
    mdelay(1);

    /* VREG disable *****************************************************/
    rc = regulator_disable(vreg_lvs6_1p8);
    if (rc){
        printk("%s: Disable regulator vreg_lvs6_1p8 failed\n", __func__);
        goto fail;
    }
    regulator_put(vreg_lvs6_1p8);
    vreg_lvs6_1p8 = NULL;
    mdelay(1);

    rc = regulator_disable(vreg_l11_2p85);
    if (rc){
        printk("%s: Disable regulator vreg_l11_2p85 failed\n", __func__);
        goto fail;
    }
    regulator_put(vreg_l11_2p85);
    vreg_l11_2p85 = NULL;
    mdelay(1);

    rc = regulator_disable(vreg_lvs5_1p8);
    if (rc){
        printk("%s: Disable regulator vreg_lvs5_1p8 failed\n", __func__);
        goto fail;
    }
    regulator_put(vreg_lvs5_1p8);
    vreg_lvs5_1p8 = NULL;
    mdelay(1);    
    
    /* LDO disable ******************************************************/
    gpio_set_value_cansleep(CAM1_IOVDD_EN, 0);
    gpio_free(CAM1_IOVDD_EN);
    mdelay(1);
#if 0
    gpio_set_value_cansleep(CAM1_AVDD_EN, 0);
    gpio_free(CAM1_AVDD_EN);
    mdelay(1);

    gpio_set_value_cansleep(CAM1_DVDD_EN, 0);
    gpio_free(CAM1_DVDD_EN);
    mdelay(1);
#endif
    return 0;
    
fail:
	printk("%s Failed!:%d\n",__func__, __LINE__);
	if(vreg_lvs6_1p8) {
		regulator_put(vreg_lvs6_1p8);
	}
	if(vreg_l11_2p85) {
		regulator_put(vreg_l11_2p85);
	}
    if(vreg_lvs5_1p8){
		regulator_put(vreg_lvs5_1p8);
	}
    return rc;    
#endif	
}
int32_t yacd5c1sbdbc_sensor_power_up(struct msm_sensor_ctrl_t *s_ctrl)
{
	int32_t rc = 0;
	pr_err("%s: %d\n", __func__, __LINE__);

#if 0
	msm_sensor_probe_on(&s_ctrl->sensor_i2c_client->client->dev);
	SKYCDBG("%s msm_sensor_probe_on ok\n", __func__); 
	msm_camio_clk_rate_set(MSM_SENSOR_MCLK_24HZ);
	SKYCDBG("%s msm_camio_clk_rate_set ok\n", __func__);
#else
    rc = msm_sensor_power_up(s_ctrl);
    pr_err(" %s : msm_sensor_power_up : rc = %d E\n",__func__, rc);  
#endif

    	yacd5c1sbdbc_vreg_init();

	if (sgpio_ctrl(sgpios, CAM1_IOVDD_EN, 1) < 0)	rc = -EIO;

	if (sgpio_ctrl(sgpios, CAMIO_RST_N, 0) < 0)	rc = -EIO;

	if (svreg_ctrl(svregs, CAMV_IO_1P8V, 1) < 0)	rc = -EIO;
	mdelay(1); /* > 20us */
	if (svreg_ctrl(svregs, CAMV_A_2P8V, 1) < 0)	rc = -EIO;
	mdelay(1); /* > 15us */
	if (svreg_ctrl(svregs, CAMV_CORE_1P8V, 1) < 0)	rc = -EIO;
	mdelay(1);
	if (sgpio_ctrl(sgpios, CAMIO_STB_N, 1) < 0)	rc = -EIO;
	//msm_camio_clk_rate_set(24000000);
    mdelay(35); //yacd5c1sbdbc spec: >30ms
	if (sgpio_ctrl(sgpios, CAMIO_RST_N, 1) < 0)	rc = -EIO;
	mdelay(1); /* > 50us */

	pr_err("%s X (%d)\n", __func__, rc);
	return rc;

#if 0
    /* LDO enable ******************************************************/
   
    rc = gpio_request(CAM1_IOVDD_EN, "yacd5c1sbdbc");
    if (!rc) {
        printk("%s:%d\n", __func__, __LINE__);
        gpio_direction_output(CAM1_IOVDD_EN, 1);
    } else {
		printk("%s: gpio CAM1_IOVDD_EN request fail", __func__);
	}
    mdelay(1);
#if 0 
    rc = gpio_request(CAM1_AVDD_EN, "yacd5c1sbdbc");
    if (!rc) {
        printk("%s:%d\n", __func__, __LINE__);
        gpio_direction_output(CAM1_AVDD_EN, 1);
    } else {
		printk("%s: gpio CAM1_AVDD_EN request fail", __func__);
	}
    mdelay(1);

    rc = gpio_request(CAM1_DVDD_EN, "yacd5c1sbdbc");
    if (!rc) {
        printk("%s:%d\n", __func__, __LINE__);
        gpio_direction_output(CAM1_DVDD_EN, 1);
    } else {
		printk("%s: gpio CAM1_DVDD_EN request fail", __func__);
	}
    mdelay(1);
#endif
    /* VREG enable *****************************************************/
    rc = regulator_enable(vreg_lvs5_1p8);
    if (rc) {
        printk("%s: Enable regulator vreg_lvs5_1p8 failed\n", __func__);
        goto fail;
    }
    mdelay(1);

    rc = regulator_enable(vreg_l11_2p85);
    if (rc) {
        printk("%s: Enable regulator vreg_l11_2p85 failed\n", __func__);
        goto fail;
    }
    mdelay(1);  

    rc = regulator_enable(vreg_lvs6_1p8);
    if (rc) {
        printk("%s: Enable regulator vreg_lvs6_1p8 failed\n", __func__);
        goto fail;
    }
    mdelay(1);
    
    /* Standby *********************************************************/
    rc = gpio_request(data->sensor_platform_info->sensor_pwd, "yacd5c1sbdbc");
    if (!rc) {
        printk("%s:Standby\n", __func__);
        //gpio_set_value(SENSOR_STANDBY,1);
        gpio_set_value_cansleep(data->sensor_platform_info->sensor_pwd, 0);
        gpio_direction_output(data->sensor_platform_info->sensor_pwd, 1);
    } else {
		printk("%s: gpio Standby request fail", __func__);
	}
    mdelay(1);

    /* MCLK set ********************************************************/
    printk(" msm_camio_clk_rate_set E\n");
	msm_camio_clk_rate_set(MSM_SENSOR_MCLK_24HZ);
    printk(" msm_camio_clk_rate_set X\n");
    mdelay(1);

    /* Reset  *********************************************************/
	rc = gpio_request(data->sensor_platform_info->sensor_reset, "yacd5c1sbdbc");
	if (!rc) {
		printk("%s: reset sensor\n", __func__);
		gpio_direction_output(data->sensor_platform_info->sensor_reset, 0);
		usleep_range(1000, 2000);
		gpio_set_value_cansleep(data->sensor_platform_info->sensor_reset, 1);
		usleep_range(4000, 5000);
	} else {
		printk("%s: gpio Reset request fail", __func__);
	}

    return rc;

fail:
	printk("%s Failed!:%d\n",__func__, __LINE__);
	if(vreg_lvs6_1p8) {
		regulator_put(vreg_lvs6_1p8);
	}
	if(vreg_l11_2p85) {
		regulator_put(vreg_l11_2p85);
	}
    if(vreg_lvs5_1p8){
		regulator_put(vreg_lvs5_1p8);
	}    
    return rc;
#endif
}
예제 #15
0
static int apds9900_power_init(struct apds9900_priv *alsps, bool on)
{
	int ret;
	printk("%s on%d\n",__func__,on);
	if (!on) {
		if (regulator_count_voltages(alsps->vdd) > 0)
			regulator_set_voltage(alsps->vdd,
					0, STK3X1X_VDD_MAX_UV);

		regulator_put(alsps->vdd);

		if (regulator_count_voltages(alsps->vio) > 0)
			regulator_set_voltage(alsps->vio,
					0, STK3X1X_VIO_MAX_UV);

		regulator_put(alsps->vio);
	} else {
		printk("regulator_get \n");
		
		alsps->vdd = regulator_get(&alsps->client->dev, "vdd");
		if (IS_ERR(alsps->vdd)) {
			ret = PTR_ERR(alsps->vdd);
			dev_err(&alsps->client->dev,
				"Regulator get failed vdd ret=%d\n", ret);
			return ret;
		}

		printk("regulator_count_voltages\n");

		if (regulator_count_voltages(alsps->vdd) > 0) {
			ret = regulator_set_voltage(alsps->vdd,
					STK3X1X_VDD_MIN_UV,
					STK3X1X_VDD_MAX_UV);
			if (ret) {
				dev_err(&alsps->client->dev,
					"Regulator set failed vdd ret=%d\n",
					ret);
				goto reg_vdd_put;
			}
		}
		printk("regulator_count vio\n");

		alsps->vio = regulator_get(&alsps->client->dev, "vio");
		if (IS_ERR(alsps->vio)) {
			ret = PTR_ERR(alsps->vio);
			dev_err(&alsps->client->dev,
				"Regulator get failed vio ret=%d\n", ret);
			goto reg_vdd_set;
		}

		if (regulator_count_voltages(alsps->vio) > 0) {
			ret = regulator_set_voltage(alsps->vio,
					STK3X1X_VIO_MIN_UV,
					STK3X1X_VIO_MAX_UV);
			if (ret) {
				dev_err(&alsps->client->dev,
				"Regulator set failed vio ret=%d\n", ret);
				goto reg_vio_put;
			}
		}
	}

	return 0;

reg_vio_put:
	regulator_put(alsps->vio);
reg_vdd_set:
	if (regulator_count_voltages(alsps->vdd) > 0)
		regulator_set_voltage(alsps->vdd, 0, STK3X1X_VDD_MAX_UV);
reg_vdd_put:
	regulator_put(alsps->vdd);
	return ret;
}
예제 #16
0
static int tegra_camera_probe(struct platform_device *pdev)
{
	int err;
	struct tegra_camera_dev *dev;

	dev_info(&pdev->dev, "%s\n", __func__);
	dev = devm_kzalloc(&pdev->dev, sizeof(struct tegra_camera_dev),
			GFP_KERNEL);
	if (!dev) {
		err = -ENOMEM;
		dev_err(&pdev->dev, "%s: unable to allocate memory\n",
			__func__);
		goto alloc_err;
	}

	mutex_init(&dev->tegra_camera_lock);

	/* Powergate VE when boot */
	mutex_lock(&dev->tegra_camera_lock);
#ifndef CONFIG_ARCH_TEGRA_2x_SOC
	err = tegra_powergate_partition(TEGRA_POWERGATE_VENC);
	if (err)
		dev_err(&pdev->dev, "%s: powergate failed.\n", __func__);
#endif
	mutex_unlock(&dev->tegra_camera_lock);

	dev->dev = &pdev->dev;

	/* Get regulator pointer */
#ifdef CONFIG_ARCH_TEGRA_2x_SOC
	dev->reg = regulator_get(&pdev->dev, "vcsi");
#else
	dev->reg = regulator_get(&pdev->dev, "avdd_dsi_csi");
#endif
	if (IS_ERR_OR_NULL(dev->reg)) {
		if (dev->reg == ERR_PTR(-ENODEV)) {
			dev->reg = NULL;
			dev_info(&pdev->dev, "%s: no regulator device, overriding\n",
							__func__);
		} else {
			dev_err(&pdev->dev, "%s: couldn't get regulator\n",
							__func__);
			return PTR_ERR(dev->reg);
		}
	}

	dev->misc_dev.minor = MISC_DYNAMIC_MINOR;
	dev->misc_dev.name = TEGRA_CAMERA_NAME;
	dev->misc_dev.fops = &tegra_camera_fops;
	dev->misc_dev.parent = &pdev->dev;

	err = misc_register(&dev->misc_dev);
	if (err) {
		dev_err(&pdev->dev, "%s: Unable to register misc device!\n",
		       TEGRA_CAMERA_NAME);
		goto misc_register_err;
	}

	err = tegra_camera_clk_get(pdev, "isp", &dev->isp_clk);
	if (err)
		goto misc_register_err;
	err = tegra_camera_clk_get(pdev, "vi", &dev->vi_clk);
	if (err)
		goto vi_clk_get_err;
	err = tegra_camera_clk_get(pdev, "vi_sensor", &dev->vi_sensor_clk);
	if (err)
		goto vi_sensor_clk_get_err;
	err = tegra_camera_clk_get(pdev, "csus", &dev->csus_clk);
	if (err)
		goto csus_clk_get_err;
	err = tegra_camera_clk_get(pdev, "csi", &dev->csi_clk);
	if (err)
		goto csi_clk_get_err;
	err = tegra_camera_clk_get(pdev, "emc", &dev->emc_clk);
	if (err)
		goto emc_clk_get_err;

	/* dev is set in order to restore in _remove */
	platform_set_drvdata(pdev, dev);

	return 0;

emc_clk_get_err:
	clk_put(dev->emc_clk);
csi_clk_get_err:
	clk_put(dev->csus_clk);
csus_clk_get_err:
	clk_put(dev->vi_sensor_clk);
vi_sensor_clk_get_err:
	clk_put(dev->vi_clk);
vi_clk_get_err:
	clk_put(dev->isp_clk);
misc_register_err:
	regulator_put(dev->reg);
alloc_err:
	return err;
}
static void kxtf9_exit(void)
{
	regulator_put(kxtf9_regulator);
}
예제 #18
0
static int __devinit gpio_keys_probe(struct platform_device *pdev)
{
	const struct gpio_keys_platform_data *pdata = pdev->dev.platform_data;
	struct gpio_keys_drvdata *ddata;
	struct gpio_keys_button *button = NULL;
	struct gpio_button_data *bdata = NULL;
	struct device *dev = &pdev->dev;
	struct gpio_keys_platform_data alt_pdata;
	struct input_dev *input;
	int i, error;
	int wakeup = 0;
	int ret;
	struct device *sec_key;
#ifdef CONFIG_SEC_PATEK_PROJECT
	struct device *sec_keypad;
	struct device *sec_flip;
#endif

	if (!pdata) {
		error = gpio_keys_get_devtree_pdata(dev, &alt_pdata);
		if (error)
			return error;
		pdata = &alt_pdata;
	}

	ddata = kzalloc(sizeof(struct gpio_keys_drvdata) +
			pdata->nbuttons * sizeof(struct gpio_button_data),
			GFP_KERNEL);
	input = input_allocate_device();
	if (!ddata || !input) {
		dev_err(dev, "failed to allocate state\n");
		error = -ENOMEM;
		goto fail1;
	}

	ddata->input = input;
	ddata->n_buttons = pdata->nbuttons;
	ddata->enable = pdata->enable;
	ddata->disable = pdata->disable;
#ifdef CONFIG_SENSORS_HALL_DEBOUNCE
	ddata->debounce_set = pdata->debounce_set;
#endif
#ifdef CONFIG_SENSORS_HALL

#if defined (CONFIG_SEC_MILLET_PROJECT) || defined (CONFIG_SEC_BERLUTI_PROJECT)\
	|| defined (CONFIG_SEC_MATISSE_PROJECT)	|| defined (CONFIG_SEC_ATLANTIC_PROJECT)\
    || defined (CONFIG_SEC_MEGA2_PROJECT) || defined (CONFIG_SEC_T8_PROJECT) || defined (CONFIG_SEC_T10_PROJECT) || defined(CONFIG_SEC_HESTIA_PROJECT)
	ret = gpio_request(pdata->gpio_flip_cover,"HALL");
	if(ret)
		printk(KERN_CRIT "[HALL IC] gpio Request FAIL\n");
	else {
		gpio_tlmm_config(GPIO_CFG(pdata->gpio_flip_cover,0, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL,GPIO_CFG_2MA),GPIO_CFG_DISABLE);
	}
#endif
	ddata->gpio_flip_cover = pdata->gpio_flip_cover;
	ddata->flip_code = pdata->flip_code;
	ddata->irq_flip_cover = gpio_to_irq(ddata->gpio_flip_cover);
	wake_lock_init(&ddata->flip_wake_lock, WAKE_LOCK_SUSPEND,
		"flip_wake_lock");
	flip_status_before = -1;
#endif
	mutex_init(&ddata->disable_lock);
#ifdef CONFIG_SENSORS_HALL_IRQ_CTRL
	mutex_init(&ddata->irq_lock);
#endif

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

	input->name = pdata->name ? : pdev->name;
	input->phys = "gpio-keys/input0";
	input->dev.parent = &pdev->dev;
#ifdef CONFIG_SENSORS_HALL
	if(ddata->gpio_flip_cover != 0) {
		input->evbit[0] |= BIT_MASK(EV_SW);
		input_set_capability(input, EV_SW, ddata->flip_code);
	}
#endif
#ifdef CONFIG_SENSORS_HALL_IRQ_CTRL
	ddata->gsm_area = false;
	ddata->cover_state = false;
	ddata->workaround_set = pdata->workaround_set;
	drv_data = ddata;
#endif
#ifdef CONFIG_SENSORS_HALL_DEBOUNCE
	ddata->debounce_set = false;
#endif
	input->open = gpio_keys_open;
	input->close = gpio_keys_close;

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

	/* Enable auto repeat feature of Linux input subsystem */
	if (pdata->rep)
		__set_bit(EV_REP, input->evbit);

	for (i = 0; i < pdata->nbuttons; i++) {
		button = &pdata->buttons[i];
		bdata = &ddata->data[i];

		error = gpio_keys_setup_key(pdev, input, bdata, button);
		if (error)
			goto fail2;
#ifdef KEY_BOOSTER
		error = gpio_key_init_dvfs(bdata);
		if (error < 0) {
			dev_err(dev, "Fail get dvfs level for touch booster\n");
			goto fail2;
		}
#endif
		if (button->wakeup)
			wakeup = 1;
	}

	error = sysfs_create_group(&pdev->dev.kobj, &gpio_keys_attr_group);
	if (error) {
		dev_err(dev, "Unable to export keys/switches, error: %d\n",
			error);
		goto fail2;
	}

	error = input_register_device(input);
	if (error) {
		dev_err(dev, "Unable to register input device, error: %d\n",
			error);
		goto fail3;
	}

	/* get current state of buttons that are connected to GPIOs */
	for (i = 0; i < pdata->nbuttons; i++) {
		bdata = &ddata->data[i];
		if (gpio_is_valid(bdata->button->gpio))
			gpio_keys_gpio_report_event(bdata);
	}
	input_sync(input);

	sec_key = device_create(sec_class, NULL, 0, NULL, "sec_key");
	if (IS_ERR(sec_key))
		pr_err("Failed to create device(sec_key)!\n");

#ifdef CONFIG_SEC_PATEK_PROJECT
	sec_keypad=device_create(sec_class, NULL, 0, NULL, "sec_keypad");
	if (device_create_file(sec_keypad, &dev_attr_brightness) < 0)
		pr_err("Failed to create device file(%s)!\n", dev_attr_brightness.attr.name);

	sec_flip = device_create(sec_class, NULL, 0, NULL, "sec_flip");
	if (device_create_file(sec_flip, &dev_attr_flipStatus) < 0)
		pr_err("Failed to create device file(%s)!\n", dev_attr_flipStatus.attr.name);
#endif

	ret = device_create_file(sec_key, &dev_attr_sec_key_pressed);
	if (ret) {
		pr_err("Failed to create device file in sysfs entries(%s)!\n",
				dev_attr_sec_key_pressed.attr.name);
	}
#if defined(CONFIG_SEC_S_PROJECT)
	ret = device_create_file(sec_key, &dev_attr_sec_key_pressed_code);
	if (ret) {
		pr_err("Failed to create device file in sysfs entries(%s)!\n",
				dev_attr_sec_key_pressed_code.attr.name);
	}
#endif

#ifdef CONFIG_SENSORS_HALL_IRQ_CTRL
	if(ddata->gpio_flip_cover != 0) {
		ret = device_create_file(sec_key, &dev_attr_hall_irq_ctrl);
		if (ret < 0) {
			pr_err("Failed to create device file(%s)!, error: %d\n",
				dev_attr_hall_irq_ctrl.attr.name, ret);
		}
	}
#endif
#if defined(CONFIG_SENSORS_HALL)
	if(ddata->gpio_flip_cover != 0) {
		ret = device_create_file(sec_key, &dev_attr_hall_detect);
		if (ret < 0) {
			pr_err("Failed to create device file(%s)!, error: %d\n",
				dev_attr_hall_detect.attr.name, ret);
		}
	}
#if defined(CONFIG_SENSORS_HALL_DEBOUNCE)
	if(ddata->gpio_flip_cover != 0) {
		ret = device_create_file(sec_key, &dev_attr_hall_irq_ctrl);
		if (ret < 0) {
			pr_err("Failed to create device file(%s)!, error: %d\n",
				dev_attr_hall_irq_ctrl.attr.name, ret);
		}
	}
#endif
#if defined (CONFIG_SEC_MILLET_PROJECT) || defined (CONFIG_SEC_BERLUTI_PROJECT) ||  defined (CONFIG_SEC_T8_PROJECT)
	if (!lvs1_1p8) {
		lvs1_1p8 = regulator_get(dev, "8226_lvs1");
		if(!lvs1_1p8)
			printk(KERN_CRIT "%s: regulator_get for 8226_lvs1 failed\n", __func__);
		else {
			ret = regulator_enable(lvs1_1p8);
			if (ret){
				regulator_put(lvs1_1p8);
				printk(KERN_CRIT "%s: Failed to enable regulator lvs1_1p8.\n",__func__);
			}
		}
	}
#endif

#endif

#ifdef CONFIG_USE_VM_KEYBOARD_REJECT
	reject_keyboard_specific_key = false;
	ret = device_create_file(sec_key, &dev_attr_reject_key_comb);
	if (ret < 0) {
		pr_err("Failed to create device file(%s), error: %d\n",
				dev_attr_reject_key_comb.attr.name, ret);
	}
#endif
	ret = device_create_file(sec_key, &dev_attr_wakeup_keys);
	if (ret < 0) {
		pr_err("Failed to create device file(%s), error: %d\n",
				dev_attr_wakeup_keys.attr.name, ret);
	}
	dev_set_drvdata(sec_key, ddata);

	device_init_wakeup(&pdev->dev, wakeup);

#if defined(CONFIG_SEC_PATEK_PROJECT)
	keypadled_powerset(&pdev->dev);
	dev_set_drvdata(sec_flip, ddata);
#endif

#ifdef PERIODIC_CHECK_GPIOS
    INIT_DELAYED_WORK_DEFERRABLE(&g_gpio_check_work,
            sec_gpiocheck_work);
    schedule_delayed_work(&g_gpio_check_work,
            msecs_to_jiffies(0));
#endif

	return 0;

 fail3:
	sysfs_remove_group(&pdev->dev.kobj, &gpio_keys_attr_group);
 fail2:
	while (--i >= 0)
		gpio_remove_key(&ddata->data[i]);

	platform_set_drvdata(pdev, NULL);
#ifdef CONFIG_SENSORS_HALL
	wake_lock_destroy(&ddata->flip_wake_lock);
#endif
 fail1:
	input_free_device(input);
	kfree(ddata);
	/* If we have no platform_data, we allocated buttons dynamically. */
	if (!pdev->dev.platform_data)
		kfree(pdata->buttons);

	return error;
}
static int msm_csid_init(struct csid_device *csid_dev, uint32_t *csid_version)
{
	int rc = 0;

	if (!csid_version) {
		pr_err("%s:%d csid_version NULL\n", __func__, __LINE__);
		rc = -EINVAL;
		return rc;
	}

	csid_dev->reg_ptr = NULL;

	if (csid_dev->csid_state == CSID_POWER_UP) {
		pr_err("%s: csid invalid state %d\n", __func__,
			csid_dev->csid_state);
		rc = -EINVAL;
		return rc;
	}

	csid_dev->base = ioremap(csid_dev->mem->start,
		resource_size(csid_dev->mem));
	if (!csid_dev->base) {
		pr_err("%s csid_dev->base NULL\n", __func__);
		rc = -ENOMEM;
		return rc;
	}

	pr_info("%s: CSID_VERSION = 0x%x\n", __func__,
		csid_dev->ctrl_reg->csid_reg.csid_version);
	/* power up */
	if (csid_dev->ctrl_reg->csid_reg.csid_version < CSID_VERSION_V22) {
		rc = msm_camera_config_vreg(&csid_dev->pdev->dev,
			csid_8960_vreg_info, ARRAY_SIZE(csid_8960_vreg_info),
			NULL, 0, &csid_dev->csi_vdd, 1);
	} else {
		rc = msm_camera_config_vreg(&csid_dev->pdev->dev,
			csid_vreg_info, ARRAY_SIZE(csid_vreg_info),
			NULL, 0, &csid_dev->csi_vdd, 1);
	}
	if (rc < 0) {
		pr_err("%s: regulator on failed\n", __func__);
		goto vreg_config_failed;
	}
	if (csid_dev->ctrl_reg->csid_reg.csid_version < CSID_VERSION_V22) {
		rc = msm_camera_enable_vreg(&csid_dev->pdev->dev,
			csid_8960_vreg_info, ARRAY_SIZE(csid_8960_vreg_info),
			NULL, 0, &csid_dev->csi_vdd, 1);
	} else {
		rc = msm_camera_enable_vreg(&csid_dev->pdev->dev,
			csid_vreg_info, ARRAY_SIZE(csid_vreg_info),
			NULL, 0, &csid_dev->csi_vdd, 1);
	}
	if (rc < 0) {
		pr_err("%s: regulator enable failed\n", __func__);
		goto vreg_enable_failed;
	}

	csid_dev->reg_ptr = regulator_get(&(csid_dev->pdev->dev),
					 "qcom,gdscr-vdd");
	if (IS_ERR_OR_NULL(csid_dev->reg_ptr)) {
		pr_debug(" %s: Failed in getting TOP gdscr regulator handle",
			__func__);
	} else {
		rc = regulator_enable(csid_dev->reg_ptr);
		if (rc) {
			pr_err(" %s: regulator enable failed for GDSCR\n",
				__func__);
			goto gdscr_regulator_enable_failed;
		}
	}

	if (csid_dev->ctrl_reg->csid_reg.csid_version == CSID_VERSION_V22)
		msm_cam_clk_sel_src(&csid_dev->pdev->dev,
			&csid_clk_info[3], csid_clk_src_info,
			csid_dev->num_clk_src_info);


	rc = msm_cam_clk_enable(&csid_dev->pdev->dev,
			csid_clk_info, csid_dev->csid_clk,
			csid_dev->num_clk, 1);
	if (rc < 0) {
		pr_err("%s:%d clock enable failed\n",
			 __func__, __LINE__);
		goto clk_enable_failed;
	}
	CDBG("%s:%d called\n", __func__, __LINE__);
	csid_dev->hw_version =
		msm_camera_io_r(csid_dev->base +
		csid_dev->ctrl_reg->csid_reg.csid_hw_version_addr);
	CDBG("%s:%d called csid_dev->hw_version %x\n", __func__, __LINE__,
		csid_dev->hw_version);
	*csid_version = csid_dev->hw_version;

	init_completion(&csid_dev->reset_complete);

	enable_irq(csid_dev->irq->start);

	msm_csid_reset(csid_dev);
	csid_dev->csid_state = CSID_POWER_UP;
	return rc;

clk_enable_failed:
	if (csid_dev->ctrl_reg->csid_reg.csid_version < CSID_VERSION_V22) {
		msm_camera_enable_vreg(&csid_dev->pdev->dev,
			csid_8960_vreg_info, ARRAY_SIZE(csid_8960_vreg_info),
			NULL, 0, &csid_dev->csi_vdd, 0);
	} else {
		msm_camera_enable_vreg(&csid_dev->pdev->dev,
			csid_vreg_info, ARRAY_SIZE(csid_vreg_info),
			NULL, 0, &csid_dev->csi_vdd, 0);
	}
gdscr_regulator_enable_failed:
	if (!IS_ERR_OR_NULL(csid_dev->reg_ptr)) {
		regulator_disable(csid_dev->reg_ptr);
		regulator_put(csid_dev->reg_ptr);
		csid_dev->reg_ptr = NULL;
	}

vreg_enable_failed:
	if (csid_dev->ctrl_reg->csid_reg.csid_version < CSID_VERSION_V22) {
		msm_camera_config_vreg(&csid_dev->pdev->dev,
			csid_8960_vreg_info, ARRAY_SIZE(csid_8960_vreg_info),
			NULL, 0, &csid_dev->csi_vdd, 0);
	} else {
		msm_camera_config_vreg(&csid_dev->pdev->dev,
			csid_vreg_info, ARRAY_SIZE(csid_vreg_info),
			NULL, 0, &csid_dev->csi_vdd, 0);
	}
vreg_config_failed:
	iounmap(csid_dev->base);
	csid_dev->base = NULL;
	return rc;
}
예제 #20
0
static int pda_power_probe(struct platform_device *pdev)
{
	int ret = 0;

	dev = &pdev->dev;

	if (pdev->id != -1) {
		dev_err(dev, "it's meaningless to register several "
			"pda_powers; use id = -1\n");
		ret = -EINVAL;
		goto wrongid;
	}

	pdata = pdev->dev.platform_data;

	if (pdata->init) {
		ret = pdata->init(dev);
		if (ret < 0)
			goto init_failed;
	}

	update_status();
	update_charger();

	if (!pdata->wait_for_status)
		pdata->wait_for_status = 500;

	if (!pdata->wait_for_charger)
		pdata->wait_for_charger = 500;

	if (!pdata->polling_interval)
		pdata->polling_interval = 2000;

	if (!pdata->ac_max_uA)
		pdata->ac_max_uA = 500000;

	setup_timer(&charger_timer, charger_timer_func, 0);
	setup_timer(&supply_timer, supply_timer_func, 0);

	ac_irq = platform_get_resource_byname(pdev, IORESOURCE_IRQ, "ac");
	usb_irq = platform_get_resource_byname(pdev, IORESOURCE_IRQ, "usb");

	if (pdata->supplied_to) {
		pda_psy_ac.supplied_to = pdata->supplied_to;
		pda_psy_ac.num_supplicants = pdata->num_supplicants;
		pda_psy_usb.supplied_to = pdata->supplied_to;
		pda_psy_usb.num_supplicants = pdata->num_supplicants;
	}

	ac_draw = regulator_get(dev, "ac_draw");
	if (IS_ERR(ac_draw)) {
		dev_dbg(dev, "couldn't get ac_draw regulator\n");
		ac_draw = NULL;
		ret = PTR_ERR(ac_draw);
	}

#ifdef CONFIG_USB_OTG_UTILS
	transceiver = usb_get_transceiver();
	if (transceiver && !pdata->is_usb_online) {
		pdata->is_usb_online = otg_is_usb_online;
	}
	if (transceiver && !pdata->is_ac_online) {
		pdata->is_ac_online = otg_is_ac_online;
	}
#endif

	if (pdata->is_ac_online) {
		ret = power_supply_register(&pdev->dev, &pda_psy_ac);
		if (ret) {
			dev_err(dev, "failed to register %s power supply\n",
				pda_psy_ac.name);
			goto ac_supply_failed;
		}

		if (ac_irq) {
			ret = request_irq(ac_irq->start, power_changed_isr,
					  get_irq_flags(ac_irq), ac_irq->name,
					  &pda_psy_ac);
			if (ret) {
				dev_err(dev, "request ac irq failed\n");
				goto ac_irq_failed;
			}
		} else {
			polling = 1;
		}
	}

	if (pdata->is_usb_online) {
		ret = power_supply_register(&pdev->dev, &pda_psy_usb);
		if (ret) {
			dev_err(dev, "failed to register %s power supply\n",
				pda_psy_usb.name);
			goto usb_supply_failed;
		}

		if (usb_irq) {
			ret = request_irq(usb_irq->start, power_changed_isr,
					  get_irq_flags(usb_irq),
					  usb_irq->name, &pda_psy_usb);
			if (ret) {
				dev_err(dev, "request usb irq failed\n");
				goto usb_irq_failed;
			}
		} else {
			polling = 1;
		}
	}

#ifdef CONFIG_USB_OTG_UTILS
	if (transceiver && pdata->use_otg_notifier) {
		otg_nb.notifier_call = otg_handle_notification;
		ret = usb_register_notifier(transceiver, &otg_nb);
		if (ret) {
			dev_err(dev, "failure to register otg notifier\n");
			goto otg_reg_notifier_failed;
		}
		polling = 0;
	}
#endif

	if (polling) {
		dev_dbg(dev, "will poll for status\n");
		setup_timer(&polling_timer, polling_timer_func, 0);
		mod_timer(&polling_timer,
			  jiffies + msecs_to_jiffies(pdata->polling_interval));
	}

	if (ac_irq || usb_irq)
		device_init_wakeup(&pdev->dev, 1);

	return 0;

#ifdef CONFIG_USB_OTG_UTILS
otg_reg_notifier_failed:
	if (pdata->is_usb_online && usb_irq)
		free_irq(usb_irq->start, &pda_psy_usb);
#endif
usb_irq_failed:
	if (pdata->is_usb_online)
		power_supply_unregister(&pda_psy_usb);
usb_supply_failed:
	if (pdata->is_ac_online && ac_irq)
		free_irq(ac_irq->start, &pda_psy_ac);
#ifdef CONFIG_USB_OTG_UTILS
	if (transceiver)
		usb_put_transceiver(transceiver);
#endif
ac_irq_failed:
	if (pdata->is_ac_online)
		power_supply_unregister(&pda_psy_ac);
ac_supply_failed:
	if (ac_draw) {
		regulator_put(ac_draw);
		ac_draw = NULL;
	}
	if (pdata->exit)
		pdata->exit(dev);
init_failed:
wrongid:
	return ret;
}
예제 #21
0
static void msm_camera_vreg_config(int vreg_en)
{
	static int gpio_initialzed = 0;
	static struct regulator* ldo2 = NULL;
	static struct regulator* ldo3 = NULL;
	static struct regulator* ldo4 = NULL;
	int rc;

	if (!gpio_initialzed) {
		gpio_request(GPIO_CAM_RESET, "cam_reset");
		gpio_direction_output(GPIO_CAM_RESET, 0);
		gpio_initialzed = 1;
	}

	if (vreg_en) {
		gpio_set_value(GPIO_CAM_RESET, 1);
		mdelay(1);

		/* TODO : error checking */
		ldo4 = regulator_get(NULL, "RT8053_LDO4");
		if (ldo4 == NULL) {
			pr_err("%s: regulator_get(ldo4) failed\n", __func__);
		}

		ldo2 = regulator_get(NULL, "RT8053_LDO2");
		if (ldo2 == NULL) {
			pr_err("%s: regulator_get(ldo2) failed\n", __func__);
		}

		ldo3 = regulator_get(NULL, "RT8053_LDO3");
		if (ldo3 == NULL) {
			pr_err("%s: regulator_get(ldo3) failed\n", __func__);
		}

		rc = regulator_set_voltage(ldo4, 1800000, 1800000);
		if (rc < 0) {
			pr_err("%s: regulator_set_voltage(ldo4) failed\n", __func__);
		}
		rc = regulator_enable(ldo4);
		if (rc < 0) {
			pr_err("%s: regulator_enable(ldo4) failed\n", __func__);
		}

		rc = regulator_set_voltage(ldo2, 2800000, 2800000);
		if (rc < 0) {
			pr_err("%s: regulator_set_voltage(ldo2) failed\n", __func__);
		}
		rc = regulator_enable(ldo2);
		if (rc < 0) {
			pr_err("%s: regulator_enable(ldo2) failed\n", __func__);
		}

		rc = regulator_set_voltage(ldo3, 2800000, 2800000);
		if (rc < 0) {
			pr_err("%s: regulator_set_voltage(ldo3) failed\n", __func__);
		}
		rc = regulator_enable(ldo3);
		if (rc < 0) {
			pr_err("%s: regulator_enable(ldo3) failed\n", __func__);
		}
	} else {
		gpio_set_value(GPIO_CAM_RESET, 0);

		rc = regulator_disable(ldo3);
		if (rc < 0) {
			pr_err("%s: regulator_disable(ldo3) failed\n", __func__);
		}
		regulator_put(ldo3);

		rc = regulator_disable(ldo2);
		if (rc < 0) {
			pr_err("%s: regulator_disble(ldo2) failed\n", __func__);
		}
		regulator_put(ldo2);

		rc = regulator_disable(ldo4);
		if (rc < 0) {
			pr_err("%s: regulator_disable(ldo4) failed\n", __func__);
		}
		regulator_put(ldo4);
	}

	return;
}
예제 #22
0
static int ist30xx_regulator_configure(struct ist30xx_data *ts, bool on)
{
        int retval;

        if (on == true) {
                tsp_debug("ist30xx_regulator_configure : On \n");
        } else {
                tsp_debug("ist30xx_regulator_configure : Off \n");
        }

        if (on == false)
                goto hw_shutdown;

        ts->vdd = regulator_get(&ts->client->dev, "vdd");
        if (IS_ERR(ts->vdd)) {
                tsp_debug("Failed to get vdd regulator \n");
                return PTR_ERR(ts->vdd);
        }

        if (regulator_count_voltages(ts->vdd) > 0) {
		tsp_debug("regulator_set_voltage(VDD L22, %d, %d) \n", IST30XX_VDD_VOLTAGE, IST30XX_VDD_VOLTAGE);

                retval = regulator_set_voltage(ts->vdd, IST30XX_VDD_VOLTAGE, IST30XX_VDD_VOLTAGE);
                if (retval) {
                        tsp_debug("regulator set_vtg failed retval=%d \n", retval);
                        goto err_set_vtg_vdd;
                }
        }

        if (ts->pdata->i2c_pull_up) {
                tsp_debug("this device has i2c_pull_up \n");
                ts->vcc_i2c = regulator_get(&ts->client->dev, "vcc_i2c");
                if (IS_ERR(ts->vcc_i2c)) {
                        tsp_debug("Failed to get i2c regulator \n");
                        retval = PTR_ERR(ts->vcc_i2c);
                        goto err_get_vtg_i2c;
                }

                if (regulator_count_voltages(ts->vcc_i2c) > 0) {
			 tsp_debug("regulator_set_voltage(vcc_i2c, %d, %d) \n", IST30XX_I2C_VOLTAGE, IST30XX_I2C_VOLTAGE);
                        retval = regulator_set_voltage(ts->vcc_i2c, IST30XX_I2C_VOLTAGE, IST30XX_I2C_VOLTAGE);
                        if (retval) {
                                tsp_debug("reg set i2c vtg failed retval=%d \n", retval);
                                goto err_set_vtg_i2c;
                        }
                }
        }

        tsp_debug("ist30xx_regulator_configure : On Done \n");
        return 0;

err_set_vtg_i2c:
        if (ts->pdata->i2c_pull_up)
                regulator_put(ts->vcc_i2c);
err_get_vtg_i2c:
        if (regulator_count_voltages(ts->vdd) > 0)
                regulator_set_voltage(ts->vdd, 0, IST30XX_VDD_VOLTAGE);
err_set_vtg_vdd:
        regulator_put(ts->vdd);

        tsp_debug("ist30xx_regulator_configure err \n");

        return retval;

hw_shutdown:
        if (regulator_count_voltages(ts->vdd) > 0)
                regulator_set_voltage(ts->vdd, 0, IST30XX_VDD_VOLTAGE);
                regulator_put(ts->vdd);

        if (ts->pdata->i2c_pull_up) {
                if (regulator_count_voltages(ts->vcc_i2c) > 0)
                        regulator_set_voltage(ts->vcc_i2c, 0, IST30XX_I2C_VOLTAGE);
                regulator_put(ts->vcc_i2c);
        }

        tsp_debug("ist30xx_regulator_configure : Off done \n");

        return 0;
}
int video_harden_regulator_enable(video_harden_dev_id_enum dev_id)
{
    int ret = 0;

#if 0
	struct device_node *np = NULL;
	struct platform_device *pdev=NULL;
	struct device *dev;

	np = of_find_compatible_node(NULL, NULL, "hisi,video_harden");
	if (np ==NULL) {
		printk(KERN_ERR "the device node video_harden is null\n");
		return ret;
	}

	pdev=of_find_device_by_node(np);
	if (pdev ==NULL) {
		printk(KERN_ERR "the device video_harden is null\n");
		return ret;
	}
	dev=&pdev->dev;
#endif

    printk(KERN_INFO "dev_id is %d.\n",dev_id);

    ret = video_harden_device_id_check(dev_id);
    if (ret != 0) {
        return -1;
    }

    ret = down_interruptible(&video_harden_busy_lock);
	if (0 != ret) {
		printk(KERN_ERR "video_harden_busy_lock failed\n");
		return -1;
	}

    if ((0 == video_harden_regulator_vote.vcodec_bit)
       && (0 == video_harden_regulator_vote.jpeg_bit)
       && (0 == video_harden_regulator_vote.isp_bit)) {
        /* AO_SC PW MTCMOS EN [0x830]: VIDEO HARDEN power on */
        //media_pd_vdd = regulator_get(dev, "SOC_MED_PD_VDD");
        media_pd_vdd = regulator_get(NULL, "soc_med");
        if (IS_ERR(media_pd_vdd)) {
            media_pd_vdd    = NULL;
            up(&video_harden_busy_lock);
            printk(KERN_ERR "get video harden regulator failed!\n");
            return -1;
        }

        ret = regulator_enable(media_pd_vdd);
        if (0 != ret) {
            regulator_put(media_pd_vdd);
            media_pd_vdd    = NULL;
            up(&video_harden_busy_lock);
            printk(KERN_ERR "failed to enable video harden regulator.\n");
            return -1;
        }

        printk(KERN_INFO "video harden regulator is enabled successfully.\n");
    } else {
        printk(KERN_INFO "video harden regulator is already enabled! skip. \n");
    }

    switch (dev_id) {
        case VIDEO_HARDEN_DEV_ID_VCODEC: /* VCODEC */
            video_harden_regulator_vote.vcodec_bit = 1;
            break;

        case VIDEO_HARDEN_DEV_ID_JPEG: /* JPEG */
            video_harden_regulator_vote.jpeg_bit = 1;
            break;

        case VIDEO_HARDEN_DEV_ID_ISP: /* ISP */
            video_harden_regulator_vote.isp_bit = 1;
            break;
        default:
            break;
    }

    up(&video_harden_busy_lock);

    printk(KERN_INFO "%s, g_video_harden_vote is 0x%x.\n",
        __func__, *((unsigned int *)&video_harden_regulator_vote));

    return 0;
}
예제 #24
0
/**
 * allocate resources.
 * @pdev - pointer to platform device.
 */
static int dsps_alloc_resources(struct platform_device *pdev)
{
	int ret = -ENODEV;
	struct resource *ppss_res;
	struct resource *ppss_wdog;
	int i;

	pr_debug("%s.\n", __func__);

	if ((drv->pdata->signature != DSPS_SIGNATURE)) {
		pr_err("%s: invalid signature for pdata.", __func__);
		return -EINVAL;
	}

	ppss_res = platform_get_resource_byname(pdev, IORESOURCE_MEM,
						"ppss_reg");
	if (!ppss_res) {
		pr_err("%s: failed to get ppss_reg resource.\n", __func__);
		return -EINVAL;
	}

	for (i = 0; i < drv->pdata->clks_num; i++) {
		const char *name = drv->pdata->clks[i].name;
		struct clk *clock;

		drv->pdata->clks[i].clock = NULL;

		pr_debug("%s: get clk %s.", __func__, name);

		clock = clk_get(drv->dev, name);
		if (IS_ERR(clock)) {
			pr_err("%s: can't get clk %s.", __func__, name);
			goto clk_err;
		}
		drv->pdata->clks[i].clock = clock;
	}

	for (i = 0; i < drv->pdata->gpios_num; i++) {
		const char *name = drv->pdata->gpios[i].name;
		int num = drv->pdata->gpios[i].num;

		drv->pdata->gpios[i].is_owner = false;

		pr_debug("%s: get gpio %s.", __func__, name);

		ret = gpio_request(num, name);
		if (ret) {
			pr_err("%s: request GPIO %s err %d.",
			       __func__, name, ret);
			goto gpio_err;
		}

		drv->pdata->gpios[i].is_owner = true;

	}

	for (i = 0; i < drv->pdata->regs_num; i++) {
		const char *name = drv->pdata->regs[i].name;

		drv->pdata->regs[i].reg = NULL;

		pr_debug("%s: get regulator %s.", __func__, name);

		drv->pdata->regs[i].reg = regulator_get(drv->dev, name);
		if (IS_ERR(drv->pdata->regs[i].reg)) {
			pr_err("%s: get regulator %s failed.",
			       __func__, name);
			goto reg_err;
		}
	}

	drv->ppss_base = ioremap(ppss_res->start,
				 resource_size(ppss_res));

	ppss_wdog = platform_get_resource_byname(pdev, IORESOURCE_IRQ,
						"ppss_wdog");
	if (ppss_wdog) {
		drv->wdog_irq = ppss_wdog->start;
		ret = request_irq(drv->wdog_irq, dsps_wdog_bite_irq,
				  IRQF_TRIGGER_RISING, "dsps_wdog", NULL);
		if (ret) {
			pr_err("%s: request_irq fail %d\n", __func__, ret);
			goto request_irq_err;
		}
	} else {
		drv->wdog_irq = -1;
		pr_debug("%s: ppss_wdog not supported.\n", __func__);
	}

	drv->dspsfw_ramdump_segments[0].address = drv->pdata->tcm_code_start;
	drv->dspsfw_ramdump_segments[0].size =  drv->pdata->tcm_code_size;
	drv->dspsfw_ramdump_segments[1].address = drv->pdata->tcm_buf_start;
	drv->dspsfw_ramdump_segments[1].size =  drv->pdata->tcm_buf_size;
	drv->dspsfw_ramdump_segments[2].address = drv->pdata->pipe_start;
	drv->dspsfw_ramdump_segments[2].size =  drv->pdata->pipe_size;
	drv->dspsfw_ramdump_segments[3].address = drv->pdata->ddr_start;
	drv->dspsfw_ramdump_segments[3].size =  drv->pdata->ddr_size;

	drv->dspsfw_ramdump_dev = create_ramdump_device("dsps");
	if (!drv->dspsfw_ramdump_dev) {
		pr_err("%s: create_ramdump_device(\"dsps\") fail\n",
			      __func__);
		goto create_ramdump_err;
	}

	drv->smem_ramdump_segments[0].address = drv->pdata->smem_start;
	drv->smem_ramdump_segments[0].size =  drv->pdata->smem_size;
	drv->smem_ramdump_dev = create_ramdump_device("smem");
	if (!drv->smem_ramdump_dev) {
		pr_err("%s: create_ramdump_device(\"smem\") fail\n",
		       __func__);
		goto create_ramdump_err;
	}

	if (drv->pdata->init)
		drv->pdata->init(drv->pdata);

	return 0;

create_ramdump_err:
	disable_irq_nosync(drv->wdog_irq);
	free_irq(drv->wdog_irq, NULL);

request_irq_err:
	iounmap(drv->ppss_base);

reg_err:
	for (i = 0; i < drv->pdata->regs_num; i++) {
		if (drv->pdata->regs[i].reg) {
			regulator_put(drv->pdata->regs[i].reg);
			drv->pdata->regs[i].reg = NULL;
		}
	}

gpio_err:
	for (i = 0; i < drv->pdata->gpios_num; i++)
		if (drv->pdata->gpios[i].is_owner) {
			gpio_free(drv->pdata->gpios[i].num);
			drv->pdata->gpios[i].is_owner = false;
		}
clk_err:
	for (i = 0; i < drv->pdata->clks_num; i++)
		if (drv->pdata->clks[i].clock) {
			clk_put(drv->pdata->clks[i].clock);
			drv->pdata->clks[i].clock = NULL;
		}

	return ret;
}
예제 #25
0
static void ir_remocon_send(struct ir_remocon_data *data)
{
	unsigned int		period, off_period = 0;
	unsigned int		duty;
	unsigned int		on, off = 0;
	unsigned int		i, j;
	int					ret;
	static int		cpu_lv = -1;

	if (data->pwr_en == -1) {
		regulator = regulator_get(NULL, "vled_3.3v");
		if (IS_ERR(regulator))
			goto out;

		regulator_enable(regulator);
		regulator_status = 1;
	}

	if (data->pwr_en != -1)
		gpio_direction_output(data->pwr_en, 1);

	__udelay(1000);

	if (cpu_lv == -1) {
		if (data->pwr_en == -1)
			exynos_cpufreq_get_level(500000, &cpu_lv);
		else
			exynos_cpufreq_get_level(800000, &cpu_lv);
	}

	ret = exynos_cpufreq_lock(DVFS_LOCK_ID_IR_LED, cpu_lv);
	if (ret < 0)
		pr_err("%s: fail to lock cpufreq\n", __func__);

	ret = exynos_cpufreq_upper_limit(DVFS_LOCK_ID_IR_LED, cpu_lv);
	if (ret < 0)
		pr_err("%s: fail to lock cpufreq(limit)\n", __func__);

	if (data->pwr_en == -1)
		period  = (MICRO_SEC/data->signal[0])-2;
	else
		period  = (MICRO_SEC/data->signal[0])-1;

	duty = period/4;
	on = duty;
	off = period - duty;

	local_irq_disable();
	for (i = 1; i < MAX_SIZE; i += 2) {
		if (data->signal[i] == 0)
			break;

		for (j = 0; j < data->signal[i]; j++) {
			gpio_direction_output(data->gpio, 1);
			__udelay(on);
			gpio_direction_output(data->gpio, 0);
			__udelay(off);
		}

		if (data->pwr_en == -1)
			period = (MICRO_SEC/data->signal[0]);
		else
			period = (MICRO_SEC/data->signal[0])+1;

		off_period = data->signal[i+1]*period;

		if (off_period <= 9999) {
			if (off_period > 1000) {
				__udelay(off_period % 1000);
				mdelay(off_period/1000);
			} else
				__udelay(off_period);
		} else {
			local_irq_enable();
			__udelay(off_period % 1000);
			mdelay(off_period/1000);
			local_irq_disable();
		}
	}
	gpio_direction_output(data->gpio, 1);
	__udelay(on);
	gpio_direction_output(data->gpio, 0);
	__udelay(off);

	local_irq_enable();
	pr_info("%s end!\n", __func__);
	exynos_cpufreq_lock_free(DVFS_LOCK_ID_IR_LED);
	exynos_cpufreq_upper_limit_free(DVFS_LOCK_ID_IR_LED);

	if (data->pwr_en != -1)
		gpio_direction_output(data->pwr_en, 0);

	if ((data->pwr_en == -1) && (regulator_status == 1)) {
		regulator_force_disable(regulator);
		regulator_put(regulator);

		regulator_status = -1;
	}
out: ;
}
static int __devinit pm8058_othc_probe(struct platform_device *pd)
{
	int rc;
	struct pm8058_othc *dd;
	struct pm8058_chip *chip;
	struct resource *res;
	struct pmic8058_othc_config_pdata *pdata = pd->dev.platform_data;

	pr_err("[tagL] pmic8058_othc_probe called!");

	chip = platform_get_drvdata(pd);
	if (chip == NULL) {
		pr_err("Invalid driver information\n");
		return  -EINVAL;
	}

	/* Check PMIC8058 version. A0 version is not supported */
	if (pm8058_rev(chip) == PM_8058_REV_1p0) {
		pr_err("PMIC8058 version not supported\n");
		return -ENODEV;
	}

	if (pdata == NULL) {
		pr_err("Platform data not present\n");
		return -EINVAL;
	}

	dd = kzalloc(sizeof(*dd), GFP_KERNEL);
	if (dd == NULL) {
		pr_err("Unable to allocate memory\n");
		return -ENOMEM;
	}

	/* Enable runtime PM ops, start in ACTIVE mode */
	rc = pm_runtime_set_active(&pd->dev);
	if (rc < 0)
		dev_dbg(&pd->dev, "unable to set runtime pm state\n");
	pm_runtime_enable(&pd->dev);

	res = platform_get_resource_byname(pd, IORESOURCE_IO, "othc_base");
	if (res == NULL) {
		pr_err("othc resource:Base address absent\n");
		rc = -ENXIO;
		goto fail_get_res;
	}

	dd->othc_pdata = pdata;
	dd->pm_chip = chip;
	dd->othc_base = res->start;
	if (pdata->micbias_regulator == NULL) {
		pr_err("OTHC regulator not specified\n");
		goto fail_get_res;
	}

	dd->othc_vreg = regulator_get(NULL,
				pdata->micbias_regulator->regulator);
	if (IS_ERR(dd->othc_vreg)) {
		pr_err("regulator get failed\n");
		rc = PTR_ERR(dd->othc_vreg);
		goto fail_get_res;
	}

	rc = regulator_set_voltage(dd->othc_vreg,
				pdata->micbias_regulator->min_uV,
				pdata->micbias_regulator->max_uV);
	if (rc) {
		pr_err("othc regulator set voltage failed\n");
		goto fail_reg_enable;
	}

	rc = regulator_enable(dd->othc_vreg);
	if (rc) {
		pr_err("othc regulator enable failed\n");
		goto fail_reg_enable;
	}

	platform_set_drvdata(pd, dd);

	if (pdata->micbias_capability == OTHC_MICBIAS_HSED) {
		/* HSED to be supported on this MICBIAS line */
		if (pdata->hsed_config != NULL) {
			rc = othc_configure_hsed(dd, pd);
			if (rc < 0)
				goto fail_othc_hsed;
		} else {
			pr_err("HSED config data not present\n");
			rc = -EINVAL;
			goto fail_othc_hsed;
		}
	}

	/* Store the local driver data structure */
	if (dd->othc_pdata->micbias_select < OTHC_MICBIAS_MAX)
		config[dd->othc_pdata->micbias_select] = dd;

	pr_debug("Device %s:%d successfully registered\n",
					pd->name, pd->id);
	return 0;

fail_othc_hsed:
	regulator_disable(dd->othc_vreg);
fail_reg_enable:
	regulator_put(dd->othc_vreg);
fail_get_res:
	pm_runtime_set_suspended(&pd->dev);
	pm_runtime_disable(&pd->dev);

	kfree(dd);
	return rc;
}
예제 #27
0
static int __devinit ad9834_probe(struct spi_device *spi)
{
	struct ad9834_platform_data *pdata = spi->dev.platform_data;
	struct ad9834_state *st;
	struct iio_dev *indio_dev;
	struct regulator *reg;
	int ret;

	if (!pdata) {
		dev_dbg(&spi->dev, "no platform data?\n");
		return -ENODEV;
	}

	reg = regulator_get(&spi->dev, "vcc");
	if (!IS_ERR(reg)) {
		ret = regulator_enable(reg);
		if (ret)
			goto error_put_reg;
	}

	indio_dev = iio_allocate_device(sizeof(*st));
	if (indio_dev == NULL) {
		ret = -ENOMEM;
		goto error_disable_reg;
	}
	spi_set_drvdata(spi, indio_dev);
	st = iio_priv(indio_dev);
	st->mclk = pdata->mclk;
	st->spi = spi;
	st->devid = spi_get_device_id(spi)->driver_data;
	st->reg = reg;
	indio_dev->dev.parent = &spi->dev;
	indio_dev->name = spi_get_device_id(spi)->name;
	switch (st->devid) {
	case ID_AD9833:
	case ID_AD9837:
		indio_dev->info = &ad9833_info;
		break;
	default:
		indio_dev->info = &ad9834_info;
		break;
	}
	indio_dev->modes = INDIO_DIRECT_MODE;

	/* Setup default messages */

	st->xfer.tx_buf = &st->data;
	st->xfer.len = 2;

	spi_message_init(&st->msg);
	spi_message_add_tail(&st->xfer, &st->msg);

	st->freq_xfer[0].tx_buf = &st->freq_data[0];
	st->freq_xfer[0].len = 2;
	st->freq_xfer[0].cs_change = 1;
	st->freq_xfer[1].tx_buf = &st->freq_data[1];
	st->freq_xfer[1].len = 2;

	spi_message_init(&st->freq_msg);
	spi_message_add_tail(&st->freq_xfer[0], &st->freq_msg);
	spi_message_add_tail(&st->freq_xfer[1], &st->freq_msg);

	st->control = AD9834_B28 | AD9834_RESET;

	if (!pdata->en_div2)
		st->control |= AD9834_DIV2;

	if (!pdata->en_signbit_msb_out && (st->devid == ID_AD9834))
		st->control |= AD9834_SIGN_PIB;

	st->data = cpu_to_be16(AD9834_REG_CMD | st->control);
	ret = spi_sync(st->spi, &st->msg);
	if (ret) {
		dev_err(&spi->dev, "device init failed\n");
		goto error_free_device;
	}

	ret = ad9834_write_frequency(st, AD9834_REG_FREQ0, pdata->freq0);
	if (ret)
		goto error_free_device;

	ret = ad9834_write_frequency(st, AD9834_REG_FREQ1, pdata->freq1);
	if (ret)
		goto error_free_device;

	ret = ad9834_write_phase(st, AD9834_REG_PHASE0, pdata->phase0);
	if (ret)
		goto error_free_device;

	ret = ad9834_write_phase(st, AD9834_REG_PHASE1, pdata->phase1);
	if (ret)
		goto error_free_device;

	ret = iio_device_register(indio_dev);
	if (ret)
		goto error_free_device;

	return 0;

error_free_device:
	iio_free_device(indio_dev);
error_disable_reg:
	if (!IS_ERR(reg))
		regulator_disable(reg);
error_put_reg:
	if (!IS_ERR(reg))
		regulator_put(reg);
	return ret;
}
void sku3_lcdc_power_init(void)
{
	int rc = 0;
	u32 socinfo = socinfo_get_platform_type();

	  /* LDO_EXT2V8 */
	if (gpio_request(SKU3_LCDC_LCD_CAMERA_LDO_2V8, "lcd_camera_ldo_2v8")) {
		pr_err("failed to request gpio lcd_camera_ldo_2v8\n");
		return;
	}

	rc = gpio_tlmm_config(GPIO_CFG(SKU3_LCDC_LCD_CAMERA_LDO_2V8, 0,
		GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
		GPIO_CFG_ENABLE);

	if (rc < 0) {
		pr_err("%s:unable to enable lcd_camera_ldo_2v8!\n", __func__);
		goto fail_gpio2;
	}

	/* LDO_EVT1V8 */
	if (socinfo == 0x0B) {
		if (gpio_request(SKU3_LCDC_LCD_CAMERA_LDO_1V8,
				"lcd_camera_ldo_1v8")) {
			pr_err("failed to request gpio lcd_camera_ldo_1v8\n");
			goto fail_gpio1;
		}

		rc = gpio_tlmm_config(GPIO_CFG(SKU3_LCDC_LCD_CAMERA_LDO_1V8, 0,
			GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
			GPIO_CFG_ENABLE);

		if (rc < 0) {
			pr_err("%s: unable to enable lcdc_camera_ldo_1v8!\n",
				__func__);
			goto fail_gpio1;
		}
	} else if (socinfo == 0x0F || machine_is_msm8625_qrd7()) {
		if (gpio_request(SKU3_1_LCDC_LCD_CAMERA_LDO_1V8,
				"lcd_camera_ldo_1v8")) {
			pr_err("failed to request gpio lcd_camera_ldo_1v8\n");
			goto fail_gpio1;
		}

		rc = gpio_tlmm_config(GPIO_CFG(SKU3_1_LCDC_LCD_CAMERA_LDO_1V8,
			0, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
			GPIO_CFG_ENABLE);

		if (rc < 0) {
			pr_err("%s: unable to enable lcdc_camera_ldo_1v8!\n",
				__func__);
			goto fail_gpio1;
		}
	}

	if (socinfo == 0x0B)
		gpio_free(SKU3_LCDC_LCD_CAMERA_LDO_1V8);
	else if (socinfo == 0x0F || machine_is_msm8625_qrd7())
		gpio_free(SKU3_1_LCDC_LCD_CAMERA_LDO_1V8);

	gpio_free(SKU3_LCDC_LCD_CAMERA_LDO_2V8);

	gpio_reg_2p85v_sku3 = regulator_get(&msm_lcdc_device.dev,
							"lcd_vdd_sku3");
	if (IS_ERR(gpio_reg_2p85v_sku3)) {
		pr_err("%s:ext_2p85v regulator get failed", __func__);
		regulator_put(gpio_reg_2p85v_sku3);
		return;
	}

	gpio_reg_1p8v_sku3 = regulator_get(&msm_lcdc_device.dev,
							"lcd_vddi_sku3");
	if (IS_ERR(gpio_reg_1p8v_sku3)) {
		pr_err("%s:ext_1p8v regulator get failed", __func__);
		regulator_put(gpio_reg_1p8v_sku3);
		return;
	}

	rc = regulator_bulk_get(NULL, ARRAY_SIZE(regs_truly_lcdc),
			regs_truly_lcdc);
	if (rc)
		pr_err("%s: could not get regulators: %d\n", __func__, rc);

	rc = regulator_bulk_set_voltage(ARRAY_SIZE(regs_truly_lcdc),
			regs_truly_lcdc);
	if (rc)
		pr_err("%s: could not set voltages: %d\n", __func__, rc);

	return;

fail_gpio1:
	if (socinfo == 0x0B)
		gpio_free(SKU3_LCDC_LCD_CAMERA_LDO_1V8);
	else if (socinfo == 0x0F || machine_is_msm8625_qrd7())
		gpio_free(SKU3_1_LCDC_LCD_CAMERA_LDO_1V8);
fail_gpio2:
	gpio_free(SKU3_LCDC_LCD_CAMERA_LDO_2V8);
	return;
}
예제 #29
0
static int adc1x8s102_probe(struct spi_device *spi)
{
    struct adc1x8s102_platform_data *pdata = spi->dev.platform_data;
    struct adc1x8s102_state *st;
    struct iio_dev *indio_dev = iio_device_alloc(sizeof(*st));
    int ret;

    if (NULL == indio_dev) {
        dev_crit(&spi->dev, "Cannot allocate memory for indio_dev\n");
        return -ENOMEM;
    }

    st = iio_priv(indio_dev);
    if (NULL == pdata) {
        dev_err(&spi->dev, "Cannot get adc1x8s102 platform data\n");
        return -EFAULT;
    }
    st->ext_vin = pdata->ext_vin;

    /* Use regulator, if available. */
    st->reg = regulator_get(&spi->dev, "vref");
    if (IS_ERR(st->reg)) {
        ret = PTR_ERR(st->reg);
        dev_warn(&spi->dev,
                 "Cannot get 'vref' regulator\n");
        goto error_free;
    }
    ret = regulator_enable(st->reg);
    if (ret < 0) {
        dev_warn(&spi->dev,
                 "Cannot enable vref regulator\n");
        goto error_put_reg;
    }

    spi_set_drvdata(spi, indio_dev);
    st->spi = spi;

    indio_dev->name = spi_get_device_id(spi)->name;
    indio_dev->dev.parent = &spi->dev;
    indio_dev->modes = INDIO_DIRECT_MODE;
    indio_dev->channels = adc1x8s102_channels;
    indio_dev->num_channels = ARRAY_SIZE(adc1x8s102_channels);
    indio_dev->info = &adc1x8s102_info;

    /* Setup default message */
    st->scan_single_xfer.tx_buf = st->tx_buf;
    st->scan_single_xfer.rx_buf = st->rx_buf;
    st->scan_single_xfer.len = 2 * sizeof(__be16);
    st->scan_single_xfer.cs_change = 0;

    spi_message_init(&st->scan_single_msg);
    spi_message_add_tail(&st->scan_single_xfer, &st->scan_single_msg);

    ret = iio_triggered_buffer_setup(indio_dev, NULL,
                                     &adc1x8s102_trigger_handler, NULL);
    if (ret)
        goto error_disable_reg;

    ret = iio_device_register(indio_dev);
    if (ret) {
        dev_err(&spi->dev,
                "Failed to register IIO device\n");
        goto error_cleanup_ring;
    }
    return 0;

error_cleanup_ring:
    iio_triggered_buffer_cleanup(indio_dev);
error_disable_reg:
    regulator_disable(st->reg);
error_put_reg:
    regulator_put(st->reg);
error_free:
    iio_device_free(indio_dev);

    return ret;
}
예제 #30
0
static void devm_regulator_release(struct device *dev, void *res)
{
	regulator_put(*(struct regulator **)res);
}