pm-debug.c 2.3 KB

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