Blackfin: punt Blackfin-specific GPIO wakeup API
authorMichael Hennerich <michael.hennerich@analog.com>
Wed, 10 Mar 2010 14:26:06 +0000 (14:26 +0000)
committerMike Frysinger <vapier@gentoo.org>
Fri, 21 May 2010 13:40:16 +0000 (09:40 -0400)
This patch removes a custom GPIO wakeup API which allowed GPIOs to act
as wakeup sources, which are not configured as Interrupts.
This API is a leftover from the time before irq_wake was established.
From now on people must use enable_irq_wake(GPIO_IRQx) and the GPIO in
question needs to be configured as Interrupt.

Signed-off-by: Michael Hennerich <michael.hennerich@analog.com>
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
arch/blackfin/Kconfig
arch/blackfin/include/asm/gpio.h
arch/blackfin/kernel/bfin_gpio.c
arch/blackfin/mach-common/ints-priority.c
arch/blackfin/mach-common/pm.c

index c078849df7f9712349e0e5c1f721d977953f8e3f..405bdaa173332d874f8f2847822b94ba4c3a31a8 100644 (file)
@@ -1187,32 +1187,6 @@ config  PM_BFIN_SLEEP
          If unsure, select "Sleep Deeper".
 endchoice
 
-config PM_WAKEUP_BY_GPIO
-       bool "Allow Wakeup from Standby by GPIO"
-       depends on PM && !BF54x
-
-config PM_WAKEUP_GPIO_NUMBER
-       int "GPIO number"
-       range 0 47
-       depends on PM_WAKEUP_BY_GPIO
-       default 2
-
-choice
-       prompt "GPIO Polarity"
-       depends on PM_WAKEUP_BY_GPIO
-       default PM_WAKEUP_GPIO_POLAR_H
-config  PM_WAKEUP_GPIO_POLAR_H
-       bool "Active High"
-config  PM_WAKEUP_GPIO_POLAR_L
-       bool "Active Low"
-config  PM_WAKEUP_GPIO_POLAR_EDGE_F
-       bool "Falling EDGE"
-config  PM_WAKEUP_GPIO_POLAR_EDGE_R
-       bool "Rising EDGE"
-config  PM_WAKEUP_GPIO_POLAR_EDGE_B
-       bool "Both EDGE"
-endchoice
-
 comment "Possible Suspend Mem / Hibernate Wake-Up Sources"
        depends on PM
 
index 91bd2d7b9d5541fdb56271e94f1d9dcd68054be8..01b19d0cf50974be13f804e6175f9f814d1e136b 100644 (file)
@@ -167,23 +167,23 @@ int bfin_special_gpio_request(unsigned gpio, const char *label);
 #endif
 
 #ifdef CONFIG_PM
+int bfin_pm_standby_ctrl(unsigned ctrl);
 
-unsigned int bfin_pm_standby_setup(void);
-void bfin_pm_standby_restore(void);
+static inline int bfin_pm_standby_setup(void)
+{
+       return bfin_pm_standby_ctrl(1);
+}
+
+static inline void bfin_pm_standby_restore(void)
+{
+       bfin_pm_standby_ctrl(0);
+}
 
 void bfin_gpio_pm_hibernate_restore(void);
 void bfin_gpio_pm_hibernate_suspend(void);
 
 #ifndef CONFIG_BF54x
-#define PM_WAKE_RISING 0x1
-#define PM_WAKE_FALLING        0x2
-#define PM_WAKE_HIGH   0x4
-#define PM_WAKE_LOW    0x8
-#define PM_WAKE_BOTH_EDGES     (PM_WAKE_RISING | PM_WAKE_FALLING)
-#define PM_WAKE_IGNORE 0xF0
-
-int gpio_pm_wakeup_request(unsigned gpio, unsigned char type);
-void gpio_pm_wakeup_free(unsigned gpio);
+int gpio_pm_wakeup_ctrl(unsigned gpio, unsigned ctrl);
 
 struct gpio_port_s {
        unsigned short data;
index e35e20f00d9b3c864ec2a568afc86947f2a5681d..42833ee2b308ba546b323823a6bc2d37e94481ba 100644 (file)
@@ -475,9 +475,7 @@ GET_GPIO_P(maskb)
 
 
 #ifdef CONFIG_PM
-
 static unsigned short wakeup_map[GPIO_BANK_NUM];
-static unsigned char wakeup_flags_map[MAX_BLACKFIN_GPIOS];
 
 static const unsigned int sic_iwr_irqs[] = {
 #if defined(BF533_FAMILY)
@@ -514,112 +512,26 @@ static const unsigned int sic_iwr_irqs[] = {
 *************************************************************
 * MODIFICATION HISTORY :
 **************************************************************/
-int gpio_pm_wakeup_request(unsigned gpio, unsigned char type)
-{
-       unsigned long flags;
-
-       if ((check_gpio(gpio) < 0) || !type)
-               return -EINVAL;
-
-       local_irq_save_hw(flags);
-       wakeup_map[gpio_bank(gpio)] |= gpio_bit(gpio);
-       wakeup_flags_map[gpio] = type;
-       local_irq_restore_hw(flags);
-
-       return 0;
-}
-EXPORT_SYMBOL(gpio_pm_wakeup_request);
-
-void gpio_pm_wakeup_free(unsigned gpio)
+int gpio_pm_wakeup_ctrl(unsigned gpio, unsigned ctrl)
 {
        unsigned long flags;
 
        if (check_gpio(gpio) < 0)
-               return;
+               return -EINVAL;
 
        local_irq_save_hw(flags);
-
-       wakeup_map[gpio_bank(gpio)] &= ~gpio_bit(gpio);
-
-       local_irq_restore_hw(flags);
-}
-EXPORT_SYMBOL(gpio_pm_wakeup_free);
-
-static int bfin_gpio_wakeup_type(unsigned gpio, unsigned char type)
-{
-       port_setup(gpio, GPIO_USAGE);
-       set_gpio_dir(gpio, 0);
-       set_gpio_inen(gpio, 1);
-
-       if (type & (PM_WAKE_RISING | PM_WAKE_FALLING))
-               set_gpio_edge(gpio, 1);
-        else
-               set_gpio_edge(gpio, 0);
-
-       if ((type & (PM_WAKE_BOTH_EDGES)) == (PM_WAKE_BOTH_EDGES))
-               set_gpio_both(gpio, 1);
+       if (ctrl)
+               wakeup_map[gpio_bank(gpio)] |= gpio_bit(gpio);
        else
-               set_gpio_both(gpio, 0);
-
-       if ((type & (PM_WAKE_FALLING | PM_WAKE_LOW)))
-               set_gpio_polar(gpio, 1);
-       else
-               set_gpio_polar(gpio, 0);
+               wakeup_map[gpio_bank(gpio)] &= ~gpio_bit(gpio);
 
-       SSYNC();
-
-       return 0;
-}
-
-u32 bfin_pm_standby_setup(void)
-{
-       u16 bank, mask, i, gpio;
-
-       for (i = 0; i < MAX_BLACKFIN_GPIOS; i += GPIO_BANKSIZE) {
-               mask = wakeup_map[gpio_bank(i)];
-               bank = gpio_bank(i);
-
-               gpio_bank_saved[bank].maskb = gpio_array[bank]->maskb;
-               gpio_array[bank]->maskb = 0;
-
-               if (mask) {
-#if defined(CONFIG_BF52x) || defined(BF537_FAMILY) || defined(CONFIG_BF51x)
-                       gpio_bank_saved[bank].fer   = *port_fer[bank];
-#endif
-                       gpio_bank_saved[bank].inen  = gpio_array[bank]->inen;
-                       gpio_bank_saved[bank].polar = gpio_array[bank]->polar;
-                       gpio_bank_saved[bank].dir   = gpio_array[bank]->dir;
-                       gpio_bank_saved[bank].edge  = gpio_array[bank]->edge;
-                       gpio_bank_saved[bank].both  = gpio_array[bank]->both;
-                       gpio_bank_saved[bank].reserved =
-                                               reserved_gpio_map[bank];
-
-                       gpio = i;
-
-                       while (mask) {
-                               if ((mask & 1) && (wakeup_flags_map[gpio] !=
-                                       PM_WAKE_IGNORE)) {
-                                       reserved_gpio_map[gpio_bank(gpio)] |=
-                                                       gpio_bit(gpio);
-                                       bfin_gpio_wakeup_type(gpio,
-                                               wakeup_flags_map[gpio]);
-                                       set_gpio_data(gpio, 0); /*Clear*/
-                               }
-                               gpio++;
-                               mask >>= 1;
-                       }
-
-                       bfin_internal_set_wake(sic_iwr_irqs[bank], 1);
-                       gpio_array[bank]->maskb_set = wakeup_map[gpio_bank(i)];
-               }
-       }
-
-       AWA_DUMMY_READ(maskb_set);
+       set_gpio_maskb(gpio, ctrl);
+       local_irq_restore_hw(flags);
 
        return 0;
 }
 
-void bfin_pm_standby_restore(void)
+int bfin_pm_standby_ctrl(unsigned ctrl)
 {
        u16 bank, mask, i;
 
@@ -627,24 +539,10 @@ void bfin_pm_standby_restore(void)
                mask = wakeup_map[gpio_bank(i)];
                bank = gpio_bank(i);
 
-               if (mask) {
-#if defined(CONFIG_BF52x) || defined(BF537_FAMILY) || defined(CONFIG_BF51x)
-                       *port_fer[bank]         = gpio_bank_saved[bank].fer;
-#endif
-                       gpio_array[bank]->inen  = gpio_bank_saved[bank].inen;
-                       gpio_array[bank]->dir   = gpio_bank_saved[bank].dir;
-                       gpio_array[bank]->polar = gpio_bank_saved[bank].polar;
-                       gpio_array[bank]->edge  = gpio_bank_saved[bank].edge;
-                       gpio_array[bank]->both  = gpio_bank_saved[bank].both;
-
-                       reserved_gpio_map[bank] =
-                                       gpio_bank_saved[bank].reserved;
-                       bfin_internal_set_wake(sic_iwr_irqs[bank], 0);
-               }
-
-               gpio_array[bank]->maskb = gpio_bank_saved[bank].maskb;
+               if (mask)
+                       bfin_internal_set_wake(sic_iwr_irqs[bank], ctrl);
        }
-       AWA_DUMMY_READ(maskb);
+       return 0;
 }
 
 void bfin_gpio_pm_hibernate_suspend(void)
@@ -708,16 +606,11 @@ void bfin_gpio_pm_hibernate_restore(void)
 #else /* CONFIG_BF54x */
 #ifdef CONFIG_PM
 
-u32 bfin_pm_standby_setup(void)
+int bfin_pm_standby_ctrl(unsigned ctrl)
 {
        return 0;
 }
 
-void bfin_pm_standby_restore(void)
-{
-
-}
-
 void bfin_gpio_pm_hibernate_suspend(void)
 {
        int i, bank;
index 7ad8878bfa1815110a53220a1d96ab2c53df0476..ce988713445d3019a4d6d7bed745bf5082c31b40 100644 (file)
@@ -662,14 +662,7 @@ static int bfin_gpio_irq_type(unsigned int irq, unsigned int type)
 #ifdef CONFIG_PM
 int bfin_gpio_set_wake(unsigned int irq, unsigned int state)
 {
-       unsigned gpio = irq_to_gpio(irq);
-
-       if (state)
-               gpio_pm_wakeup_request(gpio, PM_WAKE_IGNORE);
-       else
-               gpio_pm_wakeup_free(gpio);
-
-       return 0;
+       return gpio_pm_wakeup_ctrl(irq_to_gpio(irq), state);
 }
 #endif
 
index c1f1ccc846f067ade4556eb3c2e98db523a27a50..ea7f95f6bb4c92b4cd779a3c158bce85c9694361 100644 (file)
 #include <asm/dma.h>
 #include <asm/dpmc.h>
 
-#ifdef CONFIG_PM_WAKEUP_GPIO_POLAR_H
-#define WAKEUP_TYPE    PM_WAKE_HIGH
-#endif
-
-#ifdef CONFIG_PM_WAKEUP_GPIO_POLAR_L
-#define WAKEUP_TYPE    PM_WAKE_LOW
-#endif
-
-#ifdef CONFIG_PM_WAKEUP_GPIO_POLAR_EDGE_F
-#define WAKEUP_TYPE    PM_WAKE_FALLING
-#endif
-
-#ifdef CONFIG_PM_WAKEUP_GPIO_POLAR_EDGE_R
-#define WAKEUP_TYPE    PM_WAKE_RISING
-#endif
-
-#ifdef CONFIG_PM_WAKEUP_GPIO_POLAR_EDGE_B
-#define WAKEUP_TYPE    PM_WAKE_BOTH_EDGES
-#endif
-
 
 void bfin_pm_suspend_standby_enter(void)
 {
        unsigned long flags;
 
-#ifdef CONFIG_PM_WAKEUP_BY_GPIO
-       gpio_pm_wakeup_request(CONFIG_PM_WAKEUP_GPIO_NUMBER, WAKEUP_TYPE);
-#endif
-
        local_irq_save_hw(flags);
        bfin_pm_standby_setup();