irq.c 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. // SPDX-License-Identifier: GPL-2.0-only
  2. /*
  3. * Copyright (C) 2011 Google, Inc.
  4. *
  5. * Author:
  6. * Colin Cross <[email protected]>
  7. *
  8. * Copyright (C) 2010,2013, NVIDIA Corporation
  9. */
  10. #include <linux/cpu_pm.h>
  11. #include <linux/interrupt.h>
  12. #include <linux/io.h>
  13. #include <linux/irqchip/arm-gic.h>
  14. #include <linux/irq.h>
  15. #include <linux/kernel.h>
  16. #include <linux/of_address.h>
  17. #include <linux/of.h>
  18. #include <linux/syscore_ops.h>
  19. #include <soc/tegra/irq.h>
  20. #include "board.h"
  21. #include "iomap.h"
  22. #define SGI_MASK 0xFFFF
  23. #ifdef CONFIG_PM_SLEEP
  24. static void __iomem *tegra_gic_cpu_base;
  25. #endif
  26. bool tegra_pending_sgi(void)
  27. {
  28. u32 pending_set;
  29. void __iomem *distbase = IO_ADDRESS(TEGRA_ARM_INT_DIST_BASE);
  30. pending_set = readl_relaxed(distbase + GIC_DIST_PENDING_SET);
  31. if (pending_set & SGI_MASK)
  32. return true;
  33. return false;
  34. }
  35. #ifdef CONFIG_PM_SLEEP
  36. static int tegra_gic_notifier(struct notifier_block *self,
  37. unsigned long cmd, void *v)
  38. {
  39. switch (cmd) {
  40. case CPU_PM_ENTER:
  41. writel_relaxed(0x1E0, tegra_gic_cpu_base + GIC_CPU_CTRL);
  42. break;
  43. }
  44. return NOTIFY_OK;
  45. }
  46. static struct notifier_block tegra_gic_notifier_block = {
  47. .notifier_call = tegra_gic_notifier,
  48. };
  49. static const struct of_device_id tegra114_dt_gic_match[] __initconst = {
  50. { .compatible = "arm,cortex-a15-gic" },
  51. { }
  52. };
  53. static void __init tegra114_gic_cpu_pm_registration(void)
  54. {
  55. struct device_node *dn;
  56. dn = of_find_matching_node(NULL, tegra114_dt_gic_match);
  57. if (!dn)
  58. return;
  59. tegra_gic_cpu_base = of_iomap(dn, 1);
  60. cpu_pm_register_notifier(&tegra_gic_notifier_block);
  61. }
  62. #else
  63. static void __init tegra114_gic_cpu_pm_registration(void) { }
  64. #endif
  65. static const struct of_device_id tegra_ictlr_match[] __initconst = {
  66. { .compatible = "nvidia,tegra20-ictlr" },
  67. { .compatible = "nvidia,tegra30-ictlr" },
  68. { }
  69. };
  70. void __init tegra_init_irq(void)
  71. {
  72. if (WARN_ON(!of_find_matching_node(NULL, tegra_ictlr_match)))
  73. pr_warn("Outdated DT detected, suspend/resume will NOT work\n");
  74. tegra114_gic_cpu_pm_registration();
  75. }