diff options
author | Laxman Dewangan <ldewangan@nvidia.com> | 2013-10-30 15:07:02 +0530 |
---|---|---|
committer | Laxman Dewangan <ldewangan@nvidia.com> | 2013-10-30 10:06:45 -0700 |
commit | 86003361a6b28a12f748439bd3ff8bcdba123339 (patch) | |
tree | 57090a336f6552b3c3d6d413100bd8e9ca97a822 | |
parent | 097539e1a189ab66afebcde3a35aa6e26776269e (diff) |
ARM: tegra: wakeup: add function to get wakeup irq
Add API to get irq number of wakeup source which causes
system to wakeup from LP0.
Change-Id: I3a61099bad9880f1a560d7d9477e1ff69044876b
Signed-off-by: Laxman Dewangan <ldewangan@nvidia.com>
Reviewed-on: http://git-master/r/304932
Reviewed-by: Automatic_Commit_Validation_User
-rw-r--r-- | arch/arm/mach-tegra/tegra-wakeups.c | 28 | ||||
-rw-r--r-- | include/linux/system-wakeup.h | 33 |
2 files changed, 61 insertions, 0 deletions
diff --git a/arch/arm/mach-tegra/tegra-wakeups.c b/arch/arm/mach-tegra/tegra-wakeups.c index 5c39dbf49155..0a7c6c43990b 100644 --- a/arch/arm/mach-tegra/tegra-wakeups.c +++ b/arch/arm/mach-tegra/tegra-wakeups.c @@ -18,11 +18,15 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ +#include <linux/export.h> #include <linux/kernel.h> #include <linux/gpio.h> #include <linux/init.h> +#include <linux/interrupt.h> +#include <linux/irq.h> #include <linux/io.h> #include <linux/irqchip/tegra.h> +#include <linux/system-wakeup.h> #include <mach/irqs.h> #include <mach/gpio-tegra.h> @@ -148,3 +152,27 @@ int tegra_disable_wake_source(int wake) { return tegra_set_wake_source(wake, -EINVAL); } + +int get_wakeup_reason_irq(void) +{ + unsigned long long wake_status = tegra_read_pmc_wake_status(); + unsigned long long mask_ll = 1ULL; + int irq; + struct irq_desc *desc; + int i; + + for (i = 0; i < tegra_wake_table_len; ++i) { + if (mask_ll & wake_status) { + irq = tegra_wake_to_irq(i); + if (!irq) + continue; + desc = irq_to_desc(irq); + if (!desc || !desc->action || !desc->action->name) + continue; + return irq; + } + mask_ll <<= 1; + } + return -EINVAL; +} +EXPORT_SYMBOL_GPL(get_wakeup_reason_irq); diff --git a/include/linux/system-wakeup.h b/include/linux/system-wakeup.h new file mode 100644 index 000000000000..a9747fc2a1aa --- /dev/null +++ b/include/linux/system-wakeup.h @@ -0,0 +1,33 @@ +/* + * PMC interface for NVIDIA SoCs Tegra + * + * Copyright (c) 2013, NVIDIA CORPORATION. All rights reserved. + * + * Author: Laxman Dewangan <ldewangan@nvidia.com> + * + * 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 __LINUX_SYSTEM_WAKEUP_H__ +#define __LINUX_SYSTEM_WAKEUP_H__ + +#ifdef CONFIG_PM_SLEEP +extern int get_wakeup_reason_irq(void); +#else +static inline int get_wakeup_reason_irq(void) +{ + return -EINVAL; +} +#endif + +#endif /* __LINUX_SYSTEM_WAKEUP_H__ */ |