f9cc88f4c5cba9f506a28f5a31872636890c20d3
[15.05/openwrt.git] / target / linux / brcm2708 / patches-3.18 / 0081-Added-support-to-reserve-enable-a-GPIO-pin-to-be-use.patch
1 From 47a2d8098a9523435aec2fff1389ae92fd8791a9 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 081/114] 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  1 file changed, 27 insertions(+)
11
12 diff --git a/arch/arm/mach-bcm2708/bcm2708.c b/arch/arm/mach-bcm2708/bcm2708.c
13 index b36037b..762e17c 100644
14 --- a/arch/arm/mach-bcm2708/bcm2708.c
15 +++ b/arch/arm/mach-bcm2708/bcm2708.c
16 @@ -37,6 +37,7 @@
17  #include <linux/spi/spi.h>
18  #include <linux/gpio/machine.h>
19  #include <linux/w1-gpio.h>
20 +#include <linux/pps-gpio.h>
21  
22  #include <linux/version.h>
23  #include <linux/clkdev.h>
24 @@ -93,6 +94,7 @@ static unsigned disk_led_active_low = 1;
25  static unsigned reboot_part = 0;
26  static unsigned w1_gpio_pin = W1_GPIO;
27  static unsigned w1_gpio_pullup = W1_PULLUP;
28 +static int pps_gpio_pin = -1;
29  static bool vc_i2c_override = false;
30  
31  static unsigned use_dt = 0;
32 @@ -274,6 +276,19 @@ static struct platform_device w1_device = {
33  };
34  #endif
35  
36 +static struct pps_gpio_platform_data pps_gpio_info = {
37 +       .assert_falling_edge = false,
38 +       .capture_clear = false,
39 +       .gpio_pin = -1,
40 +       .gpio_label = "PPS",
41 +};
42 +
43 +static struct platform_device pps_gpio_device = {
44 +       .name = "pps-gpio",
45 +       .id = PLATFORM_DEVID_NONE,
46 +       .dev.platform_data = &pps_gpio_info,
47 +};
48 +
49  static u64 fb_dmamask = DMA_BIT_MASK(DMA_MASK_BITS_COMMON);
50  
51  static struct platform_device bcm2708_fb_device = {
52 @@ -841,6 +856,16 @@ void __init bcm2708_init(void)
53  #ifdef CONFIG_BCM2708_GPIO
54         bcm_register_device_dt(&bcm2708_gpio_device);
55  #endif
56 +
57 +#if defined(CONFIG_PPS_CLIENT_GPIO) || defined(CONFIG_PPS_CLIENT_GPIO_MODULE)
58 +       if (!use_dt && (pps_gpio_pin >= 0)) {
59 +               pr_info("bcm2708: GPIO %d setup as pps-gpio device\n", pps_gpio_pin);
60 +               pps_gpio_info.gpio_pin = pps_gpio_pin;
61 +               pps_gpio_device.id = pps_gpio_pin;
62 +               bcm_register_device(&pps_gpio_device);
63 +       }
64 +#endif
65 +
66  #if defined(CONFIG_W1_MASTER_GPIO) || defined(CONFIG_W1_MASTER_GPIO_MODULE)
67         w1_gpio_pdata.pin = w1_gpio_pin;
68         w1_gpio_pdata.ext_pullup_enable_pin = w1_gpio_pullup;
69 @@ -1101,5 +1126,7 @@ module_param(disk_led_active_low, uint, 0644);
70  module_param(reboot_part, uint, 0644);
71  module_param(w1_gpio_pin, uint, 0644);
72  module_param(w1_gpio_pullup, uint, 0644);
73 +module_param(pps_gpio_pin, int, 0644);
74 +MODULE_PARM_DESC(pps_gpio_pin, "Set GPIO pin to reserve for PPS");
75  module_param(vc_i2c_override, bool, 0644);
76  MODULE_PARM_DESC(vc_i2c_override, "Allow the use of VC's I2C peripheral.");
77 -- 
78 1.8.3.2
79