pm-debug.c 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. /*
  2. * Copyright (C) 2013 Samsung Electronics Co., Ltd.
  3. * Tomasz Figa <t.figa@samsung.com>
  4. * Copyright (C) 2008 Openmoko, Inc.
  5. * Copyright (C) 2004-2008 Simtec Electronics
  6. * Ben Dooks <ben@simtec.co.uk>
  7. * http://armlinux.simtec.co.uk/
  8. *
  9. * Samsung common power management (suspend to RAM) debug support
  10. *
  11. * This program is free software; you can redistribute it and/or modify
  12. * it under the terms of the GNU General Public License version 2 as
  13. * published by the Free Software Foundation.
  14. */
  15. #include <linux/serial_core.h>
  16. #include <linux/serial_s3c.h>
  17. #include <linux/io.h>
  18. #include <asm/mach/map.h>
  19. #include <plat/cpu.h>
  20. #include <plat/pm-common.h>
  21. #ifdef CONFIG_SAMSUNG_ATAGS
  22. #include <plat/pm.h>
  23. #include <mach/pm-core.h>
  24. #else
  25. static inline void s3c_pm_debug_init_uart(void) {}
  26. static inline void s3c_pm_arch_update_uart(void __iomem *regs,
  27. struct pm_uart_save *save) {}
  28. #endif
  29. static struct pm_uart_save uart_save;
  30. extern void printascii(const char *);
  31. void s3c_pm_dbg(const char *fmt, ...)
  32. {
  33. va_list va;
  34. char buff[256];
  35. va_start(va, fmt);
  36. vsnprintf(buff, sizeof(buff), fmt, va);
  37. va_end(va);
  38. printascii(buff);
  39. }
  40. void s3c_pm_debug_init(void)
  41. {
  42. /* restart uart clocks so we can use them to output */
  43. s3c_pm_debug_init_uart();
  44. }
  45. static inline void __iomem *s3c_pm_uart_base(void)
  46. {
  47. unsigned long paddr;
  48. unsigned long vaddr;
  49. debug_ll_addr(&paddr, &vaddr);
  50. return (void __iomem *)vaddr;
  51. }
  52. void s3c_pm_save_uarts(void)
  53. {
  54. void __iomem *regs = s3c_pm_uart_base();
  55. struct pm_uart_save *save = &uart_save;
  56. save->ulcon = __raw_readl(regs + S3C2410_ULCON);
  57. save->ucon = __raw_readl(regs + S3C2410_UCON);
  58. save->ufcon = __raw_readl(regs + S3C2410_UFCON);
  59. save->umcon = __raw_readl(regs + S3C2410_UMCON);
  60. save->ubrdiv = __raw_readl(regs + S3C2410_UBRDIV);
  61. if (!soc_is_s3c2410())
  62. save->udivslot = __raw_readl(regs + S3C2443_DIVSLOT);
  63. S3C_PMDBG("UART[%p]: ULCON=%04x, UCON=%04x, UFCON=%04x, UBRDIV=%04x\n",
  64. regs, save->ulcon, save->ucon, save->ufcon, save->ubrdiv);
  65. }
  66. void s3c_pm_restore_uarts(void)
  67. {
  68. void __iomem *regs = s3c_pm_uart_base();
  69. struct pm_uart_save *save = &uart_save;
  70. s3c_pm_arch_update_uart(regs, save);
  71. __raw_writel(save->ulcon, regs + S3C2410_ULCON);
  72. __raw_writel(save->ucon, regs + S3C2410_UCON);
  73. __raw_writel(save->ufcon, regs + S3C2410_UFCON);
  74. __raw_writel(save->umcon, regs + S3C2410_UMCON);
  75. __raw_writel(save->ubrdiv, regs + S3C2410_UBRDIV);
  76. if (!soc_is_s3c2410())
  77. __raw_writel(save->udivslot, regs + S3C2443_DIVSLOT);
  78. }