From 86003361a6b28a12f748439bd3ff8bcdba123339 Mon Sep 17 00:00:00 2001 From: Laxman Dewangan Date: Wed, 30 Oct 2013 15:07:02 +0530 Subject: 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 Reviewed-on: http://git-master/r/304932 Reviewed-by: Automatic_Commit_Validation_User --- arch/arm/mach-tegra/tegra-wakeups.c | 28 ++++++++++++++++++++++++++++ include/linux/system-wakeup.h | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 61 insertions(+) create mode 100644 include/linux/system-wakeup.h 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 . */ +#include #include #include #include +#include +#include #include #include +#include #include #include @@ -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 + * + * 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 . + */ + +#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__ */ -- cgit v1.2.3