summaryrefslogtreecommitdiff
path: root/recipes-kernel/linux/linux-3.12.70/linux-3.12-at91-gpio-pullup.patch
blob: 583a20527773280ace4f1b28ae4356a602dad02f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
Index: linux-3.12.13/arch/arm/mach-at91/gpio.c
===================================================================
--- linux-3.12.13.orig/arch/arm/mach-at91/gpio.c	2014-02-22 15:32:50.000000000 -0600
+++ linux-3.12.13/arch/arm/mach-at91/gpio.c	2014-03-07 09:13:09.931501303 -0600
@@ -294,6 +294,25 @@
 }
 EXPORT_SYMBOL(at91_set_gpio_output);
 
+/*
+ * configure pin for output and enable/disable pullup
+ */
+int __init_or_module at91_set_gpio_output_with_pullup(unsigned pin, int value, int use_pullup)
+{
+	void __iomem	*pio = pin_to_controller(pin);
+	unsigned	mask = pin_to_mask(pin);
+
+	if (!pio)
+		return -EINVAL;
+
+	__raw_writel(mask, pio + PIO_IDR);
+	__raw_writel(mask, pio + (use_pullup ? PIO_PUER : PIO_PUDR));
+	__raw_writel(mask, pio + (value ? PIO_SODR : PIO_CODR));
+	__raw_writel(mask, pio + PIO_OER);
+	__raw_writel(mask, pio + PIO_PER);
+	return 0;
+}
+EXPORT_SYMBOL(at91_set_gpio_output_with_pullup);
 
 /*
  * enable/disable the glitch filter; mostly used with IRQ handling.
Index: linux-3.12.13/arch/arm/mach-at91/include/mach/gpio.h
===================================================================
--- linux-3.12.13.orig/arch/arm/mach-at91/include/mach/gpio.h	2014-02-22 15:32:50.000000000 -0600
+++ linux-3.12.13/arch/arm/mach-at91/include/mach/gpio.h	2014-03-07 09:13:39.331501866 -0600
@@ -195,6 +195,7 @@
 extern int __init_or_module at91_set_D_periph(unsigned pin, int use_pullup);
 extern int __init_or_module at91_set_gpio_input(unsigned pin, int use_pullup);
 extern int __init_or_module at91_set_gpio_output(unsigned pin, int value);
+extern int __init_or_module at91_set_gpio_output_with_pullup(unsigned pin, int value, int use_pullup);
 extern int __init_or_module at91_set_deglitch(unsigned pin, int is_on);
 extern int __init_or_module at91_set_debounce(unsigned pin, int is_on, int div);
 extern int __init_or_module at91_set_multi_drive(unsigned pin, int is_on);