#include <linux/module.h>
#include <linux/notifier.h>
#include <linux/intel_mid_pm.h>
+#include <linux/input/lis3dh.h>
#include <linux/usb/penwell_otg.h>
#include <linux/hsi/hsi.h>
#include <linux/hsi/intel_mid_hsi.h>
return NULL;
}
+static void *lsm303dlhc_accel_platform_data(void *info)
+{
+ static struct lis3dh_acc_platform_data accel;
+
+ accel.poll_interval = 200;
+ accel.negate_x = 1;
+ accel.negate_y = 0;
+ accel.negate_z = 0;
+ accel.axis_map_x = 0;
+ accel.axis_map_y = 1;
+ accel.axis_map_z = 2;
+ accel.gpio_int1 = get_gpio_by_name("accel_int");
+ accel.gpio_int2 = get_gpio_by_name("accel_2");
+ accel.model = MODEL_LSM303DLHC;
+
+ return &accel;
+}
+
static void *ektf2136_spi_platform_data(void *info)
{
static int dummy;
{"ov8830", SFI_DEV_TYPE_I2C, 0, &ov8830_platform_data_init},
{"synaptics_3202", SFI_DEV_TYPE_I2C, 0, &s3202_platform_data_init},
+ {"lsm303dl", SFI_DEV_TYPE_I2C, 0, &lsm303dlhc_accel_platform_data},
+
{},
};
dev_dbg(&acc->client->dev, "hw init start\n");
- err = lis3dh_acc_i2c_read(acc, WHO_AM_I, buf, 1);
- if (err < 0) {
- dev_warn(&acc->client->dev, "Error reading WHO_AM_I: is device "
- "available/working?\n");
- goto err_firstread;
- } else {
- acc->hw_working = 1;
+ /* LSM303DLHC doesn't have WHO_AM_I register */
+ if (acc->pdata->model != MODEL_LSM303DLHC) {
+ err = lis3dh_acc_i2c_read(acc, WHO_AM_I, buf, 1);
+ if (err < 0) {
+ dev_warn(&acc->client->dev, "Error reading WHO_AM_I: "
+ "is device available/working?\n");
+ goto err_firstread;
+ }
}
+ acc->hw_working = 1;
+
buf[0] = acc->resume_state[RES_CTRL_REG1];
err = lis3dh_acc_i2c_write(acc, CTRL_REG1, buf, 1);
if (err < 0)
};
static const struct i2c_device_id lis3dh_acc_id[]
- = { { LIS3DH_ACC_DEV_NAME, 0 }, { }, };
+ = { { LIS3DH_ACC_DEV_NAME, 0 }, { "lsm303dl", 0 }, { }, };
MODULE_DEVICE_TABLE(i2c, lis3dh_acc_id);
#define LIS3DH_ACC_G_8G 0x20
#define LIS3DH_ACC_G_16G 0x30
+/* supported accelerometer model */
+enum acc_model {
+ MODEL_LIS3DH,
+ MODEL_LSM303DLHC
+};
#ifdef __KERNEL__
struct lis3dh_acc_platform_data {
*/
int gpio_int1;
int gpio_int2;
+
+ enum acc_model model;
};
#endif /* __KERNEL__ */