blob: ace7a390b5febfab7bba8c826ed3243bac057ed8 [file] [log] [blame]
David Brazdil0f672f62019-12-10 10:32:29 +00001// SPDX-License-Identifier: GPL-2.0-only
Andrew Scullb4b6d4a2019-01-02 15:54:55 +00002/*
3 * Copyright (C) 2011 Google, Inc.
4 *
5 * Author:
6 * Colin Cross <ccross@android.com>
7 *
8 * Copyright (C) 2010,2013, NVIDIA Corporation
Andrew Scullb4b6d4a2019-01-02 15:54:55 +00009 */
10
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>
20
21#include "board.h"
22#include "iomap.h"
23#include "irq.h"
24
25#define SGI_MASK 0xFFFF
26
27#ifdef CONFIG_PM_SLEEP
28static void __iomem *tegra_gic_cpu_base;
29#endif
30
31bool tegra_pending_sgi(void)
32{
33 u32 pending_set;
34 void __iomem *distbase = IO_ADDRESS(TEGRA_ARM_INT_DIST_BASE);
35
36 pending_set = readl_relaxed(distbase + GIC_DIST_PENDING_SET);
37
38 if (pending_set & SGI_MASK)
39 return true;
40
41 return false;
42}
43
44#ifdef CONFIG_PM_SLEEP
45static int tegra_gic_notifier(struct notifier_block *self,
46 unsigned long cmd, void *v)
47{
48 switch (cmd) {
49 case CPU_PM_ENTER:
50 writel_relaxed(0x1E0, tegra_gic_cpu_base + GIC_CPU_CTRL);
51 break;
52 }
53
54 return NOTIFY_OK;
55}
56
57static struct notifier_block tegra_gic_notifier_block = {
58 .notifier_call = tegra_gic_notifier,
59};
60
61static const struct of_device_id tegra114_dt_gic_match[] __initconst = {
62 { .compatible = "arm,cortex-a15-gic" },
63 { }
64};
65
David Brazdil0f672f62019-12-10 10:32:29 +000066static void __init tegra114_gic_cpu_pm_registration(void)
Andrew Scullb4b6d4a2019-01-02 15:54:55 +000067{
68 struct device_node *dn;
69
70 dn = of_find_matching_node(NULL, tegra114_dt_gic_match);
71 if (!dn)
72 return;
73
74 tegra_gic_cpu_base = of_iomap(dn, 1);
75
76 cpu_pm_register_notifier(&tegra_gic_notifier_block);
77}
78#else
David Brazdil0f672f62019-12-10 10:32:29 +000079static void __init tegra114_gic_cpu_pm_registration(void) { }
Andrew Scullb4b6d4a2019-01-02 15:54:55 +000080#endif
81
82static const struct of_device_id tegra_ictlr_match[] __initconst = {
83 { .compatible = "nvidia,tegra20-ictlr" },
84 { .compatible = "nvidia,tegra30-ictlr" },
85 { }
86};
87
88void __init tegra_init_irq(void)
89{
90 if (WARN_ON(!of_find_matching_node(NULL, tegra_ictlr_match)))
91 pr_warn("Outdated DT detected, suspend/resume will NOT work\n");
92
93 tegra114_gic_cpu_pm_registration();
94}