18c2ecf20Sopenharmony_ci// SPDX-License-Identifier: GPL-2.0 28c2ecf20Sopenharmony_ci// 38c2ecf20Sopenharmony_ci// Copyright (C) 2013 Samsung Electronics Co., Ltd. 48c2ecf20Sopenharmony_ci// Tomasz Figa <t.figa@samsung.com> 58c2ecf20Sopenharmony_ci// Copyright (C) 2008 Openmoko, Inc. 68c2ecf20Sopenharmony_ci// Copyright (C) 2004-2008 Simtec Electronics 78c2ecf20Sopenharmony_ci// Ben Dooks <ben@simtec.co.uk> 88c2ecf20Sopenharmony_ci// http://armlinux.simtec.co.uk/ 98c2ecf20Sopenharmony_ci// 108c2ecf20Sopenharmony_ci// Samsung common power management (suspend to RAM) debug support 118c2ecf20Sopenharmony_ci 128c2ecf20Sopenharmony_ci#include <linux/serial_core.h> 138c2ecf20Sopenharmony_ci#include <linux/serial_s3c.h> 148c2ecf20Sopenharmony_ci#include <linux/io.h> 158c2ecf20Sopenharmony_ci 168c2ecf20Sopenharmony_ci#include <asm/mach/map.h> 178c2ecf20Sopenharmony_ci 188c2ecf20Sopenharmony_ci#include <linux/soc/samsung/s3c-pm.h> 198c2ecf20Sopenharmony_ci 208c2ecf20Sopenharmony_cistatic struct pm_uart_save uart_save; 218c2ecf20Sopenharmony_ci 228c2ecf20Sopenharmony_ciextern void printascii(const char *); 238c2ecf20Sopenharmony_ci 248c2ecf20Sopenharmony_civoid s3c_pm_dbg(const char *fmt, ...) 258c2ecf20Sopenharmony_ci{ 268c2ecf20Sopenharmony_ci va_list va; 278c2ecf20Sopenharmony_ci char buff[256]; 288c2ecf20Sopenharmony_ci 298c2ecf20Sopenharmony_ci va_start(va, fmt); 308c2ecf20Sopenharmony_ci vsnprintf(buff, sizeof(buff), fmt, va); 318c2ecf20Sopenharmony_ci va_end(va); 328c2ecf20Sopenharmony_ci 338c2ecf20Sopenharmony_ci printascii(buff); 348c2ecf20Sopenharmony_ci} 358c2ecf20Sopenharmony_ci 368c2ecf20Sopenharmony_cistatic inline void __iomem *s3c_pm_uart_base(void) 378c2ecf20Sopenharmony_ci{ 388c2ecf20Sopenharmony_ci unsigned long paddr; 398c2ecf20Sopenharmony_ci unsigned long vaddr; 408c2ecf20Sopenharmony_ci 418c2ecf20Sopenharmony_ci debug_ll_addr(&paddr, &vaddr); 428c2ecf20Sopenharmony_ci 438c2ecf20Sopenharmony_ci return (void __iomem *)vaddr; 448c2ecf20Sopenharmony_ci} 458c2ecf20Sopenharmony_ci 468c2ecf20Sopenharmony_civoid s3c_pm_save_uarts(bool is_s3c2410) 478c2ecf20Sopenharmony_ci{ 488c2ecf20Sopenharmony_ci void __iomem *regs = s3c_pm_uart_base(); 498c2ecf20Sopenharmony_ci struct pm_uart_save *save = &uart_save; 508c2ecf20Sopenharmony_ci 518c2ecf20Sopenharmony_ci save->ulcon = __raw_readl(regs + S3C2410_ULCON); 528c2ecf20Sopenharmony_ci save->ucon = __raw_readl(regs + S3C2410_UCON); 538c2ecf20Sopenharmony_ci save->ufcon = __raw_readl(regs + S3C2410_UFCON); 548c2ecf20Sopenharmony_ci save->umcon = __raw_readl(regs + S3C2410_UMCON); 558c2ecf20Sopenharmony_ci save->ubrdiv = __raw_readl(regs + S3C2410_UBRDIV); 568c2ecf20Sopenharmony_ci 578c2ecf20Sopenharmony_ci if (!is_s3c2410) 588c2ecf20Sopenharmony_ci save->udivslot = __raw_readl(regs + S3C2443_DIVSLOT); 598c2ecf20Sopenharmony_ci 608c2ecf20Sopenharmony_ci S3C_PMDBG("UART[%p]: ULCON=%04x, UCON=%04x, UFCON=%04x, UBRDIV=%04x\n", 618c2ecf20Sopenharmony_ci regs, save->ulcon, save->ucon, save->ufcon, save->ubrdiv); 628c2ecf20Sopenharmony_ci} 638c2ecf20Sopenharmony_ci 648c2ecf20Sopenharmony_civoid s3c_pm_restore_uarts(bool is_s3c2410) 658c2ecf20Sopenharmony_ci{ 668c2ecf20Sopenharmony_ci void __iomem *regs = s3c_pm_uart_base(); 678c2ecf20Sopenharmony_ci struct pm_uart_save *save = &uart_save; 688c2ecf20Sopenharmony_ci 698c2ecf20Sopenharmony_ci s3c_pm_arch_update_uart(regs, save); 708c2ecf20Sopenharmony_ci 718c2ecf20Sopenharmony_ci __raw_writel(save->ulcon, regs + S3C2410_ULCON); 728c2ecf20Sopenharmony_ci __raw_writel(save->ucon, regs + S3C2410_UCON); 738c2ecf20Sopenharmony_ci __raw_writel(save->ufcon, regs + S3C2410_UFCON); 748c2ecf20Sopenharmony_ci __raw_writel(save->umcon, regs + S3C2410_UMCON); 758c2ecf20Sopenharmony_ci __raw_writel(save->ubrdiv, regs + S3C2410_UBRDIV); 768c2ecf20Sopenharmony_ci 778c2ecf20Sopenharmony_ci if (!is_s3c2410) 788c2ecf20Sopenharmony_ci __raw_writel(save->udivslot, regs + S3C2443_DIVSLOT); 798c2ecf20Sopenharmony_ci} 80