summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBryan Wu <pengw@nvidia.com>2014-09-17 18:04:17 -0700
committerWinnie Hsu <whsu@nvidia.com>2015-01-07 18:05:29 -0800
commit373c23c7936c05f615d3db569198c10be3d9d4b2 (patch)
tree99fd916382f2bcf633b5209f331182ebf5bd26ef
parent2e8fe26468a7c4e9b41e5bbd28681664e1153238 (diff)
media: tegra_v4l2_camera: use port num to init clk
Change clks_init() internal API to use CSI port number to enable clks instead of using dev_id which is incorrect sometime, since vi.0 might also assigned to CSI_B/CSI_C port. Bug 1560636 Change-Id: I0e26308ec885e2e34fe8faa63fca404c911912c4 Signed-off-by: Bryan Wu <pengw@nvidia.com> Reviewed-on: http://git-master/r/539002 Reviewed-by: Venkat Moganty <vmoganty@nvidia.com> (cherry picked from commit c66d8e5880589b0d95dba63d10daff53e47e8628) Reviewed-on: http://git-master/r/665995 Reviewed-by: Automatic_Commit_Validation_User GVS: Gerrit_Virtual_Submit Reviewed-by: Winnie Hsu <whsu@nvidia.com>
-rw-r--r--arch/arm/mach-tegra/tegra12_clocks.c5
-rw-r--r--drivers/media/platform/soc_camera/tegra_camera/common.c29
-rw-r--r--drivers/media/platform/soc_camera/tegra_camera/common.h2
-rw-r--r--drivers/media/platform/soc_camera/tegra_camera/vi.c2
-rw-r--r--drivers/media/platform/soc_camera/tegra_camera/vi2.c17
5 files changed, 32 insertions, 23 deletions
diff --git a/arch/arm/mach-tegra/tegra12_clocks.c b/arch/arm/mach-tegra/tegra12_clocks.c
index d89cda845a78..bb738a86b51a 100644
--- a/arch/arm/mach-tegra/tegra12_clocks.c
+++ b/arch/arm/mach-tegra/tegra12_clocks.c
@@ -8620,9 +8620,14 @@ struct clk_duplicate tegra_clk_duplicates[] = {
CLK_DUPLICATE("csi", "tegra_vi.0", "csi"),
CLK_DUPLICATE("csi", "tegra_vi.1", "csi"),
CLK_DUPLICATE("csus", "tegra_vi.0", "csus"),
+ CLK_DUPLICATE("csus", "tegra_vi.1", "csus"),
+ CLK_DUPLICATE("vim2_clk", "tegra_vi.0", "vim2_clk"),
CLK_DUPLICATE("vim2_clk", "tegra_vi.1", "vim2_clk"),
CLK_DUPLICATE("cilab", "tegra_vi.0", "cilab"),
+ CLK_DUPLICATE("cilab", "tegra_vi.1", "cilab"),
+ CLK_DUPLICATE("cilcd", "tegra_vi.0", "cilcd"),
CLK_DUPLICATE("cilcd", "tegra_vi.1", "cilcd"),
+ CLK_DUPLICATE("cile", "tegra_vi.0", "cile"),
CLK_DUPLICATE("cile", "tegra_vi.1", "cile"),
CLK_DUPLICATE("i2s0", NULL, "i2s0"),
CLK_DUPLICATE("i2s1", NULL, "i2s1"),
diff --git a/drivers/media/platform/soc_camera/tegra_camera/common.c b/drivers/media/platform/soc_camera/tegra_camera/common.c
index 6274696ae83f..bcaf607d8336 100644
--- a/drivers/media/platform/soc_camera/tegra_camera/common.c
+++ b/drivers/media/platform/soc_camera/tegra_camera/common.c
@@ -132,9 +132,13 @@ static const struct soc_mbus_pixelfmt tegra_camera_rgb_formats[] = {
},
};
-static int tegra_camera_activate(struct tegra_camera_dev *cam)
+static int tegra_camera_activate(struct tegra_camera_dev *cam,
+ struct soc_camera_device *icd)
{
struct tegra_camera_ops *cam_ops = cam->ops;
+ struct soc_camera_subdev_desc *ssdesc = &icd->sdesc->subdev_desc;
+ struct tegra_camera_platform_data *pdata = ssdesc->drv_priv;
+ int port = pdata->port;
int ret;
ret = nvhost_module_busy_ext(cam->ndev);
@@ -156,6 +160,10 @@ static int tegra_camera_activate(struct tegra_camera_dev *cam)
/* Unpowergate VE */
tegra_unpowergate_partition(TEGRA_POWERGATE_VENC);
+ /* Init Clocks */
+ if (cam_ops->clks_init)
+ cam_ops->clks_init(cam, port);
+
if (cam_ops->clks_enable)
cam_ops->clks_enable(cam);
@@ -174,6 +182,9 @@ static void tegra_camera_deactivate(struct tegra_camera_dev *cam)
if (cam_ops->clks_disable)
cam_ops->clks_disable(cam);
+ if (cam->ops->clks_deinit)
+ cam->ops->clks_deinit(cam);
+
if (cam_ops->deactivate)
cam_ops->deactivate(cam);
@@ -225,7 +236,7 @@ static int tegra_camera_capture_frame(struct tegra_camera_dev *cam)
if (!retry) {
tegra_camera_deactivate(cam);
mdelay(5);
- tegra_camera_activate(cam);
+ tegra_camera_activate(cam, icd);
if (cam->active)
cam->ops->capture_setup(cam);
}
@@ -577,7 +588,7 @@ static int tegra_camera_add_device(struct soc_camera_device *icd)
int ret;
if (!cam->enable_refcnt) {
- ret = tegra_camera_activate(cam);
+ ret = tegra_camera_activate(cam, icd);
if (ret)
return ret;
cam->num_frames = 0;
@@ -914,16 +925,13 @@ static int tegra_camera_probe(struct platform_device *pdev)
#endif
}
- /* Init Clocks */
- cam->ops->clks_init(cam);
-
/* Init Regulator */
cam->reg = devm_regulator_get(&pdev->dev, cam->regulator_name);
if (IS_ERR_OR_NULL(cam->reg)) {
dev_err(&pdev->dev, "%s: couldn't get regulator %s, err %ld\n",
__func__, cam->regulator_name, PTR_ERR(cam->reg));
cam->reg = NULL;
- goto exit_deinit_clk;
+ goto exit;
}
mutex_init(&ndata->lock);
@@ -932,7 +940,7 @@ static int tegra_camera_probe(struct platform_device *pdev)
if (err) {
dev_err(&pdev->dev, "%s: nvhost get resources failed %d\n",
__func__, err);
- goto exit_deinit_clk;
+ goto exit;
}
/* Init syncpts */
@@ -983,8 +991,6 @@ exit_cleanup_alloc_ctx:
vb2_dma_contig_cleanup_ctx(cam->alloc_ctx);
exit_free_syncpts:
cam->ops->free_syncpts(cam);
-exit_deinit_clk:
- cam->ops->clks_deinit(cam);
exit:
return err;
}
@@ -1006,9 +1012,6 @@ static int tegra_camera_remove(struct platform_device *pdev)
if (cam->ops)
cam->ops->free_syncpts(cam);
- if (cam->ops)
- cam->ops->clks_deinit(cam);
-
dev_notice(&pdev->dev, "Tegra camera host driver unloaded\n");
return 0;
diff --git a/drivers/media/platform/soc_camera/tegra_camera/common.h b/drivers/media/platform/soc_camera/tegra_camera/common.h
index ab1a9af15d9f..084d45f03b98 100644
--- a/drivers/media/platform/soc_camera/tegra_camera/common.h
+++ b/drivers/media/platform/soc_camera/tegra_camera/common.h
@@ -56,7 +56,7 @@ struct tegra_camera_clk {
};
struct tegra_camera_ops {
- int (*clks_init)(struct tegra_camera_dev *cam);
+ int (*clks_init)(struct tegra_camera_dev *cam, int port);
void (*clks_deinit)(struct tegra_camera_dev *cam);
void (*clks_enable)(struct tegra_camera_dev *cam);
void (*clks_disable)(struct tegra_camera_dev *cam);
diff --git a/drivers/media/platform/soc_camera/tegra_camera/vi.c b/drivers/media/platform/soc_camera/tegra_camera/vi.c
index 1f07d6895d9f..1fa0d098a88a 100644
--- a/drivers/media/platform/soc_camera/tegra_camera/vi.c
+++ b/drivers/media/platform/soc_camera/tegra_camera/vi.c
@@ -302,7 +302,7 @@ static struct tegra_camera_clk vi_clks[] = {
#endif
};
-static int vi_clks_init(struct tegra_camera_dev *cam)
+static int vi_clks_init(struct tegra_camera_dev *cam, int port)
{
struct platform_device *pdev = cam->ndev;
struct tegra_camera_clk *clks;
diff --git a/drivers/media/platform/soc_camera/tegra_camera/vi2.c b/drivers/media/platform/soc_camera/tegra_camera/vi2.c
index 00b400799cdf..09a3a6173a9f 100644
--- a/drivers/media/platform/soc_camera/tegra_camera/vi2.c
+++ b/drivers/media/platform/soc_camera/tegra_camera/vi2.c
@@ -344,7 +344,7 @@ static struct tegra_camera_clk vi2_clks1[] = {
.use_devname = 1,
},
{
- .name = "vi_sensor",
+ .name = "vi_sensor2",
.freq = 24000000,
},
{
@@ -366,12 +366,12 @@ static struct tegra_camera_clk vi2_clks1[] = {
},
{
.name = "cilcd",
- .freq = 0,
+ .freq = 102000000,
.use_devname = 1,
},
{
.name = "cile",
- .freq = 0,
+ .freq = 102000000,
.use_devname = 1,
},
/* Always put "p11_d" at the end */
@@ -383,23 +383,24 @@ static struct tegra_camera_clk vi2_clks1[] = {
#define MAX_DEVID_LENGTH 16
-static int vi2_clks_init(struct tegra_camera_dev *cam)
+static int vi2_clks_init(struct tegra_camera_dev *cam, int port)
{
struct platform_device *pdev = cam->ndev;
struct tegra_camera_clk *clks;
int i;
- switch (pdev->id) {
- case 0:
+ switch (port) {
+ case TEGRA_CAMERA_PORT_CSI_A:
cam->num_clks = ARRAY_SIZE(vi2_clks0);
cam->clks = vi2_clks0;
break;
- case 1:
+ case TEGRA_CAMERA_PORT_CSI_B:
+ case TEGRA_CAMERA_PORT_CSI_C:
cam->num_clks = ARRAY_SIZE(vi2_clks1);
cam->clks = vi2_clks1;
break;
default:
- dev_err(&pdev->dev, "Wrong device ID %d\n", pdev->id);
+ dev_err(&pdev->dev, "Wrong port number %d\n", port);
return -ENODEV;
}