Skip to content

Commit

Permalink
[AVR32] Introduce at32_reserve_pin()
Browse files Browse the repository at this point in the history
at32_reserve_pin() can be used for reserving portmux pins without
altering their configuration. Useful for e.g. SDRAM pins where we
really don't want to change the bootloader-provided configuration.

Signed-off-by: Haavard Skinnemoen <hskinnemoen@atmel.com>
  • Loading branch information
Haavard Skinnemoen committed Feb 9, 2007
1 parent dde2510 commit e7f70b8
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
23 changes: 22 additions & 1 deletion arch/avr32/mach-at32ap/pio.c
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,28 @@ void __init at32_select_gpio(unsigned int pin, unsigned long flags)
dump_stack();
}

/*--------------------------------------------------------------------------*/
/* Reserve a pin, preventing anyone else from changing its configuration. */
void __init at32_reserve_pin(unsigned int pin)
{
struct pio_device *pio;
unsigned int pin_index = pin & 0x1f;

pio = gpio_to_pio(pin);
if (unlikely(!pio)) {
printk("pio: invalid pin %u\n", pin);
goto fail;
}

if (unlikely(test_and_set_bit(pin_index, &pio->pinmux_mask))) {
printk("%s: pin %u is busy\n", pio->name, pin_index);
goto fail;
}

return;

fail:
dump_stack();
}

/*--------------------------------------------------------------------------*/

Expand Down
1 change: 1 addition & 0 deletions include/asm-avr32/arch-at32ap/portmux.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,6 @@
void at32_select_periph(unsigned int pin, unsigned int periph,
unsigned long flags);
void at32_select_gpio(unsigned int pin, unsigned long flags);
void at32_reserve_pin(unsigned int pin);

#endif /* __ASM_ARCH_PORTMUX_H__ */

0 comments on commit e7f70b8

Please sign in to comment.