brcm2708: update 4.1 patches
[openwrt/openwrt.git] / target / linux / brcm2708 / patches-4.1 / 0051-Added-support-to-reserve-enable-a-GPIO-pin-to-be-use.patch
1 From 9ec46a1866cc3e5f1f672fbf5d8763d28f4eba61 Mon Sep 17 00:00:00 2001
2 From: Timo Kokkonen <tjko@iki.fi>
3 Date: Wed, 29 Oct 2014 23:30:30 -0700
4 Subject: [PATCH 051/171] Added support to reserve/enable a GPIO pin to be used
5 from pps-gpio module (LinuxPPS). Enable PPS modules in default config for
6 RPi.
7
8 ---
9 arch/arm/mach-bcm2708/bcm2708.c | 27 +++++++++++++++++++++++++++
10 arch/arm/mach-bcm2709/bcm2709.c | 27 +++++++++++++++++++++++++++
11 2 files changed, 54 insertions(+)
12
13 --- a/arch/arm/mach-bcm2708/bcm2708.c
14 +++ b/arch/arm/mach-bcm2708/bcm2708.c
15 @@ -37,6 +37,7 @@
16 #include <linux/spi/spi.h>
17 #include <linux/gpio/machine.h>
18 #include <linux/w1-gpio.h>
19 +#include <linux/pps-gpio.h>
20
21 #include <linux/version.h>
22 #include <linux/clkdev.h>
23 @@ -92,6 +93,7 @@ static unsigned reboot_part = 0;
24 static unsigned w1_gpio_pin = W1_GPIO;
25 static unsigned w1_gpio_pullup = W1_PULLUP;
26 static bool vc_i2c_override = false;
27 +static int pps_gpio_pin = -1;
28
29 static unsigned use_dt = 0;
30
31 @@ -325,6 +327,19 @@ static struct platform_device w1_device
32 };
33 #endif
34
35 +static struct pps_gpio_platform_data pps_gpio_info = {
36 + .assert_falling_edge = false,
37 + .capture_clear = false,
38 + .gpio_pin = -1,
39 + .gpio_label = "PPS",
40 +};
41 +
42 +static struct platform_device pps_gpio_device = {
43 + .name = "pps-gpio",
44 + .id = PLATFORM_DEVID_NONE,
45 + .dev.platform_data = &pps_gpio_info,
46 +};
47 +
48 static u64 fb_dmamask = DMA_BIT_MASK(DMA_MASK_BITS_COMMON);
49
50 static struct platform_device bcm2708_fb_device = {
51 @@ -860,6 +875,16 @@ void __init bcm2708_init(void)
52 #ifdef CONFIG_BCM2708_GPIO
53 bcm_register_device_dt(&bcm2708_gpio_device);
54 #endif
55 +
56 +#if defined(CONFIG_PPS_CLIENT_GPIO) || defined(CONFIG_PPS_CLIENT_GPIO_MODULE)
57 + if (!use_dt && (pps_gpio_pin >= 0)) {
58 + pr_info("bcm2708: GPIO %d setup as pps-gpio device\n", pps_gpio_pin);
59 + pps_gpio_info.gpio_pin = pps_gpio_pin;
60 + pps_gpio_device.id = pps_gpio_pin;
61 + bcm_register_device(&pps_gpio_device);
62 + }
63 +#endif
64 +
65 #if defined(CONFIG_W1_MASTER_GPIO) || defined(CONFIG_W1_MASTER_GPIO_MODULE)
66 w1_gpio_pdata.pin = w1_gpio_pin;
67 w1_gpio_pdata.ext_pullup_enable_pin = w1_gpio_pullup;
68 @@ -1116,3 +1141,5 @@ module_param(w1_gpio_pin, uint, 0644);
69 module_param(w1_gpio_pullup, uint, 0644);
70 module_param(vc_i2c_override, bool, 0644);
71 MODULE_PARM_DESC(vc_i2c_override, "Allow the use of VC's I2C peripheral.");
72 +module_param(pps_gpio_pin, int, 0644);
73 +MODULE_PARM_DESC(pps_gpio_pin, "Set GPIO pin to reserve for PPS");
74 --- a/arch/arm/mach-bcm2709/bcm2709.c
75 +++ b/arch/arm/mach-bcm2709/bcm2709.c
76 @@ -37,6 +37,7 @@
77 #include <linux/spi/spi.h>
78 #include <linux/gpio/machine.h>
79 #include <linux/w1-gpio.h>
80 +#include <linux/pps-gpio.h>
81
82 #include <linux/version.h>
83 #include <linux/clkdev.h>
84 @@ -94,6 +95,7 @@ static unsigned reboot_part = 0;
85 static unsigned w1_gpio_pin = W1_GPIO;
86 static unsigned w1_gpio_pullup = W1_PULLUP;
87 static bool vc_i2c_override = false;
88 +static int pps_gpio_pin = -1;
89
90 static unsigned use_dt = 0;
91
92 @@ -335,6 +337,19 @@ static struct platform_device w1_device
93 };
94 #endif
95
96 +static struct pps_gpio_platform_data pps_gpio_info = {
97 + .assert_falling_edge = false,
98 + .capture_clear = false,
99 + .gpio_pin = -1,
100 + .gpio_label = "PPS",
101 +};
102 +
103 +static struct platform_device pps_gpio_device = {
104 + .name = "pps-gpio",
105 + .id = PLATFORM_DEVID_NONE,
106 + .dev.platform_data = &pps_gpio_info,
107 +};
108 +
109 static u64 fb_dmamask = DMA_BIT_MASK(DMA_MASK_BITS_COMMON);
110
111 static struct platform_device bcm2708_fb_device = {
112 @@ -880,6 +895,16 @@ void __init bcm2709_init(void)
113 #ifdef CONFIG_BCM2708_GPIO
114 bcm_register_device_dt(&bcm2708_gpio_device);
115 #endif
116 +
117 +#if defined(CONFIG_PPS_CLIENT_GPIO) || defined(CONFIG_PPS_CLIENT_GPIO_MODULE)
118 + if (!use_dt && (pps_gpio_pin >= 0)) {
119 + pr_info("bcm2709: GPIO %d setup as pps-gpio device\n", pps_gpio_pin);
120 + pps_gpio_info.gpio_pin = pps_gpio_pin;
121 + pps_gpio_device.id = pps_gpio_pin;
122 + bcm_register_device(&pps_gpio_device);
123 + }
124 +#endif
125 +
126 #if defined(CONFIG_W1_MASTER_GPIO) || defined(CONFIG_W1_MASTER_GPIO_MODULE)
127 w1_gpio_pdata.pin = w1_gpio_pin;
128 w1_gpio_pdata.ext_pullup_enable_pin = w1_gpio_pullup;
129 @@ -1284,3 +1309,5 @@ module_param(w1_gpio_pin, uint, 0644);
130 module_param(w1_gpio_pullup, uint, 0644);
131 module_param(vc_i2c_override, bool, 0644);
132 MODULE_PARM_DESC(vc_i2c_override, "Allow the use of VC's I2C peripheral.");
133 +module_param(pps_gpio_pin, int, 0644);
134 +MODULE_PARM_DESC(pps_gpio_pin, "Set GPIO pin to reserve for PPS");