From: lw Date: Mon, 17 Sep 2012 13:53:00 +0000 (+0800) Subject: gps:add gps support for rk2928 and rk3066b X-Git-Tag: firefly_0821_release~8618 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=2c70c8f5df8193278cb4b88d7bc0ff77ea1b8bae;p=firefly-linux-kernel-4.4.55.git gps:add gps support for rk2928 and rk3066b --- diff --git a/arch/arm/mach-rk2928/board-rk2928-sdk.c b/arch/arm/mach-rk2928/board-rk2928-sdk.c index 90dd117d379d..aee3fce47f9b 100755 --- a/arch/arm/mach-rk2928/board-rk2928-sdk.c +++ b/arch/arm/mach-rk2928/board-rk2928-sdk.c @@ -53,6 +53,10 @@ #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(); } /** diff --git a/arch/arm/mach-rk30/board-rk3066b-sdk.c b/arch/arm/mach-rk30/board-rk3066b-sdk.c index 5d3d699a4d73..3d759afba2c1 100755 --- a/arch/arm/mach-rk30/board-rk3066b-sdk.c +++ b/arch/arm/mach-rk30/board-rk3066b-sdk.c @@ -58,6 +58,10 @@ #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 #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(); } diff --git a/drivers/misc/Makefile b/drivers/misc/Makefile old mode 100644 new mode 100755 index 1117e9237945..0bbfe1e012f0 --- a/drivers/misc/Makefile +++ b/drivers/misc/Makefile @@ -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 diff --git a/drivers/misc/gps/Kconfig b/drivers/misc/gps/Kconfig old mode 100644 new mode 100755 index ae012dbcaefd..f6902169512d --- a/drivers/misc/gps/Kconfig +++ b/drivers/misc/gps/Kconfig @@ -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 diff --git a/drivers/misc/gps/Makefile b/drivers/misc/gps/Makefile old mode 100644 new mode 100755 index 6b4bdb6480c2..66bb6f730402 --- a/drivers/misc/gps/Makefile +++ b/drivers/misc/gps/Makefile @@ -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 index 000000000000..85a47c60be5d --- /dev/null +++ b/drivers/misc/gps/rk_gps/Kconfig @@ -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 index 000000000000..5399d06cfe37 --- /dev/null +++ b/drivers/misc/gps/rk_gps/Makefile @@ -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 index 000000000000..4e21aeb0a66c --- /dev/null +++ b/drivers/misc/gps/rk_gps/rk_gps.h @@ -0,0 +1,34 @@ +/* + 2012.07.25 lby@rock-chips.com +*/ + +#ifndef __RK_GPS_H__ +#define __RK_GPS_H__ + +struct rk_gps_data { + int (*io_init)(void); + int (*power_up)(void); + int (*power_down)(void); + int (*reset)(int); + int (*enable_hclk_gps)(void); + int (*disable_hclk_gps)(void); + int GpsSign; + int GpsMag; //GPIO index + int GpsClk; //GPIO index + int GpsVCCEn; //GPIO index + int GpsSpi_CSO; //GPIO index + int GpsSpiClk; //GPIO index + int GpsSpiMOSI; //GPIO index + int GpsSpiEn; //USE SPI + int GpsAdcCh; //ADC CHANNEL + int GpsIrq; + + unsigned long u32GpsPhyAddr; + int u32GpsPhySize; + unsigned long u32MemoryPhyAddr; //must reserved 8MB memory for GPS + unsigned long u32MemoryVirAddr; + unsigned long u32GpsRegBase; //GPS register base virtual address + +}; + +#endif 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 index 000000000000..2c24bb1c5aa9 --- /dev/null +++ b/drivers/misc/gps/rk_gps/rk_gps_null.c @@ -0,0 +1 @@ +//for rk_gps building