summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhilippe Langlais <philippe.langlais@linaro.org>2012-01-13 12:46:53 +0100
committerPhilippe Langlais <philippe.langlais@stericsson.com>2012-05-22 11:06:10 +0200
commit78ec329add085434c6cdc5ff199b633a7431dadb (patch)
tree2a63270da03ccefcb9cebc55afb9264c5d77f37b
parente38b899c7d35e03ad9a66e40a7ca0092e34aa969 (diff)
mach-ux500: lsm303dh: Read the chip_id of LSM303
Check which accelerometer chip is mounted and read the chip ID to detect whether chip is LSM303DHL/LSM303DHLC. Signed-off-by: Naga Radhesh <naga.radheshy@stericsson.com> Signed-off-by: Philippe Langlais <philippe.langlais@linaro.org>
-rw-r--r--arch/arm/mach-ux500/board-mop500-sensors.c36
1 files changed, 35 insertions, 1 deletions
diff --git a/arch/arm/mach-ux500/board-mop500-sensors.c b/arch/arm/mach-ux500/board-mop500-sensors.c
index bc08e332699..eff8295e97a 100644
--- a/arch/arm/mach-ux500/board-mop500-sensors.c
+++ b/arch/arm/mach-ux500/board-mop500-sensors.c
@@ -146,10 +146,38 @@ void mop500_sensors_probe_add_lsm303dlh_a(void)
i2c_put_adapter(adap);
}
+/*
+ * Check which accelerometer chip is mounted on UIB and
+ * read the chip ID to detect whether chip is LSM303DHL/LSM303DHLC.
+ */
+static int mop500_get_acc_id(void)
+{
+ int status;
+ union i2c_smbus_data data;
+ struct i2c_adapter *i2c2;
+
+ i2c2 = i2c_get_adapter(2);
+ if (!i2c2) {
+ pr_err("failed to get i2c adapter\n");
+ return -1;
+ }
+ status = i2c_smbus_xfer(i2c2, 0x18 , 0 ,
+ I2C_SMBUS_READ, 0x0F ,
+ I2C_SMBUS_BYTE_DATA, &data);
+ if (status < 0) {
+ status = i2c_smbus_xfer(i2c2, 0x19 , 0 ,
+ I2C_SMBUS_READ, 0x0F ,
+ I2C_SMBUS_BYTE_DATA, &data);
+ }
+ i2c_put_adapter(i2c2);
+ return (status < 0) ? status : data.byte;
+}
+
static int __init mop500_sensors_init(void)
{
+ int ret;
- if (!machine_is_snowball() && !uib_is_stuib())
+ if (!machine_is_snowball() && !uib_is_stuib() && !uib_is_u8500uibr3())
return 0;
if (machine_is_hrefv60()) {
@@ -166,6 +194,12 @@ static int __init mop500_sensors_init(void)
lsm303dlh_pdata.irq_m = GPIO_MAGNET_DRDY;
}
+ ret = mop500_get_acc_id();
+ if (ret < 0)
+ printk(KERN_ERR " Failed to get Accelerometer chip ID\n");
+ else
+ lsm303dlh_pdata.chip_id = ret;
+
mop500_sensors_i2c_add(2, mop500_i2c2_devices,
ARRAY_SIZE(mop500_i2c2_devices));