Abhilash Kesavan | 6b6844d | 2011-10-04 20:30:22 +0900 | [diff] [blame] | 1 | /* linux/arch/arm/mach-s5p64x0/irq-pm.c |
| 2 | * |
| 3 | * Copyright (c) 2011 Samsung Electronics Co., Ltd. |
| 4 | * http://www.samsung.com |
| 5 | * |
| 6 | * S5P64X0 - Interrupt handling Power Management |
| 7 | * |
| 8 | * Based on arch/arm/mach-s3c64xx/irq-pm.c by Ben Dooks |
| 9 | * |
| 10 | * This program is free software; you can redistribute it and/or modify |
| 11 | * it under the terms of the GNU General Public License version 2 as |
| 12 | * published by the Free Software Foundation. |
| 13 | */ |
| 14 | |
| 15 | #include <linux/syscore_ops.h> |
| 16 | #include <linux/serial_core.h> |
Tushar Behera | 334a1c7 | 2014-02-14 10:32:45 +0900 | [diff] [blame] | 17 | #include <linux/serial_s3c.h> |
Abhilash Kesavan | 6b6844d | 2011-10-04 20:30:22 +0900 | [diff] [blame] | 18 | #include <linux/io.h> |
| 19 | |
Abhilash Kesavan | 6b6844d | 2011-10-04 20:30:22 +0900 | [diff] [blame] | 20 | #include <plat/pm.h> |
| 21 | |
| 22 | #include <mach/regs-gpio.h> |
| 23 | |
| 24 | static struct sleep_save irq_save[] = { |
| 25 | SAVE_ITEM(S5P64X0_EINT0CON0), |
| 26 | SAVE_ITEM(S5P64X0_EINT0FLTCON0), |
| 27 | SAVE_ITEM(S5P64X0_EINT0FLTCON1), |
| 28 | SAVE_ITEM(S5P64X0_EINT0MASK), |
| 29 | }; |
| 30 | |
| 31 | static struct irq_grp_save { |
| 32 | u32 con; |
| 33 | u32 fltcon; |
| 34 | u32 mask; |
| 35 | } eint_grp_save[4]; |
| 36 | |
Arnd Bergmann | 0443a65 | 2014-02-26 17:55:35 +0100 | [diff] [blame] | 37 | #ifdef CONFIG_SERIAL_SAMSUNG |
Abhilash Kesavan | 6b6844d | 2011-10-04 20:30:22 +0900 | [diff] [blame] | 38 | static u32 irq_uart_mask[CONFIG_SERIAL_SAMSUNG_UARTS]; |
Arnd Bergmann | 0443a65 | 2014-02-26 17:55:35 +0100 | [diff] [blame] | 39 | #endif |
Abhilash Kesavan | 6b6844d | 2011-10-04 20:30:22 +0900 | [diff] [blame] | 40 | |
| 41 | static int s5p64x0_irq_pm_suspend(void) |
| 42 | { |
| 43 | struct irq_grp_save *grp = eint_grp_save; |
| 44 | int i; |
| 45 | |
| 46 | S3C_PMDBG("%s: suspending IRQs\n", __func__); |
| 47 | |
| 48 | s3c_pm_do_save(irq_save, ARRAY_SIZE(irq_save)); |
| 49 | |
Arnd Bergmann | 0443a65 | 2014-02-26 17:55:35 +0100 | [diff] [blame] | 50 | #ifdef CONFIG_SERIAL_SAMSUNG |
Abhilash Kesavan | 6b6844d | 2011-10-04 20:30:22 +0900 | [diff] [blame] | 51 | for (i = 0; i < CONFIG_SERIAL_SAMSUNG_UARTS; i++) |
| 52 | irq_uart_mask[i] = __raw_readl(S3C_VA_UARTx(i) + S3C64XX_UINTM); |
Arnd Bergmann | 0443a65 | 2014-02-26 17:55:35 +0100 | [diff] [blame] | 53 | #endif |
Abhilash Kesavan | 6b6844d | 2011-10-04 20:30:22 +0900 | [diff] [blame] | 54 | |
| 55 | for (i = 0; i < ARRAY_SIZE(eint_grp_save); i++, grp++) { |
| 56 | grp->con = __raw_readl(S5P64X0_EINT12CON + (i * 4)); |
| 57 | grp->mask = __raw_readl(S5P64X0_EINT12MASK + (i * 4)); |
| 58 | grp->fltcon = __raw_readl(S5P64X0_EINT12FLTCON + (i * 4)); |
| 59 | } |
| 60 | |
| 61 | return 0; |
| 62 | } |
| 63 | |
| 64 | static void s5p64x0_irq_pm_resume(void) |
| 65 | { |
| 66 | struct irq_grp_save *grp = eint_grp_save; |
| 67 | int i; |
| 68 | |
| 69 | S3C_PMDBG("%s: resuming IRQs\n", __func__); |
| 70 | |
| 71 | s3c_pm_do_restore(irq_save, ARRAY_SIZE(irq_save)); |
| 72 | |
Arnd Bergmann | 0443a65 | 2014-02-26 17:55:35 +0100 | [diff] [blame] | 73 | #ifdef CONFIG_SERIAL_SAMSUNG |
Abhilash Kesavan | 6b6844d | 2011-10-04 20:30:22 +0900 | [diff] [blame] | 74 | for (i = 0; i < CONFIG_SERIAL_SAMSUNG_UARTS; i++) |
| 75 | __raw_writel(irq_uart_mask[i], S3C_VA_UARTx(i) + S3C64XX_UINTM); |
Arnd Bergmann | 0443a65 | 2014-02-26 17:55:35 +0100 | [diff] [blame] | 76 | #endif |
Abhilash Kesavan | 6b6844d | 2011-10-04 20:30:22 +0900 | [diff] [blame] | 77 | |
| 78 | for (i = 0; i < ARRAY_SIZE(eint_grp_save); i++, grp++) { |
| 79 | __raw_writel(grp->con, S5P64X0_EINT12CON + (i * 4)); |
| 80 | __raw_writel(grp->mask, S5P64X0_EINT12MASK + (i * 4)); |
| 81 | __raw_writel(grp->fltcon, S5P64X0_EINT12FLTCON + (i * 4)); |
| 82 | } |
| 83 | |
| 84 | S3C_PMDBG("%s: IRQ configuration restored\n", __func__); |
| 85 | } |
| 86 | |
| 87 | static struct syscore_ops s5p64x0_irq_syscore_ops = { |
| 88 | .suspend = s5p64x0_irq_pm_suspend, |
| 89 | .resume = s5p64x0_irq_pm_resume, |
| 90 | }; |
| 91 | |
| 92 | static int __init s5p64x0_syscore_init(void) |
| 93 | { |
| 94 | register_syscore_ops(&s5p64x0_irq_syscore_ops); |
| 95 | |
| 96 | return 0; |
| 97 | } |
| 98 | core_initcall(s5p64x0_syscore_init); |