system.h 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. /* linux/include/asm-arm/arch-s3c2410/system.h
  2. *
  3. * (c) 2003 Simtec Electronics
  4. * Ben Dooks <ben@simtec.co.uk>
  5. *
  6. * S3C2410 - System function defines and includes
  7. *
  8. * This program is free software; you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License version 2 as
  10. * published by the Free Software Foundation.
  11. *
  12. * Changelog:
  13. * 12-May-2003 BJD Created file
  14. * 14-May-2003 BJD Removed idle to aid debugging
  15. * 12-Jun-2003 BJD Added reset via watchdog
  16. * 04-Sep-2003 BJD Moved to v2.6
  17. * 28-Oct-2004 BJD Added over-ride for idle, and fixed reset panic()
  18. */
  19. #include <asm/hardware.h>
  20. #include <asm/io.h>
  21. #include <asm/arch/map.h>
  22. #include <asm/arch/idle.h>
  23. #include <asm/arch/regs-watchdog.h>
  24. #include <asm/arch/regs-clock.h>
  25. void (*s3c24xx_idle)(void);
  26. void s3c24xx_default_idle(void)
  27. {
  28. void __iomem *reg = S3C2410_CLKCON;
  29. unsigned long tmp;
  30. int i;
  31. /* idle the system by using the idle mode which will wait for an
  32. * interrupt to happen before restarting the system.
  33. */
  34. /* Warning: going into idle state upsets jtag scanning */
  35. __raw_writel(__raw_readl(reg) | (1<<2), reg);
  36. /* the samsung port seems to do a loop and then unset idle.. */
  37. for (i = 0; i < 50; i++) {
  38. tmp += __raw_readl(reg); /* ensure loop not optimised out */
  39. }
  40. /* this bit is not cleared on re-start... */
  41. __raw_writel(__raw_readl(reg) & ~(1<<2), reg);
  42. }
  43. static void arch_idle(void)
  44. {
  45. if (s3c24xx_idle != NULL)
  46. (s3c24xx_idle)();
  47. else
  48. s3c24xx_default_idle();
  49. }
  50. static void
  51. arch_reset(char mode)
  52. {
  53. if (mode == 's') {
  54. cpu_reset(0);
  55. }
  56. printk("arch_reset: attempting watchdog reset\n");
  57. __raw_writel(0, S3C2410_WTCON); /* disable watchdog, to be safe */
  58. /* put initial values into count and data */
  59. __raw_writel(0x100, S3C2410_WTCNT);
  60. __raw_writel(0x100, S3C2410_WTDAT);
  61. /* set the watchdog to go and reset... */
  62. __raw_writel(S3C2410_WTCON_ENABLE|S3C2410_WTCON_DIV16|S3C2410_WTCON_RSTEN |
  63. S3C2410_WTCON_PRESCALE(0x80), S3C2410_WTCON);
  64. /* wait for reset to assert... */
  65. mdelay(5000);
  66. printk(KERN_ERR "Watchdog reset failed to assert reset\n");
  67. /* we'll take a jump through zero as a poor second */
  68. cpu_reset(0);
  69. }