aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm/plat-omap/gpio.c
diff options
context:
space:
mode:
authorRajendra Nayak <rnayak@ti.com>2008-09-26 08:17:48 -0400
committerKevin Hilman <khilman@deeprootsystems.com>2009-11-11 17:40:12 -0500
commit40c670f0314c3c9463ce9c2f2b9b1085884837f6 (patch)
treef603ced6489005ddecd67f8c17a560f78d451d29 /arch/arm/plat-omap/gpio.c
parenta2d3e7bad82dcfb67924849e2063238a1ae51b6e (diff)
OMAP3: PM: GPIO context save/restore
Add context save and restore to enable off-mode. Signed-off-by: Rajendra Nayak <rnayak@ti.com> Signed-off-by: Kevin Hilman <khilman@deeprootsystems.com>
Diffstat (limited to 'arch/arm/plat-omap/gpio.c')
-rw-r--r--arch/arm/plat-omap/gpio.c92
1 files changed, 92 insertions, 0 deletions
diff --git a/arch/arm/plat-omap/gpio.c b/arch/arm/plat-omap/gpio.c
index 35a59ce5a2b4..b71052c6581b 100644
--- a/arch/arm/plat-omap/gpio.c
+++ b/arch/arm/plat-omap/gpio.c
@@ -290,6 +290,23 @@ static struct gpio_bank gpio_bank_34xx[6] = {
290 METHOD_GPIO_24XX }, 290 METHOD_GPIO_24XX },
291}; 291};
292 292
293struct omap3_gpio_regs {
294 u32 sysconfig;
295 u32 irqenable1;
296 u32 irqenable2;
297 u32 wake_en;
298 u32 ctrl;
299 u32 oe;
300 u32 leveldetect0;
301 u32 leveldetect1;
302 u32 risingdetect;
303 u32 fallingdetect;
304 u32 dataout;
305 u32 setwkuena;
306 u32 setdataout;
307};
308
309static struct omap3_gpio_regs gpio_context[OMAP34XX_NR_GPIOS];
293#endif 310#endif
294 311
295#ifdef CONFIG_ARCH_OMAP4 312#ifdef CONFIG_ARCH_OMAP4
@@ -2036,6 +2053,81 @@ void omap2_gpio_resume_after_retention(void)
2036 2053
2037#endif 2054#endif
2038 2055
2056#ifdef CONFIG_ARCH_OMAP34XX
2057/* save the registers of bank 2-6 */
2058void omap_gpio_save_context(void)
2059{
2060 int i;
2061
2062 /* saving banks from 2-6 only since GPIO1 is in WKUP */
2063 for (i = 1; i < gpio_bank_count; i++) {
2064 struct gpio_bank *bank = &gpio_bank[i];
2065 gpio_context[i].sysconfig =
2066 __raw_readl(bank->base + OMAP24XX_GPIO_SYSCONFIG);
2067 gpio_context[i].irqenable1 =
2068 __raw_readl(bank->base + OMAP24XX_GPIO_IRQENABLE1);
2069 gpio_context[i].irqenable2 =
2070 __raw_readl(bank->base + OMAP24XX_GPIO_IRQENABLE2);
2071 gpio_context[i].wake_en =
2072 __raw_readl(bank->base + OMAP24XX_GPIO_WAKE_EN);
2073 gpio_context[i].ctrl =
2074 __raw_readl(bank->base + OMAP24XX_GPIO_CTRL);
2075 gpio_context[i].oe =
2076 __raw_readl(bank->base + OMAP24XX_GPIO_OE);
2077 gpio_context[i].leveldetect0 =
2078 __raw_readl(bank->base + OMAP24XX_GPIO_LEVELDETECT0);
2079 gpio_context[i].leveldetect1 =
2080 __raw_readl(bank->base + OMAP24XX_GPIO_LEVELDETECT1);
2081 gpio_context[i].risingdetect =
2082 __raw_readl(bank->base + OMAP24XX_GPIO_RISINGDETECT);
2083 gpio_context[i].fallingdetect =
2084 __raw_readl(bank->base + OMAP24XX_GPIO_FALLINGDETECT);
2085 gpio_context[i].dataout =
2086 __raw_readl(bank->base + OMAP24XX_GPIO_DATAOUT);
2087 gpio_context[i].setwkuena =
2088 __raw_readl(bank->base + OMAP24XX_GPIO_SETWKUENA);
2089 gpio_context[i].setdataout =
2090 __raw_readl(bank->base + OMAP24XX_GPIO_SETDATAOUT);
2091 }
2092}
2093
2094/* restore the required registers of bank 2-6 */
2095void omap_gpio_restore_context(void)
2096{
2097 int i;
2098
2099 for (i = 1; i < gpio_bank_count; i++) {
2100 struct gpio_bank *bank = &gpio_bank[i];
2101 __raw_writel(gpio_context[i].sysconfig,
2102 bank->base + OMAP24XX_GPIO_SYSCONFIG);
2103 __raw_writel(gpio_context[i].irqenable1,
2104 bank->base + OMAP24XX_GPIO_IRQENABLE1);
2105 __raw_writel(gpio_context[i].irqenable2,
2106 bank->base + OMAP24XX_GPIO_IRQENABLE2);
2107 __raw_writel(gpio_context[i].wake_en,
2108 bank->base + OMAP24XX_GPIO_WAKE_EN);
2109 __raw_writel(gpio_context[i].ctrl,
2110 bank->base + OMAP24XX_GPIO_CTRL);
2111 __raw_writel(gpio_context[i].oe,
2112 bank->base + OMAP24XX_GPIO_OE);
2113 __raw_writel(gpio_context[i].leveldetect0,
2114 bank->base + OMAP24XX_GPIO_LEVELDETECT0);
2115 __raw_writel(gpio_context[i].leveldetect1,
2116 bank->base + OMAP24XX_GPIO_LEVELDETECT1);
2117 __raw_writel(gpio_context[i].risingdetect,
2118 bank->base + OMAP24XX_GPIO_RISINGDETECT);
2119 __raw_writel(gpio_context[i].fallingdetect,
2120 bank->base + OMAP24XX_GPIO_FALLINGDETECT);
2121 __raw_writel(gpio_context[i].dataout,
2122 bank->base + OMAP24XX_GPIO_DATAOUT);
2123 __raw_writel(gpio_context[i].setwkuena,
2124 bank->base + OMAP24XX_GPIO_SETWKUENA);
2125 __raw_writel(gpio_context[i].setdataout,
2126 bank->base + OMAP24XX_GPIO_SETDATAOUT);
2127 }
2128}
2129#endif
2130
2039/* 2131/*
2040 * This may get called early from board specific init 2132 * This may get called early from board specific init
2041 * for boards that have interrupts routed via FPGA. 2133 * for boards that have interrupts routed via FPGA.