system.h 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. /* linux/include/asm-arm/arch-s3c2410/system.h
  2. *
  3. * Copyright (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. #include <asm/hardware.h>
  13. #include <asm/io.h>
  14. #include <asm/arch/map.h>
  15. #include <asm/arch/idle.h>
  16. #include <asm/arch/reset.h>
  17. #include <asm/plat-s3c/regs-watchdog.h>
  18. #include <asm/arch/regs-clock.h>
  19. #include <linux/clk.h>
  20. #include <linux/err.h>
  21. void (*s3c24xx_idle)(void);
  22. void (*s3c24xx_reset_hook)(void);
  23. void s3c24xx_default_idle(void)
  24. {
  25. unsigned long tmp;
  26. int i;
  27. /* idle the system by using the idle mode which will wait for an
  28. * interrupt to happen before restarting the system.
  29. */
  30. /* Warning: going into idle state upsets jtag scanning */
  31. __raw_writel(__raw_readl(S3C2410_CLKCON) | S3C2410_CLKCON_IDLE,
  32. S3C2410_CLKCON);
  33. /* the samsung port seems to do a loop and then unset idle.. */
  34. for (i = 0; i < 50; i++) {
  35. tmp += __raw_readl(S3C2410_CLKCON); /* ensure loop not optimised out */
  36. }
  37. /* this bit is not cleared on re-start... */
  38. __raw_writel(__raw_readl(S3C2410_CLKCON) & ~S3C2410_CLKCON_IDLE,
  39. S3C2410_CLKCON);
  40. }
  41. static void arch_idle(void)
  42. {
  43. if (s3c24xx_idle != NULL)
  44. (s3c24xx_idle)();
  45. else
  46. s3c24xx_default_idle();
  47. }
  48. static void
  49. arch_reset(char mode)
  50. {
  51. struct clk *wdtclk;
  52. if (mode == 's') {
  53. cpu_reset(0);
  54. }
  55. if (s3c24xx_reset_hook)
  56. s3c24xx_reset_hook();
  57. printk("arch_reset: attempting watchdog reset\n");
  58. __raw_writel(0, S3C2410_WTCON); /* disable watchdog, to be safe */
  59. wdtclk = clk_get(NULL, "watchdog");
  60. if (!IS_ERR(wdtclk)) {
  61. clk_enable(wdtclk);
  62. } else
  63. printk(KERN_WARNING "%s: warning: cannot get watchdog clock\n", __func__);
  64. /* put initial values into count and data */
  65. __raw_writel(0x80, S3C2410_WTCNT);
  66. __raw_writel(0x80, S3C2410_WTDAT);
  67. /* set the watchdog to go and reset... */
  68. __raw_writel(S3C2410_WTCON_ENABLE|S3C2410_WTCON_DIV16|S3C2410_WTCON_RSTEN |
  69. S3C2410_WTCON_PRESCALE(0x20), S3C2410_WTCON);
  70. /* wait for reset to assert... */
  71. mdelay(500);
  72. printk(KERN_ERR "Watchdog reset failed to assert reset\n");
  73. /* delay to allow the serial port to show the message */
  74. mdelay(50);
  75. /* we'll take a jump through zero as a poor second */
  76. cpu_reset(0);
  77. }