diff options
author | Arto Merilainen <amerilainen@nvidia.com> | 2014-05-28 21:30:45 +0300 |
---|---|---|
committer | Riham Haidar <rhaidar@nvidia.com> | 2014-05-30 12:12:00 -0700 |
commit | 1b7e1ff5f0935952309a7ce946561a0d5ceed4ce (patch) | |
tree | cbbc6f2450d9cfd72337eb243b1658be9b64c43c | |
parent | c831cca475194014218c19fef7d59bf57a48ea8e (diff) |
drivers: video: tegra: vi: implement probe/remove
add probe/remove callback functions for tegra_vi to keep and release
regulator properly.
bug 200003367
Change-Id: I790d7d1822cacd1d8b01913ecedf6d73d83a8786
Signed-off-by: Charlie Huang <chahuang@nvidia.com>
Signed-off-by: Arto Merilainen <amerilainen@nvidia.com>
Reviewed-on: http://git-master/r/416407
Reviewed-by: Automatic_Commit_Validation_User
Reviewed-by: Bharat Nihalani <bnihalani@nvidia.com>
-rw-r--r-- | drivers/video/tegra/host/t124/t124.c | 8 | ||||
-rw-r--r-- | drivers/video/tegra/host/vi/tegra_vi.c | 44 | ||||
-rw-r--r-- | drivers/video/tegra/host/vi/vi.c | 24 | ||||
-rw-r--r-- | drivers/video/tegra/host/vi/vi.h | 2 |
4 files changed, 26 insertions, 52 deletions
diff --git a/drivers/video/tegra/host/t124/t124.c b/drivers/video/tegra/host/t124/t124.c index d8c3332d7dd7..b258e0957f1f 100644 --- a/drivers/video/tegra/host/t124/t124.c +++ b/drivers/video/tegra/host/t124/t124.c @@ -207,8 +207,6 @@ struct nvhost_device_data t124_vi_info = { {"cilab", 102000000}, {"emc", 0, TEGRA_HOST1X_EMC_MODULE_ID}, {"sclk", 80000000} }, - .init = nvhost_vi_init, - .deinit = nvhost_vi_deinit, .prepare_poweroff = nvhost_vi_prepare_poweroff, .finalize_poweron = nvhost_vi_finalize_poweron, .ctrl_ops = &tegra_vi_ctrl_ops, @@ -246,8 +244,6 @@ struct nvhost_device_data t124_vib_info = { {"cile", 102000000}, {"emc", 0, TEGRA_HOST1X_EMC_MODULE_ID}, {"sclk", 80000000} }, - .init = nvhost_vi_init, - .deinit = nvhost_vi_deinit, .prepare_poweroff = nvhost_vi_prepare_poweroff, .finalize_poweron = nvhost_vi_finalize_poweron, .ctrl_ops = &tegra_vi_ctrl_ops, @@ -450,8 +446,6 @@ struct nvhost_device_data t132_vi_info = { {"csi", 0}, {"cilab", 102000000}, {"emc", 0, TEGRA_HOST1X_EMC_MODULE_ID} }, - .init = nvhost_vi_init, - .deinit = nvhost_vi_deinit, .prepare_poweroff = nvhost_vi_prepare_poweroff, .finalize_poweron = nvhost_vi_finalize_poweron, .ctrl_ops = &tegra_vi_ctrl_ops, @@ -477,8 +471,6 @@ struct nvhost_device_data t132_vib_info = { {"cilcd", 102000000}, {"cile", 102000000}, {"emc", 0, TEGRA_HOST1X_EMC_MODULE_ID} }, - .init = nvhost_vi_init, - .deinit = nvhost_vi_deinit, .prepare_poweroff = nvhost_vi_prepare_poweroff, .finalize_poweron = nvhost_vi_finalize_poweron, .ctrl_ops = &tegra_vi_ctrl_ops, diff --git a/drivers/video/tegra/host/vi/tegra_vi.c b/drivers/video/tegra/host/vi/tegra_vi.c index 4499e569e33e..878864426eca 100644 --- a/drivers/video/tegra/host/vi/tegra_vi.c +++ b/drivers/video/tegra/host/vi/tegra_vi.c @@ -56,49 +56,13 @@ static DEFINE_MUTEX(la_lock); #ifdef TEGRA_12X_OR_HIGHER_CONFIG -int nvhost_vi_init(struct platform_device *dev) -{ - int ret = 0; - struct vi *tegra_vi = nvhost_get_private_data(dev); - - if (!tegra_vi) - return -ENODEV; - - tegra_vi->reg = regulator_get(&dev->dev, "avdd_dsi_csi"); - if (IS_ERR(tegra_vi->reg)) { - if (tegra_vi->reg == ERR_PTR(-ENODEV)) { - ret = -ENODEV; - dev_info(&dev->dev, - "%s: no regulator device\n", - __func__); - } else { - dev_err(&dev->dev, - "%s: couldn't get regulator\n", - __func__); - } - tegra_vi->reg = NULL; - return ret; - } - - return 0; -} - -void nvhost_vi_deinit(struct platform_device *dev) -{ - struct vi *tegra_vi = nvhost_get_private_data(dev); - - if (tegra_vi && tegra_vi->reg) { - regulator_put(tegra_vi->reg); - tegra_vi->reg = NULL; - } -} - int nvhost_vi_finalize_poweron(struct platform_device *dev) { int ret = 0; struct vi *tegra_vi; tegra_vi = (struct vi *)nvhost_get_private_data(dev); + if (tegra_vi && tegra_vi->reg) { ret = regulator_enable(tegra_vi->reg); if (ret) { @@ -113,7 +77,7 @@ int nvhost_vi_finalize_poweron(struct platform_device *dev) if (dev->id == 0) host1x_writel(dev, T12_VI_CFG_CG_CTRL, T12_CG_2ND_LEVEL_EN); - fail: +fail: return ret; } @@ -132,7 +96,7 @@ int nvhost_vi_prepare_poweroff(struct platform_device *dev) goto fail; } } - fail: +fail: return ret; } @@ -222,7 +186,7 @@ static int vi_set_la(struct vi *tegra_vi1, uint vi_bw) (struct nvhost_device_data *)tegra_vi1->ndev->dev.platform_data; if (!pdata_vi1) - return -ENODEV; + return -ENODEV; /* Copy device data for other vi device */ mutex_lock(&la_lock); diff --git a/drivers/video/tegra/host/vi/vi.c b/drivers/video/tegra/host/vi/vi.c index 94d426363a72..c76f1d77d661 100644 --- a/drivers/video/tegra/host/vi/vi.c +++ b/drivers/video/tegra/host/vi/vi.c @@ -185,12 +185,25 @@ static int vi_probe(struct platform_device *dev) if (i2c_ctrl && i2c_ctrl->new_devices) i2c_ctrl->new_devices(dev); + tegra_vi->reg = regulator_get(&tegra_vi->ndev->dev, "avdd_dsi_csi"); + if (IS_ERR(tegra_vi->reg)) { + err = PTR_ERR(tegra_vi->reg); + if (err == -ENODEV) + dev_info(&tegra_vi->ndev->dev, + "%s: no regulator device\n", __func__); + else + dev_err(&tegra_vi->ndev->dev, + "%s: couldn't get regulator\n", __func__); + tegra_vi->reg = NULL; + goto camera_i2c_unregister; + } + #ifdef CONFIG_TEGRA_CAMERA tegra_vi->camera = tegra_camera_register(dev); if (!tegra_vi->camera) { dev_err(&dev->dev, "%s: can't register tegra_camera\n", __func__); - goto camera_i2c_unregister; + goto vi_regulator_put; } #endif @@ -213,8 +226,12 @@ static int vi_probe(struct platform_device *dev) camera_unregister: #ifdef CONFIG_TEGRA_CAMERA tegra_camera_unregister(tegra_vi->camera); -camera_i2c_unregister: +vi_regulator_put: #endif + regulator_put(tegra_vi->reg); + tegra_vi->reg = NULL; + +camera_i2c_unregister: if (i2c_ctrl && i2c_ctrl->remove_devices) i2c_ctrl->remove_devices(dev); pdata->private_data = i2c_ctrl; @@ -255,6 +272,9 @@ static int __exit vi_remove(struct platform_device *dev) tegra_pd_remove_device(&dev->dev); #endif + regulator_put(tegra_vi->reg); + tegra_vi->reg = NULL; + /* Remove I2C Devices according to settings from board file */ if (i2c_ctrl && i2c_ctrl->remove_devices) i2c_ctrl->remove_devices(dev); diff --git a/drivers/video/tegra/host/vi/vi.h b/drivers/video/tegra/host/vi/vi.h index 7ba53d343073..b5c8fae8f593 100644 --- a/drivers/video/tegra/host/vi/vi.h +++ b/drivers/video/tegra/host/vi/vi.h @@ -52,8 +52,6 @@ struct vi { extern const struct file_operations tegra_vi_ctrl_ops; int nvhost_vi_prepare_poweroff(struct platform_device *); int nvhost_vi_finalize_poweron(struct platform_device *); -int nvhost_vi_init(struct platform_device *); -void nvhost_vi_deinit(struct platform_device *); void nvhost_vi_reset(struct platform_device *); #endif |