modify gsensor lis3dh active function

This commit is contained in:
lw@rock-chips.com
2012-06-20 12:02:50 +08:00
committed by lw
parent 2e24b8e311
commit 3cdc86d854
3 changed files with 24 additions and 11 deletions

View File

@@ -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

View File

@@ -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,

View File

@@ -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)