]> rtime.felk.cvut.cz Git - sojka/nv-tegra/linux-3.10.git/commitdiff
drivers: misc: add DT support for tegra-c2port
authorAnkita Garg <ankitag@nvidia.com>
Fri, 18 Jul 2014 17:39:15 +0000 (10:39 -0700)
committerRaymond Poudrier <rapoudrier@nvidia.com>
Sat, 21 Feb 2015 01:31:33 +0000 (17:31 -0800)
Modify c2port-loki driver to boot/read configuration
from DT files instead of board files.

Bug 1582082

Change-Id: I6633cb8b372f3ba0358781a6a81452390cd122b7
Signed-off-by: martin gao <marting@nvidia.com>
Signed-off-by: Ankita Garg <ankitag@nvidia.com>
(cherry picked from commit 8f46e610ee3d689606dfa6962a287e054c2cd5e6)
Reviewed-on: http://git-master/r/668692
(cherry picked from commit 805aa9f2d0fab1a6a41fd47c72dcdd91039d6a2c)
Reviewed-on: http://git-master/r/654234
(cherry picked from commit 3938c318f121c4dcac90422327f61e3005fb1c53)
Reviewed-on: http://git-master/r/439893
GVS: Gerrit_Virtual_Submit
Reviewed-by: Raymond Poudrier <rapoudrier@nvidia.com>
drivers/misc/c2port/Kconfig
drivers/misc/c2port/c2port-loki.c

index 5768d6618a6a3c343de3d6d6b16432c1924dddd9..89fecc1e515e861dba7084c86528d66dab255519 100644 (file)
@@ -23,7 +23,7 @@ if C2PORT
 config C2PORT_LOKI
        tristate "C2 port support for NVIDIA Loki"
        default n
-       depends on MACH_LOKI
+       depends on C2PORT
        help
          This option enables C2 support for Joystick micro controller of
          NVIDIA Loki platform.
index ec154718c14765ae6186a185e0fa62357ee5a475..86b017ee0950426fc652a3e3ce638f2aedf02cdf 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013, NVIDIA CORPORATION.  All rights reserved.
+ * Copyright (c) 2013-2015, 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,
@@ -31,7 +31,8 @@
 #include <linux/interrupt.h>
 #include <linux/slab.h>
 #include <linux/platform_data/tegra_c2port_platform_data.h>
-#include <asm/system.h>
+#include <linux/of.h>
+#include <linux/of_gpio.h>
 
 struct tegra_c2port_device {
        struct c2port_device *p_c2dev;
@@ -189,18 +190,21 @@ static struct c2port_ops tegra_c2port_ops = {
 /* mcu_debugger driver functions */
 static int tegra_c2port_probe(struct platform_device *pdev)
 {
-       struct tegra_c2port_platform_data *pdata =
-           (struct tegra_c2port_platform_data *)pdev->dev.platform_data;
-
-       if (!pdata) {
-               dev_err(&pdev->dev, "no platform_data\n");
-               return -ENOENT;
+       struct tegra_c2port_platform_data *pdata = NULL;
+       u32 value = 0;
+       int error = 0;
+#ifdef CONFIG_OF
+       struct device_node *node = NULL;
+#endif
+       if (!pdev) {
+               pr_err("c2port: pdev NULL.\n");
+               return -EINVAL;
        }
 
        if (g_c2port_device) {
                dev_err(&pdev->dev,
                        "tegra_c2port probe more than one device!\n");
-               return -1;
+               return -EINVAL;
        }
 
        g_c2port_device = devm_kzalloc(&pdev->dev,
@@ -211,9 +215,46 @@ static int tegra_c2port_probe(struct platform_device *pdev)
                        "tegra_c2port_device allocated error!\n");
                return -ENOMEM;
        }
+
+#ifdef CONFIG_OF
+       node = pdev->dev.of_node;
+
+       if (node) {
+               g_c2port_device->GPIO_C2CK =
+                       (int)of_get_named_gpio(node, "gpio_c2ck", 0);
+
+               if (g_c2port_device->GPIO_C2CK < 0) {
+                       dev_err(&pdev->dev, "gpio_c2ck not available.\n");
+                       error = -ENXIO;
+                       goto free_mem;
+               }
+
+               g_c2port_device->GPIO_C2D =
+                       (int)of_get_named_gpio(node, "gpio_c2d", 0);
+               if (g_c2port_device->GPIO_C2D < 0) {
+                       dev_err(&pdev->dev, "gpio_c2d not available.\n");
+                       error = -ENXIO;
+                       goto free_mem;
+               }
+               goto reg_dev;
+       }
+#endif
+       pdata = (struct tegra_c2port_platform_data *)pdev->dev.platform_data;
+
+       if (!pdata) {
+               dev_err(&pdev->dev, "No platform_data \n");
+               error = -ENOENT;
+               goto free_mem;
+       }
+
        g_c2port_device->GPIO_C2CK = pdata->gpio_c2ck;
        g_c2port_device->GPIO_C2D = pdata->gpio_c2d;
 
+reg_dev:
+       dev_info(&pdev->dev, "gpio_c2ck: %d, gpio_c2d: %d\n",
+               g_c2port_device->GPIO_C2CK,
+               g_c2port_device->GPIO_C2D);
+
        /* register the device with c2 port core */
        g_c2port_device->p_c2dev = c2port_device_register("tegra_mcu_c2port",
                                                          &tegra_c2port_ops,
@@ -222,11 +263,16 @@ static int tegra_c2port_probe(struct platform_device *pdev)
        if (!g_c2port_device->p_c2dev) {
                dev_err(&pdev->dev,
                        "tegra_port c2 device register failed!\n");
-               devm_kfree(&pdev->dev, g_c2port_device);
-               g_c2port_device = NULL;
-               return -EBUSY;
+               error = -EBUSY;
+               goto free_mem;
        }
-       return 0;
+       dev_info(&pdev->dev, "tegra_c2port probe success.\n");
+       return error;
+
+free_mem:
+       devm_kfree(&pdev->dev, g_c2port_device);
+       g_c2port_device = NULL;
+       return error;
 }
 
 static int tegra_c2port_remove(struct platform_device *pdev)