Merge tag 'locking-urgent-2020-12-27' of git://git.kernel.org/pub/scm/linux/kernel...
[linux/fpc-iii.git] / arch / arm / mach-tegra / irq.c
blob4e1ee70b2a3f187802bc5b9354e277773b8dc0f1
1 // SPDX-License-Identifier: GPL-2.0-only
2 /*
3 * Copyright (C) 2011 Google, Inc.
5 * Author:
6 * Colin Cross <ccross@android.com>
8 * Copyright (C) 2010,2013, NVIDIA Corporation
9 */
11 #include <linux/cpu_pm.h>
12 #include <linux/interrupt.h>
13 #include <linux/io.h>
14 #include <linux/irqchip/arm-gic.h>
15 #include <linux/irq.h>
16 #include <linux/kernel.h>
17 #include <linux/of_address.h>
18 #include <linux/of.h>
19 #include <linux/syscore_ops.h>
21 #include <soc/tegra/irq.h>
23 #include "board.h"
24 #include "iomap.h"
26 #define SGI_MASK 0xFFFF
28 #ifdef CONFIG_PM_SLEEP
29 static void __iomem *tegra_gic_cpu_base;
30 #endif
32 bool tegra_pending_sgi(void)
34 u32 pending_set;
35 void __iomem *distbase = IO_ADDRESS(TEGRA_ARM_INT_DIST_BASE);
37 pending_set = readl_relaxed(distbase + GIC_DIST_PENDING_SET);
39 if (pending_set & SGI_MASK)
40 return true;
42 return false;
45 #ifdef CONFIG_PM_SLEEP
46 static int tegra_gic_notifier(struct notifier_block *self,
47 unsigned long cmd, void *v)
49 switch (cmd) {
50 case CPU_PM_ENTER:
51 writel_relaxed(0x1E0, tegra_gic_cpu_base + GIC_CPU_CTRL);
52 break;
55 return NOTIFY_OK;
58 static struct notifier_block tegra_gic_notifier_block = {
59 .notifier_call = tegra_gic_notifier,
62 static const struct of_device_id tegra114_dt_gic_match[] __initconst = {
63 { .compatible = "arm,cortex-a15-gic" },
64 { }
67 static void __init tegra114_gic_cpu_pm_registration(void)
69 struct device_node *dn;
71 dn = of_find_matching_node(NULL, tegra114_dt_gic_match);
72 if (!dn)
73 return;
75 tegra_gic_cpu_base = of_iomap(dn, 1);
77 cpu_pm_register_notifier(&tegra_gic_notifier_block);
79 #else
80 static void __init tegra114_gic_cpu_pm_registration(void) { }
81 #endif
83 static const struct of_device_id tegra_ictlr_match[] __initconst = {
84 { .compatible = "nvidia,tegra20-ictlr" },
85 { .compatible = "nvidia,tegra30-ictlr" },
86 { }
89 void __init tegra_init_irq(void)
91 if (WARN_ON(!of_find_matching_node(NULL, tegra_ictlr_match)))
92 pr_warn("Outdated DT detected, suspend/resume will NOT work\n");
94 tegra114_gic_cpu_pm_registration();