/*
* Driver for Freescale's 3-Axis Accelerometer MMA8450
*
- * Copyright (C) 2011 Freescale Semiconductor, Inc. All Rights Reserved.
+ * Copyright (C) 2011-2013 Freescale Semiconductor, Inc. All Rights Reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
#define MMA8450_CTRL_REG1 0x38
#define MMA8450_CTRL_REG2 0x39
+#define MMA8450_ID 0xC6
+#define MMA8450_WHO_AM_I 0x0F
/* mma8450 status */
struct mma8450 {
{
struct input_polled_dev *idev;
struct mma8450 *m;
- int err;
+ int err, client_id;
+ struct i2c_adapter *adapter = NULL;
+
+ adapter = to_i2c_adapter(c->dev.parent);
+ err = i2c_check_functionality(adapter,
+ I2C_FUNC_SMBUS_BYTE |
+ I2C_FUNC_SMBUS_BYTE_DATA);
+ if (!err)
+ goto err_out;
+
+ client_id = i2c_smbus_read_byte_data(c, MMA8450_WHO_AM_I);
+
+ if (MMA8450_ID != client_id) {
+ dev_err(&c->dev,
+ "read chip ID 0x%x is not equal to 0x%x!\n", client_id,
+ MMA8450_ID);
+ err = -EINVAL;
+ goto err_out;
+ }
m = kzalloc(sizeof(struct mma8450), GFP_KERNEL);
idev = input_allocate_polled_device();
err_free_mem:
input_free_polled_device(idev);
kfree(m);
+err_out:
return err;
}