]> rtime.felk.cvut.cz Git - sojka/nv-tegra/linux-3.10.git/commitdiff
video: host: vi: split out built-in code
authorBryan Wu <pengw@nvidia.com>
Wed, 23 Oct 2013 18:31:15 +0000 (11:31 -0700)
committerTerje Bergstrom <tbergstrom@nvidia.com>
Tue, 29 Oct 2013 07:55:07 +0000 (00:55 -0700)
VI driver could be a module. Those T124 sepcific functions are
used by other drivers, which make VI driver can't be built as a
module. So split them out to a separated file and always build
it into kernel, then the rest of vi.c driver can be a module.

Bug 1377330

Change-Id: I4a35ddd62f1c3caca09e596603f5f99b16159754
Signed-off-by: Bryan Wu <pengw@nvidia.com>
Reviewed-on: http://git-master/r/289327
Reviewed-by: Automatic_Commit_Validation_User
GVS: Gerrit_Virtual_Submit
Reviewed-by: Terje Bergstrom <tbergstrom@nvidia.com>
drivers/video/tegra/host/vi/Makefile
drivers/video/tegra/host/vi/tegra_vi.c [new file with mode: 0644]
drivers/video/tegra/host/vi/vi.c

index b13e240b5d4a6b4bc109d2b20a520d46927379e2..7aa70ea1cf94ed2c051351a1e64c297f8eb31914 100644 (file)
@@ -5,4 +5,5 @@ ccflags-y += -Idrivers/video/tegra/camera
 nvhost-vi-objs  = \
                vi.o
 
+obj-y += tegra_vi.o
 obj-$(CONFIG_TEGRA_GRHOST_VI) += nvhost-vi.o
diff --git a/drivers/video/tegra/host/vi/tegra_vi.c b/drivers/video/tegra/host/vi/tegra_vi.c
new file mode 100644 (file)
index 0000000..2d7ed2d
--- /dev/null
@@ -0,0 +1,191 @@
+/*
+ * drivers/video/tegra/host/vi/tegra_vi.c
+ *
+ * Copyright (c) 2013, NVIDIA CORPORATION. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms and conditions of the GNU General Public License,
+ * version 2, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <linux/delay.h>
+#include <linux/module.h>
+#include <linux/nvhost.h>
+#include <linux/nvhost_vi_ioctl.h>
+#include <linux/platform_device.h>
+
+#include "bus_client.h"
+#include "chip_support.h"
+#include "host1x/host1x.h"
+#include "vi.h"
+
+#define T12_VI_CFG_CG_CTRL     0x2e
+#define T12_CG_2ND_LEVEL_EN    1
+#define T12_VI_CSI_0_SW_RESET  0x40
+#define T12_VI_CSI_1_SW_RESET  0x80
+#define T12_VI_CSI_SW_RESET_MCCIF_RESET 3
+
+#ifdef TEGRA_12X_OR_HIGHER_CONFIG
+int nvhost_vi_init(struct platform_device *dev)
+{
+       int ret = 0;
+       struct vi *tegra_vi;
+       tegra_vi = (struct vi *)nvhost_get_private_data(dev);
+
+       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;
+}
+
+void nvhost_vi_deinit(struct platform_device *dev)
+{
+       struct vi *tegra_vi;
+       tegra_vi = (struct vi *)nvhost_get_private_data(dev);
+
+       if (tegra_vi->reg)
+               regulator_put(tegra_vi->reg);
+}
+
+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->reg) {
+               ret = regulator_enable(tegra_vi->reg);
+               if (ret)
+                       dev_err(&dev->dev,
+                               "%s: enable csi regulator failed.\n",
+                               __func__);
+       }
+
+       if (nvhost_client_can_writel(dev))
+               nvhost_client_writel(dev,
+                               T12_CG_2ND_LEVEL_EN, T12_VI_CFG_CG_CTRL);
+       return ret;
+}
+
+int nvhost_vi_prepare_poweroff(struct platform_device *dev)
+{
+       int ret = 0;
+       struct vi *tegra_vi;
+       tegra_vi = (struct vi *)nvhost_get_private_data(dev);
+
+       if (tegra_vi->reg) {
+               ret = regulator_disable(tegra_vi->reg);
+               if (ret)
+                       dev_err(&dev->dev,
+                               "%s: disable csi regulator failed.\n",
+                               __func__);
+       }
+       return ret;
+}
+
+long tegra_vi_ioctl(struct file *file,
+               unsigned int cmd, unsigned long arg)
+{
+       struct vi *tegra_vi;
+
+       if (_IOC_TYPE(cmd) != NVHOST_VI_IOCTL_MAGIC)
+               return -EFAULT;
+
+       tegra_vi = file->private_data;
+       switch (cmd) {
+       case NVHOST_VI_IOCTL_ENABLE_TPG: {
+               uint enable;
+               int ret;
+               struct clk *clk;
+
+               if (copy_from_user(&enable,
+                       (const void __user *)arg, sizeof(uint))) {
+                       dev_err(&tegra_vi->ndev->dev,
+                               "%s: Failed to copy arg from user\n", __func__);
+                       return -EFAULT;
+               }
+
+               clk = clk_get(&tegra_vi->ndev->dev, "pll_d");
+               if (enable)
+                       ret = tegra_clk_cfg_ex(clk,
+                               TEGRA_CLK_PLLD_CSI_OUT_ENB, 1);
+               else
+                       ret = tegra_clk_cfg_ex(clk,
+                               TEGRA_CLK_MIPI_CSI_OUT_ENB, 1);
+               clk_put(clk);
+
+               return ret;
+       }
+       default:
+               dev_err(&tegra_vi->ndev->dev,
+                       "%s: Unknown vi ioctl.\n", __func__);
+               return -EINVAL;
+       }
+       return 0;
+}
+
+static int tegra_vi_open(struct inode *inode, struct file *file)
+{
+       struct nvhost_device_data *pdata;
+       struct vi *vi;
+
+       pdata = container_of(inode->i_cdev,
+               struct nvhost_device_data, ctrl_cdev);
+       BUG_ON(pdata == NULL);
+
+       vi = (struct vi *)pdata->private_data;
+       BUG_ON(vi == NULL);
+
+       file->private_data = vi;
+       return 0;
+}
+
+static int tegra_vi_release(struct inode *inode, struct file *file)
+{
+       return 0;
+}
+
+const struct file_operations tegra_vi_ctrl_ops = {
+       .owner = THIS_MODULE,
+       .open = tegra_vi_open,
+       .unlocked_ioctl = tegra_vi_ioctl,
+       .release = tegra_vi_release,
+};
+#endif
+
+void nvhost_vi_reset(struct platform_device *pdev)
+{
+       u32 reset_reg;
+
+       if (pdev->id == 0)
+               reset_reg = T12_VI_CSI_0_SW_RESET;
+       else
+               reset_reg = T12_VI_CSI_1_SW_RESET;
+
+       nvhost_client_writel(pdev, T12_VI_CSI_SW_RESET_MCCIF_RESET,
+                       reset_reg);
+
+       udelay(10);
+
+       nvhost_client_writel(pdev, 0, reset_reg);
+}
+
index 38bad0fb33c2761bcaf144aa9664420c90bcb0f0..4a405f244e79e75b59c6666ba4d9e16307e26ee0 100644 (file)
@@ -25,7 +25,6 @@
 #include <linux/of.h>
 #include <linux/of_device.h>
 #include <linux/of_platform.h>
-#include <linux/nvhost_vi_ioctl.h>
 #include <linux/clk/tegra.h>
 
 #include <mach/pm_domains.h>
 #include "vi.h"
 
 #define MAX_DEVID_LENGTH       16
-#define T12_VI_CFG_CG_CTRL     0x2e
-#define T12_CG_2ND_LEVEL_EN    1
-#define T12_VI_CSI_0_SW_RESET  0x40
-#define T12_VI_CSI_1_SW_RESET  0x80
-#define T12_VI_CSI_SW_RESET_MCCIF_RESET 3
 
 static struct of_device_id tegra_vi_of_match[] = {
 #ifdef TEGRA_11X_OR_HIGHER_CONFIG
@@ -260,162 +254,6 @@ static void __exit vi_exit(void)
        platform_driver_unregister(&vi_driver);
 }
 
-#ifdef TEGRA_12X_OR_HIGHER_CONFIG
-int nvhost_vi_init(struct platform_device *dev)
-{
-       int ret = 0;
-       struct vi *tegra_vi;
-       tegra_vi = (struct vi *)nvhost_get_private_data(dev);
-
-       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;
-}
-
-void nvhost_vi_deinit(struct platform_device *dev)
-{
-       struct vi *tegra_vi;
-       tegra_vi = (struct vi *)nvhost_get_private_data(dev);
-
-       if (tegra_vi->reg)
-               regulator_put(tegra_vi->reg);
-}
-
-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->reg) {
-               ret = regulator_enable(tegra_vi->reg);
-               if (ret)
-                       dev_err(&dev->dev,
-                               "%s: enable csi regulator failed.\n",
-                               __func__);
-       }
-
-       if (nvhost_client_can_writel(dev))
-               nvhost_client_writel(dev,
-                               T12_CG_2ND_LEVEL_EN, T12_VI_CFG_CG_CTRL);
-       return ret;
-}
-
-int nvhost_vi_prepare_poweroff(struct platform_device *dev)
-{
-       int ret = 0;
-       struct vi *tegra_vi;
-       tegra_vi = (struct vi *)nvhost_get_private_data(dev);
-
-       if (tegra_vi->reg) {
-               ret = regulator_disable(tegra_vi->reg);
-               if (ret)
-                       dev_err(&dev->dev,
-                               "%s: disable csi regulator failed.\n",
-                               __func__);
-       }
-       return ret;
-}
-
-long tegra_vi_ioctl(struct file *file,
-               unsigned int cmd, unsigned long arg)
-{
-       struct vi *tegra_vi;
-
-       if (_IOC_TYPE(cmd) != NVHOST_VI_IOCTL_MAGIC)
-               return -EFAULT;
-
-       tegra_vi = file->private_data;
-       switch (cmd) {
-       case NVHOST_VI_IOCTL_ENABLE_TPG: {
-               uint enable;
-               int ret;
-               struct clk *clk;
-
-               if (copy_from_user(&enable,
-                       (const void __user *)arg, sizeof(uint))) {
-                       dev_err(&tegra_vi->ndev->dev,
-                               "%s: Failed to copy arg from user\n", __func__);
-                       return -EFAULT;
-               }
-
-               clk = clk_get(&tegra_vi->ndev->dev, "pll_d");
-               if (enable)
-                       ret = tegra_clk_cfg_ex(clk,
-                               TEGRA_CLK_PLLD_CSI_OUT_ENB, 1);
-               else
-                       ret = tegra_clk_cfg_ex(clk,
-                               TEGRA_CLK_MIPI_CSI_OUT_ENB, 1);
-               clk_put(clk);
-
-               return ret;
-       }
-       default:
-               dev_err(&tegra_vi->ndev->dev,
-                       "%s: Unknown vi ioctl.\n", __func__);
-               return -EINVAL;
-       }
-       return 0;
-}
-
-static int tegra_vi_open(struct inode *inode, struct file *file)
-{
-       struct nvhost_device_data *pdata;
-       struct vi *vi;
-
-       pdata = container_of(inode->i_cdev,
-               struct nvhost_device_data, ctrl_cdev);
-       BUG_ON(pdata == NULL);
-
-       vi = (struct vi *)pdata->private_data;
-       BUG_ON(vi == NULL);
-
-       file->private_data = vi;
-       return 0;
-}
-
-static int tegra_vi_release(struct inode *inode, struct file *file)
-{
-       return 0;
-}
-
-const struct file_operations tegra_vi_ctrl_ops = {
-       .owner = THIS_MODULE,
-       .open = tegra_vi_open,
-       .unlocked_ioctl = tegra_vi_ioctl,
-       .release = tegra_vi_release,
-};
-#endif
-
-void nvhost_vi_reset(struct platform_device *pdev)
-{
-       u32 reset_reg;
-
-       if (pdev->id == 0)
-               reset_reg = T12_VI_CSI_0_SW_RESET;
-       else
-               reset_reg = T12_VI_CSI_1_SW_RESET;
-
-       nvhost_client_writel(pdev, T12_VI_CSI_SW_RESET_MCCIF_RESET,
-                       reset_reg);
-
-       udelay(10);
-
-       nvhost_client_writel(pdev, 0, reset_reg);
-}
-
 late_initcall(vi_init);
 module_exit(vi_exit);
 MODULE_LICENSE("GPL v2");