2 * Copyright (C) 2011 Google, Inc.
5 * Colin Cross <ccross@android.com>
7 * Copyright (C) 2010,2013, NVIDIA Corporation
9 * This software is licensed under the terms of the GNU General Public
10 * License version 2, as published by the Free Software Foundation, and
11 * may be copied, distributed, and modified under those terms.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
20 #include <linux/cpu_pm.h>
21 #include <linux/interrupt.h>
23 #include <linux/irqchip/arm-gic.h>
24 #include <linux/irq.h>
25 #include <linux/kernel.h>
26 #include <linux/of_address.h>
28 #include <linux/syscore_ops.h>
34 #define SGI_MASK 0xFFFF
36 #ifdef CONFIG_PM_SLEEP
37 static void __iomem
*tegra_gic_cpu_base
;
40 bool tegra_pending_sgi(void)
43 void __iomem
*distbase
= IO_ADDRESS(TEGRA_ARM_INT_DIST_BASE
);
45 pending_set
= readl_relaxed(distbase
+ GIC_DIST_PENDING_SET
);
47 if (pending_set
& SGI_MASK
)
53 #ifdef CONFIG_PM_SLEEP
54 static int tegra_gic_notifier(struct notifier_block
*self
,
55 unsigned long cmd
, void *v
)
59 writel_relaxed(0x1E0, tegra_gic_cpu_base
+ GIC_CPU_CTRL
);
66 static struct notifier_block tegra_gic_notifier_block
= {
67 .notifier_call
= tegra_gic_notifier
,
70 static const struct of_device_id tegra114_dt_gic_match
[] __initconst
= {
71 { .compatible
= "arm,cortex-a15-gic" },
75 static void tegra114_gic_cpu_pm_registration(void)
77 struct device_node
*dn
;
79 dn
= of_find_matching_node(NULL
, tegra114_dt_gic_match
);
83 tegra_gic_cpu_base
= of_iomap(dn
, 1);
85 cpu_pm_register_notifier(&tegra_gic_notifier_block
);
88 static void tegra114_gic_cpu_pm_registration(void) { }
91 static const struct of_device_id tegra_ictlr_match
[] __initconst
= {
92 { .compatible
= "nvidia,tegra20-ictlr" },
93 { .compatible
= "nvidia,tegra30-ictlr" },
97 void __init
tegra_init_irq(void)
99 if (WARN_ON(!of_find_matching_node(NULL
, tegra_ictlr_match
)))
100 pr_warn("Outdated DT detected, suspend/resume will NOT work\n");
102 tegra114_gic_cpu_pm_registration();