#include <linux/regulator/machine.h>
#include <linux/rfkill-rk.h>
#include <linux/sensor-dev.h>
+#if defined(CONFIG_GPS_HV5820B)
+#include "../../../drivers/misc/gps/hv5820b/hv5820b_gps.h"
+#endif
#ifdef CONFIG_VIDEO_RK29
/*---------------- Camera Sensor Macro Define Begin ------------------------*/
},
};
#endif
+#if defined(CONFIG_GPS_HV5820B)
+int hv5820b_gps_io_init(void)
+{
+ printk("%s \n", __FUNCTION__);
+ rk30_mux_api_set(GPIO1B1_SPI_TXD_UART1_SOUT_NAME, GPIO1B_GPIO1B1);//VCC_EN
+ gpio_request(RK2928_PIN1_PB1, NULL);
+ gpio_direction_output(RK2928_PIN1_PB1, GPIO_LOW);
+
+ rk30_mux_api_set(GPIO1A2_I2S_LRCKRX_GPS_CLK_NAME, GPIO1A_GPS_CLK);//GPS_CLK
+ rk30_mux_api_set(GPIO1A4_I2S_SDO_GPS_MAG_NAME, GPIO1A_GPS_MAG);//GPS_MAG
+ rk30_mux_api_set(GPIO1A5_I2S_SDI_GPS_SIGN_NAME, GPIO1A_GPS_SIGN);//GPS_SIGN
+
+ rk30_mux_api_set(GPIO1B0_SPI_CLK_UART1_CTSN_NAME, GPIO1B_GPIO1B0);//SPI_CLK
+ gpio_request(RK2928_PIN1_PB0, NULL);
+ gpio_direction_output(RK2928_PIN1_PB0, GPIO_LOW);
+
+ rk30_mux_api_set(GPIO1B2_SPI_RXD_UART1_SIN_NAME, GPIO1B_GPIO1B2);//SPI_MOSI
+ gpio_request(RK2928_PIN1_PB2, NULL);
+ gpio_direction_output(RK2928_PIN1_PB2, GPIO_LOW);
+
+ rk30_mux_api_set(GPIO1B3_SPI_CSN0_UART1_RTSN_NAME, GPIO1B_GPIO1B3);//SPI_CS
+ gpio_request(RK2928_PIN1_PB3, NULL);
+ gpio_direction_output(RK2928_PIN1_PB3, GPIO_LOW);
+ return 0;
+}
+int hv5820b_gps_power_up(void)
+{
+ printk("%s \n", __FUNCTION__);
+
+ return 0;
+}
+
+int hv5820b_gps_power_down(void)
+{
+ printk("%s \n", __FUNCTION__);
+
+ return 0;
+}
+
+int hv5820b_gps_reset_set(int level)
+{
+ return 0;
+}
+int hv5820b_enable_hclk_gps(void)
+{
+ printk("%s \n", __FUNCTION__);
+ clk_enable(clk_get(NULL, "hclk_gps"));
+ return 0;
+}
+int hv5820b_disable_hclk_gps(void)
+{
+ printk("%s \n", __FUNCTION__);
+ clk_disable(clk_get(NULL, "hclk_gps"));
+ return 0;
+}
+struct hv5820b_gps_data hv5820b_gps_info = {
+ .io_init = hv5820b_gps_io_init,
+ .power_up = hv5820b_gps_power_up,
+ .power_down = hv5820b_gps_power_down,
+ .reset = hv5820b_gps_reset_set,
+ .enable_hclk_gps = hv5820b_enable_hclk_gps,
+ .disable_hclk_gps = hv5820b_disable_hclk_gps,
+ .GpsSign = RK2928_PIN1_PA4,
+ .GpsMag = RK2928_PIN1_PB1, //GPIO index
+ .GpsClk = RK2928_PIN1_PA2, //GPIO index
+ .GpsVCCEn = RK2928_PIN1_PB1, //GPIO index
+ .GpsSpi_CSO = RK2928_PIN1_PB3, //GPIO index
+ .GpsSpiClk = RK2928_PIN1_PB0, //GPIO index
+ .GpsSpiMOSI = RK2928_PIN1_PB2, //GPIO index
+};
+struct platform_device hv5820b_device_gps = {
+ .name = "gps_hv5820b",
+ .id = -1,
+ .dev = {
+ .platform_data = &hv5820b_gps_info,
+ }
+ };
+#endif
static struct platform_device *devices[] __initdata = {
#ifdef CONFIG_ION
&device_ion,
#ifdef CONFIG_FB_ROCKCHIP
&device_fb,
#endif
+#ifdef CONFIG_GPS_HV5820B
+ &hv5820b_device_gps,
+#endif
};
static void __init rk2928_board_init(void)
obj-$(CONFIG_MT6229) += mt6229.o
obj-$(CONFIG_STE) += ste.o
obj-$(CONFIG_RK29_SUPPORT_MODEM) += rk29_modem/
-obj-$(CONFIG_GPS_GNS7560) += gps/
+obj-$(CONFIG_RK29_GPS) += gps/
obj-y += inv_mpu/
obj-$(CONFIG_RK29_NEWTON) += newton.o
obj-$(CONFIG_TDSC8800) += tdsc8800.o
config GPS_GNS7560
bool "gns7560 support"
default n
-
+
+source "drivers/misc/gps/hv5820b/Kconfig"
endif # RK29_GPS
obj-$(CONFIG_GPS_GNS7560) += rk29_gps.o
-
+obj-$(CONFIG_RK29_GPS) += hv5820b/
--- /dev/null
+#
+# gps device configuration
+#
+
+
+
+config GPS_HV5820B
+ bool "HV5820B support"
+ default n
+
+
+
+
--- /dev/null
+obj-$(CONFIG_GPS_HV5820B) += gpsdriver.o PALAPI.o gpsdrv.a
+
+
--- /dev/null
+///////////////////////////////////////////////////////////////////////////////////\r
+//\r
+// Filename: PALAPI.c\r
+// Author: sjchen\r
+// Copyright: \r
+// Date: 2010/12/01\r
+// Description:\r
+// linux system interface\r
+//\r
+// Revision:\r
+// 0.0.1\r
+//\r
+///////////////////////////////////////////////////////////////////////////////////\r
+#include <linux/module.h>\r
+#include <linux/kernel.h>\r
+#include <linux/string.h>\r
+#include <linux/slab.h>\r
+#include <linux/sched.h>\r
+#include <linux/time.h>\r
+#include <linux/fs.h>\r
+#include <linux/delay.h>\r
+#include <linux/spinlock.h>\r
+#include <linux/mm.h>\r
+#include <linux/miscdevice.h>\r
+#include <asm/system.h>\r
+#include <asm/page.h>\r
+#include <asm/pgtable.h>\r
+#include <asm/uaccess.h>\r
+\r
+#include <linux/interrupt.h>\r
+#include <asm/cacheflush.h>\r
+#include <asm/cachetype.h>\r
+#include <asm/io.h>\r
+#include <linux/semaphore.h>\r
+\r
+#include <mach/gpio.h>\r
+\r
+\r
+///////////////////////////////////////////////////////////////////////////////////\r
+// \r
+// Function Name:PAL_AllocMem\r
+// Parameters:\r
+// Description: allocate system memory\r
+// Notes: sjchen 2010/12/01\r
+//\r
+///////////////////////////////////////////////////////////////////////////////////\r
+void* PAL_AllocMem(int nBytes)\r
+{\r
+ return kmalloc ( nBytes, GFP_KERNEL);\r
+}\r
+\r
+\r
+///////////////////////////////////////////////////////////////////////////////////\r
+// \r
+// Function Name:PAL_FreeMem\r
+// Parameters:\r
+// Description: free system memory\r
+// Notes: sjchen 2010/12/01\r
+//\r
+///////////////////////////////////////////////////////////////////////////////////\r
+void PAL_FreeMem(void* pMem)\r
+{\r
+ if(pMem)\r
+ {\r
+ kfree(pMem);\r
+ }\r
+}\r
+\r
+\r
+///////////////////////////////////////////////////////////////////////////////////\r
+// \r
+// Function Name:PAL_CreateMutex\r
+// Parameters:\r
+// Description: Create a semaphore\r
+// Notes: sjchen 2010/12/01\r
+//\r
+///////////////////////////////////////////////////////////////////////////////////\r
+int PAL_CreateMutex ( void)\r
+{\r
+ struct semaphore *psem;\r
+\r
+ psem = (struct semaphore *)PAL_AllocMem(sizeof(struct semaphore));\r
+ //init_MUTEX_LOCKED(psem);\r
+ sema_init(psem, 0);\r
+ return (int)psem;\r
+\r
+}\r
+\r
+///////////////////////////////////////////////////////////////////////////////////\r
+// \r
+// Function Name:PAL_ReleaseMutex\r
+// Parameters:\r
+// Description: Release a semaphore\r
+// Notes: sjchen 2010/12/01\r
+//\r
+///////////////////////////////////////////////////////////////////////////////////\r
+void PAL_ReleaseMutex ( int hMutex )\r
+{\r
+ if(hMutex)\r
+ {\r
+ up((struct semaphore *)hMutex);\r
+ }\r
+\r
+ return ;\r
+}\r
+\r
+///////////////////////////////////////////////////////////////////////////////////\r
+// \r
+// Function Name:PAL_WaitMutex\r
+// Parameters:\r
+// Description: Wait semaphore to signal\r
+// Notes: sjchen 2010/12/01\r
+//\r
+///////////////////////////////////////////////////////////////////////////////////\r
+void PAL_WaitMutex(int hMutex)\r
+{\r
+ if(hMutex)\r
+ {\r
+ down((struct semaphore *)hMutex);\r
+ }\r
+}\r
+\r
+///////////////////////////////////////////////////////////////////////////////////\r
+// \r
+// Function Name:PAL_CloseMutes\r
+// Parameters:\r
+// Description: Close a semaphore\r
+// Notes: sjchen 2010/12/01\r
+//\r
+///////////////////////////////////////////////////////////////////////////////////\r
+void PAL_CloseMutes(int hMutex)\r
+{\r
+ if(hMutex)\r
+ {\r
+ PAL_FreeMem((void *)hMutex);\r
+ }\r
+}\r
+\r
+\r
+///////////////////////////////////////////////////////////////////////////////////\r
+// \r
+// Function Name:PAL_memset\r
+// Parameters:\r
+// Description:\r
+// Notes: sjchen 2010/12/01\r
+//\r
+///////////////////////////////////////////////////////////////////////////////////\r
+void PAL_memset (\r
+ void* pbuf,\r
+ unsigned char nval,\r
+ int nsize\r
+ )\r
+{\r
+ memset ( pbuf, nval, nsize );\r
+}\r
+\r
+///////////////////////////////////////////////////////////////////////////////////\r
+// \r
+// Function Name:PAL_memcpy\r
+// Parameters:\r
+// Description:\r
+// Notes: sjchen 2010/12/01\r
+//\r
+///////////////////////////////////////////////////////////////////////////////////\r
+void PAL_memcpy (\r
+ void* pDst,\r
+ void* pSrc,\r
+ int nSize\r
+ )\r
+{\r
+ memcpy ( pDst, pSrc, nSize );\r
+}\r
+\r
+\r
+///////////////////////////////////////////////////////////////////////////////////\r
+// \r
+// Function Name:PAL_GetCurTimer_US\r
+// Parameters:\r
+// Description: Get system time \r
+// Notes: sjchen 2010/11/30\r
+//\r
+///////////////////////////////////////////////////////////////////////////////////\r
+void PAL_GetCurTimer_US(\r
+ int *n32Second,\r
+ int *n32us\r
+ )\r
+{\r
+ struct timeval tv;\r
+\r
+ do_gettimeofday(&tv);\r
+\r
+ *n32Second = tv.tv_sec;\r
+ *n32us = tv.tv_usec;\r
+}\r
+\r
+\r
+///////////////////////////////////////////////////////////////////////////////////\r
+// \r
+// Function Name:PAL_GetCurTimer_US\r
+// Parameters:\r
+// Description: Get system time \r
+// Notes: sjchen 2010/11/30\r
+//\r
+///////////////////////////////////////////////////////////////////////////////////\r
+void PAL_GetSysTimer_US(\r
+ int *n32Second,\r
+ int *n32us\r
+ )\r
+{\r
+ PAL_GetCurTimer_US(n32Second, n32us);\r
+}\r
+\r
+///////////////////////////////////////////////////////////////////////////////////\r
+// \r
+// Function Name:PAL_GetKernelFreePage\r
+// Parameters:\r
+// Description: Allocate kernel free page\r
+// Notes: sjchen 2010/11/30\r
+//\r
+///////////////////////////////////////////////////////////////////////////////////\r
+int PAL_GetKernelFreePage(int nPageSize)\r
+{\r
+ return __get_free_pages(GFP_KERNEL,get_order(nPageSize));\r
+}\r
+\r
+\r
+///////////////////////////////////////////////////////////////////////////////////\r
+// \r
+// Function Name:PAL_FreeKernelPage\r
+// Parameters:\r
+// Description: Free kernel page\r
+// Notes: sjchen 2010/11/30\r
+//\r
+///////////////////////////////////////////////////////////////////////////////////\r
+void PAL_FreeKernelPage(int nAddr,int nPageSize)\r
+{\r
+ if(nAddr != 0 && nPageSize != 0)\r
+ {\r
+ free_pages(nAddr,get_order(nPageSize)); \r
+ \r
+ }\r
+}\r
+\r
+///////////////////////////////////////////////////////////////////////////////////\r
+// \r
+// Function Name:PAL_GetUser\r
+// Parameters:\r
+// Description: \r
+// Notes: sjchen 2010/11/30\r
+//\r
+///////////////////////////////////////////////////////////////////////////////////\r
+int PAL_GetUser(int *p)\r
+{\r
+ int nData = 0;\r
+ \r
+ __get_user(nData,(int __user *)p);\r
+\r
+ return nData;\r
+}\r
+\r
+///////////////////////////////////////////////////////////////////////////////////\r
+// \r
+// Function Name:PAL_CopyFromUser\r
+// Parameters:\r
+// Description: Copy datas from user space to kernel space\r
+// Notes: sjchen 2010/11/30\r
+//\r
+///////////////////////////////////////////////////////////////////////////////////\r
+void PAL_CopyFromUser(void *pDest,void *pSrc,int nSize)\r
+{\r
+ __copy_from_user(pDest,(void __user *)pSrc,nSize);\r
+}\r
+\r
+\r
+///////////////////////////////////////////////////////////////////////////////////\r
+// \r
+// Function Name:PAL_CopyToUser\r
+// Parameters:\r
+// Description: Copy datas from kernel space to user space\r
+// Notes: sjchen 2010/11/30\r
+//\r
+///////////////////////////////////////////////////////////////////////////////////\r
+int PAL_CopyToUser(void *pDest,void *pSrc,int nSize)\r
+{\r
+ return copy_to_user((void __user *)pDest, pSrc, nSize);\r
+}\r
+\r
+///////////////////////////////////////////////////////////////////////////////////\r
+// \r
+// Function Name:PAL_Sprintf\r
+// Parameters:\r
+// Description:\r
+// Notes: sjchen 2010/11/04\r
+//\r
+///////////////////////////////////////////////////////////////////////////////////\r
+int PAL_Sprintf (\r
+ char * pDst,\r
+ const char * pFormat,\r
+ ...\r
+ )\r
+{\r
+ int nNum = 0;\r
+\r
+ va_list ptr;\r
+\r
+ va_start ( ptr, pFormat );\r
+\r
+ nNum = vsprintf ( pDst, pFormat, ptr );\r
+\r
+ va_end ( ptr );\r
+\r
+ return nNum;\r
+}\r
+///////////////////////////////////////////////////////////////////////////////////\r
+// \r
+// Function Name:PAL_Sprintf\r
+// Parameters:\r
+// Description:\r
+// Notes: sjchen 2010/11/04\r
+//\r
+///////////////////////////////////////////////////////////////////////////////////\r
+void PAL_KDEBUG (\r
+ const char * pFormat,\r
+ ...\r
+ )\r
+{\r
+#if 1\r
+ va_list ptr;\r
+ \r
+ va_start ( ptr, pFormat );\r
+\r
+ vprintk ( pFormat, ptr );\r
+\r
+ va_end ( ptr );\r
+#endif\r
+ return ;\r
+}\r
+\r
+///////////////////////////////////////////////////////////////////////////////////\r
+// \r
+// Function Name:PAL_mdelay\r
+// Parameters:\r
+// Description:\r
+// Notes: sjchen 2010/11/04\r
+//\r
+///////////////////////////////////////////////////////////////////////////////////\r
+void PAL_mdelay(int ms)\r
+{\r
+ mdelay(ms);\r
+}\r
+\r
+///////////////////////////////////////////////////////////////////////////////////\r
+// \r
+// Function Name:PAL_dma_cache_wback_inv\r
+// Parameters:\r
+// Description:\r
+// Notes: sjchen 2010/11/04\r
+//\r
+///////////////////////////////////////////////////////////////////////////////////\r
+void PAL_dma_cache_wback_inv(void * pMem, int size )\r
+{\r
+ //TODO:\r
+ //fluch cache\r
+ \r
+ __cpuc_flush_dcache_area(pMem, size );\r
+}\r
+\r
+\r
+///////////////////////////////////////////////////////////////////////////////////\r
+// \r
+// Function Name:PAL_dma_cache_wback_inv\r
+// Parameters:\r
+// Description:\r
+// Notes: sjchen 2010/11/04\r
+//\r
+///////////////////////////////////////////////////////////////////////////////////\r
+void PAL_dma_cache_inv(void * pMem, int size )\r
+{\r
+ //TODO:\r
+ //fluch cache\r
+ \r
+ __cpuc_flush_dcache_area(pMem, size );\r
+}\r
+\r
+\r
+\r
+///////////////////////////////////////////////////////////////////////////////////\r
+// \r
+// Function Name:PAL_Set_GPIO_Pin\r
+// Parameters:\r
+// Description:\r
+// Notes: sjchen 2010/11/04\r
+//\r
+///////////////////////////////////////////////////////////////////////////////////\r
+void PAL_Set_GPIO_Pin(int gpio)\r
+{\r
+ //TODO:\r
+ //Set gpio to high level\r
+ \r
+ //gpio_write_one_pin_value(gpio, 1);\r
+ gpio_set_value(gpio, GPIO_HIGH);\r
+}\r
+\r
+///////////////////////////////////////////////////////////////////////////////////\r
+// \r
+// Function Name:PAL_Clr_GPIO_Pin\r
+// Parameters:\r
+// Description:\r
+// Notes: sjchen 2010/11/04\r
+//\r
+///////////////////////////////////////////////////////////////////////////////////\r
+void PAL_Clr_GPIO_Pin(int gpio)\r
+{\r
+ //TODO:\r
+ //Set gpio to low level\r
+ \r
+ //gpio_write_one_pin_value(gpio, 0);\r
+ gpio_set_value(gpio, GPIO_LOW);\r
+}\r
+\r
+\r
--- /dev/null
+///////////////////////////////////////////////////////////////////////////////////\r
+//\r
+// Filename: PALAPI.h\r
+// Author: sjchen\r
+// Copyright: \r
+// Date: 2010/12/01\r
+// Description:\r
+// declare linux driver function \r
+//\r
+// Revision:\r
+// 0.0.1\r
+//\r
+///////////////////////////////////////////////////////////////////////////////////\r
+\r
+#ifndef __PALAPI_H___\r
+#define __PALAPI_H___\r
+\r
+extern void* PAL_AllocMem(int nBytes);\r
+extern void PAL_FreeMem(void* pMem);\r
+extern int PAL_CreateMutex ( void);\r
+extern void PAL_ReleaseMutex ( int hMutex );\r
+extern void PAL_WaitMutex(int hMutex);\r
+extern void PAL_CloseMutes(int hMutex);\r
+\r
+extern void PAL_memset (\r
+ void* pbuf,\r
+ unsigned char nval,\r
+ int nsize\r
+ );\r
+\r
+extern void PAL_memcpy (\r
+ void* pDst,\r
+ void* pSrc,\r
+ int nSize\r
+ );\r
+\r
+void PAL_GetCurTimer_US(\r
+ int *n32Second,\r
+ int *n32us\r
+ );\r
+\r
+void PAL_GetSysTimer_US(\r
+ int *n32Second,\r
+ int *n32us\r
+ );\r
+\r
+int PAL_GetKernelFreePage(int nPageSize);\r
+\r
+void PAL_FreeKernelPage(int nAddr,int nPageSize);\r
+\r
+int PAL_GetUser(int *p);\r
+\r
+void PAL_CopyFromUser(void *pDest,void *pSrc,int nSize);\r
+\r
+int PAL_CopyToUser(void *pDest,void *pSrc,int nSize);\r
+\r
+int PAL_Sprintf (\r
+ char * pDst,\r
+ const char * pFormat,\r
+ ...\r
+ );\r
+\r
+void PAL_mdelay(int ms);\r
+\r
+void PAL_KDEBUG (\r
+ const char * pFormat,\r
+ ...\r
+ );\r
+void PAL_Set_GPIO_Pin(int gpio);\r
+void PAL_Clr_GPIO_Pin(int gpio);\r
+\r
+#endif //__PALAPI_H___\r
--- /dev/null
+///////////////////////////////////////////////////////////////////////////////////\r
+//\r
+// Filename: gpsdriver.c\r
+// Author: sjchen\r
+// Copyright: \r
+// Date: 2012/07/09\r
+// Description:\r
+// GPS driver\r
+//\r
+// Revision:\r
+// 0.0.1\r
+//\r
+///////////////////////////////////////////////////////////////////////////////////\r
+#include <linux/module.h>\r
+#include <linux/kernel.h>\r
+#include <linux/string.h>\r
+#include <linux/slab.h>\r
+#include <linux/errno.h>\r
+#include <linux/init.h>\r
+#include <linux/fs.h>\r
+#include <linux/delay.h>\r
+#include <linux/spinlock.h>\r
+#include <linux/mm.h>\r
+#include <linux/miscdevice.h>\r
+#include <linux/interrupt.h>\r
+#include <linux/printk.h>\r
+#include <asm/system.h>\r
+#include <asm/page.h>\r
+#include <asm/pgtable.h>\r
+#include <asm/uaccess.h>\r
+#include <linux/clk.h>\r
+#include <asm/io.h>\r
+\r
+//#include <mach/clock.h>\r
+\r
+\r
+#include "gpsdrv.h"\r
+#include "gpsdriver.h"\r
+#include "lnxdrv.h"\r
+#include "PALAPI.h"\r
+\r
+#include <linux/platform_device.h>\r
+#include <mach/gpio.h>\r
+#include "hv5820b_gps.h"\r
+\r
+///////////////////////////////////////////////////////////////////////////////////\r
+// \r
+// macro declaration\r
+//\r
+///////////////////////////////////////////////////////////////////////////////////\r
+#define GPS_MAJOR ( 61 )\r
+#define SW_VA_GPS_IO_BASE 0x10400000\r
+#define GPS_USE_SPI \r
+\r
+\r
+///////////////////////////////////////////////////////////////////////////////////\r
+// \r
+// static variables declaration\r
+//\r
+///////////////////////////////////////////////////////////////////////////////////\r
+static char gpsstr[]="gps";\r
+static struct miscdevice gps_miscdev;\r
+struct hv5820b_gps_data *hv5820b_pdata ;\r
+void *gps_mem =NULL;\r
+unsigned long gps_mem_address; //BSP define for u32MemoryPhyAddr\r
+unsigned long gps_mem_size = 8*0x00100000; //it must be more than 8MB\r
+\r
+///////////////////////////////////////////////////////////////////////////////////\r
+// \r
+// extern variables declaration\r
+//\r
+///////////////////////////////////////////////////////////////////////////////////\r
+extern unsigned long gps_mem_address; //BSP define for u32MemoryPhyAddr\r
+extern unsigned long gps_mem_size; //it must be more than 8MB\r
+\r
+\r
+#ifdef GPS_USE_SPI\r
+#include <linux/adc.h>\r
+void VtuneAndSpiCheck_rk(int enable_check);\r
+int AdcValueGet(void);\r
+int GetVtuneAdcValue_rk(void);\r
+void ConfigRfSpi_rk(int Val );\r
+struct adc_client *adc_gps_cleint;\r
+#define LOW_SCALE_0_65V 600\r
+#define HIGH_SCALE_0_95V 1000\r
+void gps_callback(struct adc_client *client, void *callback_param, int result)\r
+{\r
+ return;\r
+}\r
+void VtuneAndSpiCheck_rk(int enable_check)\r
+{\r
+ int VtuneAvg;\r
+ int SpiValue = 2;\r
+ int cnt = 0;\r
+\r
+ if( enable_check == 0)\r
+ return;\r
+\r
+ VtuneAvg = 0; \r
+ while( (VtuneAvg < LOW_SCALE_0_65V) || (VtuneAvg > HIGH_SCALE_0_95V) && cnt < 10)\r
+ { \r
+ if( (SpiValue >= 8) || (SpiValue <= 0) )\r
+ break; \r
+\r
+ VtuneAvg = AdcValueGet();\r
+ \r
+ if( VtuneAvg < LOW_SCALE_0_65V)\r
+ {\r
+ SpiValue++;\r
+ ConfigRfSpi_rk( SpiValue);\r
+ }\r
+\r
+ if( VtuneAvg > HIGH_SCALE_0_95V)\r
+ {\r
+ SpiValue--;\r
+ ConfigRfSpi_rk( SpiValue);\r
+ }\r
+ cnt ++;\r
+ }\r
+}\r
+\r
+ \r
+int AdcValueGet()\r
+{\r
+ // Read adc value\r
+ int adc_value;\r
+ int sampletime = 100;\r
+ int AveValue;\r
+ int SumValue;\r
+ int i; \r
+\r
+ \r
+ SumValue = 0;\r
+ for(i = 0; i < sampletime; i++)\r
+ {\r
+ adc_value = GetVtuneAdcValue_rk();\r
+ \r
+ SumValue += adc_value;\r
+ }\r
+ AveValue = SumValue / sampletime;\r
+ return AveValue;\r
+}\r
+\r
+int GetVtuneAdcValue_rk()\r
+{\r
+ int adc_val = 0;\r
+ \r
+ adc_val = adc_sync_read(adc_gps_cleint);\r
+ if(adc_val < 0)\r
+ printk("GetVtuneAdcValue error");\r
+ \r
+ return adc_val;\r
+}\r
+\r
+void ConfigRfSpi_rk(int Val )\r
+{\r
+ int i;\r
+\r
+#define GPS_SCLK hv5820b_pdata->GpsSpiMOSI\r
+#define GPS_MOSI hv5820b_pdata->GpsSpiClk\r
+#define GPS_SCS hv5820b_pdata->GpsSpi_CSO\r
+\r
+\r
+ PAL_Clr_GPIO_Pin(GPS_SCLK);\r
+ PAL_Clr_GPIO_Pin(GPS_SCS);\r
+\r
+ for(i = 0; i < 100000000; i++);\r
+\r
+ PAL_Set_GPIO_Pin(GPS_SCLK);\r
+ PAL_Set_GPIO_Pin(GPS_MOSI); //b15\r
+\r
+\r
+ for(i = 0; i < 100000000; i++);\r
+ PAL_Clr_GPIO_Pin(GPS_SCLK);\r
+ for(i = 0; i < 100000000; i++);\r
+ PAL_Set_GPIO_Pin(GPS_SCLK); //b14\r
+ for(i = 0; i < 100000000; i++);\r
+ PAL_Clr_GPIO_Pin(GPS_SCLK);\r
+ for(i = 0; i < 100000000; i++);\r
+ PAL_Set_GPIO_Pin(GPS_SCLK); //b13\r
+ for(i = 0; i < 100000000; i++);\r
+ PAL_Clr_GPIO_Pin(GPS_SCLK);\r
+ for(i = 0; i < 100000000; i++);\r
+ PAL_Set_GPIO_Pin(GPS_SCLK); //b12\r
+ PAL_Clr_GPIO_Pin(GPS_MOSI);\r
+ for(i = 0; i < 100000000; i++);\r
+ PAL_Clr_GPIO_Pin(GPS_SCLK);\r
+ for(i = 0; i < 100000000; i++);\r
+ PAL_Set_GPIO_Pin(GPS_SCLK); //b11\r
+ PAL_Set_GPIO_Pin(GPS_MOSI);\r
+ for(i = 0; i < 100000000; i++);\r
+ PAL_Clr_GPIO_Pin(GPS_SCLK);\r
+ for(i = 0; i < 100000000; i++);\r
+ PAL_Set_GPIO_Pin(GPS_SCLK); //b10\r
+ for(i = 0; i < 100000000; i++);\r
+ PAL_Clr_GPIO_Pin(GPS_SCLK);\r
+ for(i = 0; i < 100000000; i++);\r
+ PAL_Set_GPIO_Pin(GPS_SCLK); //b9\r
+ PAL_Clr_GPIO_Pin(GPS_MOSI);\r
+ for(i = 0; i < 100000000; i++);\r
+ PAL_Clr_GPIO_Pin(GPS_SCLK);\r
+ for(i = 0; i < 100000000; i++);\r
+ PAL_Set_GPIO_Pin(GPS_SCLK); //b8\r
+ for(i = 0; i < 100000000; i++);\r
+ PAL_Clr_GPIO_Pin(GPS_SCLK);\r
+ for(i = 0; i < 100000000; i++);\r
+ PAL_Set_GPIO_Pin(GPS_SCLK); //b7\r
+ for(i = 0; i < 100000000; i++);\r
+ PAL_Clr_GPIO_Pin(GPS_SCLK);\r
+ for(i = 0; i < 100000000; i++);\r
+ PAL_Set_GPIO_Pin(GPS_SCLK); //b6\r
+ if ((Val >> 4) & 1)\r
+ PAL_Set_GPIO_Pin(GPS_MOSI);\r
+ else\r
+ PAL_Clr_GPIO_Pin(GPS_MOSI);\r
+ for(i = 0; i < 100000000; i++);\r
+ PAL_Clr_GPIO_Pin(GPS_SCLK);\r
+ for(i = 0; i < 100000000; i++);\r
+ PAL_Set_GPIO_Pin(GPS_SCLK); //b5\r
+ if ((Val >> 3) & 1)\r
+ PAL_Set_GPIO_Pin(GPS_MOSI);\r
+ else\r
+ PAL_Clr_GPIO_Pin(GPS_MOSI); \r
+ for(i = 0; i < 100000000; i++);\r
+ PAL_Clr_GPIO_Pin(GPS_SCLK);\r
+ for(i = 0; i < 100000000; i++);\r
+ PAL_Set_GPIO_Pin(GPS_SCLK); //b4\r
+ if ((Val >> 2) & 1)\r
+ PAL_Set_GPIO_Pin(GPS_MOSI);\r
+ else\r
+ PAL_Clr_GPIO_Pin(GPS_MOSI); \r
+ for(i = 0; i < 100000000; i++);\r
+ PAL_Clr_GPIO_Pin(GPS_SCLK);\r
+ for(i = 0; i < 100000000; i++);\r
+ PAL_Set_GPIO_Pin(GPS_SCLK); //b3\r
+ if ((Val >> 1) & 1)\r
+ PAL_Set_GPIO_Pin(GPS_MOSI);\r
+ else\r
+ PAL_Clr_GPIO_Pin(GPS_MOSI);\r
+ for(i = 0; i < 100000000; i++);\r
+ PAL_Clr_GPIO_Pin(GPS_SCLK);\r
+ for(i = 0; i < 100000000; i++);\r
+ PAL_Set_GPIO_Pin(GPS_SCLK); //b2\r
+ if ((Val >> 0) & 1)\r
+ PAL_Set_GPIO_Pin(GPS_MOSI);\r
+ else\r
+ PAL_Clr_GPIO_Pin(GPS_MOSI);\r
+ for(i = 0; i < 100000000; i++);\r
+ PAL_Clr_GPIO_Pin(GPS_SCLK);\r
+ for(i = 0; i < 100000000; i++);\r
+ PAL_Set_GPIO_Pin(GPS_SCLK); //b1\r
+ for(i = 0; i < 100000000; i++);\r
+ PAL_Clr_GPIO_Pin(GPS_SCLK);\r
+ for(i = 0; i < 100000000; i++);\r
+ PAL_Set_GPIO_Pin(GPS_SCLK); //b0\r
+ for(i = 0; i < 100000000; i++);\r
+ PAL_Clr_GPIO_Pin(GPS_SCLK);\r
+ for(i = 0; i < 100000000; i++);\r
+ for(i = 0; i < 100000000; i++);\r
+ PAL_Set_GPIO_Pin(GPS_SCS);\r
+}\r
+#endif\r
+static int hv5820b_gps_probe(struct platform_device *pdev)\r
+{\r
+ int err;\r
+ struct hv5820b_gps_data *pdata = pdev->dev.platform_data;\r
+ if(!pdata)\r
+ return -1;\r
+ hv5820b_pdata = pdata;\r
+ \r
+ printk("Enter GPSDrv_Init\n");\r
+\r
+ err = request_irq ( GPS_BB_INT_MASK, gps_int_handler, IRQF_DISABLED, gpsstr, NULL );\r
+\r
+ if ( err )\r
+ {\r
+ printk ( "gps_mod_init: gps request irq failed!\n" );\r
+\r
+ return err;\r
+ }\r
+\r
+ err = misc_register( &gps_miscdev);\r
+ if (err < 0)\r
+ {\r
+ return err;\r
+ }\r
+\r
+ gps_mem=kzalloc(gps_mem_size, GFP_KERNEL);\r
+ gps_mem_address = (unsigned long)(&gps_mem);\r
+ //TODO: \r
+ //Set the GPIO (GPS_VCC_EN) to low level in here\r
+ //\r
+ if(pdata->io_init)\r
+ pdata->io_init();\r
+ gpio_direction_output(pdata->GpsVCCEn, GPIO_LOW);\r
+ #ifdef GPS_USE_SPI\r
+ adc_gps_cleint = adc_register(2, gps_callback, NULL);\r
+ #endif\r
+ return 0; \r
+}\r
+static int hv5820b_gps_remove(struct platform_device *pdev)\r
+{\r
+#ifdef GPS_USE_SPI\r
+ adc_unregister(adc_gps_cleint);\r
+#endif\r
+ return 0;\r
+}\r
+static int hv5820b_gps_suspend(struct platform_device *pdev, pm_message_t state)\r
+{\r
+ return 0; \r
+}\r
+static int hv5820b_gps_resume(struct platform_device *pdev)\r
+{\r
+ return 0;\r
+}\r
+static struct platform_driver hv5820b_gps_driver = {\r
+ .probe = hv5820b_gps_probe,\r
+ .remove = hv5820b_gps_remove,\r
+ .suspend = hv5820b_gps_suspend,\r
+ .resume = hv5820b_gps_resume,\r
+ .driver = {\r
+ .name = "gps_hv5820b",\r
+ .owner = THIS_MODULE,\r
+ },\r
+};\r
+\r
+///////////////////////////////////////////////////////////////////////////////////\r
+// \r
+// Function Name: gps_mod_init\r
+// Parameters: \r
+// Description:\r
+// Notes: sjchen 2010/11/04\r
+//\r
+///////////////////////////////////////////////////////////////////////////////////\r
+static int __init gps_mod_init(void)\r
+{\r
+ return platform_driver_register(&hv5820b_gps_driver);\r
+}\r
+\r
+\r
+\r
+///////////////////////////////////////////////////////////////////////////////////\r
+// \r
+// Function Name: gps_mod_exit\r
+// Parameters:\r
+// Description:\r
+// Notes: sjchen 2010/11/04\r
+//\r
+///////////////////////////////////////////////////////////////////////////////////\r
+static void __exit gps_mod_exit ( void )\r
+{\r
+ //Disable baseband interrupt\r
+ WriteGpsRegisterUlong ( BB_INT_ENA_OFFSET, 0 );\r
+\r
+ free_irq( GPS_BB_INT_MASK, NULL );\r
+\r
+ //unregister_chrdev ( GPS_MAJOR, gpsstr );\r
+ misc_deregister(&gps_miscdev);\r
+ platform_driver_unregister(&hv5820b_gps_driver);\r
+ printk ( "GPS exit ok!\n");\r
+}\r
+\r
+///////////////////////////////////////////////////////////////////////////////////\r
+// \r
+// Function Name:gps_ioctl\r
+// Parameters:\r
+// Description:\r
+// Notes: sjchen 2010/11/04\r
+//\r
+///////////////////////////////////////////////////////////////////////////////////\r
+long gps_ioctl(struct file *file, unsigned int cmd,\r
+ unsigned long arg) \r
+{\r
+ int ret = 0;\r
+ BB_DRV_VERSION __user * pVersion;\r
+ GPS_DRV_INIT GpsInitStruct;\r
+\r
+ switch(cmd) \r
+ {\r
+\r
+ case IOCTL_BB_GPS_START:\r
+ //TODO:\r
+ // Gps baseband module initialize in here. \r
+ // Module power up\r
+ if(hv5820b_pdata->enable_hclk_gps)\r
+ hv5820b_pdata->enable_hclk_gps();\r
+ \r
+ memset(&GpsInitStruct,0,sizeof(GpsInitStruct));\r
+ GpsInitStruct.u32GpsRegBase = SW_VA_GPS_IO_BASE; // GPS Reg Base address \r
+ GpsInitStruct.u32MemoryPhyAddr = gps_mem_address; // sample code\r
+ GpsInitStruct.u32MemoryVirAddr = __phys_to_virt(gps_mem_address);\r
+ GpsInitStruct.u32GpsSign = hv5820b_pdata->GpsSign; //GPIO index\r
+ GpsInitStruct.u32GpsMag = hv5820b_pdata->GpsMag; //GPIO index\r
+ GpsInitStruct.u32GpsClk = hv5820b_pdata->GpsClk; //GPIO index\r
+ GpsInitStruct.u32GpsVCCEn = hv5820b_pdata->GpsVCCEn; //GPIO index\r
+ GpsInitStruct.u32GpsSpi_CSO = hv5820b_pdata->GpsSpi_CSO; //GPIO index\r
+ GpsInitStruct.u32GpsSpiClk = hv5820b_pdata->GpsSpiClk; //GPIO index\r
+ GpsInitStruct.u32GpsSpiMOSI = hv5820b_pdata->GpsSpiMOSI; //GPIO index\r
+ //TODO:\r
+ //Add other member of struct GpsInitStruct\r
+ Gps_Init( arg,&GpsInitStruct);\r
+ #ifdef GPS_USE_SPI\r
+ VtuneAndSpiCheck_rk(1);\r
+ #endif\r
+ break;\r
+\r
+ case IOCTL_BB_UPDATEDATA:\r
+ Gps_UpdateData(arg);\r
+ break;\r
+\r
+\r
+ case IOCTL_BB_GPS_STOP:\r
+ Gps_Stop();\r
+ \r
+ //TODO:\r
+ // Set the GPIO(GPS_VCC_EN) to low level\r
+ // Close the module clk.\r
+ gpio_direction_output(hv5820b_pdata->GpsVCCEn, GPIO_LOW);\r
+ if(hv5820b_pdata->disable_hclk_gps)\r
+ hv5820b_pdata->disable_hclk_gps();\r
+ break;\r
+\r
+ case IOCTL_BB_GET_VERSION:\r
+ pVersion = ( void __user * ) arg;\r
+\r
+ pVersion->u32Major = DRV_MAJOR_VERSION;\r
+ pVersion->u32Minor = DRV_MINOR_VERSION; \r
+ PAL_Sprintf(pVersion->strCompileTime,"%s,%s",__DATE__,__TIME__);\r
+\r
+ break;\r
+\r
+ default:\r
+\r
+ printk ( "gpsdrv: ioctl number is worng %d\n",cmd);\r
+\r
+ break;\r
+ };\r
+\r
+ return ret;\r
+}\r
+\r
+\r
+///////////////////////////////////////////////////////////////////////////////////\r
+// \r
+// Function Name:gps_read\r
+// Parameters:\r
+// Description: Read gps data\r
+// Notes: sjchen 2010/11/04\r
+//\r
+///////////////////////////////////////////////////////////////////////////////////\r
+ssize_t gps_read(struct file *file, char __user *buf, size_t size, loff_t *ppos)\r
+{\r
+ ssize_t nsize;\r
+ if((nsize = GpsDrv_Read(buf,size)))\r
+ {\r
+ return nsize;\r
+ }\r
+\r
+ return -EFAULT;\r
+}\r
+\r
+///////////////////////////////////////////////////////////////////////////////////\r
+// \r
+// Function Name:gps_open\r
+// Parameters:\r
+// Description:\r
+// Notes: sjchen 2010/11/04\r
+//\r
+///////////////////////////////////////////////////////////////////////////////////\r
+static int gps_open (struct inode *inode, struct file *filp)\r
+{\r
+ return 0; /* success */\r
+}\r
+\r
+\r
+\r
+///////////////////////////////////////////////////////////////////////////////////\r
+// \r
+// Function Name:gps_close \r
+// Parameters:\r
+// Description:\r
+// Notes: sjchen 2010/11/04\r
+//\r
+///////////////////////////////////////////////////////////////////////////////////\r
+static int gps_close (struct inode *inode, struct file *filp) \r
+{\r
+ return 0;\r
+}\r
+\r
+///////////////////////////////////////////////////////////////////////////////////\r
+// \r
+// Function Name: driver struct\r
+// Parameters:\r
+// Description:\r
+// Notes: sjchen 2010/11/04\r
+//\r
+///////////////////////////////////////////////////////////////////////////////////\r
+static const struct file_operations gps_fops = \r
+{\r
+ . owner = THIS_MODULE,\r
+ . open = gps_open,\r
+ . release = gps_close,\r
+ . unlocked_ioctl = gps_ioctl,\r
+ . read = gps_read,\r
+};\r
+\r
+static struct miscdevice gps_miscdev = \r
+{\r
+ .minor = MISC_DYNAMIC_MINOR,\r
+ .name = gpsstr,\r
+ .fops = &gps_fops,\r
+};\r
+\r
+\r
+///////////////////////////////////////////////////////////////////////////////////\r
+// \r
+// Module Name:\r
+// Parameters:\r
+// Description:\r
+// Notes: sjchen 2010/11/04\r
+//\r
+///////////////////////////////////////////////////////////////////////////////////\r
+module_init ( gps_mod_init );\r
+module_exit ( gps_mod_exit );\r
+\r
+\r
+MODULE_LICENSE("GPL");\r
+\r
+\r
--- /dev/null
+///////////////////////////////////////////////////////////////////////////////////\r
+//\r
+// Filename: gpsdriver.h\r
+// Author: sjchen\r
+// Copyright: \r
+// Date: 2012/07/09\r
+// Description:\r
+// gps driver function \r
+//\r
+// Revision:\r
+// 0.0.1\r
+//\r
+///////////////////////////////////////////////////////////////////////////////////\r
+\r
+#ifndef __GPSDRIVER_H___\r
+#define __GPSDRIVER_H___\r
+\r
+#define GPS_BB_INT_MASK 57 \r
+\r
+\r
+typedef struct __tag_GPS_DRV_INIT\r
+{\r
+ unsigned long u32MemoryPhyAddr; //must reserved 8MB memory for GPS\r
+ unsigned long u32MemoryVirAddr;\r
+ unsigned long u32GpsRegBase; //GPS register base virtual address\r
+ unsigned int u32GpsSign; //GPIO index\r
+ unsigned int u32GpsMag; //GPIO index\r
+ unsigned int u32GpsClk; //GPIO index\r
+ unsigned int u32GpsVCCEn; //GPIO index\r
+ unsigned int u32GpsSpi_CSO; //GPIO index\r
+ unsigned int u32GpsSpiClk; //GPIO index\r
+ unsigned int u32GpsSpiMOSI; //GPIO index\r
+}GPS_DRV_INIT,*PGPS_DRV_INIT;\r
+\r
+extern void WriteGpsRegisterUlong ( int reg_offset, int value );
+
+extern int ReadGpsRegisterUlong ( int reg_offset );
+
+extern irqreturn_t gps_int_handler ( int irq, void * dev_id );
+
+extern void Gps_Init(unsigned long arg,PGPS_DRV_INIT pGpsDrvInit);
+
+extern void Gps_UpdateData(unsigned long arg);
+
+extern void Gps_Stop(void);
+
+extern int GpsDrv_Read(char *buf ,int nSize);
+
+#endif //__GPSDRIVER_H___
+
--- /dev/null
+///////////////////////////////////////////////////////////////////////////////////\r
+//\r
+// Filename: gpsdrv.h\r
+// Author: sjchen\r
+// Copyright: \r
+// Date: 2012/07/09\r
+// Description:\r
+// the struct driver to app\r
+//\r
+// Revision:\r
+// 0.0.1\r
+//\r
+///////////////////////////////////////////////////////////////////////////////////\r
+#ifndef __GPSDRV_H__\r
+#define __GPSDRV_H__\r
+\r
+\r
+#define DRV_MAJOR_VERSION 1 \r
+#define DRV_MINOR_VERSION 9\r
+\r
+typedef struct __tag_BB_COMMAND_BUFFER {\r
+ int n32BufferA;\r
+ int n32BufferB;\r
+ int n32NavBuf;\r
+} BB_COMMAND_BUFFER, *PBB_COMMAND_BUFFER;\r
+\r
+\r
+typedef struct __tag_DRV_VERSION {\r
+ unsigned int u32Major;\r
+ unsigned int u32Minor;\r
+ char strCompileTime[32];\r
+\r
+}BB_DRV_VERSION,*PBB_DRV_VERSION;\r
+\r
+// IOCTL code\r
+enum\r
+{\r
+ // GPS Start\r
+ IOCTL_BB_GPS_START = 128,\r
+ IOCTL_BB_GPS_STOP,\r
+\r
+ //Update gps data\r
+ IOCTL_BB_UPDATEDATA,\r
+\r
+ //Driver version\r
+ IOCTL_BB_GET_VERSION\r
+\r
+};\r
+\r
+#endif /* __GPSDRV_H__ */\r
+\r
+\r
+\r
--- /dev/null
+/*\r
+ 2012.07.25 lby@rock-chips.com\r
+*/\r
+\r
+#ifndef __HV5820B_GPS_H__\r
+#define __HV5820B_GPS_H__\r
+\r
+struct hv5820b_gps_data {\r
+ int (*io_init)(void);\r
+ int (*power_up)(void);\r
+ int (*power_down)(void);\r
+ int (*reset)(int);\r
+ int (*enable_hclk_gps)(void);\r
+ int (*disable_hclk_gps)(void);\r
+ int GpsSign;\r
+ int GpsMag; //GPIO index\r
+ int GpsClk; //GPIO index\r
+ int GpsVCCEn; //GPIO index\r
+ int GpsSpi_CSO; //GPIO index\r
+ int GpsSpiClk; //GPIO index\r
+ int GpsSpiMOSI; //GPIO index\r
+\r
+};\r
+\r
+#endif\r
--- /dev/null
+///////////////////////////////////////////////////////////////////////////////////\r
+//\r
+// Filename: lnxdrv.h\r
+// Author: sjchen\r
+// Copyright: \r
+// Date: 2012/07/09\r
+// Description:\r
+// the macor of GPS baseband\r
+//\r
+// Revision:\r
+// 0.0.1\r
+//\r
+///////////////////////////////////////////////////////////////////////////////////\r
+\r
+#ifndef __LNXDRV_H__\r
+#define __LNXDRV_H__\r
+\r
+///////////////////////////////////////////////////////////////////////////////////\r
+// \r
+// macro declaration\r
+//\r
+///////////////////////////////////////////////////////////////////////////////////\r
+\r
+#define MEM_CHECK_BOUNDARY (16)\r
+\r
+//base band control registers offset \r
+#define BB_CTRL_OFFSET 0x0400\r
+#define BB_START_ADR_OFFSET 0x0404\r
+#define BB_DS_PAR_OFFSET 0x0408\r
+#define BB_INT_ENA_OFFSET 0x040c\r
+#define BB_INT_STATUS_OFFSET 0x0410\r
+#define BB_CHN_STATUS_OFFSET 0x0414\r
+#define BB_CHN_VALID_OFFSET 0x0418\r
+#define BB_TIMER_VAL_OFFSET 0x041c\r
+#define BB_RF_WT_ADDR_OFFSET 0x0420\r
+ \r
+ \r
+\r
+//the following is bb register bit define\r
+#define BB_RESET 0x4 \r
+#define BB_NXT_BLK 0x2 \r
+#define BB_TRICKLE 0x1 \r
+#define BB_CTRL_CLR 0x0 \r
+\r
+#define TIMEOUT_INT 0x1 \r
+#define ACC_BLK_DONE_INT 0x2 \r
+#define OBUF_RDY_INT 0x4 \r
+\r
+#endif /* __LNXDRV_H__ */\r
+\r
+\r
+\r