summaryrefslogtreecommitdiff
path: root/arch/avr32
diff options
context:
space:
mode:
authorHaavard Skinnemoen <hskinnemoen@atmel.com>2007-01-30 11:01:23 +0100
committerHaavard Skinnemoen <hskinnemoen@atmel.com>2007-02-09 15:01:58 +0100
commite7f70b8cc69b1bcc56ed8d70f8e3671ec3956374 (patch)
tree9985b269a4b5fa46bd605f85fd3cf50609b37d7a /arch/avr32
parentdde251033f3e54619317269a908ce40e6f3a8d04 (diff)
downloadlinux-3.10-e7f70b8cc69b1bcc56ed8d70f8e3671ec3956374.tar.gz
linux-3.10-e7f70b8cc69b1bcc56ed8d70f8e3671ec3956374.tar.bz2
linux-3.10-e7f70b8cc69b1bcc56ed8d70f8e3671ec3956374.zip
[AVR32] Introduce at32_reserve_pin()
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>
Diffstat (limited to 'arch/avr32')
-rw-r--r--arch/avr32/mach-at32ap/pio.c23
1 files changed, 22 insertions, 1 deletions
diff --git a/arch/avr32/mach-at32ap/pio.c b/arch/avr32/mach-at32ap/pio.c
index c3f596ce526..9ba5654cde1 100644
--- a/arch/avr32/mach-at32ap/pio.c
+++ b/arch/avr32/mach-at32ap/pio.c
@@ -135,7 +135,28 @@ fail:
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();
+}
/*--------------------------------------------------------------------------*/