From 1a4ec221f28d60a1ed175e12b18c921548e3684d Mon Sep 17 00:00:00 2001 From: "prabhu.annabathula" Date: Fri, 18 Jun 2010 17:47:20 -0500 Subject: [PATCH] GPS: Add gpio controller driver for brcm 4750 driver provides ioctls for broadcom gps guci library to set gps reset and standby lines for brcm 4750 chip Signed-off-by: prabhu.annabathula --- drivers/misc/Kconfig | 6 ++ drivers/misc/Makefile | 1 + drivers/misc/gps-gpio-brcm4750.c | 121 ++++++++++++++++++++++++++++++ include/linux/gps-gpio-brcm4750.h | 39 ++++++++++ 4 files changed, 167 insertions(+) create mode 100755 drivers/misc/gps-gpio-brcm4750.c create mode 100755 include/linux/gps-gpio-brcm4750.h diff --git a/drivers/misc/Kconfig b/drivers/misc/Kconfig index 3b32cb25de93..6bde1ef65863 100644 --- a/drivers/misc/Kconfig +++ b/drivers/misc/Kconfig @@ -460,6 +460,12 @@ config APANIC_PLABEL If your platform uses a different flash partition label for storing crashdumps, enter it here. +config GPS_GPIO_BRCM4750 + bool "Enable gpio controller for GPS brcm 4750" + default y + ---help--- + Adds GPIO controller driver for GPS Broadcom 4750 chipset + source "drivers/misc/c2port/Kconfig" source "drivers/misc/eeprom/Kconfig" source "drivers/misc/cb710/Kconfig" diff --git a/drivers/misc/Makefile b/drivers/misc/Makefile index 7a9d82400508..5695c1b35ef4 100644 --- a/drivers/misc/Makefile +++ b/drivers/misc/Makefile @@ -44,3 +44,4 @@ obj-$(CONFIG_SENSORS_AK8975) += akm8975.o obj-$(CONFIG_SENSORS_KXTF9) += kxtf9.o obj-$(CONFIG_SENSORS_MAX9635) += max9635.o obj-$(CONFIG_SENSORS_L3G4200D) += l3g4200d.o +obj-$(CONFIG_GPS_GPIO_BRCM4750) += gps-gpio-brcm4750.o diff --git a/drivers/misc/gps-gpio-brcm4750.c b/drivers/misc/gps-gpio-brcm4750.c new file mode 100755 index 000000000000..0b53badf7a62 --- /dev/null +++ b/drivers/misc/gps-gpio-brcm4750.c @@ -0,0 +1,121 @@ +/* + * Copyright (C) 2010 Motorola, Inc. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + * 02111-1307, USA + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +struct gps_gpio_brcm4750_platform_data *gps_gpio_data; + +static int gps_brcm4750_ioctl(struct inode *inode, + struct file *filp, unsigned int cmd, unsigned long arg) +{ + unsigned int gpio_val; + + if (cmd <= 0) + return -EINVAL; + + if (copy_from_user((void *) &gpio_val, (void *) arg, + sizeof(int))) + return -EFAULT; + + if (!(gpio_val == 0 || gpio_val == 1)) + return -EINVAL; + + switch (cmd) { + case IOC_GPS_GPIO_RESET: + pr_info("%s: Setting gps gpio reset pin: %d\n", + __func__, gpio_val); + if (gps_gpio_data->set_reset_gpio) + gps_gpio_data->set_reset_gpio(gpio_val); + break; + case IOC_GPS_GPIO_STANDBY: + pr_info("%s: Setting gps gpio standby pin to: %d\n", + __func__, gpio_val); + if (gps_gpio_data->set_standby_gpio) + gps_gpio_data->set_standby_gpio(gpio_val); + break; + default: + pr_info("%s: Invalid GPS GPIO IOCTL command\n", __func__); + return -EINVAL; + } + + return 0; +} + +static const struct file_operations gps_brcm4750_fops = { + .owner = THIS_MODULE, + .ioctl = gps_brcm4750_ioctl, +}; + +static struct miscdevice gps_gpio_miscdev = { + .minor = MISC_DYNAMIC_MINOR, + .name = GPS_GPIO_DRIVER_NAME, + .fops = &gps_brcm4750_fops, +}; + +static int gps_gpio_brcm4750_probe(struct platform_device *pdev) +{ + gps_gpio_data = pdev->dev.platform_data; + if (misc_register(&gps_gpio_miscdev)) { + pr_info("%s: gps_brcm4750 misc_register failed\n", __func__); + return -1; + } + return 0; +} + +static int gps_gpio_brcm4750_remove(struct platform_device *pdev) +{ + if (gps_gpio_data->free_gpio) + gps_gpio_data->free_gpio(); + return 0; +} + +static struct platform_driver gps_gpio_brcm4750_driver = { + .probe = gps_gpio_brcm4750_probe, + .remove = gps_gpio_brcm4750_remove, + .driver = { + .name = GPS_GPIO_DRIVER_NAME, + .owner = THIS_MODULE, + }, +}; + +static int __init gps_gpio_brcm4750_init(void) +{ + return platform_driver_register(&gps_gpio_brcm4750_driver); +} + +static void __exit gps_gpio_brcm4750_exit(void) +{ + platform_driver_unregister(&gps_gpio_brcm4750_driver); +} + +module_init(gps_gpio_brcm4750_init); +module_exit(gps_gpio_brcm4750_exit); + +MODULE_AUTHOR("Motorola"); +MODULE_DESCRIPTION("GPS GPIO Controller for BRCM 4750"); +MODULE_LICENSE("GPL"); diff --git a/include/linux/gps-gpio-brcm4750.h b/include/linux/gps-gpio-brcm4750.h new file mode 100755 index 000000000000..d534ab7afe12 --- /dev/null +++ b/include/linux/gps-gpio-brcm4750.h @@ -0,0 +1,39 @@ +/* + * Copyright (C) 2010 Motorola, Inc. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + * 02111-1307, USA + */ + +#ifndef _GPS_GPIO_BRCM4750_H_ +#define _GPS_GPIO_BRCM4750_H_ + +#include + +#define GPS_GPIO_DRIVER_NAME "gps_brcm4750" + +#define GPS_GPIO_IOCTL_BASE 'w' + +#define IOC_GPS_GPIO_RESET _IOW(GPS_GPIO_IOCTL_BASE, 0x0, int) +#define IOC_GPS_GPIO_STANDBY _IOW(GPS_GPIO_IOCTL_BASE, 0x1, int) + +#ifdef __KERNEL__ +struct gps_gpio_brcm4750_platform_data { + void (*set_reset_gpio)(unsigned int gpio_val); + void (*set_standby_gpio)(unsigned int gpio_val); + void (*free_gpio)(void); +} __attribute__ ((packed)); + +#endif /* __KERNEL__ */ +#endif /* _GPS_GPIO_BRCM4750_H_ */ -- 2.34.1