summaryrefslogtreecommitdiff
path: root/arch
diff options
context:
space:
mode:
authorBitan Biswas <bbiswas@nvidia.com>2012-06-01 16:13:26 +0530
committerSimone Willett <swillett@nvidia.com>2012-06-03 08:07:04 -0700
commit13a24d7aa0f4de6e0c4f578296b803748590b98c (patch)
tree33ebfc364dafc299d4d96aba5d07dd41a40c5e6b /arch
parentbd44232c77e49bba4f23f5c7dde68a82414c722b (diff)
ARM: tegra: wake up cleanup
Duplicate functions for wakeup support removed. bug 980993 Change-Id: I1e385a1adec6f2d64ce2c88a59e94d647a16569d Signed-off-by: Bitan Biswas <bbiswas@nvidia.com> Reviewed-on: http://git-master/r/105901 Reviewed-by: Automatic_Commit_Validation_User GVS: Gerrit_Virtual_Submit Reviewed-by: Laxman Dewangan <ldewangan@nvidia.com>
Diffstat (limited to 'arch')
-rw-r--r--arch/arm/mach-tegra/Makefile1
-rw-r--r--arch/arm/mach-tegra/pm-irq.c1
-rw-r--r--arch/arm/mach-tegra/pm-irq.h2
-rw-r--r--arch/arm/mach-tegra/wakeups-t2.c57
-rw-r--r--arch/arm/mach-tegra/wakeups-t3.c57
-rw-r--r--arch/arm/mach-tegra/wakeups.c85
-rw-r--r--arch/arm/mach-tegra/wakeups.h29
7 files changed, 124 insertions, 108 deletions
diff --git a/arch/arm/mach-tegra/Makefile b/arch/arm/mach-tegra/Makefile
index 3b046a93edf5..ffa77c2c5c05 100644
--- a/arch/arm/mach-tegra/Makefile
+++ b/arch/arm/mach-tegra/Makefile
@@ -61,6 +61,7 @@ obj-$(CONFIG_ARCH_TEGRA_2x_SOC) += tegra2_emc.o
obj-$(CONFIG_ARCH_TEGRA_3x_SOC) += tegra3_emc.o
obj-$(CONFIG_ARCH_TEGRA_2x_SOC) += wakeups-t2.o
obj-$(CONFIG_ARCH_TEGRA_3x_SOC) += wakeups-t3.o
+obj-y += wakeups.o
obj-$(CONFIG_ARCH_TEGRA_2x_SOC) += pm-t2.o
obj-$(CONFIG_ARCH_TEGRA_3x_SOC) += pm-t3.o
diff --git a/arch/arm/mach-tegra/pm-irq.c b/arch/arm/mach-tegra/pm-irq.c
index 57d21361ca14..9b205f86f8b9 100644
--- a/arch/arm/mach-tegra/pm-irq.c
+++ b/arch/arm/mach-tegra/pm-irq.c
@@ -29,6 +29,7 @@
#include <mach/iomap.h>
#include "pm-irq.h"
+#include "wakeups.h"
#define PMC_CTRL 0x0
#define PMC_CTRL_LATCH_WAKEUPS (1 << 5)
diff --git a/arch/arm/mach-tegra/pm-irq.h b/arch/arm/mach-tegra/pm-irq.h
index 8e87b4bba246..639bfe9c4cc9 100644
--- a/arch/arm/mach-tegra/pm-irq.h
+++ b/arch/arm/mach-tegra/pm-irq.h
@@ -22,8 +22,6 @@
int tegra_pm_irq_set_wake(int irq, int enable);
int tegra_pm_irq_set_wake_type(int irq, int flow_type);
bool tegra_pm_irq_lp0_allowed(void);
-int tegra_irq_to_wake(int irq);
-int tegra_wake_to_irq(int wake);
#else
static inline int tegra_pm_irq_set_wake_type(int irq, int flow_type)
{
diff --git a/arch/arm/mach-tegra/wakeups-t2.c b/arch/arm/mach-tegra/wakeups-t2.c
index 7c5d12ac60d4..8079e6820145 100644
--- a/arch/arm/mach-tegra/wakeups-t2.c
+++ b/arch/arm/mach-tegra/wakeups-t2.c
@@ -22,8 +22,9 @@
#include <mach/gpio.h>
#include "gpio-names.h"
+#include "wakeups.h"
-static int tegra_wake_event_irq[] = {
+static int tegra_wake_event_irq_t2[] = {
[0] = TEGRA_GPIO_TO_IRQ(TEGRA_GPIO_PO5),
[1] = TEGRA_GPIO_TO_IRQ(TEGRA_GPIO_PV3),
[2] = TEGRA_GPIO_TO_IRQ(TEGRA_GPIO_PL1),
@@ -57,55 +58,5 @@ static int tegra_wake_event_irq[] = {
[30] = TEGRA_GPIO_TO_IRQ(TEGRA_GPIO_PN2),
};
-int tegra_irq_to_wake(int irq)
-{
- int i;
- int wake_irq;
- int search_gpio;
- static int last_wake = -1;
-
- /* Two level wake irq search for gpio based wakeups -
- * 1. check for GPIO irq(based on tegra_wake_event_irq table)
- * e.g. for a board, wake7 based on GPIO PU6 and irq==358 done first
- * 2. check for gpio bank irq assuming search for GPIO irq
- * preceded this search.
- * e.g. in this step check for gpio bank irq GPIO6 irq==119
- */
- for (i = 0; i < ARRAY_SIZE(tegra_wake_event_irq); i++) {
- /* return if step 1 matches */
- if (tegra_wake_event_irq[i] == irq) {
- pr_info("Wake%d for irq=%d\n", i, irq);
- last_wake = i;
- return i;
- }
-
- /* step 2 below uses saved last_wake from step 1
- * in previous call */
- search_gpio = irq_to_gpio(
- tegra_wake_event_irq[i]);
- if (search_gpio < 0)
- continue;
- wake_irq = tegra_gpio_get_bank_int_nr(search_gpio);
- if (wake_irq < 0)
- continue;
- if ((last_wake == i) &&
- (wake_irq == irq)) {
- pr_info("gpio bank wake found: wake%d for irq=%d\n",
- i, irq);
- return i;
- }
- }
-
- return -EINVAL;
-}
-
-int tegra_wake_to_irq(int wake)
-{
- if (wake < 0)
- return -EINVAL;
-
- if (wake >= ARRAY_SIZE(tegra_wake_event_irq))
- return -EINVAL;
-
- return tegra_wake_event_irq[wake];
-}
+int *tegra_wake_event_irq = tegra_wake_event_irq_t2;
+unsigned int tegra_wake_event_irq_size = ARRAY_SIZE(tegra_wake_event_irq_t2);
diff --git a/arch/arm/mach-tegra/wakeups-t3.c b/arch/arm/mach-tegra/wakeups-t3.c
index 823736204362..33dfb12f7211 100644
--- a/arch/arm/mach-tegra/wakeups-t3.c
+++ b/arch/arm/mach-tegra/wakeups-t3.c
@@ -22,8 +22,9 @@
#include <mach/gpio.h>
#include "gpio-names.h"
+#include "wakeups.h"
-static int tegra_wake_event_irq[] = {
+static int tegra_wake_event_irq_t3[] = {
TEGRA_GPIO_TO_IRQ(TEGRA_GPIO_PO5), /* wake0 */
TEGRA_GPIO_TO_IRQ(TEGRA_GPIO_PV1), /* wake1 */
TEGRA_GPIO_TO_IRQ(TEGRA_GPIO_PL1), /* wake2 */
@@ -68,55 +69,5 @@ static int tegra_wake_event_irq[] = {
INT_USB3, /* TEGRA_USB3_UTMIP, */ /* wake41 */
};
-int tegra_irq_to_wake(int irq)
-{
- int i;
- int wake_irq;
- int search_gpio;
- static int last_wake = -1;
-
- /* Two level wake irq search for gpio based wakeups -
- * 1. check for GPIO irq(based on tegra_wake_event_irq table)
- * e.g. for a board, wake7 based on GPIO PU6 and irq==390 done first
- * 2. check for gpio bank irq assuming search for GPIO irq
- * preceded this search.
- * e.g. in this step check for gpio bank irq GPIO6 irq==119
- */
- for (i = 0; i < ARRAY_SIZE(tegra_wake_event_irq); i++) {
- /* return if step 1 matches */
- if (tegra_wake_event_irq[i] == irq) {
- pr_info("Wake%d for irq=%d\n", i, irq);
- last_wake = i;
- return i;
- }
-
- /* step 2 below uses saved last_wake from step 1
- * in previous call */
- search_gpio = irq_to_gpio(
- tegra_wake_event_irq[i]);
- if (search_gpio < 0)
- continue;
- wake_irq = tegra_gpio_get_bank_int_nr(search_gpio);
- if (wake_irq < 0)
- continue;
- if ((last_wake == i) &&
- (wake_irq == irq)) {
- pr_info("gpio bank wake found: wake%d for irq=%d\n",
- i, irq);
- return i;
- }
- }
-
- return -EINVAL;
-}
-
-int tegra_wake_to_irq(int wake)
-{
- if (wake < 0)
- return -EINVAL;
-
- if (wake >= ARRAY_SIZE(tegra_wake_event_irq))
- return -EINVAL;
-
- return tegra_wake_event_irq[wake];
-}
+int *tegra_wake_event_irq = tegra_wake_event_irq_t3;
+unsigned int tegra_wake_event_irq_size = ARRAY_SIZE(tegra_wake_event_irq_t3);
diff --git a/arch/arm/mach-tegra/wakeups.c b/arch/arm/mach-tegra/wakeups.c
new file mode 100644
index 000000000000..d53563cf22ba
--- /dev/null
+++ b/arch/arm/mach-tegra/wakeups.c
@@ -0,0 +1,85 @@
+/*
+ * Copyright (c) 2012, 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/kernel.h>
+#include <linux/gpio.h>
+#include <linux/init.h>
+#include <linux/io.h>
+#include <linux/interrupt.h>
+
+#include <mach/iomap.h>
+#include <mach/irqs.h>
+#include <mach/gpio.h>
+
+#include "gpio-names.h"
+#include "wakeups.h"
+
+extern int *tegra_wake_event_irq;
+extern unsigned int tegra_wake_event_irq_size;
+
+int tegra_irq_to_wake(int irq)
+{
+ int i;
+ int wake_irq;
+ int search_gpio;
+ static int last_wake = -1;
+
+ /* Two level wake irq search for gpio based wakeups -
+ * 1. check for GPIO irq(based on tegra_wake_event_irq table)
+ * e.g. for a board, wake7 based on GPIO PU6 and irq==390 done first
+ * 2. check for gpio bank irq assuming search for GPIO irq
+ * preceded this search.
+ * e.g. in this step check for gpio bank irq GPIO6 irq==119
+ */
+ for (i = 0; i < tegra_wake_event_irq_size; i++) {
+ /* return if step 1 matches */
+ if (tegra_wake_event_irq[i] == irq) {
+ pr_info("Wake%d for irq=%d\n", i, irq);
+ last_wake = i;
+ return i;
+ }
+
+ /* step 2 below uses saved last_wake from step 1
+ * in previous call */
+ search_gpio = irq_to_gpio(
+ tegra_wake_event_irq[i]);
+ if (search_gpio < 0)
+ continue;
+ wake_irq = tegra_gpio_get_bank_int_nr(search_gpio);
+ if (wake_irq < 0)
+ continue;
+ if ((last_wake == i) &&
+ (wake_irq == irq)) {
+ pr_info("gpio bank wake found: wake%d for irq=%d\n",
+ i, irq);
+ return i;
+ }
+ }
+
+ return -EINVAL;
+}
+
+int tegra_wake_to_irq(int wake)
+{
+ if (wake < 0)
+ return -EINVAL;
+
+ if (wake >= tegra_wake_event_irq_size)
+ return -EINVAL;
+
+ return tegra_wake_event_irq[wake];
+}
+
diff --git a/arch/arm/mach-tegra/wakeups.h b/arch/arm/mach-tegra/wakeups.h
new file mode 100644
index 000000000000..ab113649d534
--- /dev/null
+++ b/arch/arm/mach-tegra/wakeups.h
@@ -0,0 +1,29 @@
+/*
+ * Copyright (c) 2012, 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/>.
+ */
+
+#ifndef __WAKEUPS_H_
+#define __WAKEUPS_H_
+
+/*
+ * given irq number returns wake source index or negative value for error
+ */
+int tegra_irq_to_wake(int irq);
+/*
+ * given wake source index, returns irq number or negative value for error
+ */
+int tegra_wake_to_irq(int wake);
+
+#endif /* end __WAKEUPS_H_ */