Skip to content

Commit

Permalink
Blackfin arch: reset POLAR setting when acquiring a gpio for the firs…
Browse files Browse the repository at this point in the history
…t time

when requesting a GPIO for the first time, the POLAR setting is not
set to a sane state.  this can lead to indeterminate behavior that
cannot be resolved without an explicit write to the Blackfin port POLAR
register.

when requesting a GPIO for the first time via gpio_request(), the POLAR
setting for the GPIO in question should be set to sane state.  this
should occur if the GPIO has not been allocated in any other way.

some examples:
 - when doing something like "request_irq(); gpio_request();" on the
   same GPIO, the POLAR setting should not be reset.
 - when doing "gpio_request(); gpio_request();" on the same GPIO, the
   POLAR setting should be reset only the first time and not the second.

Signed-off-by: Michael Hennerich <michael.hennerich@analog.com>
Signed-off-by: Bryan Wu <cooloney@kernel.org>
  • Loading branch information
Michael Hennerich authored and Bryan Wu committed Feb 4, 2009
1 parent 5e7bb13 commit a2be393
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion arch/blackfin/kernel/bfin_gpio.c
Original file line number Diff line number Diff line change
Expand Up @@ -1053,9 +1053,15 @@ int bfin_gpio_request(unsigned gpio, const char *label)
local_irq_restore_hw(flags);
return -EBUSY;
}
if (unlikely(reserved_gpio_irq_map[gpio_bank(gpio)] & gpio_bit(gpio)))
if (unlikely(reserved_gpio_irq_map[gpio_bank(gpio)] & gpio_bit(gpio))) {
printk(KERN_NOTICE "bfin-gpio: GPIO %d is already reserved as gpio-irq!"
" (Documentation/blackfin/bfin-gpio-notes.txt)\n", gpio);
}
#ifndef BF548_FAMILY
else { /* Reset POLAR setting when acquiring a gpio for the first time */
set_gpio_polar(gpio, 0);
}
#endif

reserved_gpio_map[gpio_bank(gpio)] |= gpio_bit(gpio);
set_label(gpio, label);
Expand Down

0 comments on commit a2be393

Please sign in to comment.