summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNaga RADHESH Y <naga.radheshy@stericsson.com>2012-02-14 07:47:08 +0100
committerPhilippe Langlais <philippe.langlais@linaro.org>2012-02-15 11:06:35 +0100
commita87aadbd5d960fe6eec64a96b30dfd58ad17a1ef (patch)
treea1eef49f5eaf091d6ad76968fac312b3537b07da
parentd525aabb9f015990cce09ae7e977fc62243b3b50 (diff)
mach-ux500: update Chipid by reading 0x0F register
update ChipId by reading 0x0F register,this chipid is used in megnetometer driver to differentiate b/w lsm303dlh and lsm303dlhc device. ST-Ericsson ID: - ST-Ericsson Linux next: NA ST-Ericsson FOSS-OUT ID: Trivial Signed-off-by: Naga Radhesh <naga.radheshy@stericsson.com>
-rw-r--r--arch/arm/mach-ux500/board-mop500-sensors.c33
1 files changed, 28 insertions, 5 deletions
diff --git a/arch/arm/mach-ux500/board-mop500-sensors.c b/arch/arm/mach-ux500/board-mop500-sensors.c
index bc08e332699..5ee7fec5357 100644
--- a/arch/arm/mach-ux500/board-mop500-sensors.c
+++ b/arch/arm/mach-ux500/board-mop500-sensors.c
@@ -80,7 +80,7 @@ static struct i2c_board_info __initdata mop500_2_i2c2_devices[] = {
static struct i2c_board_info __initdata snowball_i2c2_devices[] = {
{
/* LSM303DLH Accelerometer */
- I2C_BOARD_INFO("lsm303dlh_a", 0x19),
+ I2C_BOARD_INFO("lsm303dlhc_a", 0x19),
.platform_data = &lsm303dlh_pdata,
},
};
@@ -121,6 +121,7 @@ void mop500_sensors_i2c_add(int busnum, struct i2c_board_info const *info,
void mop500_sensors_probe_add_lsm303dlh_a(void)
{
static const int busnum = 2;
+ int status;
struct i2c_adapter *adap;
struct i2c_client *client;
static const unsigned short i2c_addr_list[] = {
@@ -130,6 +131,7 @@ void mop500_sensors_probe_add_lsm303dlh_a(void)
I2C_BOARD_INFO("lsm303dlh_a", 0),
.platform_data = &lsm303dlh_pdata,
};
+ union i2c_smbus_data data;
adap = i2c_get_adapter(busnum);
if (!adap) {
@@ -143,6 +145,23 @@ void mop500_sensors_probe_add_lsm303dlh_a(void)
pr_err(__FILE__ ": failed to register %s to i2c%d\n",
i2c_info.type,
busnum);
+ /* driver is different for LSM3030DLH(0x18) and LSM303DLHC(0x19)*/
+ if (i2c_info.addr == 0x19) {
+ snprintf(i2c_info.type, sizeof(i2c_info.type), "lsm303dlhc_a");
+ }
+ /*
+ * From the i2c_new_probed_device() function we will come to know
+ * the adress of the device, so read 0x0F register to get chipID.
+ * This chipID is used in magnetometer driver to invet co-ordinates.
+ */
+ status = i2c_smbus_xfer(adap, i2c_info.addr , 0 ,
+ I2C_SMBUS_READ, 0x0F ,
+ I2C_SMBUS_BYTE_DATA, &data);
+ if (status < 0) {
+ pr_err(__FILE__ ": failed to read 0x0F register\n");
+ }
+ else
+ lsm303dlh_pdata.chip_id = data.byte;
i2c_put_adapter(adap);
}
@@ -166,20 +185,24 @@ static int __init mop500_sensors_init(void)
lsm303dlh_pdata.irq_m = GPIO_MAGNET_DRDY;
}
- mop500_sensors_i2c_add(2, mop500_i2c2_devices,
- ARRAY_SIZE(mop500_i2c2_devices));
-
if (machine_is_snowball()) {
if (cpu_is_u8500v21())
/* This is ugly but we cant know what address
* to use */
mop500_sensors_probe_add_lsm303dlh_a();
- else /* Add the accelerometer with new addr */
+ else {
+ /* Add the accelerometer with new addr */
mop500_sensors_i2c_add(2, snowball_i2c2_devices,
ARRAY_SIZE(snowball_i2c2_devices));
+ /* For 0x19 accelerometer chip_id is 51*/
+ lsm303dlh_pdata.chip_id = 51;
+ }
} else /* none snowball have the old addr */
mop500_sensors_i2c_add(2, mop500_2_i2c2_devices,
ARRAY_SIZE(mop500_2_i2c2_devices));
+
+ mop500_sensors_i2c_add(2, mop500_i2c2_devices,
+ ARRAY_SIZE(mop500_i2c2_devices));
return 0;
}