gps:add gps support for rk2928 and rk3066b
authorlw <lw@rock-chips.com>
Mon, 17 Sep 2012 13:53:00 +0000 (21:53 +0800)
committerlw <lw@rock-chips.com>
Mon, 17 Sep 2012 13:53:32 +0000 (21:53 +0800)
arch/arm/mach-rk2928/board-rk2928-sdk.c
arch/arm/mach-rk30/board-rk3066b-sdk.c
drivers/misc/Makefile [changed mode: 0644->0755]
drivers/misc/gps/Kconfig [changed mode: 0644->0755]
drivers/misc/gps/Makefile [changed mode: 0644->0755]
drivers/misc/gps/rk_gps/Kconfig [new file with mode: 0755]
drivers/misc/gps/rk_gps/Makefile [new file with mode: 0755]
drivers/misc/gps/rk_gps/rk_gps.h [new file with mode: 0755]
drivers/misc/gps/rk_gps/rk_gps_null.c [new file with mode: 0644]

index 90dd117d379d30e10c396245487b778944074d36..aee3fce47f9b61230a3687c284a52d3c0659ce7a 100755 (executable)
 #if defined(CONFIG_SPIM_RK29)
 #include "../../../drivers/spi/rk29_spim.h"
 #endif
+#if defined(CONFIG_GPS_RK)
+#include "../../../drivers/misc/gps/rk_gps/rk_gps.h"
+#endif
+
 
 #ifdef  CONFIG_THREE_FB_BUFFER
 #define RK30_FB0_MEM_SIZE 12*SZ_1M
@@ -687,6 +691,92 @@ static struct platform_device device_acodec = {
 };
 #endif
 
+#if defined(CONFIG_GPS_RK)
+int rk_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 rk_gps_power_up(void)
+{
+       printk("%s \n", __FUNCTION__);
+
+       return 0;
+}
+
+int rk_gps_power_down(void)
+{
+       printk("%s \n", __FUNCTION__);
+
+       return 0;
+}
+
+int rk_gps_reset_set(int level)
+{
+       return 0;
+}
+int rk_enable_hclk_gps(void)
+{
+       printk("%s \n", __FUNCTION__);
+       clk_enable(clk_get(NULL, "aclk_gps"));
+       return 0;
+}
+int rk_disable_hclk_gps(void)
+{
+       printk("%s \n", __FUNCTION__);
+       clk_disable(clk_get(NULL, "aclk_gps"));
+       return 0;
+}
+struct rk_gps_data rk_gps_info = {
+       .io_init = rk_gps_io_init,
+       .power_up = rk_gps_power_up,
+       .power_down = rk_gps_power_down,
+       .reset = rk_gps_reset_set,
+       .enable_hclk_gps = rk_enable_hclk_gps,
+       .disable_hclk_gps = rk_disable_hclk_gps,
+       .GpsSign = RK2928_PIN1_PA5,
+       .GpsMag = RK2928_PIN1_PA4,        //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  
+       .GpsIrq = IRQ_GPS,
+       .GpsSpiEn = 1,
+       .GpsAdcCh = 2,
+       .u32GpsPhyAddr = RK2928_GPS_PHYS,
+       .u32GpsPhySize = RK2928_GPS_SIZE,
+};
+
+struct platform_device rk_device_gps = {
+       .name = "gps_hv5820b",
+       .id = -1,
+       .dev            = {
+       .platform_data = &rk_gps_info,
+               }
+       };
+#endif
+
+
 static struct platform_device *devices[] __initdata = {
 #ifdef CONFIG_FB_ROCKCHIP
        &device_fb,
@@ -709,6 +799,10 @@ static struct platform_device *devices[] __initdata = {
 #ifdef CONFIG_SND_SOC_RK2928
        &device_acodec,
 #endif
+#ifdef CONFIG_GPS_RK
+       &rk_device_gps,
+#endif
+
 };
 //i2c
 #ifdef CONFIG_I2C0_RK30
@@ -875,6 +969,12 @@ static void __init rk2928_reserve(void)
 #ifdef CONFIG_VIDEO_RK29
        rk30_camera_request_reserve_mem();
 #endif
+       
+#ifdef CONFIG_GPS_RK
+       //it must be more than 8MB
+       rk_gps_info.u32MemoryPhyAddr = board_mem_reserve_add("gps", SZ_8M);
+#endif
+
        board_mem_reserved();
 }
 /**
index 5d3d699a4d731428a662afcf750a588cebb27b69..3d759afba2c15f36912f21dff1b92869f020b826 100755 (executable)
 #if defined(CONFIG_SPIM_RK29)
 #include "../../../drivers/spi/rk29_spim.h"
 #endif
+#if defined(CONFIG_GPS_RK)
+#include "../../../drivers/misc/gps/rk_gps/rk_gps.h"
+#endif
+
 #if defined(CONFIG_MU509)
 #include <linux/mu509.h>
 #endif
@@ -1081,6 +1085,93 @@ static struct platform_device device_rfkill_rk = {
 };
 #endif
 
+#if defined(CONFIG_GPS_RK)
+int rk_gps_io_init(void)
+{
+       printk("%s \n", __FUNCTION__);
+       
+       rk30_mux_api_set(GPIO1B5_UART3RTSN_NAME, GPIO1B_GPIO1B5);//VCC_EN
+       gpio_request(RK30_PIN1_PB5, NULL);
+       gpio_direction_output(RK30_PIN1_PB5, GPIO_LOW);
+
+       rk30_mux_api_set(GPIO1B4_UART3CTSN_GPSRFCLK_NAME, GPIO1B_GPSRFCLK);//GPS_CLK
+       rk30_mux_api_set(GPIO1B2_UART3SIN_GPSMAG_NAME, GPIO1B_GPSMAG);//GPS_MAG
+       rk30_mux_api_set(GPIO1B3_UART3SOUT_GPSSIG_NAME, GPIO1B_GPSSIG);//GPS_SIGN
+
+       rk30_mux_api_set(GPIO1A6_UART1CTSN_SPI0CLK_NAME, GPIO1A_GPIO1A6);//SPI_CLK
+       gpio_request(RK30_PIN1_PA6, NULL);
+       gpio_direction_output(RK30_PIN1_PA6, GPIO_LOW);
+
+       rk30_mux_api_set(GPIO1A5_UART1SOUT_SPI0TXD_NAME, GPIO1A_GPIO1A5);//SPI_MOSI
+       gpio_request(RK30_PIN1_PA5, NULL);
+       gpio_direction_output(RK30_PIN1_PA5, GPIO_LOW); 
+
+       rk30_mux_api_set(GPIO1A7_UART1RTSN_SPI0CSN0_NAME, GPIO1A_GPIO1A7);//SPI_CS
+       gpio_request(RK30_PIN1_PA7, NULL);
+       gpio_direction_output(RK30_PIN1_PA7, GPIO_LOW);         
+       return 0;
+}
+int rk_gps_power_up(void)
+{
+       printk("%s \n", __FUNCTION__);
+
+       return 0;
+}
+
+int rk_gps_power_down(void)
+{
+       printk("%s \n", __FUNCTION__);
+
+       return 0;
+}
+
+int rk_gps_reset_set(int level)
+{
+       return 0;
+}
+int rk_enable_hclk_gps(void)
+{
+       printk("%s \n", __FUNCTION__);
+       clk_enable(clk_get(NULL, "hclk_gps"));
+       return 0;
+}
+int rk_disable_hclk_gps(void)
+{
+       printk("%s \n", __FUNCTION__);
+       clk_disable(clk_get(NULL, "hclk_gps"));
+       return 0;
+}
+struct rk_gps_data rk_gps_info = {
+       .io_init = rk_gps_io_init,
+       .power_up = rk_gps_power_up,
+       .power_down = rk_gps_power_down,
+       .reset = rk_gps_reset_set,
+       .enable_hclk_gps = rk_enable_hclk_gps,
+       .disable_hclk_gps = rk_disable_hclk_gps,
+       .GpsSign = RK30_PIN1_PB3,
+       .GpsMag = RK30_PIN1_PB2,        //GPIO index
+       .GpsClk = RK30_PIN1_PB4,        //GPIO index
+       .GpsVCCEn = RK30_PIN1_PB5,     //GPIO index
+       .GpsSpi_CSO = RK30_PIN1_PA4,    //GPIO index
+       .GpsSpiClk = RK30_PIN1_PA5,     //GPIO index
+       .GpsSpiMOSI = RK30_PIN1_PA7,      //GPIO index
+       .GpsIrq = IRQ_GPS,
+       .GpsSpiEn = 0,
+       .GpsAdcCh = 2,
+       .u32GpsPhyAddr = RK30_GPS_PHYS,
+       .u32GpsPhySize = RK30_GPS_SIZE,
+};
+
+struct platform_device rk_device_gps = {
+       .name = "gps_hv5820b",
+       .id = -1,
+       .dev            = {
+       .platform_data = &rk_gps_info,
+               }
+       };
+#endif
+
+
 static struct platform_device *devices[] __initdata = {
 #ifdef CONFIG_FB_ROCKCHIP
        &device_fb,
@@ -1129,6 +1220,10 @@ static struct platform_device *devices[] __initdata = {
 #ifdef CONFIG_RFKILL_RK
        &device_rfkill_rk,
 #endif
+#ifdef CONFIG_GPS_RK
+       &rk_device_gps,
+#endif
+
 };
 
 // i2c
@@ -1459,6 +1554,11 @@ static void __init rk30_reserve(void)
 #ifdef CONFIG_VIDEO_RK29
        rk30_camera_request_reserve_mem();
 #endif
+       
+#ifdef CONFIG_GPS_RK
+       //it must be more than 8MB
+       rk_gps_info.u32MemoryPhyAddr = board_mem_reserve_add("gps", SZ_8M);
+#endif
        board_mem_reserved();
 }
 
old mode 100644 (file)
new mode 100755 (executable)
index 1117e92..0bbfe1e
@@ -54,7 +54,7 @@ obj-$(CONFIG_MTK23D)          += mtk23d.o
 obj-$(CONFIG_FM580X)           += fm580x.o
 obj-$(CONFIG_RK29_SUPPORT_MODEM)       += rk29_modem/
 obj-$(CONFIG_3G_MODULE)                += 3g_module/
-obj-$(CONFIG_GPS_GNS7560)      += gps/
+obj-$(CONFIG_GPS_DEVICES)      += gps/
 obj-y += inv_mpu/
 obj-$(CONFIG_TDSC8800) += tdsc8800.o
 obj-$(CONFIG_RK29_SC8800)      +=      sc8800.o
old mode 100644 (file)
new mode 100755 (executable)
index ae012db..f690216
@@ -2,17 +2,20 @@
 # gps device configuration
 #
 
-menuconfig RK29_GPS
-       bool "RK29 support GPS"
+menuconfig GPS_DEVICES
+       bool "support GPS devices"
        default n
        ---help---
-        Say Y here if you have a support modem
+        Say Y here if you support gps
 
-if RK29_GPS
+if GPS_DEVICES
+
+source "drivers/misc/gps/rk_gps/Kconfig"       
 
 config GPS_GNS7560
        bool "gns7560 support"
        default n
+       
 
 endif # RK29_GPS
 
old mode 100644 (file)
new mode 100755 (executable)
index 6b4bdb6..66bb6f7
@@ -1,3 +1,2 @@
+obj-$(CONFIG_GPS_DEVICES)              += rk_gps/
 obj-$(CONFIG_GPS_GNS7560)    += rk29_gps.o
-
-
diff --git a/drivers/misc/gps/rk_gps/Kconfig b/drivers/misc/gps/rk_gps/Kconfig
new file mode 100755 (executable)
index 0000000..85a47c6
--- /dev/null
@@ -0,0 +1,13 @@
+#
+# gps device configuration
+#
+
+
+
+config GPS_RK
+       tristate "rk gps support"
+       default M
+
+
+
+
diff --git a/drivers/misc/gps/rk_gps/Makefile b/drivers/misc/gps/rk_gps/Makefile
new file mode 100755 (executable)
index 0000000..5399d06
--- /dev/null
@@ -0,0 +1,4 @@
+# All selected in one module named smsmdtv
+gps-objs                   := rk_gps_null.o
+obj-$(CONFIG_GPS_RK)           += gps.o
+
diff --git a/drivers/misc/gps/rk_gps/rk_gps.h b/drivers/misc/gps/rk_gps/rk_gps.h
new file mode 100755 (executable)
index 0000000..4e21aeb
--- /dev/null
@@ -0,0 +1,34 @@
+/*\r
+       2012.07.25  lby@rock-chips.com\r
+*/\r
+\r
+#ifndef __RK_GPS_H__\r
+#define __RK_GPS_H__\r
+\r
+struct rk_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
+       int    GpsSpiEn;        //USE SPI\r
+       int    GpsAdcCh;        //ADC CHANNEL\r
+       int    GpsIrq;\r
+       \r
+       unsigned long   u32GpsPhyAddr;\r
+       int             u32GpsPhySize;\r
+       unsigned long   u32MemoryPhyAddr; //must reserved 8MB memory for GPS\r
+       unsigned long   u32MemoryVirAddr;\r
+       unsigned long   u32GpsRegBase;    //GPS register base virtual address\r
+\r
+};\r
+\r
+#endif\r
diff --git a/drivers/misc/gps/rk_gps/rk_gps_null.c b/drivers/misc/gps/rk_gps/rk_gps_null.c
new file mode 100644 (file)
index 0000000..2c24bb1
--- /dev/null
@@ -0,0 +1 @@
+//for rk_gps building