summaryrefslogtreecommitdiff
path: root/arch/arm/mach-tegra/wakeups-t2.c
diff options
context:
space:
mode:
authorColin Cross <ccross@android.com>2011-04-04 13:07:37 -0700
committerDan Willemsen <dwillemsen@nvidia.com>2011-11-30 21:34:15 -0800
commitc8776eedd4b2a8fb03299cde39ff56da67c3da2c (patch)
tree12c07ea3e55e0a2b5b143a128826b48405d5a4f0 /arch/arm/mach-tegra/wakeups-t2.c
parent15a129e3b2d1438932bbf1e51933b6b54eb01aea (diff)
ARM: tegra: suspend: add LP0 wakeup sources
LP0 suspend can only wake up from 31 sources, mostly gpios spread randomly across all the gpio banks, but also a few internal irqs. Change-Id: Ic707d1da6b8d7ddb45dc511ed3739f31066aceaf Signed-off-by: Colin Cross <ccross@android.com>
Diffstat (limited to 'arch/arm/mach-tegra/wakeups-t2.c')
-rw-r--r--arch/arm/mach-tegra/wakeups-t2.c98
1 files changed, 98 insertions, 0 deletions
diff --git a/arch/arm/mach-tegra/wakeups-t2.c b/arch/arm/mach-tegra/wakeups-t2.c
new file mode 100644
index 000000000000..667fea714fe7
--- /dev/null
+++ b/arch/arm/mach-tegra/wakeups-t2.c
@@ -0,0 +1,98 @@
+/*
+ * Copyright (c) 2011, Google, Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that 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.
+ */
+
+#include <linux/kernel.h>
+#include <linux/gpio.h>
+#include <linux/init.h>
+#include <linux/io.h>
+
+#include <mach/iomap.h>
+#include <mach/irqs.h>
+
+#include "gpio-names.h"
+
+#define NUM_WAKE_EVENTS 31
+
+static int tegra_wake_event_irq[] = {
+ [0] = TEGRA_GPIO_TO_IRQ(TEGRA_GPIO_PO5),
+ [1] = TEGRA_GP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+ [29] = TEGRA_GPIO_TO_IRQ(TEGRA_GPIO_PQ7),
+ [30] = TEGRA_GPIO_TO_IRQ(TEGRA_GPIO_PN2),
+ [31] = -EINVAL,
+ /*
+ * The gpio bank irqs aren't actually wake sources, but they don't
+ * prevent lp0 because the gpio chained irq is requested directly
+ */
+ [32] = INT_GPIO1,
+ [33] = INT_GPIO2,
+ [34] = INT_GPIO3,
+ [35] = INT_GPIO4,
+ [36] = INT_GPIO5,
+ [37] = INT_GPIO6,
+ [38] = INT_GPIO7,
+};
+
+int tegra_irq_to_wake(int irq)
+{
+ int i;
+ for (i = 0; i < ARRAY_SIZE(tegra_wake_event_irq); i++)
+ if (tegra_wake_event_irq[i] == irq)
+ break;
+
+ if (i == ARRAY_SIZE(tegra_wake_event_irq))
+ return -ENOTSUPP;
+
+ if (i > NUM_WAKE_EVENTS)
+ return -EALREADY;
+
+ return i;
+}
+
+int tegra_wake_to_irq(int wake)
+{
+ if (wake < 0)
+ return -EINVAL;
+
+ if (wake >= NUM_WAKE_EVENTS)
+ return -EINVAL;
+
+ return tegra_wake_event_irq[wake];
+}