aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/iio/chemical/bme680.h (follow)
AgeCommit message (Collapse)AuthorFilesLines
2019-03-09iio:chemical:bme680: Fix SPI read interfaceMike Looijmans1-4/+2
The SPI interface implementation was completely broken. When using the SPI interface, there are only 7 address bits, the upper bit is controlled by a page select register. The core needs access to both ranges, so implement register read/write for both regions. The regmap paging functionality didn't agree with a register that needs to be read and modified, so I implemented a custom paging algorithm. This fixes that the device wouldn't even probe in SPI mode. The SPI interface then isn't different from I2C, merged them into the core, and the I2C/SPI named registers are no longer needed. Implemented register value caching for the registers to reduce the I2C/SPI data transfers considerably. The calibration set reads as all zeroes until some undefined point in time, and I couldn't determine what makes it valid. The datasheet mentions these registers but does not provide any hints on when they become valid, and they aren't even enumerated in the memory map. So check the calibration and retry reading it from the device after each measurement until it provides something valid. Despite the size this is suitable for a stable backport given that it seems the SPI support never worked. Signed-off-by: Mike Looijmans <mike.looijmans@topic.nl> Fixes: 1b3bd8592780 ("iio: chemical: Add support for Bosch BME680 sensor"); Cc: <Stable@vger.kernel.org> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2018-08-25iio: chemical: bme680: Remove field value definesDavid Frey1-2/+0
Remove BME680_RUN_GAS_EN_BIT and BME680_NB_CONV_0_VAL field value definitions because the fields are simply boolean and integer respectively. Signed-off-by: David Frey <dpfrey@gmail.com> Reviewed-by: Himanshu Jha <himanshujha199640@gmail.com> Tested-by: Himanshu Jha <himanshujha199640@gmail.com> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2018-08-19iio: chemical: bme680: use GENMASK macroDavid Frey1-4/+4
Replace hardcoded bit masks with GENMASK macro Signed-off-by: David Frey <dpfrey@gmail.com> Reviewed-by: Himanshu Jha <himanshujha199640@gmail.com> Tested-by: Himanshu Jha <himanshujha199640@gmail.com> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2018-08-19iio: chemical: bme680: change MSK->MASK in #definesDavid Frey1-3/+3
Convert all defines to use "MASK" instead of a mix of "MSK" and "MASK" Signed-off-by: David Frey <dpfrey@gmail.com> Reviewed-by: Himanshu Jha <himanshujha199640@gmail.com> Tested-by: Himanshu Jha <himanshujha199640@gmail.com> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2018-08-19iio: chemical: bme680: indent #defines consistentlyDavid Frey1-8/+7
Signed-off-by: David Frey <dpfrey@gmail.com> Reviewed-by: Himanshu Jha <himanshujha199640@gmail.com> Tested-by: Himanshu Jha <himanshujha199640@gmail.com> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2018-07-28iio: chemical: Add support for Bosch BME680 sensorHimanshu Jha1-0/+96
Bosch BME680 is a 4-in-1 sensor with temperature, pressure, humidity and gas sensing capability. It supports both I2C and SPI communication protocol for effective data communication. The device supports two modes: 1. Sleep mode 2. Forced mode The measurements only takes place when forced mode is triggered and a single TPHG cycle is performed by the sensor. The sensor automatically goes to sleep after afterwards. The device has various calibration constants/parameters programmed into devices' non-volatile memory(NVM) during production and can't be altered by the user. These constants are used in the compensation functions to get the required compensated readings along with the raw data. The compensation functions/algorithms are provided by Bosch Sensortec GmbH via their API[1]. As these don't change during the measurement cycle, therefore we read and store them at the probe. The default configs supplied by Bosch are also set at probe. 0-day tested with build success. GSoC-2018: https://summerofcode.withgoogle.com/projects/#6691473790074880 Mentor: Daniel Baluta [1] https://github.com/BoschSensortec/BME680_driver Datasheet: https://ae-bst.resource.bosch.com/media/_tech/media/datasheets/BST-BME680-DS001-00.pdf Note from Jonathan: The compensation functions are 'interesting' and could do with a tidy up in future. However, they work so we can leave that for another day. Cc: Daniel Baluta <daniel.baluta@nxp.com> Signed-off-by: Himanshu Jha <himanshujha199640@gmail.com> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>