2b12829eacd52d5b416a4489a58f119c0e15797d
[openwrt/staging/dedeckeh.git] / target / linux / brcm2708 / patches-3.18 / 0097-bcm2709-Port-pps-gpio-and-i2c-patches.patch
1 From aca6741a1d26736f6000d18b3c60a18a313be6ea Mon Sep 17 00:00:00 2001
2 From: Phil Elwell <phil@raspberrypi.org>
3 Date: Mon, 26 Jan 2015 17:40:22 +0000
4 Subject: [PATCH 097/114] bcm2709: Port pps-gpio and i2c patches
5
6 ---
7 arch/arm/mach-bcm2709/bcm2709.c | 41 +++++++++++++++++++++++++++++++++++++++--
8 1 file changed, 39 insertions(+), 2 deletions(-)
9
10 diff --git a/arch/arm/mach-bcm2709/bcm2709.c b/arch/arm/mach-bcm2709/bcm2709.c
11 index 5d73b73..f009aeb 100644
12 --- a/arch/arm/mach-bcm2709/bcm2709.c
13 +++ b/arch/arm/mach-bcm2709/bcm2709.c
14 @@ -37,6 +37,7 @@
15 #include <linux/spi/spi.h>
16 #include <linux/gpio/machine.h>
17 #include <linux/w1-gpio.h>
18 +#include <linux/pps-gpio.h>
19
20 #include <linux/version.h>
21 #include <linux/clkdev.h>
22 @@ -95,6 +96,8 @@ static unsigned disk_led_active_low = 1;
23 static unsigned reboot_part = 0;
24 static unsigned w1_gpio_pin = W1_GPIO;
25 static unsigned w1_gpio_pullup = W1_PULLUP;
26 +static int pps_gpio_pin = -1;
27 +static bool vc_i2c_override = false;
28
29 static unsigned use_dt = 0;
30
31 @@ -283,6 +286,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 +876,16 @@ void __init bcm2709_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("bcm2709: 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 @@ -884,8 +910,15 @@ void __init bcm2709_init(void)
69 bcm_register_device(&bcm2835_thermal_device);
70
71 bcm_register_device_dt(&bcm2708_spi_device);
72 - bcm_register_device_dt(&bcm2708_bsc0_device);
73 - bcm_register_device_dt(&bcm2708_bsc1_device);
74 +
75 + if (vc_i2c_override) {
76 + bcm_register_device_dt(&bcm2708_bsc0_device);
77 + bcm_register_device_dt(&bcm2708_bsc1_device);
78 + } else if ((boardrev & 0xffffff) == 0x2 || (boardrev & 0xffffff) == 0x3) {
79 + bcm_register_device_dt(&bcm2708_bsc0_device);
80 + } else {
81 + bcm_register_device_dt(&bcm2708_bsc1_device);
82 + }
83
84 #if defined(CONFIG_SND_BCM2708_SOC_I2S) || defined(CONFIG_SND_BCM2708_SOC_I2S_MODULE)
85 bcm_register_device_dt(&bcm2708_i2s_device);
86 @@ -1245,3 +1278,7 @@ module_param(disk_led_active_low, uint, 0644);
87 module_param(reboot_part, uint, 0644);
88 module_param(w1_gpio_pin, uint, 0644);
89 module_param(w1_gpio_pullup, uint, 0644);
90 +module_param(pps_gpio_pin, int, 0644);
91 +MODULE_PARM_DESC(pps_gpio_pin, "Set GPIO pin to reserve for PPS");
92 +module_param(vc_i2c_override, bool, 0644);
93 +MODULE_PARM_DESC(vc_i2c_override, "Allow the use of VC's I2C peripheral.");
94 --
95 1.8.3.2
96