sysirq_mask.c 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. /*
  2. * sysirq_mask.c - System-interrupt masking
  3. *
  4. * Copyright (C) 2013 Johan Hovold <jhovold@gmail.com>
  5. *
  6. * Functions to disable system interrupts from backup-powered peripherals.
  7. *
  8. * The RTC and RTT-peripherals are generally powered by backup power (VDDBU)
  9. * and are not reset on wake-up, user, watchdog or software reset. This means
  10. * that their interrupts may be enabled during early boot (e.g. after a user
  11. * reset).
  12. *
  13. * As the RTC and RTT share the system-interrupt line with the PIT, an
  14. * interrupt occurring before a handler has been installed would lead to the
  15. * system interrupt being disabled and prevent the system from booting.
  16. *
  17. * This program is free software; you can redistribute it and/or modify
  18. * it under the terms of the GNU General Public License as published by
  19. * the Free Software Foundation; either version 2 of the License, or
  20. * (at your option) any later version.
  21. */
  22. #include <linux/io.h>
  23. #include <mach/at91_rtt.h>
  24. #include "generic.h"
  25. #define AT91_RTC_IDR 0x24 /* Interrupt Disable Register */
  26. #define AT91_RTC_IMR 0x28 /* Interrupt Mask Register */
  27. #define AT91_RTC_IRQ_MASK 0x1f /* Available IRQs mask */
  28. void __init at91_sysirq_mask_rtc(u32 rtc_base)
  29. {
  30. void __iomem *base;
  31. base = ioremap(rtc_base, 64);
  32. if (!base)
  33. return;
  34. /*
  35. * sam9x5 SoCs have the following errata:
  36. * "RTC: Interrupt Mask Register cannot be used
  37. * Interrupt Mask Register read always returns 0."
  38. *
  39. * Hence we're not relying on IMR values to disable
  40. * interrupts.
  41. */
  42. writel_relaxed(AT91_RTC_IRQ_MASK, base + AT91_RTC_IDR);
  43. (void)readl_relaxed(base + AT91_RTC_IMR); /* flush */
  44. iounmap(base);
  45. }
  46. void __init at91_sysirq_mask_rtt(u32 rtt_base)
  47. {
  48. void __iomem *base;
  49. void __iomem *reg;
  50. u32 mode;
  51. base = ioremap(rtt_base, 16);
  52. if (!base)
  53. return;
  54. reg = base + AT91_RTT_MR;
  55. mode = readl_relaxed(reg);
  56. if (mode & (AT91_RTT_ALMIEN | AT91_RTT_RTTINCIEN)) {
  57. pr_info("AT91: Disabling rtt irq\n");
  58. mode &= ~(AT91_RTT_ALMIEN | AT91_RTT_RTTINCIEN);
  59. writel_relaxed(mode, reg);
  60. (void)readl_relaxed(reg); /* flush */
  61. }
  62. iounmap(base);
  63. }