diff options
author | Haavard Skinnemoen <hskinnemoen@atmel.com> | 2007-01-30 05:01:23 -0500 |
---|---|---|
committer | Haavard Skinnemoen <hskinnemoen@atmel.com> | 2007-02-09 09:01:58 -0500 |
commit | e7f70b8cc69b1bcc56ed8d70f8e3671ec3956374 (patch) | |
tree | 9985b269a4b5fa46bd605f85fd3cf50609b37d7a | |
parent | dde251033f3e54619317269a908ce40e6f3a8d04 (diff) |
[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>
-rw-r--r-- | arch/avr32/mach-at32ap/pio.c | 23 | ||||
-rw-r--r-- | include/asm-avr32/arch-at32ap/portmux.h | 1 |
2 files changed, 23 insertions, 1 deletions
diff --git a/arch/avr32/mach-at32ap/pio.c b/arch/avr32/mach-at32ap/pio.c index c3f596ce5267..9ba5654cde11 100644 --- a/arch/avr32/mach-at32ap/pio.c +++ b/arch/avr32/mach-at32ap/pio.c | |||
@@ -135,7 +135,28 @@ fail: | |||
135 | dump_stack(); | 135 | dump_stack(); |
136 | } | 136 | } |
137 | 137 | ||
138 | /*--------------------------------------------------------------------------*/ | 138 | /* Reserve a pin, preventing anyone else from changing its configuration. */ |
139 | void __init at32_reserve_pin(unsigned int pin) | ||
140 | { | ||
141 | struct pio_device *pio; | ||
142 | unsigned int pin_index = pin & 0x1f; | ||
143 | |||
144 | pio = gpio_to_pio(pin); | ||
145 | if (unlikely(!pio)) { | ||
146 | printk("pio: invalid pin %u\n", pin); | ||
147 | goto fail; | ||
148 | } | ||
149 | |||
150 | if (unlikely(test_and_set_bit(pin_index, &pio->pinmux_mask))) { | ||
151 | printk("%s: pin %u is busy\n", pio->name, pin_index); | ||
152 | goto fail; | ||
153 | } | ||
154 | |||
155 | return; | ||
156 | |||
157 | fail: | ||
158 | dump_stack(); | ||
159 | } | ||
139 | 160 | ||
140 | /*--------------------------------------------------------------------------*/ | 161 | /*--------------------------------------------------------------------------*/ |
141 | 162 | ||
diff --git a/include/asm-avr32/arch-at32ap/portmux.h b/include/asm-avr32/arch-at32ap/portmux.h index 2ba611e0e134..9930871decde 100644 --- a/include/asm-avr32/arch-at32ap/portmux.h +++ b/include/asm-avr32/arch-at32ap/portmux.h | |||
@@ -23,5 +23,6 @@ | |||
23 | void at32_select_periph(unsigned int pin, unsigned int periph, | 23 | void at32_select_periph(unsigned int pin, unsigned int periph, |
24 | unsigned long flags); | 24 | unsigned long flags); |
25 | void at32_select_gpio(unsigned int pin, unsigned long flags); | 25 | void at32_select_gpio(unsigned int pin, unsigned long flags); |
26 | void at32_reserve_pin(unsigned int pin); | ||
26 | 27 | ||
27 | #endif /* __ASM_ARCH_PORTMUX_H__ */ | 28 | #endif /* __ASM_ARCH_PORTMUX_H__ */ |