summaryrefslogtreecommitdiff
path: root/driver/stm_mems_common.c
Commit message (Collapse)AuthorAgeFilesLines
* Update license boilerplate text in source code filesMike Frysinger2022-09-121-1/+1
| | | | | | | | | | | | | | | Normally we don't do this, but enough changes have accumulated that we're doing a tree-wide one-off update of the name & style. BRANCH=none BUG=chromium:1098010 TEST=`repo upload` works Change-Id: Icd3a1723c20595356af83d190b2c6a9078b3013b Signed-off-by: Mike Frysinger <vapier@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3891203 Reviewed-by: Jeremy Bettis <jbettis@chromium.org> Reviewed-by: Jack Rosenthal <jrosenth@chromium.org>
* driver: st: Enable on/off body detection to lsm6dsmGwendal Grignou2022-08-311-0/+17
| | | | | | | | | | | | | | Remove simple macro in lsm6dso and move the code to report activities to common code. BUG=b:236799854 BRANCH=dedede TEST=Compile. Check on bugzzy the EC report on/off body detection. Change-Id: I7a1713182b4ee7807a2f681a70e664d0f4eae563 Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3860189 Reviewed-by: Diana Z <dzigterman@chromium.org>
* driver/stm_mems_common.c: Format with clang-formatJack Rosenthal2022-07-011-20/+14
| | | | | | | | | | | BUG=b:236386294 BRANCH=none TEST=none Change-Id: Ia3070653d6edb3f3a5f537ef1f2e4df167421abf Signed-off-by: Jack Rosenthal <jrosenth@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3730071 Reviewed-by: Jeremy Bettis <jbettis@chromium.org>
* motion_sense: Make change in range permanentGwendal Grignou2020-11-121-4/+2
| | | | | | | | | | | | | | | | | | | | | | | | | When AP changes range, unlike offset or ODR, it was not surviving init() call. If the sensor is powered off in S3, at resume the range would be back to the default. To make it consistent with other attributes, remember range change until EC powers down. - remove get_range - add current_range to store the range currently used. This is modifiable by the AP - when the AP shutdown, revert current_range to default_range - Remove const attribute for sensor structure when init and set_range is called. BUG=chromium:1083791 BRANCH=none TEST=One eve branch, check range is preserved even after 'shutdown -h 0' Change-Id: Ia7126ac0cc9c3fef60b4464d95d6dd15e64b0fc4 Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2215751 Reviewed-by: Yuval Peress <peress@chromium.org>
* Remove __7b, __8b and __7bfDenis Brockus2019-07-201-8/+8
| | | | | | | | | | | | | | | | | | | The extentions were added to make the compiler perform most of the verification that the conversion was being done correctly to remove 8bit addressing as the standard I2C/SPI address type. Now that the compiler has verified the code, the extra extentions are being removed BUG=chromium:971296 BRANCH=none TEST=make buildall -j TEST=verify sensor functionality on arcada_ish Change-Id: I36894f8bb9daefb5b31b5e91577708f6f9af2a4f Signed-off-by: Denis Brockus <dbrockus@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1704792 Reviewed-by: Jack Rosenthal <jrosenth@chromium.org>
* Use 7bit I2C/SPI slave addresses in ECDenis Brockus2019-07-191-8/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Opt for 7bit slave addresses in EC code. If 8bit is expected by a driver, make it local and show this in the naming. Use __7b, __7bf and __8b as name extensions for i2c/spi addresses used in the EC codebase. __7b indicates a 7bit address by itself. __7bf indicates a 7bit address with optional flags attached. __8b indicates a 8bit address by itself. Allow space for 10bit addresses, even though this is not currently being used by any of our attached devices. These extensions are for verification purposes only and will be removed in the last pass of this ticket. I want to make sure the variable names reflect the type to help eliminate future 7/8/7-flags confusion. BUG=chromium:971296 BRANCH=none TEST=make buildall -j Change-Id: I2fc3d1b52ce76184492b2aaff3060f486ca45f45 Signed-off-by: Denis Brockus <dbrockus@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1699893 Reviewed-by: Jack Rosenthal <jrosenth@chromium.org>
* type: Rename vector_3_t to intv3_t.Yilun Lin2018-09-131-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Naming of many vector types and matrix types are not clear enough. For example, we have: vector_3_t, which is a vector of three int. vec3_t, which is a vector of three float. size4_t, which is a vector of four size_t. mat33_t, which is a 3x3 matrix of float. matrix_3x3_t, which is a 3x3 matrix of fixed point. Besides, we have types like int8_t, uint16_t types. To clearly distinguished types, the CL propose to, For vector types, naming should be `$type + 'v' + $num + '_t'`: vector_3_t becomes intv3_t vec3_t becomes floatv3_t vector 4 of uint16_t becomes uint16v4_t (which doesn't exist yet) For matrix types, naming should be `mat$N$N_` + $type + '_t', where $N is the matrix size: matrix_3x3_t becomes mat33_fp_t # fp: fixed point mat33_t becomes mat33_float_t TEST=make buildall -j BUG=b:114662791 Change-Id: I865aa3ecbab6cb97f8585a081a679adf00febe1d Signed-off-by: Yilun Lin <yllin@google.com> Reviewed-on: https://chromium-review.googlesource.com/1215442 Commit-Ready: Yilun Lin <yllin@chromium.org> Tested-by: Yilun Lin <yllin@chromium.org> Reviewed-by: Nicolas Boichat <drinkcat@chromium.org>
* drivers: Refactor to use high-level i2c APIsJonathan Brandmeyer2018-08-091-15/+2
| | | | | | | | | | | | | | | | | | | | | | | | Using the high-level APIs for block transfers eliminates some code duplication and error-prone manual locking sequences. - common/cbi: Block transfers - driver/accel_bma2x2: Block transfers - driver/accel_kionix: Block transfers - driver/accelgyro_bmi160: Block transfers - driver/accelgyro_lsm6ds0: Block transfers - driver/baro_bmp280: Block and byte transfers - driver/charger/rt946x: Block transfers - driver/gyro_l3gd20h: Block transfers - driver/stm_mems_common: Block transfers - driver/tcpm: Block transfers TEST=buildall; motionsense and PD testing on Grunt convertible which exercises the bma160, kionix and tcpcm drivers. BRANCH=none BUG=chromium:871851 Change-Id: I1732253a244c3343459265ce1e1e54488cee65b8 Signed-off-by: Jonathan Brandmeyer <jbrandmeyer@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1167958 Reviewed-by: Jett Rink <jettrink@chromium.org>
* phaser: add new lis2de chip typePaul Ma2018-06-301-1/+2
| | | | | | | | | | | | | | | Add new motion sense chip type MOTIONSENSE_CHIP_LIS2DE and make ectool support it. also use +/- 2g range for lis2de to get one extra bit of precision. BRANCH=none BUG=b:110604678 TEST=boot phaser360 board, run 'ectool motionsense info 0' Change-Id: Idd8a797e5a8b38efcd0a4ac47eb584534106fb86 Signed-off-by: Paul Ma <magf@bitland.corp-partner.google.com> Reviewed-on: https://chromium-review.googlesource.com/1118094 Reviewed-by: Jett Rink <jettrink@chromium.org>
* phaser: fix lis2de resolution and sensor value outputPaul Ma2018-06-271-2/+5
| | | | | | | | | | | | | | | | | | | | | | lis2de only support 8-bit resolution. This is what is different from lis2dh. This patch add two defines (CONFIG_ACCEL_LIS2DH and CONFIG_ACCEL_LIS2DE) to defferientiate them. For calculate_lid_angle() reliable calculation, code asks for 16 bits sensor value output, this patch fix that as well. Signed-off-by: Paul Ma <magf@bitland.corp-partner.google.com> BRANCH=none BUG=b:110604678 TEST=boot phaser360 board, use 'accelinfo on' to watch lid output and angle output, lid axis value should be 16 bit range and angle is correct. Change-Id: If77954ecf477736b9168b3a3b6805396a3201a57 Reviewed-on: https://chromium-review.googlesource.com/1111775 Commit-Ready: Paul Ma <magf@bitland.corp-partner.google.com> Tested-by: Paul Ma <magf@bitland.corp-partner.google.com> Reviewed-by: Jett Rink <jettrink@chromium.org>
* stm: inline raw_read8 in header fileJett Rink2018-05-041-20/+2
| | | | | | | | | | | | | | | | Rename raw_read8 to st_raw_read8 and statically inline in the header file. Removing the extern removes linker warnings when including this header file without the driver, which happens in baseboard files. BRANCH=none BUG=none TEST=including "driver/accelgyro_lsm6dsm.h" in c files that do not link the actual driver will now compile. Change-Id: I43f799a3b05b2343e012d43bdc9459d138ecf1b5 Signed-off-by: Jett Rink <jettrink@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1042727 Reviewed-by: Randall Spangler <rspangler@chromium.org>
* driver: lsm6dsm/lsm6dsl: Add FIFO supportMario Tesi2018-04-051-5/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Added FIFO support to Acc and Gyro with watermark interrupt management. Watermark is configurable setting macro CONFIG_ACCEL_FIFO_THRES properly (board.h) BUG=b:73546254 BRANCH=master TEST=Pass CTS test cheets_CTS_N.7.1_r15.x86.CtsHardwareTestCases on meowth. TEST=Tested on discovery (target stmems) BOARD with LSM6DSM connected to EC i2c master bus. Using motion sense console commands is possible to: - enable sensor (accelinit 0, accelinit 1 for acc and gyro) - set ODR (accelrate 0 x, accelrate 1 y where x, y are mHz) - show sensor data (accelinfo on <time> where time is in ms) Using this procedure is possible to see Green Led of Discovery Board Blinking each time an interrupt from FIFO arrives. To be sure to generate interrupt is better to use high ODR and low time in accelinfo. Change-Id: Icf95b0e889dc806206b8ca50e74636e6a2441a18 Signed-off-by: Mario Tesi <mario.tesi@st.com> Reviewed-on: https://chromium-review.googlesource.com/467326 Commit-Ready: Gwendal Grignou <gwendal@chromium.org> Tested-by: Gwendal Grignou <gwendal@chromium.org> Reviewed-by: Gwendal Grignou <gwendal@chromium.org>
* driver: lsm6dsm/lsm6dsl/lis2dh: Use STM MEMs common functionsGwendal Grignou2018-03-191-31/+38
| | | | | | | | | | | | | | | | | | | LSM6DSM now use STM MEMs common functions already used by LIS2DH12 device. Added st_raw_read_n_noinc function to read i2c data not using auto increment protocol. BUG=b:73546254 BRANCH=master TEST=Tested on discovery BOARD with LSM6DSM sensor connected on I2C master bus interface of target board. Using motion sense console commands is possible to enable, set data rate, set full scale and show data from sensor (acc and gyro). Commons function works properly for LSM6DSM. Change-Id: I7a987306135a85abcfa9c1d3ba596fb70598fadc Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/465376
* driver: sensor: Remove set_resolution when NOOPGwendal Grignou2018-03-151-13/+0
| | | | | | | | | | | | | | set_resolution is only used for few sensors and is not exposed to the AP. Remove definition when sensors have a fixed resolution. BUG=none BRANCH=master TEST=compile, kevin has enough space for perform_calib. Change-Id: I8482387e135356467edaee44da3a0e47cf1db524 Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/961222 Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
* lis2dh: code cleanupGwendal Grignou2017-02-131-19/+15
| | | | | | | | | | | | | | | | | | | | | Make FIFO a stack variable to save static memory, Remove auto_inc argument, always set Remove constant for rate 0. Force board to declare sensor private data. Avoid name collision in stm_mems_common Include stm_mems_common.h in accel_lis2dh.h, caller only need to include accel_lis2dh.h. BUG=none BRANCH=none TEST=Compile with discovery_stmems board. Change-Id: Id52b54dd4ec3cf217247c5511ad5a506067ad293 Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/441144 Tested-by: mario tesi <mario.tesi@st.com> Reviewed-by: Aseda Aboagye <aaboagye@chromium.org> Reviewed-by: mario tesi <mario.tesi@st.com>
* driver: accel: Add acc driver basics and FIFO for LIS2DH/LIS2DH12Mario Tesi2017-02-091-0/+182
Add driver for acc sensor ST lis2dh/lis2dh12 Support interrupt management for FIFO watermark Starting to share common code with other devices like lsm6dsm/lsm6dsl (acc/gyro) or new lis2mdl (mag) TODO: Add all embedded functions support (click, tap and so on) BUG=none BRANCH=master TEST=Tested on discovery BOARD with sensor connected on EC i2c master bus. Added motion sense task on discovery board task list, added gpio info in board configuration file and tested with motion sense console commands. Data for acc seems ok: can successfully change ODR and full scale range. Also FIFO and interrupt tested Device tested is lis2dh (lis2dh12 simply differs for low pin count but share the same registers) Change-Id: I16abeac3f139a604094b38d8d8b857a62c93a242 Signed-off-by: Mario Tesi <mario.tesi@st.com> Reviewed-on: https://chromium-review.googlesource.com/412700 Commit-Ready: mario tesi <mario.tesi@st.com> Tested-by: mario tesi <mario.tesi@st.com> Reviewed-by: Gwendal Grignou <gwendal@chromium.org>