]> rtime.felk.cvut.cz Git - sojka/nv-tegra/linux-3.10.git/commitdiff
watchdog: tegra: Add device tree support.
authorArve Hjønnevåg <arve@android.com>
Tue, 6 May 2014 04:41:55 +0000 (21:41 -0700)
committerDhiren Parmar <dparmar@nvidia.com>
Sun, 17 Aug 2014 08:45:11 +0000 (01:45 -0700)
Add compatible string.
Compute timer reg from timer regs base addr instead of device id.

Reviewed-on: http://git-master/r/433781
(cherry picked from commit ae30129714b1f9327e5f4b085413800bfbcbb194)

Change-Id: Ida3e00eff28244a1857fe43c479d7baed667c524
Signed-off-by: Arve Hjønnevåg <arve@android.com>
Signed-off-by: Arun Kannan <akannan@nvidia.com>
Reviewed-on: http://git-master/r/454847
Reviewed-by: Mitch Luban <mluban@nvidia.com>
Tested-by: Mitch Luban <mluban@nvidia.com>
GVS: Gerrit_Virtual_Submit

drivers/watchdog/tegra_wdt.c

index 5aeb538d2e780807f2c2e63a9e2daff93d99cebc..69782438e4f93e30b5f60aab2db9a276d0cf8032 100644 (file)
@@ -28,6 +28,7 @@
 #include <linux/interrupt.h>
 #include <linux/io.h>
 #include <linux/kernel.h>
+#include <linux/of.h>
 #include <linux/platform_device.h>
 #include <linux/slab.h>
 #include <linux/spinlock.h>
@@ -37,8 +38,6 @@
 /* minimum and maximum watchdog trigger periods, in seconds */
 #define MIN_WDT_PERIOD 5
 #define MAX_WDT_PERIOD 1000
-/* Assign Timer 7 to Timer 10 for WDT0 to WDT3, respectively */
-#define TMR_SRC_START  7
 
 enum tegra_wdt_status {
        WDT_DISABLED = 1 << 0,
@@ -253,7 +252,10 @@ static int tegra_wdt_probe(struct platform_device *pdev)
        tegra_wdt->wdt_source = ioremap(res_src->start, resource_size(res_src));
        tegra_wdt->wdt_timer = ioremap(res_wdt->start, resource_size(res_wdt));
        /* tmrsrc will be used to set WDT_CFG */
-       tegra_wdt->tmrsrc = (TMR_SRC_START + pdev->id) % 10;
+       if ((res_wdt->start & 0xff) < 0x50)
+               tegra_wdt->tmrsrc = 1 + (res_wdt->start & 0xf) / 8;
+       else
+               tegra_wdt->tmrsrc = (3 + ((res_wdt->start & 0xff) - 0x50) / 8) % 10;
        if (!tegra_wdt->wdt_source || !tegra_wdt->wdt_timer) {
                dev_err(&pdev->dev, "unable to map registers\n");
                ret = -ENOMEM;
@@ -336,6 +338,11 @@ static int tegra_wdt_resume(struct platform_device *pdev)
 }
 #endif
 
+static const struct of_device_id tegra_wdt_match[] = {
+       { .compatible = "nvidia,tegra-wdt", },
+       {}
+};
+
 static struct platform_driver tegra_wdt_driver = {
        .probe          = tegra_wdt_probe,
        .remove         = tegra_wdt_remove,
@@ -346,6 +353,7 @@ static struct platform_driver tegra_wdt_driver = {
        .driver         = {
                .owner  = THIS_MODULE,
                .name   = "tegra_wdt",
+               .of_match_table = of_match_ptr(tegra_wdt_match),
        },
 };