예제 #1
0
static int tegra_camera_probe(struct platform_device *pdev)
{
	int err;

	pr_info("%s: probe\n", TEGRA_CAMERA_NAME);
#ifdef CONFIG_ARCH_TEGRA_2x_SOC
	tegra_camera_regulator_csi = regulator_get(&pdev->dev, "vcsi");
#else
	tegra_camera_regulator_csi = regulator_get(&pdev->dev, "avdd_dsi_csi");
#endif
	if (IS_ERR_OR_NULL(tegra_camera_regulator_csi)) {
		pr_err("%s: Couldn't get regulator\n", TEGRA_CAMERA_NAME);
		return PTR_ERR(tegra_camera_regulator_csi);
	}

	err = misc_register(&tegra_camera_device);
	if (err) {
		pr_err("%s: Unable to register misc device!\n",
		       TEGRA_CAMERA_NAME);
		goto misc_register_err;
	}

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

	return 0;

csi_clk_get_err:
	clk_put(csus_clk);
csus_clk_get_err:
	clk_put(vi_sensor_clk);
vi_sensor_clk_get_err:
	clk_put(vi_clk);
vi_clk_get_err:
	clk_put(isp_clk);
misc_register_err:
	regulator_put(tegra_camera_regulator_csi);
	return err;
}
예제 #2
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;
	pdata = pdev->dev.platform_data;

	/* 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);
		}
	}

	regulator_set_voltage(dev->reg, 1200000, 1200000);

	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);
	p_cam_dev = 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;
}
예제 #3
0
static int tegra_camera_probe(struct platform_device *pdev)
{
	int err;

	pr_info("%s: probe\n", TEGRA_CAMERA_NAME);

	mutex_lock(&tegra_camera_lock);
	tegra_camera_powergate = 0;
	err = tegra_powergate_partition(TEGRA_POWERGATE_VENC);
	if (err)
		pr_err("%s: Powergating failed.\n", __func__);
	mutex_unlock(&tegra_camera_lock);

#ifdef CONFIG_ARCH_TEGRA_2x_SOC
	tegra_camera_regulator_csi = regulator_get(&pdev->dev, "vcsi");
#else
	tegra_camera_regulator_csi = regulator_get(&pdev->dev, "avdd_dsi_csi");
#endif
	if (IS_ERR_OR_NULL(tegra_camera_regulator_csi)) {
		pr_err("%s: Couldn't get regulator\n", TEGRA_CAMERA_NAME);
		return PTR_ERR(tegra_camera_regulator_csi);
	}
	regulator_set_voltage(tegra_camera_regulator_csi, 1200000, 1200000);

	err = misc_register(&tegra_camera_device);
	if (err) {
		pr_err("%s: Unable to register misc device!\n",
		       TEGRA_CAMERA_NAME);
		goto misc_register_err;
	}

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

	return 0;

csi_clk_get_err:
	clk_put(csus_clk);
csus_clk_get_err:
	clk_put(vi_sensor_clk);
vi_sensor_clk_get_err:
	clk_put(vi_clk);
vi_clk_get_err:
	clk_put(isp_clk);
misc_register_err:
	regulator_put(tegra_camera_regulator_csi);
	return err;
}
예제 #4
0
static int tegra_camera_probe(struct platform_device *pdev)
{
	int err;
#ifdef CONFIG_TEGRA_DYNAMIC_CAMERA_CLK_RATE
	int i;

	graphics_clk_cfg =
			(struct tegra_camera_clk_config*) (pdev->dev.platform_data);
	graphics_clks = NULL;
	graphics_restore_clks = NULL;
	set_graphics_clk = 1;
	current_usecase = CAMERA_USECASE_PREVIEW;
#endif
	pr_info("%s: probe\n", TEGRA_CAMERA_NAME);
#ifndef CONFIG_MACH_N1
	tegra_camera_regulator_csi = regulator_get(&pdev->dev, "vcsi");
	if (IS_ERR_OR_NULL(tegra_camera_regulator_csi)) {
		pr_err("%s: Couldn't get regulator vcsi\n", TEGRA_CAMERA_NAME);
		return PTR_ERR(tegra_camera_regulator_csi);
	}
#endif

	err = misc_register(&tegra_camera_device);
	if (err) {
		pr_err("%s: Unable to register misc device!\n",
		       TEGRA_CAMERA_NAME);
		goto misc_register_err;
	}

#ifdef CONFIG_TEGRA_DYNAMIC_CAMERA_CLK_RATE
	err = misc_register(&tegra_camera_clk_device);
	if (err) {
		pr_err("%s: Unable to register misc clk device!\n",
			__func__);
		goto misc_register_clk_err;
	}
#endif

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

#ifdef CONFIG_TEGRA_DYNAMIC_CAMERA_CLK_RATE
	graphics_clks = tegra_camera_get_clks(
			graphics_clk_cfg->n_clks,
			graphics_clk_cfg->clk_devs,
			graphics_clk_cfg->clk_cons);

	if (graphics_clks == NULL)
		goto graphic_clk_get_err;

	graphics_restore_clks = tegra_camera_get_clks(
			graphics_clk_cfg->n_restore_clks,
			graphics_clk_cfg->clk_restore_devs,
			graphics_clk_cfg->clk_restore_cons);
	if (graphics_clks == NULL)
		goto graphic_restore_clk_get_err;

	graphics_restore_clk_rates = kmalloc(sizeof(unsigned long) *
				graphics_clk_cfg->n_restore_clks, GFP_KERNEL);

	if (graphics_restore_clk_rates == NULL)
		goto graphic_restore_clk_get_err;
#endif
#if defined CONFIG_HAS_EARLYSUSPEND && defined CONFIG_CPU_FREQ
	work_q_set_conservative = 0;
	INIT_DELAYED_WORK(&scaling_gov_work, set_scaling_gov_work);
#endif

	return 0;

#ifdef CONFIG_TEGRA_DYNAMIC_CAMERA_CLK_RATE
graphic_restore_clk_get_err:
	for (i = 0; i <graphics_clk_cfg->n_restore_clks
			 && graphics_restore_clks[i] != NULL; i++)
		clk_put(graphics_restore_clks[i]);
	if (graphics_restore_clks != NULL)
		kfree(graphics_restore_clks);
	if (graphics_restore_clk_rates != NULL)
		kfree(graphics_restore_clk_rates);
graphic_clk_get_err:
	for (i = 0; i <graphics_clk_cfg->n_clks
			 && graphics_clks[i] != NULL; i++)
		clk_put(graphics_clks[i]);
	if (graphics_clks != NULL)
		kfree(graphics_clks);
#endif
csi_clk_get_err:
	clk_put(csus_clk);
csus_clk_get_err:
	clk_put(vi_sensor_clk);
vi_sensor_clk_get_err:
	clk_put(vi_clk);
vi_clk_get_err:
	clk_put(isp_clk);
#ifdef CONFIG_TEGRA_DYNAMIC_CAMERA_CLK_RATE
misc_register_clk_err:
	misc_deregister(&tegra_camera_device);
#endif
misc_register_err:
	regulator_put(tegra_camera_regulator_csi);
	return err;
}
예제 #5
0
struct tegra_camera *tegra_camera_register(struct platform_device *ndev)
{
	struct tegra_camera *camera = NULL;
	int ret = 0;
	int i;

	dev_info(&ndev->dev, "%s: ++\n", __func__);

	camera = kzalloc(sizeof(struct tegra_camera), GFP_KERNEL);
	if (!camera) {
		dev_err(&ndev->dev, "can't allocate memory for tegra_camera\n");
		return camera;
	}

	mutex_init(&camera->tegra_camera_lock);

	/* Powergate VE when boot */
	mutex_lock(&camera->tegra_camera_lock);
#ifndef CONFIG_ARCH_TEGRA_2x_SOC
	ret = tegra_camera_powergate_init(camera);
	if (ret)
		goto regulator_fail;
#endif
	mutex_unlock(&camera->tegra_camera_lock);

	camera->dev = &ndev->dev;

	/* Get regulator pointer */
#ifdef CONFIG_ARCH_TEGRA_2x_SOC
	camera->reg = regulator_get(&ndev->dev, "vcsi");
#else
	camera->reg = regulator_get(&ndev->dev, "avdd_dsi_csi");
#endif

	if (IS_ERR_OR_NULL(camera->reg)) {
		ret = -ENODEV;
		if (camera->reg == ERR_PTR(-ENODEV)) {
			camera->reg = NULL;
			dev_info(&ndev->dev,
				"%s: no regulator device, overriding\n",
							__func__);
		} else {
			dev_err(&ndev->dev, "%s: couldn't get regulator\n",
							__func__);
			goto regulator_fail;
		}
	}

	camera->misc_dev.minor = MISC_DYNAMIC_MINOR;
	camera->misc_dev.name = TEGRA_CAMERA_NAME;
	camera->misc_dev.fops = &tegra_camera_fops;
	camera->misc_dev.parent = &ndev->dev;
	ret = misc_register(&camera->misc_dev);
	if (ret) {
		dev_err(&ndev->dev, "%s: unable to register misc device!\n",
			TEGRA_CAMERA_NAME);
		goto misc_register_fail;
	}

	for (i = 0; i < CAMERA_CLK_MAX; i++) {
		ret = tegra_camera_clk_get(ndev, clock_init[i].name,
				&camera->clock[clock_init[i].index].clk);
		if (ret)
			goto clk_get_fail;
	}

#ifdef CONFIG_ARCH_TEGRA_11x_SOC
	/* Dedicated bw is what VI could ask for at most */
	camera->isomgr_handle = tegra_isomgr_register(TEGRA_ISO_CLIENT_VI_0,
					/* dedicated bw, KBps*/
					tegra_camera_get_max_bw(camera),
					NULL,	/* tegra_isomgr_renegotiate */
					NULL);	/* *priv */
	if (!camera->isomgr_handle) {
		dev_err(&ndev->dev, "%s: unable to register isomgr\n",
					__func__);
		goto clk_get_fail;
	}
#endif

	return camera;

clk_get_fail:
	for (; i > 0; i--)
		clk_put(camera->clock[clock_init[i].index].clk);
	misc_deregister(&camera->misc_dev);
misc_register_fail:
	regulator_put(camera->reg);
regulator_fail:
	kfree(camera);
	camera = NULL;
	return camera;
}