iio: temperature: mlx90635 Driver for MLX90635 IR temperature sensor
Subsystems (3)
Crt Mori
maintainercover iio: temperature: mlx90635 Driver for MLX90635 IR temperature sensor
Hi everybody,
There is a new contactless sensor in Melexis portfolio. MLX90635 is just 1.8x1.8mm in size, but with factory calibration offers instant usage in every project. It offers wide refresh rate range that is configurable between 100ms and 4s.
Driver currently provides temperature calculations, power management and changes to the refresh rate. Since sensor is aimed towards the consumer market there is really low number of EEPROM write cycles available, so driver changes refresh rate only in run time registers to avoid writing to EEPROM. Reading EEPROM is not available in Sleep Step mode, so I am using caching at the driver initialization to ensure that measurements can still be taken in Sleep Step mode.
Crt Mori (2):
iio: temperature: mlx90635 MLX90635 IR Temperature sensor
dt-bindings: iio: temperature: add MLX90635 device bindings
.../iio/temperature/melexis,mlx90635.yaml | 60 + MAINTAINERS | 7 + drivers/iio/temperature/Kconfig | 12 + drivers/iio/temperature/Makefile | 1 + drivers/iio/temperature/mlx90635.c | 1099 +++++++++++++++++ 5 files changed, 1179 insertions(+) create mode 100644 Documentation/devicetree/bindings/iio/temperature/melexis,mlx90635.yaml create mode 100644 drivers/iio/temperature/mlx90635.c
Signature · 1 line
2.40.1
Crt Mori
maintainerPATCH 1/2 iio: temperature: mlx90635 MLX90635 IR Temperature sensor
MLX90635 is an Infra Red contactless temperature sensor most suitable for consumer applications where measured object temperature is in range between -20 to 100 degrees Celsius. It has improved accuracy for measurements within temperature range of human body and can operate in ambient temperature range between -20 to 85 degrees Celsius.
Driver provides simple power management possibility as it returns to lowest possible power mode (Step sleep mode) in which temperature measurements can still be performed, yet for continuous measuring it switches to Continuous power mode where measurements constantly change without triggering.
--- MAINTAINERS | 7 + drivers/iio/temperature/Kconfig | 12 + drivers/iio/temperature/Makefile | 1 + drivers/iio/temperature/mlx90635.c | 1099 ++++++++++++++++++++++++++++ 4 files changed, 1119 insertions(+) create mode 100644 drivers/iio/temperature/mlx90635.c
MAINTAINERS +7 -0
@@ -13725,6 +13725,13 @@ S: Supported W: http://www.melexis.com F: drivers/iio/temperature/mlx90632.c +MELEXIS MLX90635 DRIVER +M: Crt Mori <[email protected]> +L: [email protected] +S: Supported +W: http://www.melexis.com +F: drivers/iio/temperature/mlx90635.c + MELFAS MIP4 TOUCHSCREEN DRIVER M: Sangwon Jee <[email protected]> S: Supported
drivers/iio/temperature/Kconfig +12 -0
@@ -76,6 +76,18 @@ config MLX90632 This driver can also be built as a module. If so, the module will be called mlx90632. +config MLX90635 + tristate "MLX90635 contact-less infrared sensor with medical accuracy" + depends on I2C + select REGMAP_I2C + help + If you say yes here you get support for the Melexis + MLX90635 contact-less infrared sensor with medical accuracy + connected with I2C. + + This driver can also be built as a module. If so, the module will + be called mlx90635. + config TMP006 tristate "TMP006 infrared thermopile sensor" depends on I2C
drivers/iio/temperature/Makefile +1 -0
@@ -13,6 +13,7 @@ obj-$(CONFIG_MAX31865) += max31865.o obj-$(CONFIG_MCP9600) += mcp9600.o obj-$(CONFIG_MLX90614) += mlx90614.o obj-$(CONFIG_MLX90632) += mlx90632.o +obj-$(CONFIG_MLX90632) += mlx90635.o obj-$(CONFIG_TMP006) += tmp006.o obj-$(CONFIG_TMP007) += tmp007.o obj-$(CONFIG_TMP117) += tmp117.o
drivers/iio/temperature/mlx90635.c new file +1099 -0
1,099 lines not on this page · raw message
Signature · 1 line
2.40.1
kernel test robot
build botRe: [PATCH 1/2] iio: temperature: mlx90635 MLX90635 IR Temperature sensor
kernel test robot noticed the following build warnings:
Hi Crt,
kernel test robot noticed the following build warnings:
[auto build test WARNING on jic23-iio/togreg]
[also build test WARNING on linus/master v6.7-rc2 next-20231124] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Crt-Mori/iio-temperature-mlx90635-MLX90635-IR-Temperature-sensor/20231122-202635 base: https://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio.git togreg patch link: https://lore.kernel.org/r/aa36393700ff783274894186366a152bb27e58ff.1700648165.git.cmo%40melexis.com patch subject: [PATCH 1/2] iio: temperature: mlx90635 MLX90635 IR Temperature sensor config: x86_64-randconfig-122-20231123 (https://download.01.org/0day-ci/archive/20231124/[email protected]/config) compiler: clang version 16.0.4 (https://github.com/llvm/llvm-project.git ae42196bc493ffe877a7e3dff8be32035dea4d07) reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20231124/[email protected]/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
All warnings (new ones prefixed by >>):
>> drivers/iio/temperature/mlx90635.c:380:12: warning: logical not is only applied to the left hand side of this comparison [-Wlogical-not-parentheses]
!(reg_status & MLX90635_STAT_END_CONV) == 0,
^ ~~
include/linux/regmap.h:124:58: note: expanded from macro 'regmap_read_poll_timeout'
__tmp = read_poll_timeout(regmap_read, __ret, __ret || (cond), \
^~~~
include/linux/iopoll.h:47:7: note: expanded from macro 'read_poll_timeout'
if (cond) \
^~~~
drivers/iio/temperature/mlx90635.c:380:12: note: add parentheses after the '!' to evaluate the comparison first
drivers/iio/temperature/mlx90635.c:380:12: note: add parentheses around left hand side expression to silence this warning
>> drivers/iio/temperature/mlx90635.c:380:12: warning: logical not is only applied to the left hand side of this comparison [-Wlogical-not-parentheses]
!(reg_status & MLX90635_STAT_END_CONV) == 0,
^ ~~
include/linux/regmap.h:124:58: note: expanded from macro 'regmap_read_poll_timeout'
__tmp = read_poll_timeout(regmap_read, __ret, __ret || (cond), \
^~~~
include/linux/iopoll.h:58:3: note: expanded from macro 'read_poll_timeout'
(cond) ? 0 : -ETIMEDOUT; \
^~~~ drivers/iio/temperature/mlx90635.c:380:12: note: add parentheses after the '!' to evaluate the comparison first drivers/iio/temperature/mlx90635.c:380:12: note: add parentheses around left hand side expression to silence this warning 2 warnings generated.
vim +380 drivers/iio/temperature/mlx90635.c
356
357 static int mlx90635_perform_measurement_burst(struct mlx90635_data *data)
358 {
359 unsigned int reg_status;
360 int refresh_time;
361 int ret;
362
363 ret = regmap_write_bits(data->regmap, MLX90635_REG_STATUS,
364 MLX90635_STAT_END_CONV, MLX90635_STAT_END_CONV);
365 if (ret < 0)
366 return ret;
367
368 ret = mlx90635_calculate_dataset_ready_time(data, &refresh_time);
369 if (ret < 0)
370 return ret;
371
372 ret = regmap_write_bits(data->regmap, MLX90635_REG_CTRL2,
373 MLX90635_CTRL2_SOB(1), MLX90635_CTRL2_SOB(1));
374 if (ret < 0)
375 return ret;
376
377 msleep(refresh_time); /* Wait minimum time for dataset to be ready */
378
379 ret = regmap_read_poll_timeout(data->regmap, MLX90635_REG_STATUS, reg_status,
> 380 !(reg_status & MLX90635_STAT_END_CONV) == 0,
381 MLX90635_TIMING_POLLING, MLX90635_READ_RETRIES * 10000);
382 if (ret < 0) {
383 dev_err(&data->client->dev, "data not ready");
384 return -ETIMEDOUT;
385 }
386
387 return ret;
388 }
389
Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki
Jonathan Cameron
maintainerRe: [PATCH 1/2] iio: temperature: mlx90635 MLX90635 IR Temperature sensor
In reply to Crt MoriQuoted 6 lines · On Wed, 22 Nov 2023 11:24:06 +0100 Crt Mori <[email protected]> wrote:
MLX90635 is an Infra Red contactless temperature sensor most suitable for consumer applications where measured object temperature is in range between -20 to 100 degrees Celsius. It has improved accuracy for measurements within temperature range of human body and can operate in ambient temperature range between -20 to 85 degrees Celsius.
Quoted 7 lines
Driver provides simple power management possibility as it returns to lowest possible power mode (Step sleep mode) in which temperature measurements can still be performed, yet for continuous measuring it switches to Continuous power mode where measurements constantly change without triggering.
Signed-off-by Crt Mori<[email protected]>
Hi Crt,
Very nice. A few minor bits inline.
Note (as normal for me), I haven't sanity checked any calibration maths - just assuming you got that bit right as don't want to spend ages comparing datasheet maths to what you have coded up + I'm not sure I can get the datasheet anyway :)
Jonathan
Quoted 1 line
drivers/iio/temperature/mlx90635.c +0
-0
...
drivers/iio/temperature/mlx90635.c line 27
Quoted 3 lines
drivers/iio/temperature/mlx90635.c +3
-0+ +#include <linux/iio/iio.h> +#include <linux/iio/sysfs.h>
Needed? Rarely needed in a driver that hasn't had to do custom ABI and I don't see any here.
drivers/iio/temperature/mlx90635.c line 90
Quoted 12 lines
drivers/iio/temperature/mlx90635.c +12
-0+ +/* Control register2 address - volatile */ +#define MLX90635_REG_CTRL2 0x0016/* Control Register2 address */ +#define MLX90635_CTRL2_BURST_CNT_SHIFT 6/* Burst count */ +#define MLX90635_CTRL2_BURST_CNT_MASK GENMASK(MLX90635_CTRL2_BURST_CNT_SHIFT + 4, MLX90635_CTRL2_BURST_CNT_SHIFT) +#define MLX90635_CTRL2_BURST (ctrl_val) (ctrl_val << MLX90635_CTRL2_BURST_CNT_SHIFT) +#define MLX90635_CTRL2_MODE_SHIFT 11/* Power mode */ +#define MLX90635_CTRL2_MODE_MASK GENMASK(MLX90635_CTRL2_MODE_SHIFT + 1, MLX90635_CTRL2_MODE_SHIFT) +#define MLX90635_CTRL2_MODE (ctrl_val) (ctrl_val << MLX90635_CTRL2_MODE_SHIFT) +#define MLX90635_CTRL2_SOB_SHIFT 15/* Start burst measurement in step mode */ +#define MLX90635_CTRL2_SOB_MASK BIT(MLX90635_CTRL2_SOB_SHIFT) +#define MLX90635_CTRL2_SOB (ctrl_val) (ctrl_val << MLX90635_CTRL2_SOB_SHIFT)
Can't do these with mask and FIELD_PREP() to simplify the macros + ensure any passed in value doesn't overwrite neighbouring fields?
drivers/iio/temperature/mlx90635.c line 114
Quoted 3 lines
drivers/iio/temperature/mlx90635.c +3
-0+/* Magic constants */ +#define MLX90635_ID_DSPv1 0x01/* EEPROM DSP version */ +#define MLX90635_RESET_CMD 0x0006/**< Reset sensor (address or global) */
Why the /**< syntax?
drivers/iio/temperature/mlx90635.c line 123
Quoted 9 lines
drivers/iio/temperature/mlx90635.c +9
-0+#define MLX90635_MAX_MEAS_NUM 31/**< Maximum number of measurements in list */ +#define MLX90635_PTAT_DIV 12/**< Used to divide the PTAT value in pre-processing */ +#define MLX90635_IR_DIV 24/**< Used to divide the IR value in pre-processing */ +#define MLX90635_SLEEP_DELAY_MS 6000/* Autosleep delay */ +#define MLX90635_MEAS_MAX_TIME 2000/* Max measurement time in ms for the lowest refresh rate */ +#define MLX90635_READ_RETRIES 100/* Number of read retries before quitting with timeout error */ +#define MLX90635_VERSION_MASK (GENMASK(15, 12) | GENMASK(7, 4)) +#define MLX90635_DSP_VERSION (reg) ((reg & GENMASK(6, 4)) >> 3) +#define MLX90635_DSP_FIXED (BIT(15))
Possible to have too many brackets. I'd drop them around the BIT()
Quoted 8 lines
drivers/iio/temperature/mlx90635.c +5
-0+ +static int mlx90635_wakeup (struct mlx90635_data *data) +{ +s16 Fb, Ga, Gb, Ha, Hb,PG ,PO ; +u32 Ea, Eb, Fa;
drivers/iio/temperature/mlx90635.c line 856
Quoted 10 lines
drivers/iio/temperature/mlx90635.c +10
-0+u16 Fa_scale; +int ret; + +regcache_cache_bypass (data->regmap, false); + ret =mlx90635_pwr_continuous (data); +if (ret <0 ) { +dev_err (&data->client->dev,"Switch to continuous mode failed\n" ); +return ret; + } + ret =regmap_write_bits (data->regmap,MLX90635_REG_EE ,MLX90635_EE_ACTIVE ,MLX90635_EE_ACTIVE );
Long line. Add a break somewhere sensible.
Quoted 6 lines
drivers/iio/temperature/mlx90635.c +6
-0+if (ret <0 ) { +dev_err (&data->client->dev,"Powering EEPROM failed\n" ); +return ret; + } +usleep_range (MLX90635_TIMING_EE_ACTIVE_MIN ,MLX90635_TIMING_EE_ACTIVE_MAX ); +
drivers/iio/temperature/mlx90635.c line 872
Quoted 10 lines
drivers/iio/temperature/mlx90635.c +10
-0+regcache_mark_dirty (data->regmap); + + ret =regcache_sync (data->regmap); +if (ret <0 ) { +dev_err (&data->client->dev, +"Failed to cache everything: %d\n" , ret); +return ret; + } + + ret =regcache_sync_region (data->regmap, MLX90635_EE_Ha, MLX90635_EE_Gb);
Why is this needed given you just synced the whole thing?
Quoted 11 lines
drivers/iio/temperature/mlx90635.c +11
-0+if (ret <0 ) { +dev_err (&data->client->dev, +"Failed to sync EEEPROM region: %d\n" , ret); +return ret; + } + + ret =mlx90635_read_ee_ambient (data->regmap, &PG , &PO , &Gb); +if (ret <0 ) { +dev_err (&data->client->dev, +"Failed to read to cache Ambient coefficients EEPROM region: %d\n" , ret); +return ret;
drivers/iio/temperature/mlx90635.c line 893
Quoted 10 lines
drivers/iio/temperature/mlx90635.c +10
-0+ } + + ret =mlx90635_read_ee_object (data->regmap, &Ea, &Eb, &Fa, &Fb, &Ga, &Gb, &Ha, &Hb, &Fa_scale); +if (ret <0 ) { +dev_err (&data->client->dev, +"Failed to read to cache Object coefficients EEPROM region: %d\n" , ret); +return ret; + } + + ret =regmap_async_complete (data->regmap);
What is this syncing here for? Several calls above include internal calls to this. My knowledge of this stuff is limited, so I may well be misunderstanding what this does.
Quoted 8 lines
drivers/iio/temperature/mlx90635.c +8
-0+if (ret <0 ) { +dev_err (&data->client->dev, +"Failed to complete sync: %d\n" , ret); +return ret; + } + +return ret; +}
...
drivers/iio/temperature/mlx90635.c line 931
Quoted 3 lines
drivers/iio/temperature/mlx90635.c +3
-0+static int mlx90635_probe (struct i2c_client *client) +{ +const struct i2c_device_id *id =i2c_client_get_device_id (client);
Shouldn't do this in a modern driver because of fragility I mention below. Use the generic stuff to access data if you need it (but you don't here).
Quoted 6 lines
drivers/iio/temperature/mlx90635.c +6
-0+struct mlx90635_data *mlx90635; +struct iio_dev *indio_dev; +unsigned int dsp_version; +struct regmap *regmap; +int ret; +
drivers/iio/temperature/mlx90635.c line 947
Quoted 10 lines
drivers/iio/temperature/mlx90635.c +10
-0+ indio_dev =devm_iio_device_alloc (&client->dev,sizeof (*mlx90635)); +if (!indio_dev) { +dev_err (&client->dev,"Failed to allocate device\n" ); +return -ENOMEM ; + } + + regmap =devm_regmap_init_i2c (client, &mlx90635_regmap); +if (IS_ERR (regmap)) { + ret =PTR_ERR (regmap); +dev_err (&client->dev,"Failed to allocate regmap: %d\n" , ret);
return dev_err_probe() for all messages in probe and things only called from probe. It's neater, handles the ret printing and even does deferred handling correctly if that's relevant. Also, if you used it everywhere I don't have to think about what might defer which makes for easier reviews :)
drivers/iio/temperature/mlx90635.c line 958
Quoted 11 lines
drivers/iio/temperature/mlx90635.c +11
-0+return ret; + } + + mlx90635 =iio_priv (indio_dev); +i2c_set_clientdata (client, indio_dev); + mlx90635->client = client; + mlx90635->regmap = regmap; + mlx90635->powerstatus =MLX90635_PWR_STATUS_SLEEP_STEP ; + +mutex_init (&mlx90635->lock); + indio_dev->name = id->name;
Not keen on doing this as it can be fragile if id and of tables get out of sync or we are using backwards compatibles in dt bindings.
Given only one part supported, just hard code the name for now.
Quoted 32 lines
drivers/iio/temperature/mlx90635.c +32
-0+ indio_dev->modes =INDIO_DIRECT_MODE ; + indio_dev->info = &mlx90635_info; + indio_dev->channels = mlx90635_channels; + indio_dev->num_channels =ARRAY_SIZE (mlx90635_channels); + + mlx90635->regulator =devm_regulator_get (&client->dev,"vdd" ); +if (IS_ERR (mlx90635->regulator)) +return dev_err_probe (&client->dev,PTR_ERR (mlx90635->regulator), +"failed to get vdd regulator" ); + + ret =mlx90635_enable_regulator (mlx90635); +if (ret <0 ) +return ret; + + ret =devm_add_action_or_reset (&client->dev, mlx90635_disable_regulator, + mlx90635); +if (ret <0 ) { +dev_err (&client->dev,"Failed to setup regulator cleanup action %d\n" , + ret); +return ret; + } + + ret =mlx90635_wakeup (mlx90635); +if (ret <0 ) { +dev_err (&client->dev,"Wakeup failed: %d\n" , ret); +return ret; + } + + ret =devm_add_action_or_reset (&client->dev, mlx90635_sleep, mlx90635); +if (ret <0 ) { +dev_err (&client->dev,"Failed to setup low power cleanup action %d\n" , + ret);
drivers/iio/temperature/mlx90635.c line 999
Quoted 10 lines
drivers/iio/temperature/mlx90635.c +9
-0+return ret; + } + + ret =regmap_read (mlx90635->regmap,MLX90635_EE_VERSION , &dsp_version); +if (ret <0 ) { +dev_err (&client->dev,"read of version failed: %d\n" , ret); +return ret; + } + dsp_version = dsp_version &MLX90635_VERSION_MASK ;
FIELD_GET() always preferred as then I don't need to wonder if there is an offset for the field or not as it will be handled correctly either way
drivers/iio/temperature/mlx90635.c line 1003
Quoted 4 lines
drivers/iio/temperature/mlx90635.c +4
-0+if (MLX90635_DSP_VERSION (dsp_version) == MLX90635_ID_DSPv1) { +dev_dbg (&client->dev, +"Detected DSP v1 calibration %x\n" , dsp_version); + }else if ((dsp_version &MLX90635_DSP_FIXED ) ==MLX90635_DSP_FIXED ) {
FIELD_GET() for that bit then just check if it is 0 or 1
drivers/iio/temperature/mlx90635.c line 1009
Quoted 6 lines
drivers/iio/temperature/mlx90635.c +6
-0+dev_dbg (&client->dev, +"Detected Unknown EEPROM calibration %lx\n" ,MLX90635_DSP_VERSION (dsp_version)); + }else { +dev_err (&client->dev, +"Wrong fixed top bit %lx (expected 0x8X0X)\n" , + dsp_version &MLX90635_DSP_FIXED );
I'd like to understand what breaks if this happens but we carry on anyway?
I'd 'hope' that any future DSP version is backwards compatible or that there was some way to know if the difference between backwards compatible versions and ones that aren't.
Quoted 2 lines
drivers/iio/temperature/mlx90635.c +2
-0+return -EPROTONOSUPPORT ; + }
...
drivers/iio/temperature/mlx90635.c line 1034
Quoted 3 lines
drivers/iio/temperature/mlx90635.c +3
-0+ +static const struct i2c_device_id mlx90635_id[] = { + {"mlx90635" ,0 },
The 0 is unnecessary so I'd drop it.
drivers/iio/temperature/mlx90635.c line 1043
Quoted 9 lines
drivers/iio/temperature/mlx90635.c +9
-0+ { } +}; +MODULE_DEVICE_TABLE (i2c, mlx90635_id); + +static const struct of_device_id mlx90635_of_match[] = { + { .compatible ="melexis,mlx90635" }, + { } +}; +MODULE_DEVICE_TABLE (of, mlx90635_of_match);
Thanks,
Jonathan
Crt Mori
maintainerRe: [PATCH 1/2] iio: temperature: mlx90635 MLX90635 IR Temperature sensor
Quoted 19 lines · Jonathan Cameron
Quoted 6 lines · On Wed, 22 Nov 2023 11:24:06 +0100 Crt Mori <[email protected]> wrote:
MLX90635 is an Infra Red contactless temperature sensor most suitable for consumer applications where measured object temperature is in range between -20 to 100 degrees Celsius. It has improved accuracy for measurements within temperature range of human body and can operate in ambient temperature range between -20 to 85 degrees Celsius.
Quoted 7 lines
Driver provides simple power management possibility as it returns to lowest possible power mode (Step sleep mode) in which temperature measurements can still be performed, yet for continuous measuring it switches to Continuous power mode where measurements constantly change without triggering.
Signed-off-by Crt Mori<[email protected]>Hi Crt,
Quoted 8 lines
Very nice. A few minor bits inline.
Note (as normal for me), I haven't sanity checked any calibration maths - just assuming you got that bit right as don't want to spend ages comparing datasheet maths to what you have coded up + I'm not sure I can get the datasheet anyway :)
Jonathan
Hi Jonathan,
Maths I have unit tests where I did floating point (which will be released as embedded library same as for 90632) to integer conversion and ensure that the delta is less then the error of the sensor. So math I take full responsibility :)
Datasheet will be public probably in March, when hopefully the sensor is already part of the main Android kernel as well. But your review is anyway very valuable and detailed. Thanks for all the remarks - there is just one discussion below I would love to complete for future reference.
Best regards,
Crt
Quoted 11 lines
Quoted 11 lines
...
drivers/iio/temperature/mlx90635.c new file +10
-0+if (ret <0 ) { +dev_err (&data->client->dev,"Powering EEPROM failed\n" ); +return ret; + } +usleep_range (MLX90635_TIMING_EE_ACTIVE_MIN ,MLX90635_TIMING_EE_ACTIVE_MAX ); + +regcache_mark_dirty (data->regmap); + + ret =regcache_sync (data->regmap); +if (ret <0 ) {
Quoted 9 lines
drivers/iio/temperature/mlx90635.c line 872
Quoted 6 lines
drivers/iio/temperature/mlx90635.c new file +6
-0+dev_err (&data->client->dev, +"Failed to cache everything: %d\n" , ret); +return ret; + } + + ret =regcache_sync_region (data->regmap, MLX90635_EE_Ha, MLX90635_EE_Gb);Why is this needed given you just synced the whole thing?
Well, this is the discussion I wanted to have. I expected regcache_sync to perform i2c read of all the read_regs defined in regmap to get them to cache - but it didn't. Then I expected the same from sync_region, but it didn't, so I manually read them below.
So discussion I want to have is: why would we regcache_sync, if no reads are performed? And second one is why would we return EBUSY for volatile register range when cache_only is active?
Current driver implementation is very specific in bypassing all these, so I am quite certain this regcache_sync_region here is not needed and below regmap_async_complete as well, but I cannot be sure, since regcache_sync doesn't really do the job I would expect it to do. I looked into the code, but could not find the reason, why I do not see any reads on oscilloscope and why I need to physically read registers below, so that they are cached. regmap totally knows which registers it should cache, but it does not at init, nor at regcache_sync request. And if you remember in 90632 I had a similar remark, but could not reproduce as EEPROM was readable in most powermodes (well all used in driver), now I checked with scope and since I know this chip does not allow EEPROM reading during the step sleep mode, so everything was much easier to conclude.
Quoted 36 lines
Quoted 11 lines
drivers/iio/temperature/mlx90635.c new file +11
-0+if (ret <0 ) { +dev_err (&data->client->dev, +"Failed to sync EEEPROM region: %d\n" , ret); +return ret; + } + + ret =mlx90635_read_ee_ambient (data->regmap, &PG , &PO , &Gb); +if (ret <0 ) { +dev_err (&data->client->dev, +"Failed to read to cache Ambient coefficients EEPROM region: %d\n" , ret); +return ret;drivers/iio/temperature/mlx90635.c line 893
Quoted 10 lines
drivers/iio/temperature/mlx90635.c new file +10
-0+ } + + ret =mlx90635_read_ee_object (data->regmap, &Ea, &Eb, &Fa, &Fb, &Ga, &Gb, &Ha, &Hb, &Fa_scale); +if (ret <0 ) { +dev_err (&data->client->dev, +"Failed to read to cache Object coefficients EEPROM region: %d\n" , ret); +return ret; + } + + ret =regmap_async_complete (data->regmap);What is this syncing here for? Several calls above include internal calls to this. My knowledge of this stuff is limited, so I may well be misunderstanding what this does.
Quoted 8 lines
drivers/iio/temperature/mlx90635.c new file +8
-0+if (ret <0 ) { +dev_err (&data->client->dev, +"Failed to complete sync: %d\n" , ret); +return ret; + } + +return ret; +}...
...
Quoted 9 lines
drivers/iio/temperature/mlx90635.c line 958
Quoted 8 lines
drivers/iio/temperature/mlx90635.c new file +8
-0+ mlx90635 =iio_priv (indio_dev); +i2c_set_clientdata (client, indio_dev); + mlx90635->client = client; + mlx90635->regmap = regmap; + mlx90635->powerstatus =MLX90635_PWR_STATUS_SLEEP_STEP ; + +mutex_init (&mlx90635->lock); + indio_dev->name = id->name;
Quoted 5 lines
Not keen on doing this as it can be fragile if id and of tables get out of sync or we are using backwards compatibles in dt bindings.
Given only one part supported, just hard code the name for now.
Can you elaborate? Because I have the same thing in 90632 and I would fix there as well. I assumed this is for linking to dt, to ensure it is defined there?
Quoted 5 lines
Quoted 5 lines
drivers/iio/temperature/mlx90635.c new file +5
-0+ indio_dev->modes =INDIO_DIRECT_MODE ; + indio_dev->info = &mlx90635_info; + indio_dev->channels = mlx90635_channels; + indio_dev->num_channels =ARRAY_SIZE (mlx90635_channels); +
...
Quoted 15 lines
drivers/iio/temperature/mlx90635.c line 1003
Quoted 5 lines
drivers/iio/temperature/mlx90635.c new file +4
-0+if (MLX90635_DSP_VERSION (dsp_version) == MLX90635_ID_DSPv1) { +dev_dbg (&client->dev, +"Detected DSP v1 calibration %x\n" , dsp_version); + }else if ((dsp_version &MLX90635_DSP_FIXED ) ==MLX90635_DSP_FIXED ) {
FIELD_GET()for that bit then just check if it is 0 or 1drivers/iio/temperature/mlx90635.c line 1009
Quoted 6 lines
drivers/iio/temperature/mlx90635.c new file +6
-0+dev_dbg (&client->dev, +"Detected Unknown EEPROM calibration %lx\n" ,MLX90635_DSP_VERSION (dsp_version)); + }else { +dev_err (&client->dev, +"Wrong fixed top bit %lx (expected 0x8X0X)\n" , + dsp_version &MLX90635_DSP_FIXED );
Quoted 4 lines
I'd like to understand what breaks if this happens but we carry on anyway?
I'd 'hope' that any future DSP version is backwards compatible or that there was some way to know if the difference between backwards compatible versions and ones that aren't.
The top bit in high nibble is fixed to 1, to ensure that we have endianness correct in the wild. We did the same later on in 90632 where we had plenty of trouble the way people read 16 bits. So if that top bit is not there (bottom nibble has it hardcoded to 0), then for certain we do not have the correct chip. And as for compatible DSP
versions: when we release incompatible one, I will upgrade the driver, otherwise we have some more slack in the driver to keep on working, because that was also lesson learnt from my side in 90632 as there are compatible DSP versions possible and used, but we are still honest and bump also the DSP version here.
Quoted 5 lines
Quoted 2 lines
drivers/iio/temperature/mlx90635.c new file +2
-0+return -EPROTONOSUPPORT ; + }...
Jonathan Cameron
maintainerRe: [PATCH 1/2] iio: temperature: mlx90635 MLX90635 IR Temperature sensor
Quoted 63 lines · On Sat, 25 Nov 2023 22:26:46 +0100 Crt Mori <[email protected]> wrote:
Quoted 19 lines · Jonathan Cameron
Quoted 6 lines · On Wed, 22 Nov 2023 11:24:06 +0100 Crt Mori <[email protected]> wrote:
MLX90635 is an Infra Red contactless temperature sensor most suitable for consumer applications where measured object temperature is in range between -20 to 100 degrees Celsius. It has improved accuracy for measurements within temperature range of human body and can operate in ambient temperature range between -20 to 85 degrees Celsius.
Quoted 7 lines
Driver provides simple power management possibility as it returns to lowest possible power mode (Step sleep mode) in which temperature measurements can still be performed, yet for continuous measuring it switches to Continuous power mode where measurements constantly change without triggering.
Signed-off-by Crt Mori<[email protected]>Hi Crt,
Quoted 8 lines
Very nice. A few minor bits inline.
Note (as normal for me), I haven't sanity checked any calibration maths - just assuming you got that bit right as don't want to spend ages comparing datasheet maths to what you have coded up + I'm not sure I can get the datasheet anyway :)
Jonathan
Hi Jonathan,
Maths I have unit tests where I did floating point (which will be released as embedded library same as for 90632) to integer conversion and ensure that the delta is less then the error of the sensor. So math I take full responsibility :)Datasheet will be public probably in March, when hopefully the sensor is already part of the main Android kernel as well. But your review is anyway very valuable and detailed. Thanks for all the remarks - there is just one discussion below I would love to complete for future reference.
Best regards,
CrtQuoted 11 lines
Quoted 11 lines
...
drivers/iio/temperature/mlx90635.c new file +10
-0+if (ret <0 ) { +dev_err (&data->client->dev,"Powering EEPROM failed\n" ); +return ret; + } +usleep_range (MLX90635_TIMING_EE_ACTIVE_MIN ,MLX90635_TIMING_EE_ACTIVE_MAX ); + +regcache_mark_dirty (data->regmap); + + ret =regcache_sync (data->regmap); +if (ret <0 ) {Quoted 9 lines
drivers/iio/temperature/mlx90635.c line 872
Quoted 6 lines
drivers/iio/temperature/mlx90635.c new file +6
-0+dev_err (&data->client->dev, +"Failed to cache everything: %d\n" , ret); +return ret; + } + + ret =regcache_sync_region (data->regmap, MLX90635_EE_Ha, MLX90635_EE_Gb);Why is this needed given you just synced the whole thing?
Quoted 7 lines
Well, this is the discussion I wanted to have. I expected
regcache_syncto perform i2c read of all theread_regsdefined in regmap to get them to cache - but it didn't. Then I expected the same fromsync_region, but it didn't, so I manually read them below.So discussion I want to have is: why would we
regcache_sync, if no reads are performed?
I think the intent is to minimise the reads from the device.
If we look at the implmentation (which is probably the default here) you can see that it's only doing writes where non volatile registers are out of date. I don't think there are any reads from the device done.
https://elixir.bootlin.com/linux/latest/source/drivers/base/regmap/regcache.c#L310
If you want to ensure the cache contains the correct values a read will need to be forced.
Quoted 2 lines
And second one is why would we return EBUSY for volatile register range when
cache_onlyis active?
I'd say that's correct. We are in a state where any attempt to read a volatile register can't get the current correct value, so returning -EBUSY which basically says come back later is the correct behaviour.
Quoted 8 lines
Current driver implementation is very specific in bypassing all these, so I am quite certain this
regcache_sync_regionhere is not needed and belowregmap_async_completeas well, but I cannot be sure, sinceregcache_syncdoesn't really do the job I would expect it to do. I looked into the code, but could not find the reason, why I do not see any reads on oscilloscope and why I need to physically read registers below, so that they are cached.
I agree the docs are a little vague, but looking at the code there aren't any reads, only writes to the device so I think this behaviour is by design. The cache is considered correctly synced if an entry is simply not cached (valid I suppose as no wrong values cached).
Quoted 7 lines
regmap totally knows which registers
it should cache, but it does not at init, nor atregcache_syncrequest. And if you remember in 90632 I had a similar remark, but could not reproduce as EEPROM was readable in most powermodes (well all used in driver), now I checked with scope and since I know this chip does not allow EEPROM reading during the step sleep mode, so everything was much easier to conclude.
I think the key here is that the cache isn't really meant to provide access to values when the device is powered down; it is there to reduce bus traffic. Hence the last thing you normally want to do is read back all the values. There is a way to get that to happen on init though.
You want to hit this path:
https://elixir.bootlin.com/linux/latest/source/drivers/base/regmap/regcache.c#L183
I think you set num_reg_defaults_raw = Number of registers, but don't provide any default values, so as to indicate they should be read from the device.
Quoted 13 lines
...
Quoted 12 lines
drivers/iio/temperature/mlx90635.c line 958
Quoted 8 lines
drivers/iio/temperature/mlx90635.c new file +8
-0+ mlx90635 =iio_priv (indio_dev); +i2c_set_clientdata (client, indio_dev); + mlx90635->client = client; + mlx90635->regmap = regmap; + mlx90635->powerstatus =MLX90635_PWR_STATUS_SLEEP_STEP ; + +mutex_init (&mlx90635->lock); + indio_dev->name = id->name;Not keen on doing this as it can be fragile if id and of tables get out of sync or we are using backwards compatibles in dt bindings.
Quoted 6 lines
Quoted 2 lines
Given only one part supported, just hard code the name for now.
Can you elaborate? Because I have the same thing in 90632 and I would fix there as well. I assumed this is for linking to dt, to ensure it is defined there?
Exactly, the dt table and the i2c_id one can end up out of sync - perhaps deliberately and when compatible = "device1", "device2" is used I'm not sure exactly which one will turn up in this id if the dt table only includes device2.
So rather than arguing that out and pinning down the expected behaviour we tend to avoid using id->name in new drivers.
It's probably not broken to do so but lets make life easier for any future cases by not doing it.
Quoted 26 lines
Quoted 6 lines
Quoted 6 lines
drivers/iio/temperature/mlx90635.c new file +5
-0+ indio_dev->modes =INDIO_DIRECT_MODE ; + indio_dev->info = &mlx90635_info; + indio_dev->channels = mlx90635_channels; + indio_dev->num_channels =ARRAY_SIZE (mlx90635_channels); +...
Quoted 15 lines
drivers/iio/temperature/mlx90635.c line 1003
Quoted 5 lines
drivers/iio/temperature/mlx90635.c new file +4
-0+if (MLX90635_DSP_VERSION (dsp_version) == MLX90635_ID_DSPv1) { +dev_dbg (&client->dev, +"Detected DSP v1 calibration %x\n" , dsp_version); + }else if ((dsp_version &MLX90635_DSP_FIXED ) ==MLX90635_DSP_FIXED ) {
FIELD_GET()for that bit then just check if it is 0 or 1drivers/iio/temperature/mlx90635.c line 1009
Quoted 6 lines
drivers/iio/temperature/mlx90635.c new file +6
-0+dev_dbg (&client->dev, +"Detected Unknown EEPROM calibration %lx\n" ,MLX90635_DSP_VERSION (dsp_version)); + }else { +dev_err (&client->dev, +"Wrong fixed top bit %lx (expected 0x8X0X)\n" , + dsp_version &MLX90635_DSP_FIXED );Quoted 4 lines
I'd like to understand what breaks if this happens but we carry on anyway?
I'd 'hope' that any future DSP version is backwards compatible or that there was some way to know if the difference between backwards compatible versions and ones that aren't.
Quoted 10 lines
The top bit in high nibble is fixed to 1, to ensure that we have endianness correct in the wild. We did the same later on in 90632 where we had plenty of trouble the way people read 16 bits. So if that top bit is not there (bottom nibble has it hardcoded to 0), then for certain we do not have the correct chip. And as for compatible DSP
versions: when we release incompatible one, I will upgrade the driver, otherwise we have some more slack in the driver to keep on working, because that was also lesson learnt from my side in 90632 as there are compatible DSP versions possible and used, but we are still honest and bump also the DSP version here.
So there isn't a clear division between 'minor and major' version numbers as used in many similar cases? Minor can tick without a driver change as the interface only grows (nothing breaks), but major implies incompatible.
Anyhow, sounds like you carry on with just a dbg print if an unexpected version seen. That's fine.
Jonathan
Crt Mori
maintainerRe: [PATCH 1/2] iio: temperature: mlx90635 MLX90635 IR Temperature sensor
Quoted 46 lines · Jonathan Cameron
Quoted 42 lines · On Sat, 25 Nov 2023 22:26:46 +0100 Crt Mori <[email protected]> wrote:
Quoted 19 lines · Jonathan Cameron
Quoted 6 lines · On Wed, 22 Nov 2023 11:24:06 +0100 Crt Mori <[email protected]> wrote:
MLX90635 is an Infra Red contactless temperature sensor most suitable for consumer applications where measured object temperature is in range between -20 to 100 degrees Celsius. It has improved accuracy for measurements within temperature range of human body and can operate in ambient temperature range between -20 to 85 degrees Celsius.
Quoted 7 lines
Driver provides simple power management possibility as it returns to lowest possible power mode (Step sleep mode) in which temperature measurements can still be performed, yet for continuous measuring it switches to Continuous power mode where measurements constantly change without triggering.
Signed-off-by Crt Mori<[email protected]>Hi Crt,
Quoted 8 lines
Very nice. A few minor bits inline.
Note (as normal for me), I haven't sanity checked any calibration maths - just assuming you got that bit right as don't want to spend ages comparing datasheet maths to what you have coded up + I'm not sure I can get the datasheet anyway :)
Jonathan
Hi Jonathan,
Maths I have unit tests where I did floating point (which will be released as embedded library same as for 90632) to integer conversion and ensure that the delta is less then the error of the sensor. So math I take full responsibility :)Datasheet will be public probably in March, when hopefully the sensor is already part of the main Android kernel as well. But your review is anyway very valuable and detailed. Thanks for all the remarks - there is just one discussion below I would love to complete for future reference.
Best regards,
Crt
...
Quoted 22 lines
Quoted 2 lines
any reads on oscilloscope and why I need to physically read registers below, so that they are cached.
I agree the docs are a little vague, but looking at the code there aren't any reads, only writes to the device so I think this behaviour is by design. The cache is considered correctly synced if an entry is simply not cached (valid I suppose as no wrong values cached).
Quoted 7 lines
regmap totally knows which registers
it should cache, but it does not at init, nor atregcache_syncrequest. And if you remember in 90632 I had a similar remark, but could not reproduce as EEPROM was readable in most powermodes (well all used in driver), now I checked with scope and since I know this chip does not allow EEPROM reading during the step sleep mode, so everything was much easier to conclude.I think the key here is that the cache isn't really meant to provide access to values when the device is powered down; it is there to reduce bus traffic. Hence the last thing you normally want to do is read back all the values. There is a way to get that to happen on init though.
Quoted 5 lines
You want to hit this path:
https://elixir.bootlin.com/linux/latest/source/drivers/base/regmap/regcache.c#L183
I think you setnum_reg_defaults_raw= Number of registers, but don't provide any default values, so as to indicate they should be read from the device.
Ok, then I have understood this correctly I should only retain regcache_sync and abandon any other call to sync or complete and just rely on the natural state of the cache (and the toggling of the cache_only flag I am doing here). Will roll v2 with that, after I confirm it still works.
Quoted 25 lines
Quoted 13 lines
...
Quoted 12 lines
drivers/iio/temperature/mlx90635.c line 958
Quoted 8 lines
drivers/iio/temperature/mlx90635.c new file +8
-0+ mlx90635 =iio_priv (indio_dev); +i2c_set_clientdata (client, indio_dev); + mlx90635->client = client; + mlx90635->regmap = regmap; + mlx90635->powerstatus =MLX90635_PWR_STATUS_SLEEP_STEP ; + +mutex_init (&mlx90635->lock); + indio_dev->name = id->name;Not keen on doing this as it can be fragile if id and of tables get out of sync or we are using backwards compatibles in dt bindings.
Quoted 6 lines
Quoted 2 lines
Given only one part supported, just hard code the name for now.
Can you elaborate? Because I have the same thing in 90632 and I would fix there as well. I assumed this is for linking to dt, to ensure it is defined there?
Exactly, the dt table and the
i2c_idone can end up out of sync - perhaps deliberately and when compatible = "device1", "device2" is used I'm not sure exactly which one will turn up in this id if the dt table only includes device2.
Quoted 6 lines
So rather than arguing that out and pinning down the expected behaviour we tend to avoid using
id->namein new drivers.
It's probably not broken to do so but lets make life easier for any future cases by not doing it.
Ok, will also roll the fix for the existing two drivers.
Quoted 1 line
Quoted 1 line
...
Quoted 16 lines
Quoted 5 lines
Quoted 5 lines
I'd like to understand what breaks if this happens but we carry on anyway?
I'd 'hope' that any future DSP version is backwards compatible or that there was some way to know if the difference between backwards compatible versions and ones that aren't.Quoted 10 lines
The top bit in high nibble is fixed to 1, to ensure that we have endianness correct in the wild. We did the same later on in 90632 where we had plenty of trouble the way people read 16 bits. So if that top bit is not there (bottom nibble has it hardcoded to 0), then for certain we do not have the correct chip. And as for compatible DSP
versions: when we release incompatible one, I will upgrade the driver, otherwise we have some more slack in the driver to keep on working, because that was also lesson learnt from my side in 90632 as there are compatible DSP versions possible and used, but we are still honest and bump also the DSP version here.
Quoted 7 lines
So there isn't a clear division between 'minor and major' version numbers as used in many similar cases? Minor can tick without a driver change as the interface only grows (nothing breaks), but major implies incompatible.
Anyhow, sounds like you carry on with just a dbg print if an unexpected version seen. That's fine.
I am trying to convince them to do that, but your comment will provide me some leverage for my case. As usual, I was assured there would be no DSPv2 anyway. Thanks for the feedback.
Crt
Quoted 5 lines
Jonathan
Crt Mori
maintainerPATCH 2/2 dt-bindings: iio: temperature: add MLX90635 device bindings
In reply to Crt MoriAdd device tree bindings for MLX90635 Infra Red contactless temperature sensor.
--- .../iio/temperature/melexis,mlx90635.yaml | 60 +++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 Documentation/devicetree/bindings/iio/temperature/melexis,mlx90635.yaml
Documentation/devicetree/bindings/iio/temperature/melexis,mlx90635.yaml new file +60 -0
@@ -0,0 +1,60 @@ +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/iio/temperature/melexis,mlx90635.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Melexis MLX90635 contactless Infra Red temperature sensor + +maintainers: + - Crt Mori <[email protected]> + +description: | + https://www.melexis.com/en/documents/documentation/datasheets/datasheet-mlx90635 + + There are various applications for the Infra Red contactless temperature + sensor and MLX90635 is most suitable for consumer applications where + measured object temperature is in range between -20 to 100 degrees + Celsius with relative error of measurement 2 degree Celsius in + object temperature range for industrial applications, while just 0.2 + degree Celsius for human body measurement applications. Since it can + operate and measure ambient temperature in range of -20 to 85 degrees + Celsius it is suitable also for outdoor use. + + Be aware that electronics surrounding the sensor can increase ambient + temperature. MLX90635 can be calibrated to reduce the housing effect via + already existing EEPROM parameters. + + Since measured object emissivity effects Infra Red energy emitted, + emissivity should be set before requesting the object temperature. + +properties: + compatible: + const: melexis,mlx90635 + + reg: + maxItems: 1 + description: Default is 0x3a, but can be reprogrammed. + + vdd-supply: + description: provide VDD power to the sensor (check datasheet for voltage). + +required: + - compatible + - reg + +additionalProperties: false + +examples: + - | + i2c { + #address-cells = <1>; + #size-cells = <0>; + + temp-sensor@3a { + compatible = "melexis,mlx90635"; + reg = <0x3a>; + vdd-supply = <&ldo4_reg>; + }; + }; +...
Signature · 1 line
2.40.1
Re: [PATCH 2/2] dt-bindings: iio: temperature: add MLX90635 device bindings
Quoted 2 lines · Crt Mori
Add device tree bindings for MLX90635 Infra Red contactless temperature sensor.
Please use scripts/get_maintainers.pl to get a list of necessary people and lists to CC (and consider --no-git-fallback argument). It might happen, that command when run on an older kernel, gives you outdated entries. Therefore please be sure you base your patches on recent Linux kernel.
A nit, subject: drop second/last, redundant "bindings". The "dt-bindings" prefix is already stating that these are bindings.
Quoted 36 lines
Signed-off-by Crt Mori <[email protected]>--- .../iio/temperature/melexis,mlx90635.yaml | 60 +++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 Documentation/devicetree/bindings/iio/temperature/melexis,mlx90635.yamlDocumentation/devicetree/bindings/iio/temperature/melexis,mlx90635.yaml new file +23
-0@@ -0,0 +1,60 @@ +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/iio/temperature/melexis,mlx90635.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Melexis MLX90635 contactless Infra Red temperature sensor + +maintainers: + - Crt Mori <[email protected]> + +description: | + https://www.melexis.com/en/documents/documentation/datasheets/datasheet-mlx90635 + + There are various applications for the Infra Red contactless temperature + sensor and MLX90635 is most suitable for consumer applications where + measured object temperature is in range between -20 to 100 degrees + Celsius with relative error of measurement 2 degree Celsius in + object temperature range for industrial applications, while just 0.2 + degree Celsius for human body measurement applications. Since it can + operate and measure ambient temperature in range of -20 to 85 degrees + Celsius it is suitable also for outdoor use. +
Documentation/devicetree/bindings/iio/temperature/melexis,mlx90635.yaml line 33
Quoted 10 lines
Documentation/devicetree/bindings/iio/temperature/melexis,mlx90635.yaml new file +10
-0+ Be aware that electronics surrounding the sensor can increase ambient + temperature. MLX90635 can be calibrated to reduce the housing effect via + already existing EEPROM parameters. + + Since measured object emissivity effects Infra Red energy emitted, + emissivity should be set before requesting the object temperature. + +properties: + compatible: + const: melexis,mlx90635
It's the same as mlx90632. Add it there (as enum).
Best regards,
Krzysztof
Crt Mori
maintainerRe: [PATCH 2/2] dt-bindings: iio: temperature: add MLX90635 device bindings
Quoted 11 lines · Krzysztof Kozlowski
Quoted 2 lines · Crt Mori
Add device tree bindings for MLX90635 Infra Red contactless temperature sensor.
Please use
scripts/get_maintainers.plto get a list of necessary people and lists to CC (and consider --no-git-fallback argument). It might happen, that command when run on an older kernel, gives you outdated entries. Therefore please be sure you base your patches on recent Linux kernel.
OK, will put everyone in that list in next spin.
Quoted 3 lines
A nit, subject: drop second/last, redundant "bindings". The "dt-bindings" prefix is already stating that these are bindings.
Ok, will fix that in next version (probably main driver review will
get some comments).
Quoted 40 lines
Quoted 40 lines
Signed-off-by Crt Mori <[email protected]>--- .../iio/temperature/melexis,mlx90635.yaml | 60 +++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 Documentation/devicetree/bindings/iio/temperature/melexis,mlx90635.yamlDocumentation/devicetree/bindings/iio/temperature/melexis,mlx90635.yaml new file +27
-0@@ -0,0 +1,60 @@ +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/iio/temperature/melexis,mlx90635.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Melexis MLX90635 contactless Infra Red temperature sensor + +maintainers: + - Crt Mori <[email protected]> + +description: | + https://www.melexis.com/en/documents/documentation/datasheets/datasheet-mlx90635 + + There are various applications for the Infra Red contactless temperature + sensor and MLX90635 is most suitable for consumer applications where + measured object temperature is in range between -20 to 100 degrees + Celsius with relative error of measurement 2 degree Celsius in + object temperature range for industrial applications, while just 0.2 + degree Celsius for human body measurement applications. Since it can + operate and measure ambient temperature in range of -20 to 85 degrees + Celsius it is suitable also for outdoor use. + + Be aware that electronics surrounding the sensor can increase ambient + temperature. MLX90635 can be calibrated to reduce the housing effect via + already existing EEPROM parameters. +
Quoted 9 lines
Documentation/devicetree/bindings/iio/temperature/melexis,mlx90635.yaml line 33
Quoted 6 lines
Documentation/devicetree/bindings/iio/temperature/melexis,mlx90635.yaml new file +6
-0+ Since measured object emissivity effects Infra Red energy emitted, + emissivity should be set before requesting the object temperature. + +properties: + compatible: + const: melexis,mlx90635It's the same as mlx90632. Add it there (as enum).
Properties are the same, but then you can't have much differences for a temperature sensor. It has a bit worse relative measurement error outside of the human body range and overall different DSP, register map, even physical size - it's 1.8x1.8 mm compared to 90632 3x3 mm. I was not sure how it qualifies for adding it as another enum, but I went with the feeling that if it can reuse the driver, then it is an enum, otherwise it is a new file. And I could not reuse anything from 90632.
Thanks for quick feedback and best regards,
Crt
Quoted 3 lines
Best regards,
Krzysztof
Re: [PATCH 2/2] dt-bindings: iio: temperature: add MLX90635 device bindings
Quoted 19 lines · Crt Mori
Quoted 9 lines
Documentation/devicetree/bindings/iio/temperature/melexis,mlx90635.yaml line 33
Quoted 6 lines
Documentation/devicetree/bindings/iio/temperature/melexis,mlx90635.yaml new file +6
-0+ Since measured object emissivity effects Infra Red energy emitted, + emissivity should be set before requesting the object temperature. + +properties: + compatible: + const: melexis,mlx90635It's the same as mlx90632. Add it there (as enum).
Properties are the same, but then you can't have much differences for a temperature sensor. It has a bit worse relative measurement error outside of the human body range and overall different DSP, register map, even physical size - it's 1.8x1.8 mm compared to 90632 3x3 mm. I was not sure how it qualifies for adding it as another enum, but I went with the feeling that if it can reuse the driver, then it is an enum, otherwise it is a new file. And I could not reuse anything from 90632.
Quoted 1 line
Thanks for quick feedback and best regards,
Driver is independent choice. There is no need for new binding file if everything is the same from bindings point of view.
Best regards,
Krzysztof
Jonathan Cameron
maintainerRe: [PATCH 2/2] dt-bindings: iio: temperature: add MLX90635 device bindings
Quoted 20 lines · On Wed, 22 Nov 2023 13:35:19 +0100 Krzysztof Kozlowski <[email protected]> wrote:
Quoted 19 lines · Crt Mori
Quoted 9 lines
Documentation/devicetree/bindings/iio/temperature/melexis,mlx90635.yaml line 33
Quoted 6 lines
Documentation/devicetree/bindings/iio/temperature/melexis,mlx90635.yaml new file +6
-0+ Since measured object emissivity effects Infra Red energy emitted, + emissivity should be set before requesting the object temperature. + +properties: + compatible: + const: melexis,mlx90635It's the same as mlx90632. Add it there (as enum).
Properties are the same, but then you can't have much differences for a temperature sensor. It has a bit worse relative measurement error outside of the human body range and overall different DSP, register map, even physical size - it's 1.8x1.8 mm compared to 90632 3x3 mm. I was not sure how it qualifies for adding it as another enum, but I went with the feeling that if it can reuse the driver, then it is an enum, otherwise it is a new file. And I could not reuse anything from 90632.
Quoted 9 lines
Quoted 1 line
Thanks for quick feedback and best regards,
Driver is independent choice. There is no need for new binding file if everything is the same from bindings point of view.
Best regards,
Krzysztof
We got this wrong in the past in IIO and it's a slow effort to merge the various very similar bindings. For now we are mostly keeping to within a vendor though unless a driver supports parts from multiple vendors. It potentially gets too confusing to maintain otherwise.
This one is easy case though so definitely merge as Krzystof suggested!
Jonathan