Skip to content

Commit

Permalink
Blackfin: punt Blackfin-specific GPIO wakeup API
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
mhennerich authored and vapier committed May 21, 2010
1 parent 85eb0e4 commit bb84dbf
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 188 deletions.
26 changes: 0 additions & 26 deletions arch/blackfin/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
22 changes: 11 additions & 11 deletions arch/blackfin/include/asm/gpio.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
131 changes: 12 additions & 119 deletions arch/blackfin/kernel/bfin_gpio.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -514,137 +512,37 @@ 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;

for (i = 0; i < MAX_BLACKFIN_GPIOS; i += GPIO_BANKSIZE) {
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)
Expand Down Expand Up @@ -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;
Expand Down
9 changes: 1 addition & 8 deletions arch/blackfin/mach-common/ints-priority.c
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
24 changes: 0 additions & 24 deletions arch/blackfin/mach-common/pm.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,35 +20,11 @@
#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();

Expand Down

0 comments on commit bb84dbf

Please sign in to comment.