temp revert rk change
[firefly-linux-kernel-4.4.55.git] / arch / arm / mach-tegra / board-stingray-gps.c
1 /*
2  * Copyright (C) 2010 Motorola, Inc.
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License version 2 as
6  * published by the Free Software Foundation.
7  *
8  * This program is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11  * GNU General Public License for more details.
12  *
13  * You should have received a copy of the GNU General Public License
14  * along with this program; if not, write to the Free Software
15  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
16  * 02111-1307, USA
17  */
18
19 #include <linux/gpio.h>
20 #include <linux/gps-gpio-brcm4750.h>
21 #include <linux/kernel.h>
22 #include <linux/platform_device.h>
23 #include "board-stingray.h"
24 #include "gpio-names.h"
25
26 #define STINGRAY_GPS_RESET      TEGRA_GPIO_PH0
27 #define STINGRAY_GPS_STANDBY  TEGRA_GPIO_PH1
28 #define STINGRAY_GPS_UART_CTS  TEGRA_GPIO_PY6
29
30 static void stingray_gps_reset_gpio(unsigned int gpio_val)
31 {
32         pr_info("%s: setting GPS Reset GPIO to %d\n", __func__, gpio_val);
33         gpio_set_value(STINGRAY_GPS_RESET, gpio_val);
34 }
35
36 static void stingray_gps_standby_gpio(unsigned int gpio_val)
37 {
38         pr_info("%s: setting GPS standby GPIO to %d\n", __func__, gpio_val);
39         gpio_set_value(STINGRAY_GPS_STANDBY, gpio_val);
40 }
41
42 static void stingray_gps_gpio_release(void)
43 {
44         gpio_free(STINGRAY_GPS_RESET);
45         gpio_free(STINGRAY_GPS_STANDBY);
46 }
47
48 static void stingray_gps_gpio_init(void)
49 {
50         tegra_gpio_enable(STINGRAY_GPS_RESET);
51         gpio_request(STINGRAY_GPS_RESET, "gps_rst");
52         gpio_direction_output(STINGRAY_GPS_RESET, 0);
53
54         tegra_gpio_enable(STINGRAY_GPS_STANDBY);
55         gpio_request(STINGRAY_GPS_STANDBY, "gps_stdby");
56         gpio_direction_output(STINGRAY_GPS_STANDBY, 0);
57
58         if (stingray_revision() < STINGRAY_REVISION_P3) {
59                 tegra_gpio_enable(STINGRAY_GPS_UART_CTS);
60                 gpio_request(STINGRAY_GPS_UART_CTS, "uarte_cts");
61                 gpio_direction_output(STINGRAY_GPS_UART_CTS, 0);
62                 gpio_set_value(STINGRAY_GPS_UART_CTS, 0);
63         }
64 }
65
66 struct gps_gpio_brcm4750_platform_data stingray_gps_gpio_data = {
67         .set_reset_gpio = stingray_gps_reset_gpio,
68         .set_standby_gpio = stingray_gps_standby_gpio,
69         .free_gpio = stingray_gps_gpio_release,
70 };
71
72 static struct platform_device stingray_gps_device = {
73         .name   = GPS_GPIO_DRIVER_NAME,
74         .id             = -1,
75         .dev    = {
76         .platform_data = &stingray_gps_gpio_data,
77         },
78 };
79
80 void __init stingray_gps_init(void)
81 {
82         stingray_gps_gpio_init();
83         platform_device_register(&stingray_gps_device);
84 }