From 29632f032d349798a86ea27ec85c605b6575b56d Mon Sep 17 00:00:00 2001 From: Philippe Langlais Date: Tue, 18 Oct 2011 11:16:07 +0200 Subject: hwmon: add st lsm303dlh driver Signed-off-by: Mian Yousaf Kaukab Signed-off-by: Philippe Langlais --- include/linux/lsm303dlh.h | 56 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 include/linux/lsm303dlh.h (limited to 'include/linux/lsm303dlh.h') diff --git a/include/linux/lsm303dlh.h b/include/linux/lsm303dlh.h new file mode 100644 index 00000000000..d9fd6148198 --- /dev/null +++ b/include/linux/lsm303dlh.h @@ -0,0 +1,56 @@ +/* + * lsm303dlh.h + * ST 3-Axis Accelerometer/Magnetometer header file + * + * Copyright (C) 2010 STMicroelectronics + * Author: Carmine Iascone (carmine.iascone@st.com) + * Author: Matteo Dameno (matteo.dameno@st.com) + * + * Copyright (C) 2010 STEricsson + * Author: Mian Yousaf Kaukab + * Updated:Preetham Rao Kaskurthi + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 as published by + * the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program. If not, see . + */ + +#ifndef __LSM303DLH_H__ +#define __LSM303DLH_H__ + +#include + +#ifdef __KERNEL__ +struct lsm303dlh_platform_data { + + /* name of device for regulator */ + + const char *name_a; /* acelerometer name */ + const char *name_m; /* magnetometer name */ + + /* interrupt data */ + u32 irq_a1; /* interrupt line 1 of accelrometer*/ + u32 irq_a2; /* interrupt line 2 of accelrometer*/ + u32 irq_m; /* interrupt line of magnetometer*/ + + /* position of x,y and z axis */ + u8 axis_map_x; /* [0-2] */ + u8 axis_map_y; /* [0-2] */ + u8 axis_map_z; /* [0-2] */ + + /* orientation of x,y and z axis */ + u8 negative_x; /* [0-1] */ + u8 negative_y; /* [0-1] */ + u8 negative_z; /* [0-1] */ +}; +#endif /* __KERNEL__ */ + +#endif /* __LSM303DLH_H__ */ -- cgit v1.2.3 From 48eecdedd91046cea2470471bf0077d47aeee9fa Mon Sep 17 00:00:00 2001 From: Philippe Langlais Date: Thu, 20 Oct 2011 10:31:40 +0200 Subject: lsm303dlh: add DocBook documentation Adding DocBook documentation for lsm303dlh accelerometer and magnetometer drivers. ST-Ericsson ID: 277198 Change-Id: Idfca43aa6ffaa39b7f73d0135dc6d2b01a0a44c6 Signed-off-by: Chethan Krishna N Reviewed-on: http://gerrit.lud.stericsson.com/gerrit/23784 Reviewed-by: Srinidhi KASAGAR Conflicts: Documentation/DocBook/Makefile --- Documentation/DocBook/lsm303dlh.tmpl | 90 ++++++++++++++++++++++++++++++++++++ drivers/hwmon/lsm303dlh_a.c | 23 ++++++++- drivers/hwmon/lsm303dlh_m.c | 16 ++++++- include/linux/lsm303dlh.h | 45 ++++++++++-------- 4 files changed, 150 insertions(+), 24 deletions(-) create mode 100644 Documentation/DocBook/lsm303dlh.tmpl (limited to 'include/linux/lsm303dlh.h') diff --git a/Documentation/DocBook/lsm303dlh.tmpl b/Documentation/DocBook/lsm303dlh.tmpl new file mode 100644 index 00000000000..3b1c6afa65f --- /dev/null +++ b/Documentation/DocBook/lsm303dlh.tmpl @@ -0,0 +1,90 @@ + + + + + + LSM303DLH Accelerometer and Magnetometer + + + + Chethan Krishna + N + +
+ chethan.krishna@stericsson.com +
+
+
+
+ + + 2010 + ST-Ericsson + + + + + Linux standard functions + + + + + + License terms: GNU General Public License (GPL) version 2. + + + +
+ + + + + Introduction + + This documentation describes the accelerometer and magnetometer drivers for lsm303dlh sensor chip. + + + + + Known Bugs And Assumptions + + + + None + + + None. + + + + + + + + + Public Functions Provided + + This accelerometer/magnetometer drivers don't export any functions. + + + + + Structures + + This chapter contains the autogenerated documentation of the structures which are + used in the accelerometer/magnetometer drivers. + +!Iinclude/linux/lsm303dlh.h + + + + Internal Functions Provided + + This chapter contains the autogenerated documentation of the internal functions. + +!Idrivers/hwmon/lsm303dlh_a.c +!Idrivers/hwmon/lsm303dlh_m.c + + +
diff --git a/drivers/hwmon/lsm303dlh_a.c b/drivers/hwmon/lsm303dlh_a.c index 7721310be06..1436e77a0d6 100644 --- a/drivers/hwmon/lsm303dlh_a.c +++ b/drivers/hwmon/lsm303dlh_a.c @@ -149,8 +149,27 @@ struct lsm303dlh_a_t { short z; }; -/* - * accelerometer local data +/** + * struct lsm303dlh_a_data - data structure used by lsm303dlh_a driver + * @client: i2c client + * @lock: mutex lock for sysfs operations + * @data: lsm303dlh_a_t struct containing x, y and z values + * @input_dev: input device + * @input_dev2: input device + * @pdata: lsm303dlh platform data + * @regulator: regulator + * @range: current range value of accelerometer + * @mode: current mode of operation + * @rate: current sampling rate + * @sleep_wake: sleep wake setting + * @shift_adjust: current shift adjust value set according to range + * @interrupt_control: interrupt control settings + * @interrupt_channel: interrupt channel 0 or 1 + * @interrupt_configure: interrupt configurations for two channels + * @interrupt_duration: interrupt duration for two channels + * @interrupt_threshold: interrupt threshold for two channels + * @early_suspend: early suspend structure + * @device_status: device is ON, OFF or SUSPENDED */ struct lsm303dlh_a_data { struct i2c_client *client; diff --git a/drivers/hwmon/lsm303dlh_m.c b/drivers/hwmon/lsm303dlh_m.c index 8352b3d0281..42ef63157ae 100644 --- a/drivers/hwmon/lsm303dlh_m.c +++ b/drivers/hwmon/lsm303dlh_m.c @@ -125,8 +125,20 @@ #define DEVICE_ON 1 #define DEVICE_SUSPENDED 2 -/* - * magnetometer local data +/** + * struct lsm303dlh_m_data - data structure used by lsm303dlh_m driver + * @client: i2c client + * @lock: mutex lock for sysfs operations + * @input_dev: input device + * @regulator: regulator + * @pdata: lsm303dlh platform data + * @gain: x, y and z axes gain + * @data: Magnetic field values of x, y and z axes + * @mode: current mode of operation + * @rate: current sampling rate + * @range: current range value of magnetometer + * @early_suspend: early suspend structure + * @device_status: device is ON, OFF or SUSPENDED */ struct lsm303dlh_m_data { struct i2c_client *client; diff --git a/include/linux/lsm303dlh.h b/include/linux/lsm303dlh.h index d9fd6148198..ad369b1fbd5 100644 --- a/include/linux/lsm303dlh.h +++ b/include/linux/lsm303dlh.h @@ -29,27 +29,32 @@ #include #ifdef __KERNEL__ +/** + * struct lsm303dlh_platform_data - platform datastructure for lsm303dlh + * @name_a: accelerometer name + * @name_m: magnetometer name + * @irq_a1: interrupt line 1 of accelerometer + * @irq_a2: interrupt line 2 of accelerometer + * @irq_m: interrupt line of magnetometer + * @axis_map_x: x axis position on the hardware, 0 1 or 2 + * @axis_map_y: y axis position on the hardware, 0 1 or 2 + * @axis_map_z: z axis position on the hardware, 0 1 or 2 + * @negative_x: x axis is orientation, 0 or 1 + * @negative_y: y axis is orientation, 0 or 1 + * @negative_z: z axis is orientation, 0 or 1 + */ struct lsm303dlh_platform_data { - - /* name of device for regulator */ - - const char *name_a; /* acelerometer name */ - const char *name_m; /* magnetometer name */ - - /* interrupt data */ - u32 irq_a1; /* interrupt line 1 of accelrometer*/ - u32 irq_a2; /* interrupt line 2 of accelrometer*/ - u32 irq_m; /* interrupt line of magnetometer*/ - - /* position of x,y and z axis */ - u8 axis_map_x; /* [0-2] */ - u8 axis_map_y; /* [0-2] */ - u8 axis_map_z; /* [0-2] */ - - /* orientation of x,y and z axis */ - u8 negative_x; /* [0-1] */ - u8 negative_y; /* [0-1] */ - u8 negative_z; /* [0-1] */ + const char *name_a; + const char *name_m; + u32 irq_a1; + u32 irq_a2; + u32 irq_m; + u8 axis_map_x; + u8 axis_map_y; + u8 axis_map_z; + u8 negative_x; + u8 negative_y; + u8 negative_z; }; #endif /* __KERNEL__ */ -- cgit v1.2.3 From 9e48659950d6e4bca07d6f8bb169bb838bdc5ecb Mon Sep 17 00:00:00 2001 From: Naga Radhesh Date: Tue, 8 Nov 2011 17:21:03 +0530 Subject: lsm303dlh_m: Check for DLHC device to invert y,z Invert y,z co-ordinates as specified in data sheet if device is LSM303DLHC ST-Ericsson ID: 374970 ST-Ericsson Linux next: NA ST-Ericsson FOSS-OUT ID: Trivial Change-Id:I45e706e3f783dd58e02f23d9579f3422ef7fc984 Signed-off-by: Naga Radhesh Reviewed-on: http://gerrit.lud.stericsson.com/gerrit/36886 Reviewed-by: QATOOLS Reviewed-by: QABUILD Reviewed-by: Srinidhi KASAGAR Reviewed-by: QATEST Reviewed-by: Jonas ABERG --- drivers/hwmon/lsm303dlh_m.c | 23 +++++++++++++---------- include/linux/lsm303dlh.h | 2 ++ 2 files changed, 15 insertions(+), 10 deletions(-) (limited to 'include/linux/lsm303dlh.h') diff --git a/drivers/hwmon/lsm303dlh_m.c b/drivers/hwmon/lsm303dlh_m.c index 311e88fb58c..abc91ccb032 100644 --- a/drivers/hwmon/lsm303dlh_m.c +++ b/drivers/hwmon/lsm303dlh_m.c @@ -130,6 +130,9 @@ #define DEVICE_ON 1 #define DEVICE_SUSPENDED 2 +/* device CHIP ID defines */ +#define LSM303DLHC_CHIP_ID 51 + /** * struct lsm303dlh_m_data - data structure used by lsm303dlh_m driver * @client: i2c client @@ -334,16 +337,16 @@ static int lsm303dlh_m_xyz_read(struct lsm303dlh_m_data *ddata) ddata->data[2] = (short) (((xyz_data[4]) << 8) | xyz_data[5]); -#ifdef SENSORS_LSM303DLHC - /* - * the out registers are in x, z and y order - * so swap y and z values - */ - temp = ddata->data[1]; - ddata->data[1] = ddata->data[2]; - ddata->data[2] = temp; -#endif - + /* check if chip is DHLC */ + if (ddata->pdata.chip_id == LSM303DLHC_CHIP_ID) { + /* + * the out registers are in x, z and y order + * so swap y and z values + */ + temp = ddata->data[1]; + ddata->data[1] = ddata->data[2]; + ddata->data[2] = temp; + } /* taking orientation of x,y,z axis into account*/ ddata->data[ddata->pdata.axis_map_x] = ddata->pdata.negative_x ? diff --git a/include/linux/lsm303dlh.h b/include/linux/lsm303dlh.h index ad369b1fbd5..a565faa79ba 100644 --- a/include/linux/lsm303dlh.h +++ b/include/linux/lsm303dlh.h @@ -42,6 +42,7 @@ * @negative_x: x axis is orientation, 0 or 1 * @negative_y: y axis is orientation, 0 or 1 * @negative_z: z axis is orientation, 0 or 1 + * @chip_id: to store ID of the LSM chip */ struct lsm303dlh_platform_data { const char *name_a; @@ -55,6 +56,7 @@ struct lsm303dlh_platform_data { u8 negative_x; u8 negative_y; u8 negative_z; + u32 chip_id; }; #endif /* __KERNEL__ */ -- cgit v1.2.3