]> err.no Git - linux-2.6/commitdiff
[AVR32] Introduce at32_reserve_pin()
authorHaavard Skinnemoen <hskinnemoen@atmel.com>
Tue, 30 Jan 2007 10:01:23 +0000 (11:01 +0100)
committerHaavard Skinnemoen <hskinnemoen@atmel.com>
Fri, 9 Feb 2007 14:01:58 +0000 (15:01 +0100)
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>
arch/avr32/mach-at32ap/pio.c
include/asm-avr32/arch-at32ap/portmux.h

index c3f596ce5267f082d5430a0254c449207766986c..9ba5654cde110dda279fe83498ab5a1c25d33144 100644 (file)
@@ -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();
+}
 
 /*--------------------------------------------------------------------------*/
 
index 2ba611e0e1348d61dabbcd2fbadefd69a1948f96..9930871decde1e61bbb522b9d9243759263f773c 100644 (file)
@@ -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__ */