diff --git a/drivers/input/sensors/accel/mc3230.c b/drivers/input/sensors/accel/mc3230.c index d3fd5495df40..d5827f2f2bee 100644 --- a/drivers/input/sensors/accel/mc3230.c +++ b/drivers/input/sensors/accel/mc3230.c @@ -110,6 +110,8 @@ static int sensor_active(struct i2c_client *client, int enable, int rate); #define IS_MC3210 2 #define IS_MC2234 3 #define IS_MC3236 4 +#define IS_MC3413 5 +#define IS_MC3416 6 static const char backup_calib_path[] = "/data/misc/mcube-calib.txt"; static const char calib_path[] = @@ -376,13 +378,16 @@ static int mc3230_reg_init(struct i2c_client *client) } else if (pcode == 0x59) { mc32x0_type = IS_MC2234; } + if ((pcode & 0xF1) == 0x60) { mc32x0_type = IS_MC3236; + } else if ((pcode & 0xF1) == 0x10) { + mc32x0_type = IS_MC3413; + } else if ((pcode & 0xF1) == 0x20) { + mc32x0_type = IS_MC3416; } - GSE_LOG - ("MC3230 1, MC3210 2, MC2234 3, MC3236 4 : mc32x0_type=%d\n", - mc32x0_type); + GSE_LOG("MC3230 1, MC3210 2, MC2234 3, MC3236 4, MC3416 5, MC3416 6:mc32x0_type=%d\n", mc32x0_type); if ((mc32x0_type == IS_MC3230) || (mc32x0_type == IS_MC2234)) { ret = sensor_write_reg(client, 0x20, 0x32); @@ -390,14 +395,21 @@ static int mc3230_reg_init(struct i2c_client *client) ret = sensor_write_reg(client, 0x20, 0x02); } else if (mc32x0_type == IS_MC3210) { ret = sensor_write_reg(client, 0x20, 0x3F); + } else if (mc32x0_type == IS_MC3413) { + ret = sensor_write_reg(client, 0x20, 0x25); + } else if (mc32x0_type == IS_MC3416) { + ret = sensor_write_reg(client, 0x08, 0x05); + ret = sensor_write_reg(client, 0x20, 0x29); } if ((mc32x0_type == IS_MC3230) || (mc32x0_type == IS_MC2234)) { gsensor_gain.x = gsensor_gain.y = gsensor_gain.z = 86; } else if (mc32x0_type == IS_MC3236) { gsensor_gain.x = gsensor_gain.y = gsensor_gain.z = 64; - } else if (mc32x0_type == IS_MC3210) { + } else if ((mc32x0_type == IS_MC3210) || (mc32x0_type == IS_MC3413)) { gsensor_gain.x = gsensor_gain.y = gsensor_gain.z = 1024; + } else if (mc32x0_type == IS_MC3416) { + gsensor_gain.x = gsensor_gain.y = gsensor_gain.z = 4096; } return ret; @@ -524,8 +536,10 @@ static inline int mc3230_convert_to_int(s16 value) result = value * 192; } else if (mc32x0_type == IS_MC3236) { result = value * 256; - } else if (mc32x0_type == IS_MC3210) { + } else if ((mc32x0_type == IS_MC3210) || (mc32x0_type == IS_MC3413)) { result = value * 16; + } else if (mc32x0_type == IS_MC3416) { + result = value * 4; } return result; @@ -547,6 +561,10 @@ static void mc3230_report_value(struct i2c_client *client, input_report_abs(mc3230->input_dev, ABS_X, -(axis->x)); input_report_abs(mc3230->input_dev, ABS_Y, (axis->y)); input_report_abs(mc3230->input_dev, ABS_Z, -(axis->z)); + } else if (mc32x0_type == IS_MC3416) { + input_report_abs(mc3230->input_dev, ABS_X, (axis->x)); + input_report_abs(mc3230->input_dev, ABS_Y, -(axis->y)); + input_report_abs(mc3230->input_dev, ABS_Z, -(axis->z)); } else { input_report_abs(mc3230->input_dev, ABS_X, (axis->y)); input_report_abs(mc3230->input_dev, ABS_Y, (axis->x)); @@ -672,7 +690,8 @@ static int MC32X0_ReadOffset(struct i2c_client *client, u8 off_data[6]; off_data[0] = MC32X0_XOUT_EX_L_REG; - if (mc32x0_type == IS_MC3210) { + if ((mc32x0_type == IS_MC3210) || (mc32x0_type == IS_MC3413) + || (mc32x0_type == IS_MC3416)) { err = sensor_rx_data(client, off_data, MC32X0_DATA_LEN); if (err) { GSE_ERR("error: %d\n", err); @@ -895,7 +914,9 @@ static int MC32X0_ReadData(struct i2c_client *client, (s8)(gsensor_gain.z - (abs(tempX) + abs(tempY))); } - else if (mc32x0_type == IS_MC3210) { + else if ((mc32x0_type == IS_MC3210) + || (mc32x0_type == IS_MC3413) + || (mc32x0_type == IS_MC3416)) { do { memset(buf1, 0, 6); buf[0] = MC32X0_XOUT_EX_L_REG;