From: lw@rock-chips.com Date: Wed, 20 Jun 2012 04:02:50 +0000 (+0800) Subject: modify gsensor lis3dh active function X-Git-Tag: firefly_0821_release~9080 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=3cdc86d854083d628af66a23cd7cd0abe530ba8d;p=firefly-linux-kernel-4.4.55.git modify gsensor lis3dh active function --- diff --git a/arch/arm/configs/rk3066_sdk_defconfig b/arch/arm/configs/rk3066_sdk_defconfig index 62da1748c241..45f44bbcccce 100755 --- a/arch/arm/configs/rk3066_sdk_defconfig +++ b/arch/arm/configs/rk3066_sdk_defconfig @@ -230,14 +230,15 @@ CONFIG_TOUCHSCREEN_GT8XX=y CONFIG_INPUT_MISC=y CONFIG_INPUT_KEYCHORD=y CONFIG_INPUT_UINPUT=y -CONFIG_MAG_SENSORS=y CONFIG_COMPASS_AK8975=y -CONFIG_G_SENSOR_DEVICE=y CONFIG_GS_LIS3DH=y -CONFIG_GYRO_SENSOR_DEVICE=y CONFIG_GYRO_L3G4200D=y -CONFIG_LIGHT_SENSOR_DEVICE=y CONFIG_LS_CM3217=y +CONFIG_SENSOR_DEVICE=y +CONFIG_GSENSOR_DEVICE=y +CONFIG_COMPASS_DEVICE=y +CONFIG_GYROSCOPE_DEVICE=y +CONFIG_LIGHT_DEVICE=y # CONFIG_SERIO is not set # CONFIG_CONSOLE_TRANSLATIONS is not set # CONFIG_LEGACY_PTYS is not set diff --git a/arch/arm/mach-rk30/board-rk30-sdk.c b/arch/arm/mach-rk30/board-rk30-sdk.c index dd136a44ff63..fd47452bc232 100755 --- a/arch/arm/mach-rk30/board-rk30-sdk.c +++ b/arch/arm/mach-rk30/board-rk30-sdk.c @@ -710,12 +710,12 @@ static int lis3dh_init_platform_hw(void) return 0; } -static struct gsensor_platform_data lis3dh_info = { - .model = 8452, - .swap_xy = 0, - .swap_xyz = 1, +static struct sensor_platform_data lis3dh_info = { + .type = SENSOR_TYPE_ACCEL, + .irq_enable = 1, + .poll_delay_ms = 30, .init_platform_hw = lis3dh_init_platform_hw, - .orientation = {0, 0, 1, 0, 1, 0, 1, 0, 0}, + .orientation = {0, 1, 0, 0, 0, 1, -1, 0, 0}, }; #endif #if defined (CONFIG_COMPASS_AK8975) @@ -1301,7 +1301,7 @@ static struct i2c_board_info __initdata i2c0_info[] = { #endif #if defined (CONFIG_GS_LIS3DH) { - .type = "lis3dh", + .type = "gs_lis3dh", .addr = 0x19, //0x19(SA0-->VCC), 0x18(SA0-->GND) .flags = 0, .irq = LIS3DH_INT_PIN, diff --git a/drivers/input/sensors/accel/lis3dh.c b/drivers/input/sensors/accel/lis3dh.c index 2a33d93624b1..ac9c059f71ad 100755 --- a/drivers/input/sensors/accel/lis3dh.c +++ b/drivers/input/sensors/accel/lis3dh.c @@ -71,10 +71,20 @@ #define LIS3DH_RANGE 2000000 /* LIS3DH */ -#define LIS3DH_PRECISION 12 +#define LIS3DH_PRECISION 16 #define LIS3DH_BOUNDARY (0x1 << (LIS3DH_PRECISION - 1)) #define LIS3DH_GRAVITY_STEP (LIS3DH_RANGE / LIS3DH_BOUNDARY) +#define ODR1 0x10 /* 1Hz output data rate */ +#define ODR10 0x20 /* 10Hz output data rate */ +#define ODR25 0x30 /* 25Hz output data rate */ +#define ODR50 0x40 /* 50Hz output data rate */ +#define ODR100 0x50 /* 100Hz output data rate */ +#define ODR200 0x60 /* 200Hz output data rate */ +#define ODR400 0x70 /* 400Hz output data rate */ +#define ODR1250 0x90 /* 1250Hz output data rate */ + + struct sensor_reg_data { char reg; @@ -92,6 +102,8 @@ static int sensor_active(struct i2c_client *client, int enable, int rate) int status = 0; sensor->ops->ctrl_data = sensor_read_reg(client, sensor->ops->ctrl_reg); + + sensor->ops->ctrl_data |= ODR100; //100HZ,if 0 then power down //register setting according to chip datasheet if(!enable)