aboutsummaryrefslogtreecommitdiffstats
path: root/target/linux/brcm2708/patches-4.1/0051-Added-support-to-reserve-enable-a-GPIO-pin-to-be-use.patch
blob: b367e623828af4ac55cea46b6f0c8e8d235ecd10 (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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
From 4d818efc09ca08d42fabd91c10c75556b0ab9164 Mon Sep 17 00:00:00 2001
From: Timo Kokkonen <tjko@iki.fi>
Date: Wed, 29 Oct 2014 23:30:30 -0700
Subject: [PATCH 051/203] Added support to reserve/enable a GPIO pin to be used
 from pps-gpio module (LinuxPPS). Enable PPS modules in default config for
 RPi.

---
 arch/arm/mach-bcm2708/bcm2708.c | 27 +++++++++++++++++++++++++++
 arch/arm/mach-bcm2709/bcm2709.c | 27 +++++++++++++++++++++++++++
 2 files changed, 54 insertions(+)

--- a/arch/arm/mach-bcm2708/bcm2708.c
+++ b/arch/arm/mach-bcm2708/bcm2708.c
@@ -37,6 +37,7 @@
 #include <linux/spi/spi.h>
 #include <linux/gpio/machine.h>
 #include <linux/w1-gpio.h>
+#include <linux/pps-gpio.h>
 
 #include <linux/version.h>
 #include <linux/clkdev.h>
@@ -92,6 +93,7 @@ static unsigned reboot_part = 0;
 static unsigned w1_gpio_pin = W1_GPIO;
 static unsigned w1_gpio_pullup = W1_PULLUP;
 static bool vc_i2c_override = false;
+static int pps_gpio_pin = -1;
 
 static unsigned use_dt = 0;
 
@@ -325,6 +327,19 @@ static struct platform_device w1_device
 };
 #endif
 
+static struct pps_gpio_platform_data pps_gpio_info = {
+	.assert_falling_edge = false,
+	.capture_clear = false,
+	.gpio_pin = -1,
+	.gpio_label = "PPS",
+};
+
+static struct platform_device pps_gpio_device = {
+	.name = "pps-gpio",
+	.id = PLATFORM_DEVID_NONE,
+	.dev.platform_data = &pps_gpio_info,
+};
+
 static u64 fb_dmamask = DMA_BIT_MASK(DMA_MASK_BITS_COMMON);
 
 static struct platform_device bcm2708_fb_device = {
@@ -860,6 +875,16 @@ void __init bcm2708_init(void)
 #ifdef CONFIG_BCM2708_GPIO
 	bcm_register_device_dt(&bcm2708_gpio_device);
 #endif
+
+#if defined(CONFIG_PPS_CLIENT_GPIO) || defined(CONFIG_PPS_CLIENT_GPIO_MODULE)
+	if (!use_dt && (pps_gpio_pin >= 0)) {
+		pr_info("bcm2708: GPIO %d setup as pps-gpio device\n", pps_gpio_pin);
+		pps_gpio_info.gpio_pin = pps_gpio_pin;
+		pps_gpio_device.id = pps_gpio_pin;
+		bcm_register_device(&pps_gpio_device);
+	}
+#endif
+
 #if defined(CONFIG_W1_MASTER_GPIO) || defined(CONFIG_W1_MASTER_GPIO_MODULE)
 	w1_gpio_pdata.pin = w1_gpio_pin;
 	w1_gpio_pdata.ext_pullup_enable_pin = w1_gpio_pullup;
@@ -1116,3 +1141,5 @@ module_param(w1_gpio_pin, uint, 0644);
 module_param(w1_gpio_pullup, uint, 0644);
 module_param(vc_i2c_override, bool, 0644);
 MODULE_PARM_DESC(vc_i2c_override, "Allow the use of VC's I2C peripheral.");
+module_param(pps_gpio_pin, int, 0644);
+MODULE_PARM_DESC(pps_gpio_pin, "Set GPIO pin to reserve for PPS");
--- a/arch/arm/mach-bcm2709/bcm2709.c
+++ b/arch/arm/mach-bcm2709/bcm2709.c
@@ -37,6 +37,7 @@
 #include <linux/spi/spi.h>
 #include <linux/gpio/machine.h>
 #include <linux/w1-gpio.h>
+#include <linux/pps-gpio.h>
 
 #include <linux/version.h>
 #include <linux/clkdev.h>
@@ -94,6 +95,7 @@ static unsigned reboot_part = 0;
 static unsigned w1_gpio_pin = W1_GPIO;
 static unsigned w1_gpio_pullup = W1_PULLUP;
 static bool vc_i2c_override = false;
+static int pps_gpio_pin = -1;
 
 static unsigned use_dt = 0;
 
@@ -335,6 +337,19 @@ static struct platform_device w1_device
 };
 #endif
 
+static struct pps_gpio_platform_data pps_gpio_info = {
+	.assert_falling_edge = false,
+	.capture_clear = false,
+	.gpio_pin = -1,
+	.gpio_label = "PPS",
+};
+
+static struct platform_device pps_gpio_device = {
+	.name = "pps-gpio",
+	.id = PLATFORM_DEVID_NONE,
+	.dev.platform_data = &pps_gpio_info,
+};
+
 static u64 fb_dmamask = DMA_BIT_MASK(DMA_MASK_BITS_COMMON);
 
 static struct platform_device bcm2708_fb_device = {
@@ -880,6 +895,16 @@ void __init bcm2709_init(void)
 #ifdef CONFIG_BCM2708_GPIO
 	bcm_register_device_dt(&bcm2708_gpio_device);
 #endif
+
+#if defined(CONFIG_PPS_CLIENT_GPIO) || defined(CONFIG_PPS_CLIENT_GPIO_MODULE)
+	if (!use_dt && (pps_gpio_pin >= 0)) {
+		pr_info("bcm2709: GPIO %d setup as pps-gpio device\n", pps_gpio_pin);
+		pps_gpio_info.gpio_pin = pps_gpio_pin;
+		pps_gpio_device.id = pps_gpio_pin;
+		bcm_register_device(&pps_gpio_device);
+	}
+#endif
+
 #if defined(CONFIG_W1_MASTER_GPIO) || defined(CONFIG_W1_MASTER_GPIO_MODULE)
 	w1_gpio_pdata.pin = w1_gpio_pin;
 	w1_gpio_pdata.ext_pullup_enable_pin = w1_gpio_pullup;
@@ -1284,3 +1309,5 @@ module_param(w1_gpio_pin, uint, 0644);
 module_param(w1_gpio_pullup, uint, 0644);
 module_param(vc_i2c_override, bool, 0644);
 MODULE_PARM_DESC(vc_i2c_override, "Allow the use of VC's I2C peripheral.");
+module_param(pps_gpio_pin, int, 0644);
+MODULE_PARM_DESC(pps_gpio_pin, "Set GPIO pin to reserve for PPS");