Kukjin Kim | 8eadcf7 | 2012-04-15 21:57:38 -0700 | [diff] [blame] | 1 | /* |
Jongpill Lee | ea31fd4 | 2010-10-02 19:13:42 +0900 | [diff] [blame] | 2 | * Copyright (c) 2010 Samsung Electronics Co., Ltd. |
| 3 | * http://www.samsung.com |
| 4 | * |
| 5 | * Based on arch/arm/plat-s3c24xx/irq-pm.c, |
| 6 | * Copyright (c) 2003,2004 Simtec Electronics |
| 7 | * Ben Dooks <ben@simtec.co.uk> |
| 8 | * http://armlinux.simtec.co.uk/ |
| 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/init.h> |
| 16 | #include <linux/module.h> |
| 17 | #include <linux/interrupt.h> |
Jongpill Lee | ea31fd4 | 2010-10-02 19:13:42 +0900 | [diff] [blame] | 18 | |
| 19 | #include <plat/cpu.h> |
| 20 | #include <plat/irqs.h> |
| 21 | #include <plat/pm.h> |
| 22 | #include <mach/map.h> |
| 23 | |
| 24 | #include <mach/regs-gpio.h> |
Kukjin Kim | 05a6380 | 2013-12-19 04:07:32 +0900 | [diff] [blame] | 25 | |
| 26 | #ifndef CONFIG_ARCH_EXYNOS |
Jongpill Lee | ea31fd4 | 2010-10-02 19:13:42 +0900 | [diff] [blame] | 27 | #include <mach/regs-irq.h> |
Kukjin Kim | 05a6380 | 2013-12-19 04:07:32 +0900 | [diff] [blame] | 28 | #endif |
Jongpill Lee | ea31fd4 | 2010-10-02 19:13:42 +0900 | [diff] [blame] | 29 | |
| 30 | /* state for IRQs over sleep */ |
| 31 | |
| 32 | /* default is to allow for EINT0..EINT31, and IRQ_RTC_TIC, IRQ_RTC_ALARM, |
| 33 | * as wakeup sources |
| 34 | * |
| 35 | * set bit to 1 in allow bitfield to enable the wakeup settings on it |
| 36 | */ |
| 37 | |
| 38 | unsigned long s3c_irqwake_intallow = 0x00000006L; |
| 39 | unsigned long s3c_irqwake_eintallow = 0xffffffffL; |
| 40 | |
Lennert Buytenhek | bb0b237 | 2010-12-14 22:55:26 +0100 | [diff] [blame] | 41 | int s3c_irq_wake(struct irq_data *data, unsigned int state) |
Jongpill Lee | ea31fd4 | 2010-10-02 19:13:42 +0900 | [diff] [blame] | 42 | { |
| 43 | unsigned long irqbit; |
Kukjin Kim | bb19a75 | 2012-01-25 13:48:11 +0900 | [diff] [blame] | 44 | unsigned int irq_rtc_tic, irq_rtc_alarm; |
Jongpill Lee | ea31fd4 | 2010-10-02 19:13:42 +0900 | [diff] [blame] | 45 | |
Kukjin Kim | bb19a75 | 2012-01-25 13:48:11 +0900 | [diff] [blame] | 46 | #ifdef CONFIG_ARCH_EXYNOS |
| 47 | if (soc_is_exynos5250()) { |
| 48 | irq_rtc_tic = EXYNOS5_IRQ_RTC_TIC; |
| 49 | irq_rtc_alarm = EXYNOS5_IRQ_RTC_ALARM; |
| 50 | } else { |
| 51 | irq_rtc_tic = EXYNOS4_IRQ_RTC_TIC; |
| 52 | irq_rtc_alarm = EXYNOS4_IRQ_RTC_ALARM; |
| 53 | } |
| 54 | #else |
| 55 | irq_rtc_tic = IRQ_RTC_TIC; |
| 56 | irq_rtc_alarm = IRQ_RTC_ALARM; |
| 57 | #endif |
| 58 | |
| 59 | if (data->irq == irq_rtc_tic || data->irq == irq_rtc_alarm) { |
| 60 | irqbit = 1 << (data->irq + 1 - irq_rtc_alarm); |
| 61 | |
Jongpill Lee | ea31fd4 | 2010-10-02 19:13:42 +0900 | [diff] [blame] | 62 | if (!state) |
| 63 | s3c_irqwake_intmask |= irqbit; |
| 64 | else |
| 65 | s3c_irqwake_intmask &= ~irqbit; |
Kukjin Kim | bb19a75 | 2012-01-25 13:48:11 +0900 | [diff] [blame] | 66 | } else { |
Jongpill Lee | ea31fd4 | 2010-10-02 19:13:42 +0900 | [diff] [blame] | 67 | return -ENOENT; |
| 68 | } |
Kukjin Kim | bb19a75 | 2012-01-25 13:48:11 +0900 | [diff] [blame] | 69 | |
Jongpill Lee | ea31fd4 | 2010-10-02 19:13:42 +0900 | [diff] [blame] | 70 | return 0; |
| 71 | } |
| 72 | |
| 73 | static struct sleep_save eint_save[] = { |
| 74 | SAVE_ITEM(S5P_EINT_CON(0)), |
| 75 | SAVE_ITEM(S5P_EINT_CON(1)), |
| 76 | SAVE_ITEM(S5P_EINT_CON(2)), |
| 77 | SAVE_ITEM(S5P_EINT_CON(3)), |
| 78 | |
| 79 | SAVE_ITEM(S5P_EINT_FLTCON(0)), |
| 80 | SAVE_ITEM(S5P_EINT_FLTCON(1)), |
| 81 | SAVE_ITEM(S5P_EINT_FLTCON(2)), |
| 82 | SAVE_ITEM(S5P_EINT_FLTCON(3)), |
| 83 | SAVE_ITEM(S5P_EINT_FLTCON(4)), |
| 84 | SAVE_ITEM(S5P_EINT_FLTCON(5)), |
| 85 | SAVE_ITEM(S5P_EINT_FLTCON(6)), |
| 86 | SAVE_ITEM(S5P_EINT_FLTCON(7)), |
| 87 | |
| 88 | SAVE_ITEM(S5P_EINT_MASK(0)), |
| 89 | SAVE_ITEM(S5P_EINT_MASK(1)), |
| 90 | SAVE_ITEM(S5P_EINT_MASK(2)), |
| 91 | SAVE_ITEM(S5P_EINT_MASK(3)), |
| 92 | }; |
| 93 | |
Rafael J. Wysocki | bb072c3 | 2011-04-22 22:03:21 +0200 | [diff] [blame] | 94 | int s3c24xx_irq_suspend(void) |
Jongpill Lee | ea31fd4 | 2010-10-02 19:13:42 +0900 | [diff] [blame] | 95 | { |
| 96 | s3c_pm_do_save(eint_save, ARRAY_SIZE(eint_save)); |
| 97 | |
| 98 | return 0; |
| 99 | } |
| 100 | |
Rafael J. Wysocki | bb072c3 | 2011-04-22 22:03:21 +0200 | [diff] [blame] | 101 | void s3c24xx_irq_resume(void) |
Jongpill Lee | ea31fd4 | 2010-10-02 19:13:42 +0900 | [diff] [blame] | 102 | { |
| 103 | s3c_pm_do_restore(eint_save, ARRAY_SIZE(eint_save)); |
Jongpill Lee | ea31fd4 | 2010-10-02 19:13:42 +0900 | [diff] [blame] | 104 | } |
| 105 | |