From: hxy Date: Fri, 25 Feb 2011 07:41:43 +0000 (+0800) Subject: add gps gns7560 to phone sdk X-Git-Tag: firefly_0821_release~10751 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=8245d5ad7d51e39e74f16070973be44cd55c348f;p=firefly-linux-kernel-4.4.55.git add gps gns7560 to phone sdk --- diff --git a/arch/arm/mach-rk29/board-rk29-phonesdk.c b/arch/arm/mach-rk29/board-rk29-phonesdk.c index cab099ae14c5..c1a6e597f519 100755 --- a/arch/arm/mach-rk29/board-rk29-phonesdk.c +++ b/arch/arm/mach-rk29/board-rk29-phonesdk.c @@ -52,6 +52,7 @@ #include "devices.h" #include "../../../drivers/input/touchscreen/xpt2046_cbn_ts.h" +#include "../../../drivers/misc/gps/rk29_gps.h" /* Set memory size of pmem */ @@ -403,6 +404,55 @@ static struct mma8452_platform_data mma8452_info = { #endif +#if defined(CONFIG_RK29_GPS) + +#define RK29_GPS_POWER_PIN RK29_PIN6_PB2 +#define RK29_GPS_RESET_PIN RK29_PIN6_PC1 + +static int gps_open =0; + +int rk29_gps_power_up(void) +{ + gps_open = 1; + printk("%s \n", __FUNCTION__); + gpio_request(RK29_GPS_POWER_PIN, NULL); + gpio_direction_output(RK29_GPS_POWER_PIN, GPIO_HIGH); + gpio_request(RK29_GPS_RESET_PIN, NULL); + gpio_direction_output(RK29_GPS_RESET_PIN, GPIO_LOW); + rk29_mux_api_set(GPIO2B3_UART3SOUT_NAME, GPIO2L_UART3_SOUT); + rk29_mux_api_set(GPIO2B2_UART3SIN_NAME, GPIO2L_UART3_SIN); + mdelay(100); + gpio_direction_output(RK29_GPS_RESET_PIN, GPIO_HIGH); + return 0; +} + +int rk29_gps_power_down(void) +{ + gps_open =0; + printk("%s \n", __FUNCTION__); + gpio_direction_output(RK29_GPS_POWER_PIN, GPIO_LOW); + mdelay(100); + gpio_direction_output(RK29_GPS_RESET_PIN, GPIO_LOW); //uart1 + return 0; +} + + +struct rk29_gps_data rk29_gps_info = { + .power_up = rk29_gps_power_up, + .power_down = rk29_gps_power_down, + .uart_id = 3, + .powerpin = RK29_GPS_POWER_PIN, + .powerflag = 1, + }; + +struct platform_device rk29_device_gps = { + .name = "rk29_gps", + .id = -1, + .dev = { + .platform_data = &rk29_gps_info, + } + }; +#endif /***************************************************************************************** * i2c devices diff --git a/drivers/misc/Kconfig b/drivers/misc/Kconfig index 1f67cb9b0b82..b68f4b249d0a 100644 --- a/drivers/misc/Kconfig +++ b/drivers/misc/Kconfig @@ -292,5 +292,6 @@ source "drivers/misc/c2port/Kconfig" source "drivers/misc/eeprom/Kconfig" source "drivers/misc/cb710/Kconfig" source "drivers/misc/rk29_modem/Kconfig" +source "drivers/misc/gps/Kconfig" endif # MISC_DEVICES diff --git a/drivers/misc/gps/Kconfig b/drivers/misc/gps/Kconfig new file mode 100644 index 000000000000..ae012dbcaefd --- /dev/null +++ b/drivers/misc/gps/Kconfig @@ -0,0 +1,19 @@ +# +# gps device configuration +# + +menuconfig RK29_GPS + bool "RK29 support GPS" + default n + ---help--- + Say Y here if you have a support modem + +if RK29_GPS + +config GPS_GNS7560 + bool "gns7560 support" + default n + +endif # RK29_GPS + + diff --git a/drivers/misc/gps/Makefile b/drivers/misc/gps/Makefile new file mode 100644 index 000000000000..6b4bdb6480c2 --- /dev/null +++ b/drivers/misc/gps/Makefile @@ -0,0 +1,3 @@ +obj-$(CONFIG_GPS_GNS7560) += rk29_gps.o + + diff --git a/drivers/misc/gps/rk29_gps.c b/drivers/misc/gps/rk29_gps.c new file mode 100644 index 000000000000..a3ff3764f5c6 --- /dev/null +++ b/drivers/misc/gps/rk29_gps.c @@ -0,0 +1,195 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "rk29_gps.h" +#ifdef CONFIG_HAS_EARLYSUSPEND +#include +#endif +#if 0 +#define DBG(x...) printk(KERN_INFO x) +#else +#define DBG(x...) +#endif + +#define ENABLE 1 +#define DISABLE 0 + +static struct rk29_gps_data *pgps; +static struct early_suspend gps_early_suspend; + +static void rk29_gps_early_suspend(struct early_suspend *h) +{ + struct rk29_gps_data *pdata = pgps; + if(!pdata) + return; + + if(pdata->uart_id == 3) + { + rk29_mux_api_set(GPIO2B3_UART3SOUT_NAME, GPIO2L_GPIO2B3); + gpio_request(RK29_PIN2_PB3, NULL); + gpio_direction_output(RK29_PIN2_PB3,GPIO_LOW); + + rk29_mux_api_set(GPIO2B2_UART3SIN_NAME, GPIO2L_GPIO2B2); + gpio_request(RK29_PIN2_PB2, NULL); + gpio_direction_output(RK29_PIN2_PB2,GPIO_LOW); + + } + else + { + //to do + + } + + if(pdata->powerflag == 1) + { + pdata->power_down(); + pdata->powerflag = 0; + } + + printk("%s\n",__FUNCTION__); + +} + +static void rk29_gps_early_resume(struct early_suspend *h) +{ + struct rk29_gps_data *pdata = pgps; + if(!pdata) + return; + + if(pdata->uart_id == 3) + { + rk29_mux_api_set(GPIO2B3_UART3SOUT_NAME, GPIO2L_UART3_SOUT); + rk29_mux_api_set(GPIO2B2_UART3SIN_NAME, GPIO2L_UART3_SIN); + } + else + { + //to do + + } + + if(pdata->powerflag == 0) + { + pdata->power_up(); + pdata->powerflag = 1; + } + + printk("%s\n",__FUNCTION__); + +} +int rk29_gps_open(struct inode *inode, struct file *filp) +{ + DBG("rk29_gps_open\n"); + + return 0; +} + +int rk29_gps_ioctl(struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg) +{ + int ret = 0; + + DBG("rk29_gps_ioctl: cmd = %d\n",cmd); + + switch (cmd){ + case ENABLE: + pgps->power_up(); + pgps->powerflag = 1; + break; + + case DISABLE: + pgps->power_down(); + pgps->powerflag = 0; + break; + + default: + printk("unknown ioctl cmd!\n"); + ret = -EINVAL; + break; + } + + return ret; +} + + +int rk29_gps_release(struct inode *inode, struct file *filp) +{ + DBG("rk29_gps_release\n"); + + return 0; +} + +static struct file_operations rk29_gps_fops = { + .owner = THIS_MODULE, + .open = rk29_gps_open, + .ioctl = rk29_gps_ioctl, + .release = rk29_gps_release, +}; + +static struct miscdevice rk29_gps_dev = +{ + .minor = MISC_DYNAMIC_MINOR, + .name = "rk29_gps", + .fops = &rk29_gps_fops, +}; + +static int rk29_gps_probe(struct platform_device *pdev) +{ + int ret = 0; + struct rk29_gps_data *pdata = pdev->dev.platform_data; + if(!pdata) + return -1; + + ret = misc_register(&rk29_gps_dev); + if (ret < 0){ + printk("rk29 gps register err!\n"); + return ret; + } + + if(pdata->power_up) + pdata->power_up(); + pgps = pdata; + +#ifdef CONFIG_HAS_EARLYSUSPEND + gps_early_suspend.suspend = rk29_gps_early_suspend; + gps_early_suspend.resume = rk29_gps_early_resume; + gps_early_suspend.level = ~0x0; + register_early_suspend(&gps_early_suspend); +#endif + + printk("%s:rk29 GPS initialized\n",__FUNCTION__); + + return ret; +} + +static struct platform_driver rk29_gps_driver = { + .probe = rk29_gps_probe, + .driver = { + .name = "rk29_gps", + .owner = THIS_MODULE, + }, +}; + +static int __init rk29_gps_init(void) +{ + return platform_driver_register(&rk29_gps_driver); +} + +static void __exit rk29_gps_exit(void) +{ + platform_driver_unregister(&rk29_gps_driver); +} + +module_init(rk29_gps_init); +module_exit(rk29_gps_exit); +MODULE_DESCRIPTION ("rk29 gps driver"); +MODULE_LICENSE("GPL"); + diff --git a/drivers/misc/gps/rk29_gps.h b/drivers/misc/gps/rk29_gps.h new file mode 100644 index 000000000000..a54c5d1da65d --- /dev/null +++ b/drivers/misc/gps/rk29_gps.h @@ -0,0 +1,16 @@ +/* + 2011.01.16 lw@rock-chips.com +*/ + +#ifndef __RK29_GPS_H__ +#define __RK29_GPS_H__ + +struct rk29_gps_data { + int (*power_up)(void); + int (*power_down)(void); + int uart_id; + int powerpin; + int powerflag; +}; + +#endif