irq.c 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. /*
  2. * Copyright (C) 2011 Google, Inc.
  3. *
  4. * Author:
  5. * Colin Cross <ccross@android.com>
  6. *
  7. * Copyright (C) 2010,2013, NVIDIA Corporation
  8. *
  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.
  12. *
  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.
  17. *
  18. */
  19. #include <linux/cpu_pm.h>
  20. #include <linux/interrupt.h>
  21. #include <linux/io.h>
  22. #include <linux/irqchip/arm-gic.h>
  23. #include <linux/irq.h>
  24. #include <linux/kernel.h>
  25. #include <linux/of_address.h>
  26. #include <linux/of.h>
  27. #include <linux/syscore_ops.h>
  28. #include "board.h"
  29. #include "iomap.h"
  30. #include "irq.h"
  31. #define SGI_MASK 0xFFFF
  32. #ifdef CONFIG_PM_SLEEP
  33. static void __iomem *tegra_gic_cpu_base;
  34. #endif
  35. bool tegra_pending_sgi(void)
  36. {
  37. u32 pending_set;
  38. void __iomem *distbase = IO_ADDRESS(TEGRA_ARM_INT_DIST_BASE);
  39. pending_set = readl_relaxed(distbase + GIC_DIST_PENDING_SET);
  40. if (pending_set & SGI_MASK)
  41. return true;
  42. return false;
  43. }
  44. #ifdef CONFIG_PM_SLEEP
  45. static 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. return NOTIFY_OK;
  54. }
  55. static struct notifier_block tegra_gic_notifier_block = {
  56. .notifier_call = tegra_gic_notifier,
  57. };
  58. static const struct of_device_id tegra114_dt_gic_match[] __initconst = {
  59. { .compatible = "arm,cortex-a15-gic" },
  60. { }
  61. };
  62. static void tegra114_gic_cpu_pm_registration(void)
  63. {
  64. struct device_node *dn;
  65. dn = of_find_matching_node(NULL, tegra114_dt_gic_match);
  66. if (!dn)
  67. return;
  68. tegra_gic_cpu_base = of_iomap(dn, 1);
  69. cpu_pm_register_notifier(&tegra_gic_notifier_block);
  70. }
  71. #else
  72. static void tegra114_gic_cpu_pm_registration(void) { }
  73. #endif
  74. static const struct of_device_id tegra_ictlr_match[] __initconst = {
  75. { .compatible = "nvidia,tegra20-ictlr" },
  76. { .compatible = "nvidia,tegra30-ictlr" },
  77. { }
  78. };
  79. void __init tegra_init_irq(void)
  80. {
  81. if (WARN_ON(!of_find_matching_node(NULL, tegra_ictlr_match)))
  82. pr_warn("Outdated DT detected, suspend/resume will NOT work\n");
  83. tegra114_gic_cpu_pm_registration();
  84. }