wd_timer.c 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. /*
  2. * OMAP2+ MPU WD_TIMER-specific code
  3. *
  4. * This program is free software; you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License as published by
  6. * the Free Software Foundation; either version 2 of the License, or
  7. * (at your option) any later version.
  8. */
  9. #include <linux/kernel.h>
  10. #include <linux/io.h>
  11. #include <linux/err.h>
  12. #include <plat/omap_hwmod.h>
  13. #include "wd_timer.h"
  14. /*
  15. * In order to avoid any assumptions from bootloader regarding WDT
  16. * settings, WDT module is reset during init. This enables the watchdog
  17. * timer. Hence it is required to disable the watchdog after the WDT reset
  18. * during init. Otherwise the system would reboot as per the default
  19. * watchdog timer registers settings.
  20. */
  21. #define OMAP_WDT_WPS 0x34
  22. #define OMAP_WDT_SPR 0x48
  23. int omap2_wd_timer_disable(struct omap_hwmod *oh)
  24. {
  25. void __iomem *base;
  26. if (!oh) {
  27. pr_err("%s: Could not look up wdtimer_hwmod\n", __func__);
  28. return -EINVAL;
  29. }
  30. base = omap_hwmod_get_mpu_rt_va(oh);
  31. if (!base) {
  32. pr_err("%s: Could not get the base address for %s\n",
  33. oh->name, __func__);
  34. return -EINVAL;
  35. }
  36. /* sequence required to disable watchdog */
  37. __raw_writel(0xAAAA, base + OMAP_WDT_SPR);
  38. while (__raw_readl(base + OMAP_WDT_WPS) & 0x10)
  39. cpu_relax();
  40. __raw_writel(0x5555, base + OMAP_WDT_SPR);
  41. while (__raw_readl(base + OMAP_WDT_WPS) & 0x10)
  42. cpu_relax();
  43. return 0;
  44. }